def burp_label_color(self, text, isBorder=1): if isBorder: title = TitledBorder(LineBorder(Color.black, 1, True), '<html><h3><b>' + text + '</b></h3></html>', TitledBorder.LEFT, TitledBorder.TOP) else: title = TitledBorder(LineBorder(Color.white, 1, True), '<html><h3><b>' + text + '</b></h3></html>', TitledBorder.LEFT, TitledBorder.TOP) title.setTitleColor(self._burpColor) return title
def __init__(self, menu_title, the_settings_panel): self.settings_panel = the_settings_panel self.settings_panel.set_selected(False) self.setLayout(BorderLayout()) self.setBorder(LineBorder(Color.darkGray)) self.add(JLabel(menu_title), BorderLayout.CENTER)
def stopCellEditing(self): try: val = Integer.valueOf(self.textfield.getText()) if not (-1 < val < 65536): raise NumberFormatException() result = DefaultCellEditor.stopCellEditing(self) except: self.textfield.setBorder(LineBorder(Color.red)) result = 0 # false return result
def verify( self, input ) : text = input.getText() if not self.border : # The first time, save the border self.border = input.getBorder() result = input.getText() == "pass" if result : # valid? Restore original border input.setBorder( self.border ) else : # invalid? change border color input.setBorder( LineBorder( Color.red ) ) input.selectAll() return result
def initEnforcementDetector(self): # ## init enforcement detector tab # # These two variable appears to be unused... self.EDFP = ArrayList() self.EDCT = ArrayList() EDLType = JLabel("Type:") EDLType.setBounds(10, 10, 140, 30) EDLContent = JLabel("Content:") EDLContent.setBounds(10, 50, 140, 30) EDLabelList = JLabel("Filter List:") EDLabelList.setBounds(10, 165, 140, 30) EDStrings = [ "Headers (simple string): (enforced message headers contains)", "Headers (regex): (enforced messege headers contains)", "Body (simple string): (enforced messege body contains)", "Body (regex): (enforced messege body contains)", "Full request (simple string): (enforced messege contains)", "Full request (regex): (enforced messege contains)", "Content-Length: (constant Content-Length number of enforced response)" ] self.EDType = JComboBox(EDStrings) self.EDType.setBounds(80, 10, 430, 30) self.EDText = JTextArea("", 5, 30) self.EDText.setBounds(80, 50, 300, 110) self.EDModel = DefaultListModel() self.EDList = JList(self.EDModel) self.EDList.setBounds(80, 175, 300, 110) self.EDList.setBorder(LineBorder(Color.BLACK)) self.EDAdd = JButton("Add filter", actionPerformed=self.addEDFilter) self.EDAdd.setBounds(390, 85, 120, 30) self.EDDel = JButton("Remove filter", actionPerformed=self.delEDFilter) self.EDDel.setBounds(390, 210, 120, 30) self.EDPnl = JPanel() self.EDPnl.setLayout(None) self.EDPnl.setBounds(0, 0, 1000, 1000) self.EDPnl.add(EDLType) self.EDPnl.add(self.EDType) self.EDPnl.add(EDLContent) self.EDPnl.add(self.EDText) self.EDPnl.add(self.EDAdd) self.EDPnl.add(self.EDDel) self.EDPnl.add(EDLabelList) self.EDPnl.add(self.EDList)
def createParametersPanel(manager): global systemPanel, menuHandles, isTemporal systemPanel = SystemPanel(changeChartCI, isTemporal) global summPanel summPanel = SummPanel(isTemporal) global empiricalPanel, isDominant empiricalPanel = EmpiricalPanel(menuHandles, manager, isDominant, systemPanel, isTemporal) global simsDonePanel simsDonePanel = Meter(300, 120, 10) panel = JPanel() panel.setBorder(LineBorder(Color.GREEN)) panel.add(systemPanel) panel.add(empiricalPanel) panel.add(summPanel) panel.add(simsDonePanel) return panel
def initInterceptionFilters(self): # ## init interception filters tab # IFStrings = [ "Scope items only: (Content is not required)", "URL Contains (simple string): ", "URL Contains (regex): ", "URL Not Contains (simple string): ", "URL Not Contains (regex): " ] self.IFType = JComboBox(IFStrings) self.IFType.setBounds(80, 10, 430, 30) self.IFModel = DefaultListModel() self.IFList = JList(self.IFModel) self.IFList.setBounds(80, 175, 300, 110) self.IFList.setBorder(LineBorder(Color.BLACK)) self.IFText = JTextArea("", 5, 30) self.IFText.setBounds(80, 50, 300, 110) IFLType = JLabel("Type:") IFLType.setBounds(10, 10, 140, 30) IFLContent = JLabel("Content:") IFLContent.setBounds(10, 50, 140, 30) IFLabelList = JLabel("Filter List:") IFLabelList.setBounds(10, 165, 140, 30) self.IFAdd = JButton("Add filter", actionPerformed=self.addIFFilter) self.IFAdd.setBounds(390, 85, 120, 30) self.IFDel = JButton("Remove filter", actionPerformed=self.delIFFilter) self.IFDel.setBounds(390, 210, 120, 30) self.filtersPnl = JPanel() self.filtersPnl.setLayout(None) self.filtersPnl.setBounds(0, 0, 1000, 1000) self.filtersPnl.add(IFLType) self.filtersPnl.add(self.IFType) self.filtersPnl.add(IFLContent) self.filtersPnl.add(self.IFText) self.filtersPnl.add(self.IFAdd) self.filtersPnl.add(self.IFDel) self.filtersPnl.add(IFLabelList) self.filtersPnl.add(self.IFList)
def show_gui(): """ Shows a GUI to select dss files to compare and select an input file """ from javax.swing import JPanel, JFrame, JButton, SpringLayout, JTextBox from javax.swing.border import LineBorder textBox1 = JTextBox() textBox2 = JTextBox() file1ChooseButton = JButton("Choose File") file2ChooseButton = JButton("Choose File") contentPane = JPanel(SpringLayout()) contentPane.setBorder(LineBorder(Color.blue)) contentPane.add(JLabel("Alternative DSS File")) contentPane.add(textBox1) contentPane.add(file1ChooseButton) contentPane.add(JLabel("Base DSS File")) contentPane.add(textBox2) contentPane.add(file2ChooseButton) fr = JFrame("Calsim Report Generator") fr.contentPane().add(contentPane) fr.pack();fr.show();
def registerExtenderCallbacks(self, callbacks): # smart xss feature (print conclusion and observation) # mark resulsts # add automatic check pages in the same domain self.tagPayloads = [ "<b>test", "<b onmouseover=test()>test", "<img src=err onerror=test()>", "<script>test</script>" "", "<scr ipt>test</scr ipt>", "<SCRIPT>test;</SCRIPT>", "<scri<script>pt>test;</scr</script>ipt>", "<SCRI<script>PT>test;</SCR</script>IPT>", "<scri<scr<script>ipt>pt>test;</scr</sc</script>ript>ipt>", "<IMG \"\"\"><SCRIPT>test</SCRIPT>\">", "<IMG '''><SCRIPT>test</SCRIPT>'>", "<SCR%00IPT>test</SCR%00IPT>", "<IFRAME SRC='f' onerror=\"test\"></IFRAME>", "<IFRAME SRC='f' onerror='test'></IFRAME>", "<<SCRIPT>test//<</SCRIPT>", "<img src=\"1\" onerror=\"test\">", "<img src='1' onerror='test'", "<STYLE TYPE=\"text/javascript\">test;</STYLE>", "<<SCRIPT>test//<</SCRIPT>" ] self.attributePayloads = [ "\"\"\"><SCRIPT>test", "'''><SCRIPT>test'", "\"><script>test</script>", "\"><script>test</script><\"", "'><script>test</script>", "'><script>test</script><'", "\";test;\"", "';test;'", ";test;", "\";test;//", "\"onmouseover=test ", "onerror=\"test\"", "onerror='test'", "onload=\"test\"", "onload='test'" ] self.xssKey = 'xssme' # 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("XSSor") self.affectedResponses = ArrayList() self._log = ArrayList() self._lock = Lock() # main split pane self._splitpane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT) # table of log entries logTable = Table(self) scrollPane = JScrollPane(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()) clearAPListBtn = JButton("Clear List", actionPerformed=self.clearAPList) clearAPListBtn.setBounds(10, 85, 120, 30) apListLabel = JLabel('Affected Pages List:') apListLabel.setBounds(10, 10, 140, 30) self.affectedModel = DefaultListModel() self.affectedList = JList(self.affectedModel) self.affectedList.addListSelectionListener(listSelectedChange(self)) scrollAList = JScrollPane(self.affectedList) scrollAList.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED) scrollAList.setBounds(150, 10, 550, 200) scrollAList.setBorder(LineBorder(Color.BLACK)) APtabs = JTabbedPane() self._requestAPViewer = callbacks.createMessageEditor(self, False) self._responseAPViewer = callbacks.createMessageEditor(self, False) APtabs.addTab("Request", self._requestAPViewer.getComponent()) APtabs.addTab("Affeced Page Response", self._responseAPViewer.getComponent()) APtabs.setBounds(0, 250, 700, 350) APtabs.setSelectedIndex(1) self.APpnl = JPanel() self.APpnl.setBounds(0, 0, 1000, 1000) self.APpnl.setLayout(None) self.APpnl.add(scrollAList) self.APpnl.add(clearAPListBtn) self.APpnl.add(APtabs) self.APpnl.add(apListLabel) tabs.addTab("Affected Pages", self.APpnl) self.intercept = 0 ## init conf panel startLabel = JLabel("Plugin status:") startLabel.setBounds(10, 10, 140, 30) payloadLabel = JLabel("Basic Payload:") payloadLabel.setBounds(10, 50, 140, 30) self.basicPayload = "<script>alert(1)</script>" self.basicPayloadTxt = JTextArea(self.basicPayload, 5, 30) self.basicPayloadTxt.setBounds(120, 50, 305, 30) self.bruteForceMode = JCheckBox("Brute Force Mode") self.bruteForceMode.setBounds(120, 80, 300, 30) self.bruteForceMode.addItemListener(handleBFModeChange(self)) self.tagPayloadsCheck = JCheckBox("Tag paylods") self.tagPayloadsCheck.setBounds(120, 100, 300, 30) self.tagPayloadsCheck.setSelected(True) self.tagPayloadsCheck.setEnabled(False) self.tagPayloadsCheck.addItemListener(handleBFModeList(self)) self.attributePayloadsCheck = JCheckBox("Attribute payloads") self.attributePayloadsCheck.setBounds(260, 100, 300, 30) self.attributePayloadsCheck.setSelected(True) self.attributePayloadsCheck.setEnabled(False) self.attributePayloadsCheck.addItemListener(handleBFModeList(self)) payloadListLabel = JLabel("Payloads list (for BF mode):") payloadListLabel.setBounds(10, 130, 140, 30) self.payloadsModel = DefaultListModel() self.payloadsList = JList(self.payloadsModel) scrollPayloadsList = JScrollPane(self.payloadsList) scrollPayloadsList.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED) scrollPayloadsList.setBounds(120, 170, 300, 200) scrollPayloadsList.setBorder(LineBorder( Color.BLACK)) # add buttons to remove payloads and add for payload in self.tagPayloads: self.payloadsModel.addElement(payload) for payload in self.attributePayloads: self.payloadsModel.addElement(payload) self.startButton = JButton("XSSor is off", actionPerformed=self.startOrStop) self.startButton.setBounds(120, 10, 120, 30) self.startButton.setBackground(Color(255, 100, 91, 255)) consoleTab = JTabbedPane() self.consoleLog = JTextArea("", 5, 30) scrollLog = JScrollPane(self.consoleLog) scrollLog.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED) scrollLog.setBounds(120, 170, 550, 200) scrollLog.setBorder(LineBorder(Color.BLACK)) scrollLog.getVerticalScrollBar().addAdjustmentListener( autoScrollListener(self)) consoleTab.addTab("Console", scrollLog) consoleTab.setBounds(0, 400, 500, 200) self.pnl = JPanel() self.pnl.setBounds(0, 0, 1000, 1000) self.pnl.setLayout(None) self.pnl.add(self.startButton) self.pnl.add(startLabel) self.pnl.add(payloadLabel) self.pnl.add(self.basicPayloadTxt) self.pnl.add(self.bruteForceMode) self.pnl.add(payloadListLabel) self.pnl.add(scrollPayloadsList) self.pnl.add(self.attributePayloadsCheck) self.pnl.add(self.tagPayloadsCheck) self.pnl.add(consoleTab) tabs.addTab("Configuration", self.pnl) tabs.setSelectedIndex(3) self._splitpane.setRightComponent(tabs) # customize our UI components callbacks.customizeUiComponent(self._splitpane) callbacks.customizeUiComponent(logTable) callbacks.customizeUiComponent(scrollPane) callbacks.customizeUiComponent(tabs) # add the custom tab to Burp's UI callbacks.addSuiteTab(self) # register ourselves as an HTTP listener callbacks.registerHttpListener(self) self._callbacks.registerContextMenuFactory(self) print "Thank you for installing XSSor v0.1 extension" print "Created by Barak Tawily" print "\nGithub:\nhttps://github.com/Quitten/XSSor" return
class UI: global dssFile mainWindow = ListSelection.getMainWindow() dssFileName = mainWindow.getDSSFilename() dssFile = HecDss.open(dssFileName) global frame, lbl_close, list_locations, chckbxShowLocationPlot, eventsTable, dm_events, dm_meltRate global swePaths, precipPaths, tempPaths, bList, meltRateTable, startDateField, endDateField frame = JFrame("Snow PAC - Parameter Aggregator & Calculator") # frame.setUndecorated(True) frame.setBackground(Color.WHITE) frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) frame.setBounds(100, 100, 1110, 775) contentPane = JPanel() contentPane.setBackground(Color.WHITE) contentPane.setBorder(EmptyBorder(5, 5, 5, 5)) frame.setContentPane(contentPane) contentPane.setLayout(None) class MouseListener(MouseAdapter): # @Override def mousePressed(self, e): global xx global xy xx = e.getX() xy = e.getY() class MouseMotionListener(MouseMotionAdapter): # @Override def mouseDragged(self, arg0): x = arg0.getXOnScreen() y = arg0.getYOnScreen() frame.setLocation(x - xx, y - xy) mL = MouseListener() mML = MouseMotionListener() contentPane.addMouseListener(mL) contentPane.addMouseMotionListener(mML) if os.path.exists(img_dir + "/button.jpg"): btnIcon = ImageIcon(img_dir + "/button.jpg") else: btnIcon = ImageIcon(img_dir2 + "/button.jpg") scrollPane_events = JScrollPane() scrollPane_events.setBounds(270, 372, 403, 263) contentPane.add(scrollPane_events) scrollPane_locations = JScrollPane() scrollPane_locations.setBounds(270, 49, 403, 203) contentPane.add(scrollPane_locations) class deleteAction(AbstractAction): def actionPerformed(self, deleteEvent): # Get selected Rows and reverse list. Removes each row in list one at a time. # List is Reversed using [::-1], so it doesn't mess up the ordering as it deletes through the loop. for row in meltRateTable.getSelectedRows()[::-1]: dm_meltRate.removeRow(row) dm_meltRate.insertRow(row, [None, None]) scrollPane_table = JScrollPane() scrollPane_table.setBounds(708, 49, 338, 586) contentPane.add(scrollPane_table) meltRateTable = JTable() scrollPane_table.setViewportView(meltRateTable) scrollPane_table.setBorder(LineBorder(Color(1, 1, 1), 2, True)) meltRateTable.setFont(Font("Tahoma", Font.PLAIN, 11)) columns = ("ATI (Deg F-Day)", "Meltrate (Inches/Deg F-Day)") data = [] datarows = 100 data.append([0, None]) for i in range(datarows): data.append([None, None]) dm_meltRate = DefaultTableModel(data, columns) meltRateTable.setModel(dm_meltRate) meltRateTable.getColumnModel().getColumn(0).setPreferredWidth(154) meltRateTable.getColumnModel().getColumn(1).setResizable(False) meltRateTable.getColumnModel().getColumn(1).setPreferredWidth(154) meltRateTable.setCellSelectionEnabled(True) # Delete data from the table using the Delete Key. # meltRateTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); inputMap = meltRateTable.getInputMap(JComponent.WHEN_FOCUSED) actionMap = meltRateTable.getActionMap() deleteActionStr = "delete" inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), deleteActionStr) actionMap.put(deleteActionStr, deleteAction()) # jLabelStartDate = JLabel() # jLabelStartDate.setText("Optional Start Date:") # jLabelStartDate.setToolTipText("Optional User Specified Date Range for Paired Data. If Specified, Will be Calculated for each Water Year.") # jLabelStartDate.setBounds(420, 263, 120, 20); # jLabelStartDate.setFont( Font("Tahoma", Font.PLAIN, 12)) # contentPane.add(jLabelStartDate) # # startDateField = CalendarField(); # jLabelStartDate.setLabelFor(startDateField); # startDateField.setMargin(Insets(0, 4, 0, 0)); # startDateField.setBounds(540, 263, 118, 22); # startDateField.setFont(Font("Tahoma", Font.PLAIN, 12)); # startDateField.setToolTipText("Optional User Specified Date Range for Paired Data. If Specified, Will be Calculated for each Water Year.") # contentPane.add(startDateField); # # jLabelEndDate = JLabel() # jLabelEndDate.setText("Optional End Date:") # jLabelEndDate.setToolTipText("Optional User Specified Date Range for Paired Data. If Specified, Will be Calculated for each Water Year.") # jLabelEndDate.setBounds(420, 293, 120, 20); # jLabelEndDate.setFont( Font("Tahoma", Font.PLAIN, 12)) # contentPane.add(jLabelEndDate) # # endDateField = CalendarField(); # jLabelEndDate.setLabelFor(endDateField); # endDateField.setMargin(Insets(0, 4, 0, 0)); # endDateField.setBounds(540, 293, 118, 22); # endDateField.setFont(Font("Tahoma", Font.PLAIN, 12)); # endDateField.setToolTipText("Optional User Specified Date Range for Paired Data. If Specified, Will be Calculated for each Water Year.") # contentPane.add(endDateField); def recalcBtnSelect(event): global swePaths, precipPaths, tempPaths selectedLocations = list_locations.getSelectedValuesList() swePaths, precipPaths, tempPaths = Locations.getSelectedLocations( selectedLocations) pathsNoDPart, sList, pList, tList = CalcAtiMelt.processPathsLists( swePaths, precipPaths, tempPaths) dList = CalcAtiMelt.processPathsDatesList(pathsNoDPart) aList, mList = CalcAtiMelt.calcATIMelt(selectedLocations, sList, pList, tList, dList) # Write Melt-Cum and ATI Locations to DSS. CalcAtiMelt.writeAtiMelt(selectedLocations, dList, aList, mList) # Plot Locations if checkbox.selected = True. if chckbxShowLocationPlot.selected is True: # print '\nPLOT TEAM ACTIVATE' PlotAtiMelt.plotAtiMelt(selectedLocations) # Use optional specified dates if fields are not blank. # if startDateField.getText() and endDateField.getText() is not None: # pdStart, pdEnd = ProcessPD.getSpecifiedDates(startDateField, endDateField) # else: pdStart = None pdEnd = None # Create Paired Data for Selected Locations. ProcessPD.processPairedData(selectedLocations, dList, mList, aList, pdStart, pdEnd) # Populate the UI Paired Data Table. CalcPD.updatePDTable(dssFile, eventsTable, dm_events) # Close the DSS File. dssFile.close() def plotPDBtnSelect(event): selected_Events = eventsTable.getSelectedRows() # Print 'selected_Events: ', selected_Events # Sorting of the table by selecting the headers is doen by using: eventsTable.setAutoCreateRowSorter(True) # This sorts the table but does not update the table model. # To ensure sorting and selecting of resulting paths works properly, # we must convert our selection using: eventsTable.convertRowIndexToModel(event) selectedEvents = [] for event in selected_Events: selectedEvents.append(eventsTable.convertRowIndexToModel(event)) # print 'selectedEvents: ', selectedEvents PlotPD.plotPD(eventsTable, selectedEvents, dssFile) dssFile.close() def calcMeltRateBtnSelect(event): selected_Events = eventsTable.getSelectedRows() selectedEvents = [] for event in selected_Events: selectedEvents.append(eventsTable.convertRowIndexToModel(event)) meltRateList = CalcMeltRate.calcMeltRate(selectedEvents, eventsTable, meltRateTable, dssFile) CalcMeltRate.updateTable(meltRateTable, meltRateList, dm_meltRate) dssFile.close() locDict, bList = Locations.getPaths(dssFile) locList = Locations.getList(locDict) list_locations = JList(locList) scrollPane_locations.setViewportView(list_locations) list_locations.setBorder(LineBorder(Color(0, 0, 0), 2, True)) eventsTable = JTable() scrollPane_events.setViewportView(eventsTable) scrollPane_events.setBorder(LineBorder(Color(1, 1, 1), 2, True)) eventsTable.setFont(Font("Tahoma", Font.PLAIN, 11)) locationsList, eventsList = Locations.getPairedData(dssFile) columns = ("Location", "Event") data = [] for l, e in zip(locationsList, eventsList): data.append([l, e]) dm_events = DefaultTableModel(data, columns) eventsTable.setModel(dm_events) eventsTable.setAutoCreateRowSorter(True) eventsTable.getColumnModel().getColumn(0).setPreferredWidth(154) eventsTable.getColumnModel().getColumn(1).setResizable(False) eventsTable.getColumnModel().getColumn(1).setPreferredWidth(154) eventsTable.setRowSelectionAllowed(True) inputPanel = JPanel() inputPanel.setBorder(EmptyBorder(0, 0, 0, 0)) inputPanel.setBackground(Color(255, 255, 255)) inputPanel.setBounds(270, 11, 410, 27) contentPane.add(inputPanel) inputPanel.setLayout(None) inputPanel.setVisible(True) lbl_locations = JLabel( "DSS Locations that have PRECIP-INC, TEMPERATURE-AIR-AVG, and SWE. ") lbl_locations.setFont(Font("Tahoma", Font.PLAIN, 12)) lbl_locations.setBounds(0, 11, 410, 15) inputPanel.add(lbl_locations) btnRecalc = JButton(btnIcon, actionPerformed=recalcBtnSelect) btnRecalc.setText("Calculate Paired Data") btnRecalc.setFont(Font("Tahoma", Font.BOLD, 12)) btnRecalc.setForeground(Color.WHITE) btnRecalc.setBackground(Color.WHITE) btnRecalc.setBorderPainted(False) btnRecalc.setContentAreaFilled(False) btnRecalc.setFocusPainted(False) btnRecalc.setOpaque(True) btnRecalc.setVerticalTextPosition(SwingConstants.CENTER) btnRecalc.setHorizontalTextPosition(SwingConstants.CENTER) btnRecalc.setBounds(382, 293, 165, 54) contentPane.add(btnRecalc) leftPanel = JPanel() leftPanel.setBackground(Color.DARK_GRAY) leftPanel.setBounds(0, 0, 250, 780) contentPane.add(leftPanel) leftPanel.setLayout(None) lbl_castle = JLabel("") lbl_castle.setBounds(110, 678, 40, 25) leftPanel.add(lbl_castle) try: i_corps = ImageIO.read(File(img_dir + "/CorpsCastle.png")) except: i_corps = ImageIO.read(File(img_dir2 + "/CorpsCastle.png")) corpsCastle = i_corps.getScaledInstance(lbl_castle.getWidth(), lbl_castle.getHeight(), Image.SCALE_SMOOTH) lbl_castle.setVerticalAlignment(SwingConstants.TOP) lbl_castle.setIcon(ImageIcon(corpsCastle)) lbl_logo = JLabel("") lbl_logo.setBounds(18, 294, 218, 148) leftPanel.add(lbl_logo) try: snowLogo = ImageIO.read(File(img_dir + "/melted-snowman.png")) except: snowLogo = ImageIO.read(File(img_dir2 + "/melted-snowman.png")) dssLogo = snowLogo.getScaledInstance(lbl_logo.getWidth(), lbl_logo.getHeight(), Image.SCALE_SMOOTH) lbl_logo.setVerticalAlignment(SwingConstants.TOP) lbl_logo.setIcon(ImageIcon(dssLogo)) lbl_logo2 = JLabel("") lbl_logo2.setBounds(18, 11, 218, 148) leftPanel.add(lbl_logo2) try: snowPacLogo = ImageIO.read(File(img_dir + "/SnowPac.png")) except: snowPacLogo = ImageIO.read(File(img_dir2 + "/SnowPac.png")) snowPac = snowPacLogo.getScaledInstance(lbl_logo2.getWidth(), lbl_logo2.getHeight(), Image.SCALE_SMOOTH) lbl_logo2.setVerticalAlignment(SwingConstants.TOP) lbl_logo2.setIcon(ImageIcon(snowPac)) # lbl_close = JLabel("X") # # class CloseClickListener(MouseAdapter): # # @Override # def mouseEntered(self): # lbl_close.setBorder(LineBorder.createGrayLineBorder()) # # @Override # def mouseExited(self): # lbl_close.setBorder(None) # # @Override # def mouseClicked(self): # lbl_close.setBorder(BorderFactory.createLineBorder(Color.red)); # sys.exit(); # cL = CloseClickListener() # lbl_close.addMouseListener(cL) # # lbl_close.setHorizontalAlignment(SwingConstants.CENTER); # lbl_close.setForeground(Color(241, 57, 83)); # lbl_close.setFont(Font("Tahoma", Font.PLAIN, 18)); # lbl_close.setBounds(1071, 0, 37, 27); # contentPane.add(lbl_close); lblPxf = JLabel("Base Temperature (F):") lblPxf.setToolTipText("The temperature at which melt will occur.") lblPxf.setFont(Font("Tahoma", Font.PLAIN, 12)) lblPxf.setBounds(400, 263, 132, 15) contentPane.add(lblPxf) textField_8 = JTextField() textField_8.setFont(Font("Tahoma", Font.PLAIN, 12)) textField_8.setToolTipText("The temperature at which melt will occur.") textField_8.setText("32.0") textField_8.setBounds(548, 263, 40, 20) contentPane.add(textField_8) textField_8.setColumns(10) chckbxShowLocationPlot = JCheckBox("Plot Locations") chckbxShowLocationPlot.setToolTipText( "Will plot the Temp, Precip, SWE, ATI, and Melt for each selected location." ) chckbxShowLocationPlot.setSelected(True) chckbxShowLocationPlot.setBackground(Color.WHITE) chckbxShowLocationPlot.setFont(Font("Tahoma", Font.PLAIN, 12)) chckbxShowLocationPlot.setBounds(547, 310, 120, 23) contentPane.add(chckbxShowLocationPlot) lblEvents = JLabel("Paired Data") lblEvents.setBounds(270, 346, 72, 15) contentPane.add(lblEvents) lblEvents.setFont(Font("Tahoma", Font.PLAIN, 12)) # lblAtiThreshold = JLabel("ATI Threshold:"); # lblAtiThreshold.setToolTipText("Some Melt Events are small & can be ignored. The ATI Threshold is a value that must be reached for the event to be listed."); # lblAtiThreshold.setFont(Font("Tahoma", Font.PLAIN, 12)); # lblAtiThreshold.setBounds(500, 610, 82, 15); # contentPane.add(lblAtiThreshold); # textField_9 = JTextField(); # textField_9.setFont(Font("Tahoma", Font.PLAIN, 12)); # textField_9.setText("0.0"); # textField_9.setToolTipText("Some Melt Events are small & can be ignored. The ATI Threshold is a value that must be reached for the event to be listed."); # textField_9.setColumns(10); # textField_9.setBounds(600, 608, 60, 20); # contentPane.add(textField_9); btnPlot = JButton(btnIcon, actionPerformed=plotPDBtnSelect) btnPlot.setText("Plot Paired Data") btnPlot.setFont(Font("Tahoma", Font.BOLD, 12)) btnPlot.setForeground(Color.WHITE) btnPlot.setBackground(Color.WHITE) btnPlot.setBorderPainted(False) btnPlot.setContentAreaFilled(False) btnPlot.setFocusPainted(False) btnPlot.setOpaque(False) btnPlot.setVerticalTextPosition(SwingConstants.CENTER) btnPlot.setHorizontalTextPosition(SwingConstants.CENTER) btnPlot.setBounds(385, 657, 163, 54) contentPane.add(btnPlot) lblAtimeltrateTable = JLabel("ATI-Meltrate Table") lblAtimeltrateTable.setFont(Font("Tahoma", Font.PLAIN, 12)) lblAtimeltrateTable.setBounds(708, 10, 410, 15) contentPane.add(lblAtimeltrateTable) lblAtimeltrateTable2 = JLabel( "The first ATI value should be 0. ATI values must be ascending.") lblAtimeltrateTable2.setFont(Font("Tahoma", Font.PLAIN, 11)) lblAtimeltrateTable2.setBounds(708, 30, 410, 15) contentPane.add(lblAtimeltrateTable2) btnCalculateMeltrate = JButton(btnIcon, actionPerformed=calcMeltRateBtnSelect) btnCalculateMeltrate.setText("Calculate Meltrate") btnCalculateMeltrate.setFont(Font("Tahoma", Font.BOLD, 12)) btnCalculateMeltrate.setToolTipText( "Calculate Meltrate for ATI values in the ATI-Meltrate Table. Calculation will performed on the Paired Data Records Selected in the Paired Data Table." ) btnCalculateMeltrate.setForeground(Color.WHITE) btnCalculateMeltrate.setBackground(Color.WHITE) btnCalculateMeltrate.setBorderPainted(False) btnCalculateMeltrate.setContentAreaFilled(False) btnCalculateMeltrate.setFocusPainted(False) btnCalculateMeltrate.setOpaque(False) btnCalculateMeltrate.setVerticalTextPosition(SwingConstants.CENTER) btnCalculateMeltrate.setHorizontalTextPosition(SwingConstants.CENTER) btnCalculateMeltrate.setBounds(792, 657, 163, 54) contentPane.add(btnCalculateMeltrate) frame.setVisible(True) dssFile.close()
def draw(self): """ init the match/replace tab """ #todo add an option to ignore large requests padding = 5 labelWidth = 140 labelHeight = 30 editHeight = 110 editWidth = 300 buttonWidth = 120 buttonHeight = 30 column1X = 10 column2X = column1X + labelWidth + padding column3X = column2X + editWidth + padding MRStrings = [ "Headers (simple string):", "Headers (regex):", "Body (simple string):", "Body (regex):" ] row1Y = 10 row2Y = row1Y + labelHeight + padding row3Y = row2Y + editHeight + padding row4Y = row3Y + editHeight + padding row5Y = row4Y + labelHeight + padding row6Y = row5Y + buttonHeight + padding MRTypeLabel = JLabel("Type:") MRTypeLabel.setBounds(column1X, row1Y, labelWidth, labelHeight) MContent = JLabel("Match:") MContent.setBounds(column1X, row2Y, labelWidth, labelHeight) RContent = JLabel("Replace:") RContent.setBounds(column1X, row3Y, labelWidth, labelHeight) MRLabelList = JLabel("Filter List:") MRLabelList.setBounds(column1X, row5Y, labelWidth, labelHeight) self._extender.MRType = JComboBox(MRStrings) self._extender.MRType.setBounds(column2X, row1Y, editWidth, labelHeight) self._extender.MText = JTextArea("", 5, 30) scrollMText = JScrollPane(self._extender.MText) scrollMText.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED) scrollMText.setBounds(column2X, row2Y, editWidth, editHeight) self._extender.RText = JTextArea("", 5, 30) scrollRText = JScrollPane(self._extender.RText) scrollRText.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED) scrollRText.setBounds(column2X, row3Y, editWidth, editHeight) # i couldn't figure out how to have a model that contained anythin other than a string # so i'll use 2 models, one with the data and one for the JList self._extender.badProgrammerMRModel = {} self._extender.MRModel = DefaultListModel() self._extender.MRList = JList(self._extender.MRModel) scrollMRList = JScrollPane(self._extender.MRList) scrollMRList.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED) scrollMRList.setBounds(column2X, row5Y, editWidth, editHeight) scrollMRList.setBorder(LineBorder(Color.BLACK)) self._extender.MRAdd = JButton("Add filter", actionPerformed=self.addMRFilter) self._extender.MRAdd.setBounds(column2X, row4Y, buttonWidth, buttonHeight) self._extender.MRDel = JButton("Remove filter", actionPerformed=self.delMRFilter) self._extender.MRDel.setBounds(column3X, row5Y, buttonWidth, buttonHeight) self._extender.MRMod = JButton("Modify filter", actionPerformed=self.modMRFilter) self._extender.MRMod.setBounds(column3X, row5Y + buttonHeight + padding, buttonWidth, buttonHeight) self._extender.MRFeedback = JLabel("") self._extender.MRFeedback.setBounds(column1X, row6Y, column3X + buttonWidth, labelHeight) self._extender.MRPnl = JPanel() self._extender.MRPnl.setLayout(None) self._extender.MRPnl.setBounds(0, 0, 1000, 1000) self._extender.MRPnl.add(MRTypeLabel) self._extender.MRPnl.add(self._extender.MRType) self._extender.MRPnl.add(MContent) self._extender.MRPnl.add(scrollMText) self._extender.MRPnl.add(RContent) self._extender.MRPnl.add(scrollRText) self._extender.MRPnl.add(self._extender.MRAdd) self._extender.MRPnl.add(MRLabelList) self._extender.MRPnl.add(scrollMRList) self._extender.MRPnl.add(self._extender.MRDel) self._extender.MRPnl.add(self._extender.MRMod) self._extender.MRPnl.add(self._extender.MRFeedback)
def draw(self): """ init interception filters tab """ self._extender.savedHeaders = [{"title": "Temporary headers", "headers": "Cookie: Insert=injected; cookie=or;\nHeader: here"}] # IFStrings has to contains : character IFStrings = ["Scope items only: (Content is not required)", "URL Contains (simple string): ", "URL Contains (regex): ", "URL Not Contains (simple string): ", "URL Not Contains (regex): ", "Only HTTP methods (newline separated): ", "Ignore HTTP methods (newline separated): ", "Ignore spider requests: (Content is not required)", "Ignore proxy requests: (Content is not required)", "Ignore target requests: (Content is not required)"] self._extender.IFType = JComboBox(IFStrings) self._extender.IFType.setBounds(80, 10, 430, 30) self._extender.IFModel = DefaultListModel() self._extender.IFList = JList(self._extender.IFModel) scrollIFList = JScrollPane(self._extender.IFList) scrollIFList.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED) scrollIFList.setBounds(80, 175, 300, 110) scrollIFList.setBorder(LineBorder(Color.BLACK)) # Adding some default interception filters # self.IFModel.addElement("Scope items only: (Content is not required)") # commented for better first impression. self._extender.IFModel.addElement("URL Not Contains (regex): \\.js|\\.css|\\.png|\\.jpg|\\.svg|\\.jpeg|\\.gif|\\.woff|\\.map|\\.bmp|\\.ico$") self._extender.IFModel.addElement("Ignore spider requests: ") self._extender.IFText = JTextArea("", 5, 30) scrollIFText = JScrollPane(self._extender.IFText) scrollIFText.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED) scrollIFText.setBounds(80, 50, 300, 110) IFLType = JLabel("Type:") IFLType.setBounds(10, 10, 140, 30) IFLContent = JLabel("Content:") IFLContent.setBounds(10, 50, 140, 30) IFLabelList = JLabel("Filter List:") IFLabelList.setBounds(10, 165, 140, 30) self._extender.IFAdd = JButton("Add filter", actionPerformed=self.addIFFilter) self._extender.IFAdd.setBounds(390, 85, 120, 30) self._extender.IFDel = JButton("Remove filter", actionPerformed=self.delIFFilter) self._extender.IFDel.setBounds(390, 210, 120, 30) self._extender.IFMod = JButton("Modify filter", actionPerformed=self.modIFFilter) self._extender.IFMod.setBounds(390, 250, 120, 30) self._extender.filtersPnl = JPanel() self._extender.filtersPnl.setLayout(None) self._extender.filtersPnl.setBounds(0, 0, 1000, 1000) self._extender.filtersPnl.add(IFLType) self._extender.filtersPnl.add(self._extender.IFType) self._extender.filtersPnl.add(IFLContent) self._extender.filtersPnl.add(scrollIFText) self._extender.filtersPnl.add(self._extender.IFAdd) self._extender.filtersPnl.add(self._extender.IFDel) self._extender.filtersPnl.add(self._extender.IFMod) self._extender.filtersPnl.add(IFLabelList) self._extender.filtersPnl.add(scrollIFList)
def __init__(self): self.border = LineBorder(Color.black) self.font = Font("Monospaced", Font.PLAIN, self.font.size)
def registerExtenderCallbacks(self, callbacks): # save the helpers for later self.helpers = callbacks.getHelpers() # set our extension name callbacks.setExtensionName("Custom Request Handler") callbacks.registerSessionHandlingAction(self) callbacks.registerContextMenuFactory(self) self._text_editor = callbacks.createTextEditor() self._text_editor.setEditable(False) #How much loaded the table row self.current_column_id = 0 #GUI self._split_main = JSplitPane(JSplitPane.VERTICAL_SPLIT) self._split_top = JSplitPane(JSplitPane.HORIZONTAL_SPLIT) self._split_top.setPreferredSize(Dimension(100, 50)) self._split_top.setDividerLocation(700) self._split_center = JSplitPane(JSplitPane.VERTICAL_SPLIT) boxVertical = swing.Box.createVerticalBox() box_top = swing.Box.createHorizontalBox() boxHorizontal = swing.Box.createHorizontalBox() buttonHorizontal = swing.Box.createHorizontalBox() boxVertical.add(boxHorizontal) box_regex = swing.Box.createVerticalBox() border = BorderFactory.createTitledBorder(LineBorder(Color.BLACK), "Extract target strings", TitledBorder.LEFT, TitledBorder.TOP) box_regex.setBorder(border) self._add_btn = JButton("Add") self._add_btn.addActionListener(self) self._remove_btn = JButton("Remove") self._remove_btn.addActionListener(self) items = [ 'JSON', 'Header', ] self._dropdown = JComboBox(items) type_panel = JPanel(FlowLayout(FlowLayout.LEADING)) type_panel.add(JLabel('Type:')) type_panel.add(self._dropdown) self._jLabel_param = JLabel("Name:") self._param_error = JLabel("Name is required") self._param_error.setVisible(False) self._param_error.setFont(Font(Font.MONOSPACED, Font.ITALIC, 12)) self._param_error.setForeground(Color.red) regex_checkbox = JPanel(FlowLayout(FlowLayout.LEADING)) self._is_use_regex = JCheckBox("Extract from regex group") regex_checkbox.add(self._is_use_regex) self._jTextIn_param = JTextField(20) self._jLabel_regex = JLabel("Regex:") self._jTextIn_regex = JTextField(20) self._regex_error = JLabel("No group defined") self._regex_error.setVisible(False) self._regex_error.setFont(Font(Font.MONOSPACED, Font.ITALIC, 12)) self._regex_error.setForeground(Color.red) self._param_panel = JPanel(FlowLayout(FlowLayout.LEADING)) self._param_panel.add(self._jLabel_param) self._param_panel.add(self._jTextIn_param) self._param_panel.add(self._param_error) self._regex_panel = JPanel(FlowLayout(FlowLayout.LEADING)) self._regex_panel.add(self._jLabel_regex) self._regex_panel.add(self._jTextIn_regex) self._regex_panel.add(self._regex_error) button_panel = JPanel(FlowLayout(FlowLayout.LEADING)) #padding button_panel.add(JPanel()) button_panel.add(JPanel()) button_panel.add(JPanel()) button_panel.add(self._add_btn) button_panel.add(self._remove_btn) box_regex.add(type_panel) box_regex.add(self._param_panel) box_regex.add(regex_checkbox) box_regex.add(self._regex_panel) buttonHorizontal.add(button_panel) box_regex.add(buttonHorizontal) boxVertical.add(box_regex) box_top.add(boxVertical) box_file = swing.Box.createHorizontalBox() checkbox_panel = JPanel(FlowLayout(FlowLayout.LEADING)) border = BorderFactory.createTitledBorder( LineBorder(Color.BLACK), 'Payload Sets [Simple list]', TitledBorder.LEFT, TitledBorder.TOP) box_file.setBorder(border) box_param = swing.Box.createVerticalBox() box_param.add(checkbox_panel) file_column_names = [ "Type", "Name", "Payload", ] data = [] self.file_table_model = DefaultTableModel(data, file_column_names) self.file_table = JTable(self.file_table_model) self.file_table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF) column_model = self.file_table.getColumnModel() for count in xrange(column_model.getColumnCount()): column = column_model.getColumn(count) column.setPreferredWidth(160) self.file_table.preferredScrollableViewportSize = Dimension(500, 70) self.file_table.setFillsViewportHeight(True) panel_dropdown = JPanel(FlowLayout(FlowLayout.LEADING)) self._file_dropdown = JComboBox(items) panel_dropdown.add(JLabel('Type:')) panel_dropdown.add(self._file_dropdown) box_param.add(panel_dropdown) box_param.add(JScrollPane(self.file_table)) callbacks.customizeUiComponent(self.file_table) file_param_panel = JPanel(FlowLayout(FlowLayout.LEADING)) self._file_param = JLabel("Name:") self._file_param_text = JTextField(20) file_param_panel.add(self._file_param) file_param_panel.add(self._file_param_text) self._error_message = JLabel("Name is required") self._error_message.setVisible(False) self._error_message.setFont(Font(Font.MONOSPACED, Font.ITALIC, 12)) self._error_message.setForeground(Color.red) file_param_panel.add(self._error_message) box_param.add(file_param_panel) box_button_file = swing.Box.createVerticalBox() self._file_load_btn = JButton("Load") self._file_clear_btn = JButton("Clear") self._file_clear_btn.addActionListener(self) self._file_load_btn.addActionListener(self) box_button_file.add(self._file_load_btn) box_button_file.add(self._file_clear_btn) box_file.add(box_button_file) box_file.add(box_param) boxVertical.add(box_file) regex_column_names = [ "Type", "Name", "Regex", "Start at offset", "End at offset", ] #clear target.json with open("target.json", "w") as f: pass data = [] self.target_table_model = DefaultTableModel(data, regex_column_names) self.target_table = JTable(self.target_table_model) self.target_table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF) column_model = self.target_table.getColumnModel() for count in xrange(column_model.getColumnCount()): column = column_model.getColumn(count) column.setPreferredWidth(100) self.target_table.preferredScrollableViewportSize = Dimension(500, 70) self.target_table.setFillsViewportHeight(True) callbacks.customizeUiComponent(self.target_table) callbacks.customizeUiComponent(boxVertical) table_panel = swing.Box.createVerticalBox() table_panel.add(JScrollPane(self.target_table)) box_top.add(table_panel) self._jScrollPaneOut = JScrollPane() #self._split_main.setBottomComponent(self._jScrollPaneOut) self._split_main.setBottomComponent(self._text_editor.getComponent()) self._split_main.setTopComponent(box_top) self._split_main.setDividerLocation(450) callbacks.customizeUiComponent(self._split_main) callbacks.addSuiteTab(self) return
def draw_unauthenticated(self): """ init enforcement detector tab """ EDLType = JLabel("Type:") EDLType.setBounds(10, 10, 140, 30) EDLContent = JLabel("Content:") EDLContent.setBounds(10, 50, 140, 30) EDLabelList = JLabel("Filter List:") EDLabelList.setBounds(10, 165, 140, 30) EDStrings = [ "Headers (simple string): (enforced message headers contains)", "Headers (regex): (enforced message headers contains)", "Body (simple string): (enforced message body contains)", "Body (regex): (enforced message body contains)", "Full response (simple string): (enforced message contains)", "Full response (regex): (enforced message contains)", "Full response length: (of enforced response)", "Status code equals: (numbers only)" ] self._extender.EDTypeUnauth = JComboBox(EDStrings) self._extender.EDTypeUnauth.setBounds(80, 10, 430, 30) self._extender.EDTextUnauth = JTextArea("", 5, 30) scrollEDTextUnauth = JScrollPane(self._extender.EDTextUnauth) scrollEDTextUnauth.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED) scrollEDTextUnauth.setBounds(80, 50, 300, 110) self._extender.EDModelUnauth = DefaultListModel() self._extender.EDListUnauth = JList(self._extender.EDModelUnauth) scrollEDListUnauth = JScrollPane(self._extender.EDListUnauth) scrollEDListUnauth.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED) scrollEDListUnauth.setBounds(80, 175, 300, 110) scrollEDListUnauth.setBorder(LineBorder(Color.BLACK)) self._extender.EDAddUnauth = JButton( "Add filter", actionPerformed=self.addEDFilterUnauth) self._extender.EDAddUnauth.setBounds(390, 85, 120, 30) self._extender.EDDelUnauth = JButton( "Remove filter", actionPerformed=self.delEDFilterUnauth) self._extender.EDDelUnauth.setBounds(390, 210, 120, 30) self._extender.EDModUnauth = JButton( "Modify filter", actionPerformed=self.modEDFilterUnauth) self._extender.EDModUnauth.setBounds(390, 250, 120, 30) AndOrStrings = ["And", "Or"] self._extender.AndOrTypeUnauth = JComboBox(AndOrStrings) self._extender.AndOrTypeUnauth.setBounds(390, 170, 120, 30) self._extender.EDPnlUnauth = JPanel() self._extender.EDPnlUnauth.setLayout(None) self._extender.EDPnlUnauth.setBounds(0, 0, 1000, 1000) self._extender.EDPnlUnauth.add(EDLType) self._extender.EDPnlUnauth.add(self._extender.EDTypeUnauth) self._extender.EDPnlUnauth.add(EDLContent) self._extender.EDPnlUnauth.add(scrollEDTextUnauth) self._extender.EDPnlUnauth.add(self._extender.EDAddUnauth) self._extender.EDPnlUnauth.add(self._extender.AndOrTypeUnauth) self._extender.EDPnlUnauth.add(self._extender.EDDelUnauth) self._extender.EDPnlUnauth.add(self._extender.EDModUnauth) self._extender.EDPnlUnauth.add(EDLabelList) self._extender.EDPnlUnauth.add(scrollEDListUnauth)