目录遍历(CTFHub)

发布时间 2023-11-28 23:59:26作者: 44556677

1.F12检查

 

 2.编写遍历目录寻找flag的脚本

import requests
#主目录
url="http://challenge-79752210ab0468b5.sandbox.ctfhub.com:10800/flag_in_here/"
#普通目录
urlothers="http://challenge-79752210ab0468b5.sandbox.ctfhub.com:10800/flag_in_here/1/1/"
#获取普通目录下的响应内容
textothers=requests.get(urlothers)
#计算其文本长度
lengthothers=len(textothers.text)
for i in range(1,5):
    for j in range(1,5):
        #遍历子目录
        urlkid=url+f'{i}/{j}/'
        #子目录响应内容
        textkid=requests.get(urlkid)
        #子目录文本长度
        lengthkid=len(textkid.text)
        #比对当前子目录和普通子目录的长度
        #当二者不同时可能包含有flag
        if(lengthothers!=lengthkid):
            print(urlkid)

3.运行结果

 4.双击打开

 4.找到flag: