Created
June 14, 2017 16:11
-
-
Save atucom/eabf35f344f46ffbd2f8d25b018f88c9 to your computer and use it in GitHub Desktop.
Bulk Import Raw IPs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Written by John Mocuta (@atucom) with help from Jared McLaren (@jared_mclaren) | |
#This Burp Plugin allows the user to load many Raw IPs at once without Burp automatically | |
#adding regexes or modying them in any way. | |
#Import Burp Objects | |
from burp import IBurpExtender, IHttpListener, IBurpExtenderCallbacks, ITab | |
#Import Python Objects | |
import json | |
#Import Java GUI Objects | |
from java.awt import Dimension, FlowLayout | |
from javax.swing import JPanel, JLabel, JTextField, JTextArea, JButton, Box, BoxLayout, JFileChooser | |
from javax.swing.filechooser import FileNameExtensionFilter | |
from java.io import File | |
class BurpExtender (IBurpExtender, ITab): | |
# Extention information | |
EXT_NAME = "Bulk Raw IP Import" | |
EXT_DESC = "This plugin imports an raw list of bulk IPs to Burp's target scope" | |
EXT_AUTHOR = "John Mocuta" | |
# Output info to the Extensions console and register Burp API functions | |
def registerExtenderCallbacks(self, callbacks): | |
print "Name: \t\t" + BurpExtender.EXT_NAME | |
print "Description: \t" + BurpExtender.EXT_DESC | |
print "Author: \t" + BurpExtender.EXT_AUTHOR | |
self._callbacks = callbacks | |
self._helpers = callbacks.getHelpers() | |
callbacks.setExtensionName(BurpExtender.EXT_NAME) | |
#Create panels used for layout; we must stack and layer to get the desired GUI | |
self._jMainPanel = Box(BoxLayout.Y_AXIS) | |
self._jRow1 = JPanel(FlowLayout()) | |
self._jRow2 = JPanel(FlowLayout()) | |
self._jRow3 = JPanel(FlowLayout()) | |
self._jRow4 = JPanel(FlowLayout()) | |
#Create a button to trigger a function that builds the file handler in the main panel | |
self._jfileImportBtn = JButton("Import File...", actionPerformed=self.fileBrowse) | |
self._jfileLoadBtn = JButton("Load to Burp Target Scope", actionPerformed=self.loadScope) | |
#Two basic labels and input fields, and a custom function to load saved settings | |
self._jfirstLbl = JLabel("Enter list of IPs:") | |
self._jfirstTxt = JTextArea("",18,50) | |
self._jinstructLbl = JLabel("The below IPs will be appended to your current Target Scope when you hit 'Load to Burp Target Scope'") | |
self._jRow1.add(self._jinstructLbl) | |
self._jRow2.add(self._jfirstLbl) | |
self._jRow2.add(self._jfirstTxt) | |
self._jRow3.add(self._jfileImportBtn) | |
self._jRow3.add(self._jfileLoadBtn) | |
#Build the contents of the main panel | |
self._jMainPanel.add(self._jRow4) | |
self._jMainPanel.add(self._jRow1) | |
self._jMainPanel.add(self._jRow2) | |
self._jMainPanel.add(self._jRow3) | |
#Register the panel in the Burp GUI | |
callbacks.customizeUiComponent(self._jMainPanel) | |
callbacks.addSuiteTab(self) | |
return | |
def fileBrowse(self, e): | |
jfile = JFileChooser() | |
filter = FileNameExtensionFilter("JSON Configuration Files", ["json"]) | |
jfile.addChoosableFileFilter(filter) | |
ret = jfile.showDialog(self._jMainPanel, "Choose File") | |
if ret == JFileChooser.APPROVE_OPTION: | |
file = jfile.getSelectedFile() | |
text = self.readFile(file) | |
if self._jfirstTxt.getText(): | |
self._jfirstTxt.setText(self._jfirstTxt.getText() + "\n" + text) | |
else: | |
self._jfirstTxt.setText(text) | |
def readFile(self, file): | |
return open(file.getCanonicalPath(), "r").read() | |
def loadScope(self, e): | |
ipList = self._jfirstTxt.getText().split("\n") | |
dictJson = json.loads(self._callbacks.saveConfigAsJson()) | |
for ip in ipList: | |
if len(ip) >= 7: | |
newip = {"enabled":True, "host":ip.strip(), "protocol":"any"} | |
dictJson['target']['scope']['include'].append(newip) | |
self._callbacks.loadConfigFromJson(json.dumps(dictJson)) | |
# Standard function: Set the tab name | |
def getTabCaption(self): | |
return BurpExtender.EXT_NAME | |
# Standard function: Set the GUI component in the tab | |
def getUiComponent(self): | |
return self._jMainPanel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment