forked from xmendez/wfuzz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayloads.py
397 lines (326 loc) · 9.19 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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
import random
import sys
import __builtin__
from externals.moduleman.plugin import moduleman_plugin
from framework.core.myexception import FuzzException
from framework.fuzzer.base import wfuzz_iterator
from framework.plugins.api import search_bing
@wfuzz_iterator
@moduleman_plugin("count", "next", "__iter__")
class file:
name = "file"
description = "Returns each word from a file."
category = ["default"]
priority = 99
def __init__(self, filename):
try:
self.f = open(filename,"r")
except IOError:
raise FuzzException(FuzzException.FATAL, "Error opening file")
self.__count = len(self.f.readlines())
self.f.seek(0)
def next (self):
return self.f.next().strip()
def count(self):
return self.__count
def __iter__ (self):
return self
@wfuzz_iterator
@moduleman_plugin("count", "next", "__iter__")
class range:
name = "range"
description = "Returns each number of the given range. ie. 0-10"
category = ["default"]
priority = 99
def __init__(self, whatrange): ## range example --> "23-56"
try:
ran = whatrange.split("-")
self.minimum = int(ran[0])
self.maximum = int(ran[1])
self.__count = self.maximum - self.minimum + 1
self.width = len(ran[0])
self.current = self.minimum
except:
raise FuzzException(FuzzException.FATAL, "Bad range format (eg. \"23-56\")")
def next(self):
if self.current>self.maximum:
raise StopIteration
else:
if self.width:
payl = "%0"+ str(self.width) + "d"
payl = payl % (self.current)
else:
payl = str(self.current)
self.current += 1
return payl
def count(self):
return self.__count
def __iter__(self):
return self
@wfuzz_iterator
@moduleman_plugin("count", "next", "__iter__")
class hexrange:
name = "hexrange"
description = "Returns each hex number of the given hex range. ie. 00-ff"
category = ["default"]
priority = 99
def __init__(self, prange): ## range example --> "0-ffa"
try:
ran = prange.split("-")
self.minimum = int(ran[0],16)
self.maximum = int(ran[1],16)
self.__count = self.maximum - self.minimum + 1
self.current = self.minimum
except:
raise Exception, "Bad range format (eg. \"0-ffa\")"
def __iter__(self):
return self
def count(self):
return self.__count
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
@wfuzz_iterator
@moduleman_plugin("count", "next", "__iter__")
class hexrand:
name = "hexrand"
description = "Returns random hex numbers."
category = ["default"]
priority = 99
def __init__(self, prange): ## range example --> "0-ffa"
try:
ran = prange.split("-")
self.minimum=int(ran[0],16)
self.maximum=int(ran[1],16)
self.__count=-1
except:
raise Exception, "Bad range format (eg. \"0-ffa\")"
def __iter__ (self):
return self
def count(self):
return self.__count
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
@wfuzz_iterator
@moduleman_plugin("count", "next", "__iter__")
class buffer_overflow:
name = "buffer_overflow"
description = "Returns a string using the following pattern A * given number."
category = ["default"]
priority = 99
def __init__(self, n):
self.l = ['A' * int(n)]
self.current = 0
def __iter__(self):
return self
def count(self):
return 1
def next (self):
if self.current == 0:
elem = self.l[self.current]
self.current+=1
return elem
else:
raise StopIteration
@wfuzz_iterator
@moduleman_plugin("count", "next", "__iter__")
class list:
name = "list"
description = "Returns each element of the given word list separated by -. ie word1-word2"
category = ["default"]
priority = 99
def __init__(self, l):
if l.find("\\") >= 0:
l = l.replace("\\-", "$SEP$")
l = l.replace("\\\\", "$SCAP$")
self.l = l.split("-")
for i in __builtin__.range(len(self.l)):
self.l[i] = self.l[i].replace("$SEP$", "-")
self.l[i] = self.l[i].replace("$SCAP$", "\\")
else:
self.l = l.split("-")
self.__count = len(self.l)
self.current = 0
def __iter__ (self):
return self
def count(self):
return self.__count
def next (self):
if self.current >= self.__count:
raise StopIteration
else:
elem = self.l[self.current]
self.current += 1
return elem
@wfuzz_iterator
@moduleman_plugin("count", "next", "__iter__")
class stdin:
name = "stdin"
description = "Returns each item read from stdin."
category = ["default"]
priority = 99
def __init__(self, deprecated):
# stdin is unseekable
self.__count = -1
#self.__count=len(sys.stdin.readlines())
#sys.stdin.seek(0)
def count(self):
return self.__count
def __iter__ (self):
return self
def next (self):
#line=sys.stdin.next().strip().split(':')
line = sys.stdin.next().strip()
return line
@wfuzz_iterator
@moduleman_plugin("count", "next", "__iter__")
class names:
name = "names"
description = "Returns possible usernames by mixing the given words, separated by -, using known typical constructions. ie. jon-smith"
category = ["default"]
priority = 99
def __init__(self, startnames):
self.startnames = startnames
from sets import Set
possibleusernames = []
name = ""
llist = self.startnames.split("-")
for x in llist:
if name == "":
name = name + x
else:
name = name + " " + x
if " " in name:
parts = name.split()
possibleusernames.append(parts[0])
possibleusernames.append(parts[0]+"."+parts[1])
possibleusernames.append(parts[0]+parts[1])
possibleusernames.append(parts[0]+"."+parts[1][0])
possibleusernames.append(parts[0][0]+"."+parts[1])
possibleusernames.append(parts[0]+parts[1][0])
possibleusernames.append(parts[0][0]+parts[1])
str1=""
str2=""
str3=""
str4=""
for i in __builtin__.range(0,len(parts)-1):
str1=str1+parts[i]+"."
str2=str2+parts[i]
str3=str3+parts[i][0]+"."
str4=str4+parts[i][0]
str5=str1+parts[-1]
str6=str2+parts[-1]
str7=str4+parts[-1]
str8=str3+parts[-1]
str9=str2+parts[-1][0]
str10=str4+parts[-1][0]
possibleusernames.append(str5)
possibleusernames.append(str6)
possibleusernames.append(str7)
possibleusernames.append(str8)
possibleusernames.append(str9)
possibleusernames.append(str10)
possibleusernames.append(parts[-1])
possibleusernames.append(parts[0]+"."+parts[-1])
possibleusernames.append(parts[0]+parts[-1])
possibleusernames.append(parts[0]+"."+parts[-1][0])
possibleusernames.append(parts[0][0]+"."+parts[-1])
possibleusernames.append(parts[0]+parts[-1][0])
possibleusernames.append(parts[0][0]+parts[-1])
else:
possibleusernames.append(name)
self.creatednames=possibleusernames
self.__count=len(possibleusernames)
def count(self):
return self.__count
def __iter__(self):
return self
def next(self):
if self.creatednames:
payl = self.creatednames.pop()
return payl
else:
raise StopIteration
@wfuzz_iterator
@moduleman_plugin("count", "next", "__iter__")
class permutation:
name = "permutation"
description = "Returns permutations of the given charset and length. ie. abc-2"
category = ["default"]
priority = 99
def __init__(self, prange): ## range example --> "abcdef-4"
self.charset = []
try:
ran = prange.split("-")
self.charset = ran[0]
self.width = int(ran[1])
except:
raise Exception, "Bad range format (eg. \"abfdeg-3\")"
pset = []
for x in self.charset:
pset.append(x)
words = self.xcombinations(pset, self.width)
self.lista = []
for x in words:
self.lista.append(''.join(x))
self.__count = len(self.lista)
def __iter__ (self):
return self
def count(self):
return self.__count
def next (self):
if self.lista != []:
payl=self.lista.pop()
return payl
else:
raise StopIteration
def xcombinations(self, items, n):
if n == 0:
yield []
else:
try:
for i in xrange(len(items)):
for cc in self.xcombinations(items[:i] + items[i:], n - 1):
yield [items[i]] + cc
except:
print "Interrupted Permutation calculations"
sys.exit()
@wfuzz_iterator
@moduleman_plugin("count", "next", "__iter__")
class bing:
'''
Some examples of bing hacking:
- http://www.elladodelmal.com/2010/02/un-poco-de-bing-hacking-i-de-iii.html
'''
name = "bing"
description = "Returns URL results of a given bing API search (needs api key). ie, intitle:\"JBoss JMX Management Console\"-10"
category = ["default"]
priority = 99
def __init__(self, dork):
self.l = search_bing(dork)
self.__count = len(self.l)
self.current = 0
def __iter__ (self):
return self
def count(self):
return self.__count
def next (self):
if self.current >= self.__count:
raise StopIteration
else:
elem = self.l[self.current]['Url']
self.current += 1
return str(elem.strip())