前言
Gopher协议在SSRF漏洞中的深入研究(附视频讲解) - 知乎 (zhihu.com)
上面这篇文章真的写的很好,是目前看过最好的将SSRF(服务端请求伪造)和Gopher协议的内容。
然后这种题型,我记得在之前的文章,金砖里有个云启的练习,用的就是SSRF漏洞+file协议,呜呜呜那时候还不知道是啥。现在回首原来如此。
2023有关金砖的练习题(云启平台) - 乙太的小屋 (52ying.top)
SSRF
环境的搭建
首先推荐的还是docker,我已经将搭建好的环境打包成了镜像推送到了云,可以直接拉取。
docker pull uniqueelven/ssrf:redis
docker pull uniqueelven/ssrf:php
docker pull uniqueelven/ssrf:mysql
主要就是由以上三部分内容构成的。以下附上ms08067的源码,我是看他的课程学习的,此文章做一个资源整合和总结
ersion: '2'
services:
php:
image: polinux/httpd-php
volumes:
- ./www:/var/www/html
networks:
- ssrf-ms08067
ports:
- "8082:80"
mysql:
image: vulhub/mysql:5.5.23
networks:
- ssrf-ms08067
ports:
- "3306"
redis:
image: vulhub/redis:4.0.14
networks:
- ssrf-ms08067
ports:
- "6379"
networks:
ssrf-ms08067:
driver: bridge
(踩个坑,以后redis最好像上面这样指定版本,因为我现在这个dokcer下载默认最新版的redis可能会出现无法成功运行的问题,我不知道为啥)
curl.php
<?php
$location=$_GET['path']; // Get the URL from the user.
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, $location); // Not validating the input. Trusting the location variable
curl_exec ($curl);
curl_close ($curl);
?>
index.php
<html>
<head>
<style> div.main { margin-left:auto; margin-right:auto; width:50%; } body { background-color: #f5f5f0; }</style>
<title>
Awesome Script!
</title>
</head>
<body>
<div class="main">
<h1>Welcome to the Awesome Script</h1>
<p>Here you will be able to load any page you want. You won't have to worry about revealing your IP anymore! We use the cURL library in order to perform the HTTP requests. Have fun!</p>
<br>
<form method="GET" action="curl.php">
<input type="text" value="Website to load..." name="path">
<input type="submit" value="Submit">
</form>
</div>
</body>
</html>
关于docker的启动可以看我前面关于docker介绍的文章。
题目复现
访问页面,尝试访问本机内部的flag文件,可以成功访问
使用命令docker inspect ID
可以查看容器内部网卡等信息。
得到redis:172.19.0.4,php:172.19.0.3,mysql:172.19.0.2
通过burp抓包发现,没有内容的时候返回信息长度是2,有返回信息时候就不是,比如下面有端口打开,就是这样的。
通过长度关键信息,我们可以写探测脚本:
#!/usr/bin/python3
# -*- coding-utf-8 -*-
import requests
import optparse
def portscan(targetURL, scout):
# 待检测端口
ports