def main():
	
	activeLayers=getActiveLayers()

	if len(activeLayers)==0:
		JOptionPane.showMessageDialog(None, 
			"Add and activate at least one vector layer in the view. Retry!",
			"Batch Transparency", JOptionPane.WARNING_MESSAGE)
		return
	else:
		numFLyrVect=0
		for i in range(len(activeLayers)):
			if activeLayers[i].getClass().getCanonicalName()=="com.iver.cit.gvsig.fmap.layers.FLyrVect":
				numFLyrVect=numFLyrVect+1
		if numFLyrVect==0:
			JOptionPane.showMessageDialog(None, 
				"You have to add and activate at least one vector layer in the view. Retry!", 
				"Batch Transparency", JOptionPane.WARNING_MESSAGE)
			return
		else:
			global frame, outCheckbox, fillCheckbox, slider
			frame = JFrame("Batch Transparency", defaultCloseOperation=JFrame.DISPOSE_ON_CLOSE, 
				bounds=(100, 100, 450, 80), layout=FlowLayout(), resizable=0)

			outCheckbox = JCheckBox("outline", 1)
			fillCheckbox = JCheckBox("fill", 1)

			# Create a horizontal slider with min=0, max=100, value=50
			slider = JSlider()
			slider.setPreferredSize(Dimension(200, 50))
			slider.setValue(100)
			slider.setMajorTickSpacing(25)
			slider.setMinorTickSpacing(5)
			slider.setPaintTicks(1)
			slider.setPaintLabels(1)

			applyButton = JButton("Apply", actionPerformed=action)
			acceptButton = JButton("Accept", actionPerformed=accept)
			
			frame.add(outCheckbox)
			frame.add(fillCheckbox)
			frame.add(slider)
			frame.add(applyButton)
			frame.add(acceptButton)
			
			frame.show()
	return
def getGUI(sym_dict):
	global frame, outCheckbox, fillCheckbox, slider, colorTF, widthTF
	frame = JFrame("Border Symbology", defaultCloseOperation=JFrame.DISPOSE_ON_CLOSE, 
		       bounds=(100, 100, 450, 200), layout=FlowLayout(), resizable=0)

	colorL = JLabel('Color: ')
	colorTF = JTextField(20)
	color = sym_dict["color"]
	color = Color(color.getRed(), color.getGreen(), color.getBlue(), sym_dict["alpha"])
	colorTF.setBackground(color)
	colorTF.setText(color.toString())

	colorB = JButton('...', actionPerformed=colorChooser)
	frame.add(colorL)
	frame.add(colorTF)
	frame.add(colorB)

	widthL = JLabel('Width: ')
	widthTF = JTextField(3)
	widthTF.setText(str(sym_dict["width"]))
	frame.add(widthL)
	frame.add(widthTF)

	alphaL = JLabel('Transparency: ')
	frame.add(alphaL)

	# Create a horizontal slider with min=0, max=100, value=50
	slider = JSlider()
	slider.setPreferredSize(Dimension(200, 50))
	slider.setValue(sym_dict["alpha"]*100/255)
	slider.setMajorTickSpacing(25)
	slider.setMinorTickSpacing(5)
	slider.setPaintTicks(1)
	slider.setPaintLabels(1)

	applyButton = JButton("Apply", actionPerformed=action)
	acceptButton = JButton("Accept", actionPerformed=accept)

	frame.add(slider)
	frame.add(applyButton)
	frame.add(acceptButton)

	frame.show()
示例#3
0
class Mi_Extension(IHttpListener, IScannerCheck):
    def __init__(self, extender):
        self._callbacks = extender._callbacks
        self._helpers = extender._callbacks.getHelpers()
        self._callbacks.registerScannerCheck(self)
        # Creamos el contenedor de paneles.
        self.contenedor = JTabbedPane()

        # Campos del sub-tab 1 (mash up)
        self._tab1_nombre = JTextField()
        self._tab1_apellido = JTextField()
        self._tab1_FNacimiento = JTextField()
        self._tab1_mascota = JTextField()
        self._tab1_otro = JTextField()

        self._tab1_feedback_ta = JTextArea('This may take a while . . .')
        self._tab1_feedback_ta.setEditable(False)
        self._tab1_feedback_sp = JScrollPane(self._tab1_feedback_ta)

        self._tab1_minsize = JSlider(4, 16, 6)
        self._tab1_minsize.setMajorTickSpacing(1)
        self._tab1_minsize.setPaintLabels(True)

        self._tab1_maxsize = JSlider(4, 16, 10)
        self._tab1_maxsize.setMajorTickSpacing(1)
        self._tab1_maxsize.setPaintLabels(True)

        self._tab1_specialchars = JTextField('!,@,#,$,&,*')
        self._tab1_transformations = JCheckBox('1337 mode')
        self._tab1_firstcapital = JCheckBox('first capital letter')

        # Campos del sub-tab 2 (redirect)
        self._tab2_JTFa = JTextField()
        self._tab2_JTFaa = JTextField()
        self._tab2_JTFb = JTextField()
        self._tab2_JTFbb = JTextField()
        self._tab2_boton = JButton(' Redirect is Off ',
                                   actionPerformed=self.switch_redirect)
        self._tab2_boton.background = Color.lightGray
        self._tab2_encendido = False

        # Campos del sub-tab 3 (loader)
        self._tab3_urls_ta = JTextArea(15, 5)
        self._tab3_urls_sp = JScrollPane(self._tab3_urls_ta)

        # Campos del sub-tab 4 (headers)
        self._tab4_tabla_model = DefaultTableModel()
        self._tab4_headers_dict = {}

        # Campos del sub-tab 5 (reverse ip)
        self._tab5_target = JTextArea(15, 5)
        self._tab5_target_sp = JScrollPane(self._tab5_target)

    def create(self):

        # Estilo general para todas las sub-tab.
        gBC = GridBagConstraints()
        gBC.fill = GridBagConstraints.BOTH
        gBC.ipadx = 5
        gBC.ipady = 5
        gBC.insets = Insets(0, 5, 5, 5)
        gBC.weightx = 0.5
        #gBC.weighty = 0.7

        #######################################
        ###   Creamos la primera sub-tab. (MASHUP)
        #######################################
        tab_1 = JPanel(GridBagLayout())
        tab_1_jlabelAyuda = JLabel(
            '<html><i>&#8226Tip: This Mashup receive one or more keywords in order to generate a list of possible passwords</i></html>'
        )
        tab_1_jlabelAyuda.setFont(Font("Serif", 0, 12))

        gBC.gridx = 0
        gBC.gridy = 0
        tab_1.add(
            JLabel('<html><font color=green><i>Income:</i></font></html>'),
            gBC)

        gBC.gridy = 1
        tab_1.add(JLabel('<html><b>&#8226 Name:</b></html>'), gBC)
        gBC.gridy = 2
        tab_1.add(self._tab1_nombre, gBC)

        gBC.gridy = 3
        tab_1.add(JLabel('<html><b>&#8226 Surname:</b></html>'), gBC)
        gBC.gridy = 4
        tab_1.add(self._tab1_apellido, gBC)

        gBC.gridy = 5
        tab_1.add(JLabel('<html><b>&#8226 Birthdate: (DDMMYYYY)</b></html>'),
                  gBC)
        gBC.gridy = 6
        tab_1.add(self._tab1_FNacimiento, gBC)

        gBC.gridy = 7
        tab_1.add(JLabel('<html><b>&#8226 Pet:</b></html>'), gBC)
        gBC.gridy = 8
        tab_1.add(self._tab1_mascota, gBC)

        gBC.gridy = 9
        tab_1.add(JLabel('<html><b>&#8226 Anyother:</b></html>'), gBC)
        gBC.gridy = 10
        tab_1.add(self._tab1_otro, gBC)

        gBC.gridy = 11
        tab_1.add(JLabel('<html><b>&#8226 Passwd Min Size:</b></html>'), gBC)
        gBC.gridy = 12
        tab_1.add(self._tab1_minsize, gBC)

        gBC.gridy = 13
        tab_1.add(JLabel('<html><b>&#8226 Passwd Max Size:</b></html>'), gBC)
        gBC.gridy = 14
        tab_1.add(self._tab1_maxsize, gBC)

        gBC.gridy = 15
        tab_1.add(
            JLabel(
                '<html><b>&#8226 Especial Chars: (comma separated)</b></html>'
            ), gBC)
        gBC.gridy = 16
        tab_1.add(self._tab1_specialchars, gBC)

        gBC.gridy = 17
        tab_1.add(self._tab1_transformations, gBC)

        gBC.gridy = 18
        tab_1.add(self._tab1_firstcapital, gBC)

        gBC.gridy = 19
        tab_1.add(JButton('Mashup!', actionPerformed=self.mashup), gBC)

        gBC.gridy = 20
        gBC.gridwidth = 3
        tab_1.add(JSeparator(), gBC)
        gBC.gridwidth = 1

        gBC.gridy = 21
        gBC.gridwidth = 3
        tab_1.add(tab_1_jlabelAyuda, gBC)
        gBC.gridwidth = 1

        gBC.gridx = 1
        gBC.gridy = 0
        gBC.gridheight = 20
        gBC.weightx = 0
        tab_1.add(JSeparator(SwingConstants.VERTICAL), gBC)
        gBC.gridheight = 1
        gBC.weightx = 0.5

        gBC.gridx = 2
        gBC.gridy = 0
        tab_1.add(
            JLabel('<html><font color=green><i>Outcome:</i></font></html>'),
            gBC)

        gBC.gridy = 1
        gBC.gridwidth = 2
        gBC.gridheight = 18
        tab_1.add(self._tab1_feedback_sp, gBC)
        gBC.gridwidth = 1
        gBC.gridheight = 1

        gBC.gridy = 19
        tab_1.add(
            JButton('Copy to clipboard!', actionPerformed=self.cpy_clipboard),
            gBC)

        #######################################
        ###   Creamos la segunda sub-tab. (REDIRECT)
        #######################################
        tab_2 = JPanel(GridBagLayout())
        tab_2_jlabelAyuda = JLabel(
            '<html><i>&#8226Tip: This Redirect receive a pair of hosts x,y in order to redirect from x to y.</i></html>'
        )
        tab_2_jlabelAyuda.setFont(Font("Serif", 0, 12))

        gBC.gridx = 0
        gBC.gridy = 0
        tab_2.add(
            JLabel('<html><b>&#8226 From: (i.e. www.facebook.com)</b></html>'),
            gBC)
        gBC.gridx = 1
        gBC.gridy = 0
        tab_2.add(self._tab2_JTFa, gBC)

        gBC.gridx = 2
        gBC.gridy = 0
        tab_2.add(
            JLabel('<html><b>&#8226 To: (i.e. www.myhomepage.es)</b></html>'),
            gBC)
        gBC.gridx = 3
        gBC.gridy = 0
        tab_2.add(self._tab2_JTFaa, gBC)

        gBC.gridx = 0
        gBC.gridy = 1
        gBC.gridwidth = 4
        tab_2.add(JSeparator(), gBC)
        gBC.gridwidth = 1

        gBC.gridx = 0
        gBC.gridy = 2
        tab_2.add(JLabel('<html><b>&#8226 From:</b></html>'), gBC)
        gBC.gridx = 1
        gBC.gridy = 2
        tab_2.add(self._tab2_JTFb, gBC)

        gBC.gridx = 2
        gBC.gridy = 2
        tab_2.add(JLabel('<html><b>&#8226 To:</b></html>'), gBC)
        gBC.gridx = 3
        gBC.gridy = 2
        tab_2.add(self._tab2_JTFbb, gBC)

        gBC.gridx = 0
        gBC.gridy = 3
        gBC.gridwidth = 4
        tab_2.add(self._tab2_boton, gBC)
        gBC.gridwidth = 1

        gBC.gridx = 0
        gBC.gridy = 4
        gBC.gridwidth = 4
        gBC.insets = Insets(100, 10, 5, 10)
        tab_2.add(JSeparator(), gBC)
        gBC.gridwidth = 1
        gBC.insets = Insets(5, 10, 5, 10)

        gBC.gridx = 0
        gBC.gridy = 5
        gBC.gridwidth = 4
        tab_2.add(tab_2_jlabelAyuda, gBC)
        gBC.gridwidth = 1

        #######################################
        ###   Creamos la tercera sub-tab. (LOADER)
        #######################################
        tab_3 = JPanel(GridBagLayout())
        tab_3_jlabelAyuda = JLabel(
            '<html><i>&#8226Tip: This Loader receive a list of Hosts or IPs that will be added to the Burp Scope.</i></html>'
        )
        tab_3_jlabelAyuda.setFont(Font("Serif", 0, 12))

        gBC.gridx = 0
        gBC.gridy = 0
        tab_3.add(
            JLabel(
                '<html><font color=green><i>List of targets: (i.e. http://www.mytargetweb.com)</i></font></html>'
            ), gBC)
        gBC.gridy = 1
        gBC.gridheight = 10
        gBC.weighty = 0.5
        tab_3.add(self._tab3_urls_sp, gBC)
        gBC.gridheight = 1
        gBC.weighty = 0
        gBC.gridy = 11
        tab_3.add(
            JButton('Load Into Target => Scope!', actionPerformed=self.loader),
            gBC)

        gBC.gridy = 12
        gBC.gridwidth = 5
        gBC.insets = Insets(100, 10, 5, 10)
        tab_3.add(JSeparator(), gBC)
        gBC.gridwidth = 1
        gBC.insets = Insets(5, 10, 5, 10)

        gBC.gridy = 13
        tab_3.add(tab_3_jlabelAyuda, gBC)

        #######################################
        ###   Creamos la cuarta sub-tab. (HEADERS)
        #######################################
        tab_4_jlabelAyuda = JLabel(
            "<html><i>&#8226Tip: This Headers records all unique headers that appear in every host, check out the security headers.</i></html>"
        )
        tab_4_jlabelAyuda.setFont(Font("Serif", 0, 12))

        tab_4_jLabelRecomendacion = JLabel(
            "<html>&#8226<b>Server</b>: Don't give away much information.<br> &#8226<b>Content-Security-Policy</b>: Protect your site from XSS attacks by whitelisting sources of approved content.<br> &#8226<b>Strict-Transport-Security</b>: Enforce the browser to use HTTPS.<br> &#8226<b>Public-Key-Pins</b>: Protect your site from MITM attacks.<br> &#8226<b>X-Content-Type-Options</b>: the valid value is -> nosniff .<br> &#8226<b>X-Frame-Options</b>: tells the browser whether you want to allow your site to be framed or not.<br> &#8226<b>X-XSS-Protection</b>: the best value is -> 1; mode=block .</html>"
        )
        tab_4_jLabelRecomendacion.setFont(Font("Dialog", 0, 13))

        tab_4 = JPanel(GridBagLayout())
        splitpane = JSplitPane(JSplitPane.VERTICAL_SPLIT)
        tab_4_top = JPanel(GridBagLayout())
        tab_4_bottom = JPanel(GridBagLayout())

        gBC_table = GridBagConstraints()
        gBC_table.fill = GridBagConstraints.BOTH
        gBC_table.ipadx = 5
        gBC_table.ipady = 5
        gBC_table.insets = Insets(5, 10, 5, 10)
        gBC_table.weightx = 1
        gBC_table.weighty = 1

        tabla_datos = []
        tabla_headers = ('Severity', 'Header', 'Value', 'Host')
        self._tab4_tabla_model = DefaultTableModel(tabla_datos, tabla_headers)
        tabla_ej = JTable(self._tab4_tabla_model)
        tabla_example = JScrollPane(tabla_ej,
                                    JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)

        gBC_table.gridx = 0
        gBC_table.gridy = 0
        gBC_table.gridheight = 5
        tab_4_top.add(tabla_example, gBC_table)
        gBC_table.gridheight = 1

        gBC_table.weightx = 0.5
        gBC_table.weighty = 0
        gBC_table.gridwidth = 2
        gBC_table.gridx = 0
        gBC_table.gridy = 0
        tab_4_bottom.add(JSeparator(), gBC_table)
        gBC_table.gridy = 1
        tab_4_bottom.add(tab_4_jlabelAyuda, gBC_table)
        gBC_table.gridy = 2
        tab_4_bottom.add(tab_4_jLabelRecomendacion, gBC_table)

        splitpane.setTopComponent(tab_4_top)
        splitpane.setBottomComponent(tab_4_bottom)
        gBC_table.weightx = 1
        gBC_table.weighty = 1
        gBC_table.gridx = 0
        gBC_table.gridy = 0
        tab_4.add(splitpane, gBC_table)

        #######################################
        ###   Creamos la quinta sub-tab. (ACTIVE SCAN)
        #######################################
        tab_5 = JPanel(GridBagLayout())
        tab_5_jlabelAyuda = JLabel(
            '<html><i>&#8226Tip: This Quick Scan receive a list of targets and launch an active scan.</i></html>'
        )
        tab_5_jlabelAyuda.setFont(Font("Serif", 0, 12))
        tab_5_jlabelWarning = JLabel(
            '<html><font color=red><i>&#8226Warning: Active scanning generates large numbers of requests which are malicious in form and which may result in compromise of the application. You should use this scanning mode with caution, only with the explicit permission of the application owner. For more information, read the documentation of active scan, Burp Suite.</font></i></html>'
        )
        tab_5_jlabelWarning.setFont(Font("Dialog", 0, 13))

        gBC.gridx = 0
        gBC.gridy = 0
        tab_5.add(
            JLabel(
                '<html><font color=green><i>List of targets: (i.e. http://192.168.1.1/index.html)</i></font></html>'
            ), gBC)
        gBC.gridy = 1
        gBC.gridheight = 8
        gBC.weighty = 0.5
        tab_5.add(self._tab5_target_sp, gBC)
        gBC.gridheight = 1
        gBC.weighty = 0
        gBC.gridy = 9
        tab_5.add(JButton('Launch Scan!', actionPerformed=self.do_active_scan),
                  gBC)

        gBC.gridy = 10
        gBC.gridwidth = 5
        gBC.insets = Insets(100, 10, 5, 10)
        tab_5.add(JSeparator(), gBC)
        gBC.gridwidth = 1
        gBC.insets = Insets(5, 10, 5, 10)

        gBC.gridy = 11
        tab_5.add(tab_5_jlabelAyuda, gBC)
        gBC.gridy = 12
        tab_5.add(tab_5_jlabelWarning, gBC)

        #######################################
        ###   Creamos la ultima sub-tab.
        #######################################
        tab_about = JPanel(GridBagLayout())

        gBC_about = GridBagConstraints()
        gBC_about.fill = GridBagConstraints.HORIZONTAL
        gBC_about.ipadx = 5
        gBC_about.ipady = 5
        gBC_about.insets = Insets(5, 10, 5, 10)
        gBC_about.weightx = 1
        gBC_about.weighty = 1

        Jlabel1 = JLabel('<html><b>Plug-in L-Tools</b></html>')
        Jlabel1.setFont(Font("Dialog", 1, 18))
        jlabel2 = JLabel(
            '<html>This Plug-in provides utilities for pentesters, researchers and developers, in order to support their work.</html>'
        )
        jlabel3 = JLabel('<html><b>CC-BY 4.0, 2017. Gino Angles</b></html>')
        jlabel3.setFont(Font("Dialog", 1, 14))
        jlabel4 = JLabel('<html><b>License</b></html>')
        jlabel4.setFont(Font("Dialog", 1, 14))
        jlabel5 = JLabel(
            '<html><img alt="Licensed under a Creative Commons BY" style="border-width:0" src="https://licensebuttons.net/l/by/4.0/88x31.png"></html>'
        )
        jlabel6 = JLabel(
            '<html>This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.</html>'
        )
        jlabel7 = JLabel('<html><b>Dependencies</b></html>')
        jlabel7.setFont(Font("Dialog", 1, 14))
        jlabel8 = JLabel('Jython +2.7')
        jlabel9 = JLabel('http://www.jython.org')

        gBC_about.gridx = 0
        gBC_about.gridy = 0
        tab_about.add(Jlabel1, gBC_about)
        gBC_about.gridy = 1
        tab_about.add(jlabel2, gBC_about)
        gBC_about.gridy = 2
        tab_about.add(jlabel3, gBC_about)

        gBC_about.gridy = 3
        gBC_about.gridwidth = 5
        tab_about.add(JSeparator(), gBC_about)
        gBC_about.gridwidth = 1

        gBC_about.gridy = 4
        tab_about.add(jlabel4, gBC_about)
        gBC_about.gridy = 5
        tab_about.add(jlabel5, gBC_about)
        gBC_about.gridy = 6
        tab_about.add(jlabel6, gBC_about)

        gBC_about.gridy = 7
        gBC_about.gridwidth = 5
        tab_about.add(JSeparator(), gBC_about)
        gBC_about.gridwidth = 1

        gBC_about.gridy = 8
        tab_about.add(jlabel7, gBC_about)
        gBC_about.gridy = 9
        tab_about.add(jlabel8, gBC_about)
        gBC_about.gridy = 10
        tab_about.add(jlabel9, gBC_about)

        # Añadimos los sub-tab al contenedor y lo devolvemos.
        self.contenedor.addTab('Mashup', tab_1)
        self.contenedor.addTab('Redirect', tab_2)
        self.contenedor.addTab('Loader', tab_3)
        self.contenedor.addTab('Headers', tab_4)
        self.contenedor.addTab('Quick Scan', tab_5)
        self.contenedor.addTab('About', tab_about)

        return self.contenedor

    # Funcion que copia el contenido de texto al clipboard.
    def cpy_clipboard(self, event):
        toolkit = Toolkit.getDefaultToolkit()
        clipboard = toolkit.getSystemClipboard()
        clipboard.setContents(StringSelection(self._tab1_feedback_ta.text),
                              None)
        JOptionPane.showMessageDialog(self.contenedor,
                                      "Output copied to clipboard",
                                      "Information",
                                      JOptionPane.INFORMATION_MESSAGE)
        return

    # Funcion que instancia la clase Masher() y hace el mashup del sub-tab1 (mashup).
    def mashup(self, event):
        if self._tab1_minsize.value > self._tab1_maxsize.value:
            self._callbacks.issueAlert(
                'Mashup=> min size have to be bigger than max size.')
        else:
            estado_JCH_trans = self._tab1_transformations.isSelected()
            especial_chars = self._tab1_specialchars.text.split(",")
            mymash = Masher(self._tab1_minsize.value, self._tab1_maxsize.value,
                            especial_chars, estado_JCH_trans)
            reverse_name = self._tab1_nombre.text[::-1]
            if self._tab1_firstcapital.isSelected():
                lista_palabras = [
                    self._tab1_nombre.text.title(),
                    self._tab1_apellido.text.title(),
                    self._tab1_FNacimiento.text,
                    self._tab1_mascota.text.title(),
                    self._tab1_otro.text.title(),
                    reverse_name.title()
                ]
            else:
                lista_palabras = [
                    self._tab1_nombre.text, self._tab1_apellido.text,
                    self._tab1_FNacimiento.text, self._tab1_mascota.text,
                    self._tab1_otro.text, reverse_name
                ]

            while "" in lista_palabras:
                lista_palabras.remove("")
            rdo_rdo = mymash.mashup(lista_palabras,
                                    self._tab1_FNacimiento.text)
            self._tab1_feedback_ta.text = "\n".join(rdo_rdo)
        return

    # Funcion que activa/desactiva el redirect.
    def switch_redirect(self, event):
        if not self._tab2_encendido:
            self._tab2_boton.text = ' Redirect is On '
            self._tab2_boton.background = Color.gray
            self._tab2_encendido = True
            # Registramos la instancia del escuchador http.
            self._callbacks.registerHttpListener(self)
        else:
            self._tab2_boton.text = ' Redirect is Off '
            self._tab2_boton.background = Color.lightGray
            self._tab2_encendido = False
            # Borramos la instancia del escuchador http.
            self._callbacks.removeHttpListener(self)
        return

    # @override
    def processHttpMessage(self, toolFlag, messageIsRequest, messageInfo):
        if messageIsRequest and self._tab2_encendido:
            serviceHttp = messageInfo.getHttpService()
            if messageInfo.getHttpService().getHost() == self._tab2_JTFa.text:
                if self._tab2_JTFaa.text == '':
                    self._tab2_JTFaa.text = 'localhost'
                messageInfo.setHttpService(
                    self._helpers.buildHttpService(self._tab2_JTFaa.text,
                                                   serviceHttp.getPort(),
                                                   serviceHttp.getProtocol()))
            elif messageInfo.getHttpService().getHost(
            ) == self._tab2_JTFb.text:
                if self._tab2_JTFbb.text == '':
                    self._tab2_JTFbb.text = 'localhost'
                messageInfo.setHttpService(
                    self._helpers.buildHttpService(self._tab2_JTFbb.text,
                                                   serviceHttp.getPort(),
                                                   serviceHttp.getProtocol()))
        return

    # Funcion que carga el textArea de URL a Scope.
    def loader(self, event):
        lista_url = self._tab3_urls_ta.text.split("\n")
        for newUrl in lista_url:
            self._callbacks.includeInScope(URL(newUrl))
        return

    # @override
    def doPassiveScan(self, request_response):
        _response = request_response.getResponse()
        _request = request_response.getRequest()
        _httpService = request_response.getHttpService()
        _url = request_response.getHttpService().getHost()
        info_response = self._helpers.analyzeResponse(_response)
        info_request = self._helpers.analyzeRequest(_httpService, _request)
        headers = info_response.getHeaders()
        _fullUrl = info_request.getUrl().toString()

        for head in headers:
            head_w1 = head.split("\n")
            for head_w2 in head_w1:
                head_w3 = head_w2.split(":")
                if len(head_w3) > 1:
                    head_w3[0].encode('ascii', 'ignore')
                    head_w3[1].encode('ascii', 'ignore')

                    key = "%s-%s" % (_url, head_w3[0])

                    if key not in self._tab4_headers_dict:
                        critical = self.analizeHeader(head_w3[0])

                        fila_tabla = [
                            critical, head_w3[0], head_w3[1], _fullUrl
                        ]

                        self._tab4_headers_dict[key] = fila_tabla
                        self._tab4_tabla_model.addRow(fila_tabla)
        return

    # devuelve cuan importante es la cabecera HTTP.
    def analizeHeader(self, header):
        if header == "Content-Security-Policy":
            return "High"
        elif header == "X-Content-Type-Options":
            return "High"
        elif header == "X-Frame-Options":
            return "High"
        elif header == "X-XSS-Protection":
            return "High"
        elif header == "Strict-Transport-Security":
            return "High"
        elif header == "Public-Key-Pins":
            return "High"
        elif header == "Access-Control-Allow-Origin":
            return "High"
        elif header == "X-Permitted-Cross-Domain-Policies":
            return "High"
        elif header == "X-Powered-By":
            return "Information"
        elif header == "Server":
            return "Information"
        elif header == "Referrer-Policy":
            return "Medium"
        else:
            return " "

    # realiza un escaner al host/s apuntado.
    def do_active_scan(self, event):
        _lista_urls = self._tab5_target.text.split("\n")
        for _x_url in _lista_urls:
            _target_url = URL(_x_url)
            _target_request = self._helpers.buildHttpRequest(_target_url)

            _host = _target_url.getHost()
            _port = _target_url.getDefaultPort()
            _isHttps = True if _target_url.getProtocol() == "https" else False

            try:
                self._callbacks.doActiveScan(_host, _port, _isHttps,
                                             _target_request)
            except:
                pass
        return
