-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathGenerateForcedBrowseWordlist.py
100 lines (87 loc) · 3.37 KB
/
GenerateForcedBrowseWordlist.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
__author__ = 'Jake Miller (@LaconicWolf)'
__date__ = '20190226'
__version__ = '0.01'
__description__ = """\
Burp Extension that extracts the filenames from URLs in
scope or from a selected host. Just right click on the
hosts pane in the sitemap and click 'Generate forced
browsing wordlist' for either selected items or all hosts
in scope. The output will appear in the extender tab, where
you can set configure the extension to output to the system console,
save to a file, or show in the UI.
Blog post explaining all the code in detail:
https://laconicwolf.com/2019/03/09/burp-extension-python-tutorial-generate-a-forced-browsing-wordlist/
"""
from burp import IBurpExtender, IContextMenuFactory
from java.util import ArrayList
from javax.swing import JMenuItem
import threading
import sys
try:
from exceptions_fix import FixBurpExceptions
except ImportError:
pass
class BurpExtender(IBurpExtender, IContextMenuFactory):
def registerExtenderCallbacks(self, callbacks):
sys.stdout = callbacks.getStdout()
self.callbacks = callbacks
self.helpers = callbacks.getHelpers()
self.callbacks.setExtensionName("Forced Browsing Wordlist Generator")
callbacks.registerContextMenuFactory(self)
return
def createMenuItems(self, invocation):
self.context = invocation
menuList = ArrayList()
menuItem = JMenuItem("Generate forced browsing wordlist from selected items",
actionPerformed=self.createWordlistFromSelected)
menuList.add(menuItem)
menuItem = JMenuItem("Generate forced browsing wordlist from all hosts in scope",
actionPerformed=self.createWordlistFromScope)
menuList.add(menuItem)
return menuList
def createWordlistFromSelected(self, event):
self.fromScope = False
t = threading.Thread(target=self.createWordlist)
t.daemon = True
t.start()
def createWordlistFromScope(self, event):
self.fromScope = True
t = threading.Thread(target=self.createWordlist)
t.daemon = True
t.start()
def createWordlist(self):
httpTraffic = self.context.getSelectedMessages()
hostUrls = []
for traffic in httpTraffic:
try:
hostUrls.append(str(traffic.getUrl()))
except UnicodeEncodeError:
continue
urllist = []
siteMapData = self.callbacks.getSiteMap(None)
for entry in siteMapData:
requestInfo = self.helpers.analyzeRequest(entry)
url = requestInfo.getUrl()
try:
decodedUrl = self.helpers.urlDecode(str(url))
except Exception as e:
continue
if self.fromScope and self.callbacks.isInScope(url):
urllist.append(decodedUrl)
else:
for url in hostUrls:
if decodedUrl.startswith(str(url)):
urllist.append(decodedUrl)
filenamelist = []
for entry in urllist:
filenamelist.append(entry.split('/')[-1].split('?')[0])
for word in sorted(set(filenamelist)):
if word:
try:
print word
except UnicodeEncodeError:
continue
try:
FixBurpExceptions()
except:
pass