forked from xmendez/wfuzz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayloads.py
209 lines (153 loc) · 4.08 KB
/
payloads.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
import encoders
import copy
import random
####### SUPERCLASS
class payload:
def __init__(self):
self.__count=0
pass
def __iter__ (self):
return payload_iterator()
def count(self):
return self.__count
class payload_iterator:
def __init__(self):
pass
def next (self):
raise StopIteration
######################################
######################################
######## Inheritances
######################################
######################################
class payload_file (payload):
def __init__(self,file):
payload.__init__(self)
self.file=file
f=open(file,"r")
self.__count=len(f.readlines())
f.close()
def count(self):
return self.__count
def __iter__ (self):
return file_iterator(self.file)
class file_iterator (payload_iterator):
def __init__(self,file):
payload_iterator.__init__(self)
self.file=open (file,"r")
def next (self):
line=self.file.next().strip()
return line
################### RANGE PAYLOAD
class payload_range (payload):
def __init__(self,range,width=0): ## range example --> "23-56"
payload.__init__(self)
try:
ran=range.split("-")
self.minimum=int(ran[0])
self.maximum=int(ran[1])
self.__count=self.maximum - self.minimum
self.width=width
except:
raise Exception, "Bad range format (eg. \"23-56\")"
def count(self):
return self.__count
def __iter__ (self):
return range_iterator(self.minimum,self.maximum,self.width)
class range_iterator (payload_iterator):
def __init__(self,min,max,width):
payload_iterator.__init__(self)
self.minimum=min
self.maximum=max
self.width=width
self.current=self.minimum
def next (self):
if self.current>self.maximum:
raise StopIteration
if self.width:
payl="%0"+str(self.width)+"d"
payl=payl % (self.current)
else:
payl=str(self.current)
self.current+=1
return payl
################### HEXRANGE PAYLOAD
class payload_hexrange (payload):
def __init__(self,range): ## range example --> "0-ffa"
payload.__init__(self)
try:
ran=range.split("-")
self.minimum=int(ran[0],16)
self.maximum=int(ran[1],16)
self.__count=self.maximum - self.minimum
except:
raise Exception, "Bad range format (eg. \"0-ffa\")"
def __iter__ (self):
return hexrange_iterator(self.minimum,self.maximum)
def count(self):
return self.__count
class hexrange_iterator (payload_iterator):
def __init__(self,min,max):
payload_iterator.__init__(self)
self.minimum=min
self.maximum=max
self.current=self.minimum
def next (self):
if self.current>self.maximum:
raise StopIteration
lgth=len(hex(self.maximum).replace("0x",""))
pl="%"+str(lgth)+"s"
num=hex(self.current).replace("0x","")
pl= pl % (num)
payl=pl.replace(" ","0")
self.current+=1
return payl
class payload_hexrand (payload):
def __init__(self,range): ## range example --> "0-ffa"
payload.__init__(self)
try:
ran=range.split("-")
self.minimum=int(ran[0],16)
self.maximum=int(ran[1],16)
self.__count=self.maximum - self.minimum
except:
raise Exception, "Bad range format (eg. \"0-ffa\")"
def __iter__ (self):
return hexrand_iterator(self.minimum,self.maximum)
def count(self):
return self.__count
class hexrand_iterator (payload_iterator):
def __init__(self,min,max):
payload_iterator.__init__(self)
self.minimum=min
self.maximum=max
self.current=self.minimum
def next (self):
self.current = random.SystemRandom().randint(self.minimum,self.maximum)
lgth=len(hex(self.maximum).replace("0x",""))
pl="%"+str(lgth)+"s"
num=hex(self.current).replace("0x","")
pl= pl % (num)
payl=pl.replace(" ","0")
return payl
######################### PAYLOAD LIST
class payload_list (payload):
def __init__(self,list):
payload.__init__(self)
self.list=list
self.__count=len(list)
def __iter__ (self):
return plist_iterator(self.list)
def count(self):
return self.__count
class plist_iterator (list):
def __init__(self,list):
self.list=list
self.current=0
def next (self):
try:
elem=self.list[self.current]
self.current+=1
return elem
except:
raise StopIteration