Skip to content

Instantly share code, notes, and snippets.

@nlf
Created September 6, 2016 20:15
Show Gist options
  • Save nlf/fea5b4932819c1589eb486d602e2a16f to your computer and use it in GitHub Desktop.
Save nlf/fea5b4932819c1589eb486d602e2a16f to your computer and use it in GitHub Desktop.
from burp import IBurpExtender, ITab
from javax import swing
import os
class BurpExtender(IBurpExtender, ITab):
def registerExtenderCallbacks(self, callbacks):
self._callbacks = callbacks
self._callbacks.setExtensionName("Markdown Exporter")
self.tab = swing.JPanel()
self.layout = swing.GroupLayout(self.tab)
self.tab.setLayout(self.layout)
self.layout.setAutoCreateGaps(True)
self.layout.setAutoCreateContainerGaps(True)
self.filter_label = swing.JLabel("Filter:")
self.filter_option = swing.ButtonGroup()
self.filter_inscope = swing.JRadioButton("in scope", actionPerformed = self.option_change)
self.filter_inscope.setSelected(True)
self.filter_option.add(self.filter_inscope)
self.filter_custom = swing.JRadioButton("custom prefix", actionPerformed = self.option_change)
self.filter_option.add(self.filter_custom)
self.filter_prefix = swing.JTextField()
self.filter_prefix.setEnabled(False)
self.file_output = swing.JFileChooser()
self.export_button = swing.JButton("Export ...", actionPerformed = self.export)
self.layout.setHorizontalGroup(
self.layout.createSequentialGroup()
.addComponent(self.filter_label)
.addComponent(self.filter_inscope)
.addComponent(self.filter_custom)
.addGroup(self.layout.createParallelGroup(swing.GroupLayout.Alignment.TRAILING)
.addComponent(self.filter_prefix, 512, 512, 512)
.addComponent(self.export_button)
)
)
self.layout.setVerticalGroup(
self.layout.createSequentialGroup()
.addGroup(self.layout.createParallelGroup(swing.GroupLayout.Alignment.BASELINE)
.addComponent(self.filter_label)
.addComponent(self.filter_inscope)
.addComponent(self.filter_custom)
.addComponent(self.filter_prefix)
)
.addGroup(self.layout.createParallelGroup()
.addComponent(self.export_button)
)
)
self._callbacks.customizeUiComponent(self.tab)
self._callbacks.addSuiteTab(self)
def getUiComponent(self):
return self.tab
def getTabCaption(self):
return "Markdown Exporter"
def option_change(self, event):
if self.filter_custom.isSelected():
self.filter_prefix.setEnabled(True)
else:
self.filter_prefix.text = ""
self.filter_prefix.setEnabled(False)
return
def export(self, event):
if self.file_output.showSaveDialog(self.tab) <> swing.JFileChooser.APPROVE_OPTION:
return
filename = self.file_output.getSelectedFile().getAbsolutePath()
if not filename.endswith(".md"):
filename = filename + ".md"
if os.path.isfile(filename):
os.remove(filename)
with open(filename, "w") as f:
prefix = ""
if self.filter_custom.isSelected():
prefix = self.filter_prefix.text
issues = self._callbacks.getScanIssues(prefix)
for issue in issues:
if self.filter_inscope.isSelected() and not self._callbacks.isInScope(issue.getUrl()):
continue
f.write("# " + issue.getIssueName() + "\n")
f.write("\n")
f.write("## Severity: " + issue.getSeverity() + "\n")
f.write("\n")
f.write("## Overview:\n")
background = issue.getIssueBackground()
detail = issue.getIssueDetail()
if background is not None:
f.write(background + "\n")
if detail is not None:
f.write(detail + "\n")
f.write("\n")
f.write("## Recommendations:\n")
fix = issue.getRemediationBackground()
fix_detail = issue.getRemediationDetail()
if fix is not None:
f.write(fix + "\n")
if fix_detail is not None:
f.write(fix_detail + "\n")
f.write("\n")
f.write("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment