Skip to content

Commit

Permalink
Added option to reload the scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
n4irda committed Sep 16, 2021
1 parent 4a29f4a commit 4db2a18
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
43 changes: 26 additions & 17 deletions BurpScripthon.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import time
import json
import importlib
import imp

from burp import IBurpExtender, ITab

Expand Down Expand Up @@ -74,9 +75,9 @@ class Script(Box):

rexp = '.*'

def _on_load(self, *args):
def _on_load(self, reload=False):
if exists(SCRIPTS_DIR + '/' + self._s_name.text):
self.tab_panel._import_script(self.id, self._s_name.text)
self.tab_panel._import_script(self.id, self._s_name.text, reload)
self.notification_label.text = " "
else:
self.notification_label.text = "File not exist."
Expand All @@ -97,7 +98,11 @@ def __init__(self, *args, **kwargs):
self.setBorder(BorderFactory.createEmptyBorder(20, 10, 20, 10))

self.load_btn = JButton('load')
self.load_btn.addActionListener(self._on_load)
self.load_btn.addActionListener(lambda *x: self._on_load())

self.rload_btn = JButton("reload")
self.rload_btn.addActionListener(lambda *x: self._on_load(reload=True))

self.remove_btn = JButton('Remove')
self.remove_btn.setBackground(Color(255, 80, 80))
self.remove_btn.addActionListener(
Expand All @@ -118,23 +123,25 @@ def __init__(self, *args, **kwargs):
script_input.add(self._s_name)
script_input.add(self.active_btn)
script_input.add(self.load_btn)
script_input.add(self.rload_btn)
script_input.add(self.remove_btn)
script_input.add(Box.createHorizontalGlue())

self.notification_label = JLabel("")
self.notification_label = JLabel(" ")
self.notification_label.setForeground(Color.RED)
notification_box = Box.createHorizontalBox()
notification_box.add(Box.createHorizontalStrut(80))
notification_box.add(self.notification_label)
notification_box.add(Box.createHorizontalGlue())

self.add(script_input)
self.add(notification_box)
self.add(JSeparator())
self.add(notification_box)

btn_box = Box.createHorizontalBox()
btn_box.add(self.remove_btn)
btn_box.add(Box.createHorizontalGlue())
self.add(btn_box)
# btn_box = Box.createHorizontalBox()
# btn_box.add(self.remove_btn)
# btn_box.add(Box.createHorizontalGlue())
# self.add(btn_box)


class SettingsPanel(Box):
Expand Down Expand Up @@ -358,10 +365,15 @@ def __init__(self, extender, scripthon_inst, *args, **kwargs):
# arguments:
# s_id: (int) id of script.
# s_name: (str) name of script.
def _import_script(self, s_id, s_name):
def _import_script(self, s_id, s_name, reload=False):
if exists(SCRIPTS_DIR + '/' + s_name) and s_name[-3:] == ".py":
try:
self.imports[s_id] = importlib.import_module(s_name.split('.py')[0])
if reload:
self.imports[s_id] = imp.reload(self.imports[s_id])
else:
self.imports[s_id] = importlib.import_module(
s_name.split('.py')[0]
)
except ImportError as e:
self._error_log.text += str(e) + "\n"

Expand Down Expand Up @@ -516,9 +528,8 @@ def proxy_listener(self, isRequest, interceptdProxyMessage):

if isRequest:
dt = self.bHelpers.analyzeRequest(httpMsg)
# rid = len(ss.data["table"]) + 1
# self._ids_map[interceptdProxyMessage.messageReference] = rid
ss.data["table"][rid] = [rid, dt.getMethod(), str(dt.getUrl())]
t_rid = len(ss.data["table"]) + 1
ss.data["table"][rid] = [t_rid, dt.getMethod(), str(dt.getUrl())]

# process request with scripts
for script in self.script_panel.scripts:
Expand Down Expand Up @@ -678,13 +689,11 @@ def getUiComponent(self):
class BurpExtender(IBurpExtender):

def registerExtenderCallbacks(self, callbacks):
# keep a reference to our callbacks object

self._callbacks = callbacks

# obtain an extension helpers object
self._helpers = callbacks.getHelpers()

# set our extension name
callbacks.setExtensionName("BurpScripthon")

callbacks.addSuiteTab(BurpScripthonTab(self))
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ they both take two arguments called `HttpMessageInfo` and `extension`.
```

- BurpScripthon include a copy of BeautifulSoup4, you can use it in your script with
`import bs4
`import bs4`


### Examples.
Expand Down

0 comments on commit 4db2a18

Please sign in to comment.