自学内容网 自学内容网

SSRF正则绕过1+SSRF文件读取

[题目信息]:

题目名称题目难度
SSRF正则绕过11

[题目考点]:

SSRF正则绕过1

[Flag格式]:

SangFor{5IbCdntb9LqcbhdQZszyr8wnZ2Uhdj6i}

[环境部署]:

docker-compose.yml文件或者docker tar原始文件。

docker-compose up -d

[题目writeup]:

1、实验主页

2、使用dirsearch扫描网站目录

python dirsearch.py -u http://分配IP -e php

3、扫描到文件flag.php,访问flag.php文件

4、提示仅可以本地访问

5、代码中要求http格式为

host中以Sang开头
结尾为for

6、因此利用@、.符号和?号绕过正则匹配。

7、至此获得flag,实验结束。





[题目信息]:

题目名称题目难度
SSRF文件读取1

[题目考点]:

SSRF文件读取

[Flag格式]:

SangFor{Ux5uIUUb5un08PWtsabg5mqF2oTCY8kg}

[环境部署]:

docker-compose.yml文件或者docker tar原始文件。

docker-compose up -d

[题目writeup]:

1、题目主页

2、点击提交查询

3、题目源码

<?php 
if(!$_GET['site']){ 
$str = <<<EOD
<html> 
<body> 
look source code: 
<form action='' method='GET'> 
<input type='submit' name='submit' /> 
<input type='text' name='site' style="width:1000px" value="https://www.baidu.com"/> 
</form>
</body>
</html>
EOD;

echo $str;
die();
}

$url = $_GET[‘site’];
$url_schema = parse_url($url);
$host = $url_schema[‘host’];
$request_url = $url."/";

if ($host !== ‘www.baidu.com’){
die(“wrong site”);
}

$ci = curl_init();
curl_setopt($ci, CURLOPT_URL, $request_url);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($ci);
curl_close($ci);

if($res){
echo "<h1>Source Code:</h1>";
echo $request_url;
echo "<hr />";
echo htmlentities($res);
}else{
echo "get source failed";
}

?>

4、利用file协议读取/etc/passwd文件

  • 用file协议读取本地文件
  • 绕过逻辑中对host的检查, curl是支持file://host/path, file://path这两种形式, 但是即使有host, curl仍然会访问到本地的文件
  • 截断url后面拼接的/, GET请求, 用?#都可以

5、Payload:

file://www.baidu.com/etc/passwd?

6、成功访问passwd文件,至此实验结束。

passwd读取成功,思考如何读取flag文件!


原文地址:https://blog.csdn.net/asdfaa/article/details/125938811

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!