---恢復內容開始---
# 背景 *** *** 今天我們換一個方式來分析這個漏洞,從滲透的角度去搞。滲透過程
測試漏洞
先來看看,觀察URL是:http://192.168.195.195/bWAPP/phpi.php
message像是有鏈接,點擊看看
在查看url是http://192.168.195.195/bWAPP/phpi.php?message=test,GET型參數,burp掃一下
感覺不對,怎么可能只有Flash跨域紅紅的,目測這個地方是echo xxxx,猜測代碼:
<?php
echo $_GET["message"];
?>
可是這樣哪里來的代碼注入啊,難道message有問題,測試phpinfo(),果然有問題
那就可以看代碼了,執行message=system("cat phpi.php > phpi.txt") ,請求一下phpi.txt
我們來看代碼:
代碼設計
<?php
if(isset($_REQUEST["message"]))
{
// If the security level is not MEDIUM or HIGH
if($_COOKIE["security_level"] != "1" && $_COOKIE["security_level"] != "2")
{
?>
<p><i><?php @eval ("echo " . $_REQUEST["message"] . ";");?></i></p>
<?php
}
// If the security level is MEDIUM or HIGH
else
{
?>
<p><i><?php echo htmlspecialchars($_REQUEST["message"], ENT_QUOTES, "UTF-8");;?></i></p>
<?php
}
}
?>
卧槽,什么鬼竟然用了eval,這個可是執行代碼內容的函數,類似的還有asset、preg_replace、call_user_func, call_user_func_array,array_map等等,這其中還包括thinkphp5-RCE的罪魁禍首函數哈哈。中級和高級過濾了,使用了htmlspecialchars函數就OK了