Beispiel #1
0
    def _create_output_panel(self):
        self.outputPanel = JPanel()
        self.outputEditor = self.callbacks.createTextEditor()
        self.outputEditor.editable = False
        self.outputText = self.outputEditor.component
        self.clearOutputButton = JButton('Clear',
                                         actionPerformed=self.clear_stdout)
        self.outputButtonGroup = ButtonGroup()
        self.outputFileRadioButton = JRadioButton(
            'Save to File:', actionPerformed=self.save_file_output)
        self.outputUIRadioButton = JRadioButton(
            'Show in UI:', selected=True, actionPerformed=self.view_ui_output)
        self.outputFileTextField = JTextField(50,
                                              enabled=False,
                                              disabledTextColor=Color.black)
        self.outputFileBrowseButton = JButton(
            'Browse...', enabled=False, actionPerformed=self.set_output_file)

        self.outputButtonGroup.add(self.outputFileRadioButton)
        self.outputButtonGroup.add(self.outputUIRadioButton)

        outputLayout = GroupLayout(self.outputPanel,
                                   autoCreateGaps=True,
                                   autoCreateContainerGaps=True)
        outputLayout.setHorizontalGroup(
            outputLayout.createParallelGroup().addGroup(
                outputLayout.createSequentialGroup().addComponent(
                    self.outputFileRadioButton).addComponent(
                        self.outputFileTextField, GroupLayout.DEFAULT_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE).addComponent(
                            self.outputFileBrowseButton)).addComponent(
                                self.outputUIRadioButton).addComponent(
                                    self.outputText).addComponent(
                                        self.clearOutputButton))

        outputLayout.setVerticalGroup(
            outputLayout.createSequentialGroup().addGroup(
                outputLayout.createParallelGroup().addComponent(
                    self.outputFileRadioButton).addComponent(
                        self.outputFileTextField, GroupLayout.DEFAULT_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE).addComponent(
                            self.outputFileBrowseButton)).addComponent(
                                self.outputUIRadioButton).addComponent(
                                    self.outputText).addComponent(
                                        self.clearOutputButton))
        self.outputPanel.layout = outputLayout
Beispiel #2
0
 def __init__(self, callbacks):
     super(SpyTab, self).__init__(GroupLayout(self))
     self._callbacks = callbacks
     config = Config(self._callbacks, self)
     about = About(self._callbacks)
     # plugs = Plugins(self._callbacks)
     self.tabs = [config, about]
     self.j_tabs = self.build_ui()
     self.add(self.j_tabs)
Beispiel #3
0
    def _create_error_panel(self):
        self.errorPanel = JPanel()
        self.errorEditor = self.callbacks.createTextEditor()
        self.errorEditor.editable = False
        self.errorText = self.errorEditor.component
        self.clearErrorButton = JButton('Clear',
                                        actionPerformed=self.clear_stderr)

        errorLayout = GroupLayout(self.errorPanel,
                                  autoCreateGaps=True,
                                  autoCreateContainerGaps=True)
        errorLayout.setHorizontalGroup(
            errorLayout.createParallelGroup().addComponent(
                self.errorText).addComponent(self.clearErrorButton))
        errorLayout.setVerticalGroup(
            errorLayout.createSequentialGroup().addComponent(
                self.errorText).addComponent(self.clearErrorButton))
        self.errorPanel.layout = errorLayout
Beispiel #4
0
    def createTabGUI(self):
        """ Create GUI for this tabbed pane """

        # panel for the whole tab
        self.firstTab = JPanel()

        # name of the extention
        self.titleTop = JLabel("Timing Attack")
        self.titleTop.setFont(Font("Tahoma", 1, 14))
        self.titleTop.setForeground(Color(255, 102, 51))

        # info about the extention
        self.infoTop = JLabel(
            "Timing Attack is a open source extention to inform how long the system takes to respond for a valid and an invalid authentication."
        )
        self.infoTop.setFont(Font("Tahoma", 0, 11))

        # labels and inputs on top half
        self.addTitle = JLabel("Enter a Valid and an Invalid Username")
        self.addTitle.setFont(Font("Tahoma", 1, 13))
        self.addTitle.setForeground(Color(255, 102, 51))
        self.validUsername = JLabel("Valid Username")
        self.validUsername.setFont(Font("Tahoma", 0, 12))
        self.invalidUsername = JLabel("Invalid Username")
        self.invalidUsername.setFont(Font("Tahoma", 0, 12))
        self.parameter = JLabel("Parameter")
        self.parameter.setFont(Font("Tahoma", 0, 12))
        self.average = JLabel("Sample Size")
        self.average.setFont(Font("Tahoma", 0, 12))
        self.addValid = JTextField("")
        self.addInvalid = JTextField("")
        self.addParameter = JTextField("")
        self.addAverage = JTextField("")
        self.submitButton1 = JButton("Submit",
                                     actionPerformed=self.timeTwoUsers)

        # result on top left
        self.resultTitle = JLabel("Result")
        self.resultTitle.setFont(Font("Tahoma", 1, 13))
        self.resultTitle.setForeground(Color(255, 102, 51))
        self.showResults = JTextArea("")
        self.showResults.setEditable(False)
        self.showResultsScroll = JScrollPane(self.showResults)
        self.twoUserViewResult = JButton("View Results",
                                         actionPerformed=self.showResultsTop)
        self.twoUserViewReq = JButton("View Request",
                                      actionPerformed=self.showRequestTop)
        self.twoUserViewValidResponse = JButton(
            "View Valid Response", actionPerformed=self.showValidResponseTop)
        self.twoUserViewInvalidResponse = JButton(
            "View Invalid Response",
            actionPerformed=self.showInvalidResponseTop)
        # Set top buttons to invisible until a request is submitted
        self.twoUserViewResult.setVisible(False)
        self.twoUserViewReq.setVisible(False)
        self.twoUserViewValidResponse.setVisible(False)
        self.twoUserViewInvalidResponse.setVisible(False)

        # labels, inputs and file on bottom half
        self.addTitleFile = JLabel("Input Username File")
        self.addTitleFile.setFont(Font("Tahoma", 1, 13))
        self.addTitleFile.setForeground(Color(255, 102, 51))
        self.inputFileButton = JButton("Choose File...",
                                       actionPerformed=self.chooseFile)
        self.separatorList = JLabel("Separator")
        self.separatorList.setFont(Font("Tahoma", 0, 12))
        self.parameterList = JLabel("Parameter")
        self.parameterList.setFont(Font("Tahoma", 0, 12))
        self.averageList = JLabel("Sample Size")
        self.averageList.setFont(Font("Tahoma", 0, 12))
        self.addSeparatorList = JTextField("")
        self.addParameterList = JTextField("")
        self.addAverageList = JTextField("")
        self.submitButton2 = JButton("Submit",
                                     actionPerformed=self.timeUserList)

        # result on bottom left
        self.resultTitleList = JLabel("Result")
        self.resultTitleList.setFont(Font("Tahoma", 1, 13))
        self.resultTitleList.setForeground(Color(255, 102, 51))
        self.showResultsList = JTextArea("")
        self.showResultsList.setEditable(False)
        self.showResultsListScroll = JScrollPane(self.showResultsList)
        self.downloadResultList = JButton("Download Display",
                                          actionPerformed=self.downloadResults)
        self.listViewResults = JButton("View Results",
                                       actionPerformed=self.showListResults)
        self.listViewReq = JButton("View Request",
                                   actionPerformed=self.showListRequest)
        self.listViewResponses = JButton(
            "View Responses", actionPerformed=self.showListResponses)
        # Set list buttons to invisible until a request is submitted
        self.downloadResultList.setVisible(False)
        self.listViewResults.setVisible(False)
        self.listViewReq.setVisible(False)
        self.listViewResponses.setVisible(False)

        # something wrong?
        self.somethingWrong = JLabel("Something Wrong?")
        self.debugOn = False
        self.viewDebug = JButton("View debug output",
                                 actionPerformed=self.showDebug)
        self.debugText = JTextArea("")
        self.debugTextScroll = JScrollPane(self.debugText)
        self.debugTextScroll.setVisible(False)

        # layout
        layout = GroupLayout(self.firstTab)
        self.firstTab.setLayout(layout)

        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            # whole layout
            .addGroup(
                layout.createSequentialGroup().addGap(15)
                # title + description
                .addGroup(
                    layout.createParallelGroup(
                        GroupLayout.Alignment.LEADING).addComponent(
                            self.titleTop).addComponent(self.infoTop)
                    # titles
                    .addGroup(
                        layout.createSequentialGroup()
                        # title left
                        .addGroup(
                            layout.createParallelGroup(
                                GroupLayout.Alignment.LEADING).addComponent(
                                    self.addTitle)).addGap(168)
                        # title right
                        .addGroup(
                            layout.createParallelGroup(
                                GroupLayout.Alignment.LEADING).addComponent(
                                    self.resultTitle))).
                    addGroup(
                        layout.createSequentialGroup()
                        # left
                        .addGroup(
                            layout.createParallelGroup(
                                GroupLayout.Alignment.LEADING).addComponent(
                                    self.validUsername).addComponent(
                                        self.invalidUsername).addComponent(
                                            self.parameter).addComponent(
                                                self.average).addComponent(
                                                    self.addTitleFile).
                            addComponent(self.inputFileButton).addComponent(
                                self.separatorList).addComponent(
                                    self.parameterList).addComponent(
                                        self.averageList).addComponent(
                                            self.somethingWrong)).addGap(12).
                        addGroup(
                            layout.createParallelGroup(
                                GroupLayout.Alignment.LEADING).addComponent(
                                    self.addValid, GroupLayout.PREFERRED_SIZE,
                                    200,
                                    GroupLayout.PREFERRED_SIZE).addComponent(
                                        self.addInvalid,
                                        GroupLayout.PREFERRED_SIZE, 200,
                                        GroupLayout.PREFERRED_SIZE).
                            addComponent(
                                self.addParameter,
                                GroupLayout.PREFERRED_SIZE, 200,
                                GroupLayout.PREFERRED_SIZE).addComponent(
                                    self.addAverage,
                                    GroupLayout.PREFERRED_SIZE, 80,
                                    GroupLayout.PREFERRED_SIZE).addComponent(
                                        self.submitButton1).addComponent(
                                            self.addSeparatorList,
                                            GroupLayout.PREFERRED_SIZE, 200,
                                            GroupLayout.PREFERRED_SIZE).
                            addComponent(
                                self.addParameterList,
                                GroupLayout.PREFERRED_SIZE, 200,
                                GroupLayout.PREFERRED_SIZE).addComponent(
                                    self.addAverageList,
                                    GroupLayout.PREFERRED_SIZE, 80,
                                    GroupLayout.PREFERRED_SIZE).addComponent(
                                        self.submitButton2).addComponent(
                                            self.viewDebug)).addGap(50)
                        # right
                        .addGroup(
                            layout.createParallelGroup(
                                GroupLayout.Alignment.LEADING).addComponent(
                                    self.showResultsScroll,
                                    GroupLayout.PREFERRED_SIZE, 600,
                                    GroupLayout.PREFERRED_SIZE).
                            addGroup(layout.createSequentialGroup().addGroup(
                                layout.createParallelGroup(
                                    GroupLayout.Alignment.LEADING).
                                addComponent(self.twoUserViewResult)
                            ).addGap(15).addGroup(
                                layout.createParallelGroup(
                                    GroupLayout.Alignment.LEADING).
                                addComponent(
                                    self.twoUserViewReq)).addGap(15).addGroup(
                                        layout.createParallelGroup(
                                            GroupLayout.Alignment.LEADING).
                                        addComponent(
                                            self.twoUserViewValidResponse)
                                    ).addGap(15).addGroup(
                                        layout.createParallelGroup(
                                            GroupLayout.Alignment.LEADING).
                                        addComponent(
                                            self.twoUserViewInvalidResponse))).
                            addComponent(self.resultTitleList).addComponent(
                                self.showResultsListScroll,
                                GroupLayout.PREFERRED_SIZE, 600,
                                GroupLayout.PREFERRED_SIZE).addGroup(
                                    layout.createSequentialGroup().addGroup(
                                        layout.createParallelGroup(
                                            GroupLayout.Alignment.LEADING).
                                        addComponent(self.downloadResultList)).
                                    addGap(15).addGroup(
                                        layout.createParallelGroup(
                                            GroupLayout.Alignment.LEADING).
                                        addComponent(self.listViewResults)
                                    ).addGap(15).addGroup(
                                        layout.createParallelGroup(
                                            GroupLayout.Alignment.LEADING).
                                        addComponent(self.listViewReq)
                                    ).addGap(15).addGroup(
                                        layout.createParallelGroup(
                                            GroupLayout.Alignment.LEADING).
                                        addComponent(self.listViewResponses)
                                    )).addGap(10).addComponent(
                                        self.debugTextScroll,
                                        GroupLayout.PREFERRED_SIZE, 300,
                                        GroupLayout.PREFERRED_SIZE))))))

        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            # whole layout
            .addGroup(
                layout.createSequentialGroup().addGap(15).addComponent(
                    self.titleTop).addGap(10).addComponent(
                        self.infoTop).addGap(10)
                # titles
                .addGroup(
                    layout.createSequentialGroup()
                    # left
                    .addGroup(
                        layout.createParallelGroup(
                            GroupLayout.Alignment.LEADING).addComponent(
                                self.addTitle).addGap(25)
                        # right
                        .addGroup(
                            layout.createParallelGroup(
                                GroupLayout.Alignment.LEADING).addComponent(
                                    self.resultTitle))))
                # top half
                .addGroup(
                    layout.createSequentialGroup()
                    # left top half
                    .addGroup(
                        layout.createParallelGroup(
                            GroupLayout.Alignment.BASELINE).
                        addGroup(layout.createSequentialGroup().addGroup(
                            layout.createParallelGroup(
                                GroupLayout.Alignment.BASELINE).addComponent(
                                    self.validUsername).addGap(5).addComponent(
                                        self.addValid,
                                        GroupLayout.PREFERRED_SIZE,
                                        GroupLayout.DEFAULT_SIZE,
                                        GroupLayout.PREFERRED_SIZE)
                        ).addGap(5).addGroup(
                            layout.createParallelGroup(
                                GroupLayout.Alignment.BASELINE).addComponent(
                                    self.invalidUsername).addGap(
                                        5).addComponent(
                                            self.addInvalid,
                                            GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.PREFERRED_SIZE)
                        ).addGap(5).addGroup(
                            layout.createParallelGroup(
                                GroupLayout.Alignment.BASELINE).addComponent(
                                    self.parameter).addGap(5).addComponent(
                                        self.addParameter,
                                        GroupLayout.PREFERRED_SIZE,
                                        GroupLayout.DEFAULT_SIZE,
                                        GroupLayout.PREFERRED_SIZE)
                        ).addGap(5).addGroup(
                            layout.createParallelGroup(
                                GroupLayout.Alignment.BASELINE).addComponent(
                                    self.average).addGap(5).addComponent(
                                        self.addAverage,
                                        GroupLayout.PREFERRED_SIZE,
                                        GroupLayout.DEFAULT_SIZE,
                                        GroupLayout.PREFERRED_SIZE)
                        ).addGap(5).addGroup(
                            layout.createParallelGroup(
                                GroupLayout.Alignment.BASELINE).addComponent(
                                    self.submitButton1))).addGap(5)
                        # right top half
                        .addGroup(
                            layout.createParallelGroup(
                                GroupLayout.Alignment.BASELINE).addComponent(
                                    self.showResultsScroll,
                                    GroupLayout.PREFERRED_SIZE, 200,
                                    GroupLayout.PREFERRED_SIZE)))).addGap(5)
                # buttons + titles
                .addGroup(layout.createSequentialGroup().addGroup(
                    layout.createParallelGroup(
                        GroupLayout.Alignment.BASELINE).addComponent(
                            self.twoUserViewResult).addGap(20).addComponent(
                                self.twoUserViewReq).addGap(20).addComponent(
                                    self.twoUserViewValidResponse).addGap(20).
                    addComponent(
                        self.twoUserViewInvalidResponse)).addGap(10).addGroup(
                            layout.createParallelGroup(
                                GroupLayout.Alignment.BASELINE).addComponent(
                                    self.addTitleFile).addGap(25).addComponent(
                                        self.resultTitleList))).addGap(3)
                # bottom half
                .addGroup(
                    layout.createSequentialGroup()
                    # left bottom half
                    .addGroup(
                        layout.createParallelGroup(
                            GroupLayout.Alignment.BASELINE).
                        addGroup(layout.createSequentialGroup().addGroup(
                            layout.createParallelGroup(
                                GroupLayout.Alignment.BASELINE).addComponent(
                                    self.inputFileButton)
                        ).addGap(10).addGroup(
                            layout.createParallelGroup(
                                GroupLayout.Alignment.BASELINE).addComponent(
                                    self.separatorList).addGap(5).addComponent(
                                        self.addSeparatorList,
                                        GroupLayout.PREFERRED_SIZE,
                                        GroupLayout.DEFAULT_SIZE,
                                        GroupLayout.PREFERRED_SIZE)
                        ).addGap(5).addGroup(
                            layout.createParallelGroup(
                                GroupLayout.Alignment.BASELINE).addComponent(
                                    self.parameterList).addGap(5).addComponent(
                                        self.addParameterList,
                                        GroupLayout.PREFERRED_SIZE,
                                        GroupLayout.DEFAULT_SIZE,
                                        GroupLayout.PREFERRED_SIZE)
                        ).addGap(5).addGroup(
                            layout.createParallelGroup(
                                GroupLayout.Alignment.BASELINE).addComponent(
                                    self.averageList).addGap(5).addComponent(
                                        self.addAverageList,
                                        GroupLayout.PREFERRED_SIZE,
                                        GroupLayout.DEFAULT_SIZE,
                                        GroupLayout.PREFERRED_SIZE)
                        ).addGap(5).addGroup(
                            layout.createParallelGroup(
                                GroupLayout.Alignment.BASELINE).addComponent(
                                    self.submitButton2)
                        )).addGap(5).addGroup(
                            layout.createParallelGroup(
                                GroupLayout.Alignment.BASELINE).addComponent(
                                    self.showResultsListScroll,
                                    GroupLayout.PREFERRED_SIZE, 200,
                                    GroupLayout.PREFERRED_SIZE)))).addGap(5)
                # right bottom half
                .addGroup(layout.createSequentialGroup().addGroup(
                    layout.createParallelGroup(
                        GroupLayout.Alignment.BASELINE).addComponent(
                            self.downloadResultList).addGap(10).addComponent(
                                self.listViewResults).addGap(10).addComponent(
                                    self.listViewReq).addGap(10).addComponent(
                                        self.listViewResponses))).addGap(30)
                # something wrong section
                .addGroup(layout.createSequentialGroup().addGroup(
                    layout.createParallelGroup(
                        GroupLayout.Alignment.BASELINE).addComponent(
                            self.somethingWrong).addGap(10).addComponent(
                                self.viewDebug).addGap(10).addComponent(
                                    self.debugTextScroll,
                                    GroupLayout.PREFERRED_SIZE, 150,
                                    GroupLayout.PREFERRED_SIZE)))))
        return
Beispiel #5
0
    def __init__(self):
        self.jScrollPane1 = JScrollPane()
        self.jTable1 = JTable()
        self.jPanel1 = JPanel()
        self.labelName = JLabel()
        self.textName = JTextField()
        self.labelSeverity = JLabel()
        self.comboSeverity = None
        self.labelHost = JLabel()
        self.labelPath = JLabel()
        self.textHost = JTextField()
        self.textPath = JTextField()
        self.tabIssue = JTabbedPane()
        self.panelDescription = JPanel()
        self.panelRequest = JPanel()
        self.panelResponse = JPanel()
        self.panelRemediation = JPanel()

        # setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)

        # setting up the table
        # initial data in the table
        tableData = [
            [3, "Issue3", "Severity3", "Host3", "Path3"],
            [1, "Issue1", "Severity1", "Host1", "Path1"],
            [2, "Issue2", "Severity2", "Host2", "Path2"],
        ]
        tableHeadings = ["#", "Issue Type/Name", "Severity", "Host", "Path"]
        from IssueTable import IssueTable
        self.jTable1 = IssueTable(tableData, tableHeadings)

        # wrap the table in a scrollpane
        self.jScrollPane1.setViewportView(self.jTable1)

        # top panel containing the table
        from java.awt import Color
        self.jPanel1.setBorder(BorderFactory.createLineBorder(Color(0, 0, 0)))

        # create the labels and textfields
        self.labelName.text = "Issue Type/Name"
        self.textName.text = "Issue Name/Type"
        self.textName.editable = False
        self.labelSeverity.text = "Severity"
        # create and populate the combobox
        self.comboSeverity = JComboBox(
            ["Critical", "High", "Medium", "Low", "Info"])

        self.labelHost.text = "Host"
        self.labelPath.text = "Path"
        self.textHost.text = "Issue Host"
        self.textHost.editable = False
        self.textPath.text = "Issue Path"
        self.textPath.editable = False

        from java.lang import Short
        # description panel
        panelDescriptionLayout = GroupLayout(self.panelDescription)
        self.panelDescription.setLayout(panelDescriptionLayout)
        panelDescriptionLayout.setHorizontalGroup(
            panelDescriptionLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE))
        panelDescriptionLayout.setVerticalGroup(
            panelDescriptionLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE))
        self.tabIssue.addTab("Description", self.panelDescription)

        # request tab
        panelRequestLayout = GroupLayout(self.panelRequest)
        self.panelRequest.setLayout(panelRequestLayout)
        panelRequestLayout.setHorizontalGroup(
            panelRequestLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE))
        panelRequestLayout.setVerticalGroup(
            panelRequestLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE))
        self.tabIssue.addTab("Request", self.panelRequest)

        # response tab
        panelResponseLayout = GroupLayout(self.panelResponse)
        self.panelResponse.setLayout(panelResponseLayout)
        panelResponseLayout.setHorizontalGroup(
            panelResponseLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE))
        panelResponseLayout.setVerticalGroup(
            panelResponseLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE))
        self.tabIssue.addTab("Response", self.panelResponse)

        # remediation tab
        panelRemediationLayout = GroupLayout(self.panelRemediation)
        self.panelRemediation.setLayout(panelRemediationLayout)
        panelRemediationLayout.setHorizontalGroup(
            panelRemediationLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE))
        panelRemediationLayout.setVerticalGroup(
            panelRemediationLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE))
        self.tabIssue.addTab("Remediation", self.panelRemediation)

        # jpanel1?
        jPanel1Layout = GroupLayout(self.jPanel1)
        self.jPanel1.setLayout(jPanel1Layout)
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING).
            addGroup(jPanel1Layout.createSequentialGroup().addContainerGap(
            ).addGroup(
                jPanel1Layout.createParallelGroup(
                    GroupLayout.Alignment.LEADING).
                addGroup(jPanel1Layout.createSequentialGroup().addGroup(
                    jPanel1Layout.createParallelGroup(
                        GroupLayout.Alignment.TRAILING).addComponent(
                            self.labelHost).addComponent(
                                self.labelSeverity).addComponent(
                                    self.labelName)
                ).addPreferredGap(
                    LayoutStyle.ComponentPlacement.UNRELATED).addGroup(
                        jPanel1Layout.createParallelGroup(
                            GroupLayout.Alignment.LEADING).
                        addComponent(self.textName).addGroup(
                            jPanel1Layout.createSequentialGroup().addComponent(
                                self.comboSeverity, GroupLayout.PREFERRED_SIZE,
                                98, GroupLayout.PREFERRED_SIZE).addGap(
                                    0, 0, Short.MAX_VALUE)).
                        addGroup(
                            jPanel1Layout.createSequentialGroup().addComponent(
                                self.textHost, GroupLayout.PREFERRED_SIZE, 330,
                                GroupLayout.PREFERRED_SIZE).addGap(18, 18, 18).
                            addComponent(self.labelPath).addPreferredGap(
                                LayoutStyle.ComponentPlacement.RELATED
                            ).addComponent(self.textPath)))).addComponent(
                                self.tabIssue)).addContainerGap()))

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING).
            addGroup(jPanel1Layout.createSequentialGroup().addContainerGap(
            ).addGroup(
                jPanel1Layout.createParallelGroup(
                    GroupLayout.Alignment.BASELINE).addComponent(
                        self.labelName).addComponent(
                            self.textName, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
            ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(
                jPanel1Layout.createParallelGroup(
                    GroupLayout.Alignment.BASELINE).addComponent(
                        self.labelSeverity).addComponent(
                            self.comboSeverity, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
            ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(
                jPanel1Layout.createParallelGroup(
                    GroupLayout.Alignment.BASELINE).addComponent(
                        self.labelHost).addComponent(
                            self.labelPath).addComponent(
                                self.textHost, GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE).addComponent(
                                    self.textPath, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)).
                     addPreferredGap(
                         LayoutStyle.ComponentPlacement.RELATED).addComponent(
                             self.tabIssue).addContainerGap()))

        # create the main panel
        self.panel = JPanel()
        layout = GroupLayout(self.panel)
        self.panel.setLayout(layout)
        layout.setAutoCreateGaps(True)

        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
                layout.createSequentialGroup().addContainerGap().addGroup(
                    layout.createParallelGroup(
                        GroupLayout.Alignment.LEADING).addComponent(
                            self.jPanel1, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.DEFAULT_SIZE,
                            Short.MAX_VALUE).addComponent(
                                self.jScrollPane1)).addContainerGap()))
        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
                layout.createSequentialGroup().addContainerGap().addComponent(
                    self.jScrollPane1, GroupLayout.PREFERRED_SIZE, 119,
                    GroupLayout.PREFERRED_SIZE).addGap(
                        18, 18,
                        18).addComponent(self.jPanel1,
                                         GroupLayout.DEFAULT_SIZE,
                                         GroupLayout.DEFAULT_SIZE,
                                         Short.MAX_VALUE).addContainerGap()))
Beispiel #6
0
    def __initLayout__( self ):
        self._levelComboBox = JComboBox()
        levelComboBoxSize = Dimension( 300, 30 )
        self._levelComboBox.setPreferredSize( levelComboBoxSize )
        self._levelComboBox.setMaximumSize( levelComboBoxSize )
        for level in range( 0, 6 ):
            self._levelComboBox.addItem( str( level ) )

        self._techRenderedCheckBox = JCheckBox( 'Rendered', True )
        self._techTimebasedCheckBox = JCheckBox( 'Time-based', True )

        self._plugin_groups = {}
        for plugin in plugins:
            parent = plugin.__base__.__name__
            if not self._plugin_groups.has_key( parent ):
                self._plugin_groups[ parent ] = []
            self._plugin_groups[ parent ].append( plugin )
        self._pluginCheckBoxes = []
        for pluginGroup in self._plugin_groups.values():
            for plugin in pluginGroup:
                self._pluginCheckBoxes.append( PluginCheckBox( plugin ) )

        self._positionReplaceCheckBox = JCheckBox( 'Replace', True )
        self._positionAppendCheckBox = JCheckBox( 'Append', False )

        displayItems = (
            {
                'label': 'Level',
                'components': ( self._levelComboBox, ),
                'description': 'Level of code context escape to perform (1-5, Default:0).'
            },
            {
                'label': 'Techniques',
                'components': ( self._techRenderedCheckBox, self._techTimebasedCheckBox, ),
                'description': 'Techniques R(endered) T(ime-based blind). Default: RT.'
            },
            {
                'label': 'Template Engines',
                'components': self._pluginCheckBoxes,
                'description': 'Force back-end template engine to this value(s).'
            },
            {
                'label': 'Payload position',
                'components': ( self._positionReplaceCheckBox, self._positionAppendCheckBox, ),
                'description': 'Scan payload position. This feature only appears in BurpExtension.'
            }
        )

        layout = GroupLayout( self )
        self.setLayout( layout )
        layout.setAutoCreateGaps( True )
        layout.setAutoCreateContainerGaps( True )

        labelWidth = 200
        hgroup =  layout.createParallelGroup( GroupLayout.Alignment.LEADING )
        vgroup = layout.createSequentialGroup()
        for displayItem in displayItems:
            label = JLabel( displayItem.get( 'label' ) )
            label.setToolTipText( displayItem.get( 'description' ) )
            _hgroup = layout.createSequentialGroup().addComponent( label, labelWidth, labelWidth, labelWidth )
            _vgroup = layout.createParallelGroup( GroupLayout.Alignment.BASELINE ).addComponent( label )
            for component in displayItem.get( 'components' ):
                _hgroup.addComponent( component )
                _vgroup.addComponent( component )
            hgroup.addGroup( _hgroup )
            vgroup.addGroup( _vgroup )

        layout.setHorizontalGroup( hgroup )
        layout.setVerticalGroup( vgroup )
Beispiel #7
0
class BurpExtender(IBurpExtender, IExtensionStateListener, IHttpListener, ITab,
                   FocusListener, ActionListener, MouseAdapter):
    _version = "0.2"
    _name = "PyRules"
    _varsStorage = _name + "_vars"
    _scriptStorage = _name + "_script"

    _enabled = 0
    _vars = {}

    def registerExtenderCallbacks(self, callbacks):
        print "Load:" + self._name + " " + self._version

        self.callbacks = callbacks
        self.helpers = callbacks.helpers

        #Create Tab layout
        self.jVarsPane = JTextPane()
        self.jVarsPane.setFont(Font('Monospaced', Font.PLAIN, 11))
        self.jVarsPane.addFocusListener(self)

        self.jMenuPanel = JPanel()
        self.jLeftUpPanel = JPanel()

        self.jEnable = JCheckBox()
        self.jEnable.setFont(Font('Monospaced', Font.BOLD, 11))
        self.jEnable.setForeground(Color(0, 0, 204))
        self.jEnable.setText(self._name)
        self.jEnable.addActionListener(self)

        self.jDocs = JLabel()
        self.jDocs.setFont(Font('Monospaced', Font.PLAIN, 11))
        self.jDocs.setForeground(Color(51, 102, 255))
        self.jDocs.setText(Strings.docs_titel)
        self.jDocs.setToolTipText(Strings.docs_tooltip)
        self.jDocs.addMouseListener(self)

        self.jConsoleText = JTextArea()
        self.jConsoleText.setFont(Font('Monospaced', Font.PLAIN, 10))
        self.jConsoleText.setBackground(Color(244, 246, 247))
        self.jConsoleText.setEditable(0)
        self.jConsoleText.setWrapStyleWord(1)
        self.jConsoleText.setRows(10)
        self.jScrollConsolePane = JScrollPane()
        self.jScrollConsolePane.setViewportView(self.jConsoleText)
        #set initial text
        self.jConsoleText.setText(Strings.console_disable)

        self.jMenuPanelLayout = GroupLayout(self.jMenuPanel)
        self.jMenuPanel.setLayout(self.jMenuPanelLayout)
        self.jMenuPanelLayout.setHorizontalGroup(
            self.jMenuPanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGroup(
                    self.jMenuPanelLayout.createSequentialGroup().addComponent(
                        self.jEnable).addPreferredGap(
                            LayoutStyle.ComponentPlacement.RELATED, 205,
                            32767).addComponent(self.jDocs)))

        self.jMenuPanelLayout.setVerticalGroup(
            self.jMenuPanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGroup(
                    self.jMenuPanelLayout.createSequentialGroup().addGroup(
                        self.jMenuPanelLayout.createParallelGroup(
                            GroupLayout.Alignment.BASELINE).addComponent(
                                self.jEnable).addComponent(self.jDocs)).addGap(
                                    0, 7, 32767)))

        self.jConsolePane = JPanel()
        self.jConsoleLayout = GroupLayout(self.jConsolePane)
        self.jConsolePane.setLayout(self.jConsoleLayout)
        self.jConsoleLayout.setHorizontalGroup(
            self.jConsoleLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addComponent(
                    self.jScrollConsolePane))
        self.jConsoleLayout.setVerticalGroup(
            self.jConsoleLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGroup(
                    GroupLayout.Alignment.TRAILING,
                    self.jConsoleLayout.createSequentialGroup().addComponent(
                        self.jScrollConsolePane, GroupLayout.DEFAULT_SIZE, 154,
                        32767).addContainerGap()))
        self.jLeftUpPanelLayout = GroupLayout(self.jLeftUpPanel)
        self.jLeftUpPanel.setLayout(self.jLeftUpPanelLayout)
        self.jLeftUpPanelLayout.setHorizontalGroup(
            self.jLeftUpPanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addComponent(
                    self.jConsolePane, GroupLayout.DEFAULT_SIZE,
                    GroupLayout.DEFAULT_SIZE,
                    32767).addComponent(self.jMenuPanel,
                                        GroupLayout.DEFAULT_SIZE,
                                        GroupLayout.DEFAULT_SIZE,
                                        GroupLayout.PREFERRED_SIZE))
        self.jLeftUpPanelLayout.setVerticalGroup(
            self.jLeftUpPanelLayout.
            createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
                GroupLayout.Alignment.TRAILING,
                self.jLeftUpPanelLayout.createSequentialGroup().addComponent(
                    self.jMenuPanel, GroupLayout.PREFERRED_SIZE,
                    GroupLayout.DEFAULT_SIZE,
                    GroupLayout.PREFERRED_SIZE).addPreferredGap(
                        LayoutStyle.ComponentPlacement.RELATED).addComponent(
                            self.jConsolePane, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.DEFAULT_SIZE, 32767)))

        self.jScrollpaneLeftDown = JScrollPane()
        self.jScrollpaneLeftDown.setViewportView(self.jVarsPane)

        self.jSplitPaneLeft = JSplitPane(JSplitPane.VERTICAL_SPLIT,
                                         self.jLeftUpPanel,
                                         self.jScrollpaneLeftDown)
        self.jSplitPaneLeft.setDividerLocation(300)

        self.jScriptPane = JTextPane()
        self.jScriptPane.setFont(Font('Monospaced', Font.PLAIN, 11))
        self.jScriptPane.addMouseListener(self)

        self.JScrollPaneRight = JScrollPane()
        self.JScrollPaneRight.setViewportView(self.jScriptPane)

        self.jSplitPane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
                                     self.jSplitPaneLeft,
                                     self.JScrollPaneRight)
        self.jSplitPane.setDividerLocation(400)

        #Load saved saved settings
        ##Load vars
        vars = callbacks.loadExtensionSetting(self._varsStorage)
        if vars:
            vars = base64.b64decode(vars)
        else:
            # try to load the example
            try:
                with open("examples/Simple-CSRF-vars.py") as fvars:
                    vars = fvars.read()
            # load the default text
            except:
                vars = Strings.vars

        ## initiate the persistant variables
        locals_ = {}
        try:
            exec(vars, {}, locals_)
        except Exception as e:
            print e
        self._vars = locals_

        ## update the vars screen
        self.jVarsPane.document.insertString(self.jVarsPane.document.length,
                                             vars, SimpleAttributeSet())

        ##Load script
        script = callbacks.loadExtensionSetting(self._scriptStorage)
        if script:
            script = base64.b64decode(script)
        else:
            # try to load the example
            try:
                with open("examples/Simple-CSRF-script.py") as fscript:
                    script = fscript.read()
            # load the default text
            except:
                script = Strings.script

        ## compile the rules
        self._script = script
        self._code = ''

        try:
            self._code = compile(script, '<string>', 'exec')
        except Exception as e:
            print(
                '{}\nReload extension after you correct the error.'.format(e))

        ## update the rules screen
        self.jScriptPane.document.insertString(
            self.jScriptPane.document.length, script, SimpleAttributeSet())

        #Register Extension
        callbacks.customizeUiComponent(self.getUiComponent())
        callbacks.addSuiteTab(self)
        callbacks.registerExtensionStateListener(self)
        callbacks.registerHttpListener(self)

        self.jScriptPane.requestFocus()

    def getUiComponent(self):
        return self.jSplitPane

    def getTabCaption(self):
        return self._name

    def actionPerformed(self, event):
        #Check box was clicked
        if self.jEnable == event.getSource():
            if self._enabled == 1:
                self._enabled = 0
                # console content shows help
                self.jConsoleText.setText(Strings.console_disable)
            else:
                self._enabled = 1
                # console content displays the current persistent variable state
                self.jConsoleText.setText(Strings.console_state)
                self.jConsoleText.append(pformat(self._vars))
                self.jConsoleText.append(Strings.extra_line)
                self.jConsoleText.append(Strings.console_log)
        return

    def mouseClicked(self, event):
        if event.source == self.jDocs:
            uri = URI.create("https://github.com/DanNegrea/PyRules")
            if uri and Desktop.isDesktopSupported() and Desktop.getDesktop(
            ).isSupported(Desktop.Action.BROWSE):
                Desktop.getDesktop().browse(uri)
        return

    def focusGained(self, event):

        if self.jConsolePane == event.getSource():
            pass
            #print "Status pane gained focus" #debug
        return

    def focusLost(self, event):
        #Reinitialize the persistent values
        if self.jVarsPane == event.getSource():
            # get the text from the pane
            end = self.jVarsPane.document.length
            vars = self.jVarsPane.document.getText(0, end)

            # compute the new values
            locals_ = {}
            exec(vars, {}, locals_)
            self._vars = locals_

            # display the new result in console
            self.jConsoleText.append(Strings.console_state)
            self.jConsoleText.append(pformat(self._vars))
            self.jConsoleText.append(Strings.extra_line)
            self.jConsoleText.append(Strings.console_log)

            # scroll to bottom
            verticalScrollBar = self.jScrollConsolePane.getVerticalScrollBar()
            verticalScrollBar.setValue(verticalScrollBar.getMaximum())
        return

    def extensionUnloaded(self):
        try:
            #Save the latestest vars and script text
            ## save vars
            end = self.jVarsPane.document.length
            vars = self.jVarsPane.document.getText(0, end)
            vars = base64.b64encode(vars)
            self.callbacks.saveExtensionSetting(self._varsStorage, vars)
            ## save script/rules
            end = self.jScriptPane.document.length
            script = self.jScriptPane.document.getText(0, end)
            script = base64.b64encode(script)
            self.callbacks.saveExtensionSetting(self._scriptStorage, script)
        except Exception:
            traceback.print_exc(file=self.callbacks.getStderr())
        print "Unloaded"  #debug
        return

    def processHttpMessage(self, toolFlag, messageIsRequest, messageInfo):
        if self._enabled == 0:
            return

        try:
            locals_ = {
                'extender': self,
                'callbacks': self.callbacks,
                'helpers': self.helpers,
                'toolFlag': toolFlag,
                'messageIsRequest': messageIsRequest,
                'messageInfo': messageInfo,
                'log': self.log
            }
            # add the _vars as gloval variables
            locals_ = dict(locals_, **self._vars)

            # execute the script/rules
            try:
                exec(self.getCode, {}, locals_)
            # catch exit() call inside the rule
            except SystemExit:
                pass

            # update the persistant variables by searching the local variables with the same name
            for key in self._vars:
                # assumption self._vars dictionary is smaller than locals_
                if key in locals_:
                    self._vars[key] = locals_[key]
        except Exception:
            traceback.print_exc(file=self.callbacks.getStderr())
        return

    #Returns the compiled script
    @property
    def getCode(self):
        end = self.jScriptPane.document.length
        script = self.jScriptPane.document.getText(0, end)

        # if the script hasn't changed return the already compile text
        if script == self._script:
            return self._code
        self._script = script

        # compile, store and return the result
        self._code = compile(script, '<string>', 'exec')
        return self._code

    #Log the information into the console screen
    def log(self, obj):
        # if string just append. else use pformat from pprint
        if isinstance(obj, str):
            self.jConsoleText.append(obj + "\n")
        else:
            self.jConsoleText.append(pformat(obj) + "\n")
        # scroll to bottom
        verticalScrollBar = self.jScrollConsolePane.getVerticalScrollBar()
        verticalScrollBar.setValue(verticalScrollBar.getMaximum())
        return
Beispiel #8
0
    def registerExtenderCallbacks(self, callbacks):
        self.callbacks = callbacks
        self.helpers = callbacks.getHelpers()
        callbacks.setExtensionName("WebTech")
        self.out = callbacks.getStdout()
        self.callbacks.printOutput("Sucessfully loaded WebTech {}".format(VERSION))

        try:
            self.webtech = WebTech(options={'json': True})
        except UpdateInBurpException as e:
            #self.callbacks.printOutput(e)
            for db_file in databases:
                db = self.callbacks.makeHttpRequest(
                    'raw.githubusercontent.com', # we are hardcoding this since there isn't a nice api for that
                    443,
                    True,
                    self.helpers.buildHttpRequest(URL(db_file[0]))
                );
                db = db.tostring()
                save_database_file(db[db.index("\r\n\r\n") + len("\r\n\r\n"):], db_file[1])
            self.webtech = WebTech(options={'json': True})

        # define all checkboxes
        self.cbPassiveChecks = self.defineCheckBox("Enable Passive Scanner Checks")
        self.cbActiveChecks = self.defineCheckBox("Enable Active Scanner Checks", True, False)
        self.btnSave = JButton("Set as default", actionPerformed=self.saveConfig)
        self.btnRestore = JButton("Restore", actionPerformed=self.restoreConfig)
        self.grpConfig = JPanel()
        self.grpConfig.add(self.btnSave)
        self.grpConfig.add(self.btnRestore)
        self.restoreConfig()

        # definition of config tab
        self.tab = JPanel()
        layout = GroupLayout(self.tab)
        self.tab.setLayout(layout)
        layout.setAutoCreateGaps(True)
        layout.setAutoCreateContainerGaps(True)
        layout.setHorizontalGroup(
            layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup()
                      .addComponent(self.cbPassiveChecks)
                      .addComponent(self.cbActiveChecks)
                      )
            .addGroup(layout.createParallelGroup()
                      .addComponent(self.grpConfig, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                      )
        )
        layout.setVerticalGroup(
            layout.createSequentialGroup()
            .addComponent(self.cbPassiveChecks)
            .addComponent(self.cbActiveChecks)
            .addComponent(self.grpConfig, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        )

        callbacks.registerScannerCheck(self)
        callbacks.addSuiteTab(self)
Beispiel #9
0
    def __init__(self, callbacks, table=None):

        self.callbacks = callbacks
        self.jScrollPane1 = JScrollPane()
        self.jPanel1 = JPanel()
        self.labelName = JLabel("Name")
        self.textName = JTextField()
        self.labelSeverity = JLabel("Severity")
        self.textSeverity = JTextField()
        self.labelHost = JLabel("Host")
        self.labelPath = JLabel("Path")
        self.textHost = JTextField()
        self.textPath = JTextField()
        self.tabIssue = JTabbedPane()
        self.textAreaDescription = JTextArea()
        self.textAreaRemediation = JTextArea()
        # JScrollPanes to hold the two jTextAreas
        # put the textareas in JScrollPanes
        self.jsPaneDescription = JScrollPane(self.textAreaDescription)
        self.jsPaneRemediation = JScrollPane(self.textAreaRemediation)
        self.panelRequest = self.callbacks.createMessageEditor(None, False)
        self.panelResponse = self.callbacks.createMessageEditor(None, False)

        self.loadPanel(self.defaultIssue)

        # buttons
        self.buttonNewIssue = JButton("New Issue",
                                      actionPerformed=self.newIssueAction)
        self.buttonDeleteIssue = JButton(
            "Delete Issue", actionPerformed=self.deleteIssueAction)
        self.buttonImport = JButton("Import",
                                    actionPerformed=self.importAction)
        self.buttonExport = JButton("Export",
                                    actionPerformed=self.exportAction)

        if table is not None:
            self.tableIssue = table
        else:
            from IssueTable import IssueTable
            self.tableIssue = IssueTable()

        # wrap the table in a scrollpane
        self.jScrollPane1.setViewportView(self.tableIssue)

        # top panel containing the table
        from java.awt import Color
        self.jPanel1.setBorder(BorderFactory.createLineBorder(Color(0, 0, 0)))

        # create the labels and textfields
        self.textName.editable = False
        self.textName.setBackground(Color.LIGHT_GRAY)

        self.textSeverity.editable = False
        self.textSeverity.setBackground(Color.LIGHT_GRAY)

        self.textHost.editable = False
        self.textHost.setBackground(Color.LIGHT_GRAY)

        self.textPath.editable = False
        self.textPath.setBackground(Color.LIGHT_GRAY)

        # description textarea
        self.textAreaDescription.editable = False
        self.textAreaDescription.setLineWrap(True)
        self.textAreaDescription.setWrapStyleWord(True)
        self.tabIssue.addTab("Description", self.jsPaneDescription)

        # remediation textarea
        self.textAreaRemediation.editable = False
        self.textAreaRemediation.setLineWrap(True)
        self.textAreaRemediation.setWrapStyleWord(True)
        self.tabIssue.addTab("Remediation", self.jsPaneRemediation)

        # request tab
        self.panelRequest.setMessage("", True)
        self.tabIssue.addTab("Request", self.panelRequest.getComponent())

        # response tab
        self.panelResponse.setMessage("", False)
        self.tabIssue.addTab("Response", self.panelResponse.getComponent())

        # from java.lang import Short
        # jpanel1 is the bottom panel
        jPanel1Layout = GroupLayout(self.jPanel1)
        self.jPanel1.setLayout(jPanel1Layout)
        jPanel1Layout.setHorizontalGroup(
            # GroupLayout.Alignment.CENTER centers the group, in this case it
            # centers the buttons
            jPanel1Layout.createParallelGroup(
                GroupLayout.Alignment.CENTER
            ).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap(
            ).addGroup(
                jPanel1Layout.createParallelGroup(
                    GroupLayout.Alignment.LEADING).
                addGroup(jPanel1Layout.createSequentialGroup().addGroup(
                    jPanel1Layout.createParallelGroup(
                        GroupLayout.Alignment.TRAILING).addComponent(
                            self.labelHost).addComponent(self.labelName)
                ).addPreferredGap(
                    LayoutStyle.ComponentPlacement.UNRELATED).addGroup(
                        jPanel1Layout.createParallelGroup(
                            GroupLayout.Alignment.LEADING).addGroup(
                                jPanel1Layout.createSequentialGroup(
                                ).addComponent(self.textName).addPreferredGap(
                                    LayoutStyle.ComponentPlacement.UNRELATED).
                                addComponent(
                                    self.labelSeverity).addPreferredGap(
                                        LayoutStyle.ComponentPlacement.
                                        RELATED).addComponent(
                                            self.textSeverity,
                                            GroupLayout.PREFERRED_SIZE, 186,
                                            GroupLayout.PREFERRED_SIZE)).
                        addGroup(
                            jPanel1Layout.createSequentialGroup().addComponent(
                                self.textHost, GroupLayout.PREFERRED_SIZE, 330,
                                GroupLayout.PREFERRED_SIZE).addPreferredGap(
                                    LayoutStyle.ComponentPlacement.RELATED
                                ).addComponent(self.labelPath).addPreferredGap(
                                    LayoutStyle.ComponentPlacement.RELATED).
                            addComponent(self.textPath)))).addComponent(
                                self.tabIssue)).addContainerGap()
                       ).addGroup(
                           jPanel1Layout.createSequentialGroup().addComponent(
                               self.buttonNewIssue).addComponent(
                                   self.buttonDeleteIssue).addComponent(
                                       self.buttonImport).addComponent(
                                           self.buttonExport)))

        # link size of buttons
        from javax.swing import SwingConstants
        jPanel1Layout.linkSize(SwingConstants.HORIZONTAL, [
            self.buttonDeleteIssue, self.buttonExport, self.buttonImport,
            self.buttonNewIssue
        ])

        jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(
        ).addGroup(
            jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(
                jPanel1Layout.createParallelGroup(
                    GroupLayout.Alignment.BASELINE).addComponent(
                        self.labelName).addComponent(
                            self.textName, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE).addComponent(
                                self.labelSeverity).addComponent(
                                    self.textSeverity,
                                    GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
            ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(
                jPanel1Layout.createParallelGroup(
                    GroupLayout.Alignment.BASELINE).addComponent(
                        self.textHost, GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE).addComponent(
                            self.labelPath).addComponent(
                                self.textPath, GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE).addComponent(
                                    self.labelHost)).addPreferredGap(
                                        LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(self.tabIssue).addPreferredGap(
                LayoutStyle.ComponentPlacement.RELATED).addGroup(
                    jPanel1Layout.createParallelGroup().addComponent(
                        self.buttonNewIssue).addComponent(
                            self.buttonDeleteIssue).addComponent(
                                self.buttonImport).addComponent(
                                    self.buttonExport)).addContainerGap()))

        # create the main panel
        self.panel = JSplitPane(JSplitPane.VERTICAL_SPLIT)

        # set the top component
        self.panel.leftComponent = self.jScrollPane1
        self.panel.rightComponent = self.jPanel1
        self.panel.setDividerLocation(150)
    def __init__(self):
        TrafficMod.__init__(self)
        self.setLayout(FlowLayout(FlowLayout.LEADING))

        settings_panel = JPanel()
        layout = GroupLayout(settings_panel)
        layout.setAutoCreateGaps(True)
        layout.setAutoCreateContainerGaps(True)
        settings_panel.setLayout(layout)
        self.add(settings_panel)

        # Horizontal group
        horizontal = layout.createParallelGroup()
        layout.setHorizontalGroup(
            layout.createSequentialGroup().addGroup(horizontal))

        # Vertical group
        vertical = layout.createSequentialGroup()
        layout.setVerticalGroup(vertical)

        # Main title, label only
        main_title = JLabel(self.title)
        main_title.setFont(get_title_font(main_title))
        horizontal.addGroup(
            layout.createSequentialGroup().addComponent(main_title))
        vertical.addGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.BASELINE).addComponent(main_title))

        # loss type (random, state, or gemodel)
        self.loss_type_combo = self.get_loss_type_combo()
        loss_type_lbl = JLabel("Loss type")
        horizontal.addGroup(layout.createSequentialGroup().addComponent(
            loss_type_lbl).addComponent(self.loss_type_combo))
        vertical.addGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.BASELINE).addComponent(
                    loss_type_lbl).addComponent(self.loss_type_combo))

        # Random loss fields
        # Loss percentage
        loss_percent_lbl = JLabel("Loss %")
        horizontal.addGroup(layout.createSequentialGroup().addComponent(
            loss_percent_lbl).addComponent(self.loss_random_percent))

        vertical.addGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.BASELINE).addComponent(
                    loss_percent_lbl).addComponent(self.loss_random_percent))

        layout.linkSize(SwingConstants.HORIZONTAL, loss_percent_lbl,
                        loss_type_lbl)
        self.loss_random_items.append(loss_percent_lbl)
        self.loss_random_items.append(self.loss_random_percent)

        # Loss percent correlation
        loss_corr_lbl = JLabel("Correlation %")
        horizontal.addGroup(layout.createSequentialGroup().addComponent(
            loss_corr_lbl).addComponent(self.loss_random_percent_correlation))

        vertical.addGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.BASELINE).addComponent(
                    loss_corr_lbl).addComponent(
                        self.loss_random_percent_correlation))

        layout.linkSize(SwingConstants.HORIZONTAL, loss_corr_lbl,
                        loss_type_lbl)
        self.loss_random_items.append(loss_corr_lbl)
        self.loss_random_items.append(self.loss_random_percent_correlation)

        # State loss fields
        # P13
        loss_p13_lbl = JLabel("P13")
        horizontal.addGroup(layout.createSequentialGroup().addComponent(
            loss_p13_lbl).addComponent(self.loss_state_p13))

        vertical.addGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.BASELINE).addComponent(
                    loss_p13_lbl).addComponent(self.loss_state_p13))
        self.loss_state_items.append(loss_p13_lbl)
        self.loss_state_items.append(self.loss_state_p13)

        # P31
        loss_p31_lbl = JLabel("P31")
        horizontal.addGroup(layout.createSequentialGroup().addComponent(
            loss_p31_lbl).addComponent(self.loss_state_p31))

        vertical.addGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.BASELINE).addComponent(
                    loss_p31_lbl).addComponent(self.loss_state_p31))
        layout.linkSize(SwingConstants.HORIZONTAL, loss_p31_lbl, loss_p13_lbl)
        self.loss_state_items.append(loss_p31_lbl)
        self.loss_state_items.append(self.loss_state_p31)

        # P32
        loss_p32_lbl = JLabel("P32")
        horizontal.addGroup(layout.createSequentialGroup().addComponent(
            loss_p32_lbl).addComponent(self.loss_state_p32))

        vertical.addGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.BASELINE).addComponent(
                    loss_p32_lbl).addComponent(self.loss_state_p32))
        layout.linkSize(SwingConstants.HORIZONTAL, loss_p32_lbl, loss_p13_lbl)
        self.loss_state_items.append(loss_p32_lbl)
        self.loss_state_items.append(self.loss_state_p32)

        # P23
        loss_p23_lbl = JLabel("P23")
        horizontal.addGroup(layout.createSequentialGroup().addComponent(
            loss_p23_lbl).addComponent(self.loss_state_p23))

        vertical.addGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.BASELINE).addComponent(
                    loss_p23_lbl).addComponent(self.loss_state_p23))
        layout.linkSize(SwingConstants.HORIZONTAL, loss_p23_lbl, loss_p13_lbl)
        self.loss_state_items.append(loss_p23_lbl)
        self.loss_state_items.append(self.loss_state_p23)

        # P14
        loss_p14_lbl = JLabel("P14")
        horizontal.addGroup(layout.createSequentialGroup().addComponent(
            loss_p14_lbl).addComponent(self.loss_state_p14))

        vertical.addGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.BASELINE).addComponent(
                    loss_p14_lbl).addComponent(self.loss_state_p14))
        layout.linkSize(SwingConstants.HORIZONTAL, loss_p14_lbl, loss_p13_lbl)
        self.loss_state_items.append(loss_p14_lbl)
        self.loss_state_items.append(self.loss_state_p14)

        # Gemodel loss fields
        # P
        ge_p_lbl = JLabel("p")
        horizontal.addGroup(
            layout.createSequentialGroup().addComponent(ge_p_lbl).addComponent(
                self.loss_gemodel_p))

        vertical.addGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.BASELINE).addComponent(
                    ge_p_lbl).addComponent(self.loss_gemodel_p))
        self.loss_gemodel_items.append(ge_p_lbl)
        self.loss_gemodel_items.append(self.loss_gemodel_p)

        # R
        ge_r_lbl = JLabel("r")
        horizontal.addGroup(
            layout.createSequentialGroup().addComponent(ge_r_lbl).addComponent(
                self.loss_gemodel_r))

        vertical.addGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.BASELINE).addComponent(
                    ge_r_lbl).addComponent(self.loss_gemodel_r))
        layout.linkSize(SwingConstants.HORIZONTAL, ge_r_lbl, ge_p_lbl)
        self.loss_gemodel_items.append(ge_r_lbl)
        self.loss_gemodel_items.append(self.loss_gemodel_r)

        # H
        ge_h_lbl = JLabel("1-h")
        horizontal.addGroup(
            layout.createSequentialGroup().addComponent(ge_h_lbl).addComponent(
                self.loss_gemodel_h))

        vertical.addGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.BASELINE).addComponent(
                    ge_h_lbl).addComponent(self.loss_gemodel_h))
        layout.linkSize(SwingConstants.HORIZONTAL, ge_h_lbl, ge_p_lbl)
        self.loss_gemodel_items.append(ge_h_lbl)
        self.loss_gemodel_items.append(self.loss_gemodel_h)

        # K
        ge_k_lbl = JLabel("1-k")
        horizontal.addGroup(
            layout.createSequentialGroup().addComponent(ge_k_lbl).addComponent(
                self.loss_gemodel_k))

        vertical.addGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.BASELINE).addComponent(
                    ge_k_lbl).addComponent(self.loss_gemodel_k))
        layout.linkSize(SwingConstants.HORIZONTAL, ge_k_lbl, ge_p_lbl)
        self.loss_gemodel_items.append(ge_k_lbl)
        self.loss_gemodel_items.append(self.loss_gemodel_k)

        # Initially show the loss_random textboxes
        for item in self.loss_random_items:
            item.setVisible(True)

        for item in self.loss_state_items:
            item.setVisible(False)

        for item in self.loss_gemodel_items:
            item.setVisible(False)
Beispiel #11
0
    def initUI(self, okayEvent):
        pathPanel = JPanel()
        pPLayout = GroupLayout(pathPanel)
        pathPanel.setLayout(pPLayout)
        pPLayout.setAutoCreateContainerGaps(True)
        pPLayout.setAutoCreateGaps(True)

        btnPanel = JPanel()
        btnLayout = GroupLayout(btnPanel)
        btnPanel.setLayout(btnLayout)
        btnLayout.setAutoCreateContainerGaps(True)
        btnLayout.setAutoCreateGaps(True)
        
        paramPanel = JPanel()
        paramLayout = GroupLayout(paramPanel)
        paramPanel.setLayout(paramLayout)
        paramLayout.setAutoCreateContainerGaps(True)
        paramLayout.setAutoCreateGaps(True)
        
        layout = GroupLayout(self.getContentPane())
        self.getContentPane().setLayout(layout)
        layout.setAutoCreateGaps(True)
        layout.setAutoCreateContainerGaps(True)

        self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
        # definition of elements
        # labels
        pathLabel = JLabel("Path:")
        dateLabel = JLabel("Date:")
        strainLabel = JLabel("Strain:")
        tempLabel = JLabel("Temperature:")
        dCelLabel = JLabel("C")
        ODLabel = JLabel("OD:")
        condLabel = JLabel("Condition:")
        
        #textfields
        self.pathField = JTextField("",1)
        self.dateField = JTextField( str(date.today()), 8 )
        self.strainField = JTextField( "2926",1 )
        self.tempField = JTextField( "34",2 )
        self.ODField = JTextField( "0.5",3 )
        self.condField = JTextField( "",3 )
        
        #buttons
        OpenPathButton = JButton("Browse...", actionPerformed=self.browse)
        OKButton = JButton("OK",actionPerformed=okayEvent)
        CancelButton = JButton("Cancel", actionPerformed=self.cancel)
        
        '''ContentPane Layout'''
        layout.setHorizontalGroup(layout.createParallelGroup()
                                  .addComponent(pathPanel)
                                  .addComponent(paramPanel)
                                  .addComponent(btnPanel)
                                  )
        layout.setVerticalGroup(layout.createSequentialGroup()
                                .addComponent(pathPanel)
                                .addComponent(paramPanel)
                                .addComponent(btnPanel)
                                )
        
        
        ''' PathChooser Panel Layout '''
        pPLayout.setHorizontalGroup(pPLayout.createSequentialGroup()
                                    .addComponent(pathLabel)
                                    .addComponent(self.pathField)
                                    .addComponent(OpenPathButton)
                                    )
        
        pPLayout.setVerticalGroup(pPLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                  .addComponent(pathLabel)
                                  .addComponent(self.pathField)
                                  .addComponent(OpenPathButton)
                                  )
        
        '''Param Panel Layout'''
        paramLayout.setHorizontalGroup(paramLayout.createSequentialGroup()
                                       .addGroup(paramLayout.createParallelGroup()
                                                 .addComponent(dateLabel)
                                                 .addComponent(strainLabel)
                                                 .addComponent(tempLabel)
                                                 .addComponent(ODLabel)
                                                 .addComponent(condLabel))
                                       .addGroup(paramLayout.createParallelGroup()
                                                .addComponent(self.dateField)
                                                .addComponent(self.strainField)
                                                .addGroup(paramLayout.createSequentialGroup()
                                                          .addComponent(self.tempField)
                                                          .addComponent(dCelLabel))
                                                .addComponent(self.ODField)
                                                .addComponent(self.condField)
                                                )
                                       )
        
        paramLayout.setVerticalGroup(paramLayout.createSequentialGroup()
                                .addGroup(paramLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                          .addComponent(dateLabel)
                                          .addComponent(self.dateField)
                                          )
                                .addGroup(paramLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                          .addComponent(strainLabel)
                                          .addComponent(self.strainField)
                                          )
                                .addGroup(paramLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                          .addComponent(tempLabel)
                                          .addComponent(self.tempField)
                                          .addComponent(dCelLabel)
                                          )                                
                                .addGroup(paramLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                          .addComponent(ODLabel)
                                          .addComponent(self.ODField)
                                          )                                      
                                .addGroup(paramLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                          .addComponent(condLabel)
                                          .addComponent(self.condField)
                                          )  
                              )
        
        '''Buttons Panel Layout'''
        btnLayout.setHorizontalGroup(btnLayout.createSequentialGroup()
                                     .addComponent(CancelButton)
                                     .addComponent(OKButton)
                                     )
        btnLayout.setVerticalGroup(btnLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                   .addComponent(CancelButton)
                                   .addComponent(OKButton)
                                   )

        self.setTitle("CellSelector")

        #self.setSize(200, 150)
        self.pack()
        self.setLocationRelativeTo(None)
        self.setVisible(True)
        
        self.browse(self)
    def initUI(self):
        
        inputPanel = JPanel()
        inputPanel.setBorder(BorderFactory.createTitledBorder("Where are your control and treament images?"))
        inputLayout = GroupLayout(inputPanel, autoCreateContainerGaps=True, autoCreateGaps=True)
        inputPanel.setLayout(inputLayout)
        
        annotatePanel = JPanel()
        annotatePanel.setBorder(BorderFactory.createTitledBorder("How do you want to annotate your data?"))
        anLayout = GroupLayout(annotatePanel, autoCreateContainerGaps=True, autoCreateGaps=True)
        annotatePanel.setLayout(anLayout)
        
        exportPanel = JPanel()
        exportPanel.setBorder(BorderFactory.createTitledBorder("Where do you want to export your data"))
        exportLayout = GroupLayout(exportPanel, autoCreateContainerGaps=True, autoCreateGaps=True)
        exportPanel.setLayout(exportLayout)
        
        btnPanel = JPanel()
        btnLayout = GroupLayout(btnPanel, autoCreateContainerGaps=True, autoCreateGaps=True)
        btnPanel.setLayout(btnLayout)
        
        layout = GroupLayout(self.getContentPane(), autoCreateContainerGaps=True, autoCreateGaps=True)
        self.getContentPane().setLayout(layout)

        self.setModalityType(ModalityType.APPLICATION_MODAL)
        self.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE)# JFrame.EXIT_ON_CLOSE)
        # definition of elements
        # labels
        cPathLabel = JLabel("Control Path:")
        tPathLabel = JLabel("Treatment Path:")
        exPathLabel = JLabel("Save Results in:")
        
        #textfields
        self.cPathField = JTextField("/Users/schiklen/DotData/131118_dummy/131118_2926/cutout/", 16)
        self.tPathField = JTextField("/Users/schiklen/DotData/131118_dummy/131118_2926/cutout/", 16)
        self.exPathField = JTextField("/Users/schiklen/DotData/131118_dummy/131118_2926/cutout/", 16)
        
        #Radiobuttons
        yesNoRButton = JRadioButton("Yes / No / Ignore", selected=True, actionCommand="yesNoIgnore", actionPerformed=self.setAnnotationTypeDialog)
        intRButton = JRadioButton("Integer", actionCommand="int", actionPerformed=self.setAnnotationTypeDialog)
        nRButton = JRadioButton("Number", actionCommand="float", actionPerformed=self.setAnnotationTypeDialog)
        listRButton = JRadioButton("From List...", actionCommand="list", actionPerformed=self.openListDialog)

        self.rBGroup = ButtonGroup()
        self.rBGroup.add(yesNoRButton)
        self.rBGroup.add(intRButton)
        self.rBGroup.add(nRButton)
        self.rBGroup.add(listRButton)
        
        #self.customListButton = JButton("Custom List...", actionPerformed=self.makeCustomList, enabled=0)
        
        #buttons
        cPathButton = JButton("Browse...", actionPerformed=self.browseC) # lambda on fieldvalue
        tPathButton = JButton("Browse...", actionPerformed=self.browseT) # lambda on fieldvalue
        exPathButton = JButton("Browse...", actionPerformed=self.browseE)
        OKButton = JButton("OK", actionPerformed=self.okayEvent)
        CancelButton = JButton("Cancel", actionPerformed=self.cancel)
        
        '''General ContentPane Layout'''
        layout.setHorizontalGroup(layout.createParallelGroup()
                                  .addComponent(inputPanel)
                                  .addComponent(annotatePanel)
                                  .addComponent(exportPanel)
                                  .addComponent(btnPanel)
                                  )
        layout.linkSize(SwingConstants.HORIZONTAL, inputPanel, annotatePanel, exportPanel, btnPanel)
        layout.setVerticalGroup(layout.createSequentialGroup()
                                .addComponent(inputPanel)
                                .addComponent(annotatePanel)
                                .addComponent(exportPanel)
                                .addComponent(btnPanel)
                                )
        
        ''' Input panel Layout '''
        inputLayout.setHorizontalGroup(inputLayout.createSequentialGroup()
                                       .addGroup(inputLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                                                 .addComponent(cPathLabel)
                                                 .addComponent(tPathLabel))
                                       .addGroup(inputLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                                                 .addComponent(self.cPathField)
                                                 .addComponent(self.tPathField))
                                       .addGroup(inputLayout.createParallelGroup()
                                                 .addComponent(cPathButton)
                                                 .addComponent(tPathButton))
                                       )
        
        inputLayout.setVerticalGroup(inputLayout.createSequentialGroup()
                                       .addGroup(inputLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                                 .addComponent(cPathLabel)
                                                 .addComponent(self.cPathField)
                                                 .addComponent(cPathButton))
                                       .addGroup(inputLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                                 .addComponent(tPathLabel)
                                                 .addComponent(self.tPathField)
                                                 .addComponent(tPathButton))
                                     )
        
        '''Annotate panel layout'''
        anLayout.setHorizontalGroup(anLayout.createParallelGroup()
                                    .addComponent(yesNoRButton)
                                    .addComponent(intRButton)
                                    .addComponent(nRButton)
                                    .addComponent(listRButton)
                                    #.addComponent(self.customListButton)
                                    )
        anLayout.setVerticalGroup(anLayout.createSequentialGroup()
                                    .addComponent(yesNoRButton)
                                    .addComponent(intRButton)
                                    .addComponent(nRButton)
                                    .addComponent(listRButton)
                                    #.addComponent(self.customListButton)
                                    )
        
        
        '''Export panel layout'''
        exportLayout.setHorizontalGroup(exportLayout.createSequentialGroup()
                                        .addComponent(exPathLabel)
                                        .addComponent(self.exPathField)
                                        .addComponent(exPathButton))
        exportLayout.setVerticalGroup(exportLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                        .addComponent(exPathLabel)
                                        .addComponent(self.exPathField)
                                        .addComponent(exPathButton))
        
        
        '''Buttons Panel Layout'''
        btnLayout.setHorizontalGroup(btnLayout.createSequentialGroup()
                                     .addComponent(CancelButton)
                                     .addComponent(OKButton)
                                     )
        btnLayout.setVerticalGroup(btnLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                   .addComponent(CancelButton)
                                   .addComponent(OKButton)
                                   )

        self.setTitle("Random Picture Picker")

        self.pack()
        self.setLocationRelativeTo(None)
        self.setVisible(True)
Beispiel #13
0
    def __init__(self):
        super(WorkHelper, self).__init__()

        self.clipboard = Toolkit.getDefaultToolkit().getSystemClipboard()
        #self.initUI()

    #def initUI(self):

        #panel = JPanel()
        #self.getContentPane().add(panel)
        
#############################################################
# Layout
        layout = GroupLayout(self.getContentPane())
        self.getContentPane().setLayout(layout)
        layout.setAutoCreateGaps(True)
        layout.setAutoCreateContainerGaps(True)
#############################################################

#############################################################
# Scroll Area Input + Output
        Larea1 = JLabel("InputArea:")
        Larea2 = JLabel("OutputArea:")
        
        Sarea1 = JScrollPane()
        Sarea2 = JScrollPane()
        
        self.area1 = JTextArea()
        self.area1.setToolTipText("Input Area")
        self.area1.setEditable(True)
        self.area1.setBorder(BorderFactory.createLineBorder(Color.gray))
        
        Sarea1.setPreferredSize(Dimension(300,100))
        Sarea1.getViewport().setView((self.area1))
        
        self.area2 = JTextArea()
        self.area2.setToolTipText("Output Area")
        self.area2.setEditable(False)
        self.area2.setBorder(BorderFactory.createLineBorder(Color.gray))
        
        Sarea2.setPreferredSize(Dimension(300,100))
        Sarea2.getViewport().setView((self.area2))
#############################################################

#############################################################
# Buttons

        self.cCurly = JCheckBox("Curly");
        self.cCurly.setToolTipText("When 'Checked' Curly Brackets will surround the Categories")
        self.cCurly.setSelected(1)
        

        self.cCtClipB = JCheckBox("Auto-Copy");
        self.cCtClipB.setToolTipText("When 'Checked' after the Categories are created they will added to the clipboard")
        self.cCtClipB.setSelected(1)

        self.cSemiC = JCheckBox("SemiColumn");
        self.cSemiC.setToolTipText("When 'Checked' after the Categories are created at the end will be a semicolomn")
        self.cSemiC.setSelected(1)        
        
        bRemoveNBSP_L = JButton("Clean LText", actionPerformed=self.bRemoveNBSP_L)
        bRemoveNBSP_L.setToolTipText("Removes Spaces, Tabs from the start of every text line from the input Area")
        bRemoveNBSP_R = JButton("Clean RText", actionPerformed=self.bRemoveNBSP_R)
        bRemoveNBSP_R.setToolTipText("Removes Spaces, Tabs from the end of every text line from the input Area")
        bCopyToInput = JButton("Copy to Input", actionPerformed=self.bCopyToInput)
        bCopyToInput.setToolTipText("Copy the text from the Output Area to the Input Area for further Operations")
        
        bClear = JButton("Clear", actionPerformed=self.bClear)
        bClear.setToolTipText("Clears the text form both Input and Output text Areas")
        
        self.iStart = JTextField(maximumSize=Dimension(40,25))
        self.iStart.setToolTipText("The Start Index for the Making of the Categories")
        
        self.RThis = JTextField()
        self.RThis = JTextField(maximumSize=Dimension(120,25))
        self.RThis.setToolTipText("Text to be replaced or The Starting C_Index")
        
        self.RThat = JTextField()
        self.RThat = JTextField(maximumSize=Dimension(120,25))
        self.RThat.setToolTipText("Text to be placed or The Finish C_Index")
        
        
        bSandReplace = JButton("Replace Text", actionPerformed=self.bSandReplace)
        bSandReplace.setToolTipText("Replace the text from This with Thext from That in the Text from the Input Area and displays it in the Output Area")
        
        bcCat = JButton("CreatCateg", actionPerformed=self.bcCat)
        bcCat.setToolTipText("Create a categorical form starting C_Index to finish C_Index; Use the above text boxes to define the indexes")
        
        
        bC_S = JButton("Create _Series", actionPerformed=self.bC_S)
        bC_S.setToolTipText("Create a series form starting C_Index to finish C_Index; Use the above text boxes to define the indexes; It will create a series for every row in the Input Area")

        
        
        bM_Categories = JButton("Categories", actionPerformed=self.mCategories)
        bM_Categories.setToolTipText("Make Categories using the lines from the Input Area")
        #bM_Categories = JButton(maximumSize=Dimension(40,25))
        # de incercat daca merge cu ; sa grupezi in [dsa] elementele
#############################################################


#############################################################
# Aplication Layout 2 groups one Horizontal and one Vertical
        layout.setHorizontalGroup(layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup()
                .addComponent(Larea1)
                .addComponent(Sarea1)

                .addComponent(Sarea2)
                .addComponent(bCopyToInput)
                .addComponent(Larea2))
            .addGroup(layout.createParallelGroup()
            .addGroup(layout.createSequentialGroup()
                .addComponent(bM_Categories)
                .addComponent(self.iStart))
            .addGroup(layout.createSequentialGroup()
                .addComponent(self.cCurly)
                .addComponent(self.cSemiC)
                .addComponent(self.cCtClipB))
            .addGroup(layout.createSequentialGroup()
                .addComponent(bRemoveNBSP_L)
                .addComponent(bRemoveNBSP_R))
            .addGroup(layout.createSequentialGroup()
                .addComponent(self.RThis)
                .addComponent(self.RThat))
            .addGroup(layout.createSequentialGroup()
                .addComponent(bSandReplace)
                .addComponent(bcCat))
            .addGroup(layout.createSequentialGroup()
                .addComponent(bC_S))
                
                .addComponent(bClear))
            
        )

        layout.setVerticalGroup(layout.createSequentialGroup()
            .addComponent(Larea1)
            
            .addGroup(layout.createParallelGroup()
                .addComponent(Sarea1)
                
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup()
                        .addComponent(bM_Categories)
                        .addComponent(self.iStart))
                    .addGroup(layout.createParallelGroup()
                        .addComponent(self.cCurly)
                        .addComponent(self.cSemiC)
                        .addComponent(self.cCtClipB))
                    .addGroup(layout.createParallelGroup()
                        .addComponent(bRemoveNBSP_L)
                        .addComponent(bRemoveNBSP_R))
                    .addGroup(layout.createParallelGroup()
                        .addComponent(self.RThis)
                        .addComponent(self.RThat))
                    .addGroup(layout.createParallelGroup()   
                        .addComponent(bSandReplace)
                        .addComponent(bcCat))
                    .addGroup(layout.createParallelGroup()
                        .addComponent(bC_S))
                        
                        
                        )
                    )
                
            .addGroup(layout.createParallelGroup()
                .addComponent(bCopyToInput)
                .addComponent(bClear))
            .addComponent(Larea2)
            .addGroup(layout.createParallelGroup()
                .addComponent(Sarea2))
        )
        
        #layout.linkSize(SwingConstants.HORIZONTAL, [ok, bCopyToInput, close, bM_Categories])
        layout.linkSize(SwingConstants.HORIZONTAL, [self.RThis,self.RThat,bRemoveNBSP_L,bRemoveNBSP_R,bCopyToInput,bM_Categories,bSandReplace,bcCat,bC_S])
        
        #layout.linkSize(SwingConstants.HORIZONTAL, [self.cCurly,bM_Categories])
#############################################################

#############################################################
# Aplication Settings
        self.pack()
        #self.setPreferredSize(Dimension(1000, 1000))
        self.setTitle("Workhelper")
        self.setSize(800, 500)
        self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
        self.setLocationRelativeTo(None)
        self.setVisible(True)
Beispiel #14
0
    def __init__(self):
        super(WorkHelper, self).__init__()
        self.clipboard = Toolkit.getDefaultToolkit().getSystemClipboard()

#############################################################
# Layout:
        layout = GroupLayout(self.getContentPane())
        self.getContentPane().setLayout(layout)
        layout.setAutoCreateGaps(True)
        layout.setAutoCreateContainerGaps(True)
#############################################################

#############################################################
# Frame Area:
        Larea1 = JLabel("InputArea:")

        Sarea1 = JScrollPane()
        self.area1 = JTextArea()
        self.area1.setToolTipText("Input Area")
        self.area1.setEditable(True)
        self.area1.setBorder(BorderFactory.createLineBorder(Color.gray))
        Sarea1.setPreferredSize(Dimension(300,100))
        Sarea1.getViewport().setView((self.area1))

        bClear = JButton("Clear", actionPerformed=self.bClear)
        bClear.setToolTipText("Clears the text form both Input and Output text Areas")

        bCopyToInput = JButton("Copy to Input", actionPerformed=self.bCopyToInput)
        bCopyToInput.setToolTipText("Copy the text from the Output Area to the Input Area for further Operations")
        
        self.cCtClipB = JCheckBox("Auto-Copy");
        self.cCtClipB.setToolTipText("When 'Checked' after the Categories are created they will added to the clipboard")
        self.cCtClipB.setSelected(1)
        
        Larea2 = JLabel("OutputArea:")
        
        Sarea2 = JScrollPane()
        self.area2 = JTextArea()
        self.area2.setToolTipText("Output Area")
        self.area2.setEditable(False)
        self.area2.setBorder(BorderFactory.createLineBorder(Color.gray))
        Sarea2.setPreferredSize(Dimension(300,100))
        Sarea2.getViewport().setView((self.area2))

#############################################################
# Tabbed Area:
        tabPane = JTabbedPane(JTabbedPane.TOP)
        self.getContentPane().add(tabPane)
        #####################################################
        # Text Edit pane
        panel_TEdit = JPanel()
        layout2 = GroupLayout(panel_TEdit)
        layout2.setAutoCreateGaps(True)
        layout2.setAutoCreateContainerGaps(True)
        panel_TEdit.setLayout(layout2)
        
        bRemoveNBSP_L = JButton("Clean LText", actionPerformed=self.bRemoveNBSP_L)
        bRemoveNBSP_L.setToolTipText("Removes Spaces, Tabs from the start of every text line from the input Area")
        bRemoveNBSP_R = JButton("Clean RText", actionPerformed=self.bRemoveNBSP_R)
        bRemoveNBSP_R.setToolTipText("Removes Spaces, Tabs from the end of every text line from the input Area")
    
        
        self.ReplaceThis = JTextField()
        self.ReplaceThis = JTextField(maximumSize=Dimension(120,25))
        self.ReplaceThis.setToolTipText("Text to be replaced")

        self.ReplaceThat = JTextField()
        self.ReplaceThat = JTextField(maximumSize=Dimension(120,25))
        self.ReplaceThat.setToolTipText("Text to be placed")

        bSandReplace = JButton("Replace Text", actionPerformed=self.bSandReplace)
        bSandReplace.setToolTipText("Replace the text from This with Text from That in the Text from the Input Area and displays it in the Output Area")

        bRemNumbers = JButton("Rem Numbers", actionPerformed=self.RemNumbers)
        bRemNumbers.setToolTipText("Removes numbers from the start of every line")
        #####################################################
        # Dimension pane
        panel_Dimensions = JPanel()
        layout3 = GroupLayout(panel_Dimensions)
        layout3.setAutoCreateGaps(True)
        layout3.setAutoCreateContainerGaps(True)
        panel_Dimensions.setLayout(layout3)
        
        
        self.cCurly = JCheckBox("Curly");
        self.cCurly.setToolTipText("When 'Checked' Curly Brackets will surround the Categories")
        self.cCurly.setSelected(1)

        self.cSemiC = JCheckBox("SemiColumn");
        self.cSemiC.setToolTipText("When 'Checked' after the Categories are created at the end will be a semicolomn")
        self.cSemiC.setSelected(1)

        self.iStart = JTextField(maximumSize=Dimension(40,25))
        self.iStart.setToolTipText("The Start Index for the Making of the Categories")

        self.RThis = JTextField()
        self.RThis = JTextField(maximumSize=Dimension(120,25))
        self.RThis.setToolTipText("The Starting Index used in creating the Categorical")

        self.RThat = JTextField()
        self.RThat = JTextField(maximumSize=Dimension(120,25))
        self.RThat.setToolTipText("The Finish Index used in creating the Categorical")
        
        optioncCategories = JLabel("Options:")
        bcCat = JButton("CreatCateg", actionPerformed=self.bcCat)
        bcCat.setToolTipText("Create a categorical form starting C_Index to finish C_Index; Use the text boxes to define the indexes")

        bM_Categories = JButton("Categories", actionPerformed=self.mCategories)
        bM_Categories.setToolTipText("Make Categories using the lines from the Input Area. Use it to define Categorical questions.")
        #####################################################
        # ConfirmIt pane
        panel_ConfirmIt = JPanel()
        layout4 = GroupLayout(panel_ConfirmIt)
        layout4.setAutoCreateGaps(True)
        layout4.setAutoCreateContainerGaps(True)
        panel_ConfirmIt.setLayout(layout4)
        
        self.PID = JTextField()
        self.PID = JTextField(maximumSize=Dimension(120,25))
        self.PID.setToolTipText("The PID number used for creating links with PID and ids from every line of the Input Area")
        
        bClinks = JButton("Create Links", actionPerformed=self.bClinks)
        bClinks.setToolTipText("Create links for a project using PID and ID, ID`s are read from every line of the Input Area")
        
        bClinksNA = JButton("Create Links NA ", actionPerformed=self.bClinksNA)
        bClinksNA.setToolTipText("Create links for a project using PID and ID`s from the standard sample test for US")
        
        bClinksCA = JButton("Create Links CA", actionPerformed=self.bClinksCA)
        bClinksCA.setToolTipText("Create links for a project using PID and ID`s from the standard sample test for CA")
        
        self.Width = JTextField()
        self.Width = JTextField(maximumSize=Dimension(120,25))
        self.Width.setToolTipText("The Width used in creating the DIV html tag, note the dimension used is in px")
        
        baddDIVt = JButton("Add DIV tag", actionPerformed=self.baddDIVt)
        baddDIVt.setToolTipText("Create a DIV tag for every line in the Input Area")
        #####################################################
        # Statistics pane
        panel_Statistics = JPanel()
        layout5 = GroupLayout(panel_Statistics)
        layout5.setAutoCreateGaps(True)
        layout5.setAutoCreateContainerGaps(True)
        panel_Statistics.setLayout(layout5)         
        
        #####################################################
        # TimeTraking pane
        panel_TimeTraking = JPanel()
        layout6 = GroupLayout(panel_TimeTraking)
        layout6.setAutoCreateGaps(True)
        layout6.setAutoCreateContainerGaps(True)
        panel_TimeTraking.setLayout(layout6)     
        
        #####################################################
        # Tabbed Area Tabs
        tabPane.addTab("Text Edit", panel_TEdit)
        tabPane.addTab("Dimensions", panel_Dimensions)
        tabPane.addTab("ConfirmIt", panel_ConfirmIt)
        tabPane.addTab("Statistics", panel_Statistics)
        tabPane.addTab("TimeTraking", panel_TimeTraking)
        
        
#############################################################




#############################################################
# Aplication Layouts: 2 groups one Horizontal and one Vertical
        
        #############################################################
        # Frame Layout: 2 groups one Horizontal and one Vertical
        layout.setHorizontalGroup(layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup()
                .addComponent(Larea1)
                .addComponent(Sarea1)
                .addComponent(Sarea2)
                .addGroup(layout.createSequentialGroup()
                          .addComponent(bCopyToInput)
                          .addComponent(bClear)
                          .addComponent(self.cCtClipB))
                .addComponent(Larea2))
            .addGroup(layout.createParallelGroup()
                .addComponent(tabPane))
                        )

        layout.setVerticalGroup(layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup()
                      .addGroup(layout.createSequentialGroup()
                          .addComponent(Larea1)
                          .addComponent(Sarea1)
                          .addGroup(layout.createParallelGroup()
                                    .addComponent(bCopyToInput)
                                    .addComponent(bClear)
                                    .addComponent(self.cCtClipB)    )
                          .addComponent(Larea2)
                          .addComponent(Sarea2))
                      .addGroup(layout.createSequentialGroup()
                          .addComponent(tabPane))
                          )
                        )

        #############################################################
        # TEdit Layout: 2 groups one Horizontal and one Vertical
        layout2.setHorizontalGroup(layout2.createSequentialGroup()
            .addGroup(layout2.createParallelGroup()
                .addGroup(layout2.createSequentialGroup()
                    .addComponent(bRemNumbers)
                    .addComponent(bRemoveNBSP_L)
                    .addComponent(bRemoveNBSP_R))
                    .addGroup(layout2.createSequentialGroup()
                    .addComponent(bSandReplace)
                    .addComponent(self.ReplaceThis)
                    .addComponent(self.ReplaceThat))  
                      
                      
                      
                                   ))
        
        layout2.setVerticalGroup(layout2.createSequentialGroup()
            .addGroup(layout2.createParallelGroup()
                .addComponent(bRemNumbers)
                .addComponent(bRemoveNBSP_L)
                .addComponent(bRemoveNBSP_R))
                                 
                .addGroup(layout2.createParallelGroup()
                    .addComponent(bSandReplace)
                    .addComponent(self.ReplaceThis)
                    .addComponent(self.ReplaceThat))  
                                 )
            
            
        #############################################################
        # Dimensions Layout: 2 groups one Horizontal and one Vertical
        layout3.setHorizontalGroup(layout3.createSequentialGroup()
        
         .addGroup(layout3.createParallelGroup()
            .addGroup(layout3.createSequentialGroup()
                .addComponent(bM_Categories)
                .addComponent(self.iStart))
            .addGroup(layout3.createSequentialGroup()
                .addComponent(optioncCategories)
                .addComponent(self.cCurly)
                .addComponent(self.cSemiC)
                )
           
            .addGroup(layout3.createSequentialGroup()
                .addComponent(bcCat)
                .addComponent(self.RThis)
                .addComponent(self.RThat))
            .addGroup(layout3.createSequentialGroup()
                
                )

                )
        )
        
        layout3.setVerticalGroup(layout3.createSequentialGroup()
            .addGroup(layout3.createSequentialGroup()
                    .addGroup(layout3.createParallelGroup()
                        .addComponent(bM_Categories)
                        .addComponent(self.iStart))
                    
                    .addGroup(layout3.createParallelGroup()
                        .addComponent(bcCat)
                        .addComponent(self.RThis)
                        .addComponent(self.RThat))
                    .addGroup(layout3.createParallelGroup()
                        
                    .addGroup(layout3.createParallelGroup()
                        .addComponent(optioncCategories)
                        .addComponent(self.cCurly)
                        .addComponent(self.cSemiC)
                        )
                   
                                )
                        )
            
            )
        #############################################################
        # ConfimIT Layout: 2 groups one Horizontal and one Vertical
        layout4.setHorizontalGroup(layout4.createSequentialGroup()
        
         .addGroup(layout4.createParallelGroup()
            .addGroup(layout4.createSequentialGroup()
                .addComponent(bClinks)
                .addComponent(self.PID)
                )
            .addGroup(layout4.createSequentialGroup()
                .addComponent(bClinksNA)
                .addComponent(bClinksCA)
                )
            .addGroup(layout4.createSequentialGroup()
                .addComponent(baddDIVt)
                .addComponent(self.Width)
                
                )
                
                ))
        
        
        layout4.setVerticalGroup(layout4.createSequentialGroup()
            .addGroup(layout4.createSequentialGroup()
                    .addGroup(layout4.createParallelGroup()
                        .addComponent(bClinks)
                        .addComponent(self.PID))
                    .addGroup(layout4.createParallelGroup()
                        .addComponent(bClinksNA)
                        .addComponent(bClinksCA)
                        )
                    
                    .addGroup(layout4.createParallelGroup()
                        .addComponent(baddDIVt)
                        .addComponent(self.Width)
                        )
                    
                        
                        ))
        
        
        #layout2.linkSize(SwingConstants.HORIZONTAL, [self.cCurly,bM_Categories])
        #layout.linkSize(SwingConstants.HORIZONTAL, [ok, bCopyToInput, close, bM_Categories])
        #layout3.linkSize(SwingConstants.HORIZONTAL, [self.RThis,self.RThat,bRemoveNBSP_L,bRemoveNBSP_R,bM_Categories,bSandReplace,bcCat])

        
#############################################################

#############################################################
# Aplication Settings
        self.pack()
        #self.setPreferredSize(Dimension(1000, 1000))
        self.setTitle("Workhelper")
        self.setSize(800, 500)
        self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
        self.setLocationRelativeTo(None)
        self.setVisible(True)
Beispiel #15
0
    def initUI(self):
        #panel = 
        layout = GroupLayout(self.getContentPane())
        self.getContentPane().setLayout(layout)
        layout.setAutoCreateGaps(True)
        layout.setAutoCreateContainerGaps(True)
        #self.setPreferredSize(Dimension(300, 300))
        self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
        # definition of elements
        # labels
        dateLabel = JLabel("Date:")
        strainLabel = JLabel("Strain:")
        tempLabel = JLabel("Temperature:")
        dCelLabel = JLabel("C")
        ODLabel = JLabel("OD:")
        condLabel = JLabel("Condition:")
        
        #textfields
        dateField = JTextField( "today", 1)#str(date.today()), 8 )
        strainField = JTextField( "2926",1 )
        tempField = JTextField( "34",2 )
        ODField = JTextField( "0.5",3 )
        condField = JTextField( "0.5",3 )
        
        #buttons
        OKButton = JButton("OK",actionPerformed=None)
        CancelButton = JButton("Cancel", actionPerformed=cancel)
        
        '''horizontal layout = parallel group (sequential group (c1, c2), sequential group(c3,c4))
           vertical layout = parallel group ( sequential group(c1,c3), sequential group(c2,c4))'''
        
        layout.setHorizontalGroup(layout.createSequentialGroup()
                                  .addGroup(layout.createParallelGroup()
                                            .addComponent(dateLabel)
                                            .addComponent(strainLabel)
                                            .addComponent(tempLabel)
                                            .addComponent(ODLabel)
                                            .addComponent(condLabel))
                                  .addGroup(layout.createParallelGroup()
                                            .addComponent(dateField)
                                            .addComponent(strainField)
                                            .addGroup(layout.createSequentialGroup()
                                                      .addComponent(tempField)
                                                      .addComponent(dCelLabel))
                                            .addComponent(ODField)
                                            .addComponent(condField)
                                            .addGroup(layout.createSequentialGroup()
                                                      .addComponent(CancelButton)
                                                      .addComponent(OKButton)
                                                      .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                                      )
                                            )
                                  )
        layout.setVerticalGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                          .addComponent(dateLabel)
                                          .addComponent(dateField)
                                          )
                                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                          .addComponent(strainLabel)
                                          .addComponent(strainField)
                                          )
                                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                          .addComponent(tempLabel)
                                          .addComponent(tempField)
                                          .addComponent(dCelLabel)
                                          )                                
                                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                          .addComponent(ODLabel)
                                          .addComponent(ODField)
                                          )                                      
                                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                          .addComponent(condLabel)
                                          .addComponent(condField)
                                          )
                                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                          .addComponent(CancelButton)
                                          .addComponent(OKButton))    
                              )
    
        

        self.setTitle("CellSelector")

        #self.setSize(200, 150)
        self.pack()
        self.setLocationRelativeTo(None)
        self.setVisible(True)
Beispiel #16
0
class BurpExtender(IBurpExtender, ITab, IContextMenuFactory, DocumentListener, ChangeListener):

    #
    # implement IBurpExtender
    #
    def	registerExtenderCallbacks(self, callbacks):
        print "PhantomJS RIA Crawler extension"
        print "Nikolay Matyunin @autorak <*****@*****.**>"

        # keep a reference to our callbacks object and helpers object
        self._callbacks = callbacks
        self._helpers = callbacks.getHelpers()

        # extension name
        callbacks.setExtensionName("Phantom RIA Crawler")

        # Create Tab UI components
        self._jPanel = JPanel()
        self._jPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));

        _titleLabel = JLabel("Phantom RIA Crawler", SwingConstants.LEFT)
        _titleLabelFont = _titleLabel.font
        _titleLabelFont = _titleLabelFont.deriveFont(Font.BOLD, 12);
        _titleLabel.setFont(_titleLabelFont);
        _titleLabel.setForeground(Color(230, 142, 11))

        self._addressTextField = JTextField('')
        self._addressTextField.setColumns(50)
        _addressTextLabel = JLabel("Target URL:", SwingConstants.RIGHT)
        self._addressTextField.getDocument().addDocumentListener(self)

        self._phantomJsPathField = JTextField('phantomjs') # TODO: set permanent config value
        self._phantomJsPathField.setColumns(50)
        _phantomJsPathLabel = JLabel("PhantomJS path:", SwingConstants.RIGHT)

        self._startButton = JToggleButton('Start', actionPerformed=self.startToggled)
        self._startButton.setEnabled(False)

        _requestsMadeLabel = JLabel("DEPs found:", SwingConstants.RIGHT)
        self._requestsMadeInfo = JLabel("", SwingConstants.LEFT)
        _statesFoundLabel = JLabel("States found:", SwingConstants.RIGHT)
        self._statesFoundInfo = JLabel("", SwingConstants.LEFT)

        _separator = JSeparator(SwingConstants.HORIZONTAL)

        _configLabel = JLabel("Crawling configuration:")
        self._configButton = JButton("Load config", actionPerformed=self.loadConfigClicked)
        self._configFile = ""

        _listenersLabel= JLabel("Burp proxy listener:", SwingConstants.RIGHT)
        self._listenersCombo = JComboBox()
        self._configTimer = Timer(5000, None)
        self._configTimer.actionPerformed = self._configUpdated
        self._configTimer.stop()
        self._configUpdated(None)

        self._commandClient = CommandClient(self)

        # Layout management
        self._groupLayout = GroupLayout(self._jPanel)
        self._jPanel.setLayout(self._groupLayout)
        self._groupLayout.setAutoCreateGaps(True)
        self._groupLayout.setAutoCreateContainerGaps(True)

        self._groupLayout.setHorizontalGroup(self._groupLayout.createParallelGroup()
            .addComponent(_titleLabel)
            .addGroup(self._groupLayout.createSequentialGroup()
                .addComponent(_addressTextLabel)
                .addGroup(self._groupLayout.createParallelGroup()
                    .addComponent(self._addressTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addGroup(self._groupLayout.createSequentialGroup()
                        .addComponent(_requestsMadeLabel)
                        .addComponent(self._requestsMadeInfo))
                    .addGroup(self._groupLayout.createSequentialGroup()
                        .addComponent(_statesFoundLabel)
                        .addComponent(self._statesFoundInfo)))
                .addComponent(self._startButton))
            .addComponent(_separator)
            .addGroup(self._groupLayout.createSequentialGroup()
                .addComponent(_configLabel)
                .addComponent(self._configButton))
            .addGroup(self._groupLayout.createSequentialGroup()
                .addComponent(_phantomJsPathLabel)
                .addComponent(self._phantomJsPathField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
            .addGroup(self._groupLayout.createSequentialGroup()
                .addComponent(_listenersLabel)
                .addComponent(self._listenersCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
        )

        self._groupLayout.setVerticalGroup(self._groupLayout.createSequentialGroup()
            .addComponent(_titleLabel)
            .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(_addressTextLabel)
                .addComponent(self._addressTextField)
                .addComponent(self._startButton))
            .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(_requestsMadeLabel)
                .addComponent(self._requestsMadeInfo))
            .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(_statesFoundLabel)
                .addComponent(self._statesFoundInfo))
            .addComponent(_separator, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
            .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(_configLabel)
                .addComponent(self._configButton))
            .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(_phantomJsPathLabel)
                .addComponent(self._phantomJsPathField))
            .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(_listenersLabel)
                .addComponent(self._listenersCombo))
        )

        self._groupLayout.linkSize(SwingConstants.HORIZONTAL, _configLabel, _phantomJsPathLabel);
        self._groupLayout.linkSize(SwingConstants.HORIZONTAL, _configLabel, _listenersLabel);
        self._groupLayout.linkSize(SwingConstants.HORIZONTAL, _statesFoundLabel, _requestsMadeLabel);


        # context menu data
        self._contextMenuData = None;
        self._running = False;

        # register callbacks
        callbacks.customizeUiComponent(self._jPanel)
        callbacks.registerContextMenuFactory(self)
        callbacks.addSuiteTab(self)

        return

    #
    # implement ITab and Tab ChangeListener
    #
    def getTabCaption(self):
        return "Phantom RIA Crawler"
    def getUiComponent(self):
        return self._jPanel
    def stateChanged(self, ev):
        self._configUpdated()

    def _configUpdated(self, ev):
        config = self._callbacks.saveConfig()

        # update proxy listeners
        index = 0
        listeners = DefaultComboBoxModel()
        while (("proxy.listener" + str(index)) in config):
            listenerItem = config["proxy.listener" + str(index)]
            listenerItems = listenerItem.split(".")
            if (listenerItems[0] == "1"):
                address = ".".join(listenerItems[2][1:].split("|"))
                if (len(address) == 0):
                    address = "127.0.0.1"
                listeners.addElement(address + " : " + listenerItems[1])

            index = index + 1
        self._listenersCombo.setModel(listeners)
        return;

    #
    # implement button actions
    #
    def startToggled(self, ev):
        if (self._startButton.getModel().isSelected()):
            try:
                os.chdir(sys.path[0] + os.sep + "riacrawler" + os.sep + "scripts")
            except Exception as e:
                print >> sys.stderr, "RIA crawler scripts loading error", "I/O error({0}): {1}".format(e.errno, e.strerror)
                self._startButton.setSelected(False)
                return

            phantomJsPath = self._phantomJsPathField.text
            target = self._addressTextField.text

            config = "crawler.config"
            if (self._configFile):
                config = self._configFile

            listenerAddress = self._listenersCombo.getSelectedItem().replace(" ", "")
            p = Popen("{0} --proxy={3} main.js --target={1} --config={2}".format(phantomJsPath, target, config, listenerAddress), shell=True)
            self._running = True
            self._requestsMadeInfo.setText("")
            self._statesFoundInfo.setText("")
            self._commandClient.startCrawling()
        else:
            if (self._running):
                self._commandClient.stopCrawling()
            self._running = False

    def syncCrawlingState(self, result):
        print "RIA crawling state: ", result
        self._requestsMadeInfo.setText(str(result["requests_made"]))
        self._statesFoundInfo.setText(str(result["states_detected"]))
        if (result["running"] == False):
            self._commandClient.stopCrawling()
            self._running = False
            self._startButton.setSelected(False)

    def loadConfigClicked(self, ev):
        openFile = JFileChooser();
        openFile.showOpenDialog(None);
        self._configFile = openFile.getSelectedFile()

    #
    # implement DocumentListener for _addressTextField
    #
    def removeUpdate(self, ev):
        self.updateStartButton()
    def insertUpdate(self, ev):
        self.updateStartButton()
    def updateStartButton(self):
        self._startButton.setEnabled(len(self._addressTextField.text) > 0)


    #
    # implement IContextMenuFactory
    #
    def createMenuItems(self, contextMenuInvocation):
        menuItemList = ArrayList()

        context = contextMenuInvocation.getInvocationContext()
        if (context == IContextMenuInvocation.CONTEXT_MESSAGE_VIEWER_REQUEST or context == IContextMenuInvocation.CONTEXT_MESSAGE_EDITOR_REQUEST or
            context == IContextMenuInvocation.CONTEXT_PROXY_HISTORY or context == IContextMenuInvocation.CONTEXT_TARGET_SITE_MAP_TABLE):

            self._contextMenuData = contextMenuInvocation.getSelectedMessages()
            menuItemList.add(JMenuItem("Send to Phantom RIA Crawler", actionPerformed = self.menuItemClicked))

        return menuItemList


    def menuItemClicked(self, event):
        if (self._running == True):
            self._callbacks.issueAlert("Can't set data to Phantom RIA Crawler: crawling is running already.")
            return;

        dataIsSet = False;
        for message in self._contextMenuData:
            request = self._helpers.analyzeRequest(message)

            url = request.getUrl().toString()
            print url
            if (url):
                dataisSet = True;
                self._addressTextField.setText(url)
