class BurpExtender(IBurpExtender, IExtensionStateListener, IHttpListener, IProxyListener, ITab): def registerExtenderCallbacks(self, callbacks): self.callbacks = callbacks self.helpers = callbacks.helpers self.scriptpane = JTextPane() self.scriptpane.setFont(Font('Monospaced', Font.PLAIN, 11)) self.scrollpane = JScrollPane() self.scrollpane.setViewportView(self.scriptpane) self._code = compile('', '<string>', 'exec') self._script = '' callbacks.registerExtensionStateListener(self) callbacks.registerProxyListener(self) callbacks.customizeUiComponent(self.getUiComponent()) callbacks.addSuiteTab(self) self.scriptpane.requestFocus() def extensionUnloaded(self): try: self.callbacks.saveExtensionSetting( 'script', base64.b64encode(self._script)) except Exception: traceback.print_exc(file=self.callbacks.getStderr()) return def processProxyMessage(self, messageIsRequest, message): try: globals_ = {'extender': self, 'callbacks': self.callbacks, 'helpers': self.helpers } locals_ = {'messageIsRequest': messageIsRequest, 'message': message } exec(self.script, globals_, locals_) except Exception: traceback.print_exc(file=self.callbacks.getStderr()) return def getTabCaption(self): return 'Script' def getUiComponent(self): return self.scrollpane @property def script(self): end = self.scriptpane.document.length _script = self.scriptpane.document.getText(0, end) if _script == self._script: return self._code self._script = _script self._code = compile(_script, '<string>', 'exec') return self._code
class Tablas_Caracteres_Especiales(JFrame): def __init__(self): super(Tablas_Caracteres_Especiales, self).__init__() self.window() def window(self): self.setTitle("Tablas Caracteres") self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) self.setLayout(None) self.setLocationRelativeTo(None) self.setVisible(True) def config(): self.barra = JScrollPane() self.Tab_Caracteres_Especiales = JTable() nombre = ["nombre", "apeM", "apeP"] datos = ["victor", "esau", "cholo"] self.Tab_Caracteres_Especiales = JTable(datos, nombre) self.Tab_Caracteres_Especiales.addRow(datos) # self.Tab_Caracteres_Especiales.setFont(Font("Tahoma", 0, 14)); # NOI18N self.barra.setViewportView(self.Tab_Caracteres_Especiales) #TODO: imcompleto se nesita una array y python maneja listas :( self.getContentPane().add(self.barra) self.barra.setBounds(0, 0, 929, 574) self.setBounds(0, 0, 939, 604)
class ConsoleTab(ITab): def __init__(self, burp): self.burp = burp self.log = burp.log self.config = burp.config self.caption = burp.loadExtensionSetting(*settings.CONSOLE_CAPTION) self.scrollpane = JScrollPane() self.console = Console(burp) self.scrollpane.setViewportView(self.console.textpane) self.burp.addSuiteTab(self) self.burp.customizeUiComponent(self.getUiComponent()) def getUiComponent(self): return self.scrollpane def getTabCaption(self): return self.caption @property def interpreter(self): return self.console.interp
class BurpExtender(IBurpExtender, IContextMenuFactory, ITab): def registerExtenderCallbacks(self, callbacks): self.callbacks = callbacks self.helpers = callbacks.helpers self.console = Console(self, namespace={ 'callbacks': callbacks, 'helpers': callbacks.helpers, }) self.scrollpane = JScrollPane() self.scrollpane.setViewportView(self.console.textpane) callbacks.setExtensionName("Jython Console") callbacks.addSuiteTab(self) callbacks.registerContextMenuFactory(self) callbacks.customizeUiComponent(self.getUiComponent()) def getUiComponent(self): return self.scrollpane def getTabCaption(self): return "Console" def createMenuItems(self, invocation): menus = [] messages = invocation.getSelectedMessages() if messages: items = self.interpreter.getLocals().get('items', []) context = 'Assign' if not items else 'Append' menu = JMenuItem("%s to local variable items in Console" % (context, )) menu.addActionListener(AssignLocalsActionListener(self, 'items', messages)) menus.append(menu) return menus @property def interpreter(self): return self.console.interp
def _initUI(self): frame = JFrame('Simple popup', defaultCloseOperation=JFrame.DISPOSE_ON_CLOSE, size=(300, 300)) frame.setLayout(BoxLayout(frame.contentPane, BoxLayout.PAGE_AXIS)) # Call-back to close popup def closeDialog(event): frame.visible = False frame.dispose() # Instantiate components self.text_area = JTextArea() msgScroller = JScrollPane() msgScroller.setBorder(BorderFactory.createTitledBorder("Accounts")) msgScroller.setViewportView(self.text_area) self.close_button = JButton('Close', actionPerformed=closeDialog) # Add components to frame frame.add(msgScroller) frame.add(self.close_button) frame.visible = True
class ConsoleTab(ITab): def __init__(self, burp): self.burp = burp self.log = burp.log self.config = burp.config self.caption = burp.loadExtensionSetting(*settings.CONSOLE_CAPTION) self.scrollpane = JScrollPane() self.console = Console(burp) self.scrollpane.setViewportView(self.console.textpane) self.burp.addSuiteTab(self) self.burp.customizeUiComponent(self.getUiComponent()) def getUiComponent(self): return self.scrollpane def getTabCaption(self): return self.caption @property def interpreter(self): return self.console.interp
def __init__(self, payload=None, label=None): if not label: label = "PayloadView" self.this = JPanel() self.this.setLayout(BorderLayout()) # Add a label self.this.add(BorderLayout.PAGE_START, JLabel(label)) # Create textarea here and add to the JPanel scrollPane = JScrollPane() self._textarea = JTextArea() self._textarea.setColumns(20) self._textarea.setRows(5) self._textarea.setLineWrap(True) self._textarea.setWrapStyleWord(True) self._textarea.setEditable(True) self._textarea.setName("TextArea") self._textarea.setSelectionColor(Color(255, 153, 51)) self._textarea.requestFocus() scrollPane.setViewportView(self._textarea) self.this.add(BorderLayout.CENTER, scrollPane) self.refresh(payload)
def __init__(self, ui): JSplitPane.__init__(self, JSplitPane.HORIZONTAL_SPLIT) self._ui = ui # create the executor object self._executor = Executor(self, ui.callbacks) #### # start Left Top split layout jLeftTopPanel = JPanel() jMenuPanel = JPanel() #Load button self.jLoad = JButton(Strings.jLoad_text) self.jLoad.addActionListener(self) #File name text field self.jFileName = JTextField(Strings.jFileName_default, 30) self.jFileName.setHorizontalAlignment(JTextField.CENTER) self.jFileName.setEditable(False) #Save button self.jSave = JButton(Strings.jSave_text) self.jSave.addActionListener(self) #Exit button self.jExit = JButton(Strings.jExit_text) self.jExit.addActionListener(self) #Wiki button (URL) self.jWiki = JButton(Strings.jWiki_title) self.jWiki.setToolTipText(Strings.jWiki_tooltip) self.jWiki.addActionListener(self) # make it borderless self.jWiki.setBorder(EmptyBorder(0, 0, 0, 0)) self.jWiki.setBorderPainted(False) self.jWiki.setContentAreaFilled(False) #Console text area jConsoleText = JTextArea() jConsoleText.setEditable(0) jConsoleText.setWrapStyleWord(1) jConsoleText.setRows(10) #set initial text jConsoleText.setText(Strings.jConsoleText_help) #make scrollable jScrollConsolePane = JScrollPane() jScrollConsolePane.setViewportView(jConsoleText) jMenuPanelLayout = GroupLayout(jMenuPanel) jMenuPanel.setLayout(jMenuPanelLayout) jMenuPanelLayout.setHorizontalGroup( jMenuPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING). addGroup(jMenuPanelLayout.createSequentialGroup().addContainerGap( ).addComponent(self.jLoad).addComponent( self.jFileName).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED).addComponent( self.jSave).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED). addComponent(self.jWiki).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED).addComponent( self.jExit).addContainerGap())) jMenuPanelLayout.setVerticalGroup( jMenuPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGroup( jMenuPanelLayout.createSequentialGroup().addGroup( jMenuPanelLayout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.jLoad).addComponent( self.jFileName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.jSave).addComponent( self.jWiki).addComponent( self.jExit)))) jLeftTopPanelLayout = GroupLayout(jLeftTopPanel) jLeftTopPanel.setLayout(jLeftTopPanelLayout) jLeftTopPanelLayout.setHorizontalGroup( jLeftTopPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addComponent( jMenuPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE).addComponent( jScrollConsolePane, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, 32767)) jLeftTopPanelLayout.setVerticalGroup( jLeftTopPanelLayout. createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( GroupLayout.Alignment.TRAILING, jLeftTopPanelLayout.createSequentialGroup().addComponent( jMenuPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED).addComponent( jScrollConsolePane, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, 32767))) # end Left Top split layout #### #### # start Left Down split layout jLeftDownPanel = JPanel() jMenu2Panel = JPanel() #Clear button self.jClear = JButton(Strings.jClear_text) self.jClear.setToolTipText(Strings.jClear_tooltip) self.jClear.addActionListener(self) #Run button self.jRun = JButton(Strings.jRun_text) self.jRun.setToolTipText(Strings.jRun_tooltip) self.jRun.addActionListener(self) #Variables text area jVarsPane = JTextPane() jVarsPane.setFont(Font('Monospaced', Font.PLAIN, 11)) jVarsPane.addFocusListener(self) # set initial value jVarsPane.setText(Strings.jVarsPane_header) # make scrollable jScrollpaneLeftDown = JScrollPane() jScrollpaneLeftDown.setViewportView(jVarsPane) jMenu2PanelLayout = GroupLayout(jMenu2Panel) jMenu2Panel.setLayout(jMenu2PanelLayout) jMenu2PanelLayout.setHorizontalGroup( jMenu2PanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGroup( jMenu2PanelLayout.createSequentialGroup().addContainerGap( ).addComponent(self.jClear).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED, 100, 32767).addComponent(self.jRun).addContainerGap())) jMenu2PanelLayout.setVerticalGroup( jMenu2PanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGroup( jMenu2PanelLayout.createSequentialGroup().addGroup( jMenu2PanelLayout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.jClear).addComponent(self.jRun)))) jLeftDownPanelLayout = GroupLayout(jLeftDownPanel) jLeftDownPanel.setLayout(jLeftDownPanelLayout) jLeftDownPanelLayout.setHorizontalGroup( jLeftDownPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addComponent( jMenu2Panel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE).addComponent( jScrollpaneLeftDown, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, 32767)) jLeftDownPanelLayout.setVerticalGroup( jLeftDownPanelLayout. createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( GroupLayout.Alignment.TRAILING, jLeftDownPanelLayout.createSequentialGroup().addComponent( jMenu2Panel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED).addComponent( jScrollpaneLeftDown, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, 32767))) # end Left Down split layout #### #### # start Left layout jSplitPaneLeft = JSplitPane(JSplitPane.VERTICAL_SPLIT, jLeftTopPanel, jLeftDownPanel) jSplitPaneLeft.setDividerLocation(300) # end Left layout #### #### # start Right layout jScriptPane = JTextPane() jScriptPane.setFont(Font('Monospaced', Font.PLAIN, 11)) # set initial value jScriptPane.setText(Strings.jScriptPane_header) #jScriptPane.addMouseListener(self) jScrollPaneRight = JScrollPane() jScrollPaneRight.setViewportView(jScriptPane) # end Right layout #### self.setLeftComponent(jSplitPaneLeft) self.setRightComponent(jScrollPaneRight) self.setDividerLocation(450) #Exported variables self.jConsoleText = jConsoleText self.jScrollConsolePane = jScrollConsolePane self.jScriptPane = jScriptPane self.jVarsPane = jVarsPane
class NBPanel(): """Represents the converted frame from NetBeans.""" # mostly converted generated code def __init__(self): self.jScrollPane1 = JScrollPane() self.jTable1 = JTable() self.jPanel1 = JPanel() self.labelName = JLabel() self.textName = JTextField() self.labelSeverity = JLabel() self.comboSeverity = None self.labelHost = JLabel() self.labelPath = JLabel() self.textHost = JTextField() self.textPath = JTextField() self.tabIssue = JTabbedPane() self.panelDescription = JPanel() self.panelRequest = JPanel() self.panelResponse = JPanel() self.panelRemediation = JPanel() # setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE) # setting up the table # initial data in the table tableData = [ [3, "Issue3", "Severity3", "Host3", "Path3"], [1, "Issue1", "Severity1", "Host1", "Path1"], [2, "Issue2", "Severity2", "Host2", "Path2"], ] tableHeadings = ["#", "Issue Type/Name", "Severity", "Host", "Path"] from IssueTable import IssueTable self.jTable1 = IssueTable(tableData, tableHeadings) # wrap the table in a scrollpane self.jScrollPane1.setViewportView(self.jTable1) # top panel containing the table from java.awt import Color self.jPanel1.setBorder(BorderFactory.createLineBorder(Color(0, 0, 0))) # create the labels and textfields self.labelName.text = "Issue Type/Name" self.textName.text = "Issue Name/Type" self.textName.editable = False self.labelSeverity.text = "Severity" # create and populate the combobox self.comboSeverity = JComboBox( ["Critical", "High", "Medium", "Low", "Info"]) self.labelHost.text = "Host" self.labelPath.text = "Path" self.textHost.text = "Issue Host" self.textHost.editable = False self.textPath.text = "Issue Path" self.textPath.editable = False from java.lang import Short # description panel panelDescriptionLayout = GroupLayout(self.panelDescription) self.panelDescription.setLayout(panelDescriptionLayout) panelDescriptionLayout.setHorizontalGroup( panelDescriptionLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE)) panelDescriptionLayout.setVerticalGroup( panelDescriptionLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE)) self.tabIssue.addTab("Description", self.panelDescription) # request tab panelRequestLayout = GroupLayout(self.panelRequest) self.panelRequest.setLayout(panelRequestLayout) panelRequestLayout.setHorizontalGroup( panelRequestLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE)) panelRequestLayout.setVerticalGroup( panelRequestLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE)) self.tabIssue.addTab("Request", self.panelRequest) # response tab panelResponseLayout = GroupLayout(self.panelResponse) self.panelResponse.setLayout(panelResponseLayout) panelResponseLayout.setHorizontalGroup( panelResponseLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE)) panelResponseLayout.setVerticalGroup( panelResponseLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE)) self.tabIssue.addTab("Response", self.panelResponse) # remediation tab panelRemediationLayout = GroupLayout(self.panelRemediation) self.panelRemediation.setLayout(panelRemediationLayout) panelRemediationLayout.setHorizontalGroup( panelRemediationLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE)) panelRemediationLayout.setVerticalGroup( panelRemediationLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE)) self.tabIssue.addTab("Remediation", self.panelRemediation) # jpanel1? jPanel1Layout = GroupLayout(self.jPanel1) self.jPanel1.setLayout(jPanel1Layout) jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING). addGroup(jPanel1Layout.createSequentialGroup().addContainerGap( ).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.LEADING). addGroup(jPanel1Layout.createSequentialGroup().addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.TRAILING).addComponent( self.labelHost).addComponent( self.labelSeverity).addComponent( self.labelName) ).addPreferredGap( LayoutStyle.ComponentPlacement.UNRELATED).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.LEADING). addComponent(self.textName).addGroup( jPanel1Layout.createSequentialGroup().addComponent( self.comboSeverity, GroupLayout.PREFERRED_SIZE, 98, GroupLayout.PREFERRED_SIZE).addGap( 0, 0, Short.MAX_VALUE)). addGroup( jPanel1Layout.createSequentialGroup().addComponent( self.textHost, GroupLayout.PREFERRED_SIZE, 330, GroupLayout.PREFERRED_SIZE).addGap(18, 18, 18). addComponent(self.labelPath).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED ).addComponent(self.textPath)))).addComponent( self.tabIssue)).addContainerGap())) jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING). addGroup(jPanel1Layout.createSequentialGroup().addContainerGap( ).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.labelName).addComponent( self.textName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.labelSeverity).addComponent( self.comboSeverity, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.labelHost).addComponent( self.labelPath).addComponent( self.textHost, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.textPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)). addPreferredGap( LayoutStyle.ComponentPlacement.RELATED).addComponent( self.tabIssue).addContainerGap())) # create the main panel self.panel = JPanel() layout = GroupLayout(self.panel) self.panel.setLayout(layout) layout.setAutoCreateGaps(True) layout.setHorizontalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( layout.createSequentialGroup().addContainerGap().addGroup( layout.createParallelGroup( GroupLayout.Alignment.LEADING).addComponent( self.jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent( self.jScrollPane1)).addContainerGap())) layout.setVerticalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( layout.createSequentialGroup().addContainerGap().addComponent( self.jScrollPane1, GroupLayout.PREFERRED_SIZE, 119, GroupLayout.PREFERRED_SIZE).addGap( 18, 18, 18).addComponent(self.jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addContainerGap()))
class NBPanel(): """Represents the converted frame from NetBeans.""" # mostly converted generated code def __init__(self): self.jScrollPane1 = JScrollPane() self.jTable1 = JTable() self.jPanel1 = JPanel() self.labelName = JLabel() self.textName = JTextField() self.labelSeverity = JLabel() self.comboSeverity = None self.labelHost = JLabel() self.labelPath = JLabel() self.textHost = JTextField() self.textPath = JTextField() self.tabIssue = JTabbedPane() self.panelDescription = JPanel() self.panelRequest = JPanel() self.panelResponse = JPanel() self.panelRemediation = JPanel() # setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE) # setting up the table # initial data in the table tableData = [[None, None, None, None, None], [None, None, None, None, None], [None, None, None, None, None]] tableColumns = ["#", "Issue Type/Name", "Severity", "Host", "Path"] # create the table model tableModel = table.DefaultTableModel(tableData, tableColumns) # model.types = array.array([java.lang.Integer.class, java.lang.String.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class], java.lang.Class) # model.canEdit = array.array([False, False, False, False, False], java.lang.Boolean) # public Class getColumnClass(int columnIndex) { # return types [columnIndex] # } # # public boolean isCellEditable(int rowIndex, int columnIndex) { # return canEdit [columnIndex] # } # set the table model # if this fails, we have to use self.jTable1.setModel(tableModel) self.jTable1.setAutoCreateRowSorter(True) # wrap the table in a scrollpane self.jScrollPane1.setViewportView(self.jTable1) # top panel containing the table from java.awt import Color self.jPanel1.setBorder(BorderFactory.createLineBorder(Color(0, 0, 0))) # create the labels and textfields self.labelName.text = "Issue Type/Name" self.textName.text = "Issue Name/Type" self.labelSeverity.text = "Severity" # create and populate the combobox self.comboSeverity = JComboBox( ["Critical", "High", "Medium", "Low", "Info"]) self.labelHost.text = "Host" self.labelPath.text = "Path" self.textHost.text = "Issue Host" self.textPath.text = "Issue Path" from java.lang import Short # description panel panelDescriptionLayout = GroupLayout(self.panelDescription) self.panelDescription.setLayout(panelDescriptionLayout) panelDescriptionLayout.setHorizontalGroup( panelDescriptionLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE)) panelDescriptionLayout.setVerticalGroup( panelDescriptionLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE)) self.tabIssue.addTab("Description", self.panelDescription) # request tab panelRequestLayout = GroupLayout(self.panelRequest) self.panelRequest.setLayout(panelRequestLayout) panelRequestLayout.setHorizontalGroup( panelRequestLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE)) panelRequestLayout.setVerticalGroup( panelRequestLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE)) self.tabIssue.addTab("Request", self.panelRequest) # response tab panelResponseLayout = GroupLayout(self.panelResponse) self.panelResponse.setLayout(panelResponseLayout) panelResponseLayout.setHorizontalGroup( panelResponseLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE)) panelResponseLayout.setVerticalGroup( panelResponseLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE)) self.tabIssue.addTab("Response", self.panelResponse) # remediation tab panelRemediationLayout = GroupLayout(self.panelRemediation) self.panelRemediation.setLayout(panelRemediationLayout) panelRemediationLayout.setHorizontalGroup( panelRemediationLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE)) panelRemediationLayout.setVerticalGroup( panelRemediationLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE)) self.tabIssue.addTab("Remediation", self.panelRemediation) # jpanel1? jPanel1Layout = GroupLayout(self.jPanel1) self.jPanel1.setLayout(jPanel1Layout) jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING). addGroup(jPanel1Layout.createSequentialGroup().addContainerGap( ).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.LEADING). addGroup(jPanel1Layout.createSequentialGroup().addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.TRAILING).addComponent( self.labelHost).addComponent( self.labelSeverity).addComponent( self.labelName) ).addPreferredGap( LayoutStyle.ComponentPlacement.UNRELATED).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.LEADING). addComponent(self.textName).addGroup( jPanel1Layout.createSequentialGroup().addComponent( self.comboSeverity, GroupLayout.PREFERRED_SIZE, 98, GroupLayout.PREFERRED_SIZE).addGap( 0, 0, Short.MAX_VALUE)). addGroup( jPanel1Layout.createSequentialGroup().addComponent( self.textHost, GroupLayout.PREFERRED_SIZE, 330, GroupLayout.PREFERRED_SIZE).addGap(18, 18, 18). addComponent(self.labelPath).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED ).addComponent(self.textPath)))).addComponent( self.tabIssue)).addContainerGap())) jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING). addGroup(jPanel1Layout.createSequentialGroup().addContainerGap( ).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.labelName).addComponent( self.textName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.labelSeverity).addComponent( self.comboSeverity, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.labelHost).addComponent( self.labelPath).addComponent( self.textHost, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.textPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)). addPreferredGap( LayoutStyle.ComponentPlacement.RELATED).addComponent( self.tabIssue).addContainerGap())) # create the main panel self.panel = JPanel() layout = GroupLayout(self.panel) self.panel.setLayout(layout) layout.setAutoCreateGaps(True) layout.setHorizontalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( layout.createSequentialGroup().addContainerGap().addGroup( layout.createParallelGroup( GroupLayout.Alignment.LEADING).addComponent( self.jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent( self.jScrollPane1)).addContainerGap())) layout.setVerticalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( layout.createSequentialGroup().addContainerGap().addComponent( self.jScrollPane1, GroupLayout.PREFERRED_SIZE, 119, GroupLayout.PREFERRED_SIZE).addGap( 18, 18, 18).addComponent(self.jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addContainerGap()))
class BurpExtender(IBurpExtender, IExtensionStateListener, IHttpListener, IProxyListener, ITab): def registerExtenderCallbacks(self, callbacks): self.callbacks = callbacks self.helpers = callbacks.helpers self.scriptpane = JTextPane() self.scriptpane.setFont(Font('Monospaced', Font.PLAIN, 11)) self.scrollpane = JScrollPane() self.scrollpane.setViewportView(self.scriptpane) self._code = compile('', '<string>', 'exec') self._script = '' callbacks.registerExtensionStateListener(self) callbacks.registerProxyListener(self) callbacks.customizeUiComponent(self.getUiComponent()) callbacks.addSuiteTab(self) self.scriptpane.requestFocus() def extensionUnloaded(self): try: self.callbacks.saveExtensionSetting('script', base64.b64encode(self._script)) except Exception: traceback.print_exc(file=self.callbacks.getStderr()) return def processProxyMessage(self, messageIsRequest, message): try: globals_ = { 'extender': self, 'callbacks': self.callbacks, 'helpers': self.helpers } locals_ = { 'messageIsRequest': messageIsRequest, 'message': message } exec(self.script, globals_, locals_) except Exception: traceback.print_exc(file=self.callbacks.getStderr()) return def getTabCaption(self): return 'Script' def getUiComponent(self): return self.scrollpane @property def script(self): end = self.scriptpane.document.length _script = self.scriptpane.document.getText(0, end) if _script == self._script: return self._code self._script = _script self._code = compile(_script, '<string>', 'exec') return self._code
def _initializeGui(self, callbacks): tab = JPanel() jLabel1 = JLabel("Original Hash:") jLabel2 = JLabel("Original message:") jLabel3 = JLabel("Message to append:") jLabel5 = JLabel("Max key length:") jTextField1 = JTextField("") jTextField2 = JTextField("") jTextField3 = JTextField("") jTextField4 = JTextField("128") jLabel4 = JLabel("Hashing functions") jCheckBox1 = JCheckBox("MD4") jCheckBox2 = JCheckBox("MD5") jCheckBox3 = JCheckBox("SHA1") jCheckBox4 = JCheckBox("SHA256") jCheckBox5 = JCheckBox("SHA512") jCheckBox1.setEnabled(False) jCheckBox2.setEnabled(False) jCheckBox3.setEnabled(False) jCheckBox4.setEnabled(False) jCheckBox5.setEnabled(False) jScrollPane1 = JScrollPane() jTable1 = JTable() jButton1 = JButton("Generate", actionPerformed=self.generate_attack) jButton1.setEnabled(False) jButton2 = JButton("Copy messages", actionPerformed=self.copy_messages) jButton3 = JButton("Copy hashes", actionPerformed=self.copy_hashes) self._tab = tab self._textfields = { "original_hash": jTextField1, "original_msg": jTextField2, "append_msg": jTextField3, "max_key_len": jTextField4, } self._checkboxes = { md4: jCheckBox1, md5: jCheckBox2, sha1: jCheckBox3, sha256: jCheckBox4, sha512: jCheckBox5, } self._table = jTable1 self._extensions = {} self._hashes, self._messages = [], [] # Hash field change event jTextField1.getDocument().addDocumentListener( HashChangeListener(self._checkboxes, self._textfields['original_hash'], jButton1)) # Table columns jTable1.setModel( DefaultTableModel([], ["#", "Type", "New Message", "Hash"])) jScrollPane1.setViewportView(jTable1) # Table column width jTable1.getColumnModel().getColumn(0).setMaxWidth(50) jTable1.getColumnModel().getColumn(1).setMaxWidth(60) layout = GroupLayout(tab) tab.setLayout(layout) layout.setHorizontalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( layout.createSequentialGroup().addGap(24, 24, 24).addGroup( layout.createParallelGroup( GroupLayout.Alignment.TRAILING).addComponent(jLabel5). addComponent(jLabel1).addComponent(jLabel2). addComponent(jLabel3)).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED).addGroup( layout.createParallelGroup( GroupLayout.Alignment.LEADING).addComponent( jTextField3, GroupLayout.DEFAULT_SIZE, 425, 32767).addComponent(jTextField2). addComponent(jTextField1).addGroup( layout.createSequentialGroup().addComponent( jTextField4, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE).addGap( 0, 0, 32767))).addGap(30, 30, 30). addGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING). addGroup(layout.createSequentialGroup( ).addComponent(jCheckBox1).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED ).addComponent(jCheckBox2).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED ).addComponent(jCheckBox3).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED ).addComponent(jCheckBox4).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED).addComponent( jCheckBox5)).addComponent(jLabel4).addGroup( layout.createSequentialGroup().addComponent( jButton1).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED ).addComponent(jButton3).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED ).addComponent(jButton2))).addGap( 167, 167, 167)).addComponent(jScrollPane1)) layout.setVerticalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( layout.createSequentialGroup().addGap(26, 26, 26).addGroup( layout.createParallelGroup(GroupLayout.Alignment.BASELINE). addComponent(jLabel1).addComponent( jTextField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(jLabel4)). addPreferredGap( LayoutStyle.ComponentPlacement.RELATED).addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( jTextField2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE). addComponent(jLabel2).addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( jCheckBox2).addComponent(jCheckBox3). addComponent(jCheckBox1).addComponent(jCheckBox4). addComponent(jCheckBox5))).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED). addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( jTextField3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(jLabel3) ).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED).addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE). addComponent(jLabel5).addComponent( jTextField4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(jButton2). addComponent(jButton3).addComponent(jButton1)).addGap( 13, 13, 13).addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 971, 32767))) callbacks.customizeUiComponent(tab) callbacks.addSuiteTab(self)
class MainPanel(): """Represents the converted frame from NetBeans.""" # default issue to populate the panel with defaultIssue = Issue(name="Name", severity="Critical", host="Host", path="Path", description="Description", remediation="", reqResp=RequestResponse(request="default request", response="default response")) def loadPanel(self, issue): # type: (Issue) -> () """Populates the panel with issue.""" if issue is None: return # check if the input is the correct object assert isinstance(issue, Issue) # add selected issue to the panel to enable right-click stuff. self.selectedIssue = issue # set textfields and textareas self.textName.text = issue.name self.textHost.text = issue.host self.textPath.text = issue.path self.textAreaDescription.text = issue.description self.textAreaRemediation.text = issue.remediation self.textSeverity.text = issue.severity # request and response tabs self.panelRequest.setMessage(issue.getRequest(), True) self.panelResponse.setMessage(issue.getResponse(), False) # button actions def newIssueAction(self, event): """Pops up a frame to add a new issue.""" frm = NewIssueDialog(callbacks=self.callbacks, title="New Issue") frm.display(self) def gotNewIssue(self, issue): """got a new issue.""" self.tableIssue.addRow(issue) def editIssue(self, index, issue): """Issue has been edited.""" self.tableIssue.editRow(index, issue) def deleteIssueAction(self, event): """Delete the currently selected issue.""" # this is the button # btn = event.getSource() row = self.tableIssue.getTableSelectedRow() # YOLO self.tableIssue.deleteRow(row) # it works! def exportAction(self, event): """Export everything in the table to a file.""" lastDir = "" try: # load the last used directory # this will probably change as we will use a base64 encoded json as the complete config? lastDir = self.callbacks.loadExtensionSetting("lastDir") except: # if there is not a last used directory in the settings, continue pass from Utils import saveFileDialog, writeFile selectedFile, usedDirectory = saveFileDialog(parent=self.panel, startingDir=lastDir, title="Export Issues", extension="json") if selectedFile is not None: # write to the file writeFile(selectedFile.getAbsolutePath(), self.tableIssue.exportIssues()) if usedDirectory is not None: # overwrite the last used directory self.callbacks.saveExtensionSetting("lastDir", usedDirectory) def importAction(self, event): """Import a file to the table.""" lastDir = "" try: # load the last used directory # this will probably change as we will use a base64 encoded json as the complete config? lastDir = self.callbacks.loadExtensionSetting("lastDir") except: # if there is not a last used directory in the settings, continue pass from Utils import openFileDialog selectedFile, usedDirectory = openFileDialog(parent=self.panel, startingDir=lastDir, title="Import Issues", extension="json") # save the last directory self.callbacks.saveExtensionSetting("lastDir", usedDirectory) fi = open(selectedFile.getAbsolutePath(), "r") # read the file and create a list of Issues import json # newIssues = json.load(fi, object_hook=dictToIssue) # problem here is object_hook runs for every single object so newIssues # will have internal objects, even if we tag them from RequestResponse import RequestResponse, HttpService from base64 import b64decode issuesArray = json.load(fi) # now issuesArray is an array of dicts. # manual JSON deserialization - move this to a method/function? # also think about what happens if dictionaries are missing items newIssues = list() for eachissue in issuesArray: # now we have each issue # what if dictionaries are missing items? ht = HttpService( host=eachissue["reqResp"]["httpService"]["host"], port=eachissue["reqResp"]["httpService"]["port"], protocol=eachissue["reqResp"]["httpService"]["protocol"]) rr = RequestResponse( request=b64decode(eachissue["reqResp"]["request"]), response=b64decode(eachissue["reqResp"]["response"]), comment=eachissue["reqResp"]["comment"], highlight=eachissue["reqResp"]["highlight"], httpService=ht) iss = Issue(name=eachissue["name"], severity=eachissue["severity"], host=eachissue["host"], path=eachissue["path"], description=eachissue["description"], remediation=eachissue["remediation"], reqResp=rr) # iss = Issue() # rr = RequestResponse() # ht = HttpService() newIssues.append(iss) # clear the table self.tableIssue.clear() # add the issues to the table # for iss in newIssues: # self.tableIssue.addRow(iss) self.tableIssue.populate(newIssues) def newIssueFromBurp(self, invocation): """Create a New Issue from the context menu.""" from Utils import getPath, bytesToString, burpToolName reqResp = invocation.getSelectedMessages()[0] host = str(reqResp.getHttpService()) path = getPath(self.callbacks, reqResp) convertedReqResp = RequestResponse() convertedReqResp.fromIHttpRequestResponse(reqResp) tmpIssue = Issue(host=host, path=path, reqResp=convertedReqResp) # change the title to "New Issue from [TOOL]"? frameTitle = "New Issue from %s" % (burpToolName( invocation.getToolFlag())) frm = NewIssueDialog(callbacks=self.callbacks, issue=tmpIssue, title=frameTitle # , modality="application" ) frm.display(self) # FOCUS! frm.requestFocus() # print self.callbacks.getHelpers().bytesToString(reqResp[0].getRequest()) # mostly converted generated code def __init__(self, callbacks, table=None): self.callbacks = callbacks self.jScrollPane1 = JScrollPane() self.jPanel1 = JPanel() self.labelName = JLabel("Name") self.textName = JTextField() self.labelSeverity = JLabel("Severity") self.textSeverity = JTextField() self.labelHost = JLabel("Host") self.labelPath = JLabel("Path") self.textHost = JTextField() self.textPath = JTextField() self.tabIssue = JTabbedPane() self.textAreaDescription = JTextArea() self.textAreaRemediation = JTextArea() # JScrollPanes to hold the two jTextAreas # put the textareas in JScrollPanes self.jsPaneDescription = JScrollPane(self.textAreaDescription) self.jsPaneRemediation = JScrollPane(self.textAreaRemediation) self.panelRequest = self.callbacks.createMessageEditor(None, False) self.panelResponse = self.callbacks.createMessageEditor(None, False) self.loadPanel(self.defaultIssue) # buttons self.buttonNewIssue = JButton("New Issue", actionPerformed=self.newIssueAction) self.buttonDeleteIssue = JButton( "Delete Issue", actionPerformed=self.deleteIssueAction) self.buttonImport = JButton("Import", actionPerformed=self.importAction) self.buttonExport = JButton("Export", actionPerformed=self.exportAction) if table is not None: self.tableIssue = table else: from IssueTable import IssueTable self.tableIssue = IssueTable() # wrap the table in a scrollpane self.jScrollPane1.setViewportView(self.tableIssue) # top panel containing the table from java.awt import Color self.jPanel1.setBorder(BorderFactory.createLineBorder(Color(0, 0, 0))) # create the labels and textfields self.textName.editable = False self.textName.setBackground(Color.LIGHT_GRAY) self.textSeverity.editable = False self.textSeverity.setBackground(Color.LIGHT_GRAY) self.textHost.editable = False self.textHost.setBackground(Color.LIGHT_GRAY) self.textPath.editable = False self.textPath.setBackground(Color.LIGHT_GRAY) # description textarea self.textAreaDescription.editable = False self.textAreaDescription.setLineWrap(True) self.textAreaDescription.setWrapStyleWord(True) self.tabIssue.addTab("Description", self.jsPaneDescription) # remediation textarea self.textAreaRemediation.editable = False self.textAreaRemediation.setLineWrap(True) self.textAreaRemediation.setWrapStyleWord(True) self.tabIssue.addTab("Remediation", self.jsPaneRemediation) # request tab self.panelRequest.setMessage("", True) self.tabIssue.addTab("Request", self.panelRequest.getComponent()) # response tab self.panelResponse.setMessage("", False) self.tabIssue.addTab("Response", self.panelResponse.getComponent()) # from java.lang import Short # jpanel1 is the bottom panel jPanel1Layout = GroupLayout(self.jPanel1) self.jPanel1.setLayout(jPanel1Layout) jPanel1Layout.setHorizontalGroup( # GroupLayout.Alignment.CENTER centers the group, in this case it # centers the buttons jPanel1Layout.createParallelGroup( GroupLayout.Alignment.CENTER ).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap( ).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.LEADING). addGroup(jPanel1Layout.createSequentialGroup().addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.TRAILING).addComponent( self.labelHost).addComponent(self.labelName) ).addPreferredGap( LayoutStyle.ComponentPlacement.UNRELATED).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.LEADING).addGroup( jPanel1Layout.createSequentialGroup( ).addComponent(self.textName).addPreferredGap( LayoutStyle.ComponentPlacement.UNRELATED). addComponent( self.labelSeverity).addPreferredGap( LayoutStyle.ComponentPlacement. RELATED).addComponent( self.textSeverity, GroupLayout.PREFERRED_SIZE, 186, GroupLayout.PREFERRED_SIZE)). addGroup( jPanel1Layout.createSequentialGroup().addComponent( self.textHost, GroupLayout.PREFERRED_SIZE, 330, GroupLayout.PREFERRED_SIZE).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED ).addComponent(self.labelPath).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED). addComponent(self.textPath)))).addComponent( self.tabIssue)).addContainerGap() ).addGroup( jPanel1Layout.createSequentialGroup().addComponent( self.buttonNewIssue).addComponent( self.buttonDeleteIssue).addComponent( self.buttonImport).addComponent( self.buttonExport))) # link size of buttons from javax.swing import SwingConstants jPanel1Layout.linkSize(SwingConstants.HORIZONTAL, [ self.buttonDeleteIssue, self.buttonExport, self.buttonImport, self.buttonNewIssue ]) jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup( ).addGroup( jPanel1Layout.createSequentialGroup().addContainerGap().addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.labelName).addComponent( self.textName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.labelSeverity).addComponent( self.textSeverity, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.textHost, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.labelPath).addComponent( self.textPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.labelHost)).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED) .addComponent(self.tabIssue).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED).addGroup( jPanel1Layout.createParallelGroup().addComponent( self.buttonNewIssue).addComponent( self.buttonDeleteIssue).addComponent( self.buttonImport).addComponent( self.buttonExport)).addContainerGap())) # create the main panel self.panel = JSplitPane(JSplitPane.VERTICAL_SPLIT) # set the top component self.panel.leftComponent = self.jScrollPane1 self.panel.rightComponent = self.jPanel1 self.panel.setDividerLocation(150)
class BurpExtender(IBurpExtender, ITab, IHttpListener): def registerExtenderCallbacks(self, callbacks): self._callbacks = callbacks self._helpers = callbacks.getHelpers() callbacks.setExtensionName("burp-sensitive-param-extractor") self._stdout = PrintWriter(callbacks.getStdout(), True) callbacks.registerHttpListener(self) #callbacks.registerMessageEditorTabFactory(self) print 'burp-sensitive-param-extractor loaded.\nAuthor:LSA\nhttps://github.com/theLSA/burp-sensitive-param-extractor' self.sensitiveParamR = getParamRegular() self._callbacks.customizeUiComponent(self.getUiComponent()) self._callbacks.addSuiteTab(self) #self.endColors = [] self.requestParamDict = {} self.resultSensitiveParamsDict = {} def getTabCaption(self): return 'BSPE' def processHttpMessage(self, toolFlag, messageIsRequest, messageInfo): if messageIsRequest and toolFlag == 4: self.requestParamDict['urlParams'] = [] self.requestParamDict['BodyParams'] = [] self.requestParamDict['cookieParams'] = [] self.requestParamDict['jsonParams'] = [] cookieParamFlag = 0 service = messageInfo.getHttpService() request = messageInfo.getRequest() analyzeReq = self._helpers.analyzeRequest(service, request) reqUrl = self._helpers.analyzeRequest(messageInfo).getUrl() reqMethod = self._helpers.analyzeRequest(messageInfo).getMethod() reqParams = analyzeReq.getParameters() for param in reqParams: paramType = param.getType() if paramType == 0: #self.outputTxtArea.append("\nurlParams-") paramName = param.getName() paramValue = param.getValue() print 'urlParams:' print paramName + ':' + paramValue #self.outputTxtArea.append("[%s]" % paramName) self.requestParamDict['urlParams'].append( paramName.strip()) if paramType == 1: #self.outputTxtArea.append("\nBodyParams-") paramName = param.getName() paramValue = param.getValue() print 'BodyParams:' print paramName + ':' + paramValue #self.outputTxtArea.append("[%s]\n" % paramName) self.requestParamDict['BodyParams'].append( paramName.strip()) if paramType == 2: #self.outputTxtArea.append("\ncookieParams-") paramName = param.getName() paramValue = param.getValue() print 'CookieParams:' print paramName + ':' + paramValue #self.outputTxtArea.append("[%s]\n" % paramName) self.requestParamDict['cookieParams'].append( paramName.strip()) cookieParamFlag = 1 if paramType == 6: #self.outputTxtArea.append("\njsonParams-") paramName = param.getName() paramValue = param.getValue() print 'JsonParams:' print paramName + ':' + paramValue #self.outputTxtArea.append("[%s]\n" % paramName) self.requestParamDict['jsonParams'].append( paramName.strip()) self.resultSensitiveParamsDict = self.findSensitiveParam( self.requestParamDict) #print self.resultSensitiveParamsDict for rspdKey in self.resultSensitiveParamsDict.keys(): if self.resultSensitiveParamsDict[rspdKey] != []: print "[%s][%s]" % (reqMethod, reqUrl) self.outputTxtArea.append( "\n------------------------------------------------------\n" ) self.outputTxtArea.append("[%s][%s]\n" % (reqMethod, reqUrl)) break for rspdKey in self.resultSensitiveParamsDict.keys(): if self.resultSensitiveParamsDict[rspdKey] != []: self.outputTxtArea.append( "\n" + rspdKey + "--" + str(self.resultSensitiveParamsDict[rspdKey])) self.write2file() #pass else: return def findSensitiveParam(self, requestParamDict): #sensitiveParamR = getParamRegular() resultSensitiveParamsDict = {} resultSensitiveParamsDict['urlParams'] = [] resultSensitiveParamsDict['BodyParams'] = [] resultSensitiveParamsDict['cookieParams'] = [] resultSensitiveParamsDict['jsonParams'] = [] #print requestParamDict for spr in self.sensitiveParamR: for key in requestParamDict.keys(): for reqParam in requestParamDict[key]: if len(spr) == 1: if spr == reqParam.lower(): resultSensitiveParamsDict[key].append(reqParam) else: if spr in reqParam.lower(): print spr + ' in ' + reqParam resultSensitiveParamsDict[key].append(reqParam) #print resultSensitiveParamsDict for key in resultSensitiveParamsDict.keys(): resultSensitiveParamsDict[key] = {}.fromkeys( resultSensitiveParamsDict[key]).keys() #resultSensitiveParamsDict[key] = sorted(resultSensitiveParamsDict[key],key=resultSensitiveParamsDict[key].index) #print resultSensitiveParamsDict return resultSensitiveParamsDict def write2file(self): sensitiveParamsList = getSensitiveParamsFromFile() newSensitiveParamsList = [] #print self.resultSensitiveParamsDict for rspdKey in self.resultSensitiveParamsDict.keys(): if (self.resultSensitiveParamsDict[rspdKey] != []) and (set( self.resultSensitiveParamsDict[rspdKey]).issubset( set(sensitiveParamsList)) == False): newSensitiveParamsList.extend([ newSensitiveParam for newSensitiveParam in self.resultSensitiveParamsDict[rspdKey] if newSensitiveParam not in sensitiveParamsList ]) #print str(newSensitiveParamsList) if newSensitiveParamsList != []: newSensitiveParamsList = {}.fromkeys(newSensitiveParamsList).keys() with open('sensitive-params.txt', 'a') as sps: for nsp in newSensitiveParamsList: #print 'writeNewParams:'+nsp sps.write('\n' + nsp) def addAndSaveNewParamRegular(self, event): NewParamRegular = self.addAndSaveNewParamRegularTextField.getText() if NewParamRegular not in self.sensitiveParamR: self.sensitiveParamR.append(NewParamRegular) with open(paramRegularFile, 'a') as prf: prf.write('\n' + NewParamRegular) self.alertSaveSuccess.showMessageDialog(self.spePanel, "Add and save success!") else: self.alertSaveSuccess.showMessageDialog(self.tab, "paramRegular existed.") self.sensitiveParamsRegularListPanel.setListData(self.sensitiveParamR) self.sensitiveParamsRegularListPanel.revalidate() #self.sensitiveParamR = getParamRegular() def delParamRegular(self, event): #delParamRegularsIndex = self.sensitiveParamsRegularListPanel.selectedIndex #if delParamRegularsIndex >= 0: # print delParamRegularsIndex # print self.sensitiveParamR[delParamRegularsIndex] for sprlp in self.sensitiveParamsRegularListPanel.getSelectedValuesList( ): #print sprlp self.sensitiveParamR.remove(sprlp) #with open(paramRegularFile,'r') as prf1: # lines = prf1.readlines() with open(paramRegularFile, 'w') as prf2: #print self.sensitiveParamsRegularListPanel.getSelectedValuesList() #for line in lines: # if line.strip() in self.sensitiveParamsRegularListPanel.getSelectedValuesList(): # print 'remove:'+line # lines.remove(line) #for spr1 in lines: # #print spr1 # prf2.write(spr1) for spr2i, spr2 in enumerate(self.sensitiveParamR): print spr2i print spr2 if spr2i == len(self.sensitiveParamR) - 1: prf2.write(spr2) else: prf2.write(spr2 + '\n') self.sensitiveParamsRegularListPanel.setListData(self.sensitiveParamR) self.sensitiveParamsRegularListPanel.revalidate() #self.sensitiveParamR = getParamRegular() def clearRst(self, event): self.outputTxtArea.setText("") def exportRst(self, event): chooseFile = JFileChooser() ret = chooseFile.showDialog(self.logPane, "Choose file") filename = chooseFile.getSelectedFile().getCanonicalPath() print "\n" + "Export to : " + filename open(filename, 'w', 0).write(self.outputTxtArea.text) def getUiComponent(self): self.spePanel = JPanel() self.spePanel.setBorder(None) self.spePanel.setLayout(None) self.logPane = JScrollPane() self.outputTxtArea = JTextArea() self.outputTxtArea.setFont(Font("Consolas", Font.PLAIN, 12)) self.outputTxtArea.setLineWrap(True) self.logPane.setViewportView(self.outputTxtArea) self.spePanel.add(self.logPane) self.clearBtn = JButton("Clear", actionPerformed=self.clearRst) self.exportBtn = JButton("Export", actionPerformed=self.exportRst) self.parentFrm = JFileChooser() self.spePanel.add(self.clearBtn) self.spePanel.add(self.exportBtn) self.logPane.setBounds(20, 50, 800, 600) self.clearBtn.setBounds(20, 650, 100, 30) self.exportBtn.setBounds(600, 650, 100, 30) self.sensitiveParamsRegularListPanel = JList(self.sensitiveParamR) self.sensitiveParamsRegularListPanel.setVisibleRowCount( len(self.sensitiveParamR)) #self.spePanel.add(self.sensitiveParamsRegularListPanel) #self.sensitiveParamsRegularListPanel.setBounds(850,50,150,600) self.sensitiveParamsRegularListScrollPanel = JScrollPane() self.sensitiveParamsRegularListScrollPanel.setViewportView( self.sensitiveParamsRegularListPanel) self.spePanel.add(self.sensitiveParamsRegularListScrollPanel) self.sensitiveParamsRegularListScrollPanel.setBounds(850, 50, 150, 600) self.addAndSaveNewParamRegularButton = JButton( 'add&&save', actionPerformed=self.addAndSaveNewParamRegular) self.spePanel.add(self.addAndSaveNewParamRegularButton) self.addAndSaveNewParamRegularButton.setBounds(1000, 50, 150, 30) self.addAndSaveNewParamRegularTextField = JTextField('NewParamRegular') self.spePanel.add(self.addAndSaveNewParamRegularTextField) self.addAndSaveNewParamRegularTextField.setBounds(1150, 50, 100, 30) self.alertSaveSuccess = JOptionPane() self.spePanel.add(self.alertSaveSuccess) self.delParamRegularButton = JButton( "delete", actionPerformed=self.delParamRegular) self.spePanel.add(self.delParamRegularButton) self.delParamRegularButton.setBounds(1000, 90, 100, 30) return self.spePanel
class BurpExtender(IBurpExtender, IIntruderPayloadGeneratorFactory, IExtensionStateListener, ITab): # # implement IBurpExtender # def registerExtenderCallbacks(self, callbacks): callbacks.registerExtensionStateListener(self) # 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("Super Payload") # register ourselves as a payload generator factory callbacks.registerIntruderPayloadGeneratorFactory(self) # the Super Payload UI self.scriptpane = JTextPane() self.scriptpane.setFont(Font('Monospaced', Font.PLAIN, 11)) self.scrollpane = JScrollPane() self.scrollpane.setViewportView(self.scriptpane) callbacks.customizeUiComponent(self.getUiComponent()) callbacks.addSuiteTab(self) self.scriptpane.requestFocus() # Compile the init script content self._code = compile('', '<string>', 'exec') self._script = '' script = callbacks.loadExtensionSetting('script') if script: script = base64.b64decode(script) self.scriptpane.document.insertString( self.scriptpane.document.length, script, SimpleAttributeSet()) self._script = script self._code = compile(script, '<string>', 'exec') return def createNewInstance(self, attack): return SuperGenerator(self, attack) def getGeneratorName(self): return "SuperPayload" def extensionUnloaded(self): try: self.callbacks.saveExtensionSetting('script', base64.b64encode(self._script)) except Exception: traceback.print_exc(file=self.callbacks.getStderr()) return def getTabCaption(self): return 'Super Payload Script' def getUiComponent(self): return self.scrollpane # Get the compiled code of user script (update or not) @property def script(self): end = self.scriptpane.document.length _script = self.scriptpane.document.getText(0, end) if _script == self._script: return self._code self._script = _script self._code = compile(_script, '<string>', 'exec') return self._code
class BurpExtender(IBurpExtender, ISessionHandlingAction, IExtensionStateListener, ITab): def registerExtenderCallbacks(self, callbacks): self.callbacks = callbacks self.helpers = callbacks.helpers self.scriptpane = JTextPane() self.scriptpane.setFont(Font('Monospaced', Font.PLAIN, 11)) self.scrollpane = JScrollPane() self.scrollpane.setViewportView(self.scriptpane) self._code = compile('', '<string>', 'exec') self._script = '' script = callbacks.loadExtensionSetting('script') if script: script = base64.b64decode(script) self.scriptpane.document.insertString( self.scriptpane.document.length, script, SimpleAttributeSet()) self._script = script self._code = compile(script, '<string>', 'exec') callbacks.registerExtensionStateListener(self) callbacks.customizeUiComponent(self.getUiComponent()) callbacks.registerSessionHandlingAction(self) callbacks.addSuiteTab(self) self.scriptpane.requestFocus() def extensionUnloaded(self): try: self.callbacks.saveExtensionSetting('script', base64.b64encode(self._script)) except Exception: traceback.print_exc(file=self.callbacks.getStderr()) return def getActionName(self): return "Custom Makro Python Script" def performAction(self, currentRequest, macroItems): try: globals_ = { 'extender': self, 'callbacks': self.callbacks, 'helpers': self.helpers, 'IBurpCollaboratorClientContext': IBurpCollaboratorClientContext, 'IBurpCollaboratorInteraction': IBurpCollaboratorInteraction, 'IBurpExtender': IBurpExtender, 'IBurpExtenderCallbacks': IBurpExtenderCallbacks, 'IContextMenuFactory': IContextMenuFactory, 'IContextMenuInvocation': IContextMenuInvocation, 'ICookie': ICookie, 'IExtensionHelpers': IExtensionHelpers, 'IExtensionStateListener': IExtensionStateListener, 'IHttpListener': IHttpListener, 'IHttpRequestResponse': IHttpRequestResponse, 'IHttpRequestResponsePersisted': IHttpRequestResponsePersisted, 'IHttpRequestResponseWithMarkers': IHttpRequestResponseWithMarkers, 'IHttpService': IHttpService, 'IInterceptedProxyMessage': IInterceptedProxyMessage, 'IIntruderAttack': IIntruderAttack, 'IIntruderPayloadGenerator': IIntruderPayloadGenerator, 'IIntruderPayloadGeneratorFactory': IIntruderPayloadGeneratorFactory, 'IIntruderPayloadProcessor': IIntruderPayloadProcessor, 'IMenuItemHandler': IMenuItemHandler, 'IMessageEditor': IMessageEditor, 'IMessageEditorController': IMessageEditorController, 'IMessageEditorTab': IMessageEditorTab, 'IMessageEditorTabFactory': IMessageEditorTabFactory, 'IParameter': IParameter, 'IProxyListener': IProxyListener, 'IRequestInfo': IRequestInfo, 'IResponseInfo': IResponseInfo, 'IResponseKeywords': IResponseKeywords, 'IResponseVariations': IResponseVariations, 'IScanIssue': IScanIssue, 'IScannerCheck': IScannerCheck, 'IScannerInsertionPoint': IScannerInsertionPoint, 'IScannerInsertionPointProvider': IScannerInsertionPointProvider, 'IScannerListener': IScannerListener, 'IScanQueueItem': IScanQueueItem, 'IScopeChangeListener': IScopeChangeListener, 'ISessionHandlingAction': ISessionHandlingAction, 'ITab': ITab, 'ITempFile': ITempFile, 'ITextEditor': ITextEditor, } locals_ = { 'currentRequest': currentRequest, 'macroItems': macroItems } exec(self.script, globals_, locals_) except Exception: traceback.print_exc(file=self.callbacks.getStderr()) return def getTabCaption(self): return 'Makro Script' def getUiComponent(self): return self.scrollpane @property def script(self): end = self.scriptpane.document.length _script = self.scriptpane.document.getText(0, end) if _script == self._script: return self._code self._script = _script self._code = compile(_script, '<string>', 'exec') return self._code
class extender(): def __init__(self): self.jLabel1 = JLabel() self.jCheckBox1 = JCheckBox() self.jScrollPane1 = JScrollPane() self.jTable1 = JTable() self.jTabbedPane1 = JTabbedPane() self.jPanel1 = JPanel() self.jButton1 = JButton("Add") self.jButton2 = JButton("Remove") self.jLabel2 = JLabel() self.jLabel3 = JLabel() self.jLabel4 = JLabel() self.jLabel5 = JLabel() self.jLabel6 = JLabel() self.jTextField1 = JTextField() self.jTextField2 = JTextField() self.jTextField3 = JTextField() method = ["http", "https"] self.jComboBox1 = JComboBox(method) self.jLabel7 = JLabel() self.jLabel8 = JLabel() self.jTextField4 = JTextField() self.jButton3 = JButton() self.jPanel2 = JPanel() self.jScrollPane3 = JScrollPane() self.jTextArea2 = JTextArea() self.jLabel1.setFont(Font("굴림", 1, 12)) self.jLabel1.setText("Use local files to serve remote locations.") self.jCheckBox1.setText("Enable Map Local") self.jScrollPane1.setViewportView(self.jTable1) self.jLabel2.setText("Protocol:") self.jLabel3.setText("Host:") self.jLabel4.setText("Path:") self.jLabel5.setText("Query:") self.jLabel6.setText("Map From") self.jLabel7.setText("Map To") self.jLabel8.setText("Local Path:") self.jButton3.setText("Choose") jPanel1Layout = GroupLayout(self.jPanel1) self.jPanel1.setLayout(jPanel1Layout) from java.lang import Short jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent(self.jLabel3) .addComponent(self.jLabel2) .addComponent(self.jLabel4) .addComponent(self.jLabel5) .addComponent(self.jLabel6)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(self.jTextField1) .addComponent(self.jTextField2) .addComponent(self.jTextField3) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(self.jComboBox1, GroupLayout.PREFERRED_SIZE, 86, GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)))) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(self.jLabel7)) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(30, 30, 30) .addComponent(self.jLabel8) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(self.jTextField4, GroupLayout.DEFAULT_SIZE, 2000, Short.MAX_VALUE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(self.jButton3, GroupLayout.PREFERRED_SIZE, 95, GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(self.jButton1, GroupLayout.PREFERRED_SIZE, 79, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(self.jButton2, GroupLayout.PREFERRED_SIZE, 79, GroupLayout.PREFERRED_SIZE))) .addGap(0, 18, Short.MAX_VALUE))) .addContainerGap()) ) jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(self.jLabel6) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(self.jLabel2) .addComponent(self.jComboBox1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(self.jLabel3) .addComponent(self.jTextField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(self.jLabel4) .addComponent(self.jTextField2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(self.jLabel5) .addComponent(self.jTextField3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addComponent(self.jLabel7) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(self.jLabel8) .addComponent(self.jTextField4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(self.jButton3)) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(self.jButton1) .addComponent(self.jButton2)) .addContainerGap(19, Short.MAX_VALUE)) ) self.jTabbedPane1.addTab("Edit Mapping", self.jPanel1) self.jTextArea2.setColumns(20) self.jTextArea2.setRows(5) self.jScrollPane3.setViewportView(self.jTextArea2) jPanel2Layout = GroupLayout(self.jPanel2) self.jPanel2.setLayout(jPanel2Layout) jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addComponent(self.jScrollPane3, GroupLayout.DEFAULT_SIZE, 729, Short.MAX_VALUE) .addContainerGap()) ) jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addComponent(self.jScrollPane3, GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE) .addContainerGap()) ) self.jTabbedPane1.addTab("Viewer", self.jPanel2) self.panel = JPanel() layout = GroupLayout(self.panel) self.panel.setLayout(layout) layout.setHorizontalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(self.jScrollPane1) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(self.jCheckBox1) .addComponent(self.jLabel1, GroupLayout.PREFERRED_SIZE, 285, GroupLayout.PREFERRED_SIZE)) .addGap(0, 0, Short.MAX_VALUE)) .addComponent(self.jTabbedPane1)) .addContainerGap()) ) layout.setVerticalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(self.jLabel1) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(self.jCheckBox1) .addGap(18, 18, 18) .addComponent(self.jScrollPane1, GroupLayout.PREFERRED_SIZE, 140, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(self.jTabbedPane1) .addContainerGap()) )
class BurpExtender(IBurpExtender, IIntruderPayloadGeneratorFactory, IExtensionStateListener, ITab): # # implement IBurpExtender # def registerExtenderCallbacks(self, callbacks): callbacks.registerExtensionStateListener(self) # 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("Super Payload") # register ourselves as a payload generator factory callbacks.registerIntruderPayloadGeneratorFactory(self) # the Super Payload UI self.scriptpane = JTextPane() self.scriptpane.setFont(Font('Monospaced', Font.PLAIN, 11)) self.scrollpane = JScrollPane() self.scrollpane.setViewportView(self.scriptpane) callbacks.customizeUiComponent(self.getUiComponent()) callbacks.addSuiteTab(self) self.scriptpane.requestFocus() # Compile the init script content self._code = compile('', '<string>', 'exec') self._script = '' script = callbacks.loadExtensionSetting('script') if script: script = base64.b64decode(script) self.scriptpane.document.insertString( self.scriptpane.document.length, script, SimpleAttributeSet()) self._script = script self._code = compile(script, '<string>', 'exec') return def createNewInstance(self, attack): return SuperGenerator(self, attack) def getGeneratorName(self): return "SuperPayload" def extensionUnloaded(self): try: self.callbacks.saveExtensionSetting( 'script', base64.b64encode(self._script)) except Exception: traceback.print_exc(file=self.callbacks.getStderr()) return def getTabCaption(self): return 'Super Payload Script' def getUiComponent(self): return self.scrollpane # Get the compiled code of user script (update or not) @property def script(self): end = self.scriptpane.document.length _script = self.scriptpane.document.getText(0, end) if _script == self._script: return self._code self._script = _script self._code = compile(_script, '<string>', 'exec') return self._code
class ChatClient(JFrame): ## Constructor method, receives the variables from the ChatApp class as parameters def __init__(self, name, greeting, tn): '''Constructor, initialises base class & assigns variables ''' # Call to the super method to take care of the base class(es) super(ChatClient, self).__init__() # Assign the relevent variable names self.username=name self.greeting=greeting self.tn = tn self.no_users=[] # Initiate the Threaded function for receiving messages t1=Thread(target=self.recvFunction) # Set to daemon t1.daemon=True t1.start() #Call the main UI uI=self.clientUI() ## Main GUI building function def clientUI(self): '''ClientUI and Widget creation ''' # Colours foreground_colour = Color(30,57,68) background_colour = Color(247,246,242) window_background = Color(145,190,210) # Borders self.border2=BorderFactory.createLineBorder(foreground_colour,1, True) # Fonts self.font= Font("Ubuntu Light", Font.BOLD, 20) self.label_font= Font("Ubuntu Light", Font.BOLD, 17) self.label_2_font= Font( "Ubuntu Light",Font.BOLD, 12) self.btn_font=Font("Ubuntu Light", Font.BOLD, 15) # Set the layout parameters self.client_layout=GroupLayout(self.getContentPane()) self.getContentPane().setLayout(self.client_layout) self.getContentPane().setBackground(window_background) self.client_layout.setAutoCreateGaps(True) self.client_layout.setAutoCreateContainerGaps(True) self.setPreferredSize(Dimension(400, 450)) # Create widgets and assemble the GUI # Main display area self.main_content=JTextPane() self.main_content.setBackground(background_colour) #self.main_content.setForeground(foreground_colour) self.main_content.setEditable(False) # Message entry area self.message=JTextArea( 2,2, border=self.border2, font=self.label_font, keyPressed=self.returnKeyPress) self.message.requestFocusInWindow() self.message.setBackground(background_colour) self.message.setForeground(foreground_colour) self.message.setLineWrap(True) self.message.setWrapStyleWord(True) self.message.setBorder(BorderFactory.createEmptyBorder(3,3,3,3)) self.message.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), self.returnKeyPress) # BUttons quit_btn=JButton("Quit!", actionPerformed=ChatApp().closeEvent, border=self.border2, font=self.btn_font) go_btn=JButton("Send", actionPerformed=self.grabText, border=self.border2, font=self.btn_font) quit_btn.setBackground(background_colour) go_btn.setBackground(background_colour) quit_btn.setForeground(foreground_colour) go_btn.setForeground(foreground_colour) # Make scrollable self.scroll_content=JScrollPane(self.main_content) self.scroll_content.setPreferredSize(Dimension(150,275)) self.scroll_content.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER) self.scroll_content.setViewportView(self.main_content) self.scroll_content.setBackground(Color.WHITE) self.scroll_message=JScrollPane(self.message) self.scroll_message.setPreferredSize(Dimension(150,20)) self.scroll_message.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS) # Test user label, still not updating after first round of messages self.user_label=JLabel(" Users online : %s "%(str(len(self.no_users))),JLabel.RIGHT, font=self.label_2_font) # Assemble the components # Horizontal layout self.client_layout.setHorizontalGroup(self.client_layout.createParallelGroup() .addComponent(self.scroll_content) .addGroup(self.client_layout.createParallelGroup(GroupLayout.Alignment.CENTER) .addComponent(self.scroll_message)) .addGroup(self.client_layout.createSequentialGroup() .addComponent(quit_btn) .addComponent(go_btn).addGap(20)) .addGroup(self.client_layout.createParallelGroup() .addComponent(self.user_label)) ) # Vertical layout self.client_layout.setVerticalGroup(self.client_layout.createSequentialGroup() .addGroup(self.client_layout.createParallelGroup() .addComponent(self.scroll_content)) .addComponent(self.scroll_message) .addGroup(self.client_layout.createParallelGroup() .addComponent(quit_btn) .addComponent(go_btn)) .addGroup(self.client_layout.createParallelGroup() .addComponent(self.user_label)) ) # Finalise the GUI self.client_layout.linkSize(SwingConstants.HORIZONTAL, [quit_btn,go_btn, self.user_label]) self.pack() self.message.requestFocusInWindow() self.setTitle(">>> Client %s <<<"%self.username) self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) self.setLocationRelativeTo(None) self.setVisible(True) # Display the server greeting self.appendText('\n'+self.greeting+'\n') ## Function responsible for receiving and processing new messages def recvFunction(self): '''A function to control the receiving of data from the connection ''' # While the connection is available while self.tn: # Try to receive data using "<<<" as the delimiter try: message = self.tn.read_until('<<<') # If a message is received if message: garb, message=message.split('>>>') message, garb = message.split('<<<') message = ('\n'+message+'\n') # Call the append text function self.appendText(message) # Except if there is no data available except: #print('No message') pass ## Event driven function to retrieve and send data to the server def grabText(self, event): '''Function to repeatedly grab new messages entered into the text area and display them in the main text area. Resets the entry area ''' # Grab the text from the text area text=self.message.getText() # Don't allow an empty string through if text=='': return text=text.strip() # Call the append text function self.appendText('\nYou : '+text+'\n', self.username) # Reset the text to be empty and grab focus so that it is ready for new text input self.message.requestFocusInWindow() self.message.setText('') # Send the message to the server data=text.encode() self.tn.write(data+'\r\n') ## Function to handle appending of messages def appendText(self, message, user=None): '''This function takes care of appending any new messages to the content area ''' message_label=JTextArea(message,2,3, font=self.label_2_font) # If this is a message from the grab text function, create a new label, assign it's colours if user!=None: message_label.setBackground(Color(240,240,240)) message_label.setForeground(Color(129,129,129)) # Otherwise set the format for receive function (no user passed in) else: message_label.setBackground(Color(215,215,215)) message_label.setForeground(Color(40,153,153)) # Format and style options for the new message labels message_label.setEditable(False) message_label.setLineWrap(True) message_label.setWrapStyleWord(True) message_label.setBorder(BorderFactory.createLineBorder( Color(247,246,242),4)) # Sets the positioning of messages self.main_content.setCaretPosition(self.main_content.getDocument().getLength()) doc = self.main_content.getStyledDocument() attr=SimpleAttributeSet() self.main_content.insertComponent(message_label) # Essential for jtextarea to be able to stack message doc.insertString( self.main_content.getDocument().getLength(),'\n ', attr) # Not sure if needed self.main_content.repaint() ### This is a late edit so it isn't included in the documentation. Basically trying to dynamically update the number ### of users label at runtime. Works for incrementing the value but not decrementing it. print(message) # Only split the message if there are enough values to split (greeting messages differ in format to chat messages) try: user, text=message.split(' : ') except: return #print('Split values are %s %s'%(user, text)) user=str(user.strip()) #print(self.no_users) #print(user+' : '+text) # If the user already in the list, pass if user in self.no_users: if text == ('User %s amach sa teach !'%user): self.no_users.remove(user) print('User % removed'%user) else: #print('User %s not in list'%user) if str(user) == 'You': #print('User is equal to "You"') return self.no_users.append(user) print('User appended') self.number_users=len(self.no_users) #print('Length of user list is '+str(self.number_users)) self.user_label2=JLabel(" Users online : %s "%str(len(self.no_users)),JLabel.RIGHT, font=self.label_2_font) #print('Label created') #print('Attempt to replace label') self.client_layout.replace(self.user_label, self.user_label2) self.user_label = self.user_label2 self.user_label.repaint() self.user_label.revalidate() print('Label updated') ## Function to control return button press in message field def returnKeyPress(self,event): '''This function creates an object for return key press when inside the message entry area, creates an object of KeyAdapter and tests keycode for a match, responds with grab text callback ''' key_object=Key() key_value=key_object.keyPressed(event) if key_value == 10: self.grabText(event)
def initComponents(self): TabbedPane1 = JTabbedPane() GeneratorScrollPane = JScrollPane() GeneratorPanel = JPanel() jlbl1 = JLabel() jlbl2 = JLabel() spanePayloadList = JScrollPane() self.listPayloads = JList() pastePayloadButton = JButton( actionPerformed=self.pastePayloadButtonAction) loadPayloadButton = JButton( actionPerformed=self.loadPayloadButtonAction) removePayloadButton = JButton( actionPerformed=self.removePayloadButtonAction) clearPayloadButton = JButton( actionPerformed=self.clearPayloadButtonAction) self.textNewPayload = JTextField() addPayloadButton = JButton(actionPerformed=self.addPayloadButtonAction) jSeparator1 = JSeparator() jlbl3 = JLabel() jlbl4 = JLabel() self.chkGeneral = JCheckBox(actionPerformed=self.OnCheck) self.chkMAXDB = JCheckBox(actionPerformed=self.OnCheck) self.chkMSSQL = JCheckBox(actionPerformed=self.OnCheck) self.chkMSAccess = JCheckBox(actionPerformed=self.OnCheck) self.chkPostgres = JCheckBox(actionPerformed=self.OnCheck) self.chkOracle = JCheckBox(actionPerformed=self.OnCheck) self.chkSqlite = JCheckBox(actionPerformed=self.OnCheck) self.chkMysql = JCheckBox(actionPerformed=self.OnCheck) jlbl5 = JLabel() toClipboardButton = JButton( actionPerformed=self.toClipboardButtonAction) toFileButton = JButton(actionPerformed=self.toFileButtonAction) ProcessorScrollPane = JScrollPane() ProcessorPanel = JPanel() jLabel1 = JLabel() self.comboProcessorTech = JComboBox( itemStateChanged=self.comboProcessorTechAction) jSeparator2 = JSeparator() jLabel2 = JLabel() jLabel3 = JLabel() jScrollPane1 = JScrollPane() self.textPlainPayload = JTextArea() jLabel4 = JLabel() jScrollPane2 = JScrollPane() self.textTamperedPayload = JTextArea() tamperPayloadButton = JButton( actionPerformed=self.tamperPayloadButtonAction) jlbl1.setForeground(Color(255, 102, 51)) jlbl1.setFont(Font(jlbl1.getFont().toString(), 1, 14)) jlbl1.setText("User-Defiend Payloads") jlbl2.setText( "This payload type lets you configure a simple list of strings that are used as payloads." ) spanePayloadList.setViewportView(self.listPayloads) self.extender.PayloadList = self.readPayloadsListFile() self.listPayloads.setListData(self.extender.PayloadList) pastePayloadButton.setText("Paste") loadPayloadButton.setText("Load") removePayloadButton.setText("Remove") clearPayloadButton.setText("Clear") self.textNewPayload.setToolTipText("") addPayloadButton.setText("Add") jlbl3.setForeground(Color(255, 102, 51)) jlbl3.setFont(Font(jlbl3.getFont().toString(), 1, 14)) jlbl3.setText("Tamper Techniques") jlbl4.setText( "You can select the techniques that you want to perform processing tasks on each user-defined payload" ) self.chkGeneral.setText("General") varName = 'SQLiQueryTampering_{}'.format(self.chkGeneral.text) state = self.extender.callbacks.loadExtensionSetting(varName) if state: self.chkGeneral.setSelected(int(state)) self.chkMAXDB.setText("SAP MAX DB") varName = 'SQLiQueryTampering_{}'.format(self.chkMAXDB.text) state = self.extender.callbacks.loadExtensionSetting(varName) if state: self.chkMAXDB.setSelected(int(state)) self.chkMSSQL.setText("MS SQL Server") varName = 'SQLiQueryTampering_{}'.format(self.chkMSSQL.text) state = self.extender.callbacks.loadExtensionSetting(varName) if state: self.chkMSSQL.setSelected(int(state)) self.chkMSAccess.setText("MS Access") varName = 'SQLiQueryTampering_{}'.format(self.chkMSAccess.text) state = self.extender.callbacks.loadExtensionSetting(varName) if state: self.chkMSAccess.setSelected(int(state)) self.chkPostgres.setText("Postgres SQL") varName = 'SQLiQueryTampering_{}'.format(self.chkPostgres.text) state = self.extender.callbacks.loadExtensionSetting(varName) if state: self.chkPostgres.setSelected(int(state)) self.chkOracle.setText("Oracle") varName = 'SQLiQueryTampering_{}'.format(self.chkOracle.text) state = self.extender.callbacks.loadExtensionSetting(varName) if state: self.chkOracle.setSelected(int(state)) self.chkSqlite.setText("Sqlite") varName = 'SQLiQueryTampering_{}'.format(self.chkSqlite.text) state = self.extender.callbacks.loadExtensionSetting(varName) if state: self.chkSqlite.setSelected(int(state)) self.chkMysql.setText("MySql") varName = 'SQLiQueryTampering_{}'.format(self.chkMysql.text) state = self.extender.callbacks.loadExtensionSetting(varName) if state: self.chkMysql.setSelected(int(state)) jlbl5.setText("[?] Save the Generated/Tampered Payloads to :") toClipboardButton.setText("Clipboard") toFileButton.setText("File") GeneratorPanelLayout = GroupLayout(GeneratorPanel) GeneratorPanel.setLayout(GeneratorPanelLayout) GeneratorPanelLayout.setHorizontalGroup( GeneratorPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING). addGroup(GeneratorPanelLayout.createSequentialGroup( ).addContainerGap().addGroup( GeneratorPanelLayout.createParallelGroup( GroupLayout.Alignment.TRAILING).addComponent( jlbl2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent( jlbl4, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent( jSeparator1, GroupLayout.Alignment.LEADING). addGroup(GeneratorPanelLayout.createSequentialGroup().addGap( 6, 6, 6).addGroup( GeneratorPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGroup( GeneratorPanelLayout.createSequentialGroup( ).addGroup( GeneratorPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING, False).addComponent( removePayloadButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent( clearPayloadButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent( loadPayloadButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE). addComponent(pastePayloadButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent( addPayloadButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)). addGap(21, 21, 21).addGroup( GeneratorPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING). addComponent( self.textNewPayload).addComponent( spanePayloadList))).addComponent( jlbl1).addComponent(jlbl3). addGroup(GeneratorPanelLayout.createSequentialGroup( ).addGroup( GeneratorPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addComponent( self.chkGeneral).addComponent( self.chkMSSQL) ).addGap(18, 18, 18).addGroup( GeneratorPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addComponent( self.chkPostgres).addComponent( self.chkMAXDB) ).addGap(18, 18, 18).addGroup( GeneratorPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addComponent( self.chkMSAccess).addComponent( self.chkOracle) ).addGap(18, 18, 18).addGroup( GeneratorPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addComponent( self.chkSqlite).addComponent(self.chkMysql) )).addGroup(GeneratorPanelLayout.createSequentialGroup( ).addComponent(jlbl5).addPreferredGap( LayoutStyle.ComponentPlacement. UNRELATED).addComponent(toClipboardButton).addGap( 18, 18, 18).addComponent(toFileButton, GroupLayout.PREFERRED_SIZE, 97, GroupLayout.PREFERRED_SIZE ))))).addContainerGap())) GeneratorPanelLayout.setVerticalGroup( GeneratorPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING). addGroup(GeneratorPanelLayout.createSequentialGroup( ).addContainerGap().addComponent(jlbl1).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED).addComponent( jlbl2, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE).addGap(18, 18, 18).addGroup( GeneratorPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addComponent( spanePayloadList, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE). addGroup(GeneratorPanelLayout.createSequentialGroup( ).addComponent(pastePayloadButton).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED ).addComponent(loadPayloadButton).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED ).addComponent(removePayloadButton).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED). addComponent(clearPayloadButton))). addPreferredGap( LayoutStyle.ComponentPlacement.RELATED).addGroup( GeneratorPanelLayout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.textNewPayload, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE). addComponent(addPayloadButton)).addPreferredGap( LayoutStyle.ComponentPlacement.UNRELATED). addComponent(jSeparator1, GroupLayout.PREFERRED_SIZE, 10, GroupLayout.PREFERRED_SIZE).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED). addComponent(jlbl3).addPreferredGap( LayoutStyle.ComponentPlacement.UNRELATED ).addComponent(jlbl4).addPreferredGap( LayoutStyle.ComponentPlacement.UNRELATED).addGroup( GeneratorPanelLayout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.chkGeneral).addComponent( self.chkMAXDB).addComponent( self.chkOracle).addComponent( self.chkSqlite)). addPreferredGap( LayoutStyle.ComponentPlacement.UNRELATED).addGroup( GeneratorPanelLayout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.chkMSSQL).addComponent( self.chkPostgres).addComponent( self.chkMSAccess).addComponent( self.chkMysql) ).addGap(18, 18, 18).addGroup( GeneratorPanelLayout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( jlbl5).addComponent(toClipboardButton). addComponent(toFileButton)).addGap(20, 20, 20))) GeneratorScrollPane.setViewportView(GeneratorPanel) TabbedPane1.addTab("Generator", GeneratorScrollPane) varName = 'SQLiQueryTampering_comboProcessorTech' state = self.extender.callbacks.loadExtensionSetting(varName) for item in self.extender.getTamperFuncsName(): self.comboProcessorTech.addItem(item) if state: self.comboProcessorTech.setSelectedIndex(int(state)) jLabel1.setText("Processor Technique :") jLabel2.setText( "Modify Plain Payloads based on the selected Processor Technique. Write one payload per line." ) jLabel3.setText("Plain Payloads:") self.textPlainPayload.setColumns(20) self.textPlainPayload.setRows(5) jScrollPane1.setViewportView(self.textPlainPayload) jLabel4.setText("Tampered Payloads:") self.textTamperedPayload.setColumns(20) self.textTamperedPayload.setRows(5) jScrollPane2.setViewportView(self.textTamperedPayload) tamperPayloadButton.setText("Tamper Payloads") ProcessorPanelLayout = GroupLayout(ProcessorPanel) ProcessorPanel.setLayout(ProcessorPanelLayout) ProcessorPanelLayout.setHorizontalGroup( ProcessorPanelLayout. createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( GroupLayout.Alignment.TRAILING, ProcessorPanelLayout.createSequentialGroup().addContainerGap( GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent( tamperPayloadButton).addContainerGap( GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ).addGroup(ProcessorPanelLayout.createSequentialGroup( ).addContainerGap().addGroup( ProcessorPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addComponent(jSeparator2). addComponent(jScrollPane1).addComponent(jScrollPane2).addGroup( ProcessorPanelLayout.createSequentialGroup().addGroup( ProcessorPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addComponent( jLabel3).addComponent(jLabel4).addGroup( ProcessorPanelLayout.createSequentialGroup( ).addComponent(jLabel1).addPreferredGap( LayoutStyle.ComponentPlacement. UNRELATED).addComponent( self.comboProcessorTech, GroupLayout.PREFERRED_SIZE, 286, GroupLayout.PREFERRED_SIZE)). addComponent(jLabel2)).addGap( 0, 78, Short.MAX_VALUE))).addContainerGap())) ProcessorPanelLayout.setVerticalGroup( ProcessorPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGroup( ProcessorPanelLayout.createSequentialGroup().addGap( 33, 33, 33).addGroup( ProcessorPanelLayout.createParallelGroup( GroupLayout.Alignment.BASELINE). addComponent(jLabel1).addComponent( self.comboProcessorTech, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)).addGap( 18, 18, 18).addComponent( jSeparator2, GroupLayout.PREFERRED_SIZE, 10, GroupLayout.PREFERRED_SIZE).addGap( 12, 12, 12).addComponent(jLabel2).addGap( 18, 18, 18). addComponent(jLabel3).addPreferredGap( LayoutStyle.ComponentPlacement.UNRELATED).addComponent( jScrollPane1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap( LayoutStyle.ComponentPlacement.UNRELATED). addComponent(jLabel4).addPreferredGap( LayoutStyle.ComponentPlacement.UNRELATED).addComponent( jScrollPane2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap( LayoutStyle.ComponentPlacement.UNRELATED). addComponent(tamperPayloadButton).addGap(36, 36, 36))) ProcessorScrollPane.setViewportView(ProcessorPanel) TabbedPane1.addTab("Processor", ProcessorScrollPane) self.mainPanel = JPanel() layout = GroupLayout(self.mainPanel) self.mainPanel.setLayout(layout) layout.setHorizontalGroup( layout.createParallelGroup( GroupLayout.Alignment.LEADING).addComponent( TabbedPane1, GroupLayout.DEFAULT_SIZE, 701, Short.MAX_VALUE)) layout.setVerticalGroup( layout.createParallelGroup( GroupLayout.Alignment.LEADING).addComponent(TabbedPane1)) TabbedPane1.getAccessibleContext().setAccessibleName("Generator")
class BurpExtender(IBurpExtender, ITab, IContextMenuFactory): EXTENSION_NAME = "AutoRecon" # subdomain = list() headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " "(KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Language": "en-US,en;q=0.9", "Accept-Encoding": "gzip, deflate, br", } def registerExtenderCallbacks(self, callbacks): # keep a reference to our callbacks object self._callbacks = callbacks self._helpers = callbacks.getHelpers() callbacks.setExtensionName(self.EXTENSION_NAME) callbacks.issueAlert("AutoRecon is enabled") # add the custom tab to Burp's UI self.initUI() # self._newpanel.setLayout(FlowLayout()) # callbacks.customizeUiComponent(self._newpanel) callbacks.addSuiteTab(self) self.callable = [ # self.sublister, # self.shodan_search, self.certsh_search, # self.anubis, # self.googleDig, # self.censys, # self.certspotter, # self.bufferover_run, # self.urlscan, # self.otx_alienvault, # self.threatminer, # self.netcraft, # self.threatcrowd, # self.dnsdumpster, # self.virustotal, # self.ptrarchive, ] # self.callable = [self.censys] # define stdout writer self._stdout = PrintWriter(callbacks.getStdout(), True) self._stderr = PrintWriter(callbacks.getStderr(), True) self._stdout.println(self.EXTENSION_NAME + " by @bourne") self._stdout.println( "================================================") self._stdout.println( 'TIP: Right click on any domain and add it to scope in "autoRecon"' ) self._stdout.println("") self.outputTxtArea.setText( self.EXTENSION_NAME + " by @bourne" + "\n" + "================================================" + "\n" + 'TIP: Right click on any domain and add it to scope in "autoRecon"\n' ) self.context = None callbacks.registerContextMenuFactory(self) return def initUI(self): self.tab = JPanel() # UI for Output self.outputLabel = JLabel("AutoRecon Log:") self.outputLabel.setFont(Font("Tahoma", Font.BOLD, 14)) self.outputLabel.setForeground(Color(255, 102, 52)) self.logPane = JScrollPane() self.outputTxtArea = JTextArea() self.outputTxtArea.setFont(Font("Consolas", Font.PLAIN, 12)) self.outputTxtArea.setLineWrap(True) self.logPane.setViewportView(self.outputTxtArea) self.clearBtn = JButton("Clear Log", actionPerformed=self.clearLog) self.exportBtn = JButton("Export Log", actionPerformed=self.exportLog) self.parentFrm = JFileChooser() # Layout layout = GroupLayout(self.tab) layout.setAutoCreateGaps(True) layout.setAutoCreateContainerGaps(True) self.tab.setLayout(layout) layout.setHorizontalGroup(layout.createParallelGroup().addGroup( layout.createSequentialGroup().addGroup( layout.createParallelGroup().addComponent( self.outputLabel).addComponent(self.logPane).addComponent( self.clearBtn).addComponent(self.exportBtn)))) layout.setVerticalGroup(layout.createParallelGroup().addGroup( layout.createParallelGroup().addGroup( layout.createSequentialGroup().addComponent( self.outputLabel).addComponent(self.logPane).addComponent( self.clearBtn).addComponent(self.exportBtn)))) def getTabCaption(self): """Name of our tab""" return self.EXTENSION_NAME def getUiComponent(self): return self.tab def clearLog(self, event): self.outputTxtArea.setText( self.EXTENSION_NAME + " by @bourne" + "\n" + "================================================" + "\n" + 'TIP: Right click on any domain and add it to scope in "autoRecon"\n' ) def exportLog(self, event): chooseFile = JFileChooser() ret = chooseFile.showDialog(self.logPane, "Choose file") filename = chooseFile.getSelectedFile().getCanonicalPath() print("\n" + "Export to : " + filename) open(filename, "w", 0).write(self.outputTxtArea.text) def createMenuItems(self, context_menu): self.context = context_menu menu_list = ArrayList() menu_list.add( JMenuItem("Add domain to scope for AutoRecon", actionPerformed=self.threadAnalysis)) return menu_list def threadAnalysis(self, event): http_traffic = self.context.getSelectedMessages() self._stdout.println(str(len(http_traffic)) + " requests highlighted") for traffic in http_traffic: http_service = traffic.getHttpService() host = http_service.getHost() if host.startswith("www."): host = host[4:] self._stdout.println("User selected host: " + str(host)) self.subdomain = list() threads = [] for i in self.callable: time.sleep(1) thread = threading.Thread(target=i, args=(host, )) # thread.daemon = True threads.append(thread) thread.start() for i in threads: i.join() self.outputTxtArea.setText( self.EXTENSION_NAME + " by @bourne" + "\n" + "================================================" + "\n" + 'TIP: Right click on any domain and add it to scope in "autoRecon"\n' ) self.outputTxtArea.append("\n DOMAIN: " + host) self.outputTxtArea.append("\n Total {} subdomains found :\n\n".format( len(set(self.subdomain)))) for s in set(self.subdomain): if not "*" in s: self.outputTxtArea.append("\n" + s) # request_url = """https://api.viewdns.info/portscan/?host={}&apikey=3b59ef16aea9a71c7e6ae2872e83008493375e9e&output=json""".format( # s # ) # try: # # self.outputTxtArea.append(request_url) # time.sleep(2) # req = requests.get(request_url, verify=False, headers=self.headers, timeout=3) # req = json.loads(req.text) # except Exception as e: # self.outputTxtArea.append(str(e)) # for i in req["response"]["port"]: # if i["status"] == "open": # self.outputTxtArea.append("\n\t",i["number"],i["service"]) try: req = requests.get( """http://web.archive.org/cdx/search/cdx?url=*.{0}/* &output=json&fl=original&collapse=urlkey&page=/""" .format(s), verify=False, headers=self.headers, timeout=3) temp = [] t = json.loads(req.text) for i in t: temp.extend(i) except Exception: pass paths = [] count = 0 for i in range(1, len(temp)): not_contains = re.compile("|".join( ["js", "txt", "git", "zip"])) # print(type(temp[i])) if temp[i] not in paths and not_contains.search(temp[i]): paths.append(temp[i]) count += 1 for i in paths: if ".js" in i.lower() or ".zip" in i.lower( ) or ".txt" in i.lower() or ".git" in i.lower(): self.outputTxtArea.append("\n\t" + i) # thread = threading.Thread(target=self.certsh_search, args=(host,)) # thread.daemon = True # thread.start() # thread = threading.Thread(target=self.shodan_search, args=(host,)) # thread.daemon = True # thread.start() def certsh_search(self, host): BASE_URL = "https://crt.sh" threadLocal.response = requests.get(BASE_URL + "/?q=%." + host + "&output=json") # self._stdout.println(threadLocal.response) threadLocal.result = threadLocal.response.json() # self._stdout.println(result) threadLocal.sub = [] for item in threadLocal.result: s = item["name_value"] t = s.split("\n") self.subdomain.extend(t) # self.subdomain.append(s) # self._stdout.println(item) self._stdout.println(self.subdomain) self._stdout.println("....") if s not in threadLocal.sub: threadLocal.sub.append(s) self._stdout.println(s) return def shodan_search(self, host): BASE_URL = "https://api.shodan.io/shodan/host/search/" SHODAN_API_KEY = "J1Rp7W8tcqmhsdiB3ZU3JVhOlPpOHp8X" API = "WozM2OXwuUSMSsiseIkPtyLFxYnDUrPP" QUERY = "hostname" try: threadLocal.response = requests.get( "https://api.shodan.io/shodan/host/search?key=" + SHODAN_API_KEY + "&query=hostname:" + host) # self._stdout.println(response.text) threadLocal.result = threadLocal.response.json() # self._stdout.println(result) threadLocal.sub = [] for item in threadLocal.result["matches"]: s = item["hostnames"][0] self.subdomain.append(s) if s not in threadLocal.sub: threadLocal.sub.append(s) self._stdout.println(s) return except Exception as error: logging.exception("message") def anubis(self, host): BASE_URL = "https://jldc.me/anubis/subdomains/{0}".format(host) try: threadLocal.response = requests.get(BASE_URL) threadLocal.sub = [] results = json.loads(threadLocal.response.text) for w in results: if "*" not in w and w.endswith( "." + host) and w not in threadLocal.sub: threadLocal.sub.append(w) self.subdomain.append(w) self._stdout.println(w) return except Exception as error: logging.exception("message") def bufferover_run(self, host): try: threadLocal.response = requests.get( "http://dns.bufferover.run/dns?q={0}".format(host)) threadLocal.sub = [] results = json.loads(threadLocal.response.text)["FDNS_A"] for w in results: domain = w.split(",")[1] if ("*" not in domain and domain.endswith("." + host) and domain not in threadLocal.sub): threadLocal.sub.append(domain) self.subdomain.append(domain) self._stdout.println(domain) return except Exception as error: logging.exception("message") def urlscan(self, host): BASE_URL = "https://urlscan.io/api/v1/search/?q=domain:{0}".format( host) try: threadLocal.response = requests.get(BASE_URL) threadLocal.sub = [] results = json.loads(threadLocal.response.text)["results"] for w in results: domain = w["page"]["domain"] if ("*" not in domain and domain.endswith("." + host) and domain not in threadLocal.sub): threadLocal.sub.append(domain) self.subdomain.append(domain) self._stdout.println(domain) return except Exception as error: logging.exception("message") def otx_alienvault(self, host): BASE_URL = "https://otx.alienvault.com/api/v1/indicator/domain/{0}/passive_dns".format( host) try: tHeader = { "Host": "otx.alienvault.com", "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "Accept-Language": "en-US,en;q=0.5", "Accept-Encoding": "gzip, deflate, br", "Connection": "keep-alive", "Upgrade-Insecure-Requests": "1", "Cache-Control": "max-age=0", } response = requests.get(BASE_URL) threadLocal.sub = [] self._stdout.println(response.status_code) # results = json.loads(threadLocal.response.text)["passive_dns"] # for w in results: # h = w["hostname"] # if "*" not in h and h.endswith("." + host) and h not in threadLocal.sub: # threadLocal.sub.append(h) # self.subdomain.append(h) # self._stdout.println(h) return except Exception as error: logging.exception("message") def threatminer(self, host): BASE_URL = "https://api.threatminer.org/v2/domain.php?q={0}&api=True&rt=5".format( host) try: threadLocal.response = requests.get(BASE_URL) threadLocal.sub = [] results = json.loads(threadLocal.response.text)["results"] for w in results: if "*" not in w and w.endswith( "." + host) and w not in threadLocal.sub: threadLocal.sub.append(w) self.subdomain.append(w) self._stdout.println(w) return except Exception as error: logging.exception("message") # def censys(self, host): # try: # censys_certificates = censys.certificates.CensysCertificates( # api_id="5d63a69e-6142-46ec-830f-7279734e76f0", api_secret="qz6uDnlOCfZPJIXVyKvheot5HUxqZjNl") # certificate_query = 'parsed.names: %s' % host # certificates_search_results = censys_certificates.search( # certificate_query, fields=['parsed.names']) # subdomains = [] # for search_result in certificates_search_results: # subdomains.extend(search_result['parsed.names']) # self._stdout.println(search_result['parsed.names']) # except Exception as error: # self._stderr.println(error) # return threadLocal.subs def certspotter(self, host): BASE_URL = "https://certspotter.com/api/v0/certs?domain={0}".format( host) try: threadLocal.response = requests.get(BASE_URL) threadLocal.sub = [] if threadLocal.response.status_code == 200: for w in (threadLocal.response.content.replace( '"', " ").replace("'", " ").rsplit()): if ("*" not in w and w.endswith("." + host) and w not in threadLocal.sub): threadLocal.sub.append(w) self.subdomain.append(w) self._stdout.println(w) return except Exception as error: logging.exception("message") def googleDig(self, host): try: url_1 = "https://toolbox.googleapps.com/apps/dig/#ANY/" url_2 = "https://toolbox.googleapps.com/apps/dig/lookup" s = requests.session() threadLocal.req = s.get(url_1) csrf_middleware = re.compile( "<input type='hidden' name='csrfmiddlewaretoken' value='(.*?)' />", re.S).findall(threadLocal.req.content)[0] # tHeader = self.headers # tHeader["Referer"] = url_1 threadLocal.req = s.post( url_2, cookies={"csrftoken": csrf_middleware}, data={ "csrfmiddlewaretoken": csrf_middleware, "domain": host, "typ": "ANY", }, headers={"Referer": url_1}, verify=False, ) threadLocal.subs = [] if threadLocal.req.status_code is 200: for w in (json.loads( threadLocal.req.content)["response"].replace( '"', " ").replace(";", " ").rsplit()): if ("*" not in w and w.endswith("." + host + ".") and w[:-1] not in threadLocal.subs): threadLocal.subs.append(w[:-1]) self.subdomain.append(w[:-1]) else: # warn 403 pass except Exception as error: logging.exception("message") return threadLocal.subs def netcraft(self, host): try: threadLocal.n = 0 threadLocal.results = "" url = ( "https://searchdns.netcraft.com/?restriction=site+contains&host=*.{0}" "&lookup=wait..&position=limited".format(host)) threadLocal.subs = [] while "<b>Next page</b></a>" not in threadLocal.results: while 1: try: threadLocal.results = requests.get(url) break except: threadLocal.n += 1 if threadLocal.n is 3: break if threadLocal.n is 3: break if threadLocal.results.status_code is 200: for l in re.compile( '<a href="http://toolbar.netcraft.com/site_report\?url=(.*)">' ).findall(threadLocal.results.content): domain = parse_url(l).host if ("*" not in domain and domain.endswith("." + host) and domain not in threadLocal.subs): threadLocal.subs.append(domain) self.subdomain.append(domain) else: # warn 403 break try: url = ("http://searchdns.netcraft.com" + re.compile('<A href="(.*?)"><b>Next page</b></a>'). findall(threadLocal.results.content)[0]) except: break except Exception as error: logging.exception("message") return threadLocal.subs def threatcrowd(self, host): try: threadLocal.n = 0 url = "https://www.threatcrowd.org/searchApi/v2/domain/report/?domain={0}".format( host) threadLocal.subs = [] while 1: try: threadLocal.results = requests.get(url) break except: threadLocal.n += 1 if threadLocal.n is 3: break if threadLocal.results.status_code is 200: try: threadLocal.subs = json.loads( threadLocal.results.content)["subdomains"] for i in threadLocal.subs: self.subdomain.append(i) except: threadLocal.subs = [] else: # warn 403 pass return threadLocal.subs except Exception as error: logging.exception("message") def dnsdumpster(self, host): try: url = "https://dnsdumpster.com/" s = requests.session() threadLocal.req = s.get(url) csrf_middleware = re.compile( "<input type='hidden' name='csrfmiddlewaretoken' value='(.*?)' />", re.S).findall(threadLocal.req.content)[0] threadLocal.req = s.post( url, cookies={"csrftoken": csrf_middleware}, data={ "csrfmiddlewaretoken": csrf_middleware, "targetip": host }, headers={"Referer": url}, ) threadLocal.subs = [] if threadLocal.req.status_code is 200: for w in (threadLocal.req.content.replace(".<", " ").replace( "<", " ").replace(">", " ").rsplit()): if ("*" not in w and w.endswith("." + host) and w not in threadLocal.subs): threadLocal.subs.append(w) self.subdomain.append(w) else: # warn 403 pass except Exception as error: logging.exception("message") return threadLocal.subs def virustotal(self, host): n = 0 url = "https://www.virustotal.com/en/domain/{0}/information/".format( host) threadLocal.subs = [] try: threadLocal.results = requests.get(url, headers=headers) if threadLocal.results.status_code is 200: try: for l in re.compile( '<div class="enum.*?">.*?<a target="_blank" href=".*?">(.*?)</a>', re.S, ).findall(threadLocal.results.content): domain = parse_url(l).host if ("*" not in domain and domain.strip().endswith("." + host) and domain.strip() not in threadLocal.subs): threadLocal.subs.append(domain.strip()) except: pass else: # warn 403 pass except: pass return threadLocal.subs def ptrarchive(self, host): n = 0 url = "http://ptrarchive.com/tools/search2.htm?label={0}&date=ALL".format( host) threadLocal.subs = [] try: threadLocal.results = requests.get(url, headers=headers) if threadLocal.results.status_code is 200: for sub in threadLocal.results.content.rsplit(): if ("*" in sub and sub.endswith("." + host) and sub not in threadLocal.subs): threadLocal.subs.append(sub) else: # warn 403 pass except: pass return threadLocal.subs def sublister(self, host): BASE_URL = "https://api.sublist3r.com/search.php?domain={0}".format( host) try: threadLocal.response = requests.get(BASE_URL) threadLocal.sub = [] if threadLocal.response.status_code == 200: for w in (json.loads(threadLocal.response.text)): if ("*" not in w and w.endswith("." + host) and w not in threadLocal.sub): threadLocal.sub.append(w) self.subdomain.append(w) self._stdout.println(w) return except Exception as error: logging.exception("message")
class BurpExtender( IBurpExtender, IExtensionStateListener, IHttpListener, ITab, ): def registerExtenderCallbacks(self, callbacks): self.callbacks = callbacks self.helpers = callbacks.helpers callbacks.setExtensionName("Burp Scripter Plus") stdout = PrintWriter(callbacks.getStdout(), True) stdout.println( """Successfully loaded Burp Scripter Plus v""" + VERSION + """\n Repository @ https://github.com/Acceis/BurpScripterPlus Send feedback or bug reports on twitter @G4N4P4T1""" ) self.scriptpane = JTextPane() self.scriptpane.setFont( Font("Monospaced", Font.PLAIN, 12) ) self.scrollpane = JScrollPane() self.scrollpane.setViewportView(self.scriptpane) self._code = compile("", "<string>", "exec") self._script = "" script = callbacks.loadExtensionSetting("script") if script: script = base64.b64decode(script) self.scriptpane.document.insertString( self.scriptpane.document.length, script, SimpleAttributeSet(), ) self._script = script try: self._code = compile( script, "<string>", "exec" ) except Exception as e: traceback.print_exc( file=self.callbacks.getStderr() ) callbacks.registerExtensionStateListener(self) callbacks.registerHttpListener(self) callbacks.customizeUiComponent( self.getUiComponent() ) callbacks.addSuiteTab(self) self.scriptpane.requestFocus() def extensionUnloaded(self): try: self.callbacks.saveExtensionSetting( "script", base64.b64encode( self._script.replace( "\nmessage.build_message()", "" ) ), ) except Exception: traceback.print_exc( file=self.callbacks.getStderr() ) return def processHttpMessage( self, toolFlag, messageIsRequest, messageInfo ): try: globals_ = {} locals_ = { "extender": self, "toolFlag": toolFlag, "messageInfo": messageInfo, "message": get_message( messageInfo, self.helpers, messageIsRequest, self.callbacks, ), } exec(self.script, globals_, locals_) except Exception: traceback.print_exc( file=self.callbacks.getStderr() ) return def getTabCaption(self): return "Script+" def getUiComponent(self): return self.scrollpane @property def script(self): end = self.scriptpane.document.length _script = ( self.scriptpane.document.getText(0, end) + "\nmessage.build_message()" ) if _script == self._script: return self._code self._script = _script self._code = compile(_script, "<string>", "exec") return self._code
class BurpExtender(IBurpExtender, IExtensionStateListener, IHttpListener, ITab): def registerExtenderCallbacks(self, callbacks): self.callbacks = callbacks self.helpers = callbacks.helpers # text pane self.scriptpane = JTextPane() self.scriptpane.setFont(Font('Monospaced', Font.PLAIN, 11)) self.scrollpane = JScrollPane() self.scrollpane.setViewportView(self.scriptpane) # compile to bytecode self._code = compile('', '<string>', 'exec') self._script = '' # load configuration settings for the extension that were saved using the method saveExtensionSetting(). script = callbacks.loadExtensionSetting('script') if script: script = base64.b64decode(script) self.scriptpane.document.insertString( self.scriptpane.document.length, script, SimpleAttributeSet()) self._script = script self._code = compile(script, '<string>', 'exec') # register callbacks.registerExtensionStateListener(self) callbacks.registerHttpListener(self) # ui callbacks.customizeUiComponent(self.getUiComponent()) callbacks.addSuiteTab(self) self.scriptpane.requestFocus() # # extender unload # def extensionUnloaded(self): try: # save script, base64 encode self.callbacks.saveExtensionSetting( 'script', base64.b64encode(self._script)) except Exception: traceback.print_exc(file=self.callbacks.getStderr()) return # # implement IHttpListener # def processHttpMessage(self, toolFlag, messageIsRequest, messageInfo): try: globals_ = {'extender': self, 'callbacks': self.callbacks, 'helpers': self.helpers } locals_ = {'toolFlag': toolFlag, 'messageIsRequest': messageIsRequest, 'messageInfo': messageInfo } exec(self.script, globals_, locals_) except Exception: traceback.print_exc(file=self.callbacks.getStderr()) return # # implement ITab # def getTabCaption(self): return 'Script' def getUiComponent(self): return self.scrollpane # # script 不变时,不用重复编译, 优化性能 # @property def script(self): end = self.scriptpane.document.length _script = self.scriptpane.document.getText(0, end) if _script == self._script: return self._code self._script = _script self._code = compile(_script, '<string>', 'exec') return self._code
class MainPanel(): """Represents the converted frame from NetBeans.""" # mostly converted generated code def __init__(self, table=None): self.jScrollPane1 = JScrollPane() self.jTable1 = JTable() self.jPanel1 = JPanel() self.labelName = JLabel() self.textName = JTextField() self.labelSeverity = JLabel() self.textSeverity = JTextField() self.labelHost = JLabel() self.labelPath = JLabel() self.textHost = JTextField() self.textPath = JTextField() self.tabIssue = JTabbedPane() self.panelDescription = JPanel() self.panelRequest = JPanel() self.panelResponse = JPanel() self.panelRemediation = JPanel() # setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE) self.jTable1 = table # wrap the table in a scrollpane self.jScrollPane1.setViewportView(self.jTable1) # top panel containing the table from java.awt import Color self.jPanel1.setBorder(BorderFactory.createLineBorder(Color(0, 0, 0))) # create the labels and textfields self.labelName.text = "Issue Type/Name" self.textName.text = "Issue Name/Type" self.textName.editable = False self.textName.setBackground(Color.LIGHT_GRAY) self.labelSeverity.text = "Severity" self.textSeverity.text = "" self.textSeverity.editable = False self.textSeverity.setBackground(Color.LIGHT_GRAY) self.labelHost.text = "Host" self.textHost.text = "Issue Host" self.textHost.editable = False self.textHost.setBackground(Color.LIGHT_GRAY) self.labelPath.text = "Path" self.textPath.text = "Issue Path" self.textPath.editable = False self.textPath.setBackground(Color.LIGHT_GRAY) from java.lang import Short # description panel panelDescriptionLayout = GroupLayout(self.panelDescription) self.panelDescription.setLayout(panelDescriptionLayout) panelDescriptionLayout.setHorizontalGroup( panelDescriptionLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE)) panelDescriptionLayout.setVerticalGroup( panelDescriptionLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE)) self.tabIssue.addTab("Description", self.panelDescription) # request tab panelRequestLayout = GroupLayout(self.panelRequest) self.panelRequest.setLayout(panelRequestLayout) panelRequestLayout.setHorizontalGroup( panelRequestLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE)) panelRequestLayout.setVerticalGroup( panelRequestLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE)) self.tabIssue.addTab("Request", self.panelRequest) # response tab panelResponseLayout = GroupLayout(self.panelResponse) self.panelResponse.setLayout(panelResponseLayout) panelResponseLayout.setHorizontalGroup( panelResponseLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE)) panelResponseLayout.setVerticalGroup( panelResponseLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE)) self.tabIssue.addTab("Response", self.panelResponse) # remediation tab panelRemediationLayout = GroupLayout(self.panelRemediation) self.panelRemediation.setLayout(panelRemediationLayout) panelRemediationLayout.setHorizontalGroup( panelRemediationLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE)) panelRemediationLayout.setVerticalGroup( panelRemediationLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE)) self.tabIssue.addTab("Remediation", self.panelRemediation) # jpanel1? jPanel1Layout = GroupLayout(self.jPanel1) self.jPanel1.setLayout(jPanel1Layout) jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING). addGroup(jPanel1Layout.createSequentialGroup().addContainerGap( ).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.LEADING). addGroup(jPanel1Layout.createSequentialGroup().addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.TRAILING).addComponent( self.labelHost).addComponent( self.labelSeverity).addComponent( self.labelName) ).addPreferredGap( LayoutStyle.ComponentPlacement.UNRELATED).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.LEADING). addComponent(self.textName).addGroup( jPanel1Layout.createSequentialGroup().addComponent( self.textSeverity, GroupLayout.PREFERRED_SIZE, 98, GroupLayout.PREFERRED_SIZE).addGap( 0, 0, Short.MAX_VALUE)). addGroup( jPanel1Layout.createSequentialGroup().addComponent( self.textHost, GroupLayout.PREFERRED_SIZE, 330, GroupLayout.PREFERRED_SIZE).addGap(18, 18, 18). addComponent(self.labelPath).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED ).addComponent(self.textPath)))).addComponent( self.tabIssue)).addContainerGap())) jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING). addGroup(jPanel1Layout.createSequentialGroup().addContainerGap( ).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.labelName).addComponent( self.textName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.labelSeverity).addComponent( self.textSeverity, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup( jPanel1Layout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.labelHost).addComponent( self.labelPath).addComponent( self.textHost, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.textPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)). addPreferredGap( LayoutStyle.ComponentPlacement.RELATED).addComponent( self.tabIssue).addContainerGap())) # create the main panel self.panel = JPanel() layout = GroupLayout(self.panel) self.panel.setLayout(layout) layout.setAutoCreateGaps(True) layout.setHorizontalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( layout.createSequentialGroup().addContainerGap().addGroup( layout.createParallelGroup( GroupLayout.Alignment.LEADING).addComponent( self.jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent( self.jScrollPane1)).addContainerGap())) layout.setVerticalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( layout.createSequentialGroup().addContainerGap().addComponent( self.jScrollPane1, GroupLayout.PREFERRED_SIZE, 119, GroupLayout.PREFERRED_SIZE).addGap( 18, 18, 18).addComponent(self.jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addContainerGap()))
class main(JFrame): def __init__(self): super(main,self).__init__() self.Config() self.windows() self.ruta="" def windows(self): self.setTitle("IDE Meta Compilador") self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) self.setLayout(None) self.setLocationRelativeTo(None) self.setVisible(True) def Config(self): self.panel = JScrollPane() self.txtArea_Principal =JTextArea() self.jScrollPane1 =JScrollPane() self.txtTerminal =JTextArea() self.Menu =JMenuBar() self.menu_Archivo =JMenu() self.menu_Nuevo =JMenuItem() self.menuabrir =JMenuItem() self.menucerrar =JMenuItem() self.menuguardar =JMenuItem() self.menuguardarcomo =JMenuItem() self.menusalir =JMenuItem() self.menu_Edicion =JMenu() self.menu_cortar =JMenuItem() self.menu_copiar =JMenuItem() self.menu_pegar =JMenuItem() self.menu_Tablas =JMenu() self.menu_TablasEstaticas =JMenu() self.submenu_palabrasReservadas =JMenuItem() self.submenu_CaracteresEspeciales =JMenuItem() self.submenu_operadores =JMenu() self.ta_di_conu_enteros =JMenuItem() self.ta_di_conu_reales =JMenuItem() self.ta_di_conu_cientificos =JMenuItem() self.menu_TablaasDinamicas =JMenu() self.submenu_simbolos =JMenuItem() self.submenu_identificadores =JMenuItem() self.submenu_errores =JMenuItem() self.submenu_constantesNumericas =JMenu() self.ta_es_op_aritmeticos =JMenuItem() self.ta_es_op_relacionales =JMenuItem() self.ta_es_op_logicos =JMenuItem() self.submenu_Constantes_No_Numericas =JMenu() self.tab_caracteres =JMenuItem() self.tab_cadenas =JMenuItem() self.menu_Analisis =JMenu() self.ana_lexico =JMenuItem() self.ana_sintactico =JMenuItem() self.ana_semantico =JMenuItem() self.menu_Acerca_de =JMenu() self.btn_integrantes =JMenuItem() ######################### self.jf = JFileChooser() ######################### self.txtArea_Principal.setColumns(20) self.txtArea_Principal.setRows(5) self.txtArea_Principal.setAutoscrolls(False) self.txtArea_Principal.setEnabled(False) self.panel.setViewportView(self.txtArea_Principal) self.getContentPane().add(self.panel) self.panel.setBounds(0, 0, 1080, 450) self.txtTerminal.setColumns(20) self.txtTerminal.setRows(5) self.txtTerminal.setAutoscrolls(False) self.txtTerminal.setFocusable(False) self.jScrollPane1.setViewportView(self.txtTerminal) self.getContentPane().add(self.jScrollPane1) self.jScrollPane1.setBounds(0, 460, 1080, 150) # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU ARCHIVOS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< self.menu_Archivo.setText("Archivo") self.menu_Nuevo.addActionListener(lambda event : self.nuevo(event)) self.menu_Nuevo.setText("Nuevo") self.menu_Archivo.add(self.menu_Nuevo) self.menuabrir.setText("Abrir") self.menuabrir.addActionListener(lambda event : self.abrir(event)) self.menu_Archivo.add(self.menuabrir) self.menucerrar.setText("Cerrar") self.menucerrar.addActionListener(lambda event : self.cerrar(event)) self.menu_Archivo.add(self.menucerrar) self.menuguardar.setText("Guardar") self.menuguardar.addActionListener(lambda event : self.guardar(event)) self.menu_Archivo.add(self.menuguardar) self.menuguardarcomo.setText("Guardar como") self.menuguardarcomo.addActionListener(lambda event : self.guardarcomo(event)) self.menu_Archivo.add(self.menuguardarcomo) self.menusalir.setText("Salir") self.menusalir.addActionListener(lambda event : self.salir(event)) self.menu_Archivo.add(self.menusalir) self.Menu.add(self.menu_Archivo) # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU EDICION<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< self.menu_Edicion.setText("Edicion") self.menu_cortar.setText("Cortar") self.menu_cortar.addActionListener(lambda event : self.cortar(event)) self.menu_Edicion.add(self.menu_cortar) self.menu_copiar.setText("Copiar") self.menu_copiar.addActionListener(lambda event : self.copiar(event)) self.menu_Edicion.add(self.menu_copiar) self.menu_pegar.setText("Pegar") self.menu_pegar.addActionListener(lambda event : self.pegar(event)) self.menu_Edicion.add(self.menu_pegar) self.Menu.add(self.menu_Edicion) # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU TABLAS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< self.menu_Tablas.setText("Tablas") self.menu_TablasEstaticas.setText("Tablas Estaticas") self.submenu_palabrasReservadas.setText("Tabla de palabras reservadas") self.menu_TablasEstaticas.add(self.submenu_palabrasReservadas) self.submenu_CaracteresEspeciales.setText("Tabla de caracteres especiales") self.menu_TablasEstaticas.add(self.submenu_CaracteresEspeciales) self.submenu_operadores.setText("Tabla de operadores") self.ta_es_op_aritmeticos.setText("Aritmeticos") self.submenu_operadores.add(self.ta_es_op_aritmeticos) self.ta_es_op_relacionales.setText("Relacionales") self.submenu_operadores.add(self.ta_es_op_relacionales) self.ta_es_op_logicos.setText("Logicos") self.submenu_operadores.add(self.ta_es_op_logicos) self.menu_TablasEstaticas.add(self.submenu_operadores) self.menu_Tablas.add(self.menu_TablasEstaticas) self.menu_TablaasDinamicas.setText("Tablas Dinamicas") self.submenu_simbolos.setText("Tabla de simbolos") self.menu_TablaasDinamicas.add(self.submenu_simbolos) self.submenu_identificadores.setText("Tabla de identificadores") self.menu_TablaasDinamicas.add(self.submenu_identificadores) self.submenu_errores.setText("Tabla de errores") self.menu_TablaasDinamicas.add(self.submenu_errores) self.submenu_constantesNumericas.setText("Tabla de constantes numericas") self.ta_di_conu_enteros.setText("Enteros") self.ta_di_conu_enteros.addActionListener(lambda event : self.numeroenteros(event)) self.submenu_constantesNumericas.add(self.ta_di_conu_enteros) self.ta_di_conu_reales.setText("Reales") self.ta_di_conu_reales.addActionListener(lambda event : self.numeroreales(event)) self.submenu_constantesNumericas.add(self.ta_di_conu_reales) self.ta_di_conu_cientificos.setText("Cientificos") self.submenu_constantesNumericas.add(self.ta_di_conu_cientificos) self.menu_TablaasDinamicas.add(self.submenu_constantesNumericas) self.submenu_Constantes_No_Numericas.setText("Tabla de constantes no numericas") self.tab_caracteres.setText("Caracteres") self.submenu_Constantes_No_Numericas.add(self.tab_caracteres) self.tab_cadenas.setText("Cadenas") self.submenu_Constantes_No_Numericas.add(self.tab_cadenas) self.menu_TablaasDinamicas.add(self.submenu_Constantes_No_Numericas) self.menu_Tablas.add(self.menu_TablaasDinamicas) self.Menu.add(self.menu_Tablas) # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU ANALISIS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< self.menu_Analisis.setText("Analisis") self.ana_lexico.setText("Lexico") self.ana_lexico.addActionListener(lambda event : self.lexico(event)) self.menu_Analisis.add(self.ana_lexico) self.ana_sintactico.setText("Sintactico") self.ana_sintactico.addActionListener(lambda event : self.sintactico(event)) self.menu_Analisis.add(self.ana_sintactico) self.ana_semantico.setText("Semantico") self.menu_Analisis.add(self.ana_semantico) self.Menu.add(self.menu_Analisis) # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU ACERCA DE<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< self.menu_Acerca_de.setText("Acerca de") self.btn_integrantes.setText("Integrante del proyecto") self.btn_integrantes.addActionListener(lambda event : self.integrantes(event)) self.menu_Acerca_de.add(self.btn_integrantes) self.Menu.add(self.menu_Acerca_de) self.setJMenuBar(self.Menu) self.setBounds(0, 0, 1095, 670) ###################################### def integrantes(self,event): informacion() def cortar(self,event): self.txtArea_Principal.cut() def copiar(self,event): self.txtArea_Principal.copy() def pegar(self,event): self.txtArea_Principal.paste() def salir(self,event): self.dispose() ###################################### def guardarcomo(self,event): pass def guardar(self,event): if self.ruta == "": self.txtTerminal.setText("no hay un directorio abierto") else: agregar(self.ruta,str(self.txtArea_Principal.getText())) def cerrar(self,event): self.txtArea_Principal.setText("") self.txtArea_Principal.setEnabled(False) self.ruta="" def abrir(self,event): self.jf.showOpenDialog(self) self.ruta = self.jf.getSelectedFile() self.txtArea_Principal.setEnabled(True) self.txtArea_Principal.setText(abrir(self.ruta)) def nuevo(self,event): if self.ruta == "": print("no pasa nada") else: print("hay un archivo existente") self.ruta ="" self.txtArea_Principal.setEnabled(True) self.txtArea_Principal.setText("") ###################################### def lexico(self,event): self.txtTerminal.setText("") archivo = open("{}".format(self.ruta),"r") texto = "" for a in prueba(self.txtArea_Principal.getText()): texto += a+"\n" self.txtTerminal.setText(texto) def sintactico(self,event): self.txtTerminal.setText("") texto="" for a in prueba_sintactica(self.txtArea_Principal.getText()): texto +=a+"\n" self.txtTerminal.setText(texto)
def _create_texteditor(self, name=None, label=None): _textarea = None if name and name in self._widgets: return self._widgets[name] if not name: name = "TextArea#%s" % self._idx self._idx += 1 this = JPanel() # Add a label if label: this.setLayout(BorderLayout()) this.add(BorderLayout.PAGE_START, JLabel(label)) if self._texteditor_factory: _texteditor = self._texteditor_factory() _component = _texteditor.getComponent() this.add(BorderLayout.CENTER, _component) _textarea = self._get_textarea(_component) if not _textarea: _textarea = JTextArea() _textarea.setColumns(20) _textarea.setRows(5) _textarea.setLineWrap(True) _textarea.setWrapStyleWord(True) _textarea.setEditable(True) _textarea.setName(name) _textarea.setSelectionColor(Color(255, 153, 51)) _textarea.requestFocus() # Add textarea to a scrollable JPane _scrollpane = JScrollPane() _scrollpane.setViewportView(_textarea) this.add(BorderLayout.CENTER, _scrollpane) _textarea.setEditable(self.editable) self._textareas[name] = _textarea self._widgets[name] = this def on_change(evt): if not self._textareas[name].hasFocus(): return try: if name == "raw": SwingUtilities.invokeLater(lambda: self._refresh_queries( self._textareas['raw'].getText())) elif name.startswith('gql_query#'): id = int(name.split("#")[1]) content = json.loads(self._textareas['raw'].getText()) if id == 0 and not isinstance(content, list): content['query'] = self._textareas[name].getText() else: content[id]['query'] = self._textareas[name].getText() SwingUtilities.invokeLater(lambda: self._textareas['raw']. setText(json.dumps(content))) elif name.startswith('gql_variables#'): id = int(name.split("#")[1]) content = json.loads(self._textareas['raw'].getText()) if id == 0 and not isinstance(content, list): content['variables'] = json.loads( self._textareas[name].getText()) else: content[id]['variables'] = json.loads( self._textareas[name].getText()) SwingUtilities.invokeLater(lambda: self._textareas['raw']. setText(json.dumps(content))) except ValueError: pass # Avoid crashing for JSON not valid incompatibilities _textarea.getDocument().addDocumentListener( _PayloadListener(changed_update=on_change)) return this
class BurpExtender(IBurpExtender, IExtensionStateListener, IHttpListener, ITab): def registerExtenderCallbacks(self, callbacks): self.callbacks = callbacks self.helpers = callbacks.helpers self.scriptpane = JTextPane() self.scriptpane.setFont(Font('Monospaced', Font.PLAIN, 11)) self.scrollpane = JScrollPane() self.scrollpane.setViewportView(self.scriptpane) self._code = compile('', '<string>', 'exec') self._script = '' script = callbacks.loadExtensionSetting('script') if script: script = base64.b64decode(script) self.scriptpane.document.insertString( self.scriptpane.document.length, script, SimpleAttributeSet()) self._script = script try: self._code = compile(script, '<string>', 'exec') except Exception as e: traceback.print_exc(file=self.callbacks.getStderr()) callbacks.registerExtensionStateListener(self) callbacks.registerHttpListener(self) callbacks.customizeUiComponent(self.getUiComponent()) callbacks.addSuiteTab(self) self.scriptpane.requestFocus() def extensionUnloaded(self): try: self.callbacks.saveExtensionSetting('script', base64.b64encode(self._script)) except Exception: traceback.print_exc(file=self.callbacks.getStderr()) return def processHttpMessage(self, toolFlag, messageIsRequest, messageInfo): try: globals_ = {'postToAPI': self.postToAPI} locals_ = { 'extender': self, 'callbacks': self.callbacks, 'helpers': self.helpers, 'toolFlag': toolFlag, 'messageIsRequest': messageIsRequest, 'messageInfo': messageInfo } exec(self.script, globals_, locals_) except Exception: traceback.print_exc(file=self.callbacks.getStderr()) return def getTabCaption(self): return 'Script' def getUiComponent(self): return self.scrollpane def postToAPI(self, api_url, action, charset, postData): reqdata = {'action': action, 'charset': charset, 'postData': postData} headers = {'Content-Type': 'application/json'} req = urllib2.Request(url=api_url, headers=headers, data=json.dumps(reqdata)) res_data = urllib2.urlopen(req) @property def script(self): end = self.scriptpane.document.length _script = self.scriptpane.document.getText(0, end) if _script == self._script: return self._code self._script = _script self._code = compile(_script, '<string>', 'exec') return self._code
def _initializeGui(self, callbacks): tab = JPanel() jLabel1 = JLabel("Original Hash:") jLabel2 = JLabel("Original message:") jLabel3 = JLabel("Message to append:") jLabel5 = JLabel("Max key length:") jTextField1 = JTextField("") jTextField2 = JTextField("") jTextField3 = JTextField("") jTextField4 = JTextField("128") jLabel4 = JLabel("Hashing functions") jCheckBox1 = JCheckBox("MD4") jCheckBox2 = JCheckBox("MD5") jCheckBox3 = JCheckBox("SHA1") jCheckBox4 = JCheckBox("SHA256") jCheckBox5 = JCheckBox("SHA512") jCheckBox1.setEnabled(False) jCheckBox2.setEnabled(False) jCheckBox3.setEnabled(False) jCheckBox4.setEnabled(False) jCheckBox5.setEnabled(False) jScrollPane1 = JScrollPane() jTable1 = JTable() jButton1 = JButton("Generate", actionPerformed=self.generate_attack) jButton1.setEnabled(False) jButton2 = JButton("Copy messages", actionPerformed=self.copy_messages) jButton3 = JButton("Copy hashes", actionPerformed=self.copy_hashes) self._tab = tab self._textfields = { "original_hash": jTextField1, "original_msg": jTextField2, "append_msg": jTextField3, "max_key_len": jTextField4, } self._checkboxes = { md4: jCheckBox1, md5: jCheckBox2, sha1: jCheckBox3, sha256: jCheckBox4, sha512: jCheckBox5, } self._table = jTable1 self._extensions = {} self._hashes, self._messages = [], [] # Hash field change event jTextField1.getDocument().addDocumentListener(HashChangeListener(self._checkboxes, self._textfields['original_hash'], jButton1)) # Table columns jTable1.setModel(DefaultTableModel([],["#", "Type","New Message", "Hash"])) jScrollPane1.setViewportView(jTable1) # Table column width jTable1.getColumnModel().getColumn(0).setMaxWidth(50) jTable1.getColumnModel().getColumn(1).setMaxWidth(60) layout = GroupLayout(tab) tab.setLayout(layout) layout.setHorizontalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(24, 24, 24) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent(jLabel5) .addComponent(jLabel1) .addComponent(jLabel2) .addComponent(jLabel3)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jTextField3, GroupLayout.DEFAULT_SIZE, 425, 32767) .addComponent(jTextField2) .addComponent(jTextField1) .addGroup(layout.createSequentialGroup() .addComponent(jTextField4, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 32767))) .addGap(30, 30, 30) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jCheckBox1) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(jCheckBox2) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(jCheckBox3) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(jCheckBox4) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(jCheckBox5)) .addComponent(jLabel4) .addGroup(layout.createSequentialGroup() .addComponent(jButton1) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton3) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton2))) .addGap(167, 167, 167)) .addComponent(jScrollPane1) ) layout.setVerticalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(26, 26, 26) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(jTextField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jTextField2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jCheckBox2) .addComponent(jCheckBox3) .addComponent(jCheckBox1) .addComponent(jCheckBox4) .addComponent(jCheckBox5))) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jTextField3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jLabel5) .addComponent(jTextField4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jButton2) .addComponent(jButton3) .addComponent(jButton1)) .addGap(13, 13, 13) .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 971, 32767)) ) callbacks.customizeUiComponent(tab) callbacks.addSuiteTab(self)
class BurpExtender(IBurpExtender, IExtensionStateListener, IHttpListener, ITab, FocusListener, ActionListener, MouseAdapter): _version = "0.2" _name = "PyRules" _varsStorage = _name + "_vars" _scriptStorage = _name + "_script" _enabled = 0 _vars = {} def registerExtenderCallbacks(self, callbacks): print "Load:" + self._name + " " + self._version self.callbacks = callbacks self.helpers = callbacks.helpers #Create Tab layout self.jVarsPane = JTextPane() self.jVarsPane.setFont(Font('Monospaced', Font.PLAIN, 11)) self.jVarsPane.addFocusListener(self) self.jMenuPanel = JPanel() self.jLeftUpPanel = JPanel() self.jEnable = JCheckBox() self.jEnable.setFont(Font('Monospaced', Font.BOLD, 11)) self.jEnable.setForeground(Color(0, 0, 204)) self.jEnable.setText(self._name) self.jEnable.addActionListener(self) self.jDocs = JLabel() self.jDocs.setFont(Font('Monospaced', Font.PLAIN, 11)) self.jDocs.setForeground(Color(51, 102, 255)) self.jDocs.setText(Strings.docs_titel) self.jDocs.setToolTipText(Strings.docs_tooltip) self.jDocs.addMouseListener(self) self.jConsoleText = JTextArea() self.jConsoleText.setFont(Font('Monospaced', Font.PLAIN, 10)) self.jConsoleText.setBackground(Color(244, 246, 247)) self.jConsoleText.setEditable(0) self.jConsoleText.setWrapStyleWord(1) self.jConsoleText.setRows(10) self.jScrollConsolePane = JScrollPane() self.jScrollConsolePane.setViewportView(self.jConsoleText) #set initial text self.jConsoleText.setText(Strings.console_disable) self.jMenuPanelLayout = GroupLayout(self.jMenuPanel) self.jMenuPanel.setLayout(self.jMenuPanelLayout) self.jMenuPanelLayout.setHorizontalGroup( self.jMenuPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGroup( self.jMenuPanelLayout.createSequentialGroup().addComponent( self.jEnable).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED, 205, 32767).addComponent(self.jDocs))) self.jMenuPanelLayout.setVerticalGroup( self.jMenuPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGroup( self.jMenuPanelLayout.createSequentialGroup().addGroup( self.jMenuPanelLayout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.jEnable).addComponent(self.jDocs)).addGap( 0, 7, 32767))) self.jConsolePane = JPanel() self.jConsoleLayout = GroupLayout(self.jConsolePane) self.jConsolePane.setLayout(self.jConsoleLayout) self.jConsoleLayout.setHorizontalGroup( self.jConsoleLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addComponent( self.jScrollConsolePane)) self.jConsoleLayout.setVerticalGroup( self.jConsoleLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addGroup( GroupLayout.Alignment.TRAILING, self.jConsoleLayout.createSequentialGroup().addComponent( self.jScrollConsolePane, GroupLayout.DEFAULT_SIZE, 154, 32767).addContainerGap())) self.jLeftUpPanelLayout = GroupLayout(self.jLeftUpPanel) self.jLeftUpPanel.setLayout(self.jLeftUpPanelLayout) self.jLeftUpPanelLayout.setHorizontalGroup( self.jLeftUpPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING).addComponent( self.jConsolePane, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, 32767).addComponent(self.jMenuPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) self.jLeftUpPanelLayout.setVerticalGroup( self.jLeftUpPanelLayout. createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( GroupLayout.Alignment.TRAILING, self.jLeftUpPanelLayout.createSequentialGroup().addComponent( self.jMenuPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED).addComponent( self.jConsolePane, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, 32767))) self.jScrollpaneLeftDown = JScrollPane() self.jScrollpaneLeftDown.setViewportView(self.jVarsPane) self.jSplitPaneLeft = JSplitPane(JSplitPane.VERTICAL_SPLIT, self.jLeftUpPanel, self.jScrollpaneLeftDown) self.jSplitPaneLeft.setDividerLocation(300) self.jScriptPane = JTextPane() self.jScriptPane.setFont(Font('Monospaced', Font.PLAIN, 11)) self.jScriptPane.addMouseListener(self) self.JScrollPaneRight = JScrollPane() self.JScrollPaneRight.setViewportView(self.jScriptPane) self.jSplitPane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT, self.jSplitPaneLeft, self.JScrollPaneRight) self.jSplitPane.setDividerLocation(400) #Load saved saved settings ##Load vars vars = callbacks.loadExtensionSetting(self._varsStorage) if vars: vars = base64.b64decode(vars) else: # try to load the example try: with open("examples/Simple-CSRF-vars.py") as fvars: vars = fvars.read() # load the default text except: vars = Strings.vars ## initiate the persistant variables locals_ = {} try: exec(vars, {}, locals_) except Exception as e: print e self._vars = locals_ ## update the vars screen self.jVarsPane.document.insertString(self.jVarsPane.document.length, vars, SimpleAttributeSet()) ##Load script script = callbacks.loadExtensionSetting(self._scriptStorage) if script: script = base64.b64decode(script) else: # try to load the example try: with open("examples/Simple-CSRF-script.py") as fscript: script = fscript.read() # load the default text except: script = Strings.script ## compile the rules self._script = script self._code = '' try: self._code = compile(script, '<string>', 'exec') except Exception as e: print( '{}\nReload extension after you correct the error.'.format(e)) ## update the rules screen self.jScriptPane.document.insertString( self.jScriptPane.document.length, script, SimpleAttributeSet()) #Register Extension callbacks.customizeUiComponent(self.getUiComponent()) callbacks.addSuiteTab(self) callbacks.registerExtensionStateListener(self) callbacks.registerHttpListener(self) self.jScriptPane.requestFocus() def getUiComponent(self): return self.jSplitPane def getTabCaption(self): return self._name def actionPerformed(self, event): #Check box was clicked if self.jEnable == event.getSource(): if self._enabled == 1: self._enabled = 0 # console content shows help self.jConsoleText.setText(Strings.console_disable) else: self._enabled = 1 # console content displays the current persistent variable state self.jConsoleText.setText(Strings.console_state) self.jConsoleText.append(pformat(self._vars)) self.jConsoleText.append(Strings.extra_line) self.jConsoleText.append(Strings.console_log) return def mouseClicked(self, event): if event.source == self.jDocs: uri = URI.create("https://github.com/DanNegrea/PyRules") if uri and Desktop.isDesktopSupported() and Desktop.getDesktop( ).isSupported(Desktop.Action.BROWSE): Desktop.getDesktop().browse(uri) return def focusGained(self, event): if self.jConsolePane == event.getSource(): pass #print "Status pane gained focus" #debug return def focusLost(self, event): #Reinitialize the persistent values if self.jVarsPane == event.getSource(): # get the text from the pane end = self.jVarsPane.document.length vars = self.jVarsPane.document.getText(0, end) # compute the new values locals_ = {} exec(vars, {}, locals_) self._vars = locals_ # display the new result in console self.jConsoleText.append(Strings.console_state) self.jConsoleText.append(pformat(self._vars)) self.jConsoleText.append(Strings.extra_line) self.jConsoleText.append(Strings.console_log) # scroll to bottom verticalScrollBar = self.jScrollConsolePane.getVerticalScrollBar() verticalScrollBar.setValue(verticalScrollBar.getMaximum()) return def extensionUnloaded(self): try: #Save the latestest vars and script text ## save vars end = self.jVarsPane.document.length vars = self.jVarsPane.document.getText(0, end) vars = base64.b64encode(vars) self.callbacks.saveExtensionSetting(self._varsStorage, vars) ## save script/rules end = self.jScriptPane.document.length script = self.jScriptPane.document.getText(0, end) script = base64.b64encode(script) self.callbacks.saveExtensionSetting(self._scriptStorage, script) except Exception: traceback.print_exc(file=self.callbacks.getStderr()) print "Unloaded" #debug return def processHttpMessage(self, toolFlag, messageIsRequest, messageInfo): if self._enabled == 0: return try: locals_ = { 'extender': self, 'callbacks': self.callbacks, 'helpers': self.helpers, 'toolFlag': toolFlag, 'messageIsRequest': messageIsRequest, 'messageInfo': messageInfo, 'log': self.log } # add the _vars as gloval variables locals_ = dict(locals_, **self._vars) # execute the script/rules try: exec(self.getCode, {}, locals_) # catch exit() call inside the rule except SystemExit: pass # update the persistant variables by searching the local variables with the same name for key in self._vars: # assumption self._vars dictionary is smaller than locals_ if key in locals_: self._vars[key] = locals_[key] except Exception: traceback.print_exc(file=self.callbacks.getStderr()) return #Returns the compiled script @property def getCode(self): end = self.jScriptPane.document.length script = self.jScriptPane.document.getText(0, end) # if the script hasn't changed return the already compile text if script == self._script: return self._code self._script = script # compile, store and return the result self._code = compile(script, '<string>', 'exec') return self._code #Log the information into the console screen def log(self, obj): # if string just append. else use pformat from pprint if isinstance(obj, str): self.jConsoleText.append(obj + "\n") else: self.jConsoleText.append(pformat(obj) + "\n") # scroll to bottom verticalScrollBar = self.jScrollConsolePane.getVerticalScrollBar() verticalScrollBar.setValue(verticalScrollBar.getMaximum()) return
class BurpExtender(IBurpExtender, ISessionHandlingAction, IExtensionStateListener, IHttpListener, ITab): def registerExtenderCallbacks(self, callbacks): self.callbacks = callbacks self.helpers = callbacks.helpers self.scriptpane = JTextPane() self.scriptpane.setFont(Font('Monospaced', Font.PLAIN, 11)) self.scrollpane = JScrollPane() self.scrollpane.setViewportView(self.scriptpane) self._code = compile('', '<string>', 'exec') self._script = '' script = callbacks.loadExtensionSetting('script') if script: script = base64.b64decode(script) self.scriptpane.document.insertString( self.scriptpane.document.length, script, SimpleAttributeSet()) self._script = script try: self._code = compile(script, '<string>', 'exec') except Exception as e: traceback.print_exc(file=self.callbacks.getStderr()) callbacks.setExtensionName("Python Scripter (modified)") callbacks.registerSessionHandlingAction(self) callbacks.registerExtensionStateListener(self) callbacks.registerHttpListener(self) callbacks.customizeUiComponent(self.getUiComponent()) callbacks.addSuiteTab(self) self.scriptpane.requestFocus() return def getActionName(self): return 'Send to Python Scripter' def extensionUnloaded(self): try: self.callbacks.saveExtensionSetting('script', base64.b64encode(self._script)) except Exception: traceback.print_exc(file=self.callbacks.getStderr()) return def performAction(self, currentRequest, macroItems): self.processHttpMessage(self.callbacks.TOOL_MACRO, 1, currentRequest, macroItems) return def processHttpMessage(self, toolFlag, messageIsRequest, messageInfo, macroItems=[]): try: globals_ = {} locals_ = { 'extender': self, 'callbacks': self.callbacks, 'helpers': self.helpers, 'toolFlag': toolFlag, 'messageIsRequest': messageIsRequest, 'messageInfo': messageInfo, 'macroItems': macroItems } exec(self.script, globals_, locals_) except Exception: traceback.print_exc(file=self.callbacks.getStderr()) return def getTabCaption(self): return 'Script' def getUiComponent(self): return self.scrollpane @property def script(self): end = self.scriptpane.document.length _script = self.scriptpane.document.getText(0, end) if _script == self._script: return self._code self._script = _script self._code = compile(_script, '<string>', 'exec') return self._code
def __init__(self, arg_dict): super(CumulusUI, self).__init__() # Load argument from the command line self.start_time = arg_dict['start_time'] self.end_time = arg_dict['end_time'] self.dss_path = arg_dict['dss_path'] self.cwms_home = arg_dict['cwms_home'] self.config = arg_dict['config'] # Get the DSS Path if one was saved in the "cumulus.config" file if os.path.isfile(self.config): with open(os.path.join(APPDATA, "cumulus.config")) as f: self.dss_path = f.read() # Get the basins and products, load JSON, create lists for JList, and create dictionaries self.basin_download = json.loads(self.http_get(url_basins)) self.jlist_basins = ["{}:{}".format(b['office_symbol'], b['name']) for b in self.basin_download] self.basin_meta = dict(zip(self.jlist_basins, self.basin_download)) self.jlist_basins.sort() self.product_download = json.loads(self.http_get(url_products)) self.jlist_products = ["{}".format(p['name'].replace("_", " ").title()) for p in self.product_download] self.product_meta = dict(zip(self.jlist_products, self.product_download)) self.jlist_products.sort() btn_submit = JButton() lbl_start_date = JLabel() lbl_end_date = JLabel() self.txt_select_file = JTextField() btn_select_file = JButton() lbl_origin = JLabel() lbl_extent = JLabel() lbl_select_file = JLabel() self.txt_start_time = JTextField() self.txt_end_time = JTextField() jScrollPane1 = JScrollPane() self.lst_product = JList() self.lst_product = JList(self.jlist_products, valueChanged = self.choose_product) jScrollPane2 = JScrollPane() self.lst_watershed = JList() self.lst_watershed = JList(self.jlist_basins, valueChanged = self.choose_watershed) self.cwms_dssname = JCheckBox() self.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE) self.setTitle("Cumulus CAVI UI") self.setLocation(Point(10, 10)) self.setLocationByPlatform(True) self.setName("CumulusCaviUi") self.setResizable(False) btn_submit.setFont(Font("Tahoma", 0, 18)) btn_submit.setText("Submit") btn_submit.actionPerformed = self.submit lbl_start_date.setText("Start Date/Time") lbl_end_date.setText("End Date/Time") self.txt_select_file.setToolTipText("FQPN to output file (.dss)") btn_select_file.setText("...") btn_select_file.setToolTipText("Select File...") btn_select_file.actionPerformed = self.select_file lbl_origin.setText("Minimum (x,y):") lbl_extent.setText("Maximum (x,y):") lbl_select_file.setText("Output File Location") self.txt_start_time.setToolTipText("Start Time") self.txt_end_time.setToolTipText("End Time") self.lst_product.setBorder(BorderFactory.createTitledBorder(None, "Available Products", TitledBorder.CENTER, TitledBorder.TOP, Font("Tahoma", 0, 14))) self.lst_product.setFont(Font("Tahoma", 0, 14)) jScrollPane1.setViewportView(self.lst_product) self.lst_product.getAccessibleContext().setAccessibleName("Available Products") self.lst_product.getAccessibleContext().setAccessibleParent(jScrollPane2) self.lst_watershed.setBorder(BorderFactory.createTitledBorder(None, "Available Watersheds", TitledBorder.CENTER, TitledBorder.TOP, Font("Tahoma", 0, 14))) self.lst_watershed.setFont(Font("Tahoma", 0, 14)) self.lst_watershed.setSelectionMode(ListSelectionModel.SINGLE_SELECTION) jScrollPane2.setViewportView(self.lst_watershed) self.cwms_dssname.setText("CWMS DSS filename") self.cwms_dssname.setToolTipText("Parameter.yyyy.mm.dss") self.cwms_dssname.setVisible(False) layout = GroupLayout(self.getContentPane()); self.getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, False) .addComponent(lbl_select_file) .addComponent(jScrollPane1) .addComponent(jScrollPane2) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent(btn_submit) .addComponent(self.txt_select_file, GroupLayout.PREFERRED_SIZE, 377, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(btn_select_file)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(lbl_start_date) .addComponent(self.txt_start_time, GroupLayout.PREFERRED_SIZE, 170, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(self.txt_end_time, GroupLayout.PREFERRED_SIZE, 170, GroupLayout.PREFERRED_SIZE) .addComponent(lbl_end_date)))) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ) layout.setVerticalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGap(25, 25, 25) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(lbl_start_date) .addComponent(lbl_end_date)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(self.txt_start_time, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(self.txt_end_time, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addComponent(jScrollPane2, GroupLayout.PREFERRED_SIZE, 201, GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 201, GroupLayout.PREFERRED_SIZE) .addGap(18, 18, Short.MAX_VALUE) .addComponent(lbl_select_file) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(self.txt_select_file, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(btn_select_file)) .addGap(18, 18, 18) .addComponent(btn_submit) .addContainerGap()) ) self.txt_select_file.setText(self.dss_path) self.txt_start_time.setText(self.start_time) self.txt_end_time.setText(self.end_time) self.pack() self.setLocationRelativeTo(None)