示例#4
0
class FEA_ConfigPanel(JPanel):
    numThreads = 8
    generateXLS = True
    generateCSV = True
    doNSLookup = True
    doWBLookup = True
    cbNSLookup = None
    cbGenerateExcel = None
    cbGenerateCSV = None
    cbWayback = None

    def __init__(self):

        self.initComponents()

        # get previous settings selected by the user
        if (ModuleSettings.getConfigSetting("FEA", "doNSLookup") != None) and (
                ModuleSettings.getConfigSetting("FEA", "doNSLookup") != ""):
            if ModuleSettings.getConfigSetting("FEA", "doNSLookup"):
                self.cbNSLookup.setSelected(True)
                self.doNSLookup = True
            else:
                self.cbNSLookup.setSelected(False)
                self.doNSLookup = False

        if (ModuleSettings.getConfigSetting("FEA", "generateCSV") !=
                None) and (ModuleSettings.getConfigSetting(
                    "FEA", "generateCSV") != ""):
            if ModuleSettings.getConfigSetting("FEA", "generateCSV"):
                self.cbGenerateCSV.setSelected(True)
                self.generateCSV = True
            else:
                self.cbGenerateCSV.setSelected(False)
                self.generateCSV = False
        if (ModuleSettings.getConfigSetting("FEA", "generateXLS") !=
                None) and (ModuleSettings.getConfigSetting(
                    "FEA", "generateXLS") != ""):
            if ModuleSettings.getConfigSetting("FEA", "generateXLS"):
                self.cbGenerateExcel.setSelected(True)
                self.generateXLS = True
            else:
                self.cbGenerateExcel.setSelected(False)
                self.generateXLS = False
        if (ModuleSettings.getConfigSetting("FEA", "numThreads") != None) and (
                ModuleSettings.getConfigSetting("FEA", "numThreads") != ""):
            self.numThreads = ModuleSettings.getConfigSetting(
                "FEA", "numThreads")
            self.numberThreadsSlider.setValue(self.numThreads)
        else:
            self.numThreads = self.numberThreadsSlider.getValue()

    def addStatusLabel(self, msg):
        gbc = GridBagConstraints()
        gbc.anchor = GridBagConstraints.NORTHWEST
        gbc.gridx = 0
        gbc.gridy = 7
        lab = JLabel(msg)
        self.add(lab, gbc)

    def getDoNSLookup(self):
        return self.doNSLookup

    def getGenerateCSV(self):
        return self.generateCSV

    def getGenerateXLS(self):
        return self.generateXLS

    def getDoWBLookup(self):
        return self.doWBLookup

    def getNumThreads(self):
        return self.numThreads

    def initComponents(self):
        self.setLayout(GridBagLayout())

        gbc = GridBagConstraints()
        gbc.anchor = GridBagConstraints.NORTHWEST
        gbc.gridx = 0
        gbc.gridy = 0

        descriptionLabel = JLabel("FEA - Forensics Email Analysis")
        self.add(descriptionLabel, gbc)

        gbc.gridy = 1
        self.cbNSLookup = JCheckBox(
            "Perform DNS Lookup on email domains",
            actionPerformed=self.cbNSLookupActionPerformed)
        self.cbNSLookup.setSelected(True)
        self.add(self.cbNSLookup, gbc)

        # TODO: include option to browse for text file with list of emails to exclude from analysis

        numberThreadsLabel = JLabel(
            "Maximum number of threads for DNS Lookup task: ")
        gbc.gridy = 2
        self.add(numberThreadsLabel, gbc)

        self.numberThreadsSlider = JSlider(
            JSlider.HORIZONTAL,
            1,
            16,
            8,
            stateChanged=self.sliderActionPerformed)
        self.numberThreadsSlider.setMajorTickSpacing(1)
        self.numberThreadsSlider.setPaintLabels(True)
        self.numberThreadsSlider.setPaintTicks(True)
        self.numberThreadsSlider.setSnapToTicks(True)
        self.numberThreadsSlider.setToolTipText(
            "set maximum number of concurrent threads when performing DNS lookup on email domains"
        )

        gbc.gridy = 5
        gbc.gridwidth = 15
        gbc.gridheight = 1
        gbc.fill = GridBagConstraints.BOTH
        gbc.weightx = 0
        gbc.weighty = 0
        gbc.anchor = GridBagConstraints.NORTHWEST
        gbc.gridy = 3
        self.add(self.numberThreadsSlider, gbc)

        self.cbGenerateExcel = JCheckBox(
            "Generate Excel format report (more detailed)",
            actionPerformed=self.cbGenerateExcelActionPerformed)
        self.cbGenerateExcel.setSelected(True)
        gbc.gridy = 4
        self.add(self.cbGenerateExcel, gbc)

        self.cbGenerateCSV = JCheckBox(
            "Generate CSV format report (plaintext)",
            actionPerformed=self.cbGenerateCSVActionPerformed)
        self.cbGenerateCSV.setSelected(True)
        gbc.gridy = 5
        self.add(self.cbGenerateCSV, gbc)

        gbc.gridy = 6
        self.cbWayback = JCheckBox(
            "Perform Wayback Machine Lookup on email domains (WARNING: can be a slow process!)",
            actionPerformed=self.cbWaybackActionPerformed)
        self.cbWayback.setSelected(True)
        self.add(self.cbWayback, gbc)

    def cbWaybackActionPerformed(self, event):
        source = event.getSource()
        if (source.isSelected()):
            ModuleSettings.setConfigSetting("FEA", "doWBLookup", "true")
            self.doWBLookup = True
        else:
            ModuleSettings.setConfigSetting("FEA", "doNSLookup", "false")
            self.doWBLookup = False

    def cbNSLookupActionPerformed(self, event):
        source = event.getSource()
        if (source.isSelected()):
            ModuleSettings.setConfigSetting("FEA", "doNSLookup", "true")
            self.doNSLookup = True
            self.cbWayback.setEnabled(True)
        else:
            ModuleSettings.setConfigSetting("FEA", "doNSLookup", "false")
            self.doNSLookup = False
            self.cbWayback.setSelected(False)
            self.cbWayback.setEnabled(False)
            self.doWBLookup = False

    def cbGenerateExcelActionPerformed(self, event):
        source = event.getSource()
        if (source.isSelected()):
            ModuleSettings.setConfigSetting("FEA", "generateXLS", "true")
            self.generateXLS = True
        else:
            ModuleSettings.setConfigSetting("FEA", "generateXLS", "false")
            self.generateXLS = False

    def cbGenerateCSVActionPerformed(self, event):
        source = event.getSource()
        if (source.isSelected()):
            ModuleSettings.setConfigSetting("FEA", "generateCSV", "true")
            self.generateCSV = True
        else:
            ModuleSettings.setConfigSetting("FEA", "generateCSV", "false")
            self.generateCSV = False

    def sliderActionPerformed(self, event):
        source = event.getSource()
        self.numThreads = source.getValue()
        ModuleSettings.setConfigSetting("FEA", "numThreads", self.numThreads)
        self.addStatusLabel("number of threads set: " + str(self.numThreads))