Beispiel #17
0
    def __init__(self):
        self.listModel = DefaultListModel()

        self.cbTitle = JLabel("Out-of-band Payloads")
        self.cbTitle.setFont(self.cbTitle.getFont().deriveFont(14.0))
        self.cbTitle.setFont(self.cbTitle.getFont().deriveFont(Font.BOLD))

        self.cbSubTitle = JLabel(
            "Add payloads to active scanner that interact "
            "with out-of-band services (e.g., XSSHunter)")
        self.cbSubTitle.setFont(self.cbSubTitle.getFont().deriveFont(12.0))

        self.cbList = JList(self.listModel)
        self.cbList.setCellRenderer(ListRenderer())
        self.cbList.setVisibleRowCount(10)

        self.listScrollPane = JScrollPane(self.cbList)
        self.cbText = JTextField(actionPerformed=self.add_element)
        self.cbRemoveButton = JButton("Remove",
                                      actionPerformed=self.remove_element)
        self.cbLoadButton = JButton("Load...", actionPerformed=self.add_file)
        self.cbPasteButton = JButton("Paste",
                                     actionPerformed=self.paste_elements)
        self.cbClearButton = JButton("Clear",
                                     actionPerformed=self.clear_elements)

        self.cbAddButton = JButton("Add", actionPerformed=self.add_element)

        self.cbDropDownLabel = JLabel("Payload Encoding: ")
        self.cbDropDown = JComboBox()
        self.cbDropDown.addItem("Non URL Encoded")
        self.cbDropDown.addItem("URL Encoded")
        self.cbDropDown.addItem("Both (two requests per payload)")

        self.grpOOB = JPanel()

        grpLayout = GroupLayout(self.grpOOB)
        self.grpOOB.setLayout(grpLayout)
        grpLayout.linkSize(SwingConstants.HORIZONTAL, self.cbRemoveButton,
                           self.cbLoadButton, self.cbPasteButton,
                           self.cbClearButton, self.cbAddButton)
        grpLayout.setAutoCreateGaps(True)
        grpLayout.setAutoCreateContainerGaps(True)
        grpLayout.setHorizontalGroup(
            grpLayout.createSequentialGroup().addGroup(
                grpLayout.createParallelGroup().addComponent(
                    self.cbTitle).addGroup(
                        grpLayout.createParallelGroup().addComponent(
                            self.cbRemoveButton).addComponent(
                                self.cbLoadButton).addComponent(
                                    self.cbPasteButton).addComponent(
                                        self.cbClearButton)).addComponent(
                                            self.cbAddButton).
                addComponent(self.cbDropDownLabel)).addGroup(
                    grpLayout.createParallelGroup().addComponent(
                        self.cbSubTitle).addComponent(
                            self.listScrollPane).addComponent(
                                self.cbText).addComponent(self.cbDropDown)))
        grpLayout.setVerticalGroup(grpLayout.createSequentialGroup().addGroup(
            grpLayout.createParallelGroup().addComponent(self.cbTitle)
        ).addGroup(grpLayout.createParallelGroup().addComponent(
            self.cbSubTitle)).addGroup(
                grpLayout.createParallelGroup().addGroup(
                    grpLayout.createSequentialGroup().addComponent(
                        self.cbPasteButton).addComponent(
                            self.cbLoadButton).addComponent(
                                self.cbRemoveButton).addComponent(
                                    self.cbClearButton)).addComponent(
                                        self.listScrollPane)
            ).addGroup(grpLayout.createParallelGroup().addComponent(
                self.cbAddButton).addComponent(self.cbText)).addGroup(
                    grpLayout.createParallelGroup().addComponent(
                        self.cbDropDownLabel).addComponent(self.cbDropDown)))

        # Tab Layout
        self.tab = JPanel()
        tabLayout = GroupLayout(self.tab)
        self.tab.setLayout(tabLayout)
        tabLayout.setAutoCreateGaps(True)
        tabLayout.setAutoCreateContainerGaps(True)
        tabLayout.setHorizontalGroup(
            tabLayout.createSequentialGroup().addGroup(
                tabLayout.createParallelGroup().addComponent(
                    self.grpOOB, GroupLayout.PREFERRED_SIZE,
                    GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)))
        tabLayout.setVerticalGroup(tabLayout.createSequentialGroup().addGroup(
            tabLayout.createParallelGroup().addComponent(
                self.grpOOB, GroupLayout.PREFERRED_SIZE,
                GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)))
    def __init__(self):
        TrafficMod.__init__(self)
        self.setLayout(FlowLayout(FlowLayout.LEADING))

        settings_panel = JPanel()
        layout = GroupLayout(settings_panel)
        layout.setAutoCreateGaps(True)
        layout.setAutoCreateContainerGaps(True)
        settings_panel.setLayout(layout)
        self.add(settings_panel)

        # Horizontal group
        horizontal = layout.createParallelGroup()
        layout.setHorizontalGroup(
            layout.createSequentialGroup().addGroup(horizontal))

        # Vertical group
        vertical = layout.createSequentialGroup()
        layout.setVerticalGroup(vertical)

        # Main title, label only
        main_title = JLabel(self.title)
        main_title.setFont(get_title_font(main_title))
        horizontal.addGroup(
            layout.createSequentialGroup().addComponent(main_title))
        vertical.addGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.BASELINE).addComponent(main_title))

        # Reorder percentage
        percent_lbl = JLabel("Reorder %")
        horizontal.addGroup(layout.createSequentialGroup().addComponent(
            percent_lbl).addComponent(self.reorder_percent))
        vertical.addGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.BASELINE).addComponent(
                    percent_lbl).addComponent(self.reorder_percent))

        # Reorder percentage correlation
        corr_lbl = JLabel("Correlation %")
        horizontal.addGroup(
            layout.createSequentialGroup().addComponent(corr_lbl).addComponent(
                self.reorder_percent_correlation))
        vertical.addGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.BASELINE).addComponent(
                    corr_lbl).addComponent(self.reorder_percent_correlation))

        layout.linkSize(SwingConstants.HORIZONTAL, corr_lbl, percent_lbl)

        # Reorder gap
        gap_lbl = JLabel("Gap")
        horizontal.addGroup(
            layout.createSequentialGroup().addComponent(gap_lbl).addComponent(
                self.reorder_gap))
        vertical.addGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.BASELINE).addComponent(
                    gap_lbl).addComponent(self.reorder_gap))

        layout.linkSize(SwingConstants.HORIZONTAL, gap_lbl, percent_lbl)
Beispiel #19
0
    def set_settings(self):
        self.settings = JPanel()
        layout = GroupLayout(self.settings)
        self.settings.setLayout(layout)
        layout.setAutoCreateGaps(True)

        load_file_button = JButton("Load JSON File")
        load_file_button.setActionCommand("load")
        load_file_button.addActionListener(
            SettingsAction(self, load_file_button, None))
        save_file_button = JButton("Save JSON File")
        save_file_button.setActionCommand("save")
        save_file_button.addActionListener(
            SettingsAction(None, save_file_button, self.tabbed_panes))

        horizontal_group1 = layout.createParallelGroup(
            GroupLayout.Alignment.LEADING)
        horizontal_group1.addComponent(load_file_button)
        horizontal_group1.addComponent(save_file_button)

        horizontal_group = layout.createSequentialGroup()
        horizontal_group.addGroup(horizontal_group1)

        layout.setHorizontalGroup(horizontal_group)

        vertical_group1 = layout.createParallelGroup(
            GroupLayout.Alignment.BASELINE)
        vertical_group1.addComponent(load_file_button)
        vertical_group2 = layout.createParallelGroup(
            GroupLayout.Alignment.BASELINE)
        vertical_group2.addComponent(save_file_button)

        vertical_group = layout.createSequentialGroup()
        vertical_group.addGroup(vertical_group1)
        vertical_group.addGroup(vertical_group2)

        layout.setVerticalGroup(vertical_group)
Beispiel #20
0
    def __init__(self, callbacks, issue=defaultIssue, title="", modality=""):
        """Constructor, populates the dialog."""
        # set the title
        self.setTitle(title)
        # store the issue
        self.issue = issue

        from javax.swing import JFrame
        self.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE)

        if modality is not "":
            from java.awt.Dialog import ModalityType
            modality = modality.lower()
            # application blocks us from clicking anything else in Burp
            if modality == "application":
                self.setModalityType(ModalityType.APPLICATION_MODAL)
            if modality == "document":
                self.setModalityType(ModalityType.DOCUMENT_MODAL)
            if modality == "modeless":
                self.setModalityType(ModalityType.DOCUMENT_MODAL)
            if modality == "toolkit":
                self.setModalityType(ModalityType.DOCUMENT_MODAL)

        # assert isinstance(callbacks, IBurpExtenderCallbacks)
        # starting converted code from NetBeans
        self.labelPath = JLabel("Path")
        self.labelSeverity = JLabel("Severity")
        self.tabIssue = JTabbedPane()
        self.textAreaDescription = JTextArea()
        self.textAreaRemediation = JTextArea()
        # JScrollPanes to hold the two jTextAreas
        # put the textareas in JScrollPanes
        self.jsPaneDescription = JScrollPane(self.textAreaDescription)
        self.jsPaneRemediation = JScrollPane(self.textAreaRemediation)
        self.panelRequest = callbacks.createMessageEditor(None, True)
        self.panelResponse = callbacks.createMessageEditor(None, True)
        self.textName = JTextField()
        self.textHost = JTextField()
        self.textPath = JTextField()
        self.labelHost = JLabel("Host")
        self.labelName = JLabel("Name")

        # buttons
        self.buttonSave = JButton("Save",
                                  actionPerformed=self.saveButtonAction)
        self.buttonCancel = JButton("Cancel",
                                    actionPerformed=self.cancelButtonAction)
        self.buttonReset = JButton("Reset",
                                   actionPerformed=self.resetButtonAction)

        # description and remediation textareas
        from java.awt import Dimension
        self.textAreaDescription.setPreferredSize(Dimension(400, 500))
        self.textAreaDescription.setLineWrap(True)
        self.textAreaDescription.setWrapStyleWord(True)
        self.textAreaRemediation.setLineWrap(True)
        self.textAreaRemediation.setWrapStyleWord(True)
        self.tabIssue.addTab("Description", self.jsPaneDescription)
        self.tabIssue.addTab("Remediation", self.jsPaneRemediation)
        # request and response tabs
        # request tab
        self.panelRequest.setMessage("", True)
        self.tabIssue.addTab("Request", self.panelRequest.getComponent())
        # response tab
        self.panelResponse.setMessage("", False)
        self.tabIssue.addTab("Response", self.panelResponse.getComponent())
        # template
        self.labelTemplate = JLabel("Template")
        self.comboTemplate = JComboBox()

        # TODO: Populate this from outside using a config file from the
        # constructor? or perhaps the extension config
        self.comboSeverity = JComboBox(
            ["Critical", "High", "Medium", "Low", "Info"])
        self.comboSeverity.setSelectedIndex(-1)

        # add componentlistener
        dlgListener = DialogListener(self)
        self.addComponentListener(dlgListener)

        if issue is None:
            issue = self.defaultIssue
        # load the issue into the edit dialog.
        self.loadPanel(issue)

        # "here be dragons" GUI code
        layout = GroupLayout(self.getContentPane())
        self.getContentPane().setLayout(layout)
        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.CENTER).addGroup(
                layout.createSequentialGroup().addGroup(
                    layout.createParallelGroup(GroupLayout.Alignment.CENTER).
                    addGroup(layout.createSequentialGroup().addContainerGap(
                    ).addGroup(layout.createParallelGroup().addGroup(
                        layout.createSequentialGroup().addGroup(
                            layout.createParallelGroup().addComponent(
                                self.labelTemplate).addComponent(
                                    self.labelHost).
                            addComponent(self.labelName)).addPreferredGap(
                                LayoutStyle.ComponentPlacement.UNRELATED).
                        addGroup(layout.createParallelGroup().addGroup(
                            layout.createSequentialGroup().addComponent(
                                self.comboTemplate)
                        ).addGroup(layout.createSequentialGroup().addComponent(
                            self.textHost, GroupLayout.PREFERRED_SIZE, 212,
                            GroupLayout.PREFERRED_SIZE).addPreferredGap(
                                LayoutStyle.ComponentPlacement.UNRELATED
                            ).addComponent(self.labelPath).addPreferredGap(
                                LayoutStyle.ComponentPlacement.RELATED
                            ).addComponent(
                                self.textPath, GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE, 800
                            )).addGroup(
                                GroupLayout.Alignment.TRAILING,
                                layout.createSequentialGroup().
                                addComponent(self.textName).addPreferredGap(
                                    LayoutStyle.ComponentPlacement.UNRELATED).
                                addComponent(
                                    self.labelSeverity).addPreferredGap(
                                        LayoutStyle.ComponentPlacement.
                                        UNRELATED).addComponent(
                                            self.comboSeverity,
                                            GroupLayout.PREFERRED_SIZE, 182,
                                            GroupLayout.PREFERRED_SIZE)))
                    ).addComponent(self.tabIssue))).addGroup(
                        layout.createSequentialGroup().addComponent(
                            self.buttonSave, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.PREFERRED_SIZE,
                            GroupLayout.PREFERRED_SIZE).addComponent(
                                self.buttonReset, GroupLayout.PREFERRED_SIZE,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.PREFERRED_SIZE).addComponent(
                                    self.buttonCancel,
                                    GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.PREFERRED_SIZE, GroupLayout.
                                    PREFERRED_SIZE))).addContainerGap()))

        # link size of buttons together
        from javax.swing import SwingConstants
        layout.linkSize(SwingConstants.HORIZONTAL,
                        [self.buttonCancel, self.buttonSave, self.buttonReset])

        layout.setVerticalGroup(layout.createParallelGroup().addGroup(
            GroupLayout.Alignment.TRAILING,
            layout.createSequentialGroup().addContainerGap().addGroup(
                layout.createParallelGroup(
                    GroupLayout.Alignment.BASELINE).addComponent(
                        self.labelName).addComponent(
                            self.textName, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE).addComponent(
                                self.labelSeverity).addComponent(
                                    self.comboSeverity,
                                    GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)).
            addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(
                layout.createParallelGroup(
                    GroupLayout.Alignment.BASELINE).addComponent(
                        self.textHost, GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE).addComponent(
                            self.labelPath).addComponent(self.textPath).
                addComponent(self.labelHost)).addGroup(
                    layout.createParallelGroup(
                        GroupLayout.Alignment.BASELINE).addComponent(
                            self.comboTemplate, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE).addComponent(
                                self.labelTemplate)).addPreferredGap(
                                    LayoutStyle.ComponentPlacement.RELATED).
            addComponent(self.tabIssue).addPreferredGap(
                LayoutStyle.ComponentPlacement.RELATED).addGroup(
                    layout.createParallelGroup().addComponent(
                        self.buttonSave).addComponent(
                            self.buttonReset).addComponent(
                                self.buttonCancel)).addContainerGap()))
        # end of converted code from NetBeans

        # set the template label and combobox to invisible
        self.labelTemplate.setVisible(False)
        self.comboTemplate.setVisible(False)
Beispiel #21
0
    def registerExtenderCallbacks(self, callbacks):
        self.callbacks = callbacks
        self.helpers = callbacks.getHelpers()
        callbacks.setExtensionName("WebTech")
        self.out = callbacks.getStdout()
        self.callbacks.printOutput("Sucessfully loaded WebTech {}".format(VERSION))

        self.webtech = WebTech(options={'json': True})

        # define all checkboxes
        self.cbPassiveChecks = self.defineCheckBox("Enable Passive Scanner Checks")
        self.cbActiveChecks = self.defineCheckBox("Enable Active Scanner Checks", True, False)
        self.btnSave = JButton("Set as default", actionPerformed=self.saveConfig)
        self.btnRestore = JButton("Restore", actionPerformed=self.restoreConfig)
        self.grpConfig = JPanel()
        self.grpConfig.add(self.btnSave)
        self.grpConfig.add(self.btnRestore)
        self.restoreConfig()

        # definition of config tab
        self.tab = JPanel()
        layout = GroupLayout(self.tab)
        self.tab.setLayout(layout)
        layout.setAutoCreateGaps(True)
        layout.setAutoCreateContainerGaps(True)
        layout.setHorizontalGroup(
            layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup()
                      .addComponent(self.cbPassiveChecks)
                      .addComponent(self.cbActiveChecks)
                      )
            .addGroup(layout.createParallelGroup()
                      .addComponent(self.grpConfig, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                      )
        )
        layout.setVerticalGroup(
            layout.createSequentialGroup()
            .addComponent(self.cbPassiveChecks)
            .addComponent(self.cbActiveChecks)
            .addComponent(self.grpConfig, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        )

        callbacks.registerScannerCheck(self)
        callbacks.addSuiteTab(self)
Beispiel #22
0
    def initComponents(self):
        TabbedPane1 = JTabbedPane()
        GeneratorScrollPane = JScrollPane()
        GeneratorPanel = JPanel()
        jlbl1 = JLabel()
        jlbl2 = JLabel()
        spanePayloadList = JScrollPane()
        self.listPayloads = JList()
        pastePayloadButton = JButton(
            actionPerformed=self.pastePayloadButtonAction)
        loadPayloadButton = JButton(
            actionPerformed=self.loadPayloadButtonAction)
        removePayloadButton = JButton(
            actionPerformed=self.removePayloadButtonAction)
        clearPayloadButton = JButton(
            actionPerformed=self.clearPayloadButtonAction)
        self.textNewPayload = JTextField()
        addPayloadButton = JButton(actionPerformed=self.addPayloadButtonAction)
        jSeparator1 = JSeparator()
        jlbl3 = JLabel()
        jlbl4 = JLabel()
        self.chkGeneral = JCheckBox(actionPerformed=self.OnCheck)
        self.chkMAXDB = JCheckBox(actionPerformed=self.OnCheck)
        self.chkMSSQL = JCheckBox(actionPerformed=self.OnCheck)
        self.chkMSAccess = JCheckBox(actionPerformed=self.OnCheck)
        self.chkPostgres = JCheckBox(actionPerformed=self.OnCheck)
        self.chkOracle = JCheckBox(actionPerformed=self.OnCheck)
        self.chkSqlite = JCheckBox(actionPerformed=self.OnCheck)
        self.chkMysql = JCheckBox(actionPerformed=self.OnCheck)
        jlbl5 = JLabel()
        toClipboardButton = JButton(
            actionPerformed=self.toClipboardButtonAction)
        toFileButton = JButton(actionPerformed=self.toFileButtonAction)
        ProcessorScrollPane = JScrollPane()
        ProcessorPanel = JPanel()
        jLabel1 = JLabel()
        self.comboProcessorTech = JComboBox(
            itemStateChanged=self.comboProcessorTechAction)
        jSeparator2 = JSeparator()
        jLabel2 = JLabel()
        jLabel3 = JLabel()
        jScrollPane1 = JScrollPane()
        self.textPlainPayload = JTextArea()
        jLabel4 = JLabel()
        jScrollPane2 = JScrollPane()
        self.textTamperedPayload = JTextArea()
        tamperPayloadButton = JButton(
            actionPerformed=self.tamperPayloadButtonAction)

        jlbl1.setForeground(Color(255, 102, 51))
        jlbl1.setFont(Font(jlbl1.getFont().toString(), 1, 14))
        jlbl1.setText("User-Defiend Payloads")

        jlbl2.setText(
            "This payload type lets you configure a simple list of strings that are used as payloads."
        )

        spanePayloadList.setViewportView(self.listPayloads)
        self.extender.PayloadList = self.readPayloadsListFile()
        self.listPayloads.setListData(self.extender.PayloadList)

        pastePayloadButton.setText("Paste")

        loadPayloadButton.setText("Load")

        removePayloadButton.setText("Remove")

        clearPayloadButton.setText("Clear")

        self.textNewPayload.setToolTipText("")

        addPayloadButton.setText("Add")

        jlbl3.setForeground(Color(255, 102, 51))
        jlbl3.setFont(Font(jlbl3.getFont().toString(), 1, 14))
        jlbl3.setText("Tamper Techniques")

        jlbl4.setText(
            "You can select the techniques that you want to perform processing tasks on each user-defined payload"
        )

        self.chkGeneral.setText("General")
        varName = 'SQLiQueryTampering_{}'.format(self.chkGeneral.text)
        state = self.extender.callbacks.loadExtensionSetting(varName)
        if state: self.chkGeneral.setSelected(int(state))

        self.chkMAXDB.setText("SAP MAX DB")
        varName = 'SQLiQueryTampering_{}'.format(self.chkMAXDB.text)
        state = self.extender.callbacks.loadExtensionSetting(varName)
        if state: self.chkMAXDB.setSelected(int(state))

        self.chkMSSQL.setText("MS SQL Server")
        varName = 'SQLiQueryTampering_{}'.format(self.chkMSSQL.text)
        state = self.extender.callbacks.loadExtensionSetting(varName)
        if state: self.chkMSSQL.setSelected(int(state))

        self.chkMSAccess.setText("MS Access")
        varName = 'SQLiQueryTampering_{}'.format(self.chkMSAccess.text)
        state = self.extender.callbacks.loadExtensionSetting(varName)
        if state: self.chkMSAccess.setSelected(int(state))

        self.chkPostgres.setText("Postgres SQL")
        varName = 'SQLiQueryTampering_{}'.format(self.chkPostgres.text)
        state = self.extender.callbacks.loadExtensionSetting(varName)
        if state: self.chkPostgres.setSelected(int(state))

        self.chkOracle.setText("Oracle")
        varName = 'SQLiQueryTampering_{}'.format(self.chkOracle.text)
        state = self.extender.callbacks.loadExtensionSetting(varName)
        if state: self.chkOracle.setSelected(int(state))

        self.chkSqlite.setText("Sqlite")
        varName = 'SQLiQueryTampering_{}'.format(self.chkSqlite.text)
        state = self.extender.callbacks.loadExtensionSetting(varName)
        if state: self.chkSqlite.setSelected(int(state))

        self.chkMysql.setText("MySql")
        varName = 'SQLiQueryTampering_{}'.format(self.chkMysql.text)
        state = self.extender.callbacks.loadExtensionSetting(varName)
        if state: self.chkMysql.setSelected(int(state))

        jlbl5.setText("[?] Save the Generated/Tampered Payloads to :")

        toClipboardButton.setText("Clipboard")

        toFileButton.setText("File")

        GeneratorPanelLayout = GroupLayout(GeneratorPanel)
        GeneratorPanel.setLayout(GeneratorPanelLayout)
        GeneratorPanelLayout.setHorizontalGroup(
            GeneratorPanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).
            addGroup(GeneratorPanelLayout.createSequentialGroup(
            ).addContainerGap().addGroup(
                GeneratorPanelLayout.createParallelGroup(
                    GroupLayout.Alignment.TRAILING).addComponent(
                        jlbl2, GroupLayout.DEFAULT_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        Short.MAX_VALUE).addComponent(
                            jlbl4, GroupLayout.Alignment.LEADING,
                            GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                            Short.MAX_VALUE).addComponent(
                                jSeparator1, GroupLayout.Alignment.LEADING).
                addGroup(GeneratorPanelLayout.createSequentialGroup().addGap(
                    6, 6, 6).addGroup(
                        GeneratorPanelLayout.createParallelGroup(
                            GroupLayout.Alignment.LEADING).addGroup(
                                GeneratorPanelLayout.createSequentialGroup(
                                ).addGroup(
                                    GeneratorPanelLayout.createParallelGroup(
                                        GroupLayout.Alignment.LEADING,
                                        False).addComponent(
                                            removePayloadButton,
                                            GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE,
                                            Short.MAX_VALUE).addComponent(
                                                clearPayloadButton,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE).addComponent(
                                                    loadPayloadButton,
                                                    GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.DEFAULT_SIZE,
                                                    Short.MAX_VALUE).
                                    addComponent(pastePayloadButton,
                                                 GroupLayout.DEFAULT_SIZE,
                                                 GroupLayout.DEFAULT_SIZE,
                                                 Short.MAX_VALUE).addComponent(
                                                     addPayloadButton,
                                                     GroupLayout.DEFAULT_SIZE,
                                                     GroupLayout.DEFAULT_SIZE,
                                                     Short.MAX_VALUE)).
                                addGap(21, 21, 21).addGroup(
                                    GeneratorPanelLayout.createParallelGroup(
                                        GroupLayout.Alignment.LEADING).
                                    addComponent(
                                        self.textNewPayload).addComponent(
                                            spanePayloadList))).addComponent(
                                                jlbl1).addComponent(jlbl3).
                        addGroup(GeneratorPanelLayout.createSequentialGroup(
                        ).addGroup(
                            GeneratorPanelLayout.createParallelGroup(
                                GroupLayout.Alignment.LEADING).addComponent(
                                    self.chkGeneral).addComponent(
                                        self.chkMSSQL)
                        ).addGap(18, 18, 18).addGroup(
                            GeneratorPanelLayout.createParallelGroup(
                                GroupLayout.Alignment.LEADING).addComponent(
                                    self.chkPostgres).addComponent(
                                        self.chkMAXDB)
                        ).addGap(18, 18, 18).addGroup(
                            GeneratorPanelLayout.createParallelGroup(
                                GroupLayout.Alignment.LEADING).addComponent(
                                    self.chkMSAccess).addComponent(
                                        self.chkOracle)
                        ).addGap(18, 18, 18).addGroup(
                            GeneratorPanelLayout.createParallelGroup(
                                GroupLayout.Alignment.LEADING).addComponent(
                                    self.chkSqlite).addComponent(self.chkMysql)
                        )).addGroup(GeneratorPanelLayout.createSequentialGroup(
                        ).addComponent(jlbl5).addPreferredGap(
                            LayoutStyle.ComponentPlacement.
                            UNRELATED).addComponent(toClipboardButton).addGap(
                                18, 18,
                                18).addComponent(toFileButton,
                                                 GroupLayout.PREFERRED_SIZE,
                                                 97, GroupLayout.PREFERRED_SIZE
                                                 ))))).addContainerGap()))
        GeneratorPanelLayout.setVerticalGroup(
            GeneratorPanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).
            addGroup(GeneratorPanelLayout.createSequentialGroup(
            ).addContainerGap().addComponent(jlbl1).addPreferredGap(
                LayoutStyle.ComponentPlacement.RELATED).addComponent(
                    jlbl2, GroupLayout.PREFERRED_SIZE, 21,
                    GroupLayout.PREFERRED_SIZE).addGap(18, 18, 18).addGroup(
                        GeneratorPanelLayout.createParallelGroup(
                            GroupLayout.Alignment.LEADING).addComponent(
                                spanePayloadList, GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE).
                        addGroup(GeneratorPanelLayout.createSequentialGroup(
                        ).addComponent(pastePayloadButton).addPreferredGap(
                            LayoutStyle.ComponentPlacement.RELATED
                        ).addComponent(loadPayloadButton).addPreferredGap(
                            LayoutStyle.ComponentPlacement.RELATED
                        ).addComponent(removePayloadButton).addPreferredGap(
                            LayoutStyle.ComponentPlacement.RELATED).
                                 addComponent(clearPayloadButton))).
                     addPreferredGap(
                         LayoutStyle.ComponentPlacement.RELATED).addGroup(
                             GeneratorPanelLayout.createParallelGroup(
                                 GroupLayout.Alignment.BASELINE).addComponent(
                                     self.textNewPayload,
                                     GroupLayout.PREFERRED_SIZE,
                                     GroupLayout.DEFAULT_SIZE,
                                     GroupLayout.PREFERRED_SIZE).
                             addComponent(addPayloadButton)).addPreferredGap(
                                 LayoutStyle.ComponentPlacement.UNRELATED).
                     addComponent(jSeparator1, GroupLayout.PREFERRED_SIZE, 10,
                                  GroupLayout.PREFERRED_SIZE).addPreferredGap(
                                      LayoutStyle.ComponentPlacement.RELATED).
                     addComponent(jlbl3).addPreferredGap(
                         LayoutStyle.ComponentPlacement.UNRELATED
                     ).addComponent(jlbl4).addPreferredGap(
                         LayoutStyle.ComponentPlacement.UNRELATED).addGroup(
                             GeneratorPanelLayout.createParallelGroup(
                                 GroupLayout.Alignment.BASELINE).addComponent(
                                     self.chkGeneral).addComponent(
                                         self.chkMAXDB).addComponent(
                                             self.chkOracle).addComponent(
                                                 self.chkSqlite)).
                     addPreferredGap(
                         LayoutStyle.ComponentPlacement.UNRELATED).addGroup(
                             GeneratorPanelLayout.createParallelGroup(
                                 GroupLayout.Alignment.BASELINE).addComponent(
                                     self.chkMSSQL).addComponent(
                                         self.chkPostgres).addComponent(
                                             self.chkMSAccess).addComponent(
                                                 self.chkMysql)
                         ).addGap(18, 18, 18).addGroup(
                             GeneratorPanelLayout.createParallelGroup(
                                 GroupLayout.Alignment.BASELINE).addComponent(
                                     jlbl5).addComponent(toClipboardButton).
                             addComponent(toFileButton)).addGap(20, 20, 20)))

        GeneratorScrollPane.setViewportView(GeneratorPanel)

        TabbedPane1.addTab("Generator", GeneratorScrollPane)

        varName = 'SQLiQueryTampering_comboProcessorTech'
        state = self.extender.callbacks.loadExtensionSetting(varName)

        for item in self.extender.getTamperFuncsName():
            self.comboProcessorTech.addItem(item)

        if state: self.comboProcessorTech.setSelectedIndex(int(state))

        jLabel1.setText("Processor Technique :")

        jLabel2.setText(
            "Modify Plain Payloads based on the selected Processor Technique. Write one payload per line."
        )

        jLabel3.setText("Plain Payloads:")

        self.textPlainPayload.setColumns(20)
        self.textPlainPayload.setRows(5)
        jScrollPane1.setViewportView(self.textPlainPayload)

        jLabel4.setText("Tampered Payloads:")

        self.textTamperedPayload.setColumns(20)
        self.textTamperedPayload.setRows(5)
        jScrollPane2.setViewportView(self.textTamperedPayload)

        tamperPayloadButton.setText("Tamper Payloads")

        ProcessorPanelLayout = GroupLayout(ProcessorPanel)
        ProcessorPanel.setLayout(ProcessorPanelLayout)
        ProcessorPanelLayout.setHorizontalGroup(
            ProcessorPanelLayout.
            createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
                GroupLayout.Alignment.TRAILING,
                ProcessorPanelLayout.createSequentialGroup().addContainerGap(
                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(
                        tamperPayloadButton).addContainerGap(
                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            ).addGroup(ProcessorPanelLayout.createSequentialGroup(
            ).addContainerGap().addGroup(
                ProcessorPanelLayout.createParallelGroup(
                    GroupLayout.Alignment.LEADING).addComponent(jSeparator2).
                addComponent(jScrollPane1).addComponent(jScrollPane2).addGroup(
                    ProcessorPanelLayout.createSequentialGroup().addGroup(
                        ProcessorPanelLayout.createParallelGroup(
                            GroupLayout.Alignment.LEADING).addComponent(
                                jLabel3).addComponent(jLabel4).addGroup(
                                    ProcessorPanelLayout.createSequentialGroup(
                                    ).addComponent(jLabel1).addPreferredGap(
                                        LayoutStyle.ComponentPlacement.
                                        UNRELATED).addComponent(
                                            self.comboProcessorTech,
                                            GroupLayout.PREFERRED_SIZE, 286,
                                            GroupLayout.PREFERRED_SIZE)).
                        addComponent(jLabel2)).addGap(
                            0, 78, Short.MAX_VALUE))).addContainerGap()))
        ProcessorPanelLayout.setVerticalGroup(
            ProcessorPanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGroup(
                    ProcessorPanelLayout.createSequentialGroup().addGap(
                        33, 33, 33).addGroup(
                            ProcessorPanelLayout.createParallelGroup(
                                GroupLayout.Alignment.BASELINE).
                            addComponent(jLabel1).addComponent(
                                self.comboProcessorTech,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE)).addGap(
                                    18, 18, 18).addComponent(
                                        jSeparator2,
                                        GroupLayout.PREFERRED_SIZE, 10,
                                        GroupLayout.PREFERRED_SIZE).addGap(
                                            12, 12,
                                            12).addComponent(jLabel2).addGap(
                                                18, 18, 18).
                    addComponent(jLabel3).addPreferredGap(
                        LayoutStyle.ComponentPlacement.UNRELATED).addComponent(
                            jScrollPane1, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE).addPreferredGap(
                                LayoutStyle.ComponentPlacement.UNRELATED).
                    addComponent(jLabel4).addPreferredGap(
                        LayoutStyle.ComponentPlacement.UNRELATED).addComponent(
                            jScrollPane2, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE).addPreferredGap(
                                LayoutStyle.ComponentPlacement.UNRELATED).
                    addComponent(tamperPayloadButton).addGap(36, 36, 36)))

        ProcessorScrollPane.setViewportView(ProcessorPanel)

        TabbedPane1.addTab("Processor", ProcessorScrollPane)

        self.mainPanel = JPanel()
        layout = GroupLayout(self.mainPanel)
        self.mainPanel.setLayout(layout)
        layout.setHorizontalGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addComponent(
                    TabbedPane1, GroupLayout.DEFAULT_SIZE, 701,
                    Short.MAX_VALUE))
        layout.setVerticalGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addComponent(TabbedPane1))

        TabbedPane1.getAccessibleContext().setAccessibleName("Generator")
    def registerExtenderCallbacks(self, callbacks):
        self.callbacks = callbacks
        self.helpers = callbacks.getHelpers()
        callbacks.setExtensionName("Missing Scanner Checks")
        self.out = callbacks.getStdout()

        # define all checkboxes
        self.cbPassiveChecks = self.defineCheckBox("Passive Scanner Checks")
        self.cbDOMXSS = self.defineCheckBox("DOM XSS", False)
        self.cbDOMXSSSources = self.defineCheckBox("Sources", False)
        self.cbDOMXSSSinks = self.defineCheckBox("Sinks")
        self.cbDOMXSSjQuerySinks = self.defineCheckBox("jQuery Sinks", False)
        self.grpDOMXSSSettings = JPanel()
        self.grpDOMXSSSettings.add(self.cbDOMXSSSources)
        self.grpDOMXSSSettings.add(self.cbDOMXSSSinks)
        self.grpDOMXSSSettings.add(self.cbDOMXSSjQuerySinks)
        self.cbSTS = self.defineCheckBox("Strict Transport Security")
        self.lblSTSMin = JLabel("Minimum acceptable max-age")
        self.inSTSMin = JTextField(str(STSMinimum), 9, actionPerformed=self.setSTSMinimum) # TODO: actionPerformed only fires on enter key - focus lost would be better
        self.inSTSMin.setToolTipText("Enter the minimum max-age value which is considered as acceptable. Press return to change setting!")
        self.grpSTSSettings = JPanel()
        self.grpSTSSettings.add(self.lblSTSMin)
        self.grpSTSSettings.add(self.inSTSMin)
        self.cbXCTO = self.defineCheckBox("Content Sniffing")
        self.cbXXP = self.defineCheckBox("Client-side XSS Filter Configuration")
        self.cbRedirToHTTPS = self.defineCheckBox("Redirection from HTTP to HTTPS")
        self.btnSave = JButton("Set as default", actionPerformed=self.saveConfig)
        self.btnRestore = JButton("Restore", actionPerformed=self.restoreConfig)
        self.grpConfig = JPanel()
        self.grpConfig.add(self.btnSave)
        self.grpConfig.add(self.btnRestore)
        self.restoreConfig()

        # definition of config tab
        self.tab = JPanel()
        layout = GroupLayout(self.tab)
        self.tab.setLayout(layout)
        layout.setAutoCreateGaps(True)
        layout.setAutoCreateContainerGaps(True)
        layout.setHorizontalGroup(
            layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup()
                      .addComponent(self.cbPassiveChecks)
                      )
            .addGroup(layout.createParallelGroup()
                      .addComponent(self.cbDOMXSS)
                      .addComponent(self.cbSTS)
                      .addComponent(self.cbXCTO)
                      .addComponent(self.cbXXP)
                      .addComponent(self.cbRedirToHTTPS)
                      )
            .addGroup(layout.createParallelGroup()
                      .addComponent(self.grpDOMXSSSettings, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                      .addComponent(self.grpSTSSettings, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                      .addComponent(self.grpConfig, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                      )
            )
        layout.setVerticalGroup(
            layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup()
                      .addComponent(self.cbPassiveChecks)
                      .addComponent(self.cbDOMXSS)
                      .addComponent(self.grpDOMXSSSettings, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                      )
            .addGroup(layout.createParallelGroup()
                      .addComponent(self.cbSTS)
                      .addComponent(self.grpSTSSettings, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                      )
            .addComponent(self.cbXCTO)
            .addComponent(self.cbXXP)
            .addComponent(self.cbRedirToHTTPS)
            .addComponent(self.grpConfig, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
            )

        self.domXSSSourcesRE = re.compile("(location\s*[\[.])|([.\[]\s*[\"']?\s*(arguments|dialogArguments|innerHTML|write(ln)?|open(Dialog)?|showModalDialog|cookie|URL|documentURI|baseURI|referrer|name|opener|parent|top|content|self|frames)\W)|(localStorage|sessionStorage|Database)")
        # NOTE: done some optimizations here, original RE caused too much noise
        # - added leading dot in the first part - original recognized "<a href=..." etc.
        # - removed "value" in first part
        self.domXSSSinksRE = re.compile("(\.(src|href|data|location|code|action)\s*[\"'\]]*\s*\+?\s*=)|((replace|assign|navigate|getResponseHeader|open(Dialog)?|showModalDialog|eval|evaluate|execCommand|execScript|setTimeout|setInterval)\s*[\"'\]]*\s*\()")
        self.domXSSjQuerySinksRE = re.compile("after\(|\.append\(|\.before\(|\.html\(|\.prepend\(|\.replaceWith\(|\.wrap\(|\.wrapAll\(|\$\(|\.globalEval\(|\.add\(|jQUery\(|\$\(|\.parseHTML\(")
        self.headerSTSRE = re.compile("^Strict-Transport-Security:.*?max-age=\"?(\d+)\"?", re.I) # TODO: multiple max-age directives cause confusion!
        self.headerXCTORE = re.compile("^X-Content-Type-Options:\s*nosniff\s*$", re.I)
        self.headerXXP = re.compile("^X-XSS-Protection:\s*(\d)(?:\s*;\s*mode\s*=\s*\"?(block)\"?)?", re.I)
        self.headerLocationHTTPS = re.compile("^(?:Content-)?Location:\s*(https://.*)$", re.I)

        callbacks.registerScannerCheck(self)
        callbacks.addSuiteTab(self)
Beispiel #24
0
class ChatClient(JFrame):
	
	##  Constructor method, receives the variables from the ChatApp class as parameters
	
	def __init__(self, name, greeting, tn):
		'''Constructor, initialises base class & assigns variables
		'''
		# Call to the super method to take care of the base class(es)
		super(ChatClient, self).__init__()
		#  Assign the relevent variable names
		self.username=name
		self.greeting=greeting
		self.tn = tn
		self.no_users=[]
		#  Initiate the Threaded function for receiving messages
		t1=Thread(target=self.recvFunction)
		#  Set to daemon 
		t1.daemon=True
		t1.start()
		#Call the main UI
		uI=self.clientUI()
		
	##  Main GUI building function
	
	def clientUI(self):
		'''ClientUI and Widget creation
		'''
		#  Colours
		foreground_colour = Color(30,57,68)
		background_colour = Color(247,246,242)
		window_background = Color(145,190,210)
		#  Borders
		self.border2=BorderFactory.createLineBorder(foreground_colour,1, True)
		#  Fonts
		self.font= Font("Ubuntu Light",  Font.BOLD, 20)
		self.label_font= Font("Ubuntu Light",  Font.BOLD, 17)
		self.label_2_font= Font( "Ubuntu Light",Font.BOLD, 12)
		self.btn_font=Font("Ubuntu Light", Font.BOLD, 15)
		
		#  Set the layout parameters
		self.client_layout=GroupLayout(self.getContentPane())
		self.getContentPane().setLayout(self.client_layout)	
		self.getContentPane().setBackground(window_background)
		self.client_layout.setAutoCreateGaps(True)
		self.client_layout.setAutoCreateContainerGaps(True)
		self.setPreferredSize(Dimension(400, 450))
		
		#  Create widgets and assemble the GUI
		#  Main display area
		self.main_content=JTextPane()
		self.main_content.setBackground(background_colour)
		#self.main_content.setForeground(foreground_colour)
		self.main_content.setEditable(False)
		#  Message entry area  		
		self.message=JTextArea( 2,2, border=self.border2, font=self.label_font, keyPressed=self.returnKeyPress)
		self.message.requestFocusInWindow()	
		self.message.setBackground(background_colour)
		self.message.setForeground(foreground_colour)
		self.message.setLineWrap(True)
		self.message.setWrapStyleWord(True)
		self.message.setBorder(BorderFactory.createEmptyBorder(3,3,3,3))
		self.message.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), self.returnKeyPress) 
		#  BUttons
		quit_btn=JButton("Quit!", actionPerformed=ChatApp().closeEvent, border=self.border2, font=self.btn_font)
		go_btn=JButton("Send", actionPerformed=self.grabText, border=self.border2, font=self.btn_font)
		quit_btn.setBackground(background_colour)
		go_btn.setBackground(background_colour)
		quit_btn.setForeground(foreground_colour)
		go_btn.setForeground(foreground_colour)
		
		# Make scrollable
		self.scroll_content=JScrollPane(self.main_content)
		self.scroll_content.setPreferredSize(Dimension(150,275))
		self.scroll_content.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)
		self.scroll_content.setViewportView(self.main_content)
		self.scroll_content.setBackground(Color.WHITE)
		self.scroll_message=JScrollPane(self.message)
		self.scroll_message.setPreferredSize(Dimension(150,20))
		self.scroll_message.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS)
		
		# Test user label, still not updating after first round of messages
		self.user_label=JLabel(" Users online : %s "%(str(len(self.no_users))),JLabel.RIGHT, font=self.label_2_font)
		
		#  Assemble the components
		#  Horizontal layout
		self.client_layout.setHorizontalGroup(self.client_layout.createParallelGroup()
				.addComponent(self.scroll_content)
				.addGroup(self.client_layout.createParallelGroup(GroupLayout.Alignment.CENTER)
					.addComponent(self.scroll_message))
				.addGroup(self.client_layout.createSequentialGroup()
					.addComponent(quit_btn)
					.addComponent(go_btn).addGap(20))
				.addGroup(self.client_layout.createParallelGroup()
					.addComponent(self.user_label))
		)
		
		#  Vertical layout
		self.client_layout.setVerticalGroup(self.client_layout.createSequentialGroup()
			.addGroup(self.client_layout.createParallelGroup()
				.addComponent(self.scroll_content))
				.addComponent(self.scroll_message)
				.addGroup(self.client_layout.createParallelGroup()
					.addComponent(quit_btn)
					.addComponent(go_btn))
				.addGroup(self.client_layout.createParallelGroup()
					.addComponent(self.user_label))
		)
		
		#  Finalise the GUI
		self.client_layout.linkSize(SwingConstants.HORIZONTAL, [quit_btn,go_btn, self.user_label])
		self.pack()
		self.message.requestFocusInWindow()
		self.setTitle(">>>   Client %s   <<<"%self.username)
		self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
		self.setLocationRelativeTo(None)
		self.setVisible(True)
		#  Display the server greeting
		self.appendText('\n'+self.greeting+'\n')
	
			
	##  Function responsible for receiving and processing new messages
	
	def recvFunction(self):
		'''A function to control the receiving of data from the connection
		'''
		#  While the connection is available
		while self.tn:
			#  Try to receive data using "<<<" as the delimiter
			try:
				message = self.tn.read_until('<<<')
				#  If a message is received
				if message:
					garb, message=message.split('>>>')
					message, garb = message.split('<<<')
					message = ('\n'+message+'\n')
					#  Call the append text function
					self.appendText(message)
			#  Except if there is no data available		
			except:
				#print('No message')	
				pass
	##  Event driven function to retrieve and send data to the server
	
	def grabText(self, event): 
		'''Function to repeatedly grab new messages entered into the text 
		area and display them in the main text area. Resets the entry area
		'''
		#  Grab the text from the text area
		text=self.message.getText()
		#  Don't allow an empty string through
		if text=='':
			return
		text=text.strip()
		#  Call the append text function
		self.appendText('\nYou : '+text+'\n', self.username)
		#  Reset the text to be empty and grab focus so that it is ready for new text input
		self.message.requestFocusInWindow()
		self.message.setText('')
		#  Send the message to the server
		data=text.encode()
		self.tn.write(data+'\r\n')

	##  Function to handle appending of messages
	
	def appendText(self, message, user=None):
		'''This function takes care of appending any new messages to the content area
		'''
		message_label=JTextArea(message,2,3, font=self.label_2_font)
		#  If this is a message from the grab text function, create a new label, assign it's colours
		if user!=None:
			message_label.setBackground(Color(240,240,240))
			message_label.setForeground(Color(129,129,129))
		#  Otherwise set the format for receive function (no user passed in)	
		else:
			message_label.setBackground(Color(215,215,215))
			message_label.setForeground(Color(40,153,153))
		
		#  Format and style options for the new message labels	
		message_label.setEditable(False)
		message_label.setLineWrap(True)
		message_label.setWrapStyleWord(True)
		message_label.setBorder(BorderFactory.createLineBorder( Color(247,246,242),4))
		#  Sets the positioning of messages
		self.main_content.setCaretPosition(self.main_content.getDocument().getLength())
		doc = self.main_content.getStyledDocument()
		attr=SimpleAttributeSet()
		self.main_content.insertComponent(message_label)
		# Essential for jtextarea to be able to stack message
		doc.insertString( self.main_content.getDocument().getLength(),'\n ', attr)
		# Not sure if needed
		self.main_content.repaint()
		
		###  This is a late edit so it isn't included in the documentation. Basically trying to dynamically update the number
		###  of users label at runtime. Works for incrementing the value but not decrementing it.
		
		print(message)
		#  Only split the message if there are enough values to split (greeting messages differ in format to chat messages)
		try:
			user, text=message.split(' : ')
		except:
			return
			
		#print('Split values are %s %s'%(user, text))
		user=str(user.strip())
		#print(self.no_users)
		#print(user+' : '+text)
		#  If the user already in the list, pass
		if user in self.no_users:
			if text == ('User %s amach sa teach !'%user):
				self.no_users.remove(user)
				print('User % removed'%user)
			
		else:
			#print('User %s not in list'%user)
			if str(user) == 'You':
				#print('User is equal to "You"')
				return 
			self.no_users.append(user)
			print('User appended')
			self.number_users=len(self.no_users)
			#print('Length of user list is '+str(self.number_users))
	
		self.user_label2=JLabel(" Users online : %s "%str(len(self.no_users)),JLabel.RIGHT, font=self.label_2_font)
		#print('Label created')
		#print('Attempt to replace label')
		self.client_layout.replace(self.user_label, self.user_label2) 
		self.user_label = self.user_label2
		self.user_label.repaint()
		self.user_label.revalidate()
		print('Label updated')
	
	##  Function to control return button press in message field

	def returnKeyPress(self,event):
		'''This function creates an object for return key press when inside the message entry area,
		creates an object of KeyAdapter and tests keycode for a match, responds with grab text callback		
		'''
		key_object=Key()
		key_value=key_object.keyPressed(event)
		if key_value == 10:
			self.grabText(event)
Beispiel #25
0
    def registerExtenderCallbacks(self, callbacks):
        print "Load:" + self._name + " " + self._version

        self.callbacks = callbacks
        self.helpers = callbacks.helpers

        #Create Tab layout
        self.jVarsPane = JTextPane()
        self.jVarsPane.setFont(Font('Monospaced', Font.PLAIN, 11))
        self.jVarsPane.addFocusListener(self)

        self.jMenuPanel = JPanel()
        self.jLeftUpPanel = JPanel()

        self.jEnable = JCheckBox()
        self.jEnable.setFont(Font('Monospaced', Font.BOLD, 11))
        self.jEnable.setForeground(Color(0, 0, 204))
        self.jEnable.setText(self._name)
        self.jEnable.addActionListener(self)

        self.jDocs = JLabel()
        self.jDocs.setFont(Font('Monospaced', Font.PLAIN, 11))
        self.jDocs.setForeground(Color(51, 102, 255))
        self.jDocs.setText(Strings.docs_titel)
        self.jDocs.setToolTipText(Strings.docs_tooltip)
        self.jDocs.addMouseListener(self)

        self.jConsoleText = JTextArea()
        self.jConsoleText.setFont(Font('Monospaced', Font.PLAIN, 10))
        self.jConsoleText.setBackground(Color(244, 246, 247))
        self.jConsoleText.setEditable(0)
        self.jConsoleText.setWrapStyleWord(1)
        self.jConsoleText.setRows(10)
        self.jScrollConsolePane = JScrollPane()
        self.jScrollConsolePane.setViewportView(self.jConsoleText)
        #set initial text
        self.jConsoleText.setText(Strings.console_disable)

        self.jMenuPanelLayout = GroupLayout(self.jMenuPanel)
        self.jMenuPanel.setLayout(self.jMenuPanelLayout)
        self.jMenuPanelLayout.setHorizontalGroup(
            self.jMenuPanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGroup(
                    self.jMenuPanelLayout.createSequentialGroup().addComponent(
                        self.jEnable).addPreferredGap(
                            LayoutStyle.ComponentPlacement.RELATED, 205,
                            32767).addComponent(self.jDocs)))

        self.jMenuPanelLayout.setVerticalGroup(
            self.jMenuPanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGroup(
                    self.jMenuPanelLayout.createSequentialGroup().addGroup(
                        self.jMenuPanelLayout.createParallelGroup(
                            GroupLayout.Alignment.BASELINE).addComponent(
                                self.jEnable).addComponent(self.jDocs)).addGap(
                                    0, 7, 32767)))

        self.jConsolePane = JPanel()
        self.jConsoleLayout = GroupLayout(self.jConsolePane)
        self.jConsolePane.setLayout(self.jConsoleLayout)
        self.jConsoleLayout.setHorizontalGroup(
            self.jConsoleLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addComponent(
                    self.jScrollConsolePane))
        self.jConsoleLayout.setVerticalGroup(
            self.jConsoleLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGroup(
                    GroupLayout.Alignment.TRAILING,
                    self.jConsoleLayout.createSequentialGroup().addComponent(
                        self.jScrollConsolePane, GroupLayout.DEFAULT_SIZE, 154,
                        32767).addContainerGap()))
        self.jLeftUpPanelLayout = GroupLayout(self.jLeftUpPanel)
        self.jLeftUpPanel.setLayout(self.jLeftUpPanelLayout)
        self.jLeftUpPanelLayout.setHorizontalGroup(
            self.jLeftUpPanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addComponent(
                    self.jConsolePane, GroupLayout.DEFAULT_SIZE,
                    GroupLayout.DEFAULT_SIZE,
                    32767).addComponent(self.jMenuPanel,
                                        GroupLayout.DEFAULT_SIZE,
                                        GroupLayout.DEFAULT_SIZE,
                                        GroupLayout.PREFERRED_SIZE))
        self.jLeftUpPanelLayout.setVerticalGroup(
            self.jLeftUpPanelLayout.
            createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
                GroupLayout.Alignment.TRAILING,
                self.jLeftUpPanelLayout.createSequentialGroup().addComponent(
                    self.jMenuPanel, GroupLayout.PREFERRED_SIZE,
                    GroupLayout.DEFAULT_SIZE,
                    GroupLayout.PREFERRED_SIZE).addPreferredGap(
                        LayoutStyle.ComponentPlacement.RELATED).addComponent(
                            self.jConsolePane, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.DEFAULT_SIZE, 32767)))

        self.jScrollpaneLeftDown = JScrollPane()
        self.jScrollpaneLeftDown.setViewportView(self.jVarsPane)

        self.jSplitPaneLeft = JSplitPane(JSplitPane.VERTICAL_SPLIT,
                                         self.jLeftUpPanel,
                                         self.jScrollpaneLeftDown)
        self.jSplitPaneLeft.setDividerLocation(300)

        self.jScriptPane = JTextPane()
        self.jScriptPane.setFont(Font('Monospaced', Font.PLAIN, 11))
        self.jScriptPane.addMouseListener(self)

        self.JScrollPaneRight = JScrollPane()
        self.JScrollPaneRight.setViewportView(self.jScriptPane)

        self.jSplitPane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
                                     self.jSplitPaneLeft,
                                     self.JScrollPaneRight)
        self.jSplitPane.setDividerLocation(400)

        #Load saved saved settings
        ##Load vars
        vars = callbacks.loadExtensionSetting(self._varsStorage)
        if vars:
            vars = base64.b64decode(vars)
        else:
            # try to load the example
            try:
                with open("examples/Simple-CSRF-vars.py") as fvars:
                    vars = fvars.read()
            # load the default text
            except:
                vars = Strings.vars

        ## initiate the persistant variables
        locals_ = {}
        try:
            exec(vars, {}, locals_)
        except Exception as e:
            print e
        self._vars = locals_

        ## update the vars screen
        self.jVarsPane.document.insertString(self.jVarsPane.document.length,
                                             vars, SimpleAttributeSet())

        ##Load script
        script = callbacks.loadExtensionSetting(self._scriptStorage)
        if script:
            script = base64.b64decode(script)
        else:
            # try to load the example
            try:
                with open("examples/Simple-CSRF-script.py") as fscript:
                    script = fscript.read()
            # load the default text
            except:
                script = Strings.script

        ## compile the rules
        self._script = script
        self._code = ''

        try:
            self._code = compile(script, '<string>', 'exec')
        except Exception as e:
            print(
                '{}\nReload extension after you correct the error.'.format(e))

        ## update the rules screen
        self.jScriptPane.document.insertString(
            self.jScriptPane.document.length, script, SimpleAttributeSet())

        #Register Extension
        callbacks.customizeUiComponent(self.getUiComponent())
        callbacks.addSuiteTab(self)
        callbacks.registerExtensionStateListener(self)
        callbacks.registerHttpListener(self)

        self.jScriptPane.requestFocus()
Beispiel #26
0
	def clientUI(self):
		'''ClientUI and Widget creation
		'''
		#  Colours
		foreground_colour = Color(30,57,68)
		background_colour = Color(247,246,242)
		window_background = Color(145,190,210)
		#  Borders
		self.border2=BorderFactory.createLineBorder(foreground_colour,1, True)
		#  Fonts
		self.font= Font("Ubuntu Light",  Font.BOLD, 20)
		self.label_font= Font("Ubuntu Light",  Font.BOLD, 17)
		self.label_2_font= Font( "Ubuntu Light",Font.BOLD, 12)
		self.btn_font=Font("Ubuntu Light", Font.BOLD, 15)
		
		#  Set the layout parameters
		self.client_layout=GroupLayout(self.getContentPane())
		self.getContentPane().setLayout(self.client_layout)	
		self.getContentPane().setBackground(window_background)
		self.client_layout.setAutoCreateGaps(True)
		self.client_layout.setAutoCreateContainerGaps(True)
		self.setPreferredSize(Dimension(400, 450))
		
		#  Create widgets and assemble the GUI
		#  Main display area
		self.main_content=JTextPane()
		self.main_content.setBackground(background_colour)
		#self.main_content.setForeground(foreground_colour)
		self.main_content.setEditable(False)
		#  Message entry area  		
		self.message=JTextArea( 2,2, border=self.border2, font=self.label_font, keyPressed=self.returnKeyPress)
		self.message.requestFocusInWindow()	
		self.message.setBackground(background_colour)
		self.message.setForeground(foreground_colour)
		self.message.setLineWrap(True)
		self.message.setWrapStyleWord(True)
		self.message.setBorder(BorderFactory.createEmptyBorder(3,3,3,3))
		self.message.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), self.returnKeyPress) 
		#  BUttons
		quit_btn=JButton("Quit!", actionPerformed=ChatApp().closeEvent, border=self.border2, font=self.btn_font)
		go_btn=JButton("Send", actionPerformed=self.grabText, border=self.border2, font=self.btn_font)
		quit_btn.setBackground(background_colour)
		go_btn.setBackground(background_colour)
		quit_btn.setForeground(foreground_colour)
		go_btn.setForeground(foreground_colour)
		
		# Make scrollable
		self.scroll_content=JScrollPane(self.main_content)
		self.scroll_content.setPreferredSize(Dimension(150,275))
		self.scroll_content.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)
		self.scroll_content.setViewportView(self.main_content)
		self.scroll_content.setBackground(Color.WHITE)
		self.scroll_message=JScrollPane(self.message)
		self.scroll_message.setPreferredSize(Dimension(150,20))
		self.scroll_message.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS)
		
		# Test user label, still not updating after first round of messages
		self.user_label=JLabel(" Users online : %s "%(str(len(self.no_users))),JLabel.RIGHT, font=self.label_2_font)
		
		#  Assemble the components
		#  Horizontal layout
		self.client_layout.setHorizontalGroup(self.client_layout.createParallelGroup()
				.addComponent(self.scroll_content)
				.addGroup(self.client_layout.createParallelGroup(GroupLayout.Alignment.CENTER)
					.addComponent(self.scroll_message))
				.addGroup(self.client_layout.createSequentialGroup()
					.addComponent(quit_btn)
					.addComponent(go_btn).addGap(20))
				.addGroup(self.client_layout.createParallelGroup()
					.addComponent(self.user_label))
		)
		
		#  Vertical layout
		self.client_layout.setVerticalGroup(self.client_layout.createSequentialGroup()
			.addGroup(self.client_layout.createParallelGroup()
				.addComponent(self.scroll_content))
				.addComponent(self.scroll_message)
				.addGroup(self.client_layout.createParallelGroup()
					.addComponent(quit_btn)
					.addComponent(go_btn))
				.addGroup(self.client_layout.createParallelGroup()
					.addComponent(self.user_label))
		)
		
		#  Finalise the GUI
		self.client_layout.linkSize(SwingConstants.HORIZONTAL, [quit_btn,go_btn, self.user_label])
		self.pack()
		self.message.requestFocusInWindow()
		self.setTitle(">>>   Client %s   <<<"%self.username)
		self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
		self.setLocationRelativeTo(None)
		self.setVisible(True)
		#  Display the server greeting
		self.appendText('\n'+self.greeting+'\n')
