def addMetadata(self, objectID, project, language): """ Add a JTable at the top of the object tab containing the metadata of the object presented in that tab. """ metadataPanel = JPanel() # TODO: Need to count protocols to set up Grid dimension metadataPanel.setLayout(GridLayout(3, 2)) projectLabel = JLabel("Project: ") projectValue = JLabel(project) languageLabel = JLabel("Language: ") languageValue = JLabel(language) # If language code is in the settings, then display name instead # of code for lang, code in self.languages.iteritems(): if code == language: languageValue.setText(lang) # TODO Protocols not yet in parsed object protocolsLabel = JLabel("ATF Protocols: ") protocolsBox = JComboBox(self.protocols) metadataPanel.add(projectLabel) metadataPanel.add(projectValue) metadataPanel.add(languageLabel) metadataPanel.add(languageValue) metadataPanel.add(protocolsLabel) metadataPanel.add(protocolsBox) # Add metadataPanel to object tab in main panel self.objectTabs[objectID].add(metadataPanel)
def __init__(self): # set up the layout self.__component = JPanel(GridBagLayout()) self.__image = JLabel() self.__album = JLabel() self.__artist = JLabel() self.__application = None self.__image.setVerticalAlignment(SwingConstants.TOP) self.__album.setVerticalAlignment(SwingConstants.TOP) self.__artist.setVerticalAlignment(SwingConstants.TOP) gbc = GridBagConstraints() gbc.fill = GridBagConstraints.VERTICAL gbc.anchor = GridBagConstraints.NORTHWEST gbc.gridx = 0 gbc.gridy = 0 gbc.weighty = 2 gbc.gridheight = 2 self.__component.add(self.__image, gbc) gbc.fill = GridBagConstraints.HORIZONTAL gbc.anchor = GridBagConstraints.NORTHWEST gbc.gridx = 1 gbc.gridy = 0 gbc.gridheight = 1 gbc.weighty = 0 gbc.insets = Insets(0, 10, 0, 10) self.__component.add(self.__album, gbc) gbc.fill = GridBagConstraints.BOTH gbc.anchor = GridBagConstraints.NORTHWEST gbc.gridx = 1 gbc.gridy = 1 gbc.weightx = 2 gbc.weighty = 2 gbc.gridheight = 1 self.__component.add(self.__artist, gbc)
def startGui(self): # self.gridPanel = JPanel(GridLayout(self.numRows, self.numCols)) # self.cellButtons = self._doForAllCells(self._createCellButton) # self.grid = self._doForAllCells(lambda r,c: False) # frame.add(self.gridPanel) # buttonPanel = JPanel(FlowLayout()) # stepButton = JButton("Step", actionPerformed=self._step) # runButton = JToggleButton("Run", actionPerformed=self._run) # buttonPanel.add(stepButton) # buttonPanel.add(runButton) # frame.add(buttonPanel, SOUTH) # frame.pack() # frame.locationRelativeTo = None self.setMenuBar() image_path = "D:\\wamp\\www\\holdem\\src\\poker\\th\\images\\As.png" myPicture = ImageIcon(image_path) myPictureLabel = JLabel("Pocket: ", myPicture, JLabel.LEFT) cardPanel = JPanel() cardPanel.setLayout(None) cardPanel.add(myPictureLabel) myPictureLabel.setBounds(10,10,36,52); self._frame.getContentPane().add(cardPanel) self.msg=JLabel("Hello") self._frame.add(self.msg, NORTH) self._frame.locationRelativeTo = None self._frame.visible = True
def __init__(self): super(AboutDialog, self).__init__() # Open the files and build a tab pane self.tabbedPane = tabs = JTabbedPane() for title, path in self.INFO_FILES: textPane = JTextPane() textPane.editable = False scrollPane = JScrollPane(textPane) scrollPane.preferredSize = (32767, 32767) # just a large number with open(path, 'r') as fd: infoText = fd.read().decode('utf8') textPane.text = infoText textPane.caretPosition = 0 tabs.addTab(title, scrollPane) # Load this tabbed pane into the layout self.add(tabs, BorderLayout.CENTER) # Add a label at the top versionLabel = JLabel(JESVersion.TITLE + " version " + JESVersion.RELEASE) versionLabel.alignmentX = Component.CENTER_ALIGNMENT versionPanel = JPanel() versionPanel.add(versionLabel) self.add(versionPanel, BorderLayout.PAGE_START) # Make an OK button self.okButton = JButton(self.ok) self.buttonPanel.add(self.okButton)
def check_label_size(self): if(self.show_limits): limit_label = JLabel(("-%1.2f" % (self.range))) limit_width = limit_label.getPreferredSize().width - self.sliders[0].width / 2 if(limit_width != self.limit_width): self.setSize(self.size.width + limit_width - self.limit_width, self.size.height) self.setLocation(self.x - limit_width + self.limit_width, self.y) self.limit_width = limit_width
def initUI(self): self.panel = JPanel(size=(50,50)) self.panel.setLayout(FlowLayout( )) self.panel.setToolTipText("GPU Demo") #TODO- change this so that it deletes itself when text is entered self.textfield1 = JTextField('Smoothing Parameter',15) self.panel.add(self.textfield1) joclButton = JButton("JOCL",actionPerformed=self.onJocl) joclButton.setBounds(100, 500, 100, 30) joclButton.setToolTipText("JOCL Button") self.panel.add(joclButton) javaButton = JButton("Java",actionPerformed=self.onJava) javaButton.setBounds(100, 500, 100, 30) javaButton.setToolTipText("Java Button") self.panel.add(javaButton) qButton = JButton("Quit", actionPerformed=self.onQuit) qButton.setBounds(200, 500, 80, 30) qButton.setToolTipText("Quit Button") self.panel.add(qButton) newImage = ImageIO.read(io.File(getDataDir() + "input.png")) resizedImage = newImage.getScaledInstance(600, 600,10) newIcon = ImageIcon(resizedImage) label1 = JLabel("Input Image",newIcon, JLabel.CENTER) label1.setVerticalTextPosition(JLabel.TOP) label1.setHorizontalTextPosition(JLabel.RIGHT) label1.setSize(10,10) label1.setBackground(Color.orange) self.panel.add(label1) self.getContentPane().add(self.panel) self.clockLabel = JLabel() self.clockLabel.setSize(1,1) self.clockLabel.setBackground(Color.orange) self.clockLabel.setVerticalTextPosition(JLabel.BOTTOM) self.clockLabel.setHorizontalTextPosition(JLabel.LEFT) myClockFont = Font("Serif", Font.PLAIN, 50) self.clockLabel.setFont(myClockFont) self.panel.add(self.clockLabel) self.setTitle("Structure-oriented smoothing OpenCL Demo") self.setSize(1200, 700) self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) self.setLocationRelativeTo(None) self.setVisible(True)
def initUI(self): panel = JPanel() panel.setLayout(None) panel.setBackground(Color(66, 66, 66)) self.getContentPane().add(panel) rot = ImageIcon("input.png") rotLabel = JLabel(rot) rotLabel.setBounds(20, 20, rot.getIconWidth(), rot.getIconHeight()) min = ImageIcon("cpuoutput.png") minLabel = JLabel(min) minLabel.setBounds(40, 160, min.getIconWidth(), min.getIconHeight()) bar = ImageIcon("inputdata.png") barLabel = JLabel(bar) barLabel.setBounds(170, 50, bar.getIconWidth(), bar.getIconHeight()) panel.add(rotLabel) panel.add(minLabel) panel.add(barLabel) self.setTitle("Absolute") self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) self.setSize(350, 300) self.setLocationRelativeTo(None) self.setVisible(True)
def initExport(self): # ## init enforcement detector tab # exportLType = JLabel("File Type:") exportLType.setBounds(10, 10, 100, 30) exportLES = JLabel("Enforcement Statuses:") exportLES.setBounds(10, 50, 160, 30) exportFileTypes = ["HTML","CSV"] self.exportType = JComboBox(exportFileTypes) self.exportType.setBounds(100, 10, 200, 30) exportES = ["All Statuses", self._enfocementStatuses[0], self._enfocementStatuses[1], self._enfocementStatuses[2]] self.exportES = JComboBox(exportES) self.exportES.setBounds(100, 50, 200, 30) exportLES = JLabel("Statuses:") exportLES.setBounds(10, 50, 100, 30) self.exportButton = JButton("Export",actionPerformed=self.export) self.exportButton.setBounds(390, 25, 100, 30) self.exportPnl = JPanel() self.exportPnl.setLayout(None); self.exportPnl.setBounds(0, 0, 1000, 1000); self.exportPnl.add(exportLType) self.exportPnl.add(self.exportType) self.exportPnl.add(exportLES) self.exportPnl.add(self.exportES) self.exportPnl.add(self.exportButton)
def build_replace_row(self): ''' Builds the replace row. ''' panel = JPanel(FlowLayout()) label = JLabel("Replace: ") panel.add(label) self.replace_field = JTextField(20, actionPerformed=self.find_next) label.setLabelFor(self.replace_field) panel.add(self.replace_field) return panel
def disp_limits(self): if(not self.show_limits): limit_label = JLabel(("-%1.2f" % (self.range))) self.limit_width = limit_label.getPreferredSize().width - self.sliders[0].width / 2 self.setSize(self.size.width + self.limit_width, self.size.height) self.setLocation(self.x - self.limit_width, self.y) self.limit_hide_timer.stop() self.limit_color_val = self.limit_color_def self.show_limits = True self.repaint()
def initConfigurationTab(self): # ## init configuration tab # self.prevent304 = JCheckBox("Prevent 304 Not Modified status code") self.prevent304.setBounds(290, 25, 300, 30) self.ignore304 = JCheckBox("Ignore 304/204 status code responses") self.ignore304.setBounds(290, 5, 300, 30) self.ignore304.setSelected(True) self.autoScroll = JCheckBox("Auto Scroll") #self.autoScroll.setBounds(290, 45, 140, 30) self.autoScroll.setBounds(160, 40, 140, 30) self.doUnauthorizedRequest = JCheckBox("Check unauthenticated") self.doUnauthorizedRequest.setBounds(290, 45, 300, 30) self.doUnauthorizedRequest.setSelected(True) startLabel = JLabel("Authorization checks:") startLabel.setBounds(10, 10, 140, 30) self.startButton = JButton("Autorize is off",actionPerformed=self.startOrStop) self.startButton.setBounds(160, 10, 120, 30) self.startButton.setBackground(Color(255, 100, 91, 255)) self.clearButton = JButton("Clear List",actionPerformed=self.clearList) self.clearButton.setBounds(10, 40, 100, 30) self.replaceString = JTextArea("Cookie: Insert=injected; header=here;", 5, 30) self.replaceString.setWrapStyleWord(True); self.replaceString.setLineWrap(True) self.replaceString.setBounds(10, 80, 470, 180) self.filtersTabs = JTabbedPane() self.filtersTabs.addTab("Enforcement Detector", self.EDPnl) self.filtersTabs.addTab("Detector Unauthenticated", self.EDPnlUnauth) self.filtersTabs.addTab("Interception Filters", self.filtersPnl) self.filtersTabs.addTab("Export", self.exportPnl) self.filtersTabs.setBounds(0, 280, 2000, 700) self.pnl = JPanel() self.pnl.setBounds(0, 0, 1000, 1000); self.pnl.setLayout(None); self.pnl.add(self.startButton) self.pnl.add(self.clearButton) self.pnl.add(self.replaceString) self.pnl.add(startLabel) self.pnl.add(self.autoScroll) self.pnl.add(self.ignore304) self.pnl.add(self.prevent304) self.pnl.add(self.doUnauthorizedRequest) self.pnl.add(self.filtersTabs)
def hhwindow(): #creates a function called hhwindow, this is a function we will call whenever we want to create a new window global win,mytext #the global statement creates variables “win” and “mytext” that can be referenced outside of just this function win = swing.JFrame("Inside the Haunted House") #creates a window as a variable we named “win”, the title of the window is inside the quotes panel = JPanel() #creates a panel inside the window for text as a variable we named “panel” panel.setLayout(None) #controls layout of panel panel.setBackground(Color(0, 0, 0)) #sets background color of window win.setSize(600,400) #sets window size win.setVisible(True) #makes window visible mytextLabel = JLabel(mytext) #adds text to the window in the form of a variable, yet to be defined, called “mytext” mytextLabel.setBounds(20, 20, 500, 400) #sets boundaries for the text, text will be centered by default within these boundaries panel.add(mytextLabel) #add the label to the panel win.add(panel) #add the panel to the window win.show() #show the window
def initPanel(self): IntegerPanel.initPanel(self) num_avail_devices = NEFGPUInterface.getNumAvailableDevices() if num_avail_devices < 1: self.tf.setEnabled(False) self.tf.setEditable(False) error_message = " %s" % (NEFGPUInterface.getErrorMessage()) error_message_label = JLabel(error_message) error_message_label.setForeground(Color.red) self.add(error_message_label)
def addSection(self, name, fontstyle=None): """Creates a new section in the Popup menu.""" if self.isFirstSection: self.isFirstSection = False else: self.menu.addSeparator() # menu.add(JSeparator()) ??? label = JLabel(name) label.setLocation(4, 4) if fontstyle is not None: label.font = fontstyle self.applyStyle(label) self.menu.add(label)
def __init__(self): UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); size = Dimension(800, 800) self.setPreferredSize(size) screenSize = Toolkit.getDefaultToolkit().getScreenSize(); self.setLocation(screenSize.getSize().width/2 - size.width/2, 100) self.setTitle("bashED Terminal HQ EXTREME"); self.setUndecorated(True) self.getRootPane().setOpaque(False) #self.getRootPane().setWindowDecorationStyle(JRootPane.FRAME); self.setBackground(Color(0,128,0, 198)) #j = JDesktopPane() #j.setOpaque(False) self.setLayout(None) self.setIconImage(ImageIcon('bin/gui/media/' + "icon.png").getImage()) mp = MainPanel() self.add(mp) mp.setBounds(0, 0, size.width, size.height) imageTest = ImageIcon('bin/gui/media/' + "image.png") imageTestLabel = JLabel(imageTest) self.add(imageTestLabel) imageTestLabel.setBounds(0, 0, size.width, size.height) #self.getContentPane().add(mp) #self.getContentPane().add(JLabel("Iglo")) bb = BorderFactory.createLineBorder(Color.BLACK, 5) bw1 = BorderFactory.createLineBorder(Color.WHITE, 1) bw2 = BorderFactory.createLineBorder(Color.WHITE, 1) mp.setBorder( BorderFactory.createCompoundBorder( bw1, BorderFactory.createCompoundBorder(bb, bw2) )) #make the window viewable self.defaultCloseOperation=JFrame.EXIT_ON_CLOSE self.pack() self.setVisible(True)
def initPanel(self): BooleanPanel.initPanel(self) can_use_GPU = WeightedCostApproximator.canUseGPU() if not can_use_GPU: self.checkBox.setEnabled(False) self.label.setEnabled(False) error_message = " %s" % ( WeightedCostApproximator.getGPUErrorMessage()) error_message_label = JLabel(error_message) error_message_label.setForeground(Color.red) self.add(error_message_label)
class SummPanel(JPanel): def __init__(self, isTemporal): self.isTemporal = isTemporal JPanel() self.setLayout(GridLayout(6,2)) self.add(JLabel('Total data')) self.add(JLabel('')) self.add(JLabel('# Pops' if not isTemporal else "# Gens")) self.totalPops = JLabel('0', SwingConstants.RIGHT) self.add(self.totalPops) self.add(JLabel('# Loci')) self.totalLoci = JLabel('0', SwingConstants.RIGHT) self.add(self.totalLoci) self.add(JLabel('Selected')) self.add(JLabel('')) self.add(JLabel('# Pops' if not isTemporal else "# Gens")) self.selPops = JLabel('0', SwingConstants.RIGHT) self.add(self.selPops) self.add(JLabel('# Loci')) self.selLoci = JLabel('0', SwingConstants.RIGHT) self.add(self.selLoci) def update(self, rec, popNames, remPops, remLoci): total_pops = countPops(rec) sel_pops = total_pops - len (remPops) total_loci = len(rec.loci_list) sel_loci = total_loci - len(remLoci) self.totalPops.setText(str(total_pops)) self.selPops.setText(str(sel_pops)) self.totalLoci.setText(str(total_loci)) self.selLoci.setText(str(sel_loci))
def build_find_replace_rows(self): labels = ("Find: ", "Replace: ") # Create and populate the panel. panel = JPanel() for label in labels: row_panel = JPanel(FlowLayout()) label = JLabel(label, JLabel.TRAILING) row_panel.add(label, FlowLayout.LEFT) textfield = JTextField(20) label.setLabelFor(textfield) row_panel.add(textfield, FlowLayout.RIGHT) panel.add(row_panel) return panel
def initializeDisplay(self, queries, swing): """ queries: A list of the fasts files to be processed. swing: If true then updates about progress will be displayed in a swing window, otherwise they will be written to stdout. Initializes the interface for telling the user about progress in the pipeline. Queries is used to count the number of queries the pipeline will process and to size the swing display(if it is used) so that text isn't cutoff at the edge of the window. The swing display is setup if swing is true. """ self.numJobs = len(queries) if swing: self.frame = JFrame("Neofelis") self.frame.addWindowListener(PipelineWindowAdapter(self)) contentPane = JPanel(GridBagLayout()) self.frame.setContentPane(contentPane) self.globalLabel = JLabel(max(queries, key = len)) self.globalProgress = JProgressBar(0, self.numJobs) self.currentLabel = JLabel(max(self.messages, key = len)) self.currentProgress = JProgressBar(0, len(self.messages)) self.doneButton = JButton(DoneAction(self.frame)) self.doneButton.setEnabled(False) constraints = GridBagConstraints() constraints.gridx, constraints.gridy = 0, 0 constraints.gridwidth, constraints.gridheight = 1, 1 constraints.weightx = 1 constraints.fill = GridBagConstraints.HORIZONTAL contentPane.add(self.globalLabel, constraints) constraints.gridy = 1 contentPane.add(self.globalProgress, constraints) constraints.gridy = 2 contentPane.add(self.currentLabel, constraints) constraints.gridy = 3 contentPane.add(self.currentProgress, constraints) constraints.gridy = 4 constraints.weightx = 0 constraints.fill = GridBagConstraints.NONE constraints.anchor = GridBagConstraints.LINE_END contentPane.add(self.doneButton, constraints) self.frame.pack() self.frame.setResizable(False) self.globalLabel.setText(" ") self.currentLabel.setText(" ") self.frame.setLocationRelativeTo(None) self.frame.setVisible(True)
def __init__(self): self.setAlwaysOnTop(False); self.setSize(500, 500); menubar = JMenuBar(); menu = JMenu("A Menu"); menu_ac = menu.getAccessibleContext(); menu_ac.setAccessibleDescription("The only menu in this program"); menuitem = JMenuItem("A Menu Item"); menu.add(menuitem); menubar.add(menu); self.setJMenuBar(menubar); lbl = JLabel("A Label"); lbl.setHorizontalAlignment(JLabel.CENTER); lbl.setVerticalAlignment(JLabel.CENTER); self.setContentPane(lbl); self.setVisible(True);
def __init__(self,hostname): self.hostname=hostname JPanel.__init__(self,BorderLayout()) self.cbActionListener=foo2(self) #imglist=os.listdir('./img') #try:imglist.remove('.svn') #except:pass imglist=['01-CircleOfFifths.gif','Fifths.png','circle-o-fifths.jpg','Circle_Of_Fifths.gif','Keywheel.gif','circle-of-fifths.gif','ColorFifths.jpg','cof.gif'] self.cb=JComboBox(imglist,actionListener=self.cbActionListener)# #self.cb.addItemListener(self.cbCB) tb=JPanel() tb.setLayout(FlowLayout(FlowLayout.CENTER)) tb.add(self.cb) self.add(tb,'Center') self.img=None if hostname[0:7]=='http://': self.img=ImageIO.read(URL(self.hostname+'/static/sightreadingtrainer/img/'+imglist[0])) else: self.img=ImageIO.read(File(self.hostname+'img/'+imglist[0])) icon=ImageIcon(self.img) self.label=JLabel(icon) self.add(self.label,'North')
def __init__(self): JPanel() self.setLayout(GridLayout(1,1)) #self.add(JLabel('SELWB 1.0')) self.statusLabel = JLabel('Idle', SwingConstants.CENTER) self.statusLabel.setBackground(Color.GREEN) self.statusLabel.setOpaque(True) self.add(self.statusLabel)
def __init__(self): self.frame = JFrame("StopWatch", defaultCloseOperation=JFrame.EXIT_ON_CLOSE) self.start = JButton("Start", actionPerformed=self.start) self.frame.add(self.start, BorderLayout.WEST) self.stop = JButton("Stop", actionPerformed=self.stop) self.frame.add(self.stop, BorderLayout.EAST) self.label = JLabel(" " * 45) self.frame.add(self.label, BorderLayout.SOUTH) self.frame.pack()
class TextView(core.DataViewComponent): def __init__(self,view,name,func,args=(),label=None): core.DataViewComponent.__init__(self,label) self.view=view self.name=name self.func=func self.show_label=False self.update_label() self.data=self.view.watcher.watch(name,func,args=args) self.text_label=JLabel('',verticalAlignment=JLabel.CENTER,horizontalAlignment=JLabel.CENTER) self.text_label.font=Font('SansSerif',Font.BOLD,12) self.font_size=12 self.add(self.text_label) self.popup.add(JPopupMenu.Separator()) self.popup.add(JMenuItem('larger',actionPerformed=self.increase_font)) self.popup.add(JMenuItem('smaller',actionPerformed=self.decrease_font)) def increase_font(self,event): self.font_size+=2 self.text_label.font=Font('SansSerif',Font.BOLD,self.font_size) def decrease_font(self,event): if self.font_size<7: return self.font_size-=2 self.text_label.font=Font('SansSerif',Font.BOLD,self.font_size) def paintComponent(self,g): core.DataViewComponent.paintComponent(self,g) data=self.data.get(start=self.view.current_tick,count=1)[0] self.text_label.setSize(self.width,self.height-self.label_offset) self.text_label.setLocation(0,self.label_offset) self.text_label.text=data def save(self): info = core.DataViewComponent.save(self) info['font_size']=self.font_size return info def restore(self,d): core.DataViewComponent.restore(self,d) self.font_size=d.get('font_size',12) self.text_label.font=Font('SansSerif',Font.BOLD,self.font_size)
class LoadDialog(JDialog, ActionListener): def __init__(self, frame, what): JDialog.__init__(self,frame, what, False) self.frame = frame pane = self.getRootPane().getContentPane() panel = JPanel() panel.add(JLabel('Current population')) self.status = JLabel(" ") panel.add(self.status) pane.add(panel) self.pack() self.show() def update_status(self, curr): self.status.setText("%d" % (curr,)) Thread.yield()
def createAuxPanelWrapper(self, auxPanel, auxTitle): # Initialize auxillary panel leftPanel = JPanel() leftPanel.layout = BorderLayout() leftPanel.addFocusListener(LeftFocusListener(self)) # NengoStyle.applyStyle(leftPanel); if self.showTitle: # Create auxillary panel's title bar titleBar = JPanel() titleBar.border = BorderFactory.createEmptyBorder(0, 0, 5, 0)) NengoStyle.applyStyle(titleBar) titleBar.background = NengoStyle.COLOR_BACKGROUND2 titleBar.opaque = True titleBar.layout = BorderLayout() titleLabel = JLabel(title) titleLabel.font = NengoStyle.FONT_BIG NengoStyle.applyStyle(titleLabel) titleLabel.background = NengoStyle.COLOR_BACKGROUND2 titleLabel.opaque = True hideButtonTxt = " >> " if self.orientation == 'right' else " << " hideButton = JLabel(hideButtonTxt) NengoStyle.applyStyle(hideButton) hideButton.background = NengoStyle.COLOR_BACKGROUND2 hideButton.opaque = True # Keep in this order, Swing puts items added first on top. # We want the button to be on top titleBar.add(hideButton, BorderLayout.EAST) titleBar.add(titleLabel, BorderLayout.WEST) hideButton.addMouseListener(HideButtonListener(self, hideButton)) leftPanel.add(titleBar, BorderLayout.NORTH) leftPanel.minimumSize = self.minimumSize if auxPanel is not None: # NengoStyle.applyStyle(auxPanel) leftPanel.add(auxPanel, BorderLayout.CENTER) return leftPanel
def __init__(self, isTemporal): self.isTemporal = isTemporal JPanel() self.setLayout(GridLayout(6,2)) self.add(JLabel('Total data')) self.add(JLabel('')) self.add(JLabel('# Pops' if not isTemporal else "# Gens")) self.totalPops = JLabel('0', SwingConstants.RIGHT) self.add(self.totalPops) self.add(JLabel('# Loci')) self.totalLoci = JLabel('0', SwingConstants.RIGHT) self.add(self.totalLoci) self.add(JLabel('Selected')) self.add(JLabel('')) self.add(JLabel('# Pops' if not isTemporal else "# Gens")) self.selPops = JLabel('0', SwingConstants.RIGHT) self.add(self.selPops) self.add(JLabel('# Loci')) self.selLoci = JLabel('0', SwingConstants.RIGHT) self.add(self.selLoci)
class StatusPanel(JPanel): def __init__(self): JPanel() self.setLayout(GridLayout(1,1)) #self.add(JLabel('SELWB 1.0')) self.statusLabel = JLabel('Idle', SwingConstants.CENTER) self.statusLabel.setBackground(Color.GREEN) self.statusLabel.setOpaque(True) self.add(self.statusLabel) def setStatus(self, str, bgColor = Color.GREEN): self.statusLabel.setText(str) self.statusLabel.setBackground(bgColor)
def initEnforcementDetector(self): # ## init enforcement detector tab # # These two variable appears to be unused... self.EDFP = ArrayList() self.EDCT = ArrayList() EDLType = JLabel("Type:") EDLType.setBounds(10, 10, 140, 30) EDLContent = JLabel("Content:") EDLContent.setBounds(10, 50, 140, 30) EDLabelList = JLabel("Filter List:") EDLabelList.setBounds(10, 165, 140, 30) EDStrings = ["Headers (simple string): (enforced message headers contains)", "Headers (regex): (enforced messege headers contains)", "Body (simple string): (enforced messege body contains)", "Body (regex): (enforced messege body contains)", "Full request (simple string): (enforced messege contains)", "Full request (regex): (enforced messege contains)", "Content-Length: (constant Content-Length number of enforced response)"] self.EDType = JComboBox(EDStrings) self.EDType.setBounds(80, 10, 430, 30) self.EDText = JTextArea("", 5, 30) self.EDText.setBounds(80, 50, 300, 110) self.EDModel = DefaultListModel(); self.EDList = JList(self.EDModel); self.EDList.setBounds(80, 175, 300, 110) self.EDList.setBorder(LineBorder(Color.BLACK)) self.EDAdd = JButton("Add filter",actionPerformed=self.addEDFilter) self.EDAdd.setBounds(390, 85, 120, 30) self.EDDel = JButton("Remove filter",actionPerformed=self.delEDFilter) self.EDDel.setBounds(390, 210, 120, 30) self.EDPnl = JPanel() self.EDPnl.setLayout(None); self.EDPnl.setBounds(0, 0, 1000, 1000); self.EDPnl.add(EDLType) self.EDPnl.add(self.EDType) self.EDPnl.add(EDLContent) self.EDPnl.add(self.EDText) self.EDPnl.add(self.EDAdd) self.EDPnl.add(self.EDDel) self.EDPnl.add(EDLabelList) self.EDPnl.add(self.EDList)
class StopWatch(Runnable): def __init__(self): self.frame = JFrame("StopWatch", defaultCloseOperation=JFrame.EXIT_ON_CLOSE) self.start = JButton("Start", actionPerformed=self.start) self.frame.add(self.start, BorderLayout.WEST) self.stop = JButton("Stop", actionPerformed=self.stop) self.frame.add(self.stop, BorderLayout.EAST) self.label = JLabel(" " * 45) self.frame.add(self.label, BorderLayout.SOUTH) self.frame.pack() def start(self, event): self.started = Calendar.getInstance().getTimeInMillis() self.label.setText("Running") def stop(self, event): elapsed = Calendar.getInstance().getTimeInMillis() - self.started self.label.setText("Elapsed: %.2f seconds" % (float(elapsed) / 1000.0)) def run(self): self.frame.setVisible(1)
def registerExtenderCallbacks(self, callbacks): self._helpers = callbacks.getHelpers() callbacks.setExtensionName("JWT FuzzHelper") callbacks.registerIntruderPayloadProcessor(self) callbacks.registerExtensionStateListener(self) self._stdout = PrintWriter(callbacks.getStdout(), True) self._stderr = PrintWriter(callbacks.getStderr(), True) # Holds values passed by user from Configuration panel self._fuzzoptions = { "target": "Header", "selector": None, "signature": False, "algorithm": "HS256", "key": "" } self._isNone = lambda val: isinstance(val, type(None)) # Configuration panel Layout self._configurationPanel = JPanel() gridBagLayout = GridBagLayout() gridBagLayout.columnWidths = [0, 0, 0] gridBagLayout.rowHeights = [10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] gridBagLayout.columnWeights = [0.0, 0.0, 0.0] gridBagLayout.rowWeights = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] self._configurationPanel.setLayout(gridBagLayout) # Setup tabs self._tabs = JTabbedPane() self._tabs.addTab('Configuration', self._configurationPanel) #self._tabs.addTab('Help',self._helpPanel) # Target Options targetLabel = JLabel("Target Selection (Required): ") targetLabel.setFont(Font("Tahoma", Font.BOLD, 12)) c = GridBagConstraints() c.gridx = 0 c.gridy = 1 c.insets = Insets(0, 10, 0, 0) c.anchor = GridBagConstraints.LINE_END self._configurationPanel.add(targetLabel, c) options = ['Header', 'Payload'] self._targetComboBox = JComboBox(options) c = GridBagConstraints() c.gridx = 1 c.gridy = 1 c.anchor = GridBagConstraints.LINE_START self._configurationPanel.add(self._targetComboBox, c) # Help Button self._helpButton = JButton("Help", actionPerformed=self.helpMenu) c = GridBagConstraints() c.gridx = 2 c.gridy = 1 c.anchor = GridBagConstraints.FIRST_LINE_START self._configurationPanel.add(self._helpButton, c) # Selector Options self._selectorLabel = JLabel( "JSON Selector [Object Identifier-Index Syntax] (Required): ") self._selectorLabel.setFont(Font("Tahoma", Font.BOLD, 12)) c = GridBagConstraints() c.gridx = 0 c.gridy = 2 c.insets = Insets(0, 10, 0, 0) c.anchor = GridBagConstraints.LINE_END self._configurationPanel.add(self._selectorLabel, c) self._selectorTextField = JTextField('', 50) c = GridBagConstraints() c.gridx = 1 c.gridy = 2 self._configurationPanel.add(self._selectorTextField, c) # Regex option self._regexLabel = JLabel("Use regex as JSON Selector? (Optional): ") self._regexLabel.setFont(Font("Tahoma", Font.BOLD, 12)) c = GridBagConstraints() c.gridx = 0 c.gridy = 3 c.insets = Insets(0, 0, 0, 0) c.anchor = GridBagConstraints.LINE_END self._configurationPanel.add(self._regexLabel, c) self._regexCheckBox = JCheckBox("", actionPerformed=self.regexSelector) c = GridBagConstraints() c.gridx = 1 c.gridy = 3 c.anchor = GridBagConstraints.FIRST_LINE_START self._configurationPanel.add(self._regexCheckBox, c) # Signature Options generateSignatureLabel = JLabel("Generate signature? (Required): ") generateSignatureLabel.setFont(Font("Tahoma", Font.BOLD, 12)) c = GridBagConstraints() c.gridx = 0 c.gridy = 4 c.insets = Insets(0, 10, 0, 0) c.anchor = GridBagConstraints.LINE_END self._configurationPanel.add(generateSignatureLabel, c) options = ["False", "True"] self._generateSignatureComboBox = JComboBox(options) c = GridBagConstraints() c.gridx = 1 c.gridy = 4 c.anchor = GridBagConstraints.LINE_START self._configurationPanel.add(self._generateSignatureComboBox, c) signatureAlgorithmLabel = JLabel("Signature Algorithm (Optional): ") signatureAlgorithmLabel.setFont(Font("Tahoma", Font.BOLD, 12)) c = GridBagConstraints() c.gridx = 0 c.gridy = 5 c.insets = Insets(0, 10, 0, 0) c.anchor = GridBagConstraints.LINE_END self._configurationPanel.add(signatureAlgorithmLabel, c) options = [ "None", "HS256", "HS384", "HS512", "ES256", "ES384", "ES512", "RS256", "RS384", "RS512", "PS256", "PS256", "PS384", "PS512" ] self._algorithmSelectionComboBox = JComboBox(options) c = GridBagConstraints() c.gridx = 1 c.gridy = 5 c.anchor = GridBagConstraints.LINE_START self._configurationPanel.add(self._algorithmSelectionComboBox, c) # Signing key options self._signingKeyLabel = JLabel("Signing Key (Optional): ") self._signingKeyLabel.setFont(Font("Tahoma", Font.BOLD, 12)) c = GridBagConstraints() c.gridx = 0 c.gridy = 6 c.insets = Insets(0, 10, 0, 0) c.anchor = GridBagConstraints.LINE_END self._configurationPanel.add(self._signingKeyLabel, c) self.addSigningKeyTextArea() self._fromFileTextField = JTextField('', 50) fromFileLabel = JLabel("Signing key from file? (Optional): ") fromFileLabel.setFont(Font("Tahoma", Font.BOLD, 12)) c = GridBagConstraints() c.gridx = 0 c.gridy = 7 c.insets = Insets(0, 0, 0, 0) c.anchor = GridBagConstraints.LINE_END self._configurationPanel.add(fromFileLabel, c) self._fromFileCheckBox = JCheckBox("", actionPerformed=self.fromFile) c = GridBagConstraints() c.gridx = 1 c.gridy = 7 c.anchor = GridBagConstraints.FIRST_LINE_START self._configurationPanel.add(self._fromFileCheckBox, c) self._saveButton = JButton("Save Configuration", actionPerformed=self.saveOptions) self._saveButton.setText("Save Configuration") c = GridBagConstraints() c.gridx = 1 c.gridy = 8 c.anchor = GridBagConstraints.FIRST_LINE_START self._configurationPanel.add(self._saveButton, c) callbacks.customizeUiComponent(self._configurationPanel) callbacks.customizeUiComponent(self._tabs) callbacks.addSuiteTab(self) self._stdout.println("[JWT FuzzHelper] Loaded successfully") return
from javax.swing import JFrame from javax.swing import JTable from javax.swing import JScrollPane from javax.swing import ListSelectionModel from javax.swing.event import ChangeListener from javax.swing.table import DefaultTableCellRenderer from javax.swing.table import DefaultTableModel #------------------------------------------------------------------------------- # Define some global font related variables #------------------------------------------------------------------------------- plainFont = Font('Dialog', Font.PLAIN, 12) boldFont = Font('Dialog', Font.BOLD, 12) fmPlain = JLabel().getFontMetrics(plainFont) fmBold = JLabel().getFontMetrics(boldFont) #------------------------------------------------------------------------------- # Name: reportTableModel # Role: Define table data characteristics #------------------------------------------------------------------------------- class reportTableModel(DefaultTableModel): #--------------------------------------------------------------------------- # Name: __init__() # Role: Class constructor # Note: Save the initial data for easy highlight removal #--------------------------------------------------------------------------- def __init__(self, data, headings):
def setColumnWidths(self, table): #----------------------------------------------------------------------- # Set up some variables to access the table properties and data #----------------------------------------------------------------------- tcm = table.getColumnModel() # Table Column Model model = table.getModel() # Used to access the table data margin = tcm.getColumnMargin() # gap between columns #----------------------------------------------------------------------- # For each column, determine the maximum width required #----------------------------------------------------------------------- rows = model.getRowCount() # How many rows exist? cols = tcm.getColumnCount() # How many columns exist? labels = [JLabel(font=plainFont), JLabel(font=boldFont)] metrics = [fmPlain, fmBold] tWidth = 0 # Table width section = 0 # Boolean: current row is a section? sections = 0 # Number of setion rows #----------------------------------------------------------------------- # Note: Since the columns can't be rearranged, we can use the column # # directly, instead of having to use the index (i.e., # col.getModelIndex() #----------------------------------------------------------------------- for c in range(cols): # Note: c == column number col = tcm.getColumn(c) #------------------------------------------------------------------- # Find the maximum width required for the data values in this column # Note: Use the column adjustments to compute the best width #------------------------------------------------------------------- cWidth = 0 # Initial column width for row in range(rows): v0 = model.getValueAt(row, 0) if v0.startswith('_'): section = 1 if not c: # Only increment for col == 0 sections += 1 else: section = 0 comp = labels[section] fm = metrics[section] # FontMetric r = table.getCellRenderer(row, c) v = model.getValueAt(row, c) if v.startswith('_'): v = v[1:] comp.setText(v) cWidth = max(cWidth, comp.getPreferredSize().width) col.setMinWidth(128 + margin) col.setPreferredWidth(128 + margin) if cWidth > 0: col.setMaxWidth(cWidth + margin) #------------------------------------------------------------------- # Add current column (preferred) width to the total table width #------------------------------------------------------------------- tWidth += col.getPreferredWidth() #----------------------------------------------------------------------- # Set the preferred viewport size #----------------------------------------------------------------------- table.setPreferredScrollableViewportSize( Dimension(tWidth, 24 * table.getRowHeight()))
def __init__(self, ext): self._panel = JPanel() layout = GroupLayout(self._panel) innerPanel = JPanel() innerPanelLayout = GroupLayout(innerPanel) self._panel.setLayout(layout) innerPanel.setLayout(innerPanelLayout) self.labelDojoURL = JLabel("DefectDojo :") self.defectDojoURL = JTextField("") self.searchConnectButton = JButton('Connect', actionPerformed=ext.getProducts) self.labelApiKey = JLabel("API Key :") self.apiKey = JTextField("") self.labelUsername = JLabel("Username :"******"admin") self.labelProductID = JLabel("Product :") self.productID = JTextField(focusLost=ext.getEngagements) self.labelProductName = JLabel("Product Name :") self.productName = JComboBox() self.prodMan = ProdListener(ext) self.prodMouse = ProdMouseListener(ext) self.productName.addMouseListener(self.prodMouse) self.productName.addActionListener(self.prodMan) self.labelEngagementID = JLabel("Engagement (In Progress) :") self.engagementID = JTextField(focusLost=ext.getTests) self.engagementName = JComboBox() self.engMan = EngListener(ext) self.engagementName.addActionListener(self.engMan) self.labelTestID = JLabel("Test :") self.testID = JTextField() self.testName = JComboBox() self.testMan = TestListener(ext) self.testName.addActionListener(self.testMan) self.search = JTextField() self.searchProductButton = JButton('Product Search', actionPerformed=ext.getProducts) innerPanelLayout.setHorizontalGroup( innerPanelLayout.createParallelGroup().addGroup( GroupLayout.Alignment.TRAILING, innerPanelLayout.createSequentialGroup().addContainerGap(). addGroup( innerPanelLayout.createParallelGroup( GroupLayout.Alignment.TRAILING). addGroup(innerPanelLayout.createParallelGroup().addGroup( innerPanelLayout.createParallelGroup( GroupLayout.Alignment.TRAILING).addGroup( innerPanelLayout.createParallelGroup( GroupLayout.Alignment.TRAILING).addGroup( innerPanelLayout.createSequentialGroup( ).addComponent( self.labelUsername, GroupLayout.PREFERRED_SIZE, 168, GroupLayout.PREFERRED_SIZE).addGap( 105, 105, 105)). addComponent(self.labelProductName, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 168, GroupLayout.PREFERRED_SIZE)). addGroup( GroupLayout.Alignment.LEADING, innerPanelLayout.createSequentialGroup().addGroup( innerPanelLayout.createParallelGroup( GroupLayout.Alignment.TRAILING). addComponent( self.labelEngagementID, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 168, GroupLayout.PREFERRED_SIZE).addComponent( self.labelDojoURL, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 168, GroupLayout.PREFERRED_SIZE)). addPreferredGap( LayoutStyle.ComponentPlacement.RELATED)) ).addGroup(innerPanelLayout.createSequentialGroup( ).addGroup( innerPanelLayout.createParallelGroup().addComponent( self.labelTestID, GroupLayout.PREFERRED_SIZE, 168, GroupLayout.PREFERRED_SIZE).addComponent( self.searchProductButton, GroupLayout.PREFERRED_SIZE, 160, GroupLayout.PREFERRED_SIZE)).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED))). addGroup( GroupLayout.Alignment.LEADING, innerPanelLayout.createSequentialGroup().addComponent( self.labelApiKey, GroupLayout.PREFERRED_SIZE, 168, GroupLayout.PREFERRED_SIZE).addPreferredGap( LayoutStyle.ComponentPlacement.RELATED))). addGroup(innerPanelLayout.createParallelGroup().addGroup( innerPanelLayout.createSequentialGroup().addComponent( self.engagementID, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE).addGap( 18, 18, 18).addComponent(self.engagementName, GroupLayout.PREFERRED_SIZE, 260, GroupLayout.PREFERRED_SIZE) ).addGroup(innerPanelLayout.createSequentialGroup().addGap( 54, 54, 54).addGroup( innerPanelLayout.createParallelGroup().addComponent( self.defectDojoURL, GroupLayout.PREFERRED_SIZE, 260, GroupLayout.PREFERRED_SIZE).addComponent( self.apiKey, GroupLayout.PREFERRED_SIZE, 260, GroupLayout.PREFERRED_SIZE).addComponent( self.user, GroupLayout.PREFERRED_SIZE, 260, GroupLayout.PREFERRED_SIZE).addComponent( self.productName, GroupLayout.PREFERRED_SIZE, 260, GroupLayout.PREFERRED_SIZE) )).addGroup( innerPanelLayout.createSequentialGroup().addComponent( self.testID, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE).addGap(18, 18, 18). addGroup(innerPanelLayout.createParallelGroup( ).addComponent( self.search, GroupLayout.PREFERRED_SIZE, 260, GroupLayout.PREFERRED_SIZE).addComponent( self.testName, GroupLayout.PREFERRED_SIZE, 260, GroupLayout.PREFERRED_SIZE)))).addGap( 348, 348, 348))) innerPanelLayout.setVerticalGroup(innerPanelLayout.createParallelGroup( ).addGroup(innerPanelLayout.createSequentialGroup().addContainerGap( ).addGroup( innerPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING, False).addComponent(self.defectDojoURL).addComponent( self.labelDojoURL, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, sys.maxint) ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup( innerPanelLayout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.apiKey, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.labelApiKey, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE) ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup( innerPanelLayout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.user, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.labelUsername, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE) ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup( innerPanelLayout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.productName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.labelProductName, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE) ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup( innerPanelLayout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.engagementName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.engagementID, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.labelEngagementID, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE) ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup( innerPanelLayout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( self.testName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.testID, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent( self.labelTestID, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE) ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup( innerPanelLayout.createParallelGroup( GroupLayout.Alignment.LEADING, False).addComponent( self.search, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, sys.maxint).addComponent( self.searchProductButton)).addContainerGap( 131, sys.maxint))) layout.setHorizontalGroup(layout.createParallelGroup().addGroup( layout.createSequentialGroup().addComponent( innerPanel, GroupLayout.PREFERRED_SIZE, 633, GroupLayout.PREFERRED_SIZE).addGap(0, 312, sys.maxint))) layout.setVerticalGroup(layout.createParallelGroup().addGroup( layout.createSequentialGroup().addComponent( innerPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addGap(0, 199, sys.maxint)))
accountsList = AccountUtil.allMatchesForSearch(moneydance_data, MyAcctFilter()) accountsList = sorted(accountsList, key=lambda sort_x: (sort_x.getFullAccountName().upper())) acct = JOptionPane.showInputDialog(None, "Select Acct", "ACCOUNT LIST", JOptionPane.INFORMATION_MESSAGE, moneydance_ui.getIcon("/com/moneydance/apps/md/view/gui/glyphs/appicon_64.png"), accountsList, None) # type: Account if not acct: raise Exception("ERROR") get_a_date = JLabel("enter a date (enter as yyyy/mm/dd):") user_selectDateStart = JDateField(CustomDateFormat("ymd"),15) # Use MD API function (not std Python) user_selectDateStart.setDateInt(DateUtil.getStrippedDateInt()) datePanel = JPanel(GridLayout(0, 1)) datePanel.add(get_a_date) datePanel.add(user_selectDateStart) options = ["Cancel", "OK"] userAction = JOptionPane.showOptionDialog(None, datePanel, "Select a Date for balance:", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, None, options,
def getUiComponent(self): self.panel = JPanel() self.main = JPanel() self.main.setLayout(BoxLayout(self.main, BoxLayout.Y_AXIS)) self.access_key_panel = JPanel() self.main.add(self.access_key_panel) self.access_key_panel.setLayout( BoxLayout(self.access_key_panel, BoxLayout.X_AXIS)) self.access_key_panel.add(JLabel('Access Key: ')) self.access_key = JTextField('', 25) self.access_key_panel.add(self.access_key) self.secret_key_panel = JPanel() self.main.add(self.secret_key_panel) self.secret_key_panel.setLayout( BoxLayout(self.secret_key_panel, BoxLayout.X_AXIS)) self.secret_key_panel.add(JLabel('Secret Key: ')) self.secret_key = JPasswordField('', 25) self.secret_key_panel.add(self.secret_key) self.target_host_panel = JPanel() self.main.add(self.target_host_panel) self.target_host_panel.setLayout( BoxLayout(self.target_host_panel, BoxLayout.X_AXIS)) self.target_host_panel.add(JLabel('Target host: ')) self.target_host = JTextField('example.com', 25) self.target_host_panel.add(self.target_host) self.buttons_panel = JPanel() self.main.add(self.buttons_panel) self.buttons_panel.setLayout( BoxLayout(self.buttons_panel, BoxLayout.X_AXIS)) #self.save_button = JButton('Save', actionPerformed = self.saveKeys) #not implemented yet #self.buttons_panel.add(self.save_button) self.enable_button = JButton('Enable', actionPerformed=self.enableGateway) self.buttons_panel.add(self.enable_button) self.disable_button = JButton('Disable', actionPerformed=self.disableGateway) self.buttons_panel.add(self.disable_button) self.disable_button.setEnabled(False) self.protocol_panel = JPanel() self.main.add(self.protocol_panel) self.protocol_panel.setLayout( BoxLayout(self.protocol_panel, BoxLayout.Y_AXIS)) self.protocol_panel.add(JLabel("Target Protocol:")) self.https_button = JRadioButton("HTTPS", True) self.http_button = JRadioButton("HTTP", False) self.protocol_panel.add(self.http_button) self.protocol_panel.add(self.https_button) buttongroup = ButtonGroup() buttongroup.add(self.https_button) buttongroup.add(self.http_button) self.regions_title = JPanel() self.main.add(self.regions_title) self.regions_title.add(JLabel("Regions to launch API Gateways in:")) self.regions_panel = JPanel() self.main.add(self.regions_panel) glayout = GridLayout(4, 3) self.regions_panel.setLayout(glayout) for region in AVAIL_REGIONS: cur_region = region.replace('-', '_') cur_region = cur_region + '_status' setattr(self, cur_region, JCheckBox(region, True)) attr = getattr(self, cur_region) self.regions_panel.add(attr) self.status = JPanel() self.main.add(self.status) self.status.setLayout(BoxLayout(self.status, BoxLayout.X_AXIS)) self.status_indicator = JLabel(DISABLED, JLabel.CENTER) self.status.add(self.status_indicator) self.panel.add(self.main) return self.panel
def draw(self): """ init show tab """ filterLModified = JLabel("Modified:") filterLModified.setBounds(10, 10, 100, 30) filterLUnauthenticated = JLabel("Unauthenticated:") filterLUnauthenticated.setBounds(250, 10, 100, 30) self._extender.showAuthBypassModified = JCheckBox( self._extender.BYPASSSED_STR) self._extender.showAuthBypassModified.setBounds(10, 35, 200, 30) self._extender.showAuthBypassModified.setSelected(True) self._extender.showAuthBypassModified.addItemListener( TabTableFilter(self._extender)) self._extender.showAuthPotentiallyEnforcedModified = JCheckBox( "Is enforced???") self._extender.showAuthPotentiallyEnforcedModified.setBounds( 10, 60, 200, 30) self._extender.showAuthPotentiallyEnforcedModified.setSelected(True) self._extender.showAuthPotentiallyEnforcedModified.addItemListener( TabTableFilter(self._extender)) self._extender.showAuthEnforcedModified = JCheckBox( self._extender.ENFORCED_STR) self._extender.showAuthEnforcedModified.setBounds(10, 85, 200, 30) self._extender.showAuthEnforcedModified.setSelected(True) self._extender.showAuthEnforcedModified.addItemListener( TabTableFilter(self._extender)) self._extender.showAuthBypassUnauthenticated = JCheckBox( self._extender.BYPASSSED_STR) self._extender.showAuthBypassUnauthenticated.setBounds( 250, 35, 200, 30) self._extender.showAuthBypassUnauthenticated.setSelected(True) self._extender.showAuthBypassUnauthenticated.addItemListener( TabTableFilter(self._extender)) self._extender.showAuthPotentiallyEnforcedUnauthenticated = JCheckBox( "Is enforced???") self._extender.showAuthPotentiallyEnforcedUnauthenticated.setBounds( 250, 60, 200, 30) self._extender.showAuthPotentiallyEnforcedUnauthenticated.setSelected( True) self._extender.showAuthPotentiallyEnforcedUnauthenticated.addItemListener( TabTableFilter(self._extender)) self._extender.showAuthEnforcedUnauthenticated = JCheckBox( self._extender.ENFORCED_STR) self._extender.showAuthEnforcedUnauthenticated.setBounds( 250, 85, 200, 30) self._extender.showAuthEnforcedUnauthenticated.setSelected(True) self._extender.showAuthEnforcedUnauthenticated.addItemListener( TabTableFilter(self._extender)) self._extender.showDisabledUnauthenticated = JCheckBox("Disabled") self._extender.showDisabledUnauthenticated.setBounds(250, 110, 200, 30) self._extender.showDisabledUnauthenticated.setSelected(True) self._extender.showDisabledUnauthenticated.addItemListener( TabTableFilter(self._extender)) self._extender.filterPnl = JPanel() self._extender.filterPnl.setLayout(None) self._extender.filterPnl.setBounds(0, 0, 1000, 1000) self._extender.filterPnl.add(filterLModified) self._extender.filterPnl.add(filterLUnauthenticated) self._extender.filterPnl.add(self._extender.showAuthBypassModified) self._extender.filterPnl.add( self._extender.showAuthPotentiallyEnforcedModified) self._extender.filterPnl.add(self._extender.showAuthEnforcedModified) self._extender.filterPnl.add( self._extender.showAuthBypassUnauthenticated) self._extender.filterPnl.add( self._extender.showAuthPotentiallyEnforcedUnauthenticated) self._extender.filterPnl.add( self._extender.showAuthEnforcedUnauthenticated) self._extender.filterPnl.add( self._extender.showDisabledUnauthenticated)
def getContentPane(): global contentPane global REMAP_WIDTH global REMAP_HEIGHT global MARGIN if not contentPane: global mainScreen global mainScreenImg mainScreen = JLabel() cursorImg = BufferedImage(16,16,BufferedImage.TYPE_INT_ARGB) blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, Point(0,0), "blank cursor") mainScreen.setCursor(blankCursor) mainScreen.setPreferredSize( Dimension(REMAP_WIDTH + MARGIN, REMAP_HEIGHT + MARGIN)) mainScreen.setText("main screen!") image = BufferedImage(REMAP_WIDTH + MARGIN, REMAP_HEIGHT + MARGIN , BufferedImage.TYPE_INT_ARGB) g = image.createGraphics() g.setColor(Color.BLACK) g.fillRect(0, 0, REMAP_WIDTH + MARGIN, REMAP_HEIGHT + MARGIN) g.setColor(Color.WHITE) g.setFont(Font("Serif", Font.BOLD, 20)) g.drawString("Cursor will display on your device.", 50, 30) mainScreenImg = image mainScreen.setIcon(swing.ImageIcon(image)) mouseListener = ScrMouseListener() mainScreen.addMouseListener(mouseListener) mainScreen.addMouseMotionListener(mouseListener) mainScreen.addMouseWheelListener(mouseListener) keyListener = ScrKeyListener() mainScreen.addKeyListener(keyListener) mainScreen.setFocusable(True) scrPanel = JPanel() scrPanel.setLayout(BoxLayout(scrPanel, BoxLayout.Y_AXIS)) scrPanel.add(mainScreen) contentPane = JPanel() contentPane.setLayout(BorderLayout()) contentPane.add(scrPanel, BorderLayout.WEST) # contentPAne.add(controlPanel(). BorderLayout.EAST) return contentPane
class BurpExtender(IBurpExtender, IContextMenuFactory, ITab, IProxyListener): """ BurpSuite插件类 """ def __init__(self): self.plugin_name = u'orz Plugin' self.panel = None self.callbacks = None self.DEBUG = True self.context = None self.helpers = None self.log_box_width = 1000 self.log_box_height = 400 self.tools = Tools() self.now_version = VERSION def registerExtenderCallbacks(self, callbacks): # 注册插件 self.callbacks = callbacks self.helpers = callbacks.getHelpers() self.callbacks.setExtensionName(self.plugin_name) # 绘制标签页UI self.tab_ui() self.callbacks.customizeUiComponent(self.panel) self.callbacks.addSuiteTab(self) self.callbacks.registerProxyListener(self) self.callbacks.registerContextMenuFactory(self) print('Plugin load successfully!') self.tools.log('INFO', '插件加载成功 - 当前版本: {}'.format(VERSION)) self.tools.log('INFO', '当前debug模式: {}'.format(self.DEBUG)) # 窗口大小检查线程 log_box_thread = threading.Thread(target=self.reset_log_box_size) log_box_thread.setDaemon(True) log_box_thread.start() return def createMenuItems(self, invocation): # 创建菜单右键菜单选项 self.context = invocation menu_list = JMenu('orz Plugin') if self.context.getToolFlag() == 0x40: menu_list.add( JMenuItem(u'添加IP伪造请求头', actionPerformed=self.update_client_src_ip)) menu_list.add( JMenuItem(u'生成DNSLog Payload', actionPerformed=self.dnslog_payload)) # DEBUG 按钮 menu_list.add( JMenuItem('orz - DEBUG', actionPerformed=self.debug_fun)) return [menu_list] def tab_ui(self): self.panel = JPanel() self.panel.setLayout(None) self.ui_client_dnslog_label_1 = JLabel('-' * 10 + u' IP伪造请求头 & DNSLog 配置 ' + '-' * 155) self.ui_client_dnslog_label_1.setBounds(20, 10, 1000, 28) self.ui_client_ip_label_1 = JLabel(u'伪造IP: ') self.ui_client_ip_label_1.setBounds(20, 40, 70, 30) self.ui_client_ip = JTextField('127.0.0.1') self.ui_client_ip.setBounds(80, 40, 200, 28) self.ui_client_url_label_1 = JLabel(u'dnslog url: ') self.ui_client_url_label_1.setBounds(10, 80, 70, 30) self.ui_client_url = JTextField('http://examlpe.com') self.ui_client_url.setBounds(80, 80, 200, 28) self.ui_button_label = JLabel('-' * 210) self.ui_button_label.setBounds(20, 110, 1000, 28) #self.ui_web_test_button = JButton(u'登录测试', actionPerformed=self.login_test) #self.ui_web_test_button.setBounds(20, 140, 100, 28) self.ui_save_button = JButton(u'保存配置', actionPerformed=self.save_configuration) self.ui_save_button.setBounds(20, 140, 100, 28) self.ui_debug_button = JButton('Debug', actionPerformed=self.debug_fun) self.ui_debug_button.setBounds(135, 140, 100, 28) self.panel.add(self.ui_debug_button) self.ui_log_box = JTextArea('') self.ui_log_box.setLineWrap(True) self.ui_log_box.setEditable(False) self.ui_log_scroll_pane = JScrollPane(self.ui_log_box) self.ui_log_scroll_pane.setBounds(20, 190, self.log_box_width, self.log_box_height) self.panel.add(self.ui_client_dnslog_label_1) self.panel.add(self.ui_client_ip_label_1) self.panel.add(self.ui_client_ip) self.panel.add(self.ui_client_url_label_1) self.panel.add(self.ui_client_url) self.panel.add(self.ui_button_label) #self.panel.add(self.ui_web_test_button) self.panel.add(self.ui_save_button) self.panel.add(self.ui_log_scroll_pane) self.tools.panel = self.panel self.tools.log_box = self.ui_log_box self.tools.log_scroll_pane = self.ui_log_scroll_pane def getTabCaption(self): # 设置标签页名称 return self.plugin_name def getUiComponent(self): # 设置标签页UI return self.panel def processProxyMessage(self, message_is_request, message): """ 处理Proxy请求 url: http://biubiu.com:80/h/p?id=24&a=123 request_methond: POST GET etc cookie: 顾名思义 content_type: 如 application/json; charset=UTF-8 request_header: 包含coolie的头 request_body: 顾名思义 host: 主机名 port: 端口号 protocol: 协议,如http、https url_parameters:url中的参数信息, 格式{'id':23,'a':123} """ if message_is_request and self.DEBUG: request = message.getMessageInfo().getRequest() analyzedRequest = self.helpers.analyzeRequest( message.getMessageInfo().getHttpService(), request) request_headers = analyzedRequest.getHeaders() request_body = request[analyzedRequest.getBodyOffset():].tostring() url = str(analyzedRequest.getUrl()) host = message.getMessageInfo().getHttpService().getHost() port = message.getMessageInfo().getHttpService().getPort() protocol = message.getMessageInfo().getHttpService().getProtocol() request_methond = str(analyzedRequest.getMethod()) parameters = analyzedRequest.getParameters() url_parameters = {} for parameter in parameters: if parameter.getType() == 0: url_parameters[str(parameter.getName())] = str( parameter.getValue()) cookie = "" content_type = "" request_header = {} for header in request_headers[2:]: header = str(header).strip() header_temp = header.split(':') request_header[header_temp[0].strip()] = ':'.join( header_temp[1:]).strip() if header.startswith("Cookie:"): cookie_temp = header.split(':') cookie = ':'.join(cookie_temp[1:]).strip() continue if header.startswith("Content-Type"): content_type = ':'.join(header.split(':')[1:]).strip() # self.tools.log('content_type', content_type) # self.tools.log('request_methond', request_methond) # self.tools.log('url', url) #self.tools.log('request_header', request_header) # self.tools.log('cookie', cookie) self.tools.http_deal(url, request_methond, cookie, content_type, request_header, request_body) # 多线程 # proxy_thread = threading.Thread(target=self.tools.http_deal, args=( # url, request_methond, cookie, content_type, request_header, request_body)) # proxy_thread.setDaemon(True) # proxy_thread.start() # 新增处理线程 def login_test(self, event): # 生产环境Web方式获取Cookie测试 return def save_configuration(self, event): self.tools.client_src_ip = str(self.ui_client_ip.getText()).strip() self.tools.dnslog_url = str(self.ui_client_url.getText()).strip() self.tools.log('INFO', '配置保存成功') def reset_log_box_size(self): while self.tools.runtime(): time.sleep(1) new_width = int(self.panel.rootPane.getSize().width) - 40 new_height = int(self.panel.rootPane.getSize().height) - 290 if new_width != self.log_box_width or new_height != self.log_box_height: self.log_box_width = new_width self.log_box_height = new_height self.ui_log_scroll_pane.setBounds(20, 190, self.log_box_width, self.log_box_height) self.panel.updateUI() def debug_fun(self, event): if self.DEBUG: self.DEBUG = False self.tools.log('INFO', 'set debug = False') else: self.DEBUG = True self.tools.log('INFO', 'set debug = True') def update_web_cookie(self): http_traffic = self.context.getSelectedMessages()[0] traffic_analyze = self.helpers.analyzeRequest(http_traffic) return def web_cookie_web_prod(self, event): self.update_web_cookie() def update_client_src_ip(self, event): add_header = [ 'X-Originating-IP', 'X-Forwarded-For', 'X-Remote-IP', 'X-Remote-Addr', 'X-Client-IP', 'X-Real-IP', 'Proxy-Cllient-IP', 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR' ] http_traffic = self.context.getSelectedMessages()[0] traffic_analyze = self.helpers.analyzeRequest(http_traffic) new_headers = [] tmp_add_header = map(str.lower, add_header) for header in traffic_analyze.getHeaders(): tmp_header = header.split(':')[0].strip().lower() if tmp_header not in tmp_add_header: new_headers.append(header) new_headers += map( lambda x: '{}: {}'.format(x, self.tools.client_src_ip), add_header) new_request = self.helpers.buildHttpMessage( new_headers, http_traffic.getRequest()[traffic_analyze.getBodyOffset():]) http_traffic.setRequest(new_request) def dnslog_payload(self, event): self.tools.msg_box('功能暂未实现,待更新')
def registerExtenderCallbacks(self, callbacks): self.out = callbacks.getStdout() self.callbacks = callbacks self.helpers = callbacks.getHelpers() callbacks.setExtensionName("WhatsApp Decoder") self.banner = JLabel("WHATSAPP DECRYPTION AND ENCRYPTION EXTENSION BY DIKLA BARDA, ROMAN ZAIKIN", SwingConstants.CENTER) self.banner.setFont(Font("Serif", Font.PLAIN, 17)) self.banner.setBorder(BorderFactory.createLineBorder(Color.BLACK)) self.statusConn = JLabel("CONNECTION STATUS: ") self.statusConnField = JLabel("NOT CONNECTED") self.statusAct = JLabel("ACTION STATUS: ") self.statusActField = JLabel("OK") self.ref = JLabel("Ref object: ") self.refField = JTextField("123", 80) self.refField.setToolTipText("Copy the Ref from burpsuit WebSocket, make sure that the parameter 'secret' is there and you copy only the 'ref' without the connection and other data, if not logout from your whatsapp web and login again.") self.privateKey = JLabel("Private Key:") self.privateKeyField = JTextField("123", 80) self.privateKeyField.setToolTipText("Copy the private key list from your whatsapp web according to our blog post ") self.publicKey = JLabel("Public Key: ") self.publicKeyField = JTextField("123", 80) self.publicKeyField.setToolTipText("Copy the public key list from your whatsapp web according to our blog post") self.statusPanel1 = JPanel() self.statusPanel1.add(self.statusConn) self.statusPanel1.add(self.statusConnField) self.statusPanel2 = JPanel() self.statusPanel2.add(self.statusAct) self.statusPanel2.add(self.statusActField) self.privateKeyPanel = JPanel() self.privateKeyPanel.add(self.privateKey) self.privateKeyPanel.add(self.privateKeyField) self.publicKeyPanel = JPanel() self.publicKeyPanel.add(self.publicKey) self.publicKeyPanel.add(self.publicKeyField) self.refPanel = JPanel() self.refPanel.add(self.ref) self.refPanel.add(self.refField) self.messageField = JTextArea("", 5, 90) self.messageField.setLineWrap(True) self.messageField.setToolTipText("If you putting in the incoming traffic you can copy it from burp suit, the outgoing is the list from aesCbcEncrypt") self.whatsAppMessagesPanel = JPanel() self.whatsAppMessagesPanel.add(self.messageField) self.btnSave = JButton("Connect", actionPerformed=self.saveConfig) self.btnRestore = JButton("Clear", actionPerformed=self.clearConfig) self.grpConfig = JPanel() self.grpConfig.add(self.btnSave) self.grpConfig.add(self.btnRestore) self.btnIncoming = JButton("Incoming", actionPerformed=self.performAction) self.btnOutgoing = JButton("Outgoing", actionPerformed=self.performAction) self.btnEncrypt = JButton("Encrypt", actionPerformed=self.performAction) self.btnEncrypt.setEnabled(False) # Can't send data without a direction self.btnDecrypt = JButton("Decrypt", actionPerformed=self.performAction) self.btnDecrypt.setEnabled(False) # Can't send data without a direction self.btnCrypt = JPanel() self.btnCrypt.add(self.btnIncoming) self.btnCrypt.add(self.btnEncrypt) self.btnCrypt.add(self.btnDecrypt) self.btnCrypt.add(self.btnOutgoing) self.tab = JPanel() layout = GridBagLayout() self.tab.setLayout(layout) c = GridBagConstraints() c.ipadx = 0 c.ipady = 0 c.fill = GridBagConstraints.BOTH #c.weightx = 0 # gap between the x items #c.weighty = 0 # gap between the y items c.anchor = GridBagConstraints.NORTHWEST c.gridx = 0 c.gridy = 0 self.tab.add(self.banner, c) c.gridx = 0 c.gridy = 1 self.tab.add(self.refPanel, c) c.gridx = 0 c.gridy = 2 self.tab.add(self.privateKeyPanel, c) c.gridx = 0 c.gridy = 3 self.tab.add(self.publicKeyPanel, c) c.gridx = 0 c.gridy = 4 c.anchor = GridBagConstraints.CENTER self.tab.add(self.grpConfig, c) c.gridx = 0 c.gridy = 5 self.tab.add(self.whatsAppMessagesPanel, c) c.gridx = 0 c.gridy = 6 self.tab.add(self.btnCrypt, c) c.gridx = 0 c.gridy = 7 self.tab.add(self.statusPanel1, c) c.gridx = 0 c.gridy = 8 self.tab.add(self.statusPanel2, c) # restore config self.restoreConfig() callbacks.addSuiteTab(self)
class BurpExtender(IBurpExtender, ITab): socket_time_out = 3 def registerExtenderCallbacks(self, callbacks): self.out = callbacks.getStdout() self.callbacks = callbacks self.helpers = callbacks.getHelpers() callbacks.setExtensionName("WhatsApp Decoder") self.banner = JLabel("WHATSAPP DECRYPTION AND ENCRYPTION EXTENSION BY DIKLA BARDA, ROMAN ZAIKIN", SwingConstants.CENTER) self.banner.setFont(Font("Serif", Font.PLAIN, 17)) self.banner.setBorder(BorderFactory.createLineBorder(Color.BLACK)) self.statusConn = JLabel("CONNECTION STATUS: ") self.statusConnField = JLabel("NOT CONNECTED") self.statusAct = JLabel("ACTION STATUS: ") self.statusActField = JLabel("OK") self.ref = JLabel("Ref object: ") self.refField = JTextField("123", 80) self.refField.setToolTipText("Copy the Ref from burpsuit WebSocket, make sure that the parameter 'secret' is there and you copy only the 'ref' without the connection and other data, if not logout from your whatsapp web and login again.") self.privateKey = JLabel("Private Key:") self.privateKeyField = JTextField("123", 80) self.privateKeyField.setToolTipText("Copy the private key list from your whatsapp web according to our blog post ") self.publicKey = JLabel("Public Key: ") self.publicKeyField = JTextField("123", 80) self.publicKeyField.setToolTipText("Copy the public key list from your whatsapp web according to our blog post") self.statusPanel1 = JPanel() self.statusPanel1.add(self.statusConn) self.statusPanel1.add(self.statusConnField) self.statusPanel2 = JPanel() self.statusPanel2.add(self.statusAct) self.statusPanel2.add(self.statusActField) self.privateKeyPanel = JPanel() self.privateKeyPanel.add(self.privateKey) self.privateKeyPanel.add(self.privateKeyField) self.publicKeyPanel = JPanel() self.publicKeyPanel.add(self.publicKey) self.publicKeyPanel.add(self.publicKeyField) self.refPanel = JPanel() self.refPanel.add(self.ref) self.refPanel.add(self.refField) self.messageField = JTextArea("", 5, 90) self.messageField.setLineWrap(True) self.messageField.setToolTipText("If you putting in the incoming traffic you can copy it from burp suit, the outgoing is the list from aesCbcEncrypt") self.whatsAppMessagesPanel = JPanel() self.whatsAppMessagesPanel.add(self.messageField) self.btnSave = JButton("Connect", actionPerformed=self.saveConfig) self.btnRestore = JButton("Clear", actionPerformed=self.clearConfig) self.grpConfig = JPanel() self.grpConfig.add(self.btnSave) self.grpConfig.add(self.btnRestore) self.btnIncoming = JButton("Incoming", actionPerformed=self.performAction) self.btnOutgoing = JButton("Outgoing", actionPerformed=self.performAction) self.btnEncrypt = JButton("Encrypt", actionPerformed=self.performAction) self.btnEncrypt.setEnabled(False) # Can't send data without a direction self.btnDecrypt = JButton("Decrypt", actionPerformed=self.performAction) self.btnDecrypt.setEnabled(False) # Can't send data without a direction self.btnCrypt = JPanel() self.btnCrypt.add(self.btnIncoming) self.btnCrypt.add(self.btnEncrypt) self.btnCrypt.add(self.btnDecrypt) self.btnCrypt.add(self.btnOutgoing) self.tab = JPanel() layout = GridBagLayout() self.tab.setLayout(layout) c = GridBagConstraints() c.ipadx = 0 c.ipady = 0 c.fill = GridBagConstraints.BOTH #c.weightx = 0 # gap between the x items #c.weighty = 0 # gap between the y items c.anchor = GridBagConstraints.NORTHWEST c.gridx = 0 c.gridy = 0 self.tab.add(self.banner, c) c.gridx = 0 c.gridy = 1 self.tab.add(self.refPanel, c) c.gridx = 0 c.gridy = 2 self.tab.add(self.privateKeyPanel, c) c.gridx = 0 c.gridy = 3 self.tab.add(self.publicKeyPanel, c) c.gridx = 0 c.gridy = 4 c.anchor = GridBagConstraints.CENTER self.tab.add(self.grpConfig, c) c.gridx = 0 c.gridy = 5 self.tab.add(self.whatsAppMessagesPanel, c) c.gridx = 0 c.gridy = 6 self.tab.add(self.btnCrypt, c) c.gridx = 0 c.gridy = 7 self.tab.add(self.statusPanel1, c) c.gridx = 0 c.gridy = 8 self.tab.add(self.statusPanel2, c) # restore config self.restoreConfig() callbacks.addSuiteTab(self) def performAction(self, e=None): self.client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.client.settimeout(self.socket_time_out) self.data = self.messageField.getText() eventSource = e.getSource() eventSource.setEnabled(False) # Incoming data if eventSource == self.btnIncoming: self.direction = "in" self.btnOutgoing.setEnabled(True) self.btnEncrypt.setEnabled(True) self.btnDecrypt.setEnabled(True) # Outgoing data elif eventSource == self.btnOutgoing: self.direction = "out" self.btnIncoming.setEnabled(True) self.btnEncrypt.setEnabled(True) self.btnDecrypt.setEnabled(True) # Send elif eventSource == self.btnDecrypt: self.btnDecrypt.setEnabled(True) clientData = json.dumps({"action": "decrypt", "data": { "direction": self.direction, "msg": self.messageField.getText() } }) self.client.sendto(clientData, ("127.0.0.1",2912)) try: serverData, addr = self.client.recvfrom(2048) serverData = json.loads(serverData) if serverData["status"] == 0: print serverData self.messageField.setText(json.dumps(serverData["data"])) self.statusActField.setForeground(Color.GREEN) self.statusActField.setText("OK") else: self.statusActField.setForeground(Color.RED) self.statusActField.setText("Error: {}".format(json.dumps(serverData["data"]))) except socket.timeout: pass elif eventSource == self.btnEncrypt: self.btnEncrypt.setEnabled(True) clientData = json.dumps({"action": "encrypt", "data": { "direction": self.direction, "msg": self.messageField.getText() } }) self.client.sendto(clientData, ("127.0.0.1", 2912)) try: serverData, addr = self.client.recvfrom(2048) serverData = json.loads(serverData) if serverData["status"] == 0: if isinstance(serverData["data"], list): self.messageField.setText(json.dumps(serverData["data"])) else: self.messageField.setText(serverData["data"]) self.statusActField.setForeground(Color.GREEN) self.statusActField.setText("OK") else: self.statusActField.setForeground(Color.RED) self.statusActField.setText("Error: {}".format(json.dumps(serverData["data"]))) except socket.timeout: pass self.client.close() def saveConfig(self, e=None): self.client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.client.settimeout(self.socket_time_out) config = { 'ref': self.refField.getText(), 'private': self.privateKeyField.getText(), 'public': self.publicKeyField.getText(), } self.callbacks.saveExtensionSetting("config", pickle.dumps(config)) try: clientData = json.dumps({"action":"init", "data":{ "ref":json.loads(self.refField.getText()), "private":self.privateKeyField.getText(), "public":self.publicKeyField.getText() } }) self.client.sendto(clientData, ("127.0.0.1", 2912)) serverData, addr = self.client.recvfrom(2048) print (serverData) self.statusConnField.setText("CONNECTED") self.statusActField.setForeground(Color.GREEN) self.statusActField.setText("OK") except socket.timeout: self.statusActField.setForeground(Color.RED) self.statusActField.setText("Error: Can't connect to the local server make sure parser.py is running!") pass except Exception as e: self.statusActField.setForeground(Color.RED) self.statusActField.setText("Error: make Sure the ref is a correct json!") self.client.close() def clearConfig(self, e=None): self.refField.setText("") self.privateKeyField.setText("") self.publicKeyField.setText("") self.statusConnField.setText("NOT CONNECTED") self.statusActField.setText("OK") self.messageField.setText("") def restoreConfig(self, e=None): storedConfig = self.callbacks.loadExtensionSetting("config") if storedConfig != None: config = pickle.loads(storedConfig) self.refField.setText(config["ref"]) self.privateKeyField.setText(config["private"]) self.publicKeyField.setText(config["public"]) def getTabCaption(self): return ("WhatsApp Decoder") def getUiComponent(self): return self.tab
def __init__(self, parent, title, app): from javax.swing import JCheckBox, JRadioButton, ButtonGroup self.app = app border = BorderFactory.createEmptyBorder(5, 7, 5, 7) self.getContentPane().setBorder(border) self.getContentPane().setLayout(BorderLayout(0, 5)) self.tabbedPane = JTabbedPane() #1 Tab: general panel1 = JPanel() panel1.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7)) panel1.setLayout(BoxLayout(panel1, BoxLayout.PAGE_AXIS)) #Checkbutton to enable/disable update check when script starts self.updateCBtn = JCheckBox(self.app.strings.getString("updateCBtn")) self.updateCBtn.setToolTipText( self.app.strings.getString("updateCBtn_tooltip")) #Download tools downloadBtn = JButton(self.app.strings.getString("updatesBtn"), ImageProvider.get("dialogs", "refresh"), actionPerformed=self.on_downloadBtn_clicked) downloadBtn.setToolTipText( self.app.strings.getString("updatesBtn_tooltip")) #Checkbuttons for enabling/disabling tools toolsPanel = JPanel(BorderLayout(0, 5)) title = self.app.strings.getString("enable_disable_tools") toolsPanel.setBorder(BorderFactory.createTitledBorder(title)) infoLbl = JLabel(self.app.strings.getString("JOSM_restart_warning")) infoLbl.setFont(infoLbl.getFont().deriveFont(Font.ITALIC)) toolsPanel.add(infoLbl, BorderLayout.PAGE_START) toolsStatusPane = JPanel(GridLayout(len(self.app.realTools), 0)) self.toolsCBtns = [] for tool in self.app.realTools: toolCBtn = JCheckBox() toolCBtn.addItemListener(self) toolLbl = JLabel(tool.title, tool.bigIcon, JLabel.LEFT) self.toolsCBtns.append(toolCBtn) toolPane = JPanel() toolPane.setLayout(BoxLayout(toolPane, BoxLayout.X_AXIS)) toolPane.add(toolCBtn) toolPane.add(toolLbl) toolsStatusPane.add(toolPane) toolsPanel.add(toolsStatusPane, BorderLayout.CENTER) #Radiobuttons for enabling/disabling layers when a new one #is added layersPanel = JPanel(GridLayout(0, 1)) title = self.app.strings.getString("errors_layers_manager") layersPanel.setBorder(BorderFactory.createTitledBorder(title)) errorLayersLbl = JLabel( self.app.strings.getString("errors_layers_info")) errorLayersLbl.setFont(errorLayersLbl.getFont().deriveFont( Font.ITALIC)) layersPanel.add(errorLayersLbl) self.layersRBtns = {} group = ButtonGroup() for mode in self.app.layersModes: layerRBtn = JRadioButton(self.app.strings.getString("%s" % mode)) group.add(layerRBtn) layersPanel.add(layerRBtn) self.layersRBtns[mode] = layerRBtn #Max number of errors text field self.maxErrorsNumberTextField = JTextField() self.maxErrorsNumberTextField.setToolTipText( self.app.strings.getString("maxErrorsNumberTextField_tooltip")) self.maxErrorsNumberTFieldDefaultBorder = self.maxErrorsNumberTextField.getBorder( ) self.maxErrorsNumberTextField.getDocument().addDocumentListener( ErrNumTextListener(self)) #layout self.updateCBtn.setAlignmentX(Component.LEFT_ALIGNMENT) panel1.add(self.updateCBtn) panel1.add(Box.createRigidArea(Dimension(0, 15))) downloadBtn.setAlignmentX(Component.LEFT_ALIGNMENT) panel1.add(downloadBtn) panel1.add(Box.createRigidArea(Dimension(0, 15))) toolsPanel.setAlignmentX(Component.LEFT_ALIGNMENT) panel1.add(toolsPanel) panel1.add(Box.createRigidArea(Dimension(0, 15))) layersPanel.setAlignmentX(Component.LEFT_ALIGNMENT) panel1.add(layersPanel) panel1.add(Box.createRigidArea(Dimension(0, 15))) maxErrP = JPanel(BorderLayout(5, 0)) maxErrP.add(JLabel(self.app.strings.getString("max_errors_number")), BorderLayout.LINE_START) maxErrP.add(self.maxErrorsNumberTextField, BorderLayout.CENTER) p = JPanel(BorderLayout()) p.add(maxErrP, BorderLayout.PAGE_START) p.setAlignmentX(Component.LEFT_ALIGNMENT) panel1.add(p) self.tabbedPane.addTab(self.app.strings.getString("tab_1_title"), None, panel1, None) #2 Tab: favourite zones panel2 = JPanel(BorderLayout(5, 15)) panel2.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7)) #status topPanel = JPanel() topPanel.setLayout(BoxLayout(topPanel, BoxLayout.Y_AXIS)) infoPanel = HtmlPanel(self.app.strings.getString("fav_zones_info")) infoPanel.getEditorPane().addHyperlinkListener(self) infoPanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.favZoneStatusCBtn = JCheckBox( self.app.strings.getString("activate_fav_area"), actionListener=self) self.favZoneStatusCBtn.setToolTipText( self.app.strings.getString("activate_fav_area_tooltip")) self.favZoneStatusCBtn.setAlignmentX(Component.LEFT_ALIGNMENT) topPanel.add(infoPanel) topPanel.add(Box.createRigidArea(Dimension(0, 10))) topPanel.add(self.favZoneStatusCBtn) #table self.zonesTable = JTable() tableSelectionModel = self.zonesTable.getSelectionModel() tableSelectionModel.addListSelectionListener(ZonesTableListener(self)) columns = [ "", self.app.strings.getString("Type"), self.app.strings.getString("Name") ] tableModel = ZonesTableModel([], columns) self.zonesTable.setModel(tableModel) self.scrollPane = JScrollPane(self.zonesTable) #map self.zonesMap = JMapViewer() self.zonesMap.setZoomContolsVisible(False) self.zonesMap.setMinimumSize(Dimension(100, 200)) #buttons self.removeBtn = JButton(self.app.strings.getString("Remove"), ImageProvider.get("dialogs", "delete"), actionPerformed=self.on_removeBtn_clicked) self.removeBtn.setToolTipText( self.app.strings.getString("remove_tooltip")) newBtn = JButton(self.app.strings.getString("New"), ImageProvider.get("dialogs", "add"), actionPerformed=self.on_newBtn_clicked) newBtn.setToolTipText(self.app.strings.getString("new_tooltip")) #layout panel2.add(topPanel, BorderLayout.PAGE_START) panel2.add(self.scrollPane, BorderLayout.LINE_START) panel2.add(self.zonesMap, BorderLayout.CENTER) self.buttonsPanel = JPanel() self.buttonsPanel.add(self.removeBtn) self.buttonsPanel.add(newBtn) panel2.add(self.buttonsPanel, BorderLayout.PAGE_END) self.tabbedPane.addTab(self.app.strings.getString("tab_2_title"), None, panel2, None) #3 Tab Tools options panel3 = JPanel() panel3.setLayout(BoxLayout(panel3, BoxLayout.Y_AXIS)) panel3.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7)) for tool in self.app.realTools: if hasattr(tool, 'prefs'): p = JPanel(FlowLayout(FlowLayout.LEFT)) p.setBorder(BorderFactory.createTitledBorder(tool.title)) p.add(tool.prefsGui) panel3.add(p) self.tabbedPane.addTab(self.app.strings.getString("tab_3_title"), None, panel3, None) self.add(self.tabbedPane, BorderLayout.CENTER) exitPanel = JPanel() saveBtn = JButton(self.app.strings.getString("OK"), ImageProvider.get("ok"), actionPerformed=self.on_saveBtn_clicked) cancelBtn = JButton(self.app.strings.getString("cancel"), ImageProvider.get("cancel"), actionPerformed=self.on_cancelBtn_clicked) saveBtn.setToolTipText(self.app.strings.getString("save_preferences")) saveBtn.setAlignmentX(0.5) exitPanel.add(saveBtn) exitPanel.add(cancelBtn) self.add(exitPanel, BorderLayout.PAGE_END) self.addWindowListener(self) self.pack()
def adminLogined(instObj): global panel global table global heading global btnUpdate global frame frame = JFrame("Admin Page ") frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) frame.setSize(700, 640) frame.setLocation(200, 200) frame.setLayout(None) panel = JPanel() panel.setSize(700, 620) panel.setLocation(0, 20) panel.setLayout(None) panel.setVisible(True) panel.setBackground(Color.WHITE) heading = JLabel() heading.setBounds(310, 10, 200, 30) table = JTable() table.setBounds(0, 50, 700, 450) sp = JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS) btnUpdate = JButton("Update", actionPerformed=clickUpdate) btnUpdate.setBounds(300, 530, 100, 30) bar = JMenuBar() courses = JMenu("Course") addCourse = JMenuItem("Add Course", actionPerformed=clickAddCourse) showCourseList = JMenuItem("Show Course List", actionPerformed=clickShowCourseList) courses.add(addCourse) courses.add(showCourseList) bar.add(courses) teacher = JMenu("Teacher") addTeacher = JMenuItem("Add Teacher", actionPerformed=clickAddTeacher) showTeacherList = JMenuItem("Show Teacher List", actionPerformed=clickShowTeacherList) showTeacherIdPassword = JMenuItem( "Show Teacher Id Password", actionPerformed=clickShowTeacherIdPassword) teacher.add(addTeacher) teacher.add(showTeacherList) teacher.add(showTeacherIdPassword) bar.add(teacher) student = JMenu("Student") addStudent = JMenuItem("Add Student", actionPerformed=clickAddStudent) showAllStudentList = JMenuItem("Show All Student", actionPerformed=clickShowAllStudent) showStudentsByCourse = JMenuItem("Show Student By course", actionPerformed=clickShowStudentByCourse) showStudentsByTeacher = JMenuItem( "Show Student By Teacher", actionPerformed=clickShowStudentByTeacher) showStudentIdPassword = JMenuItem( "Show Student Id Password", actionPerformed=clickShowStudentIdPassword) student.add(addStudent) student.add(showAllStudentList) student.add(showStudentsByCourse) student.add(showStudentsByTeacher) student.add(showStudentIdPassword) bar.add(student) attendence = JMenu(" Teacher Attendence") teacherAttendence = JMenuItem(" Take Teacher Attendence", actionPerformed=clickTotalAttendence) specificTeacherAttendence = JMenuItem( "Show Specific Teacher Attendence", actionPerformed=clickShowSpecificTeacherAttendence) allTeacherAttendenceMonth = JMenuItem( "All Teacher Attendence In Month", actionPerformed=clickShowAllSTeacherAttendenceMonth) specificTeacherAttendenceInMonth = JMenuItem( "Specific Teacher Attendence In Month", actionPerformed=clickShowSpecificSTeacherAttendenceMonth) allTeacherAttendenceStatisticsInMonth = JMenuItem( "All Teacher Attendence Statistics In Month", actionPerformed=clickShowAllTeacherAttendenceStatisticsMonth) attendence.add(teacherAttendence) attendence.add(specificTeacherAttendence) attendence.add(allTeacherAttendenceMonth) attendence.add(specificTeacherAttendenceInMonth) attendence.add(allTeacherAttendenceStatisticsInMonth) bar.add(attendence) studentAttendence = JMenu(" Student Attendence") specificTeacherStudentsAttendence = JMenuItem( "Show Specific Teacher Students Attendence", actionPerformed=clickShowSpecificTeacherStudentsAttendence) specificCourseStudentsAttendence = JMenuItem( "Show Specific course Students Attendence", actionPerformed=clickShowSpecificCourseStudentsAttendence) specificTeacherStudentsAttendenceInMonth = JMenuItem( "Show Specific teacher Students Attendence In month", actionPerformed=clickShowSpecificTeacherStudentsAttendenceInMonth) specificCourseStudentsAttendenceInMonth = JMenuItem( "Show Specific course Students Attendence In month", actionPerformed=clickShowSpecificCourseStudentsAttendenceInMonth) allStudentsAttendenceStatisticsInMonth = JMenuItem( "All Students Attendence Statistics In month", actionPerformed=clickShowAllStudentsAttendenceStatisticsInMonth) specificTeacherStudentsAttendenceStatisticsInMonth = JMenuItem( "Specific Teacher Students Attendence Statistics In month", actionPerformed= clickShowSpecificTeacherStudentsAttendenceStatisticsInMonth) specificCourseStudentsAttendenceStatisticsInMonth = JMenuItem( "Specific Course Students Attendence Statistics In month", actionPerformed= clickShowSpecificCourseStudentsAttendenceStatisticsInMonth) specificStudentAttendenceInMonth = JMenuItem( "Specific Student Attendence In month", actionPerformed=clickShowSpecificStudentAttendenceInMonth) studentAttendence.add(specificTeacherStudentsAttendence) studentAttendence.add(specificCourseStudentsAttendence) studentAttendence.add(specificTeacherStudentsAttendenceInMonth) studentAttendence.add(specificCourseStudentsAttendenceInMonth) studentAttendence.add(allStudentsAttendenceStatisticsInMonth) studentAttendence.add(specificTeacherStudentsAttendenceStatisticsInMonth) studentAttendence.add(specificCourseStudentsAttendenceStatisticsInMonth) studentAttendence.add(specificStudentAttendenceInMonth) bar.add(studentAttendence) studentFee = JMenu("Student Fee ") payStudentFee = JMenuItem("Pay", actionPerformed=clickPayStudentFee) showStudentFeeListByCourse = JMenuItem( "Student Fee list By Course", actionPerformed=clickShowStudentFeeListByCourse) studentFee.add(payStudentFee) studentFee.add(showStudentFeeListByCourse) bar.add(studentFee) logout = JMenuItem("logout", actionPerformed=clickLogout) bar.add(logout) btnUpdate.setVisible(False) panel.add(table) panel.add(btnUpdate) frame.setJMenuBar(bar) frame.add(panel) frame.setVisible(True)
def run(self): frame = JFrame('consoleTimeout_02', layout=FlowLayout(), size=(180, 120), locationRelativeTo=None, defaultCloseOperation=JFrame.EXIT_ON_CLOSE) dep = AdminConfig.getid('/Deployment:isclite/') if dep: #------------------------------------------------------------------------- # To manipulate the AdminConsole app we need to locate the Application- # Deployment object associated with the app, and the ApplicationConfig # object associated with the app. If no ApplicationConfig object exists, # create one. #------------------------------------------------------------------------- appDep = AdminConfig.list('ApplicationDeployment', dep) appConfig = AdminConfig.list('ApplicationConfig', appDep) if not appConfig: appConfig = AdminConfig.create('ApplicationConfig', appDep, []) #------------------------------------------------------------------------- # Does a SessionManager exist? If not, create one #------------------------------------------------------------------------- self.sesMgmt = AdminConfig.list('SessionManager', appDep) if not self.sesMgmt: self.sesMgmt = AdminConfig.create('SessionManager', appConfig, []) #------------------------------------------------------------------------- # Get the tuningParams config ID, if one exists. #------------------------------------------------------------------------- self.tuningParms = AdminConfig.showAttribute( self.sesMgmt, 'tuningParams') if not self.tuningParms: timeout = '' messageText = "tuningParams object doesn't exist." else: timeout = AdminConfig.showAttribute(self.tuningParms, 'invalidationTimeout') messageText = '' #------------------------------------------------------------------------- # Add the components to the frame... #------------------------------------------------------------------------- frame.add(JLabel('Timeout:')) self.text = frame.add( JTextField(3, text=timeout, actionPerformed=self.update)) frame.add(JLabel('minutes')) self.message = frame.add(JLabel(messageText)) else: frame.add( JLabel( '<html>The AdminConsole application<br>' + \ 'is not available on the<br>' + \ 'specified profile.' ) ) frame.pack() frame.setVisible(1)
class BurpExtender(IBurpExtender, IBurpExtenderCallbacks, IIntruderPayloadProcessor, ITab, IExtensionStateListener): def registerExtenderCallbacks(self, callbacks): self._helpers = callbacks.getHelpers() callbacks.setExtensionName("JWT FuzzHelper") callbacks.registerIntruderPayloadProcessor(self) callbacks.registerExtensionStateListener(self) self._stdout = PrintWriter(callbacks.getStdout(), True) self._stderr = PrintWriter(callbacks.getStderr(), True) # Holds values passed by user from Configuration panel self._fuzzoptions = { "target": "Header", "selector": None, "signature": False, "algorithm": "HS256", "key": "" } self._isNone = lambda val: isinstance(val, type(None)) # Configuration panel Layout self._configurationPanel = JPanel() gridBagLayout = GridBagLayout() gridBagLayout.columnWidths = [0, 0, 0] gridBagLayout.rowHeights = [10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] gridBagLayout.columnWeights = [0.0, 0.0, 0.0] gridBagLayout.rowWeights = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] self._configurationPanel.setLayout(gridBagLayout) # Setup tabs self._tabs = JTabbedPane() self._tabs.addTab('Configuration', self._configurationPanel) #self._tabs.addTab('Help',self._helpPanel) # Target Options targetLabel = JLabel("Target Selection (Required): ") targetLabel.setFont(Font("Tahoma", Font.BOLD, 12)) c = GridBagConstraints() c.gridx = 0 c.gridy = 1 c.insets = Insets(0, 10, 0, 0) c.anchor = GridBagConstraints.LINE_END self._configurationPanel.add(targetLabel, c) options = ['Header', 'Payload'] self._targetComboBox = JComboBox(options) c = GridBagConstraints() c.gridx = 1 c.gridy = 1 c.anchor = GridBagConstraints.LINE_START self._configurationPanel.add(self._targetComboBox, c) # Help Button self._helpButton = JButton("Help", actionPerformed=self.helpMenu) c = GridBagConstraints() c.gridx = 2 c.gridy = 1 c.anchor = GridBagConstraints.FIRST_LINE_START self._configurationPanel.add(self._helpButton, c) # Selector Options self._selectorLabel = JLabel( "JSON Selector [Object Identifier-Index Syntax] (Required): ") self._selectorLabel.setFont(Font("Tahoma", Font.BOLD, 12)) c = GridBagConstraints() c.gridx = 0 c.gridy = 2 c.insets = Insets(0, 10, 0, 0) c.anchor = GridBagConstraints.LINE_END self._configurationPanel.add(self._selectorLabel, c) self._selectorTextField = JTextField('', 50) c = GridBagConstraints() c.gridx = 1 c.gridy = 2 self._configurationPanel.add(self._selectorTextField, c) # Regex option self._regexLabel = JLabel("Use regex as JSON Selector? (Optional): ") self._regexLabel.setFont(Font("Tahoma", Font.BOLD, 12)) c = GridBagConstraints() c.gridx = 0 c.gridy = 3 c.insets = Insets(0, 0, 0, 0) c.anchor = GridBagConstraints.LINE_END self._configurationPanel.add(self._regexLabel, c) self._regexCheckBox = JCheckBox("", actionPerformed=self.regexSelector) c = GridBagConstraints() c.gridx = 1 c.gridy = 3 c.anchor = GridBagConstraints.FIRST_LINE_START self._configurationPanel.add(self._regexCheckBox, c) # Signature Options generateSignatureLabel = JLabel("Generate signature? (Required): ") generateSignatureLabel.setFont(Font("Tahoma", Font.BOLD, 12)) c = GridBagConstraints() c.gridx = 0 c.gridy = 4 c.insets = Insets(0, 10, 0, 0) c.anchor = GridBagConstraints.LINE_END self._configurationPanel.add(generateSignatureLabel, c) options = ["False", "True"] self._generateSignatureComboBox = JComboBox(options) c = GridBagConstraints() c.gridx = 1 c.gridy = 4 c.anchor = GridBagConstraints.LINE_START self._configurationPanel.add(self._generateSignatureComboBox, c) signatureAlgorithmLabel = JLabel("Signature Algorithm (Optional): ") signatureAlgorithmLabel.setFont(Font("Tahoma", Font.BOLD, 12)) c = GridBagConstraints() c.gridx = 0 c.gridy = 5 c.insets = Insets(0, 10, 0, 0) c.anchor = GridBagConstraints.LINE_END self._configurationPanel.add(signatureAlgorithmLabel, c) options = [ "None", "HS256", "HS384", "HS512", "ES256", "ES384", "ES512", "RS256", "RS384", "RS512", "PS256", "PS256", "PS384", "PS512" ] self._algorithmSelectionComboBox = JComboBox(options) c = GridBagConstraints() c.gridx = 1 c.gridy = 5 c.anchor = GridBagConstraints.LINE_START self._configurationPanel.add(self._algorithmSelectionComboBox, c) # Signing key options self._signingKeyLabel = JLabel("Signing Key (Optional): ") self._signingKeyLabel.setFont(Font("Tahoma", Font.BOLD, 12)) c = GridBagConstraints() c.gridx = 0 c.gridy = 6 c.insets = Insets(0, 10, 0, 0) c.anchor = GridBagConstraints.LINE_END self._configurationPanel.add(self._signingKeyLabel, c) self.addSigningKeyTextArea() self._fromFileTextField = JTextField('', 50) fromFileLabel = JLabel("Signing key from file? (Optional): ") fromFileLabel.setFont(Font("Tahoma", Font.BOLD, 12)) c = GridBagConstraints() c.gridx = 0 c.gridy = 7 c.insets = Insets(0, 0, 0, 0) c.anchor = GridBagConstraints.LINE_END self._configurationPanel.add(fromFileLabel, c) self._fromFileCheckBox = JCheckBox("", actionPerformed=self.fromFile) c = GridBagConstraints() c.gridx = 1 c.gridy = 7 c.anchor = GridBagConstraints.FIRST_LINE_START self._configurationPanel.add(self._fromFileCheckBox, c) self._saveButton = JButton("Save Configuration", actionPerformed=self.saveOptions) self._saveButton.setText("Save Configuration") c = GridBagConstraints() c.gridx = 1 c.gridy = 8 c.anchor = GridBagConstraints.FIRST_LINE_START self._configurationPanel.add(self._saveButton, c) callbacks.customizeUiComponent(self._configurationPanel) callbacks.customizeUiComponent(self._tabs) callbacks.addSuiteTab(self) self._stdout.println("[JWT FuzzHelper] Loaded successfully") return def getProcessorName(self): return "JWT Fuzzer" def extensionUnloaded(self): del self._configurationPanel return # Intruder logic function def processPayload(self, currentPayload, originalPayload, baseValue): dataParameter = self._helpers.bytesToString( self._helpers.urlDecode(baseValue)) # utf-8 encode header, payload, signature = [ unicode(s).encode('utf-8') for s in dataParameter.split(".", 3) ] decoded_header = self._helpers.bytesToString( self._helpers.base64Decode(header + "=" * (-len(header) % 4))) decoded_payload = self._helpers.bytesToString( self._helpers.base64Decode(payload + "=" * (-len(payload) % 4))) # Decode header and payload, preserving order if they are JSON objects # Decode header try: header_dict = json.loads(decoded_header, object_pairs_hook=OrderedDict) except ValueError: raise RuntimeException( "[JWT FuzzHelper] Error: ValueError. Failed to decode header!") except Exception as e: self._stderr.println( "[ERROR] Encountered an unknown error when decoding header:\n{}\nCarrying on..." .format(e)) # Decode payload # Payload does not have to be a JSON object. # Ref: https://github.com/auth0/node-jsonwebtoken#usage payload_is_string = False try: payload_dict = json.loads(decoded_payload, object_pairs_hook=OrderedDict) except ValueError: payload_is_string = True payload_dict = decoded_payload except Exception as e: self._stderr.println( "[ERROR] Encountered an unknown error when decoding payload:\n{}\nCarrying on..." .format(e)) target = header_dict if self._fuzzoptions[ "target"] == "Header" else payload_dict selector = self._fuzzoptions["selector"] # If using Object Identifier-Index then retrieve the # value specified by the selector, # if this value does not exist, assume the user # wants to add the value that would have been specified # by the selector to the desired JWT segment (this behavior will # be noted in the help docs) intruderPayload = self._helpers.bytesToString(currentPayload) if not self._fuzzoptions["regex"]: if selector != [""]: try: value = self.getValue(target, selector) except Exception: target = self.buildDict(target, selector) if not self._isNone(selector) and selector != [""]: target = self.setValue(target, selector, intruderPayload) # Simple match-replace for regex if self._fuzzoptions["regex"]: target_string = target if payload_is_string else json.dumps(target) target_string = re.sub(selector, intruderPayload, target_string) target = target_string if payload_is_string else json.loads( target_string, object_pairs_hook=OrderedDict) if self._fuzzoptions["target"] == "Payload": payload_dict = target else: header_dict = target algorithm = self._fuzzoptions["algorithm"] if self._fuzzoptions["signature"]: # pyjwt requires lowercase 'none'. If user wants to try # "none", "NonE", "nOnE", etc... they should use .alg # as selector, delete sig from intruder and use those # permutations as their fuzz list (outlined in help docs) # and keep "Generate Signature" as False algorithm = "none" if algorithm.lower() == "none" else algorithm header_dict["alg"] = algorithm header = json.dumps(header_dict, separators=(",", ":")) payload = payload_dict if payload_is_string else json.dumps( payload_dict, separators=(",", ":")) header = self._helpers.base64Encode(header).strip("=") payload = self._helpers.base64Encode(payload).strip("=") contents = header + "." + payload key = self._fuzzoptions["key"] if self._fuzzoptions["signature"]: # pyjwt throws error when using a public key in symmetric alg (for good reason of course), # must do natively to support algorithmic sub attacks if algorithm.startswith("HS"): if algorithm == "HS256": hmac_algorithm = hashlib.sha256 elif algorithm == "HS384": hmac_algorithm = hashlib.sha384 else: hmac_algorithm = hashlib.sha512 signature = self._helpers.base64Encode( hmac.new(key, contents, hmac_algorithm).digest()).strip("=") modified_jwt = contents + "." + signature # JWT can't sign non-JSON payloads. WTF. This block is for non-JSON payloads. elif algorithm.startswith("RS") and payload_is_string: if algorithm == "RS256": rsa_algorithm = "SHA-256" elif algorithm == "RS384": rsa_algorithm = "SHA-384" else: rsa_algorithm = "SHA-512" privkey = rsa.PrivateKey.load_pkcs1(key) signature = rsa.sign(contents, privkey, rsa_algorithm) signature = base64.b64encode(signature).encode( 'utf-8').replace("=", "") modified_jwt = contents + "." + signature else: # Use pyjwt when using asymmetric alg if algorithm == "none": key = "" modified_jwt = jwt.encode(payload_dict, key, algorithm=algorithm, headers=header_dict) else: modified_jwt = contents + "." + signature return self._helpers.stringToBytes(modified_jwt) #----------------------- # getValue: # @return: A value at arbitrary depth in dictionary # @throws: TypeError #----------------------- def getValue(self, dictionary, values): return reduce(dict.__getitem__, values, dictionary) #----------------------- # buildDict: # @note: Will build dictionary of arbitrary depth #----------------------- def buildDict(self, dictionary, keys): if self._isNone(keys): return dictionary root = current = dictionary for key in keys: if key not in current: current[key] = {} current = current[key] return root #---------------------- # setValue: # @note: Will set key of arbitrary depth #----------------------- def setValue(self, dictionary, keys, value): root = current = dictionary for i, key in enumerate(keys): if i == len(keys) - 1: current[key] = value break if key in current: current = current[key] else: # Should never happen current = self.buildDict(current, keys) return root #----------------------- # addSigningKeyTextArea: # @note: Will toggle if fromFile selected. Be DRY. #---------------------- def addSigningKeyTextArea(self): self._signingKeyTextArea = JTextArea() self._signingKeyTextArea.setColumns(50) self._signingKeyTextArea.setRows(10) self._signingKeyScrollPane = JScrollPane(self._signingKeyTextArea) c = GridBagConstraints() c.gridx = 1 c.gridy = 6 c.anchor = GridBagConstraints.LINE_START self._configurationPanel.add(self._signingKeyScrollPane, c) def addSigningKeyFromFileTextField(self): c = GridBagConstraints() c.gridx = 1 c.gridy = 6 self._configurationPanel.add(self._fromFileTextField, c) #----------------------- # End Helpers #----------------------- #----------------------- # Implement ITab #----------------------- def getTabCaption(self): return "JWT FuzzHelper" def getUiComponent(self): return self._tabs #--------------------------- # Save configuration options #--------------------------- def saveOptions(self, event): self._fuzzoptions["target"] = self._targetComboBox.getSelectedItem() self._fuzzoptions["selector"] = self._selectorTextField.getText() self._fuzzoptions[ "signature"] = True if self._generateSignatureComboBox.getSelectedItem( ) == "True" else False self._fuzzoptions[ "algorithm"] = self._algorithmSelectionComboBox.getSelectedItem() if self._fromFileCheckBox.isSelected(): filename = self._fromFileTextField.getText() if os.path.isdir(filename): self._stderr.println("{} is a directory".format(filename)) return if os.path.exists(filename): with open(filename, 'rb') as f: self._fuzzoptions["key"] = f.read() else: self._fuzzoptions["key"] = unicode( self._signingKeyTextArea.getText()).encode("utf-8") # RSA keys need to end with a line break. Many headaches because of this. if not self._fuzzoptions["key"].endswith( "\n") and self._fuzzoptions["algorithm"].startswith("RS"): self._fuzzoptions["key"] += "\n" self._stdout.println("[JWT FuzzHelper] Saved options:\n{}".format( self._fuzzoptions)) # Sanity check selector if it's not a regular expression self._fuzzoptions["regex"] = self._regexCheckBox.isSelected() if not self._regexCheckBox.isSelected(): m = re.search("(\.\w+)+", self._fuzzoptions["selector"]) if self._fuzzoptions["selector"] != "." and ( isinstance(m, type(None)) or m.group(0) != self._fuzzoptions["selector"]): self._saveButton.setText("Invalid JSON Selector!") else: self._fuzzoptions["selector"] = self._fuzzoptions[ "selector"].split(".")[1:] self._saveButton.setText("Saved!") # Sanity check the regular expression else: try: re.compile(self._fuzzoptions["selector"]) self._saveButton.setText("Saved!") except re.error: self._saveButton.setText("Invalid Regex!") return #------------------------- # From file options #------------------------ def fromFile(self, event): if self._fromFileCheckBox.isSelected(): self._signingKeyLabel.setText("Path to Signing Key (Optional): ") self._configurationPanel.remove(self._signingKeyScrollPane) self.addSigningKeyFromFileTextField() else: self._signingKeyLabel.setText("Signing Key (Optional): ") self._configurationPanel.remove(self._fromFileTextField) self.addSigningKeyTextArea() self._configurationPanel.repaint() return def regexSelector(self, event): if self._regexCheckBox.isSelected(): self._selectorLabel.setText("Selector [Regex] (Required): ") else: self._selectorLabel.setText( "JSON Selector [Object Identifier-Index Syntax] (Required): ") self._configurationPanel.repaint() return #------------------------- # Help popup #------------------------- def helpMenu(self, event): self._helpPopup = JFrame('JWT Fuzzer', size=(550, 450)) self._helpPopup.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) helpPanel = JPanel() helpPanel.setPreferredSize(Dimension(550, 450)) helpPanel.setBorder(EmptyBorder(10, 10, 10, 10)) helpPanel.setLayout(BoxLayout(helpPanel, BoxLayout.Y_AXIS)) self._helpPopup.setContentPane(helpPanel) helpHeadingText = JLabel("<html><h2>JWT Fuzzer</h2></html>") authorText = JLabel("<html><p>@author: <pinnace></p></html>") aboutText = JLabel( "<html><br /> <p>This extension adds an Intruder payload processor for JWTs.</p><br /></html>" ) repositoryText = JLabel("<html>Documentation and source code:</html>") repositoryLink = JLabel( "<html>- <a href=\"https://github.com/pinnace/burp-jwt-fuzzhelper-extension\">https://github.com/pinnace/burp-jwt-fuzzhelper-extension</a></html>" ) licenseText = JLabel( "<html><br/><p>JWT Fuzzer uses a GPL 3 license. This license does not apply to the dependency below:<p></html>" ) dependencyLink = JLabel( "<html>- <a href=\"https://github.com/jpadilla/pyjwt/blob/master/LICENSE\">pyjwt</a></html>" ) dependencyLink.addMouseListener(ClickListener()) dependencyLink.setCursor(Cursor.getPredefinedCursor( Cursor.HAND_CURSOR)) repositoryLink.addMouseListener(ClickListener()) repositoryLink.setCursor(Cursor.getPredefinedCursor( Cursor.HAND_CURSOR)) helpPanel.add(helpHeadingText) helpPanel.add(authorText) helpPanel.add(aboutText) helpPanel.add(repositoryText) helpPanel.add(repositoryLink) helpPanel.add(licenseText) helpPanel.add(dependencyLink) self._helpPopup.setSize(Dimension(550, 450)) self._helpPopup.pack() self._helpPopup.setLocationRelativeTo(None) self._helpPopup.setVisible(True) return
def __init__(self, app): from java.awt import Dialog from java.awt import CardLayout JDialog.__init__(self, app.preferencesFrame, app.strings.getString("Create_a_new_favourite_zone"), Dialog.ModalityType.DOCUMENT_MODAL) self.app = app border = BorderFactory.createEmptyBorder(5, 7, 7, 7) self.getContentPane().setBorder(border) self.setLayout(BoxLayout(self.getContentPane(), BoxLayout.Y_AXIS)) self.FAVAREALAYERNAME = "Favourite zone editing" info = JLabel(self.app.strings.getString("Create_a_new_favourite_zone")) info.setAlignmentX(Component.LEFT_ALIGNMENT) #Name nameLbl = JLabel(self.app.strings.getString("fav_zone_name")) self.nameTextField = JTextField(20) self.nameTextField.setMaximumSize(self.nameTextField.getPreferredSize()) self.nameTextField.setToolTipText(self.app.strings.getString("fav_zone_name_tooltip")) namePanel = JPanel() namePanel.setLayout(BoxLayout(namePanel, BoxLayout.X_AXIS)) namePanel.add(nameLbl) namePanel.add(Box.createHorizontalGlue()) namePanel.add(self.nameTextField) #Country countryLbl = JLabel(self.app.strings.getString("fav_zone_country")) self.countryTextField = JTextField(20) self.countryTextField.setMaximumSize(self.countryTextField.getPreferredSize()) self.countryTextField.setToolTipText(self.app.strings.getString("fav_zone_country_tooltip")) countryPanel = JPanel() countryPanel.setLayout(BoxLayout(countryPanel, BoxLayout.X_AXIS)) countryPanel.add(countryLbl) countryPanel.add(Box.createHorizontalGlue()) countryPanel.add(self.countryTextField) #Type modeLbl = JLabel(self.app.strings.getString("fav_zone_type")) RECTPANEL = "rectangle" POLYGONPANEL = "polygon" BOUNDARYPANEL = "boundary" self.modesStrings = [RECTPANEL, POLYGONPANEL, BOUNDARYPANEL] modesComboModel = DefaultComboBoxModel() for i in (self.app.strings.getString("rectangle"), self.app.strings.getString("delimited_by_a_closed_way"), self.app.strings.getString("delimited_by_an_administrative_boundary")): modesComboModel.addElement(i) self.modesComboBox = JComboBox(modesComboModel, actionListener=self, editable=False) #- Rectangle self.rectPanel = JPanel() self.rectPanel.setLayout(BoxLayout(self.rectPanel, BoxLayout.Y_AXIS)) capturePane = JPanel() capturePane.setLayout(BoxLayout(capturePane, BoxLayout.X_AXIS)) capturePane.setAlignmentX(Component.LEFT_ALIGNMENT) josmP = JPanel() self.captureRBtn = JRadioButton(self.app.strings.getString("capture_area")) self.captureRBtn.addActionListener(self) self.captureRBtn.setSelected(True) self.bboxFromJosmBtn = JButton(self.app.strings.getString("get_current_area"), actionPerformed=self.on_bboxFromJosmBtn_clicked) self.bboxFromJosmBtn.setToolTipText(self.app.strings.getString("get_capture_area_tooltip")) josmP.add(self.bboxFromJosmBtn) capturePane.add(self.captureRBtn) capturePane.add(Box.createHorizontalGlue()) capturePane.add(self.bboxFromJosmBtn) manualPane = JPanel() manualPane.setLayout(BoxLayout(manualPane, BoxLayout.X_AXIS)) manualPane.setAlignmentX(Component.LEFT_ALIGNMENT) self.manualRBtn = JRadioButton(self.app.strings.getString("use_this_bbox")) self.manualRBtn.addActionListener(self) self.bboxTextField = JTextField(20) self.bboxTextField.setMaximumSize(self.bboxTextField.getPreferredSize()) self.bboxTextField.setToolTipText(self.app.strings.getString("fav_bbox_tooltip")) self.bboxTextFieldDefaultBorder = self.bboxTextField.getBorder() self.bboxTextField.getDocument().addDocumentListener(TextListener(self)) manualPane.add(self.manualRBtn) manualPane.add(Box.createHorizontalGlue()) manualPane.add(self.bboxTextField) group = ButtonGroup() group.add(self.captureRBtn) group.add(self.manualRBtn) previewPane = JPanel() previewPane.setLayout(BoxLayout(previewPane, BoxLayout.X_AXIS)) previewPane.setAlignmentX(Component.LEFT_ALIGNMENT) bboxPreviewInfo = JTextField(self.app.strings.getString("coordinates"), editable=0, border=None) bboxPreviewInfo.setMaximumSize(bboxPreviewInfo.getPreferredSize()) self.bboxPreviewTextField = JTextField(20, editable=0, border=None) self.bboxPreviewTextField.setMaximumSize(self.bboxPreviewTextField.getPreferredSize()) previewPane.add(bboxPreviewInfo) previewPane.add(Box.createHorizontalGlue()) previewPane.add(self.bboxPreviewTextField) self.rectPanel.add(capturePane) self.rectPanel.add(Box.createRigidArea(Dimension(0, 10))) self.rectPanel.add(manualPane) self.rectPanel.add(Box.createRigidArea(Dimension(0, 20))) self.rectPanel.add(previewPane) #- Polygon (closed way) drawn by hand self.polygonPanel = JPanel(BorderLayout()) self.polygonPanel.setLayout(BoxLayout(self.polygonPanel, BoxLayout.Y_AXIS)) polyInfo = JLabel("<html>%s</html>" % self.app.strings.getString("polygon_info")) polyInfo.setFont(polyInfo.getFont().deriveFont(Font.ITALIC)) polyInfo.setAlignmentX(Component.LEFT_ALIGNMENT) editPolyPane = JPanel() editPolyPane.setAlignmentX(Component.LEFT_ALIGNMENT) editPolyBtn = JButton(self.app.strings.getString("create_fav_layer"), actionPerformed=self.create_new_zone_editing_layer) editPolyBtn.setToolTipText(self.app.strings.getString("create_fav_layer_tooltip")) editPolyPane.add(editPolyBtn) self.polygonPanel.add(polyInfo) self.polygonPanel.add(Box.createRigidArea(Dimension(0, 15))) self.polygonPanel.add(editPolyPane) self.polygonPanel.add(Box.createRigidArea(Dimension(0, 15))) #- Administrative Boundary self.boundaryPanel = JPanel() self.boundaryPanel.setLayout(BoxLayout(self.boundaryPanel, BoxLayout.Y_AXIS)) boundaryInfo = JLabel("<html>%s</html>" % app.strings.getString("boundary_info")) boundaryInfo.setFont(boundaryInfo.getFont().deriveFont(Font.ITALIC)) boundaryInfo.setAlignmentX(Component.LEFT_ALIGNMENT) boundaryTagsPanel = JPanel(GridLayout(3, 3, 5, 5)) boundaryTagsPanel.setAlignmentX(Component.LEFT_ALIGNMENT) boundaryTagsPanel.add(JLabel("name =")) self.nameTagTextField = JTextField(20) boundaryTagsPanel.add(self.nameTagTextField) boundaryTagsPanel.add(UrlLabel("http://wiki.openstreetmap.org/wiki/Key:admin_level#admin_level", "admin_level =")) self.adminLevelTagTextField = JTextField(20) self.adminLevelTagTextField.setToolTipText(self.app.strings.getString("adminLevel_tooltip")) boundaryTagsPanel.add(self.adminLevelTagTextField) boundaryTagsPanel.add(JLabel(self.app.strings.getString("other_tag"))) self.optionalTagTextField = JTextField(20) self.optionalTagTextField.setToolTipText("key=value") boundaryTagsPanel.add(self.optionalTagTextField) downloadBoundariesPane = JPanel() downloadBoundariesPane.setAlignmentX(Component.LEFT_ALIGNMENT) downloadBoundariesBtn = JButton(self.app.strings.getString("download_boundary"), actionPerformed=self.on_downloadBoundariesBtn_clicked) downloadBoundariesBtn.setToolTipText(self.app.strings.getString("download_boundary_tooltip")) downloadBoundariesPane.add(downloadBoundariesBtn) self.boundaryPanel.add(boundaryInfo) self.boundaryPanel.add(Box.createRigidArea(Dimension(0, 15))) self.boundaryPanel.add(boundaryTagsPanel) self.boundaryPanel.add(Box.createRigidArea(Dimension(0, 10))) self.boundaryPanel.add(downloadBoundariesPane) self.editingPanels = {"rectangle": self.rectPanel, "polygon": self.polygonPanel, "boundary": self.boundaryPanel} #Main buttons self.okBtn = JButton(self.app.strings.getString("OK"), ImageProvider.get("ok"), actionPerformed=self.on_okBtn_clicked) self.cancelBtn = JButton(self.app.strings.getString("cancel"), ImageProvider.get("cancel"), actionPerformed=self.close_dialog) self.previewBtn = JButton(self.app.strings.getString("Preview_zone"), actionPerformed=self.on_previewBtn_clicked) self.previewBtn.setToolTipText(self.app.strings.getString("preview_zone_tooltip")) okBtnSize = self.okBtn.getPreferredSize() viewBtnSize = self.previewBtn.getPreferredSize() viewBtnSize.height = okBtnSize.height self.previewBtn.setPreferredSize(viewBtnSize) #layout self.add(info) self.add(Box.createRigidArea(Dimension(0, 15))) namePanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(namePanel) self.add(Box.createRigidArea(Dimension(0, 15))) countryPanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(countryPanel) self.add(Box.createRigidArea(Dimension(0, 15))) modeLbl.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(modeLbl) self.add(Box.createRigidArea(Dimension(0, 5))) self.add(self.modesComboBox) self.modesComboBox.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(Box.createRigidArea(Dimension(0, 15))) self.configPanel = JPanel(CardLayout()) self.configPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)) self.configPanel.add(self.rectPanel, RECTPANEL) self.configPanel.add(self.polygonPanel, POLYGONPANEL) self.configPanel.add(self.boundaryPanel, BOUNDARYPANEL) self.configPanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(self.configPanel) buttonsPanel = JPanel() buttonsPanel.add(self.okBtn) buttonsPanel.add(self.cancelBtn) buttonsPanel.add(self.previewBtn) buttonsPanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(buttonsPanel) self.addWindowListener(self) self.pack()
def helpMenu(self, event): self._helpPopup = JFrame('JWT Fuzzer', size=(550, 450)) self._helpPopup.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) helpPanel = JPanel() helpPanel.setPreferredSize(Dimension(550, 450)) helpPanel.setBorder(EmptyBorder(10, 10, 10, 10)) helpPanel.setLayout(BoxLayout(helpPanel, BoxLayout.Y_AXIS)) self._helpPopup.setContentPane(helpPanel) helpHeadingText = JLabel("<html><h2>JWT Fuzzer</h2></html>") authorText = JLabel("<html><p>@author: <pinnace></p></html>") aboutText = JLabel( "<html><br /> <p>This extension adds an Intruder payload processor for JWTs.</p><br /></html>" ) repositoryText = JLabel("<html>Documentation and source code:</html>") repositoryLink = JLabel( "<html>- <a href=\"https://github.com/pinnace/burp-jwt-fuzzhelper-extension\">https://github.com/pinnace/burp-jwt-fuzzhelper-extension</a></html>" ) licenseText = JLabel( "<html><br/><p>JWT Fuzzer uses a GPL 3 license. This license does not apply to the dependency below:<p></html>" ) dependencyLink = JLabel( "<html>- <a href=\"https://github.com/jpadilla/pyjwt/blob/master/LICENSE\">pyjwt</a></html>" ) dependencyLink.addMouseListener(ClickListener()) dependencyLink.setCursor(Cursor.getPredefinedCursor( Cursor.HAND_CURSOR)) repositoryLink.addMouseListener(ClickListener()) repositoryLink.setCursor(Cursor.getPredefinedCursor( Cursor.HAND_CURSOR)) helpPanel.add(helpHeadingText) helpPanel.add(authorText) helpPanel.add(aboutText) helpPanel.add(repositoryText) helpPanel.add(repositoryLink) helpPanel.add(licenseText) helpPanel.add(dependencyLink) self._helpPopup.setSize(Dimension(550, 450)) self._helpPopup.pack() self._helpPopup.setLocationRelativeTo(None) self._helpPopup.setVisible(True) return
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, ITab, IHttpListener, IMessageEditorTabFactory): def registerExtenderCallbacks(self, callbacks): self._callbacks = callbacks self._helpers = callbacks.getHelpers() callbacks.setExtensionName("HaE(Highlighter and Extractor)") self._stdout = PrintWriter(callbacks.getStdout(), True) callbacks.registerHttpListener(self) callbacks.registerMessageEditorTabFactory(self) print 'HaE(Highlighter and Extractor)\nAuthor: Vulkey_Chen\nBlog: gh0st.cn\nTeam: MSTSEC' self._callbacks.customizeUiComponent(self.getUiComponent()) self._callbacks.addSuiteTab(self) self.endColors = [] def getTabCaption(self): return 'HaE' def createNewInstance(self, controller, editable): return MarkINFOTab(self, controller, editable) def processHttpMessage(self, toolFlag, messageIsRequest, messageInfo): if messageIsRequest: return content = messageInfo.getResponse() r = self._helpers.analyzeResponse(content) msg = content[r.getBodyOffset():].tostring() # msg 为响应正文信息 info = getConfig() results = findContent(info, msg) colorList = [] if results != {}: for i in results: if info[i]['highlight'] == 1: if info[i]['color'] == 'red': messageInfo.setHighlight(info[i]['color']) break else: colorList.append(info[i]['color']) if not messageInfo.getHighlight(): colorsList = [colors.index(i) for i in colorList] colorsList.sort() # print(colorsList) self.helper(colorsList) endColor = [colors.index(x) for x in self.endColors] # print(endColor) messageInfo.setHighlight(colors[min(endColor)]) # 颜色升级 def helper(self, mylist): l = len(mylist) i = 0 stack = [] while i < l: if not stack: stack.append(mylist[i]) i += 1 else: if mylist[i] != stack[-1]: stack.append(mylist[i]) i += 1 else: stack[-1] -= 1 i += 1 if len(stack) == len(set(stack)): self.endColors = [colors[i] for i in stack] else: self.helper(stack) def addConfig(self, event): nameText = self.nameTextField.getText() regexText = self.regexTextField.getText() colorText = self.colorTextField.getText() isHighlight = int(self.highlightCheckBox.isSelected()) isExtract = int(self.extractCheckBox.isSelected()) if colorText in colors: with open(configFile, 'r+') as content: dicts = json.load(content) # 解决r+写入问题 content.seek(0, 0) content.truncate() if nameText in dicts: self.tipString.setText("Name is existed!") elif not (isHighlight or isExtract): self.tipString.setText("Highlight or Extract?") else: dicts[nameText] = { "regex": regexText, "highlight": isHighlight, "extract": isExtract, "color": colorText } content.write(jsbeautifier.beautify(json.dumps(dicts))) #print(dicts) self.tipString.setText("Save Successfully!") else: self.tipString.setText("Not in colors list.") def reloadConfig(self, event): with open(configFile, 'r') as content: self.configTextArea.setText(content.read()) def getUiComponent(self): self.HaEPanel = JPanel() self.HaEPanel.setBorder(None) self.HaEPanel.setLayout(BorderLayout(0, 0)) self.panel = JPanel() self.HaEPanel.add(self.panel, BorderLayout.NORTH) self.panel.setLayout(BorderLayout(0, 0)) self.tabbedPane = JTabbedPane(JTabbedPane.TOP) self.panel.add(self.tabbedPane, BorderLayout.CENTER) self.setPanel = JPanel() self.tabbedPane.addTab("Set", None, self.setPanel, None) self.setPanel.setLayout(BorderLayout(0, 0)) self.setPanel_1 = JPanel() self.setPanel.add(self.setPanel_1, BorderLayout.NORTH) self.nameString = JLabel("Name") self.setPanel_1.add(self.nameString) self.nameTextField = JTextField() self.setPanel_1.add(self.nameTextField) self.nameTextField.setColumns(10) self.regexString = JLabel("Regex") self.setPanel_1.add(self.regexString) self.regexTextField = JTextField() self.setPanel_1.add(self.regexTextField) self.regexTextField.setColumns(10) self.extractCheckBox = JCheckBox("Extract") self.setPanel_1.add(self.extractCheckBox) self.highlightCheckBox = JCheckBox("Highlight") self.setPanel_1.add(self.highlightCheckBox) self.setPanel_2 = JPanel() self.setPanel.add(self.setPanel_2) self.colorString = JLabel("Color") self.setPanel_2.add(self.colorString) self.colorTextField = JTextField() self.setPanel_2.add(self.colorTextField) self.colorTextField.setColumns(5) self.addBottun = JButton("Add", actionPerformed=self.addConfig) self.setPanel_2.add(self.addBottun) self.tipString = JLabel("") self.setPanel_2.add(self.tipString) self.configPanel = JPanel() self.tabbedPane.addTab("Config", None, self.configPanel, None) self.configPanel.setLayout(BorderLayout(0, 0)) self.configString = JLabel("This is config file content.") self.configString.setHorizontalAlignment(SwingConstants.CENTER) self.configPanel.add(self.configString, BorderLayout.NORTH) self.configTextArea = JTextArea() self.configTextArea.setEnabled(False) self.configTextArea.setTabSize(4) self.configTextArea.setLineWrap(True) self.configTextArea.setRows(20) self.configPanel.add(self.configTextArea, BorderLayout.SOUTH) self.scrollPane = JScrollPane(self.configTextArea) self.configPanel.add(self.scrollPane, BorderLayout.SOUTH) self.reloadButton = JButton("Reload", actionPerformed=self.reloadConfig) self.configPanel.add(self.reloadButton, BorderLayout.CENTER) return self.HaEPanel
def drawPluginUI(self): # Create the plugin user interface self.pluginTab = JPanel() self.uiTitle = JLabel('UPnP BHunter Load, Aim and Fire Console') self.uiTitle.setFont(Font('Tahoma', Font.BOLD, 14)) self.uiTitle.setForeground(Color(250, 100, 0)) self.uiPanelA = JSplitPane(JSplitPane.VERTICAL_SPLIT) self.uiPanelA.setMaximumSize(Dimension(2500, 1000)) self.uiPanelA.setDividerSize(2) self.uiPanelB = JSplitPane(JSplitPane.VERTICAL_SPLIT) self.uiPanelB.setDividerSize(2) self.uiPanelA.setBottomComponent(self.uiPanelB) self.uiPanelA.setBorder(BorderFactory.createLineBorder(Color.gray)) # Create and configure labels and text fields self.labeltitle_step1 = JLabel("[1st STEP] Discover UPnP Locations") self.labeltitle_step1.setFont(Font('Tahoma', Font.BOLD, 14)) self.labeltitle_step2 = JLabel( "[2nd STEP] Select a UPnP Service and Action") self.labeltitle_step2.setFont(Font('Tahoma', Font.BOLD, 14)) self.labeltitle_step3 = JLabel("[3rd STEP] Time to Attack it") self.labeltitle_step3.setFont(Font('Tahoma', Font.BOLD, 14)) self.labelsubtitle_step1 = JLabel( "Specify the IP version address in scope and start UPnP discovery") self.labelsubtitle_step2 = JLabel( "Select which of the found UPnP services will be probed") self.labelsubtitle_step3 = JLabel( "Review and modify the request, then send it to one of the attack tools" ) self.label_step1 = JLabel("Target IP") self.label_step2 = JLabel("Found UPnp Services") self.labelstatus = JLabel(" Status") self.labelempty_step1 = JLabel(" ") self.labelempty_step2 = JLabel(" ") self.labelupnp = JLabel("UPnP list") self.labelip = JLabel("IP list") self.labelactions = JLabel("Actions") self.labelNoneServiceFound = JLabel(" ") self.labelNoneServiceFound.setFont(Font('Tahoma', Font.BOLD, 12)) self.labelNoneServiceFound.setForeground(Color.red) # Create combobox for IP version selection self.ip_versions = ["IPv4", "IPv6"] self.combo_ipversion = JComboBox(self.ip_versions) self.combo_ipversion.setSelectedIndex(0) self.combo_ipversion.setEnabled(True) # Create and configure progress bar self.progressbar = JProgressBar(0, 100) self.progressbar.setString("Ready") self.progressbar.setStringPainted(True) # Create and configure buttons self.startbutton = JButton("Start Discovery", actionPerformed=self.startHunting) self.clearbutton = JButton("Clear All", actionPerformed=self.clearAll) self.intruderbutton = JButton("Send to Intruder", actionPerformed=self.sendToIntruder) self.repeaterbutton = JButton("Send to Repeater", actionPerformed=self.sendToRepeater) #self.WANrepeaterbutton = JButton("to Repeater", actionPerformed=self.sendWANUPnPToRepeater) self.textarea_request = JTextArea(18, 90) self.intruderbutton.setEnabled(False) self.repeaterbutton.setEnabled(False) # Class neeeded to handle the target combobox in second step panel class TargetComboboxListener(ActionListener): def __init__(self, upnpcombo_targets, upnpcombo_services, ip_service_dict): self.upnpcombo_targets = upnpcombo_targets self.upnpcombo_services = upnpcombo_services self.ip_service_dict = ip_service_dict def actionPerformed(self, event): try: # Update the location url combobox depending on the IP combobox selected_target = self.upnpcombo_targets.getSelectedItem() if self.ip_service_dict and selected_target: self.upnpcombo_services.removeAllItems() for service_url in self.ip_service_dict[ selected_target]: self.upnpcombo_services.addItem(service_url) self.upnpcombo_services.setSelectedIndex(0) except BaseException as e: print("[!] Exception selecting service: \"%s\" ") % e # Class neeeded to handle the service combobox in second step panel class ServiceComboboxListener(ActionListener): def __init__(self, upnpcombo_services, upnpcombo_actions, services_dict): self.upnpcombo_services = upnpcombo_services self.upnpcombo_actions = upnpcombo_actions self.services = services_dict def actionPerformed(self, event): try: # Update the location url combobox depending on the IP combobox selected_service = self.upnpcombo_services.getSelectedItem( ) if self.services and selected_service: self.upnpcombo_actions.removeAllItems() actions = self.services[selected_service] for action in actions: self.upnpcombo_actions.addItem(action) self.upnpcombo_actions.setSelectedIndex(0) except BaseException as e: print("[!] Exception selecting service: \"%s\" ") % e # Class neeeded to handle the action combobox in second step panel class ActionComboboxListener(ActionListener): def __init__(self, upnpcombo_services, upnpcombo_actions, textarea_request, services_dict): self.upnpcombo_services = upnpcombo_services self.upnpcombo_actions = upnpcombo_actions self.textarea_request = textarea_request self.services = services_dict def actionPerformed(self, event): try: # Update the location url combobox depending on the IP combobox selected_action = self.upnpcombo_actions.getSelectedItem() selected_service = self.upnpcombo_services.getSelectedItem( ) if self.services and selected_action: self.textarea_request.setText( self.services[selected_service][selected_action]) except BaseException as e: print("[!] Exception selecting action: \"%s\" ") % e self.upnpactions = [" "] self.upnpcombo_actions = JComboBox(self.upnpactions) self.upnpcombo_actions.setSelectedIndex(0) self.upnpcombo_actions.setEnabled(False) # Create the combo box, select item at index 0 (first item in list) self.upnpservices = [" "] self.upnpcombo_services = JComboBox(self.upnpservices) self.upnpcombo_services.setSelectedIndex(0) self.upnpcombo_services.setEnabled(False) # Create the combo box, select item at index 0 (first item in list) self.upnptargets = [" "] self.upnpcombo_targets = JComboBox(self.upnptargets) self.upnpcombo_targets.setSelectedIndex(0) self.upnpcombo_targets.setEnabled(False) # Set the action listeners for all the comboboxes self.upnpcombo_targets.addActionListener( TargetComboboxListener(self.upnpcombo_targets, self.upnpcombo_services, self.ip_service_dict)) self.upnpcombo_services.addActionListener( ServiceComboboxListener(self.upnpcombo_services, self.upnpcombo_actions, self.services_dict)) self.upnpcombo_actions.addActionListener( ActionComboboxListener(self.upnpcombo_services, self.upnpcombo_actions, self.textarea_request, self.services_dict)) # Configuring first step panel self.panel_step1 = JPanel() self.panel_step1.setPreferredSize(Dimension(2250, 100)) self.panel_step1.setBorder(EmptyBorder(10, 10, 10, 10)) self.panel_step1.setLayout(BorderLayout(15, 15)) self.titlepanel_step1 = JPanel() self.titlepanel_step1.setLayout(BorderLayout()) self.titlepanel_step1.add(self.labeltitle_step1, BorderLayout.NORTH) self.titlepanel_step1.add(self.labelsubtitle_step1) self.targetpanel_step1 = JPanel() self.targetpanel_step1.add(self.label_step1) self.targetpanel_step1.add(self.combo_ipversion) self.targetpanel_step1.add(self.startbutton) self.targetpanel_step1.add(self.clearbutton) self.targetpanel_step1.add(self.labelstatus) self.targetpanel_step1.add(self.progressbar) self.emptypanel_step1 = JPanel() self.emptypanel_step1.setLayout(BorderLayout()) self.emptypanel_step1.add(self.labelempty_step1, BorderLayout.WEST) # Assembling first step panel components self.panel_step1.add(self.titlepanel_step1, BorderLayout.NORTH) self.panel_step1.add(self.targetpanel_step1, BorderLayout.WEST) self.panel_step1.add(self.emptypanel_step1, BorderLayout.SOUTH) self.uiPanelA.setTopComponent(self.panel_step1) # Configure second step panel self.panel_step2 = JPanel() self.panel_step2.setPreferredSize(Dimension(2250, 100)) self.panel_step2.setBorder(EmptyBorder(10, 10, 10, 10)) self.panel_step2.setLayout(BorderLayout(15, 15)) self.titlepanel_step2 = JPanel() self.titlepanel_step2.setLayout(BorderLayout()) self.titlepanel_step2.add(self.labeltitle_step2, BorderLayout.NORTH) self.titlepanel_step2.add(self.labelsubtitle_step2) self.selectpanel_step2 = JPanel() self.selectpanel_step2.add(self.labelip) self.selectpanel_step2.add(self.upnpcombo_targets) self.selectpanel_step2.add(self.labelupnp) self.selectpanel_step2.add(self.upnpcombo_services) self.selectpanel_step2.add(self.labelactions) self.selectpanel_step2.add(self.upnpcombo_actions) self.emptypanel_step2 = JPanel() self.emptypanel_step2.setLayout(BorderLayout()) self.emptypanel_step2.add(self.labelempty_step2, BorderLayout.WEST) self.emptypanel_step2.add(self.labelNoneServiceFound) # Assembling second step panel components self.panel_step2.add(self.titlepanel_step2, BorderLayout.NORTH) self.panel_step2.add(self.selectpanel_step2, BorderLayout.WEST) self.panel_step2.add(self.emptypanel_step2, BorderLayout.SOUTH) self.uiPanelB.setTopComponent(self.panel_step2) # Configuring third step panel self.panel_step3 = JPanel() self.panel_step3.setPreferredSize(Dimension(2250, 100)) self.panel_step3.setBorder(EmptyBorder(10, 10, 10, 10)) self.panel_step3.setLayout(BorderLayout(15, 15)) self.titlepanel_step3 = JPanel() self.titlepanel_step3.setLayout(BorderLayout()) self.titlepanel_step3.add(self.labeltitle_step3, BorderLayout.NORTH) self.titlepanel_step3.add(self.labelsubtitle_step3) self.underpanel_step3 = JPanel() self.underpanel_step3.setLayout(BorderLayout()) self.underpanel_step3.add((JScrollPane(self.textarea_request)), BorderLayout.NORTH) self.actionpanel_step3 = JPanel() self.actionpanel_step3.add(self.intruderbutton) self.actionpanel_step3.add(self.repeaterbutton) self.extrapanel_step3 = JPanel() self.extrapanel_step3.setLayout(BorderLayout()) self.extrapanel_step3.add(self.actionpanel_step3, BorderLayout.WEST) # Assembling thirdd step panel components self.panel_step3.add(self.titlepanel_step3, BorderLayout.NORTH) self.panel_step3.add(self.underpanel_step3, BorderLayout.WEST) self.panel_step3.add(self.extrapanel_step3, BorderLayout.SOUTH) self.uiPanelB.setBottomComponent(self.panel_step3) # Assembling the group of all panels layout = GroupLayout(self.pluginTab) self.pluginTab.setLayout(layout) layout.setHorizontalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( layout.createSequentialGroup().addGap(10, 10, 10).addGroup( layout.createParallelGroup( GroupLayout.Alignment.LEADING).addComponent( self.uiTitle).addGap(15, 15, 15).addComponent( self.uiPanelA)).addContainerGap( 26, Short.MAX_VALUE))) layout.setVerticalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( layout.createSequentialGroup().addGap(15, 15, 15).addComponent( self.uiTitle).addGap(15, 15, 15).addComponent( self.uiPanelA).addGap(20, 20, 20).addGap(20, 20, 20)))
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)
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
def initPanelConfig(self): self._jPanel.setBounds(0, 0, 1000, 1000) self._jPanel.setLayout(GridBagLayout()) self._jAboutPanel.setBounds(0, 0, 1000, 1000) self._jAboutPanel.setLayout(GridBagLayout()) self._jLabelParameters = JLabel( "Parameters to Fuzz (comma separated): ") self._jPanelConstraints.fill = GridBagConstraints.HORIZONTAL self._jPanelConstraints.gridx = 0 self._jPanelConstraints.gridy = 0 self._jPanel.add(self._jLabelParameters, self._jPanelConstraints) self._jTextFieldParameters = JTextField("", 15) self._jPanelConstraints.fill = GridBagConstraints.HORIZONTAL self._jPanelConstraints.gridx = 1 self._jPanelConstraints.gridy = 0 self._jPanel.add(self._jTextFieldParameters, self._jPanelConstraints) self._jLabelTechniques = JLabel("Techniques (\"CHPTRSX\"):") self._jPanelConstraints.fill = GridBagConstraints.HORIZONTAL self._jPanelConstraints.gridx = 0 self._jPanelConstraints.gridy = 1 self._jPanel.add(self._jLabelTechniques, self._jPanelConstraints) self._jTextFieldTechniques = JTextField("CHPTRSX", 3) self._jPanelConstraints.fill = GridBagConstraints.HORIZONTAL self._jPanelConstraints.gridx = 1 self._jPanelConstraints.gridy = 1 self._jPanel.add(self._jTextFieldTechniques, self._jPanelConstraints) self._jLabelFuzzFactor = JLabel("Fuzz Factor (0-6):") self._jPanelConstraints.fill = GridBagConstraints.HORIZONTAL self._jPanelConstraints.gridx = 0 self._jPanelConstraints.gridy = 2 self._jPanel.add(self._jLabelFuzzFactor, self._jPanelConstraints) self._jTextFieldFuzzFactor = JTextField("6", 3) self._jPanelConstraints.fill = GridBagConstraints.HORIZONTAL self._jPanelConstraints.gridx = 1 self._jPanelConstraints.gridy = 2 self._jPanel.add(self._jTextFieldFuzzFactor, self._jPanelConstraints) self._jLabelAdditionalCmdLine = JLabel( "Additional command line switch:") self._jPanelConstraints.fill = GridBagConstraints.HORIZONTAL self._jPanelConstraints.gridx = 0 self._jPanelConstraints.gridy = 3 self._jPanel.add(self._jLabelAdditionalCmdLine, self._jPanelConstraints) self._jTextFieldAdditionalCmdLine = JTextField("", 3) self._jPanelConstraints.fill = GridBagConstraints.HORIZONTAL self._jPanelConstraints.gridx = 1 self._jPanelConstraints.gridy = 3 self._jPanel.add(self._jTextFieldAdditionalCmdLine, self._jPanelConstraints) self._jButtonSetCommandLine = JButton( 'Set Configuration', actionPerformed=self.setCommandLine) self._jPanelConstraints.fill = GridBagConstraints.HORIZONTAL self._jPanelConstraints.gridx = 0 self._jPanelConstraints.gridy = 5 self._jPanelConstraints.gridwidth = 2 self._jPanel.add(self._jButtonSetCommandLine, self._jPanelConstraints) self._jLabelAbout = JLabel("<html><body>%s</body></html>" % self.aboutText) self._jPanelConstraints.fill = GridBagConstraints.HORIZONTAL self._jPanelConstraints.gridx = 0 self._jPanelConstraints.gridy = 0 self._jAboutPanel.add(self._jLabelAbout, self._jPanelConstraints)
def setColumnWidths( self, table ) : #----------------------------------------------------------------------- # Set up some variables to access the table properties and data #----------------------------------------------------------------------- tcm = table.getColumnModel() # Table Column Model model = table.getModel() # Used to access the table data margin = tcm.getColumnMargin() # gap between columns #----------------------------------------------------------------------- # For each column, determine the maximum width required #----------------------------------------------------------------------- rows = model.getRowCount() # How many rows exist? cols = tcm.getColumnCount() # How many columns exist? labels = [ JLabel( font = plainFont ), JLabel( font = boldFont ) ] # print ' Now Min Pre Max' # print '---------------+---+---+---+---' metrics = [ fmPlain, fmBold ] tWidth = 0 # Table width section = 0 # Boolean: current row is a section? sections = 0 # Number of setion rows for i in range( cols ) : # Note: i == column index col = tcm.getColumn( i ) idx = col.getModelIndex() #------------------------------------------------------------------- # Find the maximum width required for the data values in this column # Note: Use the column adjustments to compute the best width #------------------------------------------------------------------- cWidth = 0 # Initial column width for row in range( rows ) : v0 = model.getValueAt( row, 0 ) if v0.startswith( '_' ) : section = 1 sections += 1 else : section = 0 comp = labels[ section ] fm = metrics[ section ] # FontMetric r = table.getCellRenderer( row, i ) v = model.getValueAt( row, idx ) if v.startswith( '_' ) : v = v[ 1: ] comp.setText( v ) cWidth = max( cWidth, comp.getPreferredSize().width ) if cWidth > 0 : col.setMinWidth( 128 + margin ) col.setPreferredWidth( 128 + margin ) # col.setPreferredWidth( cWidth + margin ) col.setMaxWidth( cWidth + margin ) # print 'Col: %d width: %d' % ( i, cWidth ) # print 'Col: %d widths |%3d|%3d|%3d|%d' % ( # i, # col.getWidth(), # col.getMinWidth(), # col.getPreferredWidth(), # col.getMaxWidth() # ) #------------------------------------------------------------------- # Add current column (preferred) width to the total table width #------------------------------------------------------------------- tWidth += col.getPreferredWidth() # print '---------------+---+---+---+---' h0 = table.getRowHeight() # print 'rowHeight:', h0 sections /= cols # print '#Sections:', sections #----------------------------------------------------------------------- # Set the preferred viewport size so we don't (initially) see scrollbars #----------------------------------------------------------------------- table.setPreferredScrollableViewportSize( Dimension( tWidth, sections * table.getRowHeight() ) )
class VolatilitySettingsWithUISettingsPanel(IngestModuleIngestJobSettingsPanel ): # Note, we can't use a self.settings instance variable. # Rather, self.local_settings is used. # https://wiki.python.org/jython/UserGuide#javabean-properties # Jython Introspector generates a property - 'settings' on the basis # of getSettings() defined in this class. Since only getter function # is present, it creates a read-only 'settings' property. This auto- # generated read-only property overshadows the instance-variable - # 'settings' # We get passed in a previous version of the settings so that we can # prepopulate the UI # TODO: Update this for your UI def __init__(self, settings): self.local_settings = settings self.initComponents() self.customizeComponents() # Check to see if there are any entries that need to be populated from the database. def check_Database_entries(self): head, tail = os.path.split(os.path.abspath(__file__)) settings_db = head + "\\GUI_Settings.db3" try: Class.forName("org.sqlite.JDBC").newInstance() dbConn = DriverManager.getConnection("jdbc:sqlite:%s" % settings_db) except SQLException as e: self.Error_Message.setText("Error Opening Settings DB!") try: stmt = dbConn.createStatement() SQL_Statement = 'Select Setting_Name, Setting_Value from settings;' resultSet = stmt.executeQuery(SQL_Statement) while resultSet.next(): if resultSet.getString( "Setting_Name") == "Volatility_Executable_Directory": self.Program_Executable_TF.setText( resultSet.getString("Setting_Value")) self.local_settings.setVolatility_Directory( resultSet.getString("Setting_Value")) self.local_settings.setVolatility_Dir_Found(True) # if resultSet.getString("Setting_Name") == "Volatility_Version": # self.Version_CB.setSelectedItem(resultSet.getString("Setting_Value")) self.Error_Message.setText("Settings Read successfully!") except SQLException as e: self.Error_Message.setText("Error Reading Settings Database") stmt.close() dbConn.close() # Save entries from the GUI to the database. def SaveSettings(self, e): head, tail = os.path.split(os.path.abspath(__file__)) settings_db = head + "\\GUI_Settings.db3" try: Class.forName("org.sqlite.JDBC").newInstance() dbConn = DriverManager.getConnection("jdbc:sqlite:%s" % settings_db) except SQLException as e: self.Error_Message.setText("Error Opening Settings") try: stmt = dbConn.createStatement() SQL_Statement = "" if (self.local_settings.getVolatility_Dir_Found()): SQL_Statement = 'Update settings set Setting_Value = "' + self.Program_Executable_TF.getText() + '"' + \ ' where setting_name = "Volatility_Executable_Directory";' # SQL_Statement2 = 'Update settings set Setting_Value = "' + self.Version_CB.getSelectedItem() + '"' + \ # ' where setting_name = "Volatility_Version";' else: SQL_Statement = 'Insert into settings (Setting_Name, Setting_Value) values ("Volatility_Executable_Directory", "' + \ self.Program_Executable_TF.getText() + '");' # SQL_Statement2 = 'Insert into settings (Setting_Name, Setting_Value) values ("Volatility_Version", "' + \ # self.Version_CB.getSelectedItem() + '");' stmt.execute(SQL_Statement) # stmt.execute(SQL_Statement2) self.Error_Message.setText("Volatility Executable Directory Saved") self.local_settings.setVolatility_Directory( self.Program_Executable_TF.getText()) except SQLException as e: self.Error_Message.setText(e.getMessage()) stmt.close() dbConn.close() # When button to find file is clicked then open dialog to find the file and return it. def Find_Dir(self, e): chooseFile = JFileChooser() filter = FileNameExtensionFilter("All", ["*.*"]) chooseFile.addChoosableFileFilter(filter) #chooseFile.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY) ret = chooseFile.showDialog(self.panel0, "Find Volatility Directory") if ret == JFileChooser.APPROVE_OPTION: file = chooseFile.getSelectedFile() Canonical_file = file.getCanonicalPath() #text = self.readPath(file) self.local_settings.setVolatility_Directory(Canonical_file) self.Program_Executable_TF.setText(Canonical_file) def keyPressed(self, event): self.local_settings.setProcessIDs( self.Process_Ids_To_Dump_TF.getText()) #self.Error_Message.setText(self.Process_Ids_To_Dump_TF.getText()) def checkBoxEvent(self, event): if self.Check_Box.isSelected(): self.local_settings.setFlag(True) else: self.local_settings.setFlag(False) # Create the initial data fields/layout in the UI def initComponents(self): self.panel0 = JPanel() self.rbgPanel0 = ButtonGroup() self.gbPanel0 = GridBagLayout() self.gbcPanel0 = GridBagConstraints() self.panel0.setLayout(self.gbPanel0) self.Error_Message = JLabel("") self.Error_Message.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 31 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Error_Message, self.gbcPanel0) self.panel0.add(self.Error_Message) self.Label_1 = JLabel("Volatility Executable Directory") self.Label_1.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 1 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Label_1, self.gbcPanel0) self.panel0.add(self.Label_1) self.Program_Executable_TF = JTextField(10) self.Program_Executable_TF.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 3 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Program_Executable_TF, self.gbcPanel0) self.panel0.add(self.Program_Executable_TF) self.Find_Program_Exec_BTN = JButton("Find Dir", actionPerformed=self.Find_Dir) self.Find_Program_Exec_BTN.setEnabled(True) self.rbgPanel0.add(self.Find_Program_Exec_BTN) self.gbcPanel0.gridx = 6 self.gbcPanel0.gridy = 3 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Find_Program_Exec_BTN, self.gbcPanel0) self.panel0.add(self.Find_Program_Exec_BTN) self.Blank_1 = JLabel(" ") self.Blank_1.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 5 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Blank_1, self.gbcPanel0) self.panel0.add(self.Blank_1) self.Save_Settings_BTN = JButton("Save Volatility Exec Dir", actionPerformed=self.SaveSettings) self.Save_Settings_BTN.setEnabled(True) self.rbgPanel0.add(self.Save_Settings_BTN) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 7 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Save_Settings_BTN, self.gbcPanel0) self.panel0.add(self.Save_Settings_BTN) self.Blank_2 = JLabel(" ") self.Blank_2.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 9 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Blank_2, self.gbcPanel0) self.panel0.add(self.Blank_2) self.Blank_3 = JLabel(" ") self.Blank_3.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 13 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Blank_3, self.gbcPanel0) self.panel0.add(self.Blank_3) self.Check_Box = JCheckBox( "Extract and Create Memory Image from Hiberfile", actionPerformed=self.checkBoxEvent) self.Blank_1.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 15 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Check_Box, self.gbcPanel0) self.panel0.add(self.Check_Box) self.Blank_4 = JLabel(" ") self.Blank_4.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 17 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Blank_4, self.gbcPanel0) self.panel0.add(self.Blank_4) self.Blank_5 = JLabel(" ") self.Blank_5.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 21 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Blank_5, self.gbcPanel0) self.panel0.add(self.Blank_5) self.Blank_6 = JLabel(" ") self.Blank_6.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 27 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Blank_6, self.gbcPanel0) self.panel0.add(self.Blank_6) self.Label_3 = JLabel("Message:") self.Label_3.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 29 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Label_3, self.gbcPanel0) self.panel0.add(self.Label_3) self.add(self.panel0) # Custom load any data field and initialize the values def customizeComponents(self): self.Check_Box.setSelected(self.local_settings.getFlag()) self.check_Database_entries() #pass # Return the settings used def getSettings(self): return self.local_settings
class BurpExtender(IBurpExtender, ITab, IExtensionStateListener): # Define the global variables for the burp plugin EXTENSION_NAME = "UPnP BHunter" ipv4_selected = True services_dict = {} ip_service_dict = {} STOP_THREAD = False #Some SSDP m-search parameters are based upon "UPnP Device Architecture v2.0" SSDP_MULTICAST_IPv4 = ["239.255.255.250"] SSDP_MULTICAST_IPv6 = ["FF02::C", "FF05::C"] SSDP_MULTICAST_PORT = 1900 ST_ALL = "ssdp:all" ST_ROOTDEV = "upnp:rootdevice" PLACEHOLDER = "FUZZ_HERE" SSDP_TIMEOUT = 2 def registerExtenderCallbacks(self, callbacks): # Get a reference to callbacks object self.callbacks = callbacks # Get the useful extension helpers object self.helpers = callbacks.getHelpers() # Set the extension name self.callbacks.setExtensionName(self.EXTENSION_NAME) self.callbacks.registerExtensionStateListener(self) # Draw plugin user interface self.drawPluginUI() self.callbacks.addSuiteTab(self) # Plugin loading message print("[+] Burp plugin UPnP BHunter loaded successfully") return def drawPluginUI(self): # Create the plugin user interface self.pluginTab = JPanel() self.uiTitle = JLabel('UPnP BHunter Load, Aim and Fire Console') self.uiTitle.setFont(Font('Tahoma', Font.BOLD, 14)) self.uiTitle.setForeground(Color(250, 100, 0)) self.uiPanelA = JSplitPane(JSplitPane.VERTICAL_SPLIT) self.uiPanelA.setMaximumSize(Dimension(2500, 1000)) self.uiPanelA.setDividerSize(2) self.uiPanelB = JSplitPane(JSplitPane.VERTICAL_SPLIT) self.uiPanelB.setDividerSize(2) self.uiPanelA.setBottomComponent(self.uiPanelB) self.uiPanelA.setBorder(BorderFactory.createLineBorder(Color.gray)) # Create and configure labels and text fields self.labeltitle_step1 = JLabel("[1st STEP] Discover UPnP Locations") self.labeltitle_step1.setFont(Font('Tahoma', Font.BOLD, 14)) self.labeltitle_step2 = JLabel( "[2nd STEP] Select a UPnP Service and Action") self.labeltitle_step2.setFont(Font('Tahoma', Font.BOLD, 14)) self.labeltitle_step3 = JLabel("[3rd STEP] Time to Attack it") self.labeltitle_step3.setFont(Font('Tahoma', Font.BOLD, 14)) self.labelsubtitle_step1 = JLabel( "Specify the IP version address in scope and start UPnP discovery") self.labelsubtitle_step2 = JLabel( "Select which of the found UPnP services will be probed") self.labelsubtitle_step3 = JLabel( "Review and modify the request, then send it to one of the attack tools" ) self.label_step1 = JLabel("Target IP") self.label_step2 = JLabel("Found UPnp Services") self.labelstatus = JLabel(" Status") self.labelempty_step1 = JLabel(" ") self.labelempty_step2 = JLabel(" ") self.labelupnp = JLabel("UPnP list") self.labelip = JLabel("IP list") self.labelactions = JLabel("Actions") self.labelNoneServiceFound = JLabel(" ") self.labelNoneServiceFound.setFont(Font('Tahoma', Font.BOLD, 12)) self.labelNoneServiceFound.setForeground(Color.red) # Create combobox for IP version selection self.ip_versions = ["IPv4", "IPv6"] self.combo_ipversion = JComboBox(self.ip_versions) self.combo_ipversion.setSelectedIndex(0) self.combo_ipversion.setEnabled(True) # Create and configure progress bar self.progressbar = JProgressBar(0, 100) self.progressbar.setString("Ready") self.progressbar.setStringPainted(True) # Create and configure buttons self.startbutton = JButton("Start Discovery", actionPerformed=self.startHunting) self.clearbutton = JButton("Clear All", actionPerformed=self.clearAll) self.intruderbutton = JButton("Send to Intruder", actionPerformed=self.sendToIntruder) self.repeaterbutton = JButton("Send to Repeater", actionPerformed=self.sendToRepeater) #self.WANrepeaterbutton = JButton("to Repeater", actionPerformed=self.sendWANUPnPToRepeater) self.textarea_request = JTextArea(18, 90) self.intruderbutton.setEnabled(False) self.repeaterbutton.setEnabled(False) # Class neeeded to handle the target combobox in second step panel class TargetComboboxListener(ActionListener): def __init__(self, upnpcombo_targets, upnpcombo_services, ip_service_dict): self.upnpcombo_targets = upnpcombo_targets self.upnpcombo_services = upnpcombo_services self.ip_service_dict = ip_service_dict def actionPerformed(self, event): try: # Update the location url combobox depending on the IP combobox selected_target = self.upnpcombo_targets.getSelectedItem() if self.ip_service_dict and selected_target: self.upnpcombo_services.removeAllItems() for service_url in self.ip_service_dict[ selected_target]: self.upnpcombo_services.addItem(service_url) self.upnpcombo_services.setSelectedIndex(0) except BaseException as e: print("[!] Exception selecting service: \"%s\" ") % e # Class neeeded to handle the service combobox in second step panel class ServiceComboboxListener(ActionListener): def __init__(self, upnpcombo_services, upnpcombo_actions, services_dict): self.upnpcombo_services = upnpcombo_services self.upnpcombo_actions = upnpcombo_actions self.services = services_dict def actionPerformed(self, event): try: # Update the location url combobox depending on the IP combobox selected_service = self.upnpcombo_services.getSelectedItem( ) if self.services and selected_service: self.upnpcombo_actions.removeAllItems() actions = self.services[selected_service] for action in actions: self.upnpcombo_actions.addItem(action) self.upnpcombo_actions.setSelectedIndex(0) except BaseException as e: print("[!] Exception selecting service: \"%s\" ") % e # Class neeeded to handle the action combobox in second step panel class ActionComboboxListener(ActionListener): def __init__(self, upnpcombo_services, upnpcombo_actions, textarea_request, services_dict): self.upnpcombo_services = upnpcombo_services self.upnpcombo_actions = upnpcombo_actions self.textarea_request = textarea_request self.services = services_dict def actionPerformed(self, event): try: # Update the location url combobox depending on the IP combobox selected_action = self.upnpcombo_actions.getSelectedItem() selected_service = self.upnpcombo_services.getSelectedItem( ) if self.services and selected_action: self.textarea_request.setText( self.services[selected_service][selected_action]) except BaseException as e: print("[!] Exception selecting action: \"%s\" ") % e self.upnpactions = [" "] self.upnpcombo_actions = JComboBox(self.upnpactions) self.upnpcombo_actions.setSelectedIndex(0) self.upnpcombo_actions.setEnabled(False) # Create the combo box, select item at index 0 (first item in list) self.upnpservices = [" "] self.upnpcombo_services = JComboBox(self.upnpservices) self.upnpcombo_services.setSelectedIndex(0) self.upnpcombo_services.setEnabled(False) # Create the combo box, select item at index 0 (first item in list) self.upnptargets = [" "] self.upnpcombo_targets = JComboBox(self.upnptargets) self.upnpcombo_targets.setSelectedIndex(0) self.upnpcombo_targets.setEnabled(False) # Set the action listeners for all the comboboxes self.upnpcombo_targets.addActionListener( TargetComboboxListener(self.upnpcombo_targets, self.upnpcombo_services, self.ip_service_dict)) self.upnpcombo_services.addActionListener( ServiceComboboxListener(self.upnpcombo_services, self.upnpcombo_actions, self.services_dict)) self.upnpcombo_actions.addActionListener( ActionComboboxListener(self.upnpcombo_services, self.upnpcombo_actions, self.textarea_request, self.services_dict)) # Configuring first step panel self.panel_step1 = JPanel() self.panel_step1.setPreferredSize(Dimension(2250, 100)) self.panel_step1.setBorder(EmptyBorder(10, 10, 10, 10)) self.panel_step1.setLayout(BorderLayout(15, 15)) self.titlepanel_step1 = JPanel() self.titlepanel_step1.setLayout(BorderLayout()) self.titlepanel_step1.add(self.labeltitle_step1, BorderLayout.NORTH) self.titlepanel_step1.add(self.labelsubtitle_step1) self.targetpanel_step1 = JPanel() self.targetpanel_step1.add(self.label_step1) self.targetpanel_step1.add(self.combo_ipversion) self.targetpanel_step1.add(self.startbutton) self.targetpanel_step1.add(self.clearbutton) self.targetpanel_step1.add(self.labelstatus) self.targetpanel_step1.add(self.progressbar) self.emptypanel_step1 = JPanel() self.emptypanel_step1.setLayout(BorderLayout()) self.emptypanel_step1.add(self.labelempty_step1, BorderLayout.WEST) # Assembling first step panel components self.panel_step1.add(self.titlepanel_step1, BorderLayout.NORTH) self.panel_step1.add(self.targetpanel_step1, BorderLayout.WEST) self.panel_step1.add(self.emptypanel_step1, BorderLayout.SOUTH) self.uiPanelA.setTopComponent(self.panel_step1) # Configure second step panel self.panel_step2 = JPanel() self.panel_step2.setPreferredSize(Dimension(2250, 100)) self.panel_step2.setBorder(EmptyBorder(10, 10, 10, 10)) self.panel_step2.setLayout(BorderLayout(15, 15)) self.titlepanel_step2 = JPanel() self.titlepanel_step2.setLayout(BorderLayout()) self.titlepanel_step2.add(self.labeltitle_step2, BorderLayout.NORTH) self.titlepanel_step2.add(self.labelsubtitle_step2) self.selectpanel_step2 = JPanel() self.selectpanel_step2.add(self.labelip) self.selectpanel_step2.add(self.upnpcombo_targets) self.selectpanel_step2.add(self.labelupnp) self.selectpanel_step2.add(self.upnpcombo_services) self.selectpanel_step2.add(self.labelactions) self.selectpanel_step2.add(self.upnpcombo_actions) self.emptypanel_step2 = JPanel() self.emptypanel_step2.setLayout(BorderLayout()) self.emptypanel_step2.add(self.labelempty_step2, BorderLayout.WEST) self.emptypanel_step2.add(self.labelNoneServiceFound) # Assembling second step panel components self.panel_step2.add(self.titlepanel_step2, BorderLayout.NORTH) self.panel_step2.add(self.selectpanel_step2, BorderLayout.WEST) self.panel_step2.add(self.emptypanel_step2, BorderLayout.SOUTH) self.uiPanelB.setTopComponent(self.panel_step2) # Configuring third step panel self.panel_step3 = JPanel() self.panel_step3.setPreferredSize(Dimension(2250, 100)) self.panel_step3.setBorder(EmptyBorder(10, 10, 10, 10)) self.panel_step3.setLayout(BorderLayout(15, 15)) self.titlepanel_step3 = JPanel() self.titlepanel_step3.setLayout(BorderLayout()) self.titlepanel_step3.add(self.labeltitle_step3, BorderLayout.NORTH) self.titlepanel_step3.add(self.labelsubtitle_step3) self.underpanel_step3 = JPanel() self.underpanel_step3.setLayout(BorderLayout()) self.underpanel_step3.add((JScrollPane(self.textarea_request)), BorderLayout.NORTH) self.actionpanel_step3 = JPanel() self.actionpanel_step3.add(self.intruderbutton) self.actionpanel_step3.add(self.repeaterbutton) self.extrapanel_step3 = JPanel() self.extrapanel_step3.setLayout(BorderLayout()) self.extrapanel_step3.add(self.actionpanel_step3, BorderLayout.WEST) # Assembling thirdd step panel components self.panel_step3.add(self.titlepanel_step3, BorderLayout.NORTH) self.panel_step3.add(self.underpanel_step3, BorderLayout.WEST) self.panel_step3.add(self.extrapanel_step3, BorderLayout.SOUTH) self.uiPanelB.setBottomComponent(self.panel_step3) # Assembling the group of all panels layout = GroupLayout(self.pluginTab) self.pluginTab.setLayout(layout) layout.setHorizontalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( layout.createSequentialGroup().addGap(10, 10, 10).addGroup( layout.createParallelGroup( GroupLayout.Alignment.LEADING).addComponent( self.uiTitle).addGap(15, 15, 15).addComponent( self.uiPanelA)).addContainerGap( 26, Short.MAX_VALUE))) layout.setVerticalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( layout.createSequentialGroup().addGap(15, 15, 15).addComponent( self.uiTitle).addGap(15, 15, 15).addComponent( self.uiPanelA).addGap(20, 20, 20).addGap(20, 20, 20))) def extensionUnloaded(self): # Unload the plugin, and if running stop the background thread if self.upnpcombo_services.isEnabled(): if self.th.isAlive(): print("[+] Stopping thread %s") % self.th.getName() self.STOP_THREAD = True self.th.join() else: print("Thread %s already dead") % self.th.getName() print("[+] Burp plugin UPnP BHunter successfully unloaded") return def getTabCaption(self): return self.EXTENSION_NAME def getUiComponent(self): return self.pluginTab def clearAll(self, e=None): # Reset all data of the plugin self.services_dict.clear() self.progressbar.setString("Ready") self.progressbar.setValue(0) self.upnpcombo_targets.removeAllItems() self.upnpcombo_targets.setEnabled(False) self.upnpcombo_services.removeAllItems() self.upnpcombo_services.setEnabled(False) self.upnpcombo_actions.removeAllItems() self.upnpcombo_actions.setEnabled(False) self.intruderbutton.setEnabled(False) self.repeaterbutton.setEnabled(False) self.labelNoneServiceFound.setText(" ") self.textarea_request.setText(" ") print("[+] Clearing all data") return def startHunting(self, e=None): # Starting the UPnP hunt def startHunting_run(): # Initialize the internal parameters every time the start-discovery button is clicked self.services_dict.clear() found_loc = [] discovery_files = [] self.labelNoneServiceFound.setText(" ") self.intruderbutton.setEnabled(False) self.repeaterbutton.setEnabled(False) # Then determine if targerting IPv4 or IPv6 adresses if self.combo_ipversion.getSelectedItem() == "IPv4": self.ipv4_selected = True print("[+] Selected IPv4 address scope") else: self.ipv4_selected = False print("[+] Selected IPv6 address scope") # And here finally the hunt could start self.progressbar.setString("Running...") self.progressbar.setValue(20) found_loc = self.discoverUpnpLocations() self.progressbar.setValue(40) discovery_files = self.downloadXMLfiles(found_loc) self.progressbar.setValue(60) self.buildSOAPs(discovery_files) self.progressbar.setValue(80) self.progressbar.setString("Done") self.progressbar.setValue(100) self.updateComboboxList(self.services_dict) # Update the comboboxes list with the discovered UPnPs if (self.services_dict): self.upnpcombo_targets.setEnabled(True) self.upnpcombo_services.setEnabled(True) self.upnpcombo_actions.setEnabled(True) self.intruderbutton.setEnabled(True) self.repeaterbutton.setEnabled(True) if self.STOP_THREAD: return # Start a background thread to run the above nested function in order to prevent the blocking of plugin UI self.th = threading.Thread(target=startHunting_run) #self.th.daemon = True # This does not seem to be useful self.th.setName("th-BHunter") self.th.start() def ssdpReqBuilder(self, ssdp_timeout, st_type, ssdp_ip, ssdp_port): # Builder of the two ssdp msearch request types msearch_req = "M-SEARCH * HTTP/1.1\r\n" \ "HOST: {0}:{1}\r\n" \ "MAN: \"ssdp:discover\"\r\n" \ "MX: {2}\r\n" \ "ST: {3}\r\n" \ "\r\n" \ .format(ssdp_ip, ssdp_port, ssdp_timeout, st_type) return msearch_req def sendMsearch(self, ssdp_req, ssdp_ip, ssdp_port): # Send the ssdp request and retrieve response buf_resp = set() if self.ipv4_selected: print("[+] Creating IPv4 SSDP multicast request") sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) else: print("[+] Creating IPv6 SSDP multicast request") sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) sock.setblocking(0) # Sending ssdp requests while len(ssdp_req): # Blocking socket client until the request is completely sent try: sent = sock.sendto(ssdp_req.encode("ASCII"), (ssdp_ip, ssdp_port)) ssdp_req = ssdp_req[sent:] except socket.error, exc: if exc.errno != errno.EAGAIN: print("[E] Got error %s with socket when sending") % exc sock.close() raise exc print("[!] Blocking socket until ", len(ssdp_req), " is sent.") select.select([], [sock], []) continue # Retrieving ssdp responses num_resp = 0 while sock: # Blocking socket until there are ssdp responses to be read or timeout is reached readable, __, __ = select.select([sock], [], [], self.SSDP_TIMEOUT) if not readable: # Timeout reached without receiving any ssdp response if num_resp == 0: print( "[!] Got timeout without receiving any ssdp response.") break else: num_resp = num_resp + 1 # Almost an ssdp response was received if readable[0]: try: data = sock.recv(1024) if data: buf_resp.add(data.decode('ASCII')) except socket.error, exc: print("[E] Got error %s with socket when receiving" ) % exc sock.close() raise exc
def initComponents(self): self.panel0 = JPanel() self.rbgPanel0 = ButtonGroup() self.gbPanel0 = GridBagLayout() self.gbcPanel0 = GridBagConstraints() self.panel0.setLayout(self.gbPanel0) self.Error_Message = JLabel("") self.Error_Message.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 31 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Error_Message, self.gbcPanel0) self.panel0.add(self.Error_Message) self.Label_1 = JLabel("Volatility Executable Directory") self.Label_1.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 1 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Label_1, self.gbcPanel0) self.panel0.add(self.Label_1) self.Program_Executable_TF = JTextField(10) self.Program_Executable_TF.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 3 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Program_Executable_TF, self.gbcPanel0) self.panel0.add(self.Program_Executable_TF) self.Find_Program_Exec_BTN = JButton("Find Dir", actionPerformed=self.Find_Dir) self.Find_Program_Exec_BTN.setEnabled(True) self.rbgPanel0.add(self.Find_Program_Exec_BTN) self.gbcPanel0.gridx = 6 self.gbcPanel0.gridy = 3 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Find_Program_Exec_BTN, self.gbcPanel0) self.panel0.add(self.Find_Program_Exec_BTN) self.Blank_1 = JLabel(" ") self.Blank_1.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 5 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Blank_1, self.gbcPanel0) self.panel0.add(self.Blank_1) self.Save_Settings_BTN = JButton("Save Volatility Exec Dir", actionPerformed=self.SaveSettings) self.Save_Settings_BTN.setEnabled(True) self.rbgPanel0.add(self.Save_Settings_BTN) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 7 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Save_Settings_BTN, self.gbcPanel0) self.panel0.add(self.Save_Settings_BTN) self.Blank_2 = JLabel(" ") self.Blank_2.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 9 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Blank_2, self.gbcPanel0) self.panel0.add(self.Blank_2) self.Blank_3 = JLabel(" ") self.Blank_3.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 13 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Blank_3, self.gbcPanel0) self.panel0.add(self.Blank_3) self.Check_Box = JCheckBox( "Extract and Create Memory Image from Hiberfile", actionPerformed=self.checkBoxEvent) self.Blank_1.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 15 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Check_Box, self.gbcPanel0) self.panel0.add(self.Check_Box) self.Blank_4 = JLabel(" ") self.Blank_4.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 17 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Blank_4, self.gbcPanel0) self.panel0.add(self.Blank_4) self.Blank_5 = JLabel(" ") self.Blank_5.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 21 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Blank_5, self.gbcPanel0) self.panel0.add(self.Blank_5) self.Blank_6 = JLabel(" ") self.Blank_6.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 27 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Blank_6, self.gbcPanel0) self.panel0.add(self.Blank_6) self.Label_3 = JLabel("Message:") self.Label_3.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 29 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.Label_3, self.gbcPanel0) self.panel0.add(self.Label_3) self.add(self.panel0)
def registerExtenderCallbacks(self, callbacks): self._callbacks = callbacks self._helpers = callbacks.getHelpers() callbacks.setExtensionName("Module Importer") self.out = callbacks.getStdout() self.tab = JPanel(GridBagLayout()) self.tableData = [] colNames = ('Enabled', 'Module') self.dataModel = MyTableModel(self.tableData, colNames) self.table = JTable(self.dataModel) self.tablecont = JScrollPane(self.table) c = GridBagConstraints() c.anchor = GridBagConstraints.FIRST_LINE_START c.gridx = 0 c.gridy = 4 c.gridheight = 6 c.gridwidth = 6 c.weightx = 0.6 c.weighty = 0.5 self.tab.add(self.tablecont, c) self.fc = JFileChooser() self.fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY) label_for_openDirectory = JLabel("Module Importer") c = GridBagConstraints() c.anchor = GridBagConstraints.FIRST_LINE_START c.gridx = 0 c.gridy = 0 self.tab.add(label_for_openDirectory, c) label_plugin_desc = JLabel( "This module makes your development of Burp Suite Plugin easier.") label_plugin_desc.setPreferredSize(Dimension(400, 50)) c = GridBagConstraints() c.gridx = 0 c.gridy = 1 self.tab.add(label_plugin_desc, c) label_for_openDirectory = JLabel("Module Path:") c = GridBagConstraints() c.anchor = GridBagConstraints.FIRST_LINE_START c.gridx = 0 c.gridy = 2 self.tab.add(label_for_openDirectory, c) c = GridBagConstraints() c.anchor = GridBagConstraints.FIRST_LINE_START c.gridx = 0 c.gridy = 3 self.input_id = JTextField(40) self.input_id.setEditable(java.lang.Boolean.FALSE) self.tab.add(self.input_id, c) c = GridBagConstraints() c.anchor = GridBagConstraints.FIRST_LINE_START c.gridx = 1 c.gridy = 3 self.openButton = JButton("Open Directory", actionPerformed=self.openDialog) self.tab.add(self.openButton, c) if M_PATH: self.set_fixed_module_path() #callbacks.customizeUiComponent(self.tab) #callbacks.customizeUiComponent(self.table) #callbacks.customizeUiComponent(self.tablecont) callbacks.addSuiteTab(self) callbacks.registerProxyListener(self) return
def __init__(self): #obtain prefixes from folder self.dict1 = self.obtain_prefixes( ) #Run prefix selection function - sets source directory, requests prefix size, outputs prefix dictionary lst = list(self.dict1.keys()) #pull prefixes only, as list self.lang = lst self.lst = JList(self.lang, valueChanged=self.listSelect ) # pass prefix list to GUI selection list # general GUI layout parameters, no data processing here self.frame = JFrame("Image Selection") self.frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) self.frame.setLocation(100, 100) self.frame.setSize(800, 350) self.frame.setLayout(BorderLayout()) self.frame.add(self.lst, BorderLayout.NORTH) self.lst.selectionMode = ListSelectionModel.MULTIPLE_INTERVAL_SELECTION self.button1 = JButton('Select item(s)', actionPerformed=self.clickhere) #Save option radio buttons and file extension selection #set main right panel (sub panels will fit within this) rightpanel = JPanel() rightpanel.setLayout(BoxLayout(rightpanel, BoxLayout.Y_AXIS)) #set up savestate panel buttonpanel = JPanel() self.radiobutton1 = JRadioButton( "Open selected 3D stacks and max projections \n and save max projections", True) self.radiobutton2 = JRadioButton( "Open selected 3D stacks and max projections \n and DO NOT save max projections" ) infoLabel = JLabel( "<html>Hold ctrl and click multiple prefixes to select multiple options. Will load stacks and MIPs separately <br><br> Type file extension in text field below:</html>", SwingConstants.LEFT) grp = ButtonGroup() grp.add(self.radiobutton1) grp.add(self.radiobutton2) #buttonpanel.setLayout(BoxLayout(buttonpanel, BoxLayout.Y_AXIS)) buttonpanel.add(Box.createVerticalGlue()) buttonpanel.add(infoLabel) buttonpanel.add(Box.createRigidArea(Dimension(0, 5))) buttonpanel.add(self.radiobutton1) buttonpanel.add(Box.createRigidArea(Dimension(0, 5))) buttonpanel.add(self.radiobutton2) #file extension instruction panel infopanel = JPanel() infopanel.setLayout(FlowLayout(FlowLayout.LEFT)) infopanel.setMaximumSize( infopanel.setPreferredSize(Dimension(650, 100))) infopanel.add(infoLabel) #file extension input inputPanel = JPanel() inputPanel.setLayout(BoxLayout(inputPanel, BoxLayout.X_AXIS)) self.filetype = JTextField(".tif", 15) self.filetype.setMaximumSize(self.filetype.getPreferredSize()) inputPanel.add(self.filetype) ########### WIP - integrate prefix selection with main pane, with dynamically updating prefix list ##infoLabel3 = JLabel("how long is the file prefix to group by?(integer value only)") ##self.prefix_init = JTextField() ##buttonpanel.add(infoLabel3) ##buttonpanel.add(self.prefix_init) ########### !WIP #add file extension and savestate panels to main panel rightpanel.add(infopanel) rightpanel.add(inputPanel) rightpanel.add(buttonpanel, BorderLayout.EAST) #split list and radiobutton pane (construct overall window) spl = JSplitPane(JSplitPane.HORIZONTAL_SPLIT) spl.leftComponent = JScrollPane(self.lst) spl.setDividerLocation(150) spl.rightComponent = rightpanel self.frame.add(spl) self.frame.add(self.button1, BorderLayout.SOUTH) # GUI layout done, initialise GUI to select prefixes, file extension and save option self.frame.setVisible(True)
import sys from java.awt import Window from javax.swing import JFrame, WindowConstants from javax.swing import JButton, JLabel from java.awt import BorderLayout def buttonPressed(e): l.setText("Button Pressed") border = BorderLayout() f = JFrame() l = JLabel("This is a label") b = JButton("Press Me!") f.title = "Hello AWT" f.setLayout(border) f.contentPane.add(b, BorderLayout.SOUTH) f.contentPane.add(l, BorderLayout.NORTH) f.setSize(400, 400) b.actionPerformed = buttonPressed f.visible = True f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)