示例#5
0
class VadCheckModuleSettingsPanel(IngestModuleIngestJobSettingsPanel):
    # Note, we can't use a self.settings instance variable.
    # Rather, self.local_settings is used.
    # https://wiki.python.org/jython/UserGuide#javabean-properties
    # Jython Introspector generates a property - 'settings' on the basis
    # of getSettings() defined in this class. Since only getter function
    # is present, it creates a read-only 'settings' property. This auto-
    # generated read-only property overshadows the instance-variable -
    # 'settings'

    # We get passed in a previous version of the settings so that we can
    # prepopulate the UI
    # TODO: Update this for your UI
    def __init__(self, settings):
        #print("init: " + settings.getSetting("runVadTranscriber") + " " + settings.getSetting("minPercVoiced") + " " + settings.getSetting("minTotalVoiced"))
        #print("init local_settings: " + self.local_settings.getSetting("vadAggressivness") + " " + self.local_settings.getSetting("minPercVoiced") + " " + self.local_settings.getSetting("minTotalVoiced"))
        self.local_settings = GenericIngestModuleJobSettings()
        #initComponents will initialize sliders which will call lambdas for updating settings using current values in sliders
        #which would overwrite settings.
        self.initComponents()
        #print("init local_settings 2: " + self.local_settings.getSetting("vadAggressivness") + " " + self.local_settings.getSetting("minPercVoiced") + " " + self.local_settings.getSetting("minTotalVoiced"))
        #now safe to set settings
        self.local_settings = settings
        #print("init 2: " + self.local_settings.getSetting("runVadTranscriber") + " " + self.local_settings.getSetting("minPercVoiced") + " " + self.local_settings.getSetting("minTotalVoiced"))
        self.customizeComponents()
    
    _logger = Logger.getLogger(VadCheckModuleFactory.moduleName)

    def log(self, level, msg):
        self._logger.logp(level, self.__class__.__name__, inspect.stack()[1][3], msg)

    # def makeGuiCallback(self, key, guiGetAction):
    #     def callback(event):
    #         #self.log(Level.INFO, "setting key = " + key + " val =" + str(event.getSource().getValue()))
    #         value = str(guiGetAction(event.getSource()))
    #         print("setting key = " + key + " val =" + value)
    #         self.local_settings.setSetting(key, value)
    #         print("test in settings key = " + key + " val =" + self.local_settings.getSetting(key))
    #     return callback    

    def initComponents(self):
        #print("initComponents 1: " + self.local_settings.getSetting("vadAggressivness") + " " + self.local_settings.getSetting("minPercVoiced") + " " + self.local_settings.getSetting("minTotalVoiced"))
        self.setLayout(BoxLayout(self, BoxLayout.Y_AXIS))

        self.label2 = JLabel()
        self.label2.setText("Minimum percentage of segments with speech")
        self.label3 = JLabel()
        self.label3.setText("Minimum total duration of segment with speech (s)")

        #sliderGetAction = lambda slider: slider.getValue()
        self.minPercVoiced = JSlider()#stateChanged=self.makeGuiCallback("minPercVoiced", sliderGetAction))
        self.minPercVoiced.setMajorTickSpacing(20)
        self.minPercVoiced.setMinorTickSpacing(5)
        self.minPercVoiced.setPaintLabels(True)
        self.minPercVoiced.setPaintTicks(True)

        self.minTotalVoiced = JSlider()#stateChanged=self.makeGuiCallback("minTotalVoiced", sliderGetAction))
        self.minTotalVoiced.setMajorTickSpacing(60)
        self.minTotalVoiced.setMaximum(180)
        self.minTotalVoiced.setMinorTickSpacing(10)
        self.minTotalVoiced.setPaintLabels(True)
        self.minTotalVoiced.setPaintTicks(True)
        #print("initComponents 2: " + self.local_settings.getSetting("vadAggressivness") + " " + self.local_settings.getSetting("minPercVoiced") + " " + self.local_settings.getSetting("minTotalVoiced"))

        #checkboxGetAction = lambda checkbox: checkbox.isSelected()
        self.runVadTranscriber = JCheckBox("Transcribe files with speech detected ? (slow)")#,
            #actionPerformed=self.makeGuiCallback("runVadTranscriber", checkboxGetAction))
        self.showTextSegmentStartTime = JCheckBox("Show text segment start time ?")

        self.add(self.label2)
        self.add(self.minPercVoiced)
        self.add(self.label3)
        self.add(self.minTotalVoiced)
        self.add(self.showTextSegmentStartTime)
        self.add(self.runVadTranscriber)

        self.vadTranscriberLanguage = makeLanguageSelectionComboBox(self, "english")
        #this is needed because of https://bugs.jython.org/issue1749824
        #class ComboActionListener(ActionListener):
        #    def actionPerformed(self, e):
        #        value = e.getSource().getSelectedItem()
        #        self.local_settings.setSetting(key, value)

        #self.vadTranscriberLanguage.actionListener = ComboActionListener()

    #local_settings is of type https://github.com/sleuthkit/autopsy/blob/bbdea786db487c781edf2cf9032a2ba3166e97e0/Core/src/org/sleuthkit/autopsy/ingest/GenericIngestModuleJobSettings.java
    def customizeComponents(self):
        def setValue(key, default, stringToPythonObj, guiSetAction):
            string = self.local_settings.getSetting(key)
            #print("customizeComponents " + key + " stored value was " + str(string))
            #print("string is None " + str(string is None) + " stringToPythonObj(string) " + str(stringToPythonObj(string)))
            checkedValue = default if string is None else stringToPythonObj(string)
            obj = getattr(self, key)
            guiSetAction(obj, checkedValue)
            #self.log(Level.INFO, "setValue for key " + key + " " + str(checkedValue))
        
        sliderSetAction = lambda obj, val: obj.setValue(val)
        checkBoxSetAction = lambda obj, val: obj.setSelected(val)
        comboBoxSetAction = lambda obj, val: obj.setSelectedItem(val)

        setValue("minPercVoiced", minPercVoicedDefault, int, sliderSetAction)
        setValue("minTotalVoiced", minTotalVoicedDefault, int, sliderSetAction)
        setValue("runVadTranscriber", runVadTranscriberDefault, eval, checkBoxSetAction)
        setValue("showTextSegmentStartTime", showTextSegmentStartTimeDefault, eval, checkBoxSetAction)
        setValue("vadTranscriberLanguage", runVadTranscriberDefault, lambda x: x, comboBoxSetAction)

    # Return the settings used
    #note: exceptions thrown here will be caught and not logged.
    def getSettings(self):
        #print("getSettings: " + self.local_settings.getSetting("runVadTranscriber") + " " + self.local_settings.getSetting("minPercVoiced") + " " + self.local_settings.getSetting("minTotalVoiced"))
        
        self.local_settings.setSetting("minPercVoiced", str(self.minPercVoiced.getValue()))
        self.local_settings.setSetting("minTotalVoiced", str(self.minTotalVoiced.getValue()))
        self.local_settings.setSetting("runVadTranscriber", str(self.runVadTranscriber.isSelected()))
        self.local_settings.setSetting("showTextSegmentStartTime", str(self.showTextSegmentStartTime.isSelected()))
        self.local_settings.setSetting("vadTranscriberLanguage", str(self.vadTranscriberLanguage.getSelectedItem()))
 
        return self.local_settings