Beispiel #27
0
    def __init__(self):
        self.jScrollPane1 = JScrollPane()
        self.jTable1 = JTable()
        self.jPanel1 = JPanel()
        self.labelName = JLabel()
        self.textName = JTextField()
        self.labelSeverity = JLabel()
        self.comboSeverity = None
        self.labelHost = JLabel()
        self.labelPath = JLabel()
        self.textHost = JTextField()
        self.textPath = JTextField()
        self.tabIssue = JTabbedPane()
        self.panelDescription = JPanel()
        self.panelRequest = JPanel()
        self.panelResponse = JPanel()
        self.panelRemediation = JPanel()

        # setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)

        # setting up the table
        # initial data in the table
        tableData = [[None, None, None, None, None],
                     [None, None, None, None, None],
                     [None, None, None, None, None]]
        tableColumns = ["#", "Issue Type/Name", "Severity", "Host", "Path"]
        # create the table model
        tableModel = table.DefaultTableModel(tableData, tableColumns)
        # model.types = array.array([java.lang.Integer.class, java.lang.String.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class], java.lang.Class)
        # model.canEdit = array.array([False, False, False, False, False], java.lang.Boolean)
        # public Class getColumnClass(int columnIndex) {
        # return types [columnIndex]
        # }
        #
        # public boolean isCellEditable(int rowIndex, int columnIndex) {
        # return canEdit [columnIndex]
        # }

        # set the table model
        # if this fails, we have to use
        self.jTable1.setModel(tableModel)
        self.jTable1.setAutoCreateRowSorter(True)

        # wrap the table in a scrollpane
        self.jScrollPane1.setViewportView(self.jTable1)

        # top panel containing the table
        from java.awt import Color
        self.jPanel1.setBorder(BorderFactory.createLineBorder(Color(0, 0, 0)))

        # create the labels and textfields
        self.labelName.text = "Issue Type/Name"
        self.textName.text = "Issue Name/Type"
        self.labelSeverity.text = "Severity"
        # create and populate the combobox
        self.comboSeverity = JComboBox(
            ["Critical", "High", "Medium", "Low", "Info"])

        self.labelHost.text = "Host"
        self.labelPath.text = "Path"
        self.textHost.text = "Issue Host"
        self.textPath.text = "Issue Path"

        from java.lang import Short
        # description panel
        panelDescriptionLayout = GroupLayout(self.panelDescription)
        self.panelDescription.setLayout(panelDescriptionLayout)
        panelDescriptionLayout.setHorizontalGroup(
            panelDescriptionLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE))
        panelDescriptionLayout.setVerticalGroup(
            panelDescriptionLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE))
        self.tabIssue.addTab("Description", self.panelDescription)

        # request tab
        panelRequestLayout = GroupLayout(self.panelRequest)
        self.panelRequest.setLayout(panelRequestLayout)
        panelRequestLayout.setHorizontalGroup(
            panelRequestLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE))
        panelRequestLayout.setVerticalGroup(
            panelRequestLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE))
        self.tabIssue.addTab("Request", self.panelRequest)

        # response tab
        panelResponseLayout = GroupLayout(self.panelResponse)
        self.panelResponse.setLayout(panelResponseLayout)
        panelResponseLayout.setHorizontalGroup(
            panelResponseLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE))
        panelResponseLayout.setVerticalGroup(
            panelResponseLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE))
        self.tabIssue.addTab("Response", self.panelResponse)

        # remediation tab
        panelRemediationLayout = GroupLayout(self.panelRemediation)
        self.panelRemediation.setLayout(panelRemediationLayout)
        panelRemediationLayout.setHorizontalGroup(
            panelRemediationLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE))
        panelRemediationLayout.setVerticalGroup(
            panelRemediationLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE))
        self.tabIssue.addTab("Remediation", self.panelRemediation)

        # jpanel1?
        jPanel1Layout = GroupLayout(self.jPanel1)
        self.jPanel1.setLayout(jPanel1Layout)
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING).
            addGroup(jPanel1Layout.createSequentialGroup().addContainerGap(
            ).addGroup(
                jPanel1Layout.createParallelGroup(
                    GroupLayout.Alignment.LEADING).
                addGroup(jPanel1Layout.createSequentialGroup().addGroup(
                    jPanel1Layout.createParallelGroup(
                        GroupLayout.Alignment.TRAILING).addComponent(
                            self.labelHost).addComponent(
                                self.labelSeverity).addComponent(
                                    self.labelName)
                ).addPreferredGap(
                    LayoutStyle.ComponentPlacement.UNRELATED).addGroup(
                        jPanel1Layout.createParallelGroup(
                            GroupLayout.Alignment.LEADING).
                        addComponent(self.textName).addGroup(
                            jPanel1Layout.createSequentialGroup().addComponent(
                                self.comboSeverity, GroupLayout.PREFERRED_SIZE,
                                98, GroupLayout.PREFERRED_SIZE).addGap(
                                    0, 0, Short.MAX_VALUE)).
                        addGroup(
                            jPanel1Layout.createSequentialGroup().addComponent(
                                self.textHost, GroupLayout.PREFERRED_SIZE, 330,
                                GroupLayout.PREFERRED_SIZE).addGap(18, 18, 18).
                            addComponent(self.labelPath).addPreferredGap(
                                LayoutStyle.ComponentPlacement.RELATED
                            ).addComponent(self.textPath)))).addComponent(
                                self.tabIssue)).addContainerGap()))

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING).
            addGroup(jPanel1Layout.createSequentialGroup().addContainerGap(
            ).addGroup(
                jPanel1Layout.createParallelGroup(
                    GroupLayout.Alignment.BASELINE).addComponent(
                        self.labelName).addComponent(
                            self.textName, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
            ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(
                jPanel1Layout.createParallelGroup(
                    GroupLayout.Alignment.BASELINE).addComponent(
                        self.labelSeverity).addComponent(
                            self.comboSeverity, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
            ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(
                jPanel1Layout.createParallelGroup(
                    GroupLayout.Alignment.BASELINE).addComponent(
                        self.labelHost).addComponent(
                            self.labelPath).addComponent(
                                self.textHost, GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE).addComponent(
                                    self.textPath, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)).
                     addPreferredGap(
                         LayoutStyle.ComponentPlacement.RELATED).addComponent(
                             self.tabIssue).addContainerGap()))

        # create the main panel
        self.panel = JPanel()
        layout = GroupLayout(self.panel)
        self.panel.setLayout(layout)
        layout.setAutoCreateGaps(True)

        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
                layout.createSequentialGroup().addContainerGap().addGroup(
                    layout.createParallelGroup(
                        GroupLayout.Alignment.LEADING).addComponent(
                            self.jPanel1, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.DEFAULT_SIZE,
                            Short.MAX_VALUE).addComponent(
                                self.jScrollPane1)).addContainerGap()))
        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
                layout.createSequentialGroup().addContainerGap().addComponent(
                    self.jScrollPane1, GroupLayout.PREFERRED_SIZE, 119,
                    GroupLayout.PREFERRED_SIZE).addGap(
                        18, 18,
                        18).addComponent(self.jPanel1,
                                         GroupLayout.DEFAULT_SIZE,
                                         GroupLayout.DEFAULT_SIZE,
                                         Short.MAX_VALUE).addContainerGap()))
Beispiel #28
0
	def initUI(self):
		'''Initial UI and Widget creation takes place here!
		'''
		self.setContentPane = JPanel()
		#self.setDefaultLookAndFeelDecorated(True)
		#  Borders
		foreground_colour = Color(30,57,68)
		background_colour = Color(247,246,242)
		window_background = Color(145,190,210)
		self.border = BorderFactory.createLoweredBevelBorder()
		self.border2 = BorderFactory.createLineBorder(foreground_colour, 1, True)
		#  Fonts
		self.entry_font= Font("Ubuntu Light",  Font.BOLD, 20)
		self.label_font= Font("Ubuntu Light",  Font.BOLD, 17)
		self.btn_font=Font("Ubuntu Light", Font.BOLD, 15)
		#  Layout start
		layout=GroupLayout(self.getContentPane())
		self.getContentPane().setLayout(layout)	
		layout.setAutoCreateGaps(True)
		layout.setAutoCreateContainerGaps(True)
		self.setPreferredSize(Dimension(300, 150))
		#  Create the labels
		user_label= JLabel(" Username : "******"  Server  : ", JLabel.LEFT, font=self.label_font)
				
		#  Colours
		user_label.setForeground(foreground_colour)
		server_label.setForeground(foreground_colour)
		
		#  Create the text entries
		self.username=JTextField(actionPerformed=self.continueEvent, border=self.border2,  font = self.entry_font)
		self.server=JTextField(actionPerformed=self.continueEvent, border=self.border2,  font = self.entry_font)
		
		#  Colours
		self.username.setBackground(background_colour)
		self.server.setBackground(background_colour)
		self.username.setForeground(foreground_colour)
		self.server.setForeground(foreground_colour)
		
		#  Allow editable
		self.username.setEditable(True)
		self.server.setEditable(True)
		
		#  Create the buttons
		quit_btn=JButton("  Quit!  ", actionPerformed=self.closeEvent, border=self.border2, font=self.btn_font)
		go_btn=JButton("   Go!   ", actionPerformed=self.continueEvent, border=self.border2, font=self.btn_font)
		#  Colours
		quit_btn.setBackground(background_colour)
		go_btn.setBackground(background_colour)
		quit_btn.setForeground(foreground_colour)
		go_btn.setForeground(foreground_colour)
		
		#  Setting up the horizontal groups parameters
		layout.setHorizontalGroup(layout.createSequentialGroup()
		
			#  Left side
			.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
				.addComponent(user_label)
				.addComponent(server_label))
				
			#  Right side
			.addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER)
				.addComponent(self.username)
				.addComponent(self.server)
				.addGroup(layout.createSequentialGroup()
					.addComponent(quit_btn)
					.addComponent(go_btn)))
		)
		
		#  Setting up Vertical Groups
		layout.setVerticalGroup(layout.createSequentialGroup()
			#  Top group
			.addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER)
				.addComponent(user_label)
				.addComponent(self.username))
			#  Middle group
			.addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER)
				.addComponent(server_label)
				.addComponent(self.server))
			#  Bottom group
			.addGroup(layout.createParallelGroup()
				.addComponent(quit_btn)
				.addComponent(go_btn))
		)
		
		#  Finalise the GUI	
		layout.linkSize(SwingConstants.HORIZONTAL, [quit_btn,go_btn])
		self.getContentPane().setBackground(window_background)
		self.pack()
		self.setTitle('Chat Login')
		self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
		self.setLocationRelativeTo(None)
		self.setVisible(True)
Beispiel #29
0
    def __initLayout__(self):
        self._levelComboBox = JComboBox()
        levelComboBoxSize = Dimension(300, 30)
        self._levelComboBox.setPreferredSize(levelComboBoxSize)
        self._levelComboBox.setMaximumSize(levelComboBoxSize)
        for level in range(0, 6):
            self._levelComboBox.addItem(str(level))

        self._techRenderedCheckBox = JCheckBox('Rendered', True)
        self._techTimebasedCheckBox = JCheckBox('Time-based', True)

        self._plugin_groups = {}
        for plugin in plugins:
            parent = plugin.__base__.__name__
            if not self._plugin_groups.has_key(parent):
                self._plugin_groups[parent] = []
            self._plugin_groups[parent].append(plugin)
        self._pluginCheckBoxes = []
        for pluginGroup in self._plugin_groups.values():
            for plugin in pluginGroup:
                self._pluginCheckBoxes.append(PluginCheckBox(plugin))

        self._positionReplaceCheckBox = JCheckBox('Replace', True)
        self._positionAppendCheckBox = JCheckBox('Append', False)

        displayItems = ({
            'label':
            'Level',
            'components': (self._levelComboBox, ),
            'description':
            'Level of code context escape to perform (1-5, Default:0).'
        }, {
            'label':
            'Techniques',
            'components': (
                self._techRenderedCheckBox,
                self._techTimebasedCheckBox,
            ),
            'description':
            'Techniques R(endered) T(ime-based blind). Default: RT.'
        }, {
            'label':
            'Template Engines',
            'components':
            self._pluginCheckBoxes,
            'description':
            'Force back-end template engine to this value(s).'
        }, {
            'label':
            'Payload position',
            'components': (
                self._positionReplaceCheckBox,
                self._positionAppendCheckBox,
            ),
            'description':
            'Scan payload position. This feature only appears in BurpExtension.'
        })

        layout = GroupLayout(self)
        self.setLayout(layout)
        layout.setAutoCreateGaps(True)
        layout.setAutoCreateContainerGaps(True)

        labelWidth = 200
        hgroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        vgroup = layout.createSequentialGroup()
        for displayItem in displayItems:
            label = JLabel(displayItem.get('label'))
            label.setToolTipText(displayItem.get('description'))
            _hgroup = layout.createSequentialGroup().addComponent(
                label, labelWidth, labelWidth, labelWidth)
            _vgroup = layout.createParallelGroup(
                GroupLayout.Alignment.BASELINE).addComponent(label)
            for component in displayItem.get('components'):
                _hgroup.addComponent(component)
                _vgroup.addComponent(component)
            hgroup.addGroup(_hgroup)
            vgroup.addGroup(_vgroup)

        layout.setHorizontalGroup(hgroup)
        layout.setVerticalGroup(vgroup)
    def registerExtenderCallbacks(self, this_callbacks):
        global callbacks, helpers, checkbox_perHost, checkbox_common, checkbox_ssh, checkbox_key, checkbox_php, checkbox_sql
        callbacks = this_callbacks

        ui_label = JLabel('Scans to perform:')
        checkbox_perHost = self.defineCheckBox(
            'Scan once per domain (web root only, not every subdirectory)')
        checkbox_common = self.defineCheckBox('Interesting files')
        checkbox_ssh = self.defineCheckBox('SSH private keys')
        checkbox_key = self.defineCheckBox('.key files')
        checkbox_php = self.defineCheckBox('PHP file scans')
        checkbox_sql = self.defineCheckBox('SQL file scans')

        self.tab = JPanel()
        layout = GroupLayout(self.tab)
        self.tab.setLayout(layout)
        layout.setAutoCreateGaps(True)
        layout.setAutoCreateContainerGaps(True)

        layout.setHorizontalGroup(
            layout.createSequentialGroup().addComponent(ui_label).addGroup(
                layout.createParallelGroup(
                    GroupLayout.Alignment.LEADING).addComponent(
                        checkbox_common).addComponent(checkbox_ssh).
                addComponent(checkbox_key).addComponent(checkbox_php).
                addComponent(checkbox_sql)).addComponent(checkbox_perHost))
        layout.setVerticalGroup(layout.createSequentialGroup().addGroup(
            layout.createParallelGroup(
                GroupLayout.Alignment.BASELINE).addComponent(ui_label).
            addComponent(checkbox_common).addComponent(checkbox_perHost)
        ).addComponent(checkbox_ssh).addComponent(checkbox_key).addComponent(
            checkbox_php).addComponent(checkbox_sql))

        helpers = callbacks.getHelpers()

        callbacks.setExtensionName("Interesting Files Scanner")
        callbacks.registerScannerCheck(FileScanner())
        callbacks.addSuiteTab(self)

        print 'Interesting Files Scanner'
        print 'Created by Sven Fassbender (@mezdanak, @modzero) v' + VERSION
        print 'https://github.com/modzero/interestingFileScanner'

        return
Beispiel #31
0
    def initUI(self):

        layout = GroupLayout(self.pane)
        self.pane.setLayout(layout)
        layout.setAutoCreateGaps(True)
        layout.setAutoCreateContainerGaps(True)

        bc = settings.getBool("boot.use", False)
        self.useBs = JCheckBox("Use bootstrap", bc)
        binLabel = JLabel("Bootstrap file: ")
        self.binTxt = JTextField()
        self.binTxt.text = settings.getString("boot.path", "")
        self.binBtn = JButton("Load", actionPerformed=mplab_chooseBootstrap)

        entryLabel = JLabel("Bootstrap entry address (if bin): ")
        self.entryTxt = JTextField()
        self.entryTxt.text = settings.getString("boot.entry_adr", "")

        prjLabel = JLabel("Bootstrap project: ")
        self.prjTxt = JTextField()
        self.prjTxt.text = settings.getString("boot.prj", "")

        loadLabel = JLabel("Bootstrap load address (if bin): ")

        self.loadTxt = JTextField()
        self.loadTxt.text = settings.getString("boot.load_adr", "")

        layout.setHorizontalGroup(layout.createSequentialGroup().addGroup(
            layout.createParallelGroup().addComponent(
                self.useBs).addComponent(prjLabel).addComponent(binLabel).
            addComponent(entryLabel).addComponent(loadLabel)).addGroup(
                layout.createParallelGroup()
                #                .addComponent(self.useBs)
                .addComponent(self.prjTxt).addComponent(
                    self.binTxt).addComponent(self.entryTxt).addComponent(
                        self.loadTxt)).addGroup(
                            layout.createParallelGroup().addComponent(
                                self.binBtn)))

        layout.setVerticalGroup(layout.createSequentialGroup().addGroup(
            layout.createParallelGroup().addComponent(self.useBs)
        ).addGroup(
            layout.createParallelGroup().addComponent(prjLabel).addComponent(
                self.prjTxt, GroupLayout.PREFERRED_SIZE,
                GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        ).addGroup(
            layout.createParallelGroup().addComponent(binLabel).addComponent(
                self.binTxt, GroupLayout.PREFERRED_SIZE,
                GroupLayout.DEFAULT_SIZE,
                GroupLayout.PREFERRED_SIZE).addComponent(self.binBtn)
        ).addGroup(
            layout.createParallelGroup().addComponent(entryLabel).addComponent(
                self.entryTxt, GroupLayout.PREFERRED_SIZE,
                GroupLayout.DEFAULT_SIZE,
                GroupLayout.PREFERRED_SIZE)).addGroup(
                    layout.createParallelGroup().addComponent(
                        loadLabel).addComponent(self.loadTxt,
                                                GroupLayout.PREFERRED_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.PREFERRED_SIZE)))
        self.panel.add(self.pane, BorderLayout.CENTER)
Beispiel #32
0
    def drawPluginUI(self):
        # Create the plugin user interface
        self.pluginTab = JPanel()
        self.uiTitle = JLabel('UPnP BHunter Load, Aim and Fire Console')
        self.uiTitle.setFont(Font('Tahoma', Font.BOLD, 14))
        self.uiTitle.setForeground(Color(250, 100, 0))
        self.uiPanelA = JSplitPane(JSplitPane.VERTICAL_SPLIT)
        self.uiPanelA.setMaximumSize(Dimension(2500, 1000))
        self.uiPanelA.setDividerSize(2)
        self.uiPanelB = JSplitPane(JSplitPane.VERTICAL_SPLIT)
        self.uiPanelB.setDividerSize(2)
        self.uiPanelA.setBottomComponent(self.uiPanelB)
        self.uiPanelA.setBorder(BorderFactory.createLineBorder(Color.gray))

        # Create and configure labels and text fields
        self.labeltitle_step1 = JLabel("[1st STEP] Discover UPnP Locations")
        self.labeltitle_step1.setFont(Font('Tahoma', Font.BOLD, 14))
        self.labeltitle_step2 = JLabel("[2nd STEP] Select an UPnP Service")
        self.labeltitle_step2.setFont(Font('Tahoma', Font.BOLD, 14))
        self.labeltitle_step3 = JLabel("[3rd STEP] Time to Attack it")
        self.labeltitle_step3.setFont(Font('Tahoma', Font.BOLD, 14))
        self.labelsubtitle_step1 = JLabel(
            "Specify the IP version address in scope and start UPnP discovery")
        self.labelsubtitle_step2 = JLabel(
            "Select which of the found UPnP services will be probed")
        self.labelsubtitle_step3 = JLabel(
            "Select how to test the extracted UPnP SOAP requests having input arguments"
        )
        self.label_step1 = JLabel("Target IP")
        self.label_step2 = JLabel("Found UPnp Services")
        self.label_step3 = JLabel("Send all the extracted SOAP requests     ")
        self.labelstatus = JLabel("             Status")
        self.labelempty_step1 = JLabel("                ")
        self.labelempty_step2 = JLabel("  ")
        self.labelupnp = JLabel("UPnP list")
        self.labelip = JLabel("IP list")
        self.labelLANHOST = JLabel(
            "Send the interesting LANHostConfigManagement SOAP requests     ")
        self.labelWANCONNECTION = JLabel(
            "Send the interesting WANIP/PPPConnection SOAP requests     ")
        self.labelSOAPnum = JLabel("0")
        self.labelLANHOSTnum = JLabel("0")
        self.labelWANCONNECTIONnum = JLabel("0")
        self.labelNoneServiceFound = JLabel("  ")
        self.labelNoneServiceFound.setFont(Font('Tahoma', Font.BOLD, 12))
        self.labelNoneServiceFound.setForeground(Color.red)

        # Create combobox for IP version selection
        self.ip_versions = ["IPv4", "IPv6"]
        self.combo_ipversion = JComboBox(self.ip_versions)
        self.combo_ipversion.setSelectedIndex(0)
        self.combo_ipversion.setEnabled(True)

        # Create and configure progress bar
        self.progressbar = JProgressBar(0, 100)
        self.progressbar.setString("Ready")
        self.progressbar.setStringPainted(True)

        # Create and configure buttons
        self.startbutton = JButton("Start Discovery",
                                   actionPerformed=self.startHunting)
        self.clearbutton = JButton("Clear All", actionPerformed=self.clearAll)
        self.confirmbutton = JButton("Confirm Selection",
                                     actionPerformed=self.selectUPnPService)
        self.intruderbutton = JButton("to Intruder",
                                      actionPerformed=self.sendUPnPToIntruder)
        self.LANrepeaterbutton = JButton(
            "to Repeater", actionPerformed=self.sendLANUPnPToRepeater)
        self.WANrepeaterbutton = JButton(
            "to Repeater", actionPerformed=self.sendWANUPnPToRepeater)
        self.confirmbutton.setEnabled(False)
        self.intruderbutton.setEnabled(False)
        self.LANrepeaterbutton.setEnabled(False)
        self.WANrepeaterbutton.setEnabled(False)

        # Create the combo box, select item at index 0 (first item in list)
        self.upnpservices = ["       "]
        self.upnpcombo_services = JComboBox(self.upnpservices)
        self.upnpcombo_services.setSelectedIndex(0)
        self.upnpcombo_services.setEnabled(False)

        # Class neeeded to handle the combobox in second step panel
        class ComboboxListener(ActionListener):
            def __init__(self, upnpcombo_targets, upnpcombo_services,
                         scope_dict):
                self.upnpcombo_targets = upnpcombo_targets
                self.upnpcombo_services = upnpcombo_services
                self.scope_dict = scope_dict

            def actionPerformed(self, event):
                # Update the location url combobox depending on the IP combobox
                selected_target = self.upnpcombo_targets.getSelectedItem()
                if self.scope_dict and selected_target:
                    self.upnpcombo_services.removeAllItems()
                    for scope_url in self.scope_dict[selected_target]:
                        self.upnpcombo_services.addItem(scope_url)
                    self.upnpcombo_services.setSelectedIndex(0)

        # Create the combo box, select item at index 0 (first item in list)
        self.upnptargets = ["       "]
        self.upnpcombo_targets = JComboBox(self.upnptargets)
        self.upnpcombo_targets.setSelectedIndex(0)
        self.upnpcombo_targets.setEnabled(False)
        self.upnpcombo_targets.addActionListener(
            ComboboxListener(self.upnpcombo_targets, self.upnpcombo_services,
                             self.scope_dict))

        # Configuring first step panel
        self.panel_step1 = JPanel()
        self.panel_step1.setPreferredSize(Dimension(2250, 100))
        self.panel_step1.setBorder(EmptyBorder(10, 10, 10, 10))
        self.panel_step1.setLayout(BorderLayout(15, 15))
        self.titlepanel_step1 = JPanel()
        self.titlepanel_step1.setLayout(BorderLayout())
        self.titlepanel_step1.add(self.labeltitle_step1, BorderLayout.NORTH)
        self.titlepanel_step1.add(self.labelsubtitle_step1)
        self.targetpanel_step1 = JPanel()
        self.targetpanel_step1.add(self.label_step1)
        self.targetpanel_step1.add(self.combo_ipversion)
        self.targetpanel_step1.add(self.startbutton)
        self.targetpanel_step1.add(self.clearbutton)
        self.targetpanel_step1.add(self.labelstatus)
        self.targetpanel_step1.add(self.progressbar)
        self.emptypanel_step1 = JPanel()
        self.emptypanel_step1.setLayout(BorderLayout())
        self.emptypanel_step1.add(self.labelempty_step1, BorderLayout.WEST)

        # Assembling first step panel components
        self.panel_step1.add(self.titlepanel_step1, BorderLayout.NORTH)
        self.panel_step1.add(self.targetpanel_step1, BorderLayout.WEST)
        self.panel_step1.add(self.emptypanel_step1, BorderLayout.SOUTH)
        self.uiPanelA.setTopComponent(self.panel_step1)

        # Configure second step panel
        self.panel_step2 = JPanel()
        self.panel_step2.setPreferredSize(Dimension(2250, 100))
        self.panel_step2.setBorder(EmptyBorder(10, 10, 10, 10))
        self.panel_step2.setLayout(BorderLayout(15, 15))
        self.titlepanel_step2 = JPanel()
        self.titlepanel_step2.setLayout(BorderLayout())
        self.titlepanel_step2.add(self.labeltitle_step2, BorderLayout.NORTH)
        self.titlepanel_step2.add(self.labelsubtitle_step2)
        self.selectpanel_step2 = JPanel()
        self.selectpanel_step2.add(self.labelip)
        self.selectpanel_step2.add(self.upnpcombo_targets)
        self.selectpanel_step2.add(self.labelupnp)
        self.selectpanel_step2.add(self.upnpcombo_services)
        self.selectpanel_step2.add(self.confirmbutton)
        self.emptypanel_step2 = JPanel()
        self.emptypanel_step2.setLayout(BorderLayout())
        self.emptypanel_step2.add(self.labelempty_step2, BorderLayout.WEST)
        self.emptypanel_step2.add(self.labelNoneServiceFound)

        # Assembling second step panel components
        self.panel_step2.add(self.titlepanel_step2, BorderLayout.NORTH)
        self.panel_step2.add(self.selectpanel_step2, BorderLayout.WEST)
        self.panel_step2.add(self.emptypanel_step2, BorderLayout.SOUTH)
        self.uiPanelB.setTopComponent(self.panel_step2)

        # Configuring third step panel
        self.panel_step3 = JPanel()
        self.panel_step3.setPreferredSize(Dimension(2250, 100))
        self.panel_step3.setBorder(EmptyBorder(10, 10, 10, 10))
        self.panel_step3.setLayout(BorderLayout(15, 15))
        self.titlepanel_step3 = JPanel()
        self.titlepanel_step3.setLayout(BorderLayout())
        self.titlepanel_step3.add(self.labeltitle_step3, BorderLayout.NORTH)
        self.titlepanel_step3.add(self.labelsubtitle_step3)
        self.underpanel_step3 = JPanel()

        underlayout = GroupLayout(self.underpanel_step3)
        self.underpanel_step3.setLayout(underlayout)
        underlayout.setAutoCreateGaps(True)
        underlayout.setAutoCreateContainerGaps(True)
        left2right = underlayout.createSequentialGroup()
        firstcolumn = underlayout.createParallelGroup()
        firstcolumn.addComponent(self.label_step3, GroupLayout.PREFERRED_SIZE,
                                 GroupLayout.PREFERRED_SIZE,
                                 GroupLayout.PREFERRED_SIZE)
        firstcolumn.addComponent(self.labelLANHOST, GroupLayout.PREFERRED_SIZE,
                                 GroupLayout.PREFERRED_SIZE,
                                 GroupLayout.PREFERRED_SIZE)
        firstcolumn.addComponent(self.labelWANCONNECTION,
                                 GroupLayout.PREFERRED_SIZE,
                                 GroupLayout.PREFERRED_SIZE,
                                 GroupLayout.PREFERRED_SIZE)
        secondcolumn = underlayout.createParallelGroup()
        secondcolumn.addComponent(self.labelSOAPnum)
        secondcolumn.addComponent(self.labelLANHOSTnum)
        secondcolumn.addComponent(self.labelWANCONNECTIONnum)
        thirdcolumn = underlayout.createParallelGroup()
        thirdcolumn.addComponent(self.intruderbutton)
        thirdcolumn.addComponent(self.LANrepeaterbutton)
        thirdcolumn.addComponent(self.WANrepeaterbutton)
        left2right.addGroup(firstcolumn)
        left2right.addGroup(secondcolumn)
        left2right.addGroup(thirdcolumn)
        top2bottom = underlayout.createSequentialGroup()
        firstrow = underlayout.createParallelGroup()
        firstrow.addComponent(self.label_step3, GroupLayout.PREFERRED_SIZE,
                              GroupLayout.PREFERRED_SIZE,
                              GroupLayout.PREFERRED_SIZE)
        firstrow.addComponent(self.labelSOAPnum)
        firstrow.addComponent(self.intruderbutton)
        secondrow = underlayout.createParallelGroup()
        secondrow.addComponent(self.labelLANHOST, GroupLayout.PREFERRED_SIZE,
                               GroupLayout.PREFERRED_SIZE,
                               GroupLayout.PREFERRED_SIZE)
        secondrow.addComponent(self.labelLANHOSTnum)
        secondrow.addComponent(self.LANrepeaterbutton)
        thirdrow = underlayout.createParallelGroup()
        thirdrow.addComponent(self.labelWANCONNECTION,
                              GroupLayout.PREFERRED_SIZE,
                              GroupLayout.PREFERRED_SIZE,
                              GroupLayout.PREFERRED_SIZE)
        thirdrow.addComponent(self.labelWANCONNECTIONnum)
        thirdrow.addComponent(self.WANrepeaterbutton)
        top2bottom.addGroup(firstrow)
        top2bottom.addGroup(secondrow)
        top2bottom.addGroup(thirdrow)
        underlayout.setHorizontalGroup(left2right)
        underlayout.setVerticalGroup(top2bottom)

        # Assembling thirdd step panel components
        self.panel_step3.add(self.titlepanel_step3, BorderLayout.NORTH)
        self.panel_step3.add(self.underpanel_step3, BorderLayout.WEST)
        self.uiPanelB.setBottomComponent(self.panel_step3)

        # Assembling the group of all panels
        layout = GroupLayout(self.pluginTab)
        self.pluginTab.setLayout(layout)
        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
                layout.createSequentialGroup().addGap(10, 10, 10).addGroup(
                    layout.createParallelGroup(
                        GroupLayout.Alignment.LEADING).addComponent(
                            self.uiTitle).addGap(15, 15, 15).addComponent(
                                self.uiPanelA)).addContainerGap(
                                    26, Short.MAX_VALUE)))
        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
                layout.createSequentialGroup().addGap(15, 15, 15).addComponent(
                    self.uiTitle).addGap(15, 15, 15).addComponent(
                        self.uiPanelA).addGap(20, 20, 20).addGap(20, 20, 20)))
Beispiel #33
0
    def	registerExtenderCallbacks(self, callbacks):
        print "PhantomJS RIA Crawler extension"
        print "Nikolay Matyunin @autorak <*****@*****.**>"

        # keep a reference to our callbacks object and helpers object
        self._callbacks = callbacks
        self._helpers = callbacks.getHelpers()

        # extension name
        callbacks.setExtensionName("Phantom RIA Crawler")

        # Create Tab UI components
        self._jPanel = JPanel()
        self._jPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));

        _titleLabel = JLabel("Phantom RIA Crawler", SwingConstants.LEFT)
        _titleLabelFont = _titleLabel.font
        _titleLabelFont = _titleLabelFont.deriveFont(Font.BOLD, 12);
        _titleLabel.setFont(_titleLabelFont);
        _titleLabel.setForeground(Color(230, 142, 11))

        self._addressTextField = JTextField('')
        self._addressTextField.setColumns(50)
        _addressTextLabel = JLabel("Target URL:", SwingConstants.RIGHT)
        self._addressTextField.getDocument().addDocumentListener(self)

        self._phantomJsPathField = JTextField('phantomjs') # TODO: set permanent config value
        self._phantomJsPathField.setColumns(50)
        _phantomJsPathLabel = JLabel("PhantomJS path:", SwingConstants.RIGHT)

        self._startButton = JToggleButton('Start', actionPerformed=self.startToggled)
        self._startButton.setEnabled(False)

        _requestsMadeLabel = JLabel("DEPs found:", SwingConstants.RIGHT)
        self._requestsMadeInfo = JLabel("", SwingConstants.LEFT)
        _statesFoundLabel = JLabel("States found:", SwingConstants.RIGHT)
        self._statesFoundInfo = JLabel("", SwingConstants.LEFT)

        _separator = JSeparator(SwingConstants.HORIZONTAL)

        _configLabel = JLabel("Crawling configuration:")
        self._configButton = JButton("Load config", actionPerformed=self.loadConfigClicked)
        self._configFile = ""

        _listenersLabel= JLabel("Burp proxy listener:", SwingConstants.RIGHT)
        self._listenersCombo = JComboBox()
        self._configTimer = Timer(5000, None)
        self._configTimer.actionPerformed = self._configUpdated
        self._configTimer.stop()
        self._configUpdated(None)

        self._commandClient = CommandClient(self)

        # Layout management
        self._groupLayout = GroupLayout(self._jPanel)
        self._jPanel.setLayout(self._groupLayout)
        self._groupLayout.setAutoCreateGaps(True)
        self._groupLayout.setAutoCreateContainerGaps(True)

        self._groupLayout.setHorizontalGroup(self._groupLayout.createParallelGroup()
            .addComponent(_titleLabel)
            .addGroup(self._groupLayout.createSequentialGroup()
                .addComponent(_addressTextLabel)
                .addGroup(self._groupLayout.createParallelGroup()
                    .addComponent(self._addressTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addGroup(self._groupLayout.createSequentialGroup()
                        .addComponent(_requestsMadeLabel)
                        .addComponent(self._requestsMadeInfo))
                    .addGroup(self._groupLayout.createSequentialGroup()
                        .addComponent(_statesFoundLabel)
                        .addComponent(self._statesFoundInfo)))
                .addComponent(self._startButton))
            .addComponent(_separator)
            .addGroup(self._groupLayout.createSequentialGroup()
                .addComponent(_configLabel)
                .addComponent(self._configButton))
            .addGroup(self._groupLayout.createSequentialGroup()
                .addComponent(_phantomJsPathLabel)
                .addComponent(self._phantomJsPathField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
            .addGroup(self._groupLayout.createSequentialGroup()
                .addComponent(_listenersLabel)
                .addComponent(self._listenersCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
        )

        self._groupLayout.setVerticalGroup(self._groupLayout.createSequentialGroup()
            .addComponent(_titleLabel)
            .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(_addressTextLabel)
                .addComponent(self._addressTextField)
                .addComponent(self._startButton))
            .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(_requestsMadeLabel)
                .addComponent(self._requestsMadeInfo))
            .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(_statesFoundLabel)
                .addComponent(self._statesFoundInfo))
            .addComponent(_separator, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
            .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(_configLabel)
                .addComponent(self._configButton))
            .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(_phantomJsPathLabel)
                .addComponent(self._phantomJsPathField))
            .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(_listenersLabel)
                .addComponent(self._listenersCombo))
        )

        self._groupLayout.linkSize(SwingConstants.HORIZONTAL, _configLabel, _phantomJsPathLabel);
        self._groupLayout.linkSize(SwingConstants.HORIZONTAL, _configLabel, _listenersLabel);
        self._groupLayout.linkSize(SwingConstants.HORIZONTAL, _statesFoundLabel, _requestsMadeLabel);


        # context menu data
        self._contextMenuData = None;
        self._running = False;

        # register callbacks
        callbacks.customizeUiComponent(self._jPanel)
        callbacks.registerContextMenuFactory(self)
        callbacks.addSuiteTab(self)

        return
