def createMenuItems(self, invocation): def addRequestsToTab(e): for messageInfo in messages: # saveBuffers is required since modifying the original from its source changes the saved objects, its not a copy messageIndex = self._db.createNewMessage(self._callbacks.saveBuffersToTempFiles(messageInfo), self._helpers.analyzeRequest(messageInfo).getUrl()) #self._messageTable.getModel().addRow(row) self._messageTable.redrawTable() ret = [] messages = invocation.getSelectedMessages() # Check if the messages in the target tree have a response valid = True if invocation.getInvocationContext() == invocation.CONTEXT_TARGET_SITE_MAP_TREE: for selected in messages: if not selected.getResponse(): valid = False if valid: menuItem = JMenuItem("Send request(s) to AuthMatrix"); menuItem.addActionListener(addRequestsToTab) ret.append(menuItem) return ret
def createMenuItems(self, invocation): if invocation.getInvocationContext() != invocation.CONTEXT_MESSAGE_EDITOR_REQUEST: return None menuItem = JMenuItem("Evaluate Groovy") menuItem.addActionListener( GroovyActionListener(invocation.getSelectedMessages()[0], invocation.getSelectionBounds())) return [menuItem]
def initTabs(self): # ## init autorize tabs # self.logTable = Table(self) self.logTable.setAutoCreateRowSorter(True) tableWidth = self.logTable.getPreferredSize().width self.logTable.getColumn("ID").setPreferredWidth(Math.round(tableWidth / 50 * 2)) self.logTable.getColumn("URL").setPreferredWidth(Math.round(tableWidth / 50 * 24)) self.logTable.getColumn("Orig. Length").setPreferredWidth(Math.round(tableWidth / 50 * 4)) self.logTable.getColumn("Modif. Length").setPreferredWidth(Math.round(tableWidth / 50 * 4)) self.logTable.getColumn("Unauth. Length").setPreferredWidth(Math.round(tableWidth / 50 * 4)) self.logTable.getColumn("Authorization Enforcement Status").setPreferredWidth(Math.round(tableWidth / 50 * 4)) self.logTable.getColumn("Authorization Unauth. Status").setPreferredWidth(Math.round(tableWidth / 50 * 4)) self._splitpane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT) self._splitpane.setResizeWeight(1) self.scrollPane = JScrollPane(self.logTable) self._splitpane.setLeftComponent(self.scrollPane) self.scrollPane.getVerticalScrollBar().addAdjustmentListener(autoScrollListener(self)) self.menuES0 = JCheckBoxMenuItem(self._enfocementStatuses[0],True) self.menuES1 = JCheckBoxMenuItem(self._enfocementStatuses[1],True) self.menuES2 = JCheckBoxMenuItem(self._enfocementStatuses[2],True) self.menuES0.addItemListener(menuTableFilter(self)) self.menuES1.addItemListener(menuTableFilter(self)) self.menuES2.addItemListener(menuTableFilter(self)) copyURLitem = JMenuItem("Copy URL"); copyURLitem.addActionListener(copySelectedURL(self)) self.menu = JPopupMenu("Popup") self.menu.add(copyURLitem) self.menu.add(self.menuES0) self.menu.add(self.menuES1) self.menu.add(self.menuES2) self.tabs = JTabbedPane() self._requestViewer = self._callbacks.createMessageEditor(self, False) self._responseViewer = self._callbacks.createMessageEditor(self, False) self._originalrequestViewer = self._callbacks.createMessageEditor(self, False) self._originalresponseViewer = self._callbacks.createMessageEditor(self, False) self._unauthorizedrequestViewer = self._callbacks.createMessageEditor(self, False) self._unauthorizedresponseViewer = self._callbacks.createMessageEditor(self, False) self.tabs.addTab("Modified Request", self._requestViewer.getComponent()) self.tabs.addTab("Modified Response", self._responseViewer.getComponent()) self.tabs.addTab("Original Request", self._originalrequestViewer.getComponent()) self.tabs.addTab("Original Response", self._originalresponseViewer.getComponent()) self.tabs.addTab("Unauthenticated Request", self._unauthorizedrequestViewer.getComponent()) self.tabs.addTab("Unauthenticated Response", self._unauthorizedresponseViewer.getComponent()) self.tabs.addTab("Configuration", self.pnl) self.tabs.setSelectedIndex(6) self._splitpane.setRightComponent(self.tabs)
def init(self): w, h, aa, threads = (512, 512, 1, 2) canvas = RayTracePanel(w, h, aa, threads) self.getContentPane().add(JScrollPane(canvas)) # Save FileChooser # fcS = JFileChooser() # fcS.addChoosableFileFilter(FileNameExtensionFilter('Windows Bitmap (*.bmp)', ['bmp'])) # fcS.addChoosableFileFilter(FileNameExtensionFilter('JPEG / JFIF (*.jpg)', ['jpg'])) # fcS.addChoosableFileFilter(FileNameExtensionFilter('Portable Network Graphics (*.png)', ['png'])) # def saveFile(event): # '''Performed when the save button is pressed''' # result = fcS.showSaveDialog(frame) # if result == JFileChooser.APPROVE_OPTION: # file = fcS.getSelectedFile() # fname = file.getPath() # ext = fcS.getFileFilter().getExtensions()[0] # if not fname.endswith('.' + ext): # file = File(fname + '.' + ext) # canvas.saveToFile(file, ext) # Open FileChooser # fcO = JFileChooser() # fcO.addChoosableFileFilter(FileNameExtensionFilter('RayTrace Scene File (*.rts)', ['rts'])) # def openFile(event): # '''Performed when the open button is pressed''' # result = fcO.showOpenDialog(frame) # if result == JFileChooser.APPROVE_OPTION: # fname = fcO.getSelectedFile().getPath() # if fname.endswith('.rts'): # f = open(fname, 'rb') # newScene = SceneFactory().buildScene(f) # f.close() # Painter(canvas, newScene, openButton, saveButton, stopButton).start() def stop(event): """Peformed when the stop button is pressed""" canvas.stopRendering() # Setup Menu menuBar = JMenuBar() menu = JMenu("File") menuBar.add(menu) # openButton = JMenuItem("Open...", actionPerformed=openFile) # openButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)) # menu.add(openButton) # saveButton = JMenuItem("Save as...", actionPerformed=saveFile) # saveButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)) # menu.add(saveButton) menu.addSeparator() stopButton = JMenuItem("Stop Render", actionPerformed=stop) stopButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)) stopButton.setEnabled(False) menu.add(stopButton) menu.addSeparator() # closeButton = JMenuItem('Close', actionPerformed=exit) # closeButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK)) # menu.add(closeButton) self.setJMenuBar(menuBar)
def createMenuItems(self, invocation): responses = invocation.getSelectedMessages(); if responses > 0: ret = LinkedList() requestMenuItem = JMenuItem("Send to PT Manager"); requestMenuItem.addActionListener(handleMenuItems(self,responses[0], "request")) ret.add(requestMenuItem); return(ret); return null;
def addAction(self, action, mnemonic= -1, shortcut=None): item = JMenuItem(action.toSwingAction()) if shortcut is not None: item.accelerator = shortcut if mnemonic != -1: item.mnemonic = mnemonic self.applyStyle(item) self.menu.add(item)
def add_check_item(self, tool, view, check, viewMenu): checkItem = JMenuItem(check.title) if check.icon is not None: checkItem.setIcon(check.icon) checkItem.addActionListener(QatMenuActionListener(self.app, "check", tool, view, check)) viewMenu.add(checkItem)
def initTabs(self): # ## init autorize tabs # self._splitpane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT) self.scrollPane = JScrollPane(self.logTable) self._splitpane.setLeftComponent(self.scrollPane) colorsMenu = JMenu("Paint") redMenu = JMenuItem("Red") noneMenu = JMenuItem("None") greenMenu = JMenuItem("Green") redMenu.addActionListener(paintChange(self, "Red")) noneMenu.addActionListener(paintChange(self, None)) greenMenu.addActionListener(paintChange(self, "Green")) colorsMenu.add(redMenu) colorsMenu.add(noneMenu) colorsMenu.add(greenMenu) self.menu = JPopupMenu("Popup") self.menu.add(colorsMenu) self.tabs = JTabbedPane() self.tabs.addTab("Request", self._requestViewer.getComponent()) self.tabs.addTab("Response", self._responseViewer.getComponent()) self.tabs.addTab("Vulnerability", self.pnl) self.tabs.addTab("Project Settings", self.projectSettings) self.tabs.setSelectedIndex(2) self._splitpane.setRightComponent(self.tabs)
def tcMenu(): caseSubMenu = JMenu("case view") for pkg in (entity == 'package'): pkgSubMenu = JMenu(pkg.name) cases = [ x.getNode2() for x in (pkg->(entity == 'testcase'))] for case in cases: caseItem = JMenuItem(case.name) caseItem.actionPerformed = lambda event : viewCase(event.getActionCommand()) pkgSubMenu.add(caseItem) caseSubMenu.add(pkgSubMenu) return caseSubMenu
def generate_menu_items(self): for k in self.items: #print k + '\n' #menuitem = JMenuItem(k, actionPerformed=self.menuItemClicked) menuitem = JMenuItem(k) #menu.append(JMenuItem(self._actionName, None , actionPerformed= lambda x, inv=invocation: self.sqlMapScan(inv))) menuitem.addActionListener(ActionHandler(self._callbacks, k, self._helers)) self.menuitems[menuitem] = k
def createMenuItems(self, invocation): menus = [] messages = invocation.getSelectedMessages() if messages: items = self.interpreter.getLocals().get('items', []) context = 'Assign' if not items else 'Append' menu = JMenuItem("%s to local variable items in Console" % (context, )) menu.addActionListener(AssignLocalsActionListener(self, 'items', messages)) menus.append(menu) return menus
def createMenuItems(self, invocation): messages = invocation.getSelectedMessages() def addRequestsToTab(e): for messageInfo in messages: # saveBuffers is required since modifying the original from its source changes the saved objects, its not a copy messageIndex = self._db.createNewMessage(self._callbacks.saveBuffersToTempFiles(messageInfo), self._helpers.analyzeRequest(messageInfo).getUrl()) #self._messageTable.getModel().addRow(row) self._messageTable.redrawTable() ret = [] menuItem = JMenuItem("Send request(s) to AuthMatrix"); menuItem.addActionListener(addRequestsToTab) ret.append(menuItem) return(ret)
def __init__(self): self.fMap = { IRequestInfo.CONTENT_TYPE_URL_ENCODED : self.handleURLEncoded, IRequestInfo.CONTENT_TYPE_JSON : self.handleJSON, IRequestInfo.CONTENT_TYPE_XML: self.handleXML, IRequestInfo.CONTENT_TYPE_NONE : self.handleNone, IRequestInfo.CONTENT_TYPE_UNKNOWN : self.handleNone } self.menuItem = JMenuItem('curlit') self.menuItem.addActionListener(self)
def DisplayStreetTable (collection): columns=list( ( ("Name","name"), ) ) tm= ObjectTableModel(collection,columns) frame = MyFrame("Street Table") frame.setSize(800, 1200) frame.setLayout(BorderLayout()) table = JTable(tm) table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS) header = table.getTableHeader() header.setUpdateTableInRealTime(True) header.setReorderingAllowed(True); scrollPane = JScrollPane() scrollPane.getViewport().setView((table)) # copyButton = JButton('Merge') #,actionPerformed=self.noAction # frame.add(copyButton) listener=MyListener(table) table.addMouseListener(listener) table.addKeyListener(listener) menubar = JMenuBar() file = JMenu("Edit") file.setMnemonic(KeyEvent.VK_E) lookup = JMenuItem("Lookup",actionPerformed=frame.LookupEvent) lookup.setMnemonic(KeyEvent.VK_L) file.add(lookup) menubar.add(file) frame.setJMenuBar(menubar) frame.add(scrollPane) frame.pack(); frame.setSize(frame.getPreferredSize()); frame.show()
class BurpExtender(IBurpExtender, IContextMenuFactory, ActionListener): def __init__(self): self.menuItem = JMenuItem('sqldude') self.menuItem.addActionListener(self) def _build(self): #Grab first selected message, bail if none iRequestInfo = self._helpers.analyzeRequest(self.ctxMenuInvocation.getSelectedMessages()[0]) if iRequestInfo is None: print('Request info object is null, bailing') return #print(len(iRequestInfo.getParameters())) #for i in iRequestInfo.getParameters(): # print(i.getName()) #print('cookies: ' + ''.join(cookies)) #parms = [i for i in iRequestInfo.getParameters() if i.getType() == IParameter.PARAM_BODY] parms = filter(lambda x: x.getType() == IParameter.PARAM_BODY, iRequestInfo.getParameters()) cookies = filter(lambda x: x.getType() == IParameter.PARAM_COOKIE, iRequestInfo.getParameters()) #print('parms ' + ''.join(parms)) payload = 'sqlmap -u \'%s\' --cookies=\'%s\'' % (iRequestInfo.getUrl(), ';'.join([('%s=%s' % (c.getName(),c.getValue())) for c in cookies ]) ) if len(parms) > 0: p = ['%s=%s' % (p.getName(), p.getValue()) for p in parms] payload = '%s --data=\'%s\'' % (payload, '&'.join(p)) #print('Found Cookies:\n\t' + '\n\t'.join([('%s=%s' % (c.getName(), c.getValue())) for c in cookies])) s = StringSelection(payload) Toolkit.getDefaultToolkit().getSystemClipboard().setContents(s,s) #put string on clipboard print(payload) def actionPerformed(self, actionEvent): self._build() def registerExtenderCallbacks(self, callbacks): self._helpers = callbacks.getHelpers() callbacks.setExtensionName('sqldude') callbacks.registerContextMenuFactory(self) self.mCallBacks = callbacks print('sqldude up') return def createMenuItems(self, ctxMenuInvocation): self.ctxMenuInvocation = ctxMenuInvocation return [self.menuItem]
def createItems(self, menuItems): items = [] #Refer to MenuView's menuItems dictionary where each menu item has an #array of two elements, the first is the key event and the second is the #action asigned to the menu item def getMethod(name): return menuItems[name][1] def getKeyEvent(name): return menuItems[name][0] for name, keyEvent in menuItems.items(): item = JMenuItem(name, actionPerformed = getattr(self.menuView.controller, getMethod(name))) item.setMnemonic(getKeyEvent(name)) items.append(item) return items
def initTabs(self): # ## init autorize tabs # self.logTable = Table(self) self._splitpane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT) self._splitpane.setResizeWeight(1) self.scrollPane = JScrollPane(self.logTable) self._splitpane.setLeftComponent(self.scrollPane) self.scrollPane.getVerticalScrollBar().addAdjustmentListener(autoScrollListener(self)) self.menuES0 = JCheckBoxMenuItem(self._enfocementStatuses[0],True) self.menuES1 = JCheckBoxMenuItem(self._enfocementStatuses[1],True) self.menuES2 = JCheckBoxMenuItem(self._enfocementStatuses[2],True) self.menuES0.addItemListener(menuTableFilter(self)) self.menuES1.addItemListener(menuTableFilter(self)) self.menuES2.addItemListener(menuTableFilter(self)) copyURLitem = JMenuItem("Copy URL"); copyURLitem.addActionListener(copySelectedURL(self)) self.menu = JPopupMenu("Popup") self.menu.add(copyURLitem) self.menu.add(self.menuES0) self.menu.add(self.menuES1) self.menu.add(self.menuES2) self.tabs = JTabbedPane() self._requestViewer = self._callbacks.createMessageEditor(self, False) self._responseViewer = self._callbacks.createMessageEditor(self, False) self._originalrequestViewer = self._callbacks.createMessageEditor(self, False) self._originalresponseViewer = self._callbacks.createMessageEditor(self, False) self.tabs.addTab("Modified Request", self._requestViewer.getComponent()) self.tabs.addTab("Modified Response", self._responseViewer.getComponent()) self.tabs.addTab("Original Request", self._originalrequestViewer.getComponent()) self.tabs.addTab("Original Response", self._originalresponseViewer.getComponent()) self.tabs.addTab("Configuration", self.pnl) self.tabs.setSelectedIndex(4) self._splitpane.setRightComponent(self.tabs)
def handleMouseEvent(self, event): if event.isPopupTrigger(): loadMenu = JMenuItem("Load .proto") loadMenu.addActionListener(self.tab.listener) popup = JPopupMenu() popup.add(loadMenu) if self.tab.descriptors: deserializeAsMenu = JMenu("Deserialize As...") popup.addSeparator() popup.add(deserializeAsMenu) for pb2, descriptors in self.tab.descriptors.iteritems(): subMenu = JMenu(pb2) deserializeAsMenu.add(subMenu) for name, descriptor in descriptors.iteritems(): protoMenu = JMenuItem(name) protoMenu.addActionListener( DeserializeProtoActionListener(self.tab, descriptor)) subMenu.add(protoMenu) popup.show(event.getComponent(), event.getX(), event.getY()) return
def createMenuItems(self, invocation): ''' Invoked by Burp when a right-click menu is created; adds Git Bridge's options to the menu. ''' context = invocation.getInvocationContext() tool = invocation.getToolFlag() if tool == self.callbacks.TOOL_REPEATER: if context in [invocation.CONTEXT_MESSAGE_EDITOR_REQUEST, invocation.CONTEXT_MESSAGE_VIEWER_RESPONSE]: item = JMenuItem("Send to Git Bridge") item.addActionListener(self.RepeaterHandler(self.callbacks, invocation, self.log)) items = ArrayList() items.add(item) return items elif tool == self.callbacks.TOOL_SCANNER: if context in [invocation.CONTEXT_SCANNER_RESULTS]: item = JMenuItem("Send to Git Bridge") item.addActionListener(self.ScannerHandler(self.callbacks, invocation, self.log)) items = ArrayList() items.add(item) return items else: # TODO: add support for other tools pass
def actionPerformed(self, event): messages = self.browser.getSelectedMessages() numMessages = messages.size() if numMessages == 0: self.browser.showInformationDialog("No messages selected") return if numMessages > 1: self.browser.showInformationDialog("%d messages selected, choose one" % numMessages) return message = messages.get(0) replyToId = message.getJMSMessageID() replyToQueue0 = message.getJMSReplyTo() if replyToQueue0 != None: replyToQueue0 = replyToQueue0.getQueueName() p = Pattern.compile("[^\\s:/]+://[^\\s:/]*/([^\\s:/?]+)\\??.*") m = p.matcher(replyToQueue0) if m.matches(): replyToQueue0 = m.group(1) else: replyToQueue0 = None dNode = self.browser.getBrowserTree().getFirstSelectedDestinationNode() hNode = self.browser.getBrowserTree().getSelectedHermesNode() if dNode == None or hNode == None: self.browser.showInformationDialog("Unknown destination, select destination queue") return hermes = hNode.getHermes() replyToQueue1 = dNode.getDestinationName() replyToDomain = dNode.getDomain() if replyToQueue0 == None and replyToQueue1 == None: self.browser.showInformationDialog("Unknown destination, select destination queue") return # show menu if replyToQueue0 != None and replyToQueue1 != None and replyToQueue0 != replyToQueue1: menu = JPopupMenu() q0item = JMenuItem(replyToQueue0) q0item.addActionListener(MenuItemHandler(self, hermes, replyToId, replyToQueue0, replyToDomain)) menu.add(q0item) q1item = JMenuItem(replyToQueue1) q1item.addActionListener(MenuItemHandler(self, hermes, replyToId, replyToQueue1, replyToDomain)) menu.add(q1item) menu.show(self.button, 0, self.button.getHeight()) return # show new message dialog else: if replyToQueue0 != None: replyToQueue = replyToQueue0 else: replyToQueue = replyToQueue1 self.replyTo(hermes, replyToId, replyToQueue, replyToDomain)
def createMenuItems(self, invocation): responses = invocation.getSelectedMessages(); if responses > 0: ret = LinkedList() requestMenuItem = JMenuItem("Send request to Autorize"); cookieMenuItem = JMenuItem("Send cookie to Autorize"); requestMenuItem.addActionListener(handleMenuItems(self,responses[0], "request")) cookieMenuItem.addActionListener(handleMenuItems(self, responses[0], "cookie")) ret.add(requestMenuItem); ret.add(cookieMenuItem); return(ret); return null;
def createAction(callback, name, description=None, menu=None, mnemonic=None, accelerator=None, toolBar=None, menuItemType="standard"): action = CallbackAction(callback, name, description) if menu: if menuItemType == "standard": menuItem = JMenuItem(action) elif menuItemType == "checkbox": menuItem = JCheckBoxMenuItem(action) elif menuItemType == "radiobutton": menuItem = JRadioButtonMenuItem(action) else: internal_error("unsupported menu item type %s" % `menuItemType`) menuItem = JMenuItem(action) if mnemonic: menuItem.setMnemonic(mnemonic) if accelerator: menuItem.setAccelerator(KeyStroke.getKeyStroke(ord(accelerator), Event.CTRL_MASK, 0)) menu.add(menuItem) action.setMenuItem(menuItem) if toolBar: toolbarButton = JButton(action) toolBar.add(toolbarButton) return action
def __init__(self, view, name, func, args=(), filter=True, ylimits=(-1.0, 1.0), label=None, nodeid=None): self.fixed_value = None self.cache = {} self.cache_dt_tau = None self.cache_tick_count = 0 graph.Graph.__init__(self, view, name, func, args=args, filter=filter, ylimits=ylimits, split=False, neuronmapped=False, label=label) self.border_top = 30 self.vocab = hrr.Vocabulary.registered.get(nodeid, None) if self.vocab is None: dim = len(self.data.get_first()) if dim in hrr.Vocabulary.defaults.keys(): self.vocab = hrr.Vocabulary.defaults[dim] else: self.vocab = hrr.Vocabulary(dim) self.hidden_pairs = None self.normalize = True self.popup_normalize = JCheckBoxMenuItem('normalize', self.normalize, stateChanged=self.toggle_normalize) self.popup.add(self.popup_normalize) self.smooth_normalize = False self.popup_smooth = JCheckBoxMenuItem('smooth normalize', self.smooth_normalize, stateChanged=self.toggle_smooth_normalize) self.smooth_normalize_threshold = 0.4 self.popup.add(self.popup_smooth) self.show_pairs = False self.popup_pairs = JCheckBoxMenuItem('show pairs', self.show_pairs, stateChanged=self.toggle_show_pairs) self.popup.add(self.popup_pairs) self.show_graph = True self.popup_graph = JCheckBoxMenuItem('show graph', self.show_graph, stateChanged=self.toggle_show_graph) self.popup.add(self.popup_graph) self.font_height_50 = None self.popup_set = JMenuItem('set value', actionPerformed=self.set_value) self.popup.add(self.popup_set) self.popup_release = JMenuItem('release value', actionPerformed=self.release_value) self.popup_release.setEnabled(False) self.popup.add(self.popup_release)
def draw(self): """ init autorize tabs """ self._extender.logTable = Table(self._extender) tableWidth = self._extender.logTable.getPreferredSize().width self._extender.logTable.getColumn("ID").setPreferredWidth( Math.round(tableWidth / 50 * 2)) self._extender.logTable.getColumn("Method").setPreferredWidth( Math.round(tableWidth / 50 * 3)) self._extender.logTable.getColumn("URL").setPreferredWidth( Math.round(tableWidth / 50 * 25)) self._extender.logTable.getColumn("Orig. Length").setPreferredWidth( Math.round(tableWidth / 50 * 4)) self._extender.logTable.getColumn("Modif. Length").setPreferredWidth( Math.round(tableWidth / 50 * 4)) self._extender.logTable.getColumn("Unauth. Length").setPreferredWidth( Math.round(tableWidth / 50 * 4)) self._extender.logTable.getColumn( "Authorization Enforcement Status").setPreferredWidth( Math.round(tableWidth / 50 * 4)) self._extender.logTable.getColumn( "Authorization Unauth. Status").setPreferredWidth( Math.round(tableWidth / 50 * 4)) self._extender.tableSorter = TableRowSorter(self._extender.tableModel) rowFilter = TableRowFilter(self._extender) self._extender.tableSorter.setRowFilter(rowFilter) self._extender.logTable.setRowSorter(self._extender.tableSorter) self._extender._splitpane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT) self._extender._splitpane.setResizeWeight(1) self._extender.scrollPane = JScrollPane(self._extender.logTable) self._extender._splitpane.setLeftComponent(self._extender.scrollPane) self._extender.scrollPane.getVerticalScrollBar().addAdjustmentListener( AutoScrollListener(self._extender)) copyURLitem = JMenuItem("Copy URL") copyURLitem.addActionListener(CopySelectedURL(self._extender)) sendRequestMenu = JMenuItem("Send Original Request to Repeater") sendRequestMenu.addActionListener( SendRequestRepeater(self._extender, self._extender._callbacks, True)) sendRequestMenu2 = JMenuItem("Send Modified Request to Repeater") sendRequestMenu2.addActionListener( SendRequestRepeater(self._extender, self._extender._callbacks, False)) sendResponseMenu = JMenuItem("Send Responses to Comparer") sendResponseMenu.addActionListener( SendResponseComparer(self._extender, self._extender._callbacks)) retestSelecteditem = JMenuItem("Retest selected request") retestSelecteditem.addActionListener( RetestSelectedRequest(self._extender)) deleteSelectedItem = JMenuItem("Delete") deleteSelectedItem.addActionListener( DeleteSelectedRequest(self._extender)) self._extender.menu = JPopupMenu("Popup") self._extender.menu.add(sendRequestMenu) self._extender.menu.add(sendRequestMenu2) self._extender.menu.add(sendResponseMenu) self._extender.menu.add(copyURLitem) self._extender.menu.add(retestSelecteditem) # self.menu.add(deleteSelectedItem) disabling this feature until bug will be fixed. message_editor = MessageEditor(self._extender) self._extender.tabs = JTabbedPane() self._extender._requestViewer = self._extender._callbacks.createMessageEditor( message_editor, False) self._extender._responseViewer = self._extender._callbacks.createMessageEditor( message_editor, False) self._extender._originalrequestViewer = self._extender._callbacks.createMessageEditor( message_editor, False) self._extender._originalresponseViewer = self._extender._callbacks.createMessageEditor( message_editor, False) self._extender._unauthorizedrequestViewer = self._extender._callbacks.createMessageEditor( message_editor, False) self._extender._unauthorizedresponseViewer = self._extender._callbacks.createMessageEditor( message_editor, False) self._extender.tabs.addTab( "Modified Request", self._extender._requestViewer.getComponent()) self._extender.tabs.addTab( "Modified Response", self._extender._responseViewer.getComponent()) self._extender.tabs.addTab( "Original Request", self._extender._originalrequestViewer.getComponent()) self._extender.tabs.addTab( "Original Response", self._extender._originalresponseViewer.getComponent()) self._extender.tabs.addTab( "Unauthenticated Request", self._extender._unauthorizedrequestViewer.getComponent()) self._extender.tabs.addTab( "Unauthenticated Response", self._extender._unauthorizedresponseViewer.getComponent()) self._extender.tabs.addTab("Configuration", self._extender.pnl) self._extender.tabs.setSelectedIndex(6) self._extender._splitpane.setRightComponent(self._extender.tabs)
def createMenuItems(self, invocation): menu = [] jmi1 = JMenuItem() jmi1.setText("Send to Results") jm1 = JMenu("Send to Failed Cases") jmi_obj1 = JMenuItem() jmi_obj2 = JMenuItem() jmi_obj3 = JMenuItem() jmi_obj4 = JMenuItem() jmi_obj5 = JMenuItem() jmi_obj6 = JMenuItem() jmi_obj7 = JMenuItem() jmi_obj8 = JMenuItem() jmi_obj9 = JMenuItem() jmi_obj10 = JMenuItem() jmi_obj11 = JMenuItem() jmi_obj12 = JMenuItem() jmi_obj13 = JMenuItem() jmi_obj14 = JMenuItem() jmi_obj15 = JMenuItem() jmi_obj16 = JMenuItem() jmi_obj1.setText("Objective-1") jmi_obj2.setText("Objective-2") jmi_obj3.setText("Objective-3") jmi_obj4.setText("Objective-4") jmi_obj5.setText("Objective-5") jmi_obj6.setText("Objective-6") jmi_obj7.setText("Objective-7") jmi_obj8.setText("Objective-8") jmi_obj9.setText("Objective-9") jmi_obj10.setText("Objective-10") jmi_obj11.setText("Objective-11") jmi_obj12.setText("Objective-12") jmi_obj13.setText("Objective-13") jmi_obj14.setText("Objective-14") jmi_obj15.setText("Objective-15") jmi_obj16.setText("Objective-16") jmi1.setVisible(True) jmi1.addActionListener(self) menu.append(jmi1) if(self._itabobject.getAppRating()=="Low"): jm1.add(jmi_obj1) jm1.add(jmi_obj2) jm1.add(jmi_obj3) jm1.add(jmi_obj4) jm1.add(jmi_obj5) menu.append(jm1) elif(self._itabobject.getAppRating()=="High"): jm1.add(jmi_obj1) jm1.add(jmi_obj2) jm1.add(jmi_obj3) jm1.add(jmi_obj4) jm1.add(jmi_obj5) jm1.add(jmi_obj6) jm1.add(jmi_obj7) jm1.add(jmi_obj8) jm1.add(jmi_obj9) jm1.add(jmi_obj10) jm1.add(jmi_obj11) jm1.add(jmi_obj12) jm1.add(jmi_obj13) jm1.add(jmi_obj14) jm1.add(jmi_obj15) jm1.add(jmi_obj16) menu.append(jm1) else: menu = [] return menu
def menu_with_accelerator(menuText, accelerator_pair): menu = JMenuItem(menuText) menu.setAccelerator(KeyStroke.getKeyStroke(*accelerator_pair)) return menu
def __init__(self, text="Open in GraphIQL Console"): self.menuitem = JMenuItem(text) self.menuitem.setEnabled(False) self.menuitem.addActionListener(self) self.lookup = {}
def extendPluginMenu(self, frame): return [JMenuItem(MessageAction(self.pi, frame))]
def createMenuItems(self, context_menu): self.context = context_menu menu_list = ArrayList() menu_list.add( JMenuItem("Create Wordlist", actionPerformed=self.wordlist_menu)) return menu_list
def __init__(self, text=None): self.menuitem = JMenuItem(text) self.menuitem.setEnabled(False)
def __init__(self): self.menuItem = JMenuItem('Generate betterXSS PoC') self.menuItem.addActionListener(self)
class BurpExtender(IBurpExtender, ITab, IMessageEditorController, IContextMenuFactory, ActionListener, AbstractTableModel, Runnable): # # Implement IBurpExtender # def registerExtenderCallbacks(self, callbacks): # Initialize the global stdout stream global stdout # Keep a reference to our callbacks object self._callbacks = callbacks # Obtain an extension helpers object self._helpers = callbacks.getHelpers() # set our extension name callbacks.setExtensionName("Burpsuite Yara Scanner") # Create the log and a lock on which to synchronize when adding log entries self._log = ArrayList() self._lock = Lock() # main split pane splitpane = JSplitPane(JSplitPane.VERTICAL_SPLIT) # table of log entries logTable = Table(self) scrollPane = JScrollPane(logTable) splitpane.setLeftComponent(scrollPane) # Options panel optionsPanel = JPanel() optionsPanel.setLayout(GridBagLayout()) constraints = GridBagConstraints() yara_exe_label = JLabel("Yara Executable Location:") constraints.fill = GridBagConstraints.HORIZONTAL constraints.gridx = 0 constraints.gridy = 0 optionsPanel.add(yara_exe_label, constraints) self._yara_exe_txtField = JTextField(25) constraints.fill = GridBagConstraints.HORIZONTAL constraints.gridx = 1 constraints.gridy = 0 optionsPanel.add(self._yara_exe_txtField, constraints) yara_rules_label = JLabel("Yara Rules File:") constraints.fill = GridBagConstraints.HORIZONTAL constraints.gridx = 0 constraints.gridy = 1 optionsPanel.add(yara_rules_label, constraints) self._yara_rules_files = Vector() self._yara_rules_files.add("< None >") self._yara_rules_fileList = JList(self._yara_rules_files) constraints.fill = GridBagConstraints.HORIZONTAL constraints.gridx = 1 constraints.gridy = 1 optionsPanel.add(self._yara_rules_fileList, constraints) self._yara_rules_select_files_button = JButton("Select Files") self._yara_rules_select_files_button.addActionListener(self) constraints.fill = GridBagConstraints.HORIZONTAL constraints.gridx = 1 constraints.gridy = 2 optionsPanel.add(self._yara_rules_select_files_button, constraints) self._yara_clear_button = JButton("Clear Yara Results Table") self._yara_clear_button.addActionListener(self) constraints.fill = GridBagConstraints.HORIZONTAL constraints.gridx = 1 constraints.gridy = 3 optionsPanel.add(self._yara_clear_button, constraints) # Tabs with request/response viewers viewerTabs = JTabbedPane() self._requestViewer = callbacks.createMessageEditor(self, False) self._responseViewer = callbacks.createMessageEditor(self, False) viewerTabs.addTab("Request", self._requestViewer.getComponent()) viewerTabs.addTab("Response", self._responseViewer.getComponent()) splitpane.setRightComponent(viewerTabs) # Tabs for the Yara output and the Options self._mainTabs = JTabbedPane() self._mainTabs.addTab("Yara Output", splitpane) self._mainTabs.addTab("Options", optionsPanel) # customize our UI components callbacks.customizeUiComponent(splitpane) callbacks.customizeUiComponent(logTable) callbacks.customizeUiComponent(scrollPane) callbacks.customizeUiComponent(viewerTabs) callbacks.customizeUiComponent(self._mainTabs) # add the custom tab to Burp's UI callbacks.addSuiteTab(self) # add ourselves as a context menu factory callbacks.registerContextMenuFactory(self) # Custom Menu Item self.menuItem = JMenuItem("Scan with Yara") self.menuItem.addActionListener(self) # obtain our output stream stdout = PrintWriter(callbacks.getStdout(), True) # Print a startup notification stdout.println("Burpsuite Yara scanner initialized.") # # Implement ITab # def getTabCaption(self): return "Yara" def getUiComponent(self): return self._mainTabs # # Implement IContextMenuFactory # def createMenuItems(self, invocation): if invocation.getInvocationContext() == invocation.CONTEXT_TARGET_SITE_MAP_TREE: self.requestResponses = invocation.getSelectedMessages() return [self.menuItem] else: self.requestResponses = None return None # # Implement Action # def actionPerformed(self, actionEvent): global yara_rules global yara_path if actionEvent.getSource() is self.menuItem: yara_path = self._yara_exe_txtField.getText() yara_rules = self._yara_rules_files t = Thread(self) t.start() elif actionEvent.getSource() is self._yara_clear_button: # Delete the LogEntry objects from the log row = self._log.size() self._lock.acquire() self._log.clear() # Update the Table self.fireTableRowsDeleted(0, row) # Clear data regarding any selected LogEntry objects from the request / response viewers self._requestViewer.setMessage([], True) self._responseViewer.setMessage([], False) self._currentlyDisplayedItem = None self._lock.release() elif actionEvent.getSource() is self._yara_rules_select_files_button: fileChooser = JFileChooser() yarFilter = FileNameExtensionFilter("Yara Rules", ["yar"]) fileChooser.addChoosableFileFilter(yarFilter) fileChooser.setFileFilter(yarFilter) fileChooser.setMultiSelectionEnabled(True) fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY) ret = fileChooser.showOpenDialog(None) if ret == JFileChooser.APPROVE_OPTION: self._yara_rules_files.clear() for file in fileChooser.getSelectedFiles(): self._yara_rules_files.add(file.getPath()) self._yara_rules_fileList.setListData(self._yara_rules_files) else: stdout.println("Unknown Event Received.") # # Implement Runnable # def run(self): self.yaraScan() # # Extend AbstractTableModel # def getRowCount(self): try: return self._log.size() except: return 0 def getColumnCount(self): return 2 def getColumnName(self, columnIndex): if columnIndex == 0: return "Rule Name" if columnIndex == 1: return "URL" return "" def getValueAt(self, rowIndex, columnIndex): logEntry = self._log.get(rowIndex) if columnIndex == 0: return logEntry._ruleName if columnIndex == 1: return logEntry._url.toString() return "" # # Implement IMessageEditorController # this allows our request/response viewers to obtain details about the messages being displayed # def getHttpService(self): return self._currentlyDisplayedItem.getHttpService() def getRequest(self): return self._currentlyDisplayedItem.getRequest() def getResponse(self): return self._currentlyDisplayedItem.getResponse() # # Implement the Yara scanning logic # def yaraScan(self): # If stdout has not yet been initialized, punt. if stdout is None: return # If the location of the yara executable and rules files are NULL, punt. if yara_rules is None or yara_path is None or yara_rules.size() == 0 or yara_rules.contains("< None >") or len(yara_path) == 0: JOptionPane.showMessageDialog(None, "Error: Please specify the path to the yara executable and rules file in " "the options tab.") return # If iRequestResponses is None, punt. if self.requestResponses is None: JOptionPane.showMessageDialog(None, "Error: No Request/Responses were selected.") return else: stdout.println("Processing %d item(s)." % len(self.requestResponses)) # Get the OS temp folder os_name = System.getProperty("os.name").lower() temp_folder = None if "linux" in os_name: temp_folder = "/tmp" elif "windows" in os_name: temp_folder = os.environ.get("TEMP") if temp_folder is None: temp_folder = os.environ.get("TMP") if temp_folder is None: stdout.println("Error: Could not determine TEMP folder location.") return # Keep track of the number of matches. matchCount = 0 # Process the site map selected messages for idx, iRequestResponse in enumerate(self.requestResponses): # Process the request request = iRequestResponse.getRequest() if request is not None: if len(request) > 0: try: # Yara does not support scanning from stdin so we will need to create a temp file and scan it req_filename = os.path.join(temp_folder, "req_" + str(idx) + ".tmp") req_file = open(req_filename, "wb") req_file.write(request) req_file.close() for rules in yara_rules: yara_req_output = subprocess.check_output([yara_path, rules, req_filename]) if yara_req_output is not None and len(yara_req_output) > 0: ruleName = (yara_req_output.split())[0] self._lock.acquire() row = self._log.size() # TODO: Don't add duplicate items to the table self._log.add(LogEntry(ruleName, iRequestResponse, self._helpers.analyzeRequest(iRequestResponse).getUrl())) self.fireTableRowsInserted(row, row) self._lock.release() matchCount += 1 except Exception as e: JOptionPane.showMessageDialog(None, "Error running Yara. Please check your configuration and rules.") return finally: # Remove the temp file if req_file is not None: req_file.close() os.remove(req_filename) # Process the response response = iRequestResponse.getResponse() if response is not None: if len(response) > 0: try: # Yara does not support scanning from stdin so we will need to create a temp file and scan it resp_filename = os.path.join(temp_folder, "resp_" + str(idx) + ".tmp") resp_file = open(resp_filename, "wb") resp_file.write(response) resp_file.close() for rules in yara_rules: yara_resp_output = subprocess.check_output([yara_path, rules, resp_filename]) if yara_resp_output is not None and len(yara_resp_output) > 0: ruleName = (yara_resp_output.split())[0] self._lock.acquire() row = self._log.size() # TODO: Don't add duplicate items to the table self._log.add(LogEntry(ruleName, iRequestResponse, self._helpers.analyzeRequest(iRequestResponse).getUrl())) self.fireTableRowsInserted(row, row) self._lock.release() matchCount += 1 except Exception as e: JOptionPane.showMessageDialog(None, "Error running Yara. Please check your configuration and rules.") return finally: # Remove the temp file if resp_file is not None: resp_file.close() os.remove(resp_filename) # Print a completion notification JOptionPane.showMessageDialog(None, "Yara scanning complete. %d rule(s) matched." % matchCount)
def createMenuItems(self, context_menu): self.context = context_menu menu_list = ArrayList() menu_list.add(JMenuItem("Send to Bing", actionPerformed=self.bing_menu)) #hangi http isteginin secildigini belirlemek icin kullacagimiz bir IContextMenu.. nesnesini alacak olan createMenultem islevimizi kurmaktir. menu ogesi olusturur ve bing_menu islevinin click olayini islemesini saglamaktir return menu_list
def createMenuItems(self, invocation): mainMenu = JMenuItem('History To Log', actionPerformed=self.menuOnClick) return [mainMenu]
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 menu(self): f = JMenu("File") o = JMenuItem("Copy") o.addActionListener(ActionEventListener(self.opencopy)) self.open = o f.add(o) o = JMenuItem("New") o.addActionListener(ActionEventListener(self.new)) self.open = o f.add(o) o = JMenuItem("Open") o.addActionListener(ActionEventListener(self.opendialog)) self.open = o f.add(o) o = JMenuItem("Save") o.addActionListener(ActionEventListener(self.save)) self.open = o f.add(o) o = JMenuItem("Save As") o.addActionListener(ActionEventListener(self.saveas)) self.open = o f.add(o) return f
def run(scene, w=512, h=512, aa=1, threads=1): """Create GUI and perform ray-tracing.""" # Make Swing not look like garbage (so much) UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) # Setup frame frame = JFrame("RayTracer", defaultCloseOperation=JFrame.EXIT_ON_CLOSE, size=(w, h)) frame.setIconImage(ImageIcon("resources/icon.png").getImage()) canvas = RayTracePanel(w, h, aa, threads) frame.getContentPane().add(JScrollPane(canvas)) # Save FileChooser fcS = JFileChooser() fcS.addChoosableFileFilter(FileNameExtensionFilter("Windows Bitmap (*.bmp)", ["bmp"])) fcS.addChoosableFileFilter(FileNameExtensionFilter("JPEG / JFIF (*.jpg)", ["jpg"])) fcS.addChoosableFileFilter(FileNameExtensionFilter("Portable Network Graphics (*.png)", ["png"])) def saveFile(event): """Performed when the save button is pressed""" result = fcS.showSaveDialog(frame) if result == JFileChooser.APPROVE_OPTION: file = fcS.getSelectedFile() fname = file.getPath() ext = fcS.getFileFilter().getExtensions()[0] if not fname.endswith("." + ext): file = File(fname + "." + ext) canvas.saveToFile(file, ext) # Open FileChooser fcO = JFileChooser() fcO.addChoosableFileFilter(FileNameExtensionFilter("RayTrace Scene File (*.rts)", ["rts"])) def openFile(event): """Performed when the open button is pressed""" result = fcO.showOpenDialog(frame) if result == JFileChooser.APPROVE_OPTION: fname = fcO.getSelectedFile().getPath() if fname.endswith(".rts"): f = open(fname, "rb") newScene = SceneFactory().buildScene(f) f.close() Painter(canvas, newScene, openButton, saveButton, stopButton).start() def exit(event): """Performed when the exit button is pressed""" import sys sys.exit(0) def stop(event): """Peformed when the stop button is pressed""" canvas.stopRendering() # Setup Menu menuBar = JMenuBar() menu = JMenu("File") menuBar.add(menu) openButton = JMenuItem("Open...", actionPerformed=openFile) openButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)) menu.add(openButton) saveButton = JMenuItem("Save as...", actionPerformed=saveFile) saveButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)) menu.add(saveButton) menu.addSeparator() stopButton = JMenuItem("Stop Render", actionPerformed=stop) stopButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)) stopButton.setEnabled(False) menu.add(stopButton) menu.addSeparator() closeButton = JMenuItem("Close", actionPerformed=exit) closeButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK)) menu.add(closeButton) frame.setJMenuBar(menuBar) # Finish initializing GUI self.pack()
def __init__(self, app, menuTitle): JMenu.__init__(self, menuTitle) self.app = app #quat dialog item dialogItem = JCheckBoxMenuItem(self.app.dlg.toggleAction) self.add(dialogItem) self.addSeparator() #tool submenu for tool in self.app.tools: if tool.name == "favourites": self.addSeparator() toolMenu = JMenu(tool.title) toolMenu.setIcon(tool.bigIcon) if tool.uri != "": #Website link iconFile = File.separator.join( [self.app.SCRIPTDIR, "images", "icons", "browser.png"]) urlItem = JMenuItem(tool.title) urlItem.setIcon(ImageIcon(iconFile)) urlItem.addActionListener( QatMenuActionListener(self.app, "link", tool)) toolMenu.add(urlItem) toolMenu.addSeparator() #View submenu for view in tool.views: viewMenu = JMenu(view.title) if tool.name == "favourites": self.app.favouritesMenu = viewMenu #Check item for check in view.checks: self.add_check_item(tool, view, check, viewMenu) toolMenu.add(viewMenu) self.add(toolMenu) #Local file with errors localFileItem = JMenuItem(self.app.strings.getString("Open_GPX")) localFileItem.setIcon(ImageProvider.get("open")) localFileItem.addActionListener( QatMenuActionListener(self.app, "local file")) self.add(localFileItem) self.addSeparator() #False positive dialog falsepositiveItem = JMenuItem( self.app.strings.getString("False_positives...")) falsepositiveItem.addActionListener( QatMenuActionListener(self.app, "dialog")) self.add(falsepositiveItem) #Preferences dialog preferencesItem = JMenuItem( self.app.strings.getString("Preferences...")) preferencesItem.addActionListener( QatMenuActionListener(self.app, "dialog")) self.add(preferencesItem) #About dialog item aboutItem = JMenuItem(self.app.strings.getString("About...")) aboutItem.addActionListener(QatMenuActionListener(self.app, "dialog")) self.add(aboutItem)
class BurpExtender(IBurpExtender, IContextMenuFactory, ActionListener): def __init__(self): self.menuItem = JMenuItem('Generate betterXSS PoC') self.menuItem.addActionListener(self) def _build(self): #Grab first selected message, bail if none iRequestInfo = self._helpers.analyzeRequest( self.ctxMenuInvocation.getSelectedMessages()[0]) if iRequestInfo is None: print('Request info object is null, bailing') return method = iRequestInfo.getMethod() url = iRequestInfo.getUrl() parms = filter(lambda x: x.getType() == IParameter.PARAM_BODY, iRequestInfo.getParameters()) #print('parms ' + ''.join(parms)) c = iRequestInfo.getContentType() if (c == -1): print 'error: unknown content type' elif (c == 0): print 'error: no content type' elif (c == 1): enc = 'application/x-www-form-urlencoded' if len(parms) > 0: p = ['%s=%s' % (p.getName(), p.getValue()) for p in parms] postData = '%s' % ('&'.join(p)) elif (c == 2): enc = 'multipart/form-data' if len(parms) > 0: p = ['%s=%s' % (p.getName(), p.getValue()) for p in parms] postData = '%s' % ('&'.join(p)) elif (c == 3): enc = 'text/xml' elif (c == 4): enc = 'application/json' elif (c == 5): p = ['%s:%s' % (p.getName(), p.getValue()) for p in parms] enc = 'application/x-amf' base = ''' <!-- betterXSS PoC - generated with love by thatpentestguy --> <script> function sendRequest(method, url, enc, postData) { var req = createXMLHTTPObject(); if (!req) return; req.open(method,url,true); if (typeof enc !== 'undefined'){ req.setRequestHeader('Content-type', enc) } req.onreadystatechange = function () { if (req.readyState != 4) return; if (req.status != 200 && req.status != 304) { return; } } if (req.readyState == 4) return; (typeof postData === 'undefined') ? req.send() : req.send(postData); } var XMLHttpFactories = [ function () {return new XMLHttpRequest()}, function () {return new ActiveXObject("Msxml2.XMLHTTP")}, function () {return new ActiveXObject("Msxml3.XMLHTTP")}, function () {return new ActiveXObject("Microsoft.XMLHTTP")} ]; function createXMLHTTPObject() { var xmlhttp = false; for (var i=0;i<XMLHttpFactories.length;i++) { try { xmlhttp = XMLHttpFactories[i](); } catch (e) { continue; } break; } return xmlhttp; }''' if (1 <= c <= 5): base = base + 'sendRequest(\'%s\',\'%s\',\'%s\',\'%s\');' % ( method, url, enc, postData) else: base = base + 'sendRequest(\'%s\',\'%s\');' % (method, url) base = base + '\n</script>' s = StringSelection(base) Toolkit.getDefaultToolkit().getSystemClipboard().setContents( s, s) #put string on clipboard print(base) def actionPerformed(self, actionEvent): self._build() def registerExtenderCallbacks(self, callbacks): self._helpers = callbacks.getHelpers() callbacks.setExtensionName('betterXSS') callbacks.registerContextMenuFactory(self) self.mCallBacks = callbacks print('betterXSS successfully loaded') return def createMenuItems(self, ctxMenuInvocation): self.ctxMenuInvocation = ctxMenuInvocation return [self.menuItem]
def createMenuItems(self, ctxMenuInvocation): self._ctxMenuInvocation = ctxMenuInvocation menuItems = ArrayList() menuItems.add(JMenuItem("Save response body", actionPerformed=self.saveResponseBody)) return menuItems
def initMenu(): global glzz tmenu = JMenu("testQ") smellv = JMenuItem("smell view") smellv.actionPerformed = lambda event : SmellView(glzz).go() tmenu.add(smellv) radialv = JMenuItem("radial suite view") radialv.actionPerformed = lambda event : RadialSuiteView(glzz).go() tmenu.add(radialv) treesv = JMenuItem("tree suite view") # treesv.actionPerformed = lambda event : displayTreeSuiteView(glzz) treesv.actionPerformed = lambda event : TreeSuiteView(glzz).go() tmenu.add(treesv) tmenu.add(tcMenu()) smellp = JMenuItem("smell pie") smellp.actionPerformed = lambda event : plotSmellFrequency() tmenu.add(smellp) gbar = Guess.getMainUIWindow().getGMenuBar() gbar.add(tmenu) gbar.getMenu(3).removeAll() # deface the layout menu gbar.revalidate() gbar.repaint()
def createMenuItems(self, context_menu): self.context = context_menu menu_list = ArrayList() menu_list.add(JMenuItem("Send to Bing", actionPerformed=self.bing_menu)) return menu_list
def extendPluginMenu(self): return [JMenuItem(MessageAction(self.pi))]
def registerExtenderCallbacks(self, callbacks): # keep a reference to our callbacks object self._callbacks = callbacks # obtain an extension helpers object self._helpers = callbacks.getHelpers() # set our extension name callbacks.setExtensionName("Burp Scope Monitor") self.GLOBAL_HANDLER_ANALYZED = False self.GLOBAL_HANDLER = False self.STATUS = False self.AUTOSAVE_REQUESTS = 10 self.AUTOSAVE_TIMEOUT = 600 # 10 minutes should be fine self.CONFIG_INSCOPE = True self.BAD_EXTENSIONS_DEFAULT = [ '.gif', '.png', '.js', '.woff', '.woff2', '.jpeg', '.jpg', '.css', '.ico', '.m3u8', '.ts' ] self.BAD_MIMES_DEFAULT = [ 'gif', 'script', 'jpeg', 'jpg', 'png', 'video', 'mp2t' ] self.BAD_EXTENSIONS = self.BAD_EXTENSIONS_DEFAULT self.BAD_MIMES = self.BAD_MIMES_DEFAULT self.repeaterSetting = True # create the log and a lock on which to synchronize when adding log entries self._currentlyDisplayedItem = None self.SELECTED_MODEL_ROW = 0 self.SELECTED_VIEW_ROW = 0 self._log = ArrayList() self._fullLog = ArrayList() self._lock = Lock() self._lockFile = Lock() # main split pane self._parentPane = JTabbedPane() self._splitpane = JSplitPane(JSplitPane.VERTICAL_SPLIT) ##### config pane self._config = JTabbedPane() config = JPanel() iexport = JPanel() #config.setLayout(BorderLayout()) config.setLayout(None) iexport.setLayout(None) # config radio button X_BASE = 40 Y_OFFSET = 5 Y_OPTION = 200 Y_OPTION_SPACING = 20 Y_CHECKMARK_SPACING = 20 self.showAllButton = JRadioButton(SHOW_ALL_BUTTON_LABEL, True) self.showNewButton = JRadioButton(SHOW_NEW_BUTTON_LABEL, False) self.showTestedButton = JRadioButton(SHOW_TEST_BUTTON_LABEL, False) self.showAllButton.setBounds(40, 60 + Y_OFFSET, 400, 30) self.showNewButton.setBounds(40, 80 + Y_OFFSET, 400, 30) self.showTestedButton.setBounds(40, 100 + Y_OFFSET, 400, 30) #self.showNewButton = JRadioButton(SHOW_NEW_BUTTON_LABEL, False) #self.showTestedButton = JRadioButton(SHOW_TEST_BUTTON_LABEL, False) self.showAllButton.addActionListener(self.handleRadioConfig) self.showNewButton.addActionListener(self.handleRadioConfig) self.showTestedButton.addActionListener(self.handleRadioConfig) self.clearButton = JButton("Clear") self.clearButton.addActionListener(self.handleClearButton) self.clearButton.setBounds(40, 20, 100, 30) self.startButton = JButton(MONITOR_ON_LABEL) self.startButton.addActionListener(self.handleStartButton) self.startButton.setBounds(150, 20, 200, 30) self.badExtensionsLabel = JLabel("Ignore extensions:") self.badExtensionsLabel.setBounds(X_BASE, 150, 200, 30) self.badExtensionsText = JTextArea("") self.loadBadExtensions() self.badExtensionsText.setBounds(X_BASE, 175, 310, 30) self.badExtensionsButton = JButton("Save") self.badExtensionsButton.addActionListener( self.handleBadExtensionsButton) self.badExtensionsButton.setBounds(355, 175, 70, 30) self.badExtensionsDefaultButton = JButton("Load Defaults") self.badExtensionsDefaultButton.addActionListener( self.handleBadExtensionsDefaultButton) self.badExtensionsDefaultButton.setBounds(430, 175, 120, 30) self.badMimesLabel = JLabel("Ignore mime types:") self.badMimesLabel.setBounds(X_BASE, 220, 200, 30) self.badMimesText = JTextArea("") self.loadBadMimes() self.badMimesText.setBounds(X_BASE, 245, 310, 30) self.badMimesButton = JButton("Save") self.badMimesButton.addActionListener(self.handleBadMimesButton) self.badMimesButton.setBounds(355, 245, 70, 30) self.badMimesDefaultButton = JButton("Load Defaults") self.badMimesDefaultButton.addActionListener( self.handleBadMimesDefaultButton) self.badMimesDefaultButton.setBounds(430, 245, 120, 30) self.otherLabel = JLabel("Other:") self.otherLabel.setBounds(40, 300, 120, 30) self.otherLabel2 = JLabel("Other:") self.otherLabel2.setBounds(X_BASE, Y_OPTION, 120, 30) self.autoSaveOption = JCheckBox("Auto save periodically") self.autoSaveOption.setSelected(True) self.autoSaveOption.addActionListener(self.handleAutoSaveOption) self.autoSaveOption.setBounds(X_BASE, Y_OPTION + Y_CHECKMARK_SPACING, 420, 30) self.repeaterOptionButton = JCheckBox( "Repeater request automatically marks as analyzed") self.repeaterOptionButton.setSelected(True) self.repeaterOptionButton.addActionListener( self.handleRepeaterOptionButton) self.repeaterOptionButton.setBounds(50, 330, 420, 30) self.scopeOptionButton = JCheckBox("Follow Burp Target In Scope rules") self.scopeOptionButton.setSelected(True) self.scopeOptionButton.addActionListener(self.handleScopeOptionButton) self.scopeOptionButton.setBounds(50, 350, 420, 30) self.startOptionButton = JCheckBox("Autostart Scope Monitor") self.startOptionButton.setSelected(True) self.startOptionButton.addActionListener(self.handleStartOption) self.startOptionButton.setBounds(50, 350 + Y_OPTION_SPACING, 420, 30) self.markTestedRequestsProxy = JCheckBox( "Color request in Proxy tab if analyzed") self.markTestedRequestsProxy.setSelected(True) self.markTestedRequestsProxy.addActionListener( self.handleTestedRequestsProxy) self.markTestedRequestsProxy.setBounds(50, 350 + Y_OPTION_SPACING * 2, 420, 30) self.markNotTestedRequestsProxy = JCheckBox( "Color request in Proxy tab if NOT analyzed") self.markNotTestedRequestsProxy.setSelected(True) self.markNotTestedRequestsProxy.addActionListener( self.handleNotTestedRequestsProxy) self.markNotTestedRequestsProxy.setBounds(50, 350 + Y_OPTION_SPACING * 3, 420, 30) self.saveButton = JButton("Save now") self.saveButton.addActionListener(self.handleSaveButton) self.saveButton.setBounds(X_BASE + 320, 95, 90, 30) self.loadButton = JButton("Load now") self.loadButton.addActionListener(self.handleLoadButton) self.loadButton.setBounds(X_BASE + 420, 95, 90, 30) self.selectPath = JButton("Select path") self.selectPath.addActionListener(self.selectExportFile) self.selectPath.setBounds(X_BASE + 530, 60, 120, 30) self.selectPathText = JTextArea("") self.selectPathText.setBounds(X_BASE, 60, 510, 30) self.selectPathLabel = JLabel("State file:") self.selectPathLabel.setBounds(X_BASE, 30, 200, 30) bGroup = ButtonGroup() bGroup.add(self.showAllButton) bGroup.add(self.showNewButton) bGroup.add(self.showTestedButton) config.add(self.clearButton) config.add(self.startButton) config.add(self.startOptionButton) config.add(self.showAllButton) config.add(self.showNewButton) config.add(self.showTestedButton) config.add(self.badExtensionsButton) config.add(self.badExtensionsText) config.add(self.badExtensionsLabel) config.add(self.badMimesButton) config.add(self.badMimesText) config.add(self.badMimesLabel) config.add(self.badExtensionsDefaultButton) config.add(self.badMimesDefaultButton) config.add(self.otherLabel) config.add(self.repeaterOptionButton) config.add(self.scopeOptionButton) config.add(self.markTestedRequestsProxy) config.add(self.markNotTestedRequestsProxy) iexport.add(self.saveButton) iexport.add(self.loadButton) iexport.add(self.selectPath) iexport.add(self.selectPathText) iexport.add(self.selectPathLabel) iexport.add(self.otherLabel2) iexport.add(self.autoSaveOption) self._config.addTab("General", config) self._config.addTab("Import/Export", iexport) ##### end config pane self._parentPane.addTab("Monitor", self._splitpane) self._parentPane.addTab("Config", self._config) # table of log entries self.logTable = Table(self) #self.logTable.setDefaultRenderer(self.logTable.getColumnClass(0), ColoredTableCellRenderer(self)) self.logTable.setAutoCreateRowSorter(True) self.logTable.setRowSelectionAllowed(True) renderer = ColoredTableCellRenderer(self) #column = TableColumn(0, 190, renderer, None) print 'Initiating... ' # this could be improved by fetching initial dimensions self.logTable.getColumn("URL").setPreferredWidth(720) # noscope self.logTable.getColumn("URL").setResizable(True) self.logTable.getColumn("Checked").setCellRenderer(renderer) self.logTable.getColumn("Checked").setPreferredWidth(80) self.logTable.getColumn("Checked").setMaxWidth(80) self.logTable.getColumn("Method").setPreferredWidth(120) #self.logTable.getColumn("Method").setMaxWidth(120) self.logTable.getColumn("Method").setResizable(True) self.logTable.getColumn("Time").setPreferredWidth(120) # noscope self.logTable.getColumn("Time").setResizable(True) scrollPane = JScrollPane(self.logTable) self._splitpane.setLeftComponent(scrollPane) # tabs with request/response viewers tabs = JTabbedPane() self._requestViewer = callbacks.createMessageEditor(self, False) self._responseViewer = callbacks.createMessageEditor(self, False) tabs.addTab("Request", self._requestViewer.getComponent()) tabs.addTab("Response", self._responseViewer.getComponent()) self._splitpane.setRightComponent(tabs) ## Row sorter shit #self._tableRowSorterAutoProxyAutoAction = CustomTableRowSorter(self.logTable.getModel()) #self.logTable.setRowSorter(self._tableRowSorterAutoProxyAutoAction) markAnalyzedButton = JMenuItem("Mark Requests as Analyzed") markAnalyzedButton.addActionListener(markRequestsHandler(self, True)) markNotAnalyzedButton = JMenuItem("Mark Requests as NOT Analyzed") markNotAnalyzedButton.addActionListener( markRequestsHandler(self, False)) sendRequestMenu = JMenuItem("Send Request to Repeater") sendRequestMenu.addActionListener(sendRequestRepeater(self)) deleteRequestMenu = JMenuItem("Delete request") deleteRequestMenu.addActionListener(deleteRequestHandler(self)) self.menu = JPopupMenu("Popup") self.menu.add(markAnalyzedButton) self.menu.add(markNotAnalyzedButton) self.menu.add(sendRequestMenu) self.menu.add(deleteRequestMenu) # customize our UI components callbacks.customizeUiComponent(self._parentPane) callbacks.customizeUiComponent(self._splitpane) callbacks.customizeUiComponent(self._config) callbacks.customizeUiComponent(config) callbacks.customizeUiComponent(self.logTable) callbacks.customizeUiComponent(scrollPane) callbacks.customizeUiComponent(tabs) callbacks.registerContextMenuFactory(self) callbacks.registerExtensionStateListener(self) # add the custom tab to Burp's UI callbacks.addSuiteTab(self) # register ourselves as an HTTP listener callbacks.registerHttpListener(self) self.loadConfigs() print "Loaded!" self.SC = sched.scheduler(time.time, time.sleep) self.SCC = self.SC.enter(10, 1, self.autoSave, (self.SC, )) self.SC.run() return
class main(JFrame): def __init__(self): super(main,self).__init__() self.Config() self.windows() self.ruta="" def windows(self): self.setTitle("IDE Meta Compilador") self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) self.setLayout(None) self.setLocationRelativeTo(None) self.setVisible(True) def Config(self): self.panel = JScrollPane() self.txtArea_Principal =JTextArea() self.jScrollPane1 =JScrollPane() self.txtTerminal =JTextArea() self.Menu =JMenuBar() self.menu_Archivo =JMenu() self.menu_Nuevo =JMenuItem() self.menuabrir =JMenuItem() self.menucerrar =JMenuItem() self.menuguardar =JMenuItem() self.menuguardarcomo =JMenuItem() self.menusalir =JMenuItem() self.menu_Edicion =JMenu() self.menu_cortar =JMenuItem() self.menu_copiar =JMenuItem() self.menu_pegar =JMenuItem() self.menu_Tablas =JMenu() self.menu_TablasEstaticas =JMenu() self.submenu_palabrasReservadas =JMenuItem() self.submenu_CaracteresEspeciales =JMenuItem() self.submenu_operadores =JMenu() self.ta_di_conu_enteros =JMenuItem() self.ta_di_conu_reales =JMenuItem() self.ta_di_conu_cientificos =JMenuItem() self.menu_TablaasDinamicas =JMenu() self.submenu_simbolos =JMenuItem() self.submenu_identificadores =JMenuItem() self.submenu_errores =JMenuItem() self.submenu_constantesNumericas =JMenu() self.ta_es_op_aritmeticos =JMenuItem() self.ta_es_op_relacionales =JMenuItem() self.ta_es_op_logicos =JMenuItem() self.submenu_Constantes_No_Numericas =JMenu() self.tab_caracteres =JMenuItem() self.tab_cadenas =JMenuItem() self.menu_Analisis =JMenu() self.ana_lexico =JMenuItem() self.ana_sintactico =JMenuItem() self.ana_semantico =JMenuItem() self.menu_Acerca_de =JMenu() self.btn_integrantes =JMenuItem() ######################### self.jf = JFileChooser() ######################### self.txtArea_Principal.setColumns(20) self.txtArea_Principal.setRows(5) self.txtArea_Principal.setAutoscrolls(False) self.txtArea_Principal.setEnabled(False) self.panel.setViewportView(self.txtArea_Principal) self.getContentPane().add(self.panel) self.panel.setBounds(0, 0, 1080, 450) self.txtTerminal.setColumns(20) self.txtTerminal.setRows(5) self.txtTerminal.setAutoscrolls(False) self.txtTerminal.setFocusable(False) self.jScrollPane1.setViewportView(self.txtTerminal) self.getContentPane().add(self.jScrollPane1) self.jScrollPane1.setBounds(0, 460, 1080, 150) # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU ARCHIVOS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< self.menu_Archivo.setText("Archivo") self.menu_Nuevo.addActionListener(lambda event : self.nuevo(event)) self.menu_Nuevo.setText("Nuevo") self.menu_Archivo.add(self.menu_Nuevo) self.menuabrir.setText("Abrir") self.menuabrir.addActionListener(lambda event : self.abrir(event)) self.menu_Archivo.add(self.menuabrir) self.menucerrar.setText("Cerrar") self.menucerrar.addActionListener(lambda event : self.cerrar(event)) self.menu_Archivo.add(self.menucerrar) self.menuguardar.setText("Guardar") self.menuguardar.addActionListener(lambda event : self.guardar(event)) self.menu_Archivo.add(self.menuguardar) self.menuguardarcomo.setText("Guardar como") self.menuguardarcomo.addActionListener(lambda event : self.guardarcomo(event)) self.menu_Archivo.add(self.menuguardarcomo) self.menusalir.setText("Salir") self.menusalir.addActionListener(lambda event : self.salir(event)) self.menu_Archivo.add(self.menusalir) self.Menu.add(self.menu_Archivo) # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU EDICION<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< self.menu_Edicion.setText("Edicion") self.menu_cortar.setText("Cortar") self.menu_cortar.addActionListener(lambda event : self.cortar(event)) self.menu_Edicion.add(self.menu_cortar) self.menu_copiar.setText("Copiar") self.menu_copiar.addActionListener(lambda event : self.copiar(event)) self.menu_Edicion.add(self.menu_copiar) self.menu_pegar.setText("Pegar") self.menu_pegar.addActionListener(lambda event : self.pegar(event)) self.menu_Edicion.add(self.menu_pegar) self.Menu.add(self.menu_Edicion) # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU TABLAS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< self.menu_Tablas.setText("Tablas") self.menu_TablasEstaticas.setText("Tablas Estaticas") self.submenu_palabrasReservadas.setText("Tabla de palabras reservadas") self.menu_TablasEstaticas.add(self.submenu_palabrasReservadas) self.submenu_CaracteresEspeciales.setText("Tabla de caracteres especiales") self.menu_TablasEstaticas.add(self.submenu_CaracteresEspeciales) self.submenu_operadores.setText("Tabla de operadores") self.ta_es_op_aritmeticos.setText("Aritmeticos") self.submenu_operadores.add(self.ta_es_op_aritmeticos) self.ta_es_op_relacionales.setText("Relacionales") self.submenu_operadores.add(self.ta_es_op_relacionales) self.ta_es_op_logicos.setText("Logicos") self.submenu_operadores.add(self.ta_es_op_logicos) self.menu_TablasEstaticas.add(self.submenu_operadores) self.menu_Tablas.add(self.menu_TablasEstaticas) self.menu_TablaasDinamicas.setText("Tablas Dinamicas") self.submenu_simbolos.setText("Tabla de simbolos") self.menu_TablaasDinamicas.add(self.submenu_simbolos) self.submenu_identificadores.setText("Tabla de identificadores") self.menu_TablaasDinamicas.add(self.submenu_identificadores) self.submenu_errores.setText("Tabla de errores") self.menu_TablaasDinamicas.add(self.submenu_errores) self.submenu_constantesNumericas.setText("Tabla de constantes numericas") self.ta_di_conu_enteros.setText("Enteros") self.ta_di_conu_enteros.addActionListener(lambda event : self.numeroenteros(event)) self.submenu_constantesNumericas.add(self.ta_di_conu_enteros) self.ta_di_conu_reales.setText("Reales") self.ta_di_conu_reales.addActionListener(lambda event : self.numeroreales(event)) self.submenu_constantesNumericas.add(self.ta_di_conu_reales) self.ta_di_conu_cientificos.setText("Cientificos") self.submenu_constantesNumericas.add(self.ta_di_conu_cientificos) self.menu_TablaasDinamicas.add(self.submenu_constantesNumericas) self.submenu_Constantes_No_Numericas.setText("Tabla de constantes no numericas") self.tab_caracteres.setText("Caracteres") self.submenu_Constantes_No_Numericas.add(self.tab_caracteres) self.tab_cadenas.setText("Cadenas") self.submenu_Constantes_No_Numericas.add(self.tab_cadenas) self.menu_TablaasDinamicas.add(self.submenu_Constantes_No_Numericas) self.menu_Tablas.add(self.menu_TablaasDinamicas) self.Menu.add(self.menu_Tablas) # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU ANALISIS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< self.menu_Analisis.setText("Analisis") self.ana_lexico.setText("Lexico") self.ana_lexico.addActionListener(lambda event : self.lexico(event)) self.menu_Analisis.add(self.ana_lexico) self.ana_sintactico.setText("Sintactico") self.ana_sintactico.addActionListener(lambda event : self.sintactico(event)) self.menu_Analisis.add(self.ana_sintactico) self.ana_semantico.setText("Semantico") self.menu_Analisis.add(self.ana_semantico) self.Menu.add(self.menu_Analisis) # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU ACERCA DE<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< self.menu_Acerca_de.setText("Acerca de") self.btn_integrantes.setText("Integrante del proyecto") self.btn_integrantes.addActionListener(lambda event : self.integrantes(event)) self.menu_Acerca_de.add(self.btn_integrantes) self.Menu.add(self.menu_Acerca_de) self.setJMenuBar(self.Menu) self.setBounds(0, 0, 1095, 670) ###################################### def integrantes(self,event): informacion() def cortar(self,event): self.txtArea_Principal.cut() def copiar(self,event): self.txtArea_Principal.copy() def pegar(self,event): self.txtArea_Principal.paste() def salir(self,event): self.dispose() ###################################### def guardarcomo(self,event): pass def guardar(self,event): if self.ruta == "": self.txtTerminal.setText("no hay un directorio abierto") else: agregar(self.ruta,str(self.txtArea_Principal.getText())) def cerrar(self,event): self.txtArea_Principal.setText("") self.txtArea_Principal.setEnabled(False) self.ruta="" def abrir(self,event): self.jf.showOpenDialog(self) self.ruta = self.jf.getSelectedFile() self.txtArea_Principal.setEnabled(True) self.txtArea_Principal.setText(abrir(self.ruta)) def nuevo(self,event): if self.ruta == "": print("no pasa nada") else: print("hay un archivo existente") self.ruta ="" self.txtArea_Principal.setEnabled(True) self.txtArea_Principal.setText("") ###################################### def lexico(self,event): self.txtTerminal.setText("") archivo = open("{}".format(self.ruta),"r") texto = "" for a in prueba(self.txtArea_Principal.getText()): texto += a+"\n" self.txtTerminal.setText(texto) def sintactico(self,event): self.txtTerminal.setText("") texto="" for a in prueba_sintactica(self.txtArea_Principal.getText()): texto +=a+"\n" self.txtTerminal.setText(texto)
def __init__(self, text="Open In Browser"): self.menuitem = JMenuItem(text) self.menuitem.setEnabled(False) self.menuitem.addActionListener(self)
def Config(self): self.panel = JScrollPane() self.txtArea_Principal =JTextArea() self.jScrollPane1 =JScrollPane() self.txtTerminal =JTextArea() self.Menu =JMenuBar() self.menu_Archivo =JMenu() self.menu_Nuevo =JMenuItem() self.menuabrir =JMenuItem() self.menucerrar =JMenuItem() self.menuguardar =JMenuItem() self.menuguardarcomo =JMenuItem() self.menusalir =JMenuItem() self.menu_Edicion =JMenu() self.menu_cortar =JMenuItem() self.menu_copiar =JMenuItem() self.menu_pegar =JMenuItem() self.menu_Tablas =JMenu() self.menu_TablasEstaticas =JMenu() self.submenu_palabrasReservadas =JMenuItem() self.submenu_CaracteresEspeciales =JMenuItem() self.submenu_operadores =JMenu() self.ta_di_conu_enteros =JMenuItem() self.ta_di_conu_reales =JMenuItem() self.ta_di_conu_cientificos =JMenuItem() self.menu_TablaasDinamicas =JMenu() self.submenu_simbolos =JMenuItem() self.submenu_identificadores =JMenuItem() self.submenu_errores =JMenuItem() self.submenu_constantesNumericas =JMenu() self.ta_es_op_aritmeticos =JMenuItem() self.ta_es_op_relacionales =JMenuItem() self.ta_es_op_logicos =JMenuItem() self.submenu_Constantes_No_Numericas =JMenu() self.tab_caracteres =JMenuItem() self.tab_cadenas =JMenuItem() self.menu_Analisis =JMenu() self.ana_lexico =JMenuItem() self.ana_sintactico =JMenuItem() self.ana_semantico =JMenuItem() self.menu_Acerca_de =JMenu() self.btn_integrantes =JMenuItem() ######################### self.jf = JFileChooser() ######################### self.txtArea_Principal.setColumns(20) self.txtArea_Principal.setRows(5) self.txtArea_Principal.setAutoscrolls(False) self.txtArea_Principal.setEnabled(False) self.panel.setViewportView(self.txtArea_Principal) self.getContentPane().add(self.panel) self.panel.setBounds(0, 0, 1080, 450) self.txtTerminal.setColumns(20) self.txtTerminal.setRows(5) self.txtTerminal.setAutoscrolls(False) self.txtTerminal.setFocusable(False) self.jScrollPane1.setViewportView(self.txtTerminal) self.getContentPane().add(self.jScrollPane1) self.jScrollPane1.setBounds(0, 460, 1080, 150) # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU ARCHIVOS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< self.menu_Archivo.setText("Archivo") self.menu_Nuevo.addActionListener(lambda event : self.nuevo(event)) self.menu_Nuevo.setText("Nuevo") self.menu_Archivo.add(self.menu_Nuevo) self.menuabrir.setText("Abrir") self.menuabrir.addActionListener(lambda event : self.abrir(event)) self.menu_Archivo.add(self.menuabrir) self.menucerrar.setText("Cerrar") self.menucerrar.addActionListener(lambda event : self.cerrar(event)) self.menu_Archivo.add(self.menucerrar) self.menuguardar.setText("Guardar") self.menuguardar.addActionListener(lambda event : self.guardar(event)) self.menu_Archivo.add(self.menuguardar) self.menuguardarcomo.setText("Guardar como") self.menuguardarcomo.addActionListener(lambda event : self.guardarcomo(event)) self.menu_Archivo.add(self.menuguardarcomo) self.menusalir.setText("Salir") self.menusalir.addActionListener(lambda event : self.salir(event)) self.menu_Archivo.add(self.menusalir) self.Menu.add(self.menu_Archivo) # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU EDICION<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< self.menu_Edicion.setText("Edicion") self.menu_cortar.setText("Cortar") self.menu_cortar.addActionListener(lambda event : self.cortar(event)) self.menu_Edicion.add(self.menu_cortar) self.menu_copiar.setText("Copiar") self.menu_copiar.addActionListener(lambda event : self.copiar(event)) self.menu_Edicion.add(self.menu_copiar) self.menu_pegar.setText("Pegar") self.menu_pegar.addActionListener(lambda event : self.pegar(event)) self.menu_Edicion.add(self.menu_pegar) self.Menu.add(self.menu_Edicion) # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU TABLAS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< self.menu_Tablas.setText("Tablas") self.menu_TablasEstaticas.setText("Tablas Estaticas") self.submenu_palabrasReservadas.setText("Tabla de palabras reservadas") self.menu_TablasEstaticas.add(self.submenu_palabrasReservadas) self.submenu_CaracteresEspeciales.setText("Tabla de caracteres especiales") self.menu_TablasEstaticas.add(self.submenu_CaracteresEspeciales) self.submenu_operadores.setText("Tabla de operadores") self.ta_es_op_aritmeticos.setText("Aritmeticos") self.submenu_operadores.add(self.ta_es_op_aritmeticos) self.ta_es_op_relacionales.setText("Relacionales") self.submenu_operadores.add(self.ta_es_op_relacionales) self.ta_es_op_logicos.setText("Logicos") self.submenu_operadores.add(self.ta_es_op_logicos) self.menu_TablasEstaticas.add(self.submenu_operadores) self.menu_Tablas.add(self.menu_TablasEstaticas) self.menu_TablaasDinamicas.setText("Tablas Dinamicas") self.submenu_simbolos.setText("Tabla de simbolos") self.menu_TablaasDinamicas.add(self.submenu_simbolos) self.submenu_identificadores.setText("Tabla de identificadores") self.menu_TablaasDinamicas.add(self.submenu_identificadores) self.submenu_errores.setText("Tabla de errores") self.menu_TablaasDinamicas.add(self.submenu_errores) self.submenu_constantesNumericas.setText("Tabla de constantes numericas") self.ta_di_conu_enteros.setText("Enteros") self.ta_di_conu_enteros.addActionListener(lambda event : self.numeroenteros(event)) self.submenu_constantesNumericas.add(self.ta_di_conu_enteros) self.ta_di_conu_reales.setText("Reales") self.ta_di_conu_reales.addActionListener(lambda event : self.numeroreales(event)) self.submenu_constantesNumericas.add(self.ta_di_conu_reales) self.ta_di_conu_cientificos.setText("Cientificos") self.submenu_constantesNumericas.add(self.ta_di_conu_cientificos) self.menu_TablaasDinamicas.add(self.submenu_constantesNumericas) self.submenu_Constantes_No_Numericas.setText("Tabla de constantes no numericas") self.tab_caracteres.setText("Caracteres") self.submenu_Constantes_No_Numericas.add(self.tab_caracteres) self.tab_cadenas.setText("Cadenas") self.submenu_Constantes_No_Numericas.add(self.tab_cadenas) self.menu_TablaasDinamicas.add(self.submenu_Constantes_No_Numericas) self.menu_Tablas.add(self.menu_TablaasDinamicas) self.Menu.add(self.menu_Tablas) # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU ANALISIS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< self.menu_Analisis.setText("Analisis") self.ana_lexico.setText("Lexico") self.ana_lexico.addActionListener(lambda event : self.lexico(event)) self.menu_Analisis.add(self.ana_lexico) self.ana_sintactico.setText("Sintactico") self.ana_sintactico.addActionListener(lambda event : self.sintactico(event)) self.menu_Analisis.add(self.ana_sintactico) self.ana_semantico.setText("Semantico") self.menu_Analisis.add(self.ana_semantico) self.Menu.add(self.menu_Analisis) # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MENU ACERCA DE<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< self.menu_Acerca_de.setText("Acerca de") self.btn_integrantes.setText("Integrante del proyecto") self.btn_integrantes.addActionListener(lambda event : self.integrantes(event)) self.menu_Acerca_de.add(self.btn_integrantes) self.Menu.add(self.menu_Acerca_de) self.setJMenuBar(self.Menu) self.setBounds(0, 0, 1095, 670)
def createMenuItems(self, context_menu): self.context = context_menu menu_list = ArrayList() menu_list.add(JMenuItem("Get Proxied Hosts", actionPerformed=self.custom_menu)) return menu_list
def createMenuItem(text, command, manager): mi = JMenuItem(text) mi.setActionCommand(command) mi.addActionListener(manager) return mi
def createMenuItems(self, invoker): self.invoker = invoker self.selection = self.invoker.getSelectionBounds() context = self.invoker.getInvocationContext() if not (context == self.invoker.CONTEXT_MESSAGE_EDITOR_REQUEST or context == self.invoker.CONTEXT_MESSAGE_VIEWER_REQUEST or context == self.invoker.CONTEXT_MESSAGE_EDITOR_RESPONSE or context == self.invoker.CONTEXT_MESSAGE_VIEWER_RESPONSE): return None menu_translate_sel = JMenuItem(self.src_menu_text, actionPerformed=self.translate) menu_translate_sel.setEnabled(False) menu_translate_clip = JMenuItem(self.dst_menu_text, actionPerformed=self.translate) menu_translate_clip.setEnabled(False) if self.selection is not None and self.selection[0] != self.selection[ 1]: menu_translate_sel.setEnabled(True) if self.get_clipboard_text() is not None: menu_translate_clip.setEnabled(True) menu_header = JMenu( '%s v%s' % (BurpExtender.extension_name, BurpExtender.extension_version)) menu_src = JMenu('Source Language [%s]' % (self.src)) menu_dst = JMenu('Destination Language [%s]' % (self.dst)) menu_automatic = JCheckBoxMenuItem('Automatic', actionPerformed=self.select_src) menu_src.add(menu_automatic) if self.src == menu_automatic.getText(): menu_automatic.setSelected(True) for lang in sorted(langs): menu_item = JCheckBoxMenuItem(lang, actionPerformed=self.select_src) if lang == self.src: menu_item.setSelected(True) menu_src.add(menu_item) menu_item = JCheckBoxMenuItem(lang, actionPerformed=self.select_dst) if lang == self.dst: menu_item.setSelected(True) menu_dst.add(menu_item) menu_header.add(menu_src) menu_header.add(menu_dst) menu_header.add(menu_translate_sel) menu_header.add(menu_translate_clip) return [menu_header]
def createMenuItems(self, contextMenuInvocation): self.contextMenuInvocation = contextMenuInvocation menuItems = ArrayList() menuItems.add(JMenuItem("[XCrypt]", actionPerformed=self.x_event)) return menuItems
class HRRGraph(graph.Graph): def __init__(self, view, name, func, args=(), filter=True, ylimits=(-1.0, 1.0), label=None, nodeid=None): self.fixed_value = None self.cache = {} self.cache_dt_tau = None self.cache_tick_count = 0 graph.Graph.__init__(self, view, name, func, args=args, filter=filter, ylimits=ylimits, split=False, neuronmapped=False, label=label) self.border_top = 30 self.vocab = hrr.Vocabulary.registered.get(nodeid, None) if self.vocab is None: dim = len(self.data.get_first()) if dim in hrr.Vocabulary.defaults.keys(): self.vocab = hrr.Vocabulary.defaults[dim] else: self.vocab = hrr.Vocabulary(dim) self.hidden_pairs = None self.normalize = True self.popup_normalize = JCheckBoxMenuItem('normalize', self.normalize, stateChanged=self.toggle_normalize) self.popup.add(self.popup_normalize) self.smooth_normalize = False self.popup_smooth = JCheckBoxMenuItem('smooth normalize', self.smooth_normalize, stateChanged=self.toggle_smooth_normalize) self.smooth_normalize_threshold = 0.4 self.popup.add(self.popup_smooth) self.show_pairs = False self.popup_pairs = JCheckBoxMenuItem('show pairs', self.show_pairs, stateChanged=self.toggle_show_pairs) self.popup.add(self.popup_pairs) self.show_graph = True self.popup_graph = JCheckBoxMenuItem('show graph', self.show_graph, stateChanged=self.toggle_show_graph) self.popup.add(self.popup_graph) self.font_height_50 = None self.popup_set = JMenuItem('set value', actionPerformed=self.set_value) self.popup.add(self.popup_set) self.popup_release = JMenuItem('release value', actionPerformed=self.release_value) self.popup_release.setEnabled(False) self.popup.add(self.popup_release) def toggle_normalize(self, event): if event.source.state == self.normalize: return self.normalize = event.source.state if self.normalize and self.smooth_normalize: self.popup_smooth.state = False self.clear_cache() self.repaint() def toggle_smooth_normalize(self, event): if event.source.state == self.smooth_normalize: return self.smooth_normalize = event.source.state if self.smooth_normalize and self.normalize: self.popup_normalize.state = False self.clear_cache() self.repaint() def toggle_show_pairs(self, event): if event.source.state == self.show_pairs: return self.show_pairs = event.source.state self.redo_indices() def toggle_show_graph(self, event): self.show_graph = event.source.state def redo_indices(self): if self.indices is None: return self.clear_cache() if self.show_pairs: if self.vocab.vector_pairs is None: self.vocab.generate_pairs() pairs = self.indices[len(self.vocab.keys):] if self.hidden_pairs is not None: pairs.extend(self.hidden_pairs) pairs = pairs + [False] * (len(self.vocab.key_pairs) - len(pairs)) self.indices = self.indices[:len(self.vocab.keys)] if len(self.indices) < len(self.vocab.keys): self.indices.extend([True] * (len(self.vocab.keys) - len(self.indices))) if self.show_pairs: self.indices = self.indices + pairs self.hidden_pairs = None else: self.hidden_pairs = pairs self.refix_popup() self.repaint() def save(self): info = graph.Graph.save(self) info['show_pairs'] = self.show_pairs info['normalize'] = self.normalize info['smooth_normalize'] = self.smooth_normalize info['show_graph'] = self.show_graph return info def restore(self, d): self.show_pairs = d.get('show_pairs', self.vocab.include_pairs) self.popup_pairs.state = self.show_pairs self.normalize = d.get('normalize', False) self.popup_normalize.state = self.normalize self.smooth_normalize = d.get('smooth_normalize', True) self.popup_smooth.state = self.smooth_normalize self.show_graph = d.get('show_graph', True) self.popup_graph.state = self.show_graph graph.Graph.restore(self, d) def label_for_index(self, index): if index < len(self.vocab.keys): text = self.vocab.keys[index] else: text = self.vocab.key_pairs[index - len(self.vocab.keys)] return text def set_value(self, event): key_count = len(self.vocab.keys) try: text = JOptionPane.showInputDialog(self.view.frame, 'Enter the symbolic value to represent.\nFor example: "a*b+0.3*(c*d+e)*~f"', "Set semantic pointer", JOptionPane.PLAIN_MESSAGE, None, None, None) v = self.vocab.parse(text) except: self.release_value(event) return if isinstance(v, (int, float)): v = [v] * self.vocab.dimensions else: v = v.v self.fixed_value = v self.popup_release.setEnabled(True) self.view.forced_origins[(self.name, 'X', None)] = self.fixed_value if key_count != len(self.vocab.keys): self.view.refresh_hrrs() def release_value(self, event): self.fixed_value = None self.popup_release.setEnabled(False) key = (self.name, 'X', None) if key in self.view.forced_origins: del self.view.forced_origins[key] def paintComponent(self, g): if self.show_graph: graph.Graph.paintComponent(self, g) else: core.DataViewComponent.paintComponent(self, g) dt_tau = None if self.filter and self.view.tau_filter > 0: dt_tau = self.view.dt / self.view.tau_filter try: data = self.data.get(start=self.view.current_tick, count=1, dt_tau=dt_tau)[0] except: return if data is None: return if self.normalize or self.smooth_normalize: data = self.calc_normal(data) if self.show_graph: text = self.vocab.text(data, threshold=0.3, join=',', include_pairs=self.show_pairs) g.color = Color.black bounds = g.font.getStringBounds(text, g.fontRenderContext) g.drawString(text, self.size.width / 2 - bounds.width / 2, 25 + self.label_offset) else: if self.font_height_50 is None: self.font_height_50 = self.getFontMetrics(Font('SansSerif', Font.BOLD, 50)).getHeight() items = [] total = 0 for i, dp in enumerate(self.vocab.dot(data)): if dp > 0.1: items.append((self.vocab.keys[i], dp)) total += dp if self.show_pairs: d = self.vocab.dot_pairs(data) if d is not None: for i, dp in enumerate(d): if dp > 0.1: items.append((self.vocab.key_pairs[i], dp)) total += dp if total > 0: scale = (self.size.height - self.label_offset - 25) / total y = self.label_offset for name, dp in items: g.color = Color(0.0, 0.0, 0.0, min(dp, 1.0)) font_size = int(dp * scale * 50 / self.font_height_50) g.font = Font('SansSerif', Font.BOLD, font_size) bounds = g.font.getStringBounds(name, g.fontRenderContext) g.drawString(name, self.size.width / 2 - bounds.width / 2, y + bounds.height) y += bounds.height def calc_normal(self, v): length = 0 for i in range(len(v)): length += v[i] * v[i] length = math.sqrt(length) if length > 0: scale = 1.0 / length else: scale = 0 if self.smooth_normalize and length < self.smooth_normalize_threshold: scale = 1.0 / self.smooth_normalize_threshold v = [x * scale for x in v] return v def clear_cache(self): self.cache.clear() self.cache_tick_count = 0 def post_process(self, data, start, dt_tau): if dt_tau != self.cache_dt_tau or self.cache_tick_count > self.view.watcher.timelog.tick_count: self.cache_dt_tau = dt_tau self.clear_cache() self.cache_tick_count = self.view.watcher.timelog.tick_count forget = self.cache_tick_count - self.view.watcher.timelog.tick_limit if forget in self.cache: del self.cache[forget] if not hasattr(self, 'vocab'): return [] if len(self.vocab.keys) == 0: return [] d = [] for i, dd in enumerate(data): if dd is None: d.append(None) else: index = i + start v = self.cache.get((index, dt_tau), None) if v is None: if self.normalize or self.smooth_normalize: dd = self.calc_normal(dd) v = self.vocab.dot(dd) if self.show_pairs: v2 = self.vocab.dot_pairs(dd) if v2 is not None: v = numeric.concatenate((v, v2), 0) self.cache[(index, dt_tau)] = v d.append(v) return d
def createMenuItems(self, context_menu): self.context = context_menu menu_list = ArrayList() menu_list.add( JMenuItem("Send to ReqSquared", actionPerformed=self.grabRequest)) return menu_list
def createMenuItems(self, context_menu): self.context = context_menu menu_list = ArrayList() menu_list.add(JMenuItem("Send to Header Injection Exploiter", actionPerformed=self.setPayload)) return menu_list
class RepeaterSenderAction(IProxyListener, ActionListener, IContextMenuFactory): def __init__(self, callbacks, helpers, text, overrideheaders): self.requests = {} self._helpers = helpers self._callbacks = callbacks self.menuitem = JMenuItem(text) self._burp_menuitem = JMenuItem("inql: %s" % text) self._callbacks.registerProxyListener(self) self.menuitem.addActionListener(self) self.menuitem.setEnabled(False) self._burp_menuitem.addActionListener(self) self._burp_menuitem.setEnabled(False) self._index = 0 self._host = None self._payload = None self._fname = None for r in self._callbacks.getProxyHistory(): self._process_request(self._helpers.analyzeRequest(r), r.getRequest()) self._callbacks.registerContextMenuFactory(self) self._overrideheaders = overrideheaders def processProxyMessage(self, messageIsRequest, message): """ Implements IProxyListener method :param messageIsRequest: True if BURP Message is a request :param message: message content :return: None """ if messageIsRequest: self._process_request( self._helpers.analyzeRequest(message.getMessageInfo()), message.getMessageInfo().getRequest()) def _process_request(self, reqinfo, reqbody): """ Process request and extract key values :param reqinfo: :param reqbody: :return: """ url = str(reqinfo.getUrl()) if any([url.endswith(x) for x in URLS]): for h in reqinfo.getHeaders(): if h.lower().startswith("host:"): domain = h[5:].strip() method = reqinfo.getMethod() try: self.requests[domain] except KeyError: self.requests[domain] = { 'POST': None, 'PUT': None, 'GET': None } self.requests[domain][method] = (reqinfo, reqbody) def actionPerformed(self, e): """ Overrides ActionListener behaviour. Send current query to repeater. :param e: unused :return: None """ req = self.requests[self._host]['POST'] or self.requests[ self._host]['PUT'] or self.requests[self._host]['GET'] if req: info = req[0] body = req[1] nobody = body[:info.getBodyOffset()].tostring() rstripoffset = info.getBodyOffset() - len(nobody.rstrip()) headers = body[:info.getBodyOffset() - rstripoffset].tostring() try: self._overrideheaders[self._host] except KeyError: self._overrideheaders[self._host] = [] repeater_body = StringUtil.toBytes( string_join( override_headers(headers, self._overrideheaders[self._host]), body[info.getBodyOffset() - rstripoffset:info.getBodyOffset()].tostring(), self._payload)) self._callbacks.sendToRepeater( info.getUrl().getHost(), info.getUrl().getPort(), info.getUrl().getProtocol() == 'https', repeater_body, 'GraphQL #%s' % self._index) self._index += 1 def ctx(self, host=None, payload=None, fname=None): """ When a fname is specified and is a query file or a request is selected in the other tabs, enables the context menu to send to repeater tab :param host: should be not null :param payload: should be not null :param fname: should be not null :return: None """ self._host = host self._payload = payload self._fname = fname if not self._fname.endswith('.query'): self.menuitem.setEnabled(False) self._burp_menuitem.setEnabled(False) return try: self.requests[host] self.menuitem.setEnabled(True) self._burp_menuitem.setEnabled(True) except KeyError: self.menuitem.setEnabled(False) self._burp_menuitem.setEnabled(False) def createMenuItems(self, invocation): """ Overrides IContextMenuFactory callback :param invocation: handles menu selected invocation :return: """ try: r = invocation.getSelectedMessages()[0] info = self._helpers.analyzeRequest(r) url = str(info.getUrl()) if not any([x in url for x in URLS]): return None body = r.getRequest()[info.getBodyOffset():].tostring() for h in info.getHeaders(): if h.lower().startswith("host:"): domain = h[5:].strip() self.ctx(fname='dummy.query', host=domain, payload=body) mymenu = [] mymenu.append(self._burp_menuitem) except Exception as ex: return None return mymenu
def createMenuItems(self, invocation): self._add_invocation = invocation self._imenu = JMenuItem(self._imenu_description, actionPerformed=self.addToScope) return [self._imenu]
def __init__(self): ''' Constructor ''' #Create classifiers #Character classifier path_to_this_dir = File(str(inspect.getfile( inspect.currentframe()))).getParent() character_classifier_file = open( File(path_to_this_dir, "character_classifier_11_segments_4_6_cf.dat").getPath(), 'r') self.character_classifier = CharacterClassifier( from_string_string=character_classifier_file.read()) character_classifier_file.close() #Word classifier word_classifier_file = open( File(path_to_this_dir, "word_classifier.dat").getPath(), 'r') self.word_classifier = WordClassifier( from_string_string=word_classifier_file.read()) word_classifier_file.close() #Set up window self.setTitle("HandReco Writer") self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) self.setLocationRelativeTo(None) self.setLayout(BorderLayout()) #Set up menu menu_bar = JMenuBar() info_menu = JMenu("Info") def instructions(event): instr = ''' The program can just recognise capital English characters. See Info -> Available Words... for available word corrections. Good Luck with the writing!''' JOptionPane.showMessageDialog(self, instr, "Instructions", JOptionPane.INFORMATION_MESSAGE) instructions_menu_item = JMenuItem("Instructions...", actionPerformed=instructions) info_menu.add(instructions_menu_item) def word_corrections(event): words_string = "" for word in self.word_classifier.words: words_string = words_string + word.upper() + "\n" text = "The words that can be corrected are:\n\n" + words_string dialog = JOptionPane(text, JOptionPane.INFORMATION_MESSAGE) dialog_wrapper = JDialog(self, "Available Words", False) dialog_wrapper.setContentPane(dialog) dialog_wrapper.pack() dialog_wrapper.setVisible(True) word_corrections_menu_item = JMenuItem( "Available Words...", actionPerformed=word_corrections) info_menu.add(word_corrections_menu_item) menu_bar.add(info_menu) self.setJMenuBar(menu_bar) #Input panel input_panel = JPanel() input_panel.setLayout(BoxLayout(input_panel, BoxLayout.X_AXIS)) input_panel.setBorder(BorderFactory.createTitledBorder("Input")) self.paint_area = PaintArea(100, 100) input_panel.add(self.paint_area) input_options_panel = JPanel() input_options_panel.setLayout( BoxLayout(input_options_panel, BoxLayout.Y_AXIS)) #Write Char write_char_panel = JPanel(BorderLayout()) def write_char(event): char = self.character_classifier.classify_image( self.paint_area.image()) self.text_area.setText(self.text_area.getText() + char) self.paint_area.clear() write_char_panel.add(JButton("Write Char", actionPerformed=write_char), BorderLayout.NORTH) input_options_panel.add(write_char_panel) #Space and Correct space_and_correct_panel = JPanel(BorderLayout()) def space_and_correct(event): text = self.text_area.getText() words = text.split(" ") string = words[-1] try: word = self.word_classifier.classify(string.lower()) words[-1] = word.upper() except: JOptionPane.showMessageDialog( self, "Have you entered a character which is not in the alphabet?", "Could not Correct", JOptionPane.ERROR_MESSAGE) self.text_area.setText(text + " ") return newText = "" for w in words: newText = newText + w + " " self.text_area.setText(newText) space_and_correct_panel.add( JButton("Space and Correct", actionPerformed=space_and_correct), BorderLayout.NORTH) input_options_panel.add(space_and_correct_panel) #Space space_panel = JPanel(BorderLayout()) def space(event): self.text_area.setText(self.text_area.getText() + " ") space_panel.add(JButton("Space", actionPerformed=space), BorderLayout.NORTH) input_options_panel.add(space_panel) #Clear Input Area clear_input_area_panel = JPanel(BorderLayout()) def clear(event): self.paint_area.clear() clear_input_area_panel.add( JButton("Clear Input Area", actionPerformed=clear), BorderLayout.NORTH) input_options_panel.add(clear_input_area_panel) input_panel.add(input_options_panel) self.add(input_panel, BorderLayout.NORTH) text_area_panel = JPanel() text_area_panel.setLayout(BorderLayout()) text_area_panel.setBorder(BorderFactory.createTitledBorder("Text")) self.text_area = JTextArea() self.text_area.setLineWrap(True) #Increase font size font = self.text_area.getFont() self.text_area.setFont(Font(font.getName(), Font.BOLD, 24)) text_area_panel.add(JScrollPane(self.text_area), BorderLayout.CENTER) self.add(text_area_panel, BorderLayout.CENTER) self.pack() self.setSize(Dimension(300, 300)) self.setVisible(True)
def registerExtenderCallbacks(self, callbacks): # Initialize the global stdout stream global stdout # Keep a reference to our callbacks object self._callbacks = callbacks # Obtain an extension helpers object self._helpers = callbacks.getHelpers() # set our extension name callbacks.setExtensionName("Burpsuite Yara Scanner") # Create the log and a lock on which to synchronize when adding log entries self._log = ArrayList() self._lock = Lock() # main split pane splitpane = JSplitPane(JSplitPane.VERTICAL_SPLIT) # table of log entries logTable = Table(self) scrollPane = JScrollPane(logTable) splitpane.setLeftComponent(scrollPane) # Options panel optionsPanel = JPanel() optionsPanel.setLayout(GridBagLayout()) constraints = GridBagConstraints() yara_exe_label = JLabel("Yara Executable Location:") constraints.fill = GridBagConstraints.HORIZONTAL constraints.gridx = 0 constraints.gridy = 0 optionsPanel.add(yara_exe_label, constraints) self._yara_exe_txtField = JTextField(25) constraints.fill = GridBagConstraints.HORIZONTAL constraints.gridx = 1 constraints.gridy = 0 optionsPanel.add(self._yara_exe_txtField, constraints) yara_rules_label = JLabel("Yara Rules File:") constraints.fill = GridBagConstraints.HORIZONTAL constraints.gridx = 0 constraints.gridy = 1 optionsPanel.add(yara_rules_label, constraints) self._yara_rules_files = Vector() self._yara_rules_files.add("< None >") self._yara_rules_fileList = JList(self._yara_rules_files) constraints.fill = GridBagConstraints.HORIZONTAL constraints.gridx = 1 constraints.gridy = 1 optionsPanel.add(self._yara_rules_fileList, constraints) self._yara_rules_select_files_button = JButton("Select Files") self._yara_rules_select_files_button.addActionListener(self) constraints.fill = GridBagConstraints.HORIZONTAL constraints.gridx = 1 constraints.gridy = 2 optionsPanel.add(self._yara_rules_select_files_button, constraints) self._yara_clear_button = JButton("Clear Yara Results Table") self._yara_clear_button.addActionListener(self) constraints.fill = GridBagConstraints.HORIZONTAL constraints.gridx = 1 constraints.gridy = 3 optionsPanel.add(self._yara_clear_button, constraints) # Tabs with request/response viewers viewerTabs = JTabbedPane() self._requestViewer = callbacks.createMessageEditor(self, False) self._responseViewer = callbacks.createMessageEditor(self, False) viewerTabs.addTab("Request", self._requestViewer.getComponent()) viewerTabs.addTab("Response", self._responseViewer.getComponent()) splitpane.setRightComponent(viewerTabs) # Tabs for the Yara output and the Options self._mainTabs = JTabbedPane() self._mainTabs.addTab("Yara Output", splitpane) self._mainTabs.addTab("Options", optionsPanel) # customize our UI components callbacks.customizeUiComponent(splitpane) callbacks.customizeUiComponent(logTable) callbacks.customizeUiComponent(scrollPane) callbacks.customizeUiComponent(viewerTabs) callbacks.customizeUiComponent(self._mainTabs) # add the custom tab to Burp's UI callbacks.addSuiteTab(self) # add ourselves as a context menu factory callbacks.registerContextMenuFactory(self) # Custom Menu Item self.menuItem = JMenuItem("Scan with Yara") self.menuItem.addActionListener(self) # obtain our output stream stdout = PrintWriter(callbacks.getStdout(), True) # Print a startup notification stdout.println("Burpsuite Yara scanner initialized.")
def __init__(self, text): self.requests = {} self.menuitem = JMenuItem(text) self.menuitem.addActionListener(self) self.enabled = True self.menuitem.setEnabled(self.enabled)