示例#6
0
        self.view = view

    def stateChanged(self, evt):
        s = evt.getSource()
        self.view.update(s.getValue())


frame = JFrame("Mesh taken from " + xmlDir + "* directories")
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
canvas = MyView(xmlDir)
frame.add(canvas, BorderLayout.CENTER)

jSlider1 = JSlider()
jSlider1.setValue(0)
jSlider1.setMaximum(canvas.getMaxIndex())
jSlider1.setPaintLabels(True)
jSlider1.addChangeListener(SliderListener(canvas))
frame.add(jSlider1, BorderLayout.SOUTH)

frame.setSize(800, 600)
frame.setVisible(True)


class MyKeyListener(KeyListener):
    def __init__(self, view, slider):
        self.view = view
        self.slider = slider

    def keyTyped(self, e):
        pass
示例#7
0
class SliderListener(ChangeListener):
	def __init__(self, view):
		self.view = view
	def stateChanged(self, evt):
		s = evt.getSource()
		self.view.update(s.getValue())

frame = JFrame("Mesh taken from "+xmlDir+"* directories")
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
canvas = MyView(xmlDir)
frame.add(canvas, BorderLayout.CENTER)

jSlider1 = JSlider()
jSlider1.setValue(0)
jSlider1.setMaximum(canvas.getMaxIndex())
jSlider1.setPaintLabels(True)
jSlider1.addChangeListener(SliderListener(canvas))
frame.add(jSlider1, BorderLayout.SOUTH)

frame.setSize(800,600)
frame.setVisible(True)

class MyKeyListener(KeyListener):
	def __init__(self, view, slider):
		self.view   = view
		self.slider = slider
	def keyTyped(self, e):
		pass
	def keyReleased(self, e):
		code = int(e.getKeyCode())
		if (code == KeyEvent.VK_SHIFT):