def UI(self): self.val="" self.tabbedPane = JTabbedPane(JTabbedPane.TOP) self.panel = JPanel() self.tabbedPane.addTab("App Details", None, self.panel, None) # Details of app currently under pentest would be pulled into here through API self.panel_1 = JPanel() self.tabbedPane.addTab("Results", None, self.panel_1, None) # passed results would go inside this and connected to reporting system via API self.panel_2 = JPanel() self.tabbedPane.addTab("Failed Cases", None, self.panel_2, None) #list of failed tests would go inside this self.textField = JTextField() self.textField.setBounds(12, 13, 207, 39) self.panel.add(self.textField) self.textField.setColumns(10) self.comboBox = JComboBox() self.comboBox.setEditable(True) self.comboBox.addItem("Default") self.comboBox.addItem("High") self.comboBox.addItem("Low") self.comboBox.setBounds(46, 65, 130, 28) self.comboBox.addActionListener(self) self.panel.add(self.comboBox) self.btnNewButton = JButton("Submit") self.btnNewButton.setBounds(60, 125, 97, 25) self.panel.add(self.btnNewButton) editorPane = JEditorPane(); editorPane.setBounds(12, 35, 1000, 800); self.panel_2.add(editorPane); self.panel_2.setLayout(BorderLayout()) return self.tabbedPane
def pick( self, e ) : #----------------------------------------------------------------------- # Note: Ignore valueIsAdjusting events #----------------------------------------------------------------------- if not e.getValueIsAdjusting() : List = self.List model = List.getModel() #--------------------------------------------------------------- # Is a "valid" item selected? #--------------------------------------------------------------- index = List.getSelectedIndex() if index > -1 : choice = model.elementAt( index ) if self.Links.has_key( choice ) : url = self.Links[ choice ] headerTask( url, self.splitPane ).execute() else : message = 'Nothing selected' comp = self.splitPane.getRightComponent() Type = str( comp.getClass() ).split( '.' )[ -1 ] if Type == 'JEditorPane' : comp.setText( '<html><h3>%s</h3></html>' % message ) else : area = JEditorPane( 'text/html', '<html><h3>%s</h3></html>' % message, editable = 0 ) self.splitPane.setRightComponent( area )
def tail(self, node, depth): name = node.nodeName() if self.h3Text and name == 'table': ePane = JEditorPane( 'text/html', # mime type '<html>' + str(node), # content editable=0) self.Tabs.addTab(self.h3Text, JScrollPane(ePane))
def showMessage( self, message ) : comp = self.sPane.getRightComponent() Type = str( comp.getClass() ).split( '.' )[ -1 ] if Type == 'JEditorPane' : comp.setText( '<html><h3>%s</h3></html>' % message ) else : area = JEditorPane( 'text/html', '<html><h3>%s</h3></html>' % message ) self.sPane.setRightComponent( area )
def set_advisory_tab_pane(self, scanner_issue): advisory_pane = JEditorPane() advisory_pane.setEditable(False) advisory_pane.setEnabled(True) advisory_pane.setContentType("text/html") link_listener = LinkListener() advisory_pane.addHyperlinkListener(link_listener) advisory = "<html><b>Location</b>: {}<br><br>{}</html>" advisory_pane.setText( advisory.format(scanner_issue.getUrl().encode("utf-8"), scanner_issue.getIssueDetail())) return JScrollPane(advisory_pane)
def getUiComponent(self): """Burp uses this method to obtain the component that should be used as the contents of the custom tab when it is displayed. Returns a awt.Component. """ # GUI happens here from javax.swing import (JPanel, JSplitPane, JList, JTextPane, JScrollPane, ListSelectionModel, JLabel, JTabbedPane, JEditorPane) from java.awt import BorderLayout panel = JPanel(BorderLayout()) # create a list and then JList out of it. colors = [ "red", "orange", "yellow", "green", "cyan", "blue", "pink", "magenta", "gray", "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" ] def listSelect(event): """Add the selected index to the label. Called twice when selecting the list item by mouse. So we need to use getValueIsAdjusting inside. """ if not event.getValueIsAdjusting(): doc1.insertString(0, colors[list1.selectedIndex] + "-", None) # create a list and assign the valueChanged list1 = JList(colors, valueChanged=listSelect) list1.selectionMode = ListSelectionModel.SINGLE_SELECTION # create a StyledDocument. from javax.swing.text import DefaultStyledDocument doc1 = DefaultStyledDocument() # create a JTextPane from doc1 tab1 = JTextPane(doc1) # create a JEditorPane for tab 2 tab2 = JEditorPane("https://example.net") tab2.editable = False # create the tabbedpane tabs = JTabbedPane() tabs.addTab("Tab 1", tab1) tabs.addTab("Tab 2", tab2) # create splitpane - horizontal split spl = JSplitPane(JSplitPane.HORIZONTAL_SPLIT, JScrollPane(list1), tabs) panel.add(spl) return panel
def set_advisory_tab_pane(self, scanner_issue): advisory_pane = JEditorPane() advisory_pane.setEditable(False) advisory_pane.setEnabled(True) advisory_pane.setContentType("text/html") link_listener = LinkListener() advisory_pane.addHyperlinkListener(link_listener) fmt = "<html><b>Location</b>: {}<br><br>{}</html>" advisory_pane.setText(fmt.format(scanner_issue.getUrl(), scanner_issue.getIssueDetail())) # Set a context menu self.set_context_menu(advisory_pane, scanner_issue) return JScrollPane(advisory_pane)
def advisoryReqResp(self): self.textfield = JEditorPane("text/html", "") self.kit = HTMLEditorKit() self.textfield.setEditorKit(self.kit) self.doc = self.textfield.getDocument() self.textfield.setEditable(0) self.advisorypanel = JScrollPane() self.advisorypanel.getVerticalScrollBar() self.advisorypanel.setPreferredSize(Dimension(300,450)) self.advisorypanel.getViewport().setView((self.textfield)) self.selectedreq = [] self._requestViewer = self._callbacks.createMessageEditor(self, False) self._responseViewer = self._callbacks.createMessageEditor(self, False) self._texteditor = self._callbacks.createTextEditor() self._texteditor.setEditable(False)
def run( self ) : #----------------------------------------------------------------------- # Size the frame to use 1/2 of the screen #----------------------------------------------------------------------- screenSize = Toolkit.getDefaultToolkit().getScreenSize() frameSize = Dimension( screenSize.width >> 1, screenSize.height >> 1 ) frame = JFrame( 'javadocInfo_10', size = frameSize, defaultCloseOperation = JFrame.EXIT_ON_CLOSE ) #----------------------------------------------------------------------- # Reposition the frame to be in the center of the screen #----------------------------------------------------------------------- frame.setLocation( ( screenSize.width - frameSize.width ) >> 1, ( screenSize.height - frameSize.height ) >> 1 ) #----------------------------------------------------------------------- # Initialize the list to have exactly 1 element #----------------------------------------------------------------------- model = DefaultListModel() model.addElement( 'One moment please...' ) self.List = JList( model, valueChanged = self.pick, selectionMode = ListSelectionModel.SINGLE_SELECTION ) #----------------------------------------------------------------------- # Put the List in a ScrollPane and place it in the middle of a pane #----------------------------------------------------------------------- pane = JPanel( layout = BorderLayout() ) pane.add( JScrollPane( self.List, minimumSize = ( 300, 50 ) ), BorderLayout.CENTER ) #----------------------------------------------------------------------- # Add a TextField [for the URL of the selected entry] at the bottom #----------------------------------------------------------------------- self.text = JTextField( 'Enter text...', caretUpdate = self.caretUpdate ) pane.add( self.text, BorderLayout.SOUTH ) #----------------------------------------------------------------------- # Add the pane and a scrollable TextArea to a SplitPane in the frame #----------------------------------------------------------------------- self.area = JEditorPane( 'text/html', '<html><h3>Nothing selected</h3></html>', editable = 0 ) self.splitPane = JSplitPane( JSplitPane.HORIZONTAL_SPLIT, pane, self.area ) self.splitPane.setDividerLocation( 234 ) frame.add( self.splitPane ) #----------------------------------------------------------------------- # Create a separate thread to locate & proces the remote URL #----------------------------------------------------------------------- self.Links = {} # Initialize the Links dictionary self.classes = None # complete list of all classes found soupTask( self.List, # The visible JList instance self.text, # User input field JAVADOC_URL, # Remote web page URL to be processed self.Links, # Dictionary of links found ).execute() frame.setVisible( 1 )