Beispiel #34
0
 def __init__(self, ext):
     self._panel = JPanel()
     layout = GroupLayout(self._panel)
     innerPanel = JPanel()
     innerPanelLayout = GroupLayout(innerPanel)
     self._panel.setLayout(layout)
     innerPanel.setLayout(innerPanelLayout)
     self.labelDojoURL = JLabel("DefectDojo :")
     self.defectDojoURL = JTextField("")
     self.searchConnectButton = JButton('Connect',
                                        actionPerformed=ext.getProducts)
     self.labelApiKey = JLabel("API Key :")
     self.apiKey = JTextField("")
     self.labelUsername = JLabel("Username :"******"admin")
     self.labelProductID = JLabel("Product :")
     self.productID = JTextField(focusLost=ext.getEngagements)
     self.labelProductName = JLabel("Product Name :")
     self.productName = JComboBox()
     self.prodMan = ProdListener(ext)
     self.prodMouse = ProdMouseListener(ext)
     self.productName.addMouseListener(self.prodMouse)
     self.productName.addActionListener(self.prodMan)
     self.labelEngagementID = JLabel("Engagement (In Progress) :")
     self.engagementID = JTextField(focusLost=ext.getTests)
     self.engagementName = JComboBox()
     self.engMan = EngListener(ext)
     self.engagementName.addActionListener(self.engMan)
     self.labelTestID = JLabel("Test :")
     self.testID = JTextField()
     self.testName = JComboBox()
     self.testMan = TestListener(ext)
     self.testName.addActionListener(self.testMan)
     self.search = JTextField()
     self.searchProductButton = JButton('Product Search',
                                        actionPerformed=ext.getProducts)
     innerPanelLayout.setHorizontalGroup(
         innerPanelLayout.createParallelGroup().addGroup(
             GroupLayout.Alignment.TRAILING,
             innerPanelLayout.createSequentialGroup().addContainerGap().
             addGroup(
                 innerPanelLayout.createParallelGroup(
                     GroupLayout.Alignment.TRAILING).
                 addGroup(innerPanelLayout.createParallelGroup().addGroup(
                     innerPanelLayout.createParallelGroup(
                         GroupLayout.Alignment.TRAILING).addGroup(
                             innerPanelLayout.createParallelGroup(
                                 GroupLayout.Alignment.TRAILING).addGroup(
                                     innerPanelLayout.createSequentialGroup(
                                     ).addComponent(
                                         self.labelUsername,
                                         GroupLayout.PREFERRED_SIZE, 168,
                                         GroupLayout.PREFERRED_SIZE).addGap(
                                             105, 105, 105)).
                             addComponent(self.labelProductName,
                                          GroupLayout.Alignment.LEADING,
                                          GroupLayout.PREFERRED_SIZE, 168,
                                          GroupLayout.PREFERRED_SIZE)).
                     addGroup(
                         GroupLayout.Alignment.LEADING,
                         innerPanelLayout.createSequentialGroup().addGroup(
                             innerPanelLayout.createParallelGroup(
                                 GroupLayout.Alignment.TRAILING).
                             addComponent(
                                 self.labelEngagementID,
                                 GroupLayout.Alignment.LEADING,
                                 GroupLayout.PREFERRED_SIZE, 168,
                                 GroupLayout.PREFERRED_SIZE).addComponent(
                                     self.labelDojoURL,
                                     GroupLayout.Alignment.LEADING,
                                     GroupLayout.PREFERRED_SIZE, 168,
                                     GroupLayout.PREFERRED_SIZE)).
                         addPreferredGap(
                             LayoutStyle.ComponentPlacement.RELATED))
                 ).addGroup(innerPanelLayout.createSequentialGroup(
                 ).addGroup(
                     innerPanelLayout.createParallelGroup().addComponent(
                         self.labelTestID, GroupLayout.PREFERRED_SIZE, 168,
                         GroupLayout.PREFERRED_SIZE).addComponent(
                             self.searchProductButton,
                             GroupLayout.PREFERRED_SIZE, 160,
                             GroupLayout.PREFERRED_SIZE)).addPreferredGap(
                                 LayoutStyle.ComponentPlacement.RELATED))).
                 addGroup(
                     GroupLayout.Alignment.LEADING,
                     innerPanelLayout.createSequentialGroup().addComponent(
                         self.labelApiKey, GroupLayout.PREFERRED_SIZE, 168,
                         GroupLayout.PREFERRED_SIZE).addPreferredGap(
                             LayoutStyle.ComponentPlacement.RELATED))).
             addGroup(innerPanelLayout.createParallelGroup().addGroup(
                 innerPanelLayout.createSequentialGroup().addComponent(
                     self.engagementID, GroupLayout.PREFERRED_SIZE, 36,
                     GroupLayout.PREFERRED_SIZE).addGap(
                         18, 18,
                         18).addComponent(self.engagementName,
                                          GroupLayout.PREFERRED_SIZE, 260,
                                          GroupLayout.PREFERRED_SIZE)
             ).addGroup(innerPanelLayout.createSequentialGroup().addGap(
                 54, 54, 54).addGroup(
                     innerPanelLayout.createParallelGroup().addComponent(
                         self.defectDojoURL, GroupLayout.PREFERRED_SIZE,
                         260, GroupLayout.PREFERRED_SIZE).addComponent(
                             self.apiKey, GroupLayout.PREFERRED_SIZE, 260,
                             GroupLayout.PREFERRED_SIZE).addComponent(
                                 self.user, GroupLayout.PREFERRED_SIZE, 260,
                                 GroupLayout.PREFERRED_SIZE).addComponent(
                                     self.productName,
                                     GroupLayout.PREFERRED_SIZE, 260,
                                     GroupLayout.PREFERRED_SIZE)
                 )).addGroup(
                     innerPanelLayout.createSequentialGroup().addComponent(
                         self.testID, GroupLayout.PREFERRED_SIZE, 36,
                         GroupLayout.PREFERRED_SIZE).addGap(18, 18, 18).
                     addGroup(innerPanelLayout.createParallelGroup(
                     ).addComponent(
                         self.search, GroupLayout.PREFERRED_SIZE, 260,
                         GroupLayout.PREFERRED_SIZE).addComponent(
                             self.testName, GroupLayout.PREFERRED_SIZE, 260,
                             GroupLayout.PREFERRED_SIZE)))).addGap(
                                 348, 348, 348)))
     innerPanelLayout.setVerticalGroup(innerPanelLayout.createParallelGroup(
     ).addGroup(innerPanelLayout.createSequentialGroup().addContainerGap(
     ).addGroup(
         innerPanelLayout.createParallelGroup(
             GroupLayout.Alignment.LEADING,
             False).addComponent(self.defectDojoURL).addComponent(
                 self.labelDojoURL, GroupLayout.DEFAULT_SIZE,
                 GroupLayout.DEFAULT_SIZE, sys.maxint)
     ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(
         innerPanelLayout.createParallelGroup(
             GroupLayout.Alignment.BASELINE).addComponent(
                 self.apiKey, GroupLayout.PREFERRED_SIZE,
                 GroupLayout.DEFAULT_SIZE,
                 GroupLayout.PREFERRED_SIZE).addComponent(
                     self.labelApiKey, GroupLayout.PREFERRED_SIZE, 19,
                     GroupLayout.PREFERRED_SIZE)
     ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(
         innerPanelLayout.createParallelGroup(
             GroupLayout.Alignment.BASELINE).addComponent(
                 self.user, GroupLayout.PREFERRED_SIZE,
                 GroupLayout.DEFAULT_SIZE,
                 GroupLayout.PREFERRED_SIZE).addComponent(
                     self.labelUsername, GroupLayout.PREFERRED_SIZE, 19,
                     GroupLayout.PREFERRED_SIZE)
     ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(
         innerPanelLayout.createParallelGroup(
             GroupLayout.Alignment.BASELINE).addComponent(
                 self.productName, GroupLayout.PREFERRED_SIZE,
                 GroupLayout.DEFAULT_SIZE,
                 GroupLayout.PREFERRED_SIZE).addComponent(
                     self.labelProductName, GroupLayout.PREFERRED_SIZE, 19,
                     GroupLayout.PREFERRED_SIZE)
     ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(
         innerPanelLayout.createParallelGroup(
             GroupLayout.Alignment.BASELINE).addComponent(
                 self.engagementName, GroupLayout.PREFERRED_SIZE,
                 GroupLayout.DEFAULT_SIZE,
                 GroupLayout.PREFERRED_SIZE).addComponent(
                     self.engagementID, GroupLayout.PREFERRED_SIZE,
                     GroupLayout.DEFAULT_SIZE,
                     GroupLayout.PREFERRED_SIZE).addComponent(
                         self.labelEngagementID, GroupLayout.PREFERRED_SIZE,
                         19, GroupLayout.PREFERRED_SIZE)
     ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(
         innerPanelLayout.createParallelGroup(
             GroupLayout.Alignment.BASELINE).addComponent(
                 self.testName, GroupLayout.PREFERRED_SIZE,
                 GroupLayout.DEFAULT_SIZE,
                 GroupLayout.PREFERRED_SIZE).addComponent(
                     self.testID, GroupLayout.PREFERRED_SIZE,
                     GroupLayout.DEFAULT_SIZE,
                     GroupLayout.PREFERRED_SIZE).addComponent(
                         self.labelTestID, GroupLayout.PREFERRED_SIZE, 19,
                         GroupLayout.PREFERRED_SIZE)
     ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(
         innerPanelLayout.createParallelGroup(
             GroupLayout.Alignment.LEADING, False).addComponent(
                 self.search, GroupLayout.DEFAULT_SIZE,
                 GroupLayout.DEFAULT_SIZE, sys.maxint).addComponent(
                     self.searchProductButton)).addContainerGap(
                         131, sys.maxint)))
     layout.setHorizontalGroup(layout.createParallelGroup().addGroup(
         layout.createSequentialGroup().addComponent(
             innerPanel, GroupLayout.PREFERRED_SIZE, 633,
             GroupLayout.PREFERRED_SIZE).addGap(0, 312, sys.maxint)))
     layout.setVerticalGroup(layout.createParallelGroup().addGroup(
         layout.createSequentialGroup().addComponent(
             innerPanel, GroupLayout.PREFERRED_SIZE,
             GroupLayout.DEFAULT_SIZE,
             GroupLayout.PREFERRED_SIZE).addGap(0, 199, sys.maxint)))
Beispiel #35
0
    def registerExtenderCallbacks(self, callbacks):
        self.callbacks = callbacks
        self.helpers = callbacks.helpers

        self.checkboxEnable = JCheckBox('Enabled')
        self.checkboxEnable.setSelected(False)
        self.checkboxEnable.setEnabled(True)

        self.scriptpane = JTextPane()
        self.scriptpane.setFont(Font('Monospaced', Font.PLAIN, 11))

        self.scrollpane = JScrollPane()
        self.scrollpane.setViewportView(self.scriptpane)

        self.tab = JPanel()
        layout = GroupLayout(self.tab)
        self.tab.setLayout(layout)
        layout.setAutoCreateGaps(True)
        layout.setAutoCreateContainerGaps(True)

        layout.setHorizontalGroup(layout.createParallelGroup().addComponent(
            self.checkboxEnable).addComponent(self.scrollpane))
        layout.setVerticalGroup(layout.createSequentialGroup().addComponent(
            self.checkboxEnable).addComponent(self.scrollpane))

        self._code = compile('', '<string>', 'exec')
        self._script = ''

        script = callbacks.loadExtensionSetting('script')

        if script:
            script = base64.b64decode(script)

            self.scriptpane.document.insertString(
                self.scriptpane.document.length, script, SimpleAttributeSet())

            self._script = script
            try:
                self._code = compile(script, '<string>', 'exec')
            except Exception as e:
                traceback.print_exc(file=self.callbacks.getStderr())

        callbacks.setExtensionName("Python Scripter (modified)")
        callbacks.registerSessionHandlingAction(self)
        callbacks.registerExtensionStateListener(self)
        callbacks.registerHttpListener(self)
        callbacks.customizeUiComponent(self.getUiComponent())
        callbacks.addSuiteTab(self)

        self.scriptpane.requestFocus()
        return
Beispiel #36
0
    def __init__(self):
        self.jLabel1 = JLabel()
        self.jCheckBox1 = JCheckBox()
        self.jScrollPane1 = JScrollPane()
        self.jTable1 = JTable()
        self.jTabbedPane1 = JTabbedPane()
        self.jPanel1 = JPanel()
        self.jButton1 = JButton("Add")
        self.jButton2 = JButton("Remove")
        self.jLabel2 = JLabel()
        self.jLabel3 = JLabel()
        self.jLabel4 = JLabel()
        self.jLabel5 = JLabel()
        self.jLabel6 = JLabel()
        self.jTextField1 = JTextField()
        self.jTextField2 = JTextField()
        self.jTextField3 = JTextField()
        
        method = ["http", "https"]
        self.jComboBox1 = JComboBox(method)
        
        self.jLabel7 = JLabel()
        self.jLabel8 = JLabel()
        self.jTextField4 = JTextField()
        self.jButton3 = JButton()
        self.jPanel2 = JPanel()
        self.jScrollPane3 = JScrollPane()
        self.jTextArea2 = JTextArea()

        self.jLabel1.setFont(Font("굴림", 1, 12))
        self.jLabel1.setText("Use local files to serve remote locations.")

        self.jCheckBox1.setText("Enable Map Local")
        
        self.jScrollPane1.setViewportView(self.jTable1)

        self.jLabel2.setText("Protocol:")

        self.jLabel3.setText("Host:")

        self.jLabel4.setText("Path:")

        self.jLabel5.setText("Query:")

        self.jLabel6.setText("Map From")

        self.jLabel7.setText("Map To")

        self.jLabel8.setText("Local Path:")

        self.jButton3.setText("Choose")
        
        jPanel1Layout = GroupLayout(self.jPanel1)
        self.jPanel1.setLayout(jPanel1Layout)
        
        from java.lang import Short
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                            .addComponent(self.jLabel3)
                            .addComponent(self.jLabel2)
                            .addComponent(self.jLabel4)
                            .addComponent(self.jLabel5)
                            .addComponent(self.jLabel6))
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addComponent(self.jTextField1)
                            .addComponent(self.jTextField2)
                            .addComponent(self.jTextField3)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(self.jComboBox1, GroupLayout.PREFERRED_SIZE, 86, GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(self.jLabel7))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(30, 30, 30)
                                .addComponent(self.jLabel8)
                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(self.jTextField4, GroupLayout.DEFAULT_SIZE, 2000, Short.MAX_VALUE)
                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(self.jButton3, GroupLayout.PREFERRED_SIZE, 95, GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(self.jButton1, GroupLayout.PREFERRED_SIZE, 79, GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(self.jButton2, GroupLayout.PREFERRED_SIZE, 79, GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 18, Short.MAX_VALUE)))
                .addContainerGap())
        )
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(self.jLabel6)
                .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(self.jLabel2)
                    .addComponent(self.jComboBox1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(self.jLabel3)
                    .addComponent(self.jTextField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(self.jLabel4)
                    .addComponent(self.jTextField2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(self.jLabel5)
                    .addComponent(self.jTextField3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(self.jLabel7)
                .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(self.jLabel8)
                    .addComponent(self.jTextField4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addComponent(self.jButton3))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(self.jButton1)
                    .addComponent(self.jButton2))
                .addContainerGap(19, Short.MAX_VALUE))
        )

        self.jTabbedPane1.addTab("Edit Mapping", self.jPanel1)

        self.jTextArea2.setColumns(20)
        self.jTextArea2.setRows(5)
        self.jScrollPane3.setViewportView(self.jTextArea2)

        jPanel2Layout = GroupLayout(self.jPanel2)
        self.jPanel2.setLayout(jPanel2Layout)
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(self.jScrollPane3, GroupLayout.DEFAULT_SIZE, 729, Short.MAX_VALUE)
                .addContainerGap())
        )
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(self.jScrollPane3, GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE)
                .addContainerGap())
        )

        self.jTabbedPane1.addTab("Viewer", self.jPanel2)
        
        self.panel = JPanel()
        layout = GroupLayout(self.panel)
        self.panel.setLayout(layout)
        
        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(self.jScrollPane1)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addComponent(self.jCheckBox1)
                            .addComponent(self.jLabel1, GroupLayout.PREFERRED_SIZE, 285, GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(self.jTabbedPane1))
                .addContainerGap())
        )
        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(self.jLabel1)
                .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(self.jCheckBox1)
                .addGap(18, 18, 18)
                .addComponent(self.jScrollPane1, GroupLayout.PREFERRED_SIZE, 140, GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(self.jTabbedPane1)
                .addContainerGap())
        )
Beispiel #37
0
    def __init__(self, pP):
        '''
        Constructor
        '''
        self.pP = pP
        self.annotationType = self.pP.getAnnotationType()
        
        self.setTitle("Random Picture Picker")

        #annotation Panel
        annoPanel = JPanel()
        annoPanel.setBorder(BorderFactory.createTitledBorder("Annotations"))
        annoPLayout = GroupLayout(annoPanel)
        annoPanel.setLayout(annoPLayout)
        annoPLayout.setAutoCreateContainerGaps(True)
        annoPLayout.setAutoCreateGaps(True)        

        # dynamic creation of annotation panel
        # yesNoIgnore, int, number, list
        if len(self.pP.getAnnotationType()) == 1:
            self.annoField = JTextField("", 16)
            annoPLayout.setHorizontalGroup(annoPLayout.createParallelGroup().addComponent(self.annoField))
            annoPLayout.setVerticalGroup(annoPLayout.createSequentialGroup().addComponent(self.annoField))
        elif len(self.pP.getAnnotationType()) > 1:
            choices = pP.getAnnotationType()
            print "choices", choices
            choiceBtns = []
            self.annoField = ButtonGroup()
            for c in choices:
                Btn = JRadioButton(c, actionCommand=c)
                self.annoField.add(Btn)
                choiceBtns.append(Btn)
          
            h = annoPLayout.createParallelGroup()
            for b in choiceBtns:
                h.addComponent(b)
            annoPLayout.setHorizontalGroup(h)
            
            v = annoPLayout.createSequentialGroup()
            for b in choiceBtns:
                v.addComponent(b)
            annoPLayout.setVerticalGroup(v)


        # Control Panel
        ctrlPanel = JPanel()
        ctrlPLayout = GroupLayout(ctrlPanel, autoCreateContainerGaps=True, autoCreateGaps=True)
        ctrlPanel.setLayout(ctrlPLayout)
        
        nextImgButton = JButton("Next >", actionPerformed=self.nextPicture)
        prevImgButton = JButton("< Prev", actionPerformed=self.pP.prevPicture)
        quitButton = JButton("Quit", actionPerformed=self.exit)

        ctrlPLayout.setHorizontalGroup(ctrlPLayout.createParallelGroup(GroupLayout.Alignment.CENTER)
                                       .addGroup(ctrlPLayout.createSequentialGroup()
                                                 .addComponent(prevImgButton)
                                                 .addComponent(nextImgButton))
                                       .addComponent(quitButton))
        ctrlPLayout.setVerticalGroup(ctrlPLayout.createSequentialGroup()
                                     .addGroup(ctrlPLayout.createParallelGroup()
                                               .addComponent(prevImgButton)
                                               .addComponent(nextImgButton))
                                     .addComponent(quitButton))
        ctrlPLayout.linkSize(SwingConstants.HORIZONTAL, quitButton)

        
        statusPanel = JPanel()   # contains status information: progress bar
        self.progressBar = JProgressBar()
        self.progressBar.setStringPainted(True)
        self.progressBar.setValue(0)
        statusPanel.add(self.progressBar)
        
        #MainLayout
        mainLayout = GroupLayout(self.getContentPane())
        self.getContentPane().setLayout(mainLayout)
        
        mainLayout.setHorizontalGroup(mainLayout.createParallelGroup(GroupLayout.Alignment.CENTER)
                                    .addComponent(annoPanel)
                                    .addComponent(ctrlPanel)
                                    .addComponent(statusPanel)
                                    )
        mainLayout.setVerticalGroup(mainLayout.createSequentialGroup()
                                    .addComponent(annoPanel)
                                    .addComponent(ctrlPanel)
                                    .addComponent(statusPanel)
                                    )
        mainLayout.linkSize(SwingConstants.HORIZONTAL, annoPanel, ctrlPanel, statusPanel)
         
      
        self.pack()
        self.setVisible(True)
        
        self.pP.nextPicture()
Beispiel #38
0
    def drawPluginUI(self):
        # Create the plugin user interface
        self.pluginTab = JPanel()
        self.uiTitle = JLabel('UPnP BHunter Load, Aim and Fire Console')
        self.uiTitle.setFont(Font('Tahoma', Font.BOLD, 14))
        self.uiTitle.setForeground(Color(250, 100, 0))
        self.uiPanelA = JSplitPane(JSplitPane.VERTICAL_SPLIT)
        self.uiPanelA.setMaximumSize(Dimension(2500, 1000))
        self.uiPanelA.setDividerSize(2)
        self.uiPanelB = JSplitPane(JSplitPane.VERTICAL_SPLIT)
        self.uiPanelB.setDividerSize(2)
        self.uiPanelA.setBottomComponent(self.uiPanelB)
        self.uiPanelA.setBorder(BorderFactory.createLineBorder(Color.gray))

        # Create and configure labels and text fields
        self.labeltitle_step1 = JLabel("[1st STEP] Discover UPnP Locations")
        self.labeltitle_step1.setFont(Font('Tahoma', Font.BOLD, 14))
        self.labeltitle_step2 = JLabel(
            "[2nd STEP] Select a UPnP Service and Action")
        self.labeltitle_step2.setFont(Font('Tahoma', Font.BOLD, 14))
        self.labeltitle_step3 = JLabel("[3rd STEP] Time to Attack it")
        self.labeltitle_step3.setFont(Font('Tahoma', Font.BOLD, 14))
        self.labelsubtitle_step1 = JLabel(
            "Specify the IP version address in scope and start UPnP discovery")
        self.labelsubtitle_step2 = JLabel(
            "Select which of the found UPnP services will be probed")
        self.labelsubtitle_step3 = JLabel(
            "Review and modify the request, then send it to one of the attack tools"
        )
        self.label_step1 = JLabel("Target IP")
        self.label_step2 = JLabel("Found UPnp Services")
        self.labelstatus = JLabel("             Status")
        self.labelempty_step1 = JLabel("                ")
        self.labelempty_step2 = JLabel("  ")
        self.labelupnp = JLabel("UPnP list")
        self.labelip = JLabel("IP list")
        self.labelactions = JLabel("Actions")
        self.labelNoneServiceFound = JLabel("  ")
        self.labelNoneServiceFound.setFont(Font('Tahoma', Font.BOLD, 12))
        self.labelNoneServiceFound.setForeground(Color.red)

        # Create combobox for IP version selection
        self.ip_versions = ["IPv4", "IPv6"]
        self.combo_ipversion = JComboBox(self.ip_versions)
        self.combo_ipversion.setSelectedIndex(0)
        self.combo_ipversion.setEnabled(True)

        # Create and configure progress bar
        self.progressbar = JProgressBar(0, 100)
        self.progressbar.setString("Ready")
        self.progressbar.setStringPainted(True)

        # Create and configure buttons
        self.startbutton = JButton("Start Discovery",
                                   actionPerformed=self.startHunting)
        self.clearbutton = JButton("Clear All", actionPerformed=self.clearAll)
        self.intruderbutton = JButton("Send to Intruder",
                                      actionPerformed=self.sendToIntruder)
        self.repeaterbutton = JButton("Send to Repeater",
                                      actionPerformed=self.sendToRepeater)
        #self.WANrepeaterbutton = JButton("to Repeater", actionPerformed=self.sendWANUPnPToRepeater)
        self.textarea_request = JTextArea(18, 90)
        self.intruderbutton.setEnabled(False)
        self.repeaterbutton.setEnabled(False)

        # Class neeeded to handle the target combobox in second step panel
        class TargetComboboxListener(ActionListener):
            def __init__(self, upnpcombo_targets, upnpcombo_services,
                         ip_service_dict):
                self.upnpcombo_targets = upnpcombo_targets
                self.upnpcombo_services = upnpcombo_services
                self.ip_service_dict = ip_service_dict

            def actionPerformed(self, event):
                try:
                    # Update the location url combobox depending on the IP combobox
                    selected_target = self.upnpcombo_targets.getSelectedItem()
                    if self.ip_service_dict and selected_target:
                        self.upnpcombo_services.removeAllItems()
                        for service_url in self.ip_service_dict[
                                selected_target]:
                            self.upnpcombo_services.addItem(service_url)
                        self.upnpcombo_services.setSelectedIndex(0)
                except BaseException as e:
                    print("[!] Exception selecting service: \"%s\" ") % e

        # Class neeeded to handle the service combobox in second step panel
        class ServiceComboboxListener(ActionListener):
            def __init__(self, upnpcombo_services, upnpcombo_actions,
                         services_dict):
                self.upnpcombo_services = upnpcombo_services
                self.upnpcombo_actions = upnpcombo_actions
                self.services = services_dict

            def actionPerformed(self, event):
                try:
                    # Update the location url combobox depending on the IP combobox
                    selected_service = self.upnpcombo_services.getSelectedItem(
                    )
                    if self.services and selected_service:
                        self.upnpcombo_actions.removeAllItems()
                        actions = self.services[selected_service]
                        for action in actions:
                            self.upnpcombo_actions.addItem(action)
                        self.upnpcombo_actions.setSelectedIndex(0)
                except BaseException as e:
                    print("[!] Exception selecting service: \"%s\" ") % e

        # Class neeeded to handle the action combobox in second step panel
        class ActionComboboxListener(ActionListener):
            def __init__(self, upnpcombo_services, upnpcombo_actions,
                         textarea_request, services_dict):
                self.upnpcombo_services = upnpcombo_services
                self.upnpcombo_actions = upnpcombo_actions
                self.textarea_request = textarea_request
                self.services = services_dict

            def actionPerformed(self, event):
                try:
                    # Update the location url combobox depending on the IP combobox
                    selected_action = self.upnpcombo_actions.getSelectedItem()
                    selected_service = self.upnpcombo_services.getSelectedItem(
                    )
                    if self.services and selected_action:
                        self.textarea_request.setText(
                            self.services[selected_service][selected_action])
                except BaseException as e:
                    print("[!] Exception selecting action: \"%s\" ") % e

        self.upnpactions = ["       "]
        self.upnpcombo_actions = JComboBox(self.upnpactions)
        self.upnpcombo_actions.setSelectedIndex(0)
        self.upnpcombo_actions.setEnabled(False)

        # Create the combo box, select item at index 0 (first item in list)
        self.upnpservices = ["       "]
        self.upnpcombo_services = JComboBox(self.upnpservices)
        self.upnpcombo_services.setSelectedIndex(0)
        self.upnpcombo_services.setEnabled(False)

        # Create the combo box, select item at index 0 (first item in list)
        self.upnptargets = ["       "]
        self.upnpcombo_targets = JComboBox(self.upnptargets)
        self.upnpcombo_targets.setSelectedIndex(0)
        self.upnpcombo_targets.setEnabled(False)

        # Set the action listeners for all the comboboxes
        self.upnpcombo_targets.addActionListener(
            TargetComboboxListener(self.upnpcombo_targets,
                                   self.upnpcombo_services,
                                   self.ip_service_dict))
        self.upnpcombo_services.addActionListener(
            ServiceComboboxListener(self.upnpcombo_services,
                                    self.upnpcombo_actions,
                                    self.services_dict))
        self.upnpcombo_actions.addActionListener(
            ActionComboboxListener(self.upnpcombo_services,
                                   self.upnpcombo_actions,
                                   self.textarea_request, self.services_dict))

        # Configuring first step panel
        self.panel_step1 = JPanel()
        self.panel_step1.setPreferredSize(Dimension(2250, 100))
        self.panel_step1.setBorder(EmptyBorder(10, 10, 10, 10))
        self.panel_step1.setLayout(BorderLayout(15, 15))
        self.titlepanel_step1 = JPanel()
        self.titlepanel_step1.setLayout(BorderLayout())
        self.titlepanel_step1.add(self.labeltitle_step1, BorderLayout.NORTH)
        self.titlepanel_step1.add(self.labelsubtitle_step1)
        self.targetpanel_step1 = JPanel()
        self.targetpanel_step1.add(self.label_step1)
        self.targetpanel_step1.add(self.combo_ipversion)
        self.targetpanel_step1.add(self.startbutton)
        self.targetpanel_step1.add(self.clearbutton)
        self.targetpanel_step1.add(self.labelstatus)
        self.targetpanel_step1.add(self.progressbar)
        self.emptypanel_step1 = JPanel()
        self.emptypanel_step1.setLayout(BorderLayout())
        self.emptypanel_step1.add(self.labelempty_step1, BorderLayout.WEST)

        # Assembling first step panel components
        self.panel_step1.add(self.titlepanel_step1, BorderLayout.NORTH)
        self.panel_step1.add(self.targetpanel_step1, BorderLayout.WEST)
        self.panel_step1.add(self.emptypanel_step1, BorderLayout.SOUTH)
        self.uiPanelA.setTopComponent(self.panel_step1)

        # Configure second step panel
        self.panel_step2 = JPanel()
        self.panel_step2.setPreferredSize(Dimension(2250, 100))
        self.panel_step2.setBorder(EmptyBorder(10, 10, 10, 10))
        self.panel_step2.setLayout(BorderLayout(15, 15))
        self.titlepanel_step2 = JPanel()
        self.titlepanel_step2.setLayout(BorderLayout())
        self.titlepanel_step2.add(self.labeltitle_step2, BorderLayout.NORTH)
        self.titlepanel_step2.add(self.labelsubtitle_step2)
        self.selectpanel_step2 = JPanel()
        self.selectpanel_step2.add(self.labelip)
        self.selectpanel_step2.add(self.upnpcombo_targets)
        self.selectpanel_step2.add(self.labelupnp)
        self.selectpanel_step2.add(self.upnpcombo_services)
        self.selectpanel_step2.add(self.labelactions)
        self.selectpanel_step2.add(self.upnpcombo_actions)
        self.emptypanel_step2 = JPanel()
        self.emptypanel_step2.setLayout(BorderLayout())
        self.emptypanel_step2.add(self.labelempty_step2, BorderLayout.WEST)
        self.emptypanel_step2.add(self.labelNoneServiceFound)

        # Assembling second step panel components
        self.panel_step2.add(self.titlepanel_step2, BorderLayout.NORTH)
        self.panel_step2.add(self.selectpanel_step2, BorderLayout.WEST)
        self.panel_step2.add(self.emptypanel_step2, BorderLayout.SOUTH)
        self.uiPanelB.setTopComponent(self.panel_step2)

        # Configuring third step panel
        self.panel_step3 = JPanel()
        self.panel_step3.setPreferredSize(Dimension(2250, 100))
        self.panel_step3.setBorder(EmptyBorder(10, 10, 10, 10))
        self.panel_step3.setLayout(BorderLayout(15, 15))
        self.titlepanel_step3 = JPanel()
        self.titlepanel_step3.setLayout(BorderLayout())
        self.titlepanel_step3.add(self.labeltitle_step3, BorderLayout.NORTH)
        self.titlepanel_step3.add(self.labelsubtitle_step3)
        self.underpanel_step3 = JPanel()
        self.underpanel_step3.setLayout(BorderLayout())
        self.underpanel_step3.add((JScrollPane(self.textarea_request)),
                                  BorderLayout.NORTH)
        self.actionpanel_step3 = JPanel()
        self.actionpanel_step3.add(self.intruderbutton)
        self.actionpanel_step3.add(self.repeaterbutton)
        self.extrapanel_step3 = JPanel()
        self.extrapanel_step3.setLayout(BorderLayout())
        self.extrapanel_step3.add(self.actionpanel_step3, BorderLayout.WEST)

        # Assembling thirdd step panel components
        self.panel_step3.add(self.titlepanel_step3, BorderLayout.NORTH)
        self.panel_step3.add(self.underpanel_step3, BorderLayout.WEST)
        self.panel_step3.add(self.extrapanel_step3, BorderLayout.SOUTH)
        self.uiPanelB.setBottomComponent(self.panel_step3)

        # Assembling the group of all panels
        layout = GroupLayout(self.pluginTab)
        self.pluginTab.setLayout(layout)
        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
                layout.createSequentialGroup().addGap(10, 10, 10).addGroup(
                    layout.createParallelGroup(
                        GroupLayout.Alignment.LEADING).addComponent(
                            self.uiTitle).addGap(15, 15, 15).addComponent(
                                self.uiPanelA)).addContainerGap(
                                    26, Short.MAX_VALUE)))
        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
                layout.createSequentialGroup().addGap(15, 15, 15).addComponent(
                    self.uiTitle).addGap(15, 15, 15).addComponent(
                        self.uiPanelA).addGap(20, 20, 20).addGap(20, 20, 20)))
Beispiel #39
0
    def registerExtenderCallbacks(self, callbacks):
        self.callbacks = callbacks
        self.helpers = callbacks.getHelpers()
        callbacks.setExtensionName("Missing Scanner Checks")
        self.out = callbacks.getStdout()

        # define all checkboxes
        self.cbPassiveChecks = self.defineCheckBox("Passive Scanner Checks")
        self.cbDOMXSS = self.defineCheckBox("DOM XSS", False)
        self.cbDOMXSSSources = self.defineCheckBox("Sources", False)
        self.cbDOMXSSSinks = self.defineCheckBox("Sinks")
        self.cbDOMXSSjQuerySinks = self.defineCheckBox("jQuery Sinks", False)
        self.grpDOMXSSSettings = JPanel()
        self.grpDOMXSSSettings.add(self.cbDOMXSSSources)
        self.grpDOMXSSSettings.add(self.cbDOMXSSSinks)
        self.grpDOMXSSSettings.add(self.cbDOMXSSjQuerySinks)
        self.cbSTS = self.defineCheckBox("Strict Transport Security")
        self.lblSTSMin = JLabel("Minimum acceptable max-age")
        self.inSTSMin = JTextField(
            str(STSMinimum), 9, actionPerformed=self.setSTSMinimum
        )  # TODO: actionPerformed only fires on enter key - focus lost would be better
        self.inSTSMin.setToolTipText(
            "Enter the minimum max-age value which is considered as acceptable. Press return to change setting!"
        )
        self.grpSTSSettings = JPanel()
        self.grpSTSSettings.add(self.lblSTSMin)
        self.grpSTSSettings.add(self.inSTSMin)
        self.cbXCTO = self.defineCheckBox("Content Sniffing")
        self.cbXXP = self.defineCheckBox(
            "Client-side XSS Filter Configuration")
        self.cbRedirToHTTPS = self.defineCheckBox(
            "Redirection from HTTP to HTTPS")
        self.btnSave = JButton("Set as default",
                               actionPerformed=self.saveConfig)
        self.btnRestore = JButton("Restore",
                                  actionPerformed=self.restoreConfig)
        self.grpConfig = JPanel()
        self.grpConfig.add(self.btnSave)
        self.grpConfig.add(self.btnRestore)
        self.restoreConfig()

        # definition of config tab
        self.tab = JPanel()
        layout = GroupLayout(self.tab)
        self.tab.setLayout(layout)
        layout.setAutoCreateGaps(True)
        layout.setAutoCreateContainerGaps(True)
        layout.setHorizontalGroup(layout.createSequentialGroup().addGroup(
            layout.createParallelGroup().addComponent(self.cbPassiveChecks)
        ).addGroup(layout.createParallelGroup().addComponent(
            self.cbDOMXSS).addComponent(self.cbSTS).addComponent(
                self.cbXCTO).addComponent(self.cbXXP).addComponent(
                    self.cbRedirToHTTPS)).addGroup(
                        layout.createParallelGroup().addComponent(
                            self.grpDOMXSSSettings, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.PREFERRED_SIZE,
                            GroupLayout.PREFERRED_SIZE).addComponent(
                                self.grpSTSSettings,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.PREFERRED_SIZE).addComponent(
                                    self.grpConfig, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.PREFERRED_SIZE)))
        layout.setVerticalGroup(layout.createSequentialGroup().addGroup(
            layout.createParallelGroup().addComponent(
                self.cbPassiveChecks).addComponent(self.cbDOMXSS).addComponent(
                    self.grpDOMXSSSettings, GroupLayout.PREFERRED_SIZE,
                    GroupLayout.PREFERRED_SIZE,
                    GroupLayout.PREFERRED_SIZE)).addGroup(
                        layout.createParallelGroup().addComponent(
                            self.cbSTS).addComponent(
                                self.grpSTSSettings,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.PREFERRED_SIZE)).addComponent(
                                    self.cbXCTO).addComponent(
                                        self.cbXXP).addComponent(
                                            self.cbRedirToHTTPS).addComponent(
                                                self.grpConfig,
                                                GroupLayout.PREFERRED_SIZE,
                                                GroupLayout.PREFERRED_SIZE,
                                                GroupLayout.PREFERRED_SIZE))

        self.domXSSSourcesRE = re.compile(
            "(location\s*[\[.])|([.\[]\s*[\"']?\s*(arguments|dialogArguments|innerHTML|write(ln)?|open(Dialog)?|showModalDialog|cookie|URL|documentURI|baseURI|referrer|name|opener|parent|top|content|self|frames)\W)|(localStorage|sessionStorage|Database)"
        )
        # NOTE: done some optimizations here, original RE caused too much noise
        # - added leading dot in the first part - original recognized "<a href=..." etc.
        # - removed "value" in first part
        self.domXSSSinksRE = re.compile(
            "(\.(src|href|data|location|code|action)\s*[\"'\]]*\s*\+?\s*=)|((replace|assign|navigate|getResponseHeader|open(Dialog)?|showModalDialog|eval|evaluate|execCommand|execScript|setTimeout|setInterval)\s*[\"'\]]*\s*\()"
        )
        self.domXSSjQuerySinksRE = re.compile(
            "after\(|\.append\(|\.before\(|\.html\(|\.prepend\(|\.replaceWith\(|\.wrap\(|\.wrapAll\(|\$\(|\.globalEval\(|\.add\(|jQUery\(|\$\(|\.parseHTML\("
        )
        self.headerSTSRE = re.compile(
            "^Strict-Transport-Security:.*?max-age=\"?(\d+)\"?",
            re.I)  # TODO: multiple max-age directives cause confusion!
        self.headerXCTORE = re.compile(
            "^X-Content-Type-Options:\s*nosniff\s*$", re.I)
        self.headerXXP = re.compile(
            "^X-XSS-Protection:\s*(\d)(?:\s*;\s*mode\s*=\s*\"?(block)\"?)?",
            re.I)
        self.headerLocationHTTPS = re.compile(
            "^(?:Content-)?Location:\s*(https://.*)$", re.I)

        callbacks.registerScannerCheck(self)
        callbacks.addSuiteTab(self)
Beispiel #40
0
    def __init__(self, ui):
        JSplitPane.__init__(self, JSplitPane.HORIZONTAL_SPLIT)
        self._ui = ui

        # create the executor object
        self._executor = Executor(self, ui.callbacks)

        ####
        # start Left Top split layout
        jLeftTopPanel = JPanel()
        jMenuPanel = JPanel()

        #Load button
        self.jLoad = JButton(Strings.jLoad_text)
        self.jLoad.addActionListener(self)
        #File name text field
        self.jFileName = JTextField(Strings.jFileName_default, 30)
        self.jFileName.setHorizontalAlignment(JTextField.CENTER)
        self.jFileName.setEditable(False)
        #Save button
        self.jSave = JButton(Strings.jSave_text)
        self.jSave.addActionListener(self)
        #Exit button
        self.jExit = JButton(Strings.jExit_text)
        self.jExit.addActionListener(self)
        #Wiki button (URL)
        self.jWiki = JButton(Strings.jWiki_title)
        self.jWiki.setToolTipText(Strings.jWiki_tooltip)
        self.jWiki.addActionListener(self)
        # make it borderless
        self.jWiki.setBorder(EmptyBorder(0, 0, 0, 0))
        self.jWiki.setBorderPainted(False)
        self.jWiki.setContentAreaFilled(False)

        #Console text area
        jConsoleText = JTextArea()
        jConsoleText.setEditable(0)
        jConsoleText.setWrapStyleWord(1)
        jConsoleText.setRows(10)
        #set initial text
        jConsoleText.setText(Strings.jConsoleText_help)
        #make scrollable
        jScrollConsolePane = JScrollPane()
        jScrollConsolePane.setViewportView(jConsoleText)

        jMenuPanelLayout = GroupLayout(jMenuPanel)
        jMenuPanel.setLayout(jMenuPanelLayout)
        jMenuPanelLayout.setHorizontalGroup(
            jMenuPanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).
            addGroup(jMenuPanelLayout.createSequentialGroup().addContainerGap(
            ).addComponent(self.jLoad).addComponent(
                self.jFileName).addPreferredGap(
                    LayoutStyle.ComponentPlacement.RELATED).addComponent(
                        self.jSave).addPreferredGap(
                            LayoutStyle.ComponentPlacement.RELATED).
                     addComponent(self.jWiki).addPreferredGap(
                         LayoutStyle.ComponentPlacement.RELATED).addComponent(
                             self.jExit).addContainerGap()))
        jMenuPanelLayout.setVerticalGroup(
            jMenuPanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGroup(
                    jMenuPanelLayout.createSequentialGroup().addGroup(
                        jMenuPanelLayout.createParallelGroup(
                            GroupLayout.Alignment.BASELINE).addComponent(
                                self.jLoad).addComponent(
                                    self.jFileName, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE).addComponent(
                                        self.jSave).addComponent(
                                            self.jWiki).addComponent(
                                                self.jExit))))

        jLeftTopPanelLayout = GroupLayout(jLeftTopPanel)
        jLeftTopPanel.setLayout(jLeftTopPanelLayout)
        jLeftTopPanelLayout.setHorizontalGroup(
            jLeftTopPanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addComponent(
                    jMenuPanel, GroupLayout.DEFAULT_SIZE,
                    GroupLayout.DEFAULT_SIZE,
                    GroupLayout.DEFAULT_SIZE).addComponent(
                        jScrollConsolePane, GroupLayout.DEFAULT_SIZE,
                        GroupLayout.DEFAULT_SIZE, 32767))
        jLeftTopPanelLayout.setVerticalGroup(
            jLeftTopPanelLayout.
            createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
                GroupLayout.Alignment.TRAILING,
                jLeftTopPanelLayout.createSequentialGroup().addComponent(
                    jMenuPanel, GroupLayout.PREFERRED_SIZE,
                    GroupLayout.DEFAULT_SIZE,
                    GroupLayout.PREFERRED_SIZE).addPreferredGap(
                        LayoutStyle.ComponentPlacement.RELATED).addComponent(
                            jScrollConsolePane, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.DEFAULT_SIZE, 32767)))
        # end Left Top split layout
        ####

        ####
        # start Left Down split layout
        jLeftDownPanel = JPanel()
        jMenu2Panel = JPanel()

        #Clear button
        self.jClear = JButton(Strings.jClear_text)
        self.jClear.setToolTipText(Strings.jClear_tooltip)
        self.jClear.addActionListener(self)

        #Run button
        self.jRun = JButton(Strings.jRun_text)
        self.jRun.setToolTipText(Strings.jRun_tooltip)
        self.jRun.addActionListener(self)

        #Variables text area
        jVarsPane = JTextPane()
        jVarsPane.setFont(Font('Monospaced', Font.PLAIN, 11))
        jVarsPane.addFocusListener(self)
        # set initial value
        jVarsPane.setText(Strings.jVarsPane_header)
        # make scrollable
        jScrollpaneLeftDown = JScrollPane()
        jScrollpaneLeftDown.setViewportView(jVarsPane)

        jMenu2PanelLayout = GroupLayout(jMenu2Panel)
        jMenu2Panel.setLayout(jMenu2PanelLayout)
        jMenu2PanelLayout.setHorizontalGroup(
            jMenu2PanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGroup(
                    jMenu2PanelLayout.createSequentialGroup().addContainerGap(
                    ).addComponent(self.jClear).addPreferredGap(
                        LayoutStyle.ComponentPlacement.RELATED, 100,
                        32767).addComponent(self.jRun).addContainerGap()))
        jMenu2PanelLayout.setVerticalGroup(
            jMenu2PanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGroup(
                    jMenu2PanelLayout.createSequentialGroup().addGroup(
                        jMenu2PanelLayout.createParallelGroup(
                            GroupLayout.Alignment.BASELINE).addComponent(
                                self.jClear).addComponent(self.jRun))))
        jLeftDownPanelLayout = GroupLayout(jLeftDownPanel)
        jLeftDownPanel.setLayout(jLeftDownPanelLayout)
        jLeftDownPanelLayout.setHorizontalGroup(
            jLeftDownPanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addComponent(
                    jMenu2Panel, GroupLayout.DEFAULT_SIZE,
                    GroupLayout.DEFAULT_SIZE,
                    GroupLayout.DEFAULT_SIZE).addComponent(
                        jScrollpaneLeftDown, GroupLayout.DEFAULT_SIZE,
                        GroupLayout.DEFAULT_SIZE, 32767))
        jLeftDownPanelLayout.setVerticalGroup(
            jLeftDownPanelLayout.
            createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
                GroupLayout.Alignment.TRAILING,
                jLeftDownPanelLayout.createSequentialGroup().addComponent(
                    jMenu2Panel, GroupLayout.PREFERRED_SIZE,
                    GroupLayout.DEFAULT_SIZE,
                    GroupLayout.PREFERRED_SIZE).addPreferredGap(
                        LayoutStyle.ComponentPlacement.RELATED).addComponent(
                            jScrollpaneLeftDown, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.DEFAULT_SIZE, 32767)))
        # end Left Down split layout
        ####

        ####
        # start Left layout
        jSplitPaneLeft = JSplitPane(JSplitPane.VERTICAL_SPLIT, jLeftTopPanel,
                                    jLeftDownPanel)
        jSplitPaneLeft.setDividerLocation(300)
        # end Left layout
        ####

        ####
        # start Right layout
        jScriptPane = JTextPane()
        jScriptPane.setFont(Font('Monospaced', Font.PLAIN, 11))
        # set initial value
        jScriptPane.setText(Strings.jScriptPane_header)
        #jScriptPane.addMouseListener(self)

        jScrollPaneRight = JScrollPane()
        jScrollPaneRight.setViewportView(jScriptPane)
        # end Right layout
        ####

        self.setLeftComponent(jSplitPaneLeft)
        self.setRightComponent(jScrollPaneRight)
        self.setDividerLocation(450)

        #Exported variables
        self.jConsoleText = jConsoleText
        self.jScrollConsolePane = jScrollConsolePane
        self.jScriptPane = jScriptPane
        self.jVarsPane = jVarsPane
Beispiel #41
0
    def _initializeGui(self, callbacks):
        tab = JPanel()

        jLabel1 = JLabel("Original Hash:")
        jLabel2 = JLabel("Original message:")
        jLabel3 = JLabel("Message to append:")
        jLabel5 = JLabel("Max key length:")
        jTextField1 = JTextField("")
        jTextField2 = JTextField("")
        jTextField3 = JTextField("")
        jTextField4 = JTextField("128")
        jLabel4 = JLabel("Hashing functions")
        jCheckBox1 = JCheckBox("MD4")
        jCheckBox2 = JCheckBox("MD5")
        jCheckBox3 = JCheckBox("SHA1")
        jCheckBox4 = JCheckBox("SHA256")
        jCheckBox5 = JCheckBox("SHA512")
        jCheckBox1.setEnabled(False)
        jCheckBox2.setEnabled(False)
        jCheckBox3.setEnabled(False)
        jCheckBox4.setEnabled(False)
        jCheckBox5.setEnabled(False)
        jScrollPane1 = JScrollPane()
        jTable1 = JTable()
        jButton1 = JButton("Generate", actionPerformed=self.generate_attack)
        jButton1.setEnabled(False)
        jButton2 = JButton("Copy messages", actionPerformed=self.copy_messages)
        jButton3 = JButton("Copy hashes", actionPerformed=self.copy_hashes)

        self._tab = tab
        self._textfields = {
            "original_hash": jTextField1,
            "original_msg": jTextField2,
            "append_msg": jTextField3,
            "max_key_len": jTextField4,
        }
        self._checkboxes = {
            md4: jCheckBox1,
            md5: jCheckBox2,
            sha1: jCheckBox3,
            sha256: jCheckBox4,
            sha512: jCheckBox5,
        }

        self._table = jTable1
        self._extensions = {}
        self._hashes, self._messages = [], []

        # Hash field change event
        jTextField1.getDocument().addDocumentListener(HashChangeListener(self._checkboxes, self._textfields['original_hash'], jButton1))

        # Table columns
        jTable1.setModel(DefaultTableModel([],["#", "Type","New Message", "Hash"]))
        jScrollPane1.setViewportView(jTable1)
        # Table column width
        jTable1.getColumnModel().getColumn(0).setMaxWidth(50)
        jTable1.getColumnModel().getColumn(1).setMaxWidth(60)

        layout = GroupLayout(tab)
        tab.setLayout(layout)

        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3))
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(jTextField3, GroupLayout.DEFAULT_SIZE, 425, 32767)
                    .addComponent(jTextField2)
                    .addComponent(jTextField1)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jTextField4, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, 32767)))
                .addGap(30, 30, 30)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jCheckBox1)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCheckBox2)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCheckBox3)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCheckBox4)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCheckBox5))
                    .addComponent(jLabel4)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton3)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton2)))
                .addGap(167, 167, 167))
            .addComponent(jScrollPane1)
        )
        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jTextField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(jCheckBox2)
                        .addComponent(jCheckBox3)
                        .addComponent(jCheckBox1)
                        .addComponent(jCheckBox4)
                        .addComponent(jCheckBox5)))
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jTextField4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton2)
                    .addComponent(jButton3)
                    .addComponent(jButton1))
                .addGap(13, 13, 13)
                .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 971, 32767))
        )

        callbacks.customizeUiComponent(tab)
        callbacks.addSuiteTab(self)
Beispiel #42
0
    def __init__(self, table=None):
        self.jScrollPane1 = JScrollPane()
        self.jTable1 = JTable()
        self.jPanel1 = JPanel()
        self.labelName = JLabel()
        self.textName = JTextField()
        self.labelSeverity = JLabel()
        self.textSeverity = JTextField()
        self.labelHost = JLabel()
        self.labelPath = JLabel()
        self.textHost = JTextField()
        self.textPath = JTextField()
        self.tabIssue = JTabbedPane()
        self.panelDescription = JPanel()
        self.panelRequest = JPanel()
        self.panelResponse = JPanel()
        self.panelRemediation = JPanel()

        # setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)

        self.jTable1 = table

        # wrap the table in a scrollpane
        self.jScrollPane1.setViewportView(self.jTable1)

        # top panel containing the table
        from java.awt import Color
        self.jPanel1.setBorder(BorderFactory.createLineBorder(Color(0, 0, 0)))

        # create the labels and textfields
        self.labelName.text = "Issue Type/Name"
        self.textName.text = "Issue Name/Type"
        self.textName.editable = False
        self.textName.setBackground(Color.LIGHT_GRAY)

        self.labelSeverity.text = "Severity"
        self.textSeverity.text = ""
        self.textSeverity.editable = False
        self.textSeverity.setBackground(Color.LIGHT_GRAY)

        self.labelHost.text = "Host"
        self.textHost.text = "Issue Host"
        self.textHost.editable = False
        self.textHost.setBackground(Color.LIGHT_GRAY)

        self.labelPath.text = "Path"
        self.textPath.text = "Issue Path"
        self.textPath.editable = False
        self.textPath.setBackground(Color.LIGHT_GRAY)

        from java.lang import Short
        # description panel
        panelDescriptionLayout = GroupLayout(self.panelDescription)
        self.panelDescription.setLayout(panelDescriptionLayout)
        panelDescriptionLayout.setHorizontalGroup(
            panelDescriptionLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE))
        panelDescriptionLayout.setVerticalGroup(
            panelDescriptionLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE))
        self.tabIssue.addTab("Description", self.panelDescription)

        # request tab
        panelRequestLayout = GroupLayout(self.panelRequest)
        self.panelRequest.setLayout(panelRequestLayout)
        panelRequestLayout.setHorizontalGroup(
            panelRequestLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE))
        panelRequestLayout.setVerticalGroup(
            panelRequestLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE))
        self.tabIssue.addTab("Request", self.panelRequest)

        # response tab
        panelResponseLayout = GroupLayout(self.panelResponse)
        self.panelResponse.setLayout(panelResponseLayout)
        panelResponseLayout.setHorizontalGroup(
            panelResponseLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE))
        panelResponseLayout.setVerticalGroup(
            panelResponseLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE))
        self.tabIssue.addTab("Response", self.panelResponse)

        # remediation tab
        panelRemediationLayout = GroupLayout(self.panelRemediation)
        self.panelRemediation.setLayout(panelRemediationLayout)
        panelRemediationLayout.setHorizontalGroup(
            panelRemediationLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 948, Short.MAX_VALUE))
        panelRemediationLayout.setVerticalGroup(
            panelRemediationLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGap(0, 287, Short.MAX_VALUE))
        self.tabIssue.addTab("Remediation", self.panelRemediation)

        # jpanel1?
        jPanel1Layout = GroupLayout(self.jPanel1)
        self.jPanel1.setLayout(jPanel1Layout)
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING).
            addGroup(jPanel1Layout.createSequentialGroup().addContainerGap(
            ).addGroup(
                jPanel1Layout.createParallelGroup(
                    GroupLayout.Alignment.LEADING).
                addGroup(jPanel1Layout.createSequentialGroup().addGroup(
                    jPanel1Layout.createParallelGroup(
                        GroupLayout.Alignment.TRAILING).addComponent(
                            self.labelHost).addComponent(
                                self.labelSeverity).addComponent(
                                    self.labelName)
                ).addPreferredGap(
                    LayoutStyle.ComponentPlacement.UNRELATED).addGroup(
                        jPanel1Layout.createParallelGroup(
                            GroupLayout.Alignment.LEADING).
                        addComponent(self.textName).addGroup(
                            jPanel1Layout.createSequentialGroup().addComponent(
                                self.textSeverity, GroupLayout.PREFERRED_SIZE,
                                98, GroupLayout.PREFERRED_SIZE).addGap(
                                    0, 0, Short.MAX_VALUE)).
                        addGroup(
                            jPanel1Layout.createSequentialGroup().addComponent(
                                self.textHost, GroupLayout.PREFERRED_SIZE, 330,
                                GroupLayout.PREFERRED_SIZE).addGap(18, 18, 18).
                            addComponent(self.labelPath).addPreferredGap(
                                LayoutStyle.ComponentPlacement.RELATED
                            ).addComponent(self.textPath)))).addComponent(
                                self.tabIssue)).addContainerGap()))

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING).
            addGroup(jPanel1Layout.createSequentialGroup().addContainerGap(
            ).addGroup(
                jPanel1Layout.createParallelGroup(
                    GroupLayout.Alignment.BASELINE).addComponent(
                        self.labelName).addComponent(
                            self.textName, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
            ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(
                jPanel1Layout.createParallelGroup(
                    GroupLayout.Alignment.BASELINE).addComponent(
                        self.labelSeverity).addComponent(
                            self.textSeverity, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
            ).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(
                jPanel1Layout.createParallelGroup(
                    GroupLayout.Alignment.BASELINE).addComponent(
                        self.labelHost).addComponent(
                            self.labelPath).addComponent(
                                self.textHost, GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE).addComponent(
                                    self.textPath, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)).
                     addPreferredGap(
                         LayoutStyle.ComponentPlacement.RELATED).addComponent(
                             self.tabIssue).addContainerGap()))

        # create the main panel
        self.panel = JPanel()
        layout = GroupLayout(self.panel)
        self.panel.setLayout(layout)
        layout.setAutoCreateGaps(True)

        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
                layout.createSequentialGroup().addContainerGap().addGroup(
                    layout.createParallelGroup(
                        GroupLayout.Alignment.LEADING).addComponent(
                            self.jPanel1, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.DEFAULT_SIZE,
                            Short.MAX_VALUE).addComponent(
                                self.jScrollPane1)).addContainerGap()))
        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
                layout.createSequentialGroup().addContainerGap().addComponent(
                    self.jScrollPane1, GroupLayout.PREFERRED_SIZE, 119,
                    GroupLayout.PREFERRED_SIZE).addGap(
                        18, 18,
                        18).addComponent(self.jPanel1,
                                         GroupLayout.DEFAULT_SIZE,
                                         GroupLayout.DEFAULT_SIZE,
                                         Short.MAX_VALUE).addContainerGap()))
Beispiel #43
0
    def registerExtenderCallbacks(self, callbacks):

        self._panel = JPanel()
        self._panel.setLayout(BorderLayout())
        #self._panel.setSize(400,400)

        # sourrounding try\except because Burp is not giving enough info
        try:

            # creating all the UI elements
            # create the split pane
            self._split_pane_horizontal = JSplitPane(
                JSplitPane.HORIZONTAL_SPLIT)
            self._split_panel_vertical = JSplitPane(JSplitPane.VERTICAL_SPLIT)

            # create panels
            self._panel_top = JPanel()
            self._panel_top.setLayout(BorderLayout())
            self._panel_bottom = JPanel()
            self._panel_bottom.setLayout(BorderLayout())
            self._panel_right = JPanel()
            self._panel_right.setLayout(BorderLayout())
            self._panel_request = JPanel()
            self._panel_request.setLayout(BorderLayout())
            self._panel_response = JPanel()
            self._panel_response.setLayout(BorderLayout())

            # create the tabbed pane used to show request\response
            self._tabbed_pane = JTabbedPane(JTabbedPane.TOP)

            # create the tabbed pane used to show aslan++\concretization file
            self._tabbed_pane_editor = JTabbedPane(JTabbedPane.TOP)

            # create the bottom command for selecting the SQL file and
            # generating the model
            self._button_generate = JButton(
                'Generate!', actionPerformed=self._generate_model)
            self._button_save = JButton('Save',
                                        actionPerformed=self._save_model)
            self._button_select_sql = JButton(
                'Select SQL', actionPerformed=self._select_sql_file)
            self._text_field_sql_file = JTextField(20)

            self._panel_bottom_commands = JPanel()
            layout = GroupLayout(self._panel_bottom_commands)
            layout.setAutoCreateGaps(True)
            layout.setAutoCreateContainerGaps(True)
            seq_layout = layout.createSequentialGroup()
            seq_layout.addComponent(self._text_field_sql_file)
            seq_layout.addComponent(self._button_select_sql)
            seq_layout.addComponent(self._button_generate)
            seq_layout.addComponent(self._button_save)
            layout.setHorizontalGroup(seq_layout)

            # create the message editors that will be used to show request and response
            self._message_editor_request = callbacks.createMessageEditor(
                None, True)
            self._message_editor_response = callbacks.createMessageEditor(
                None, True)

            # create the table that will be used to show the messages selected for
            # the translation

            self._columns_names = ('Host', 'Method', 'URL')
            dataModel = NonEditableModel(self._table_data, self._columns_names)
            self._table = JTable(dataModel)
            self._scrollPane = JScrollPane()
            self._scrollPane.getViewport().setView((self._table))

            popmenu = JPopupMenu()
            delete_item = JMenuItem("Delete")
            delete_item.addActionListener(self)
            popmenu.add(delete_item)
            self._table.setComponentPopupMenu(popmenu)
            self._table.addMouseListener(self)

            # add all the elements
            self._panel_request.add(
                self._message_editor_request.getComponent())
            self._panel_response.add(
                self._message_editor_response.getComponent())

            self._tabbed_pane.addTab("Request", self._panel_request)
            self._tabbed_pane.addTab("Response", self._panel_response)

            self._panel_top.add(self._scrollPane, BorderLayout.CENTER)

            self._panel_bottom.add(self._tabbed_pane, BorderLayout.CENTER)
            scroll = JScrollPane(self._panel_bottom)

            self._panel_right.add(self._tabbed_pane_editor,
                                  BorderLayout.CENTER)
            self._panel_right.add(self._panel_bottom_commands,
                                  BorderLayout.PAGE_END)

            self._split_panel_vertical.setTopComponent(self._panel_top)
            self._split_panel_vertical.setBottomComponent(scroll)
            self._split_pane_horizontal.setLeftComponent(
                self._split_panel_vertical)
            self._split_pane_horizontal.setRightComponent(self._panel_right)

            self._panel.addComponentListener(self)
            self._panel.add(self._split_pane_horizontal)

            self._callbacks = callbacks
            callbacks.setExtensionName("WAFEx")
            callbacks.addSuiteTab(self)
            callbacks.registerContextMenuFactory(self)
        except Exception as e:
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
Beispiel #44
0
	def registerExtenderCallbacks(self, callbacks):
		self._callbacks = callbacks
		self._helpers = callbacks.getHelpers()
		self._stdout = PrintWriter(callbacks.getStdout(), True)

		callbacks.setExtensionName("Argument Injection Hammer")	
		self._create_brute_payloads()

		self._stdout.println('==================================')	
		self._stdout.println("        ,")
		self._stdout.println("       /(  ___________")
		self._stdout.println("      |  >:===========`")
		self._stdout.println("       )(")
		self._stdout.println('== AIH "" Hammer Smash Party =====')
		self._stdout.println('== Neil Bergman - NCC Group  =====')
		self._stdout.println('==================================')

		self._checkbox_brute = self._define_check_box("Brute-force Short Argument Flags", False)
		self._button_save = JButton("Save Configuration", actionPerformed=self._save_config)

		self.tab = JPanel()
		layout = GroupLayout(self.tab)
		self.tab.setLayout(layout)
		layout.setAutoCreateGaps(True)
		layout.setAutoCreateContainerGaps(True)
		layout.setHorizontalGroup(
			layout.createSequentialGroup().addGroup(
				layout.createParallelGroup()
				.addComponent(self._checkbox_brute)
				
			).addGroup(
				layout.createParallelGroup()
				.addComponent(self._button_save)
			)
		)
		layout.setVerticalGroup(
			layout.createSequentialGroup().addGroup(
				layout.createParallelGroup()
				.addComponent(self._checkbox_brute)
			).addGroup(
				layout.createParallelGroup()
				.addComponent(self._button_save)
			)
		)
		callbacks.addSuiteTab(self)
		self._restore_config()

		callbacks.registerScannerCheck(self)
		return