Ejemplo n.º 1
0
class PlasoSettingsWithUISettingsPanel(IngestModuleIngestJobSettingsPanel):
    # Note, we can't use a self.settings instance variable.
    # Rather, self.local_settings is used.
    # https://wiki.python.org/jython/UserGuide#javabean-properties
    # Jython Introspector generates a property - 'settings' on the basis
    # of getSettings() defined in this class. Since only getter function
    # is present, it creates a read-only 'settings' property. This auto-
    # generated read-only property overshadows the instance-variable -
    # 'settings'

    # We get passed in a previous version of the settings so that we can
    # prepopulate the UI
    # TODO: Update this for your UI
    def __init__(self, settings):
        self.local_settings = settings
        self.initComponents()
        self.customizeComponents()

    # Check the checkboxs to see what actions need to be taken
    def checkBoxEvent(self, event):
        if self.Exclude_File_Sources_CB.isSelected():
            self.local_settings.setSetting('Exclude_File_Sources', 'true')
        else:
            self.local_settings.setSetting('Exclude_File_Sources', 'false')

        if self.Run_Plaso_CB.isSelected():
            self.local_settings.setSetting('Run_Plaso', 'true')
        else:
            self.local_settings.setSetting('Run_Plaso', 'false')

        if self.Run_Plaso_CB.isSelected():
            self.local_settings.setSetting('Import_Plaso', 'true')
        else:
            self.local_settings.setSetting('Import_Plaso', 'false')

    # When button to find file is clicked then open dialog to find the file and return it.
    def Find_Plaso_Dir(self, e):

        chooseFile = JFileChooser()
        filter = FileNameExtensionFilter("All", ["*.*"])
        chooseFile.addChoosableFileFilter(filter)
        chooseFile.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)

        ret = chooseFile.showDialog(self.panel0, "Find Plaso Directory")

        if ret == JFileChooser.APPROVE_OPTION:
            file = chooseFile.getSelectedFile()
            Canonical_file = file.getCanonicalPath()
            #text = self.readPath(file)
            self.local_settings.setSetting('Plaso_Directory', Canonical_file)
            self.Program_Executable_TF.setText(Canonical_file)

    def Find_Plaso_File(self, e):

        chooseFile = JFileChooser()
        filter = FileNameExtensionFilter("All", ["*.*"])
        chooseFile.addChoosableFileFilter(filter)

        ret = chooseFile.showDialog(self.panel0, "Find Plaso Storage File")

        if ret == JFileChooser.APPROVE_OPTION:
            file = chooseFile.getSelectedFile()
            Canonical_file = file.getCanonicalPath()
            #text = self.readPath(file)
            self.local_settings.setSetting('Plaso_Storage_File',
                                           Canonical_file)
            self.Plaso_Storage_File_TF.setText(Canonical_file)

    def onchange_cb(self, event):
        self.local_settings.setSetting('ComboBox', event.item)

    def setPlasoDirectory(self, event):
        self.local_settings.setSetting('Plaso_Directory',
                                       self.Program_Executable_TF.getText())

    def setPlasoStorageFile(self, event):
        self.local_settings.setSetting('Plaso_Storage_File',
                                       self.Plaso_Storage_File_TF.getText())

    # Create the initial data fields/layout in the UI
    def initComponents(self):
        self.panel0 = JPanel()

        self.rbgPanel0 = ButtonGroup()
        self.gbPanel0 = GridBagLayout()
        self.gbcPanel0 = GridBagConstraints()
        self.panel0.setLayout(self.gbPanel0)

        self.Label_1 = JLabel("Plaso Executable Directory")
        self.Label_1.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 1
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_1, self.gbcPanel0)
        self.panel0.add(self.Label_1)

        self.Program_Executable_TF = JTextField(
            20, focusLost=self.setPlasoDirectory)
        self.Program_Executable_TF.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 3
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Program_Executable_TF,
                                     self.gbcPanel0)
        self.panel0.add(self.Program_Executable_TF)

        self.Find_Program_Exec_BTN = JButton(
            "Find Dir", actionPerformed=self.Find_Plaso_Dir)
        self.Find_Program_Exec_BTN.setEnabled(True)
        self.rbgPanel0.add(self.Find_Program_Exec_BTN)
        self.gbcPanel0.gridx = 6
        self.gbcPanel0.gridy = 3
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Find_Program_Exec_BTN,
                                     self.gbcPanel0)
        self.panel0.add(self.Find_Program_Exec_BTN)

        self.Blank_1 = JLabel(" ")
        self.Blank_1.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_1, self.gbcPanel0)
        self.panel0.add(self.Blank_1)

        self.Run_Plaso_CB = JCheckBox("Run Plaso Against Autopsy Image",
                                      actionPerformed=self.checkBoxEvent)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 7
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Run_Plaso_CB, self.gbcPanel0)
        self.panel0.add(self.Run_Plaso_CB)

        self.dataComboBox_CB = ("All VSS", "VSS Only", "No VSS")
        self.ComboBox_CB = JComboBox(self.dataComboBox_CB)
        self.ComboBox_CB.itemStateChanged = self.onchange_cb
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 9
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.ComboBox_CB, self.gbcPanel0)
        self.panel0.add(self.ComboBox_CB)

        self.Blank_2 = JLabel(" ")
        self.Blank_2.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 11
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_2, self.gbcPanel0)
        self.panel0.add(self.Blank_2)

        self.Import_Plaso_CB = JCheckBox("Import Plaso Storage File",
                                         actionPerformed=self.checkBoxEvent)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 13
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Import_Plaso_CB, self.gbcPanel0)
        self.panel0.add(self.Import_Plaso_CB)

        self.Label_1 = JLabel("Plaso Storage File")
        self.Label_1.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 15
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_1, self.gbcPanel0)
        self.panel0.add(self.Label_1)

        self.Plaso_Storage_File_TF = JTextField(
            20, focusLost=self.setPlasoStorageFile)
        self.Plaso_Storage_File_TF.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 17
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Plaso_Storage_File_TF,
                                     self.gbcPanel0)
        self.panel0.add(self.Plaso_Storage_File_TF)

        self.Find_Storage_BTN = JButton("Find Storage File",
                                        actionPerformed=self.Find_Plaso_File)
        self.Find_Storage_BTN.setEnabled(True)
        self.rbgPanel0.add(self.Find_Storage_BTN)
        self.gbcPanel0.gridx = 6
        self.gbcPanel0.gridy = 17
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Find_Storage_BTN, self.gbcPanel0)
        self.panel0.add(self.Find_Storage_BTN)

        self.Blank_3 = JLabel(" ")
        self.Blank_3.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 19
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_3, self.gbcPanel0)
        self.panel0.add(self.Blank_3)

        self.Exclude_File_Sources_CB = JCheckBox(
            "Exclude File Source", actionPerformed=self.checkBoxEvent)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 21
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Exclude_File_Sources_CB,
                                     self.gbcPanel0)
        self.panel0.add(self.Exclude_File_Sources_CB)

        self.Blank_4 = JLabel(" ")
        self.Blank_4.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 23
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_4, self.gbcPanel0)
        self.panel0.add(self.Blank_4)

        self.Label_3 = JLabel("Message:")
        self.Label_3.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 25
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_3, self.gbcPanel0)
        self.panel0.add(self.Label_3)

        self.Error_Message = JLabel("")
        self.Error_Message.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 27
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Error_Message, self.gbcPanel0)
        self.panel0.add(self.Error_Message)

        self.add(self.panel0)

    # Custom load any data field and initialize the values
    def customizeComponents(self):
        self.Exclude_File_Sources_CB.setSelected(
            self.local_settings.getSetting('Exclude_File_Sources') == 'true')
        self.Run_Plaso_CB.setSelected(
            self.local_settings.getSetting('Run_Plaso') == 'true')
        self.Import_Plaso_CB.setSelected(
            self.local_settings.getSetting('Import_Plaso') == 'true')
        self.Program_Executable_TF.setText(
            self.local_settings.getSetting('Plaso_Directory'))
        self.Plaso_Storage_File_TF.setText(
            self.local_settings.getSetting('Plaso_Storage_File'))

    # Return the settings used
    def getSettings(self):
        return self.local_settings
Ejemplo n.º 2
0
class TimesketchSettingsWithUISettingsPanel(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
    def __init__(self, settings):
        self.local_settings = settings
        self.tag_list = []
        self.initComponents()
        self.customizeComponents()
        self.path_to_Timesketch_exe = os.path.join(os.path.dirname(os.path.abspath(__file__)), "Timesketch_api.exe")
            
    # Check to see if the Timesketch server is available and you can talk to it
    def Check_Server(self, e):

       pipe = Popen([self.path_to_Timesketch_exe, self.Protocol_TF.getText(),self.IP_Address_TF.getText(), self.Port_Number_TF.getText(), "Timesketch_status" ], stdout=PIPE, stderr=PIPE)
        
       out_text = pipe.communicate()[0]
       self.Error_Message.setText("Timesketch Status is " + out_text)
       #self.log(Level.INFO, "Timesketch Status is ==> " + out_text)

           
    def setIPAddress(self, event):
        self.local_settings.setSetting('ipAddress', self.IP_Address_TF.getText()) 

    def setPortNumber(self, event):
        self.local_settings.setSetting('portNumber', self.Port_Number_TF.getText()) 

    def setUserName(self, event):
        self.local_settings.setSetting('userName', self.userName_TF.getText()) 

    def setPassword(self, event):
        self.local_settings.setSetting('password', self.password_TF.getText()) 

    def setsketchName(self, event):
        self.local_settings.setSetting('sketchName', self.sketchName_TF.getText()) 

    def setsketchDescription(self, event):
        self.local_settings.setSetting('sketchDescription', self.sketchDescription_TF.getText()) 

    # Create the initial data fields/layout in the UI
    def initComponents(self):
        self.panel0 = JPanel()

        self.rbgPanel0 = ButtonGroup() 
        self.gbPanel0 = GridBagLayout() 
        self.gbcPanel0 = GridBagConstraints() 
        self.panel0.setLayout( self.gbPanel0 ) 

        self.Label_2 = JLabel("Timesketch IP Address")
        self.Label_2.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 5 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_2, self.gbcPanel0 ) 
        self.panel0.add( self.Label_2 ) 

        self.IP_Address_TF = JTextField(20, focusLost=self.setIPAddress) 
        self.IP_Address_TF.setEnabled(True)
        self.gbcPanel0.gridx = 4 
        self.gbcPanel0.gridy = 5 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.IP_Address_TF, self.gbcPanel0 ) 
        self.panel0.add( self.IP_Address_TF ) 

        self.Blank_2 = JLabel( " ") 
        self.Blank_2.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 7
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_2, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_2 ) 

        self.Label_3 = JLabel("Port Number")
        self.Label_3.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 9 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_3, self.gbcPanel0 ) 
        self.panel0.add( self.Label_3 ) 

        self.Port_Number_TF = JTextField(20, focusLost=self.setPortNumber) 
        self.Port_Number_TF.setEnabled(True)
        self.gbcPanel0.gridx = 4 
        self.gbcPanel0.gridy = 9 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Port_Number_TF, self.gbcPanel0 ) 
        self.panel0.add( self.Port_Number_TF ) 

        self.Blank_3 = JLabel( " ") 
        self.Blank_3.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 11
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_3, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_3 ) 
        
        self.Label_4 = JLabel("User Name")
        self.Label_4.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 13 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_4, self.gbcPanel0 ) 
        self.panel0.add( self.Label_4 ) 

        self.userName_TF = JTextField(20, focusLost=self.setUserName) 
        self.userName_TF.setEnabled(True)
        self.gbcPanel0.gridx = 4 
        self.gbcPanel0.gridy = 13 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.userName_TF, self.gbcPanel0 ) 
        self.panel0.add( self.userName_TF ) 

        self.Blank_4 = JLabel( " ") 
        self.Blank_4.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 15
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_4, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_4 ) 

        self.Label_5 = JLabel("Password")
        self.Label_5.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 17 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_5, self.gbcPanel0 ) 
        self.panel0.add( self.Label_5 ) 

        self.password_TF = JPasswordField(20, focusLost=self.setPassword) 
#        self.password_TF = JTextField(20) 
        self.password_TF.setEnabled(True)
        self.gbcPanel0.gridx = 4 
        self.gbcPanel0.gridy = 17 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.password_TF, self.gbcPanel0 ) 
        self.panel0.add( self.password_TF ) 

        self.Blank_5 = JLabel( " ") 
        self.Blank_5.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 19
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_5, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_5 ) 
        
        self.Label_6 = JLabel("Sketch Name")
        self.Label_6.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 21 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_6, self.gbcPanel0 ) 
        self.panel0.add( self.Label_6 ) 

        self.sketchName_TF = JTextField(20, focusLost=self.setsketchName) 
        self.sketchName_TF.setEnabled(True)
        self.gbcPanel0.gridx = 4 
        self.gbcPanel0.gridy = 21 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.sketchName_TF, self.gbcPanel0 ) 
        self.panel0.add( self.sketchName_TF ) 

        self.Blank_6 = JLabel( " ") 
        self.Blank_6.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 23
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_6, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_6 ) 

        self.Label_7 = JLabel("Sketch Description")
        self.Label_7.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 25 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_7, self.gbcPanel0 ) 
        self.panel0.add( self.Label_7 ) 

        self.sketchDescription_TF = JTextField(20, focusLost=self.setsketchDescription) 
        self.sketchDescription_TF.setEnabled(True)
        self.gbcPanel0.gridx = 4 
        self.gbcPanel0.gridy = 25 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.sketchDescription_TF, self.gbcPanel0 ) 
        self.panel0.add( self.sketchDescription_TF ) 

        self.Blank_7 = JLabel( " ") 
        self.Blank_7.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 27
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_7, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_7 ) 
        
        # self.Check_Server_Status_BTN = JButton( "Check Server Status", actionPerformed=self.Check_Server) 
        # self.Check_Server_Status_BTN.setEnabled(True)
        # self.rbgPanel0.add( self.Save_Settings_BTN ) 
        # self.gbcPanel0.gridx = 2 
        # self.gbcPanel0.gridy = 29
        # self.gbcPanel0.gridwidth = 1 
        # self.gbcPanel0.gridheight = 1 
        # self.gbcPanel0.fill = GridBagConstraints.BOTH 
        # self.gbcPanel0.weightx = 1 
        # self.gbcPanel0.weighty = 0 
        # self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        # self.gbPanel0.setConstraints( self.Check_Server_Status_BTN, self.gbcPanel0 ) 
        # self.panel0.add( self.Check_Server_Status_BTN ) 

        self.Error_Message = JLabel( "") 
        self.Error_Message.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 31
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints( self.Error_Message, self.gbcPanel0 ) 
        self.panel0.add( self.Error_Message ) 


        self.add(self.panel0)

    # Custom load any data field and initialize the values
    def customizeComponents(self):
        #self.Exclude_File_Sources_CB.setSelected(self.local_settings.getExclude_File_Sources())
        #self.Run_Timesketch_CB.setSelected(self.local_settings.getRun_Timesketch())
        #self.Import_Timesketch_CB.setSelected(self.local_settings.getImport_Timesketch())
        #self.check_Database_entries()
        self.IP_Address_TF.setText(self.local_settings.getSetting('ipAddress'))
        self.Port_Number_TF.setText(self.local_settings.getSetting('portNumber'))
        self.userName_TF.setText(self.local_settings.getSetting('userName'))
        self.password_TF.setText(self.local_settings.getSetting('password'))
        self.sketchName_TF.setText(Case.getCurrentCase().getNumber())
        self.sketchDescription_TF.setText(Case.getCurrentCase().getName())
        self.local_settings.setSetting('sketchName', self.sketchName_TF.getText()) 
        self.local_settings.setSetting('sketchDescription', self.sketchDescription_TF.getText()) 


    # Return the settings used
    def getSettings(self):
        return self.local_settings
Ejemplo n.º 3
0
class SPAIModelReportModule(GeneralReportModuleAdapter):
    def __init__(self):
        self.tags_selected = []
        self.moduleName = "SPAI's HTML Model for Autopsy Report"

        self._logger = Logger.getLogger(self.moduleName)

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

    def getName(self):
        return self.moduleName

    def getDescription(self):
        return "SPAI's HTML Model for Autopsy Report"

    def getRelativeFilePath(self):
        return "index.html"

    def getConfigurationPanel(self):
        self.artifact_list = []
        self.panel0 = JPanel()

        self.rbgPanel0 = ButtonGroup()
        self.gbPanel0 = GridBagLayout()
        self.gbcPanel0 = GridBagConstraints()
        self.panel0.setLayout(self.gbPanel0)

        self.Label_0 = JLabel("Number of Object to Display per page")
        self.gbcPanel0.gridx = 1
        self.gbcPanel0.gridy = 1
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_0, self.gbcPanel0)
        self.panel0.add(self.Label_0)

        self.Num_Of_Objs_Per_Page_TF = JTextField(5)
        self.Num_Of_Objs_Per_Page_TF.setEnabled(True)
        self.Num_Of_Objs_Per_Page_TF.setText("10")
        self.gbcPanel0.gridx = 3
        self.gbcPanel0.gridy = 1
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Num_Of_Objs_Per_Page_TF,
                                     self.gbcPanel0)
        self.panel0.add(self.Num_Of_Objs_Per_Page_TF)

        self.Blank_0 = JLabel(" ")
        self.Blank_0.setEnabled(True)
        self.gbcPanel0.gridx = 1
        self.gbcPanel0.gridy = 3
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_0, self.gbcPanel0)
        self.panel0.add(self.Blank_0)

        self.Label_1 = JLabel("Title To Appear on Case Info")
        self.gbcPanel0.gridx = 1
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_1, self.gbcPanel0)
        self.panel0.add(self.Label_1)

        self.Title_Case_TF = JTextField(30)
        self.Title_Case_TF.setEnabled(True)
        self.Title_Case_TF.setText("Report of media analysis")
        self.gbcPanel0.gridx = 3
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Title_Case_TF, self.gbcPanel0)
        self.panel0.add(self.Title_Case_TF)

        self.Label_2 = JLabel("Report Number To Appear on Case Info")
        self.gbcPanel0.gridx = 1
        self.gbcPanel0.gridy = 7
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_2, self.gbcPanel0)
        self.panel0.add(self.Label_2)

        self.Report_Number_TF = JTextField(30)
        self.Report_Number_TF.setEnabled(True)
        self.Report_Number_TF.setText(Case.getCurrentCase().getNumber())
        self.gbcPanel0.gridx = 3
        self.gbcPanel0.gridy = 7
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Report_Number_TF, self.gbcPanel0)
        self.panel0.add(self.Report_Number_TF)

        self.Label_3 = JLabel("Examiner(s) To Appear on Case Info")
        self.gbcPanel0.gridx = 1
        self.gbcPanel0.gridy = 9
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_3, self.gbcPanel0)
        self.panel0.add(self.Label_3)

        self.Examiners_TF = JTextField(30)
        self.Examiners_TF.setEnabled(True)
        self.Examiners_TF.setText(Case.getCurrentCase().getExaminer())
        self.gbcPanel0.gridx = 3
        self.gbcPanel0.gridy = 9
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Examiners_TF, self.gbcPanel0)
        self.panel0.add(self.Examiners_TF)

        self.Label_4 = JLabel("Description To Appear on Case Info")
        self.gbcPanel0.gridx = 1
        self.gbcPanel0.gridy = 11
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_4, self.gbcPanel0)
        self.panel0.add(self.Label_4)

        self.Description_TF = JTextField(30)
        self.Description_TF.setEnabled(True)
        #self.Description_TF.setText(Case.getCurrentCase().getNumber())
        self.gbcPanel0.gridx = 3
        self.gbcPanel0.gridy = 11
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Description_TF, self.gbcPanel0)
        self.panel0.add(self.Description_TF)

        self.Blank_4 = JLabel(" ")
        self.Blank_4.setEnabled(True)
        self.gbcPanel0.gridx = 1
        self.gbcPanel0.gridy = 19
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_4, self.gbcPanel0)
        self.panel0.add(self.Blank_4)

        self.Label_5 = JLabel("Tags to Select for Report:")
        self.Label_5.setEnabled(True)
        self.gbcPanel0.gridx = 1
        self.gbcPanel0.gridy = 21
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_5, self.gbcPanel0)
        self.panel0.add(self.Label_5)

        self.List_Box_LB = JList(self.find_tags(),
                                 valueChanged=self.onchange_lb)
        self.List_Box_LB.setVisibleRowCount(3)
        self.scpList_Box_LB = JScrollPane(self.List_Box_LB)
        self.gbcPanel0.gridx = 1
        self.gbcPanel0.gridy = 23
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 1
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.scpList_Box_LB, self.gbcPanel0)
        self.panel0.add(self.scpList_Box_LB)

        self.Blank_5 = JLabel(" ")
        self.Blank_5.setEnabled(True)
        self.gbcPanel0.gridx = 1
        self.gbcPanel0.gridy = 25
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_5, self.gbcPanel0)
        self.panel0.add(self.Blank_5)

        #self.add(self.panel0)
        return self.panel0

    def generateReport(self, baseReportDir, progressBar):

        progressBar.setIndeterminate(False)
        progressBar.start()

        # Set status bar for number of tags
        progressBar.setMaximumProgress(2)

        # Get and create the report directories
        head, tail = os.path.split(os.path.abspath(__file__))
        copy_resources_dir = os.path.join(head, "res")
        try:
            report_dir = os.path.join(baseReportDir, "Report")
            os.mkdir(report_dir)
        except:
            self.log(Level.INFO, "Could not create base report dir")

        try:
            report_files_dir = os.path.join(report_dir, "report_files")
            os.mkdir(report_files_dir)
        except:
            self.log(Level.INFO, "Could not create report_files directory")

        try:
            report_resources_dir = os.path.join(report_dir, "res")
            os.mkdir(report_resources_dir)
        except:
            self.log(Level.INFO, "Could not create report_res directory")

        # Copy the Resource directory to the report directory
        try:
            head, tail = os.path.split(os.path.abspath(__file__))
            copy_resources_dir = os.path.join(head, "res")
            copy_tree(copy_resources_dir, report_resources_dir)
        except:
            self.log(Level.INFO, "Could Not copy resources directory")

        # Copy the base files needed for the report
        try:
            copy_base_dir = os.path.join(head, "base_folder")
            copy_tree(copy_base_dir, report_dir)
        except:
            self.log(
                Level.INFO,
                "Could not write files from base_folder to base_report_Folder")

        # Create the index page
        self.create_index_file(report_dir)

        # Create The information page
        self.create_info_page(report_dir)

        # Create the Menu page.
        self.create_menu_file(report_dir)

        # Get all Content
        tags = Case.getCurrentCase().getServices().getTagsManager(
        ).getAllContentTags()
        tag_number = 1
        for sel_tag in self.tags_selected:
            tags_to_process = []
            for tag in tags:
                if tag.getName().getDisplayName() == sel_tag:
                    tags_to_process.append(tag)
                    self.log(
                        Level.INFO, "this is a content tags ==> " +
                        tag.getName().getDisplayName() + " <==")
            progressBar.updateStatusLabel("Process tag " + sel_tag)
            self.process_thru_tags(report_dir, tags_to_process, tag_number,
                                   sel_tag, report_files_dir)
            tag_number = tag_number + 1

        # Increment since we are done with step #1
        progressBar.increment()

        fileName = os.path.join(report_dir, "index.html")

        # Add the report to the Case, so it is shown in the tree
        Case.getCurrentCase().addReport(fileName, self.moduleName,
                                        "SPAI's HTML Model Report")

        progressBar.increment()

        # Call this with ERROR if report was not generated
        progressBar.complete(ReportStatus.COMPLETE)

    def process_thru_tags(self, report_dir, tags_to_process, book_mark_number,
                          tag_name, report_files_dir):
        page_number = 1
        current_page_number = 1
        num_of_tags_per_page = int(str(self.Num_Of_Objs_Per_Page_TF.getText()))
        total_pages = int(len(tags_to_process)) // num_of_tags_per_page
        if (int(len(tags_to_process)) % num_of_tags_per_page) <> 0:
            total_pages = total_pages + 1
        page_file_name = os.path.join(
            report_dir, "Bookmark" + str(book_mark_number) + "Pagina" +
            str(page_number) + ".html")
        page_file = open(page_file_name, 'w')
        self.create_page_header(page_file, len(tags_to_process), tag_name,
                                total_pages)
        tag_number = 1
        total_tag_number = 1
        for tag in tags_to_process:
            if tag_number > num_of_tags_per_page:
                tag_number = 1
                page_number = page_number + 1
                page_file_name = os.path.join(
                    report_dir, "Bookmark" + str(book_mark_number) + "Pagina" +
                    str(page_number) + ".html")
                self.create_page_footer(
                    page_file, total_pages, current_page_number,
                    "Bookmark" + str(book_mark_number) + "Pagina")
                page_file.close()
                #page_file_name = os.path.join(report_dir, "Bookmark" + str(tag_number) + "Pagina1.html")
                page_file = open(page_file_name, 'w')
                self.create_page_header(page_file, len(tags_to_process),
                                        tag_name, current_page_number)
                current_page_number = current_page_number + 1
            self.create_page_data(page_file, tag, total_tag_number,
                                  report_files_dir)
            tag_number = tag_number + 1
            total_tag_number = total_tag_number + 1
        self.create_page_footer(page_file, total_pages, current_page_number,
                                "Bookmark" + str(book_mark_number) + "Pagina")
        page_file.close()

    def create_page_footer(self, page_file, total_pages, current_page,
                           page_file_name):
        page_file.write('<!--          Rodape        -->')
        page_file.write('	<table width="100%">')
        page_file.write('		<tr>')
        page_file.write('			<td><small> ' +
                        datetime.datetime.today().strftime('%d/%m/%Y') +
                        ' </small></td>')

        if current_page < total_pages:
            if current_page < total_pages:
                if current_page == 1:
                    page_file.write('			<td>Page ' + str(current_page) +
                                    ' of ' + str(total_pages) + ' </td>')
                    page_file.write('      <td><a href="' + page_file_name +
                                    str(current_page + 1) + ".html" +
                                    '">next page &gt;&gt</a></td>')
                else:
                    page_file.write('      <td><a href="' + page_file_name +
                                    str(current_page - 1) + ".html" +
                                    '">&lt;&lt;Previous page</a></td>')
                    page_file.write('			<td>Page ' + str(current_page) +
                                    ' of ' + str(total_pages) + ' </td>')
                    page_file.write('      <td><a href="' + page_file_name +
                                    str(current_page + 1) + ".html" +
                                    '"> next page &gt;&gt</a></td>')
            elif current_page == total_pages:
                page_file.write('      <td><a href="' + page_file_name +
                                str(current_page - 1) + ".html" +
                                '">&lt;&lt;Previous page</a></td>')
                page_file.write('			<td>Page ' + str(current_page) + ' of ' +
                                str(total_pages) + ' </td>')
            else:
                page_file.write('			<td>Page ' + str(current_page) + ' of ' +
                                str(total_pages) + ' </td>')
        else:
            if current_page == 1:
                page_file.write('			<td>Page 1 of 1 </td>')
            else:
                page_file.write('      <td><a href="' + page_file_name +
                                str(current_page - 1) + ".html" +
                                '">&lt;&lt;Previous page</a></td>')
                page_file.write('			<td>Page ' + str(current_page) + ' of ' +
                                str(total_pages) + ' </td>')

        page_file.write('		</tr>')
        page_file.write('	</table>')
        page_file.write(' ')
        page_file.write('	<p><img border="0" src="res/Footer.gif"/></p>')
        page_file.write('</body>')
        page_file.write('</html>')
        page_file.write('<!--          Rodape        -->')

    def create_page_data(self, page_file, tag, tag_number, report_files_dir):
        try:
            tag_content = tag.getContent()
            lclDbPath = os.path.join(
                report_files_dir,
                str(tag_content.getId()) + "-" + tag_content.getName())
            ContentUtils.writeToFile(tag_content, File(lclDbPath))

            page_file.write('	<div class="clrBkgrnd bkmkSeparator bkmkValue">')
            page_file.write(
                '		<span style="FONT-WEIGHT:bold">Metadata: </span>')
            page_file.write('	</div>')
            page_file.write(' ')
            page_file.write('	<div class="row">')
            page_file.write(
                '		<span class="bkmkColLeft bkmkValue labelBorderless clrBkgrnd" width="100%" border="1">Index</span>'
            )
            page_file.write('		<span class="bkmkColRight bkmkValue"> ' +
                            str(tag_number) + ' </span>')
            page_file.write('	</div>')
            page_file.write(' ')
            page_file.write('	<div class="row">')
            page_file.write(
                '		<span class="bkmkColLeft bkmkValue labelBorderless clrBkgrnd" width="100%" border="1">Name</span>'
            )
            page_file.write('		<span class="bkmkColRight bkmkValue"> ' +
                            tag_content.getName() + ' </span>')
            page_file.write('	</div>')
            page_file.write(' ')
            page_file.write('	<div class="row">')
            page_file.write(
                '		<span class="bkmkColLeft bkmkValue labelBorderless clrBkgrnd" width="100%" border="1">Path</span>'
            )
            page_file.write('		<span class="bkmkColRight bkmkValue"> ' +
                            tag_content.getUniquePath() + ' </span>')
            page_file.write('	</div>')
            page_file.write(' ')
            page_file.write('	<div class="row">')
            page_file.write(
                '		<span class="bkmkColLeft bkmkValue labelBorderless clrBkgrnd" width="100%" border="1">Logical size</span>'
            )
            page_file.write('		<span class="bkmkColRight bkmkValue"> ' +
                            str(tag_content.getSize()) + ' </span>')
            page_file.write('	</div>')
            page_file.write(' ')
            page_file.write('	<div class="row">')
            page_file.write(
                '		<span class="bkmkColLeft bkmkValue labelBorderless clrBkgrnd" width="100%" border="1">Created</span>'
            )
            page_file.write('		<span class="bkmkColRight bkmkValue"> ' +
                            tag_content.getCrtimeAsDate() + ' </span>')
            page_file.write('	</div>')
            page_file.write(' ')
            page_file.write('	<div class="row"> ')
            page_file.write(
                '		<span class="bkmkColLeft bkmkValue labelBorderless clrBkgrnd" width="100%" border="1">Modified</span>'
            )
            page_file.write('		<span class="bkmkColRight bkmkValue"> ' +
                            tag_content.getMtimeAsDate() + ' </span>')
            page_file.write('	</div>')
            page_file.write(' ')
            page_file.write('	<div class="row">')
            page_file.write(
                '		<span class="bkmkColLeft bkmkValue labelBorderless clrBkgrnd" width="100%" border="1">Accessed</span>'
            )
            page_file.write('		<span class="bkmkColRight bkmkValue"> ' +
                            tag_content.getAtimeAsDate() + ' </span>')
            page_file.write('	</div>')
            page_file.write(' ')
            page_file.write('	<div class="row">')
            page_file.write(
                '		<span class="bkmkColLeft bkmkValue labelBorderless clrBkgrnd" width="100%" border="1">Deleted</span>'
            )
            page_file.write('		<span class="bkmkColRight bkmkValue"> ')
            if tag_content.exists():
                page_file.write('No' + ' </span>')
            else:
                page_file.write('Yes' + '</span>')
            page_file.write('	</div>')
            page_file.write(' ')
            page_file.write('	<div class="row">')
            page_file.write(
                '		<span class="bkmkColLeft bkmkValue labelBorderless clrBkgrnd" width="100%" border="1">Exported as</span>'
            )
            page_file.write(
                '		<span class="bkmkColRight bkmkValue">report_files\ ' +
                tag_content.getName() + ' </span>')
            page_file.write('	</div>')
            page_file.write(' ')
            page_file.write('	<div class="row">')
            page_file.write(
                '		<span class="bkmkColLeft bkmkValue labelBorderless clrBkgrnd" width="100%" border="1">Preview</span>'
            )
            self.log(Level.INFO,
                     'File Extension ==> ' + tag_content.getNameExtension())
            if tag_content.getNameExtension() in ['jpg', 'png']:
                page_file.write('<table width="100%">')
                page_file.write('    <tr>')
                page_file.write('        <td align="center" class="">')
                page_file.write('            <a href="report_files\\' +
                                str(tag_content.getId()) + '-' +
                                tag_content.getName() + '"/>')
                page_file.write('            <img src="report_files\\' +
                                str(tag_content.getId()) + '-' +
                                tag_content.getName() +
                                '" alt="report_files\\' +
                                tag_content.getName() +
                                '" width="96" height="96"/>')
                page_file.write('        </td>')
                page_file.write('    </tr>')
                page_file.write('</table>')
            else:
                page_file.write('		<span class="bkmkColRight bkmkValue">')
                page_file.write('			<a href="report_files\\' +
                                str(tag_content.getId()) + '-' +
                                tag_content.getName() + '">' +
                                tag_content.getName() + '</a>')
            page_file.write('		</span>')
            page_file.write('	</div>')
        except:
            self.log(
                Level.INFO, "File Content Not written or created ==> " +
                str(tag_content.getId()) + '-' + tag_content.getName())

    def create_page_header(self, page_file, number_of_tags, tag_name,
                           page_number):
        page_file.write('<!--          Cabecalho        -->')
        page_file.write('<?xml version="1.0" encoding="UTF-8"?>')
        page_file.write('<html xmlns="http://www.w3.org/1999/xhtml">')
        page_file.write(' ')
        page_file.write('<head>')
        page_file.write(
            '	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>'
        )
        page_file.write(
            '	<link rel="stylesheet" type="text/css" href="res/common.css"/>')
        page_file.write(
            '	<link rel="stylesheet" type="text/css" href="res/Bookmarks.css"/>'
        )
        page_file.write('	<title>Tags</title>')
        page_file.write('</head>')
        page_file.write(' ')
        page_file.write(' ')
        page_file.write('<body>')
        page_file.write('	<table>')
        page_file.write(
            '		<tr><td height="20" valign="top"><img border="0" src="res/Header.gif"/></td></tr>'
        )
        page_file.write('	</table>')
        page_file.write(' ')
        page_file.write('	<table width="100%">')
        page_file.write('		<tr>')
        #        page_file.write('			<td><small> ' + datetime.datetime.today().strftime('%d/%m-%Y') + ' </small></td>') # Danilo C M Marques - 27/10/2017
        page_file.write('			<td><small> ' +
                        datetime.datetime.today().strftime('%d/%m/%Y') +
                        ' </small></td>')  # Danilo C M Marques - 27/10/2017
        page_file.write('			<td>Page 1 of ' + str(page_number) + ' </td>')
        page_file.write('		</tr>')
        page_file.write('	</table>')
        page_file.write(' ')
        page_file.write('	<table width="100%">')
        page_file.write(
            '		<tr><th class="columnHead" colspan="1">Tag: <span style="font-size:1.25em">'
            + tag_name.encode('utf-8') + '</span></th></tr>')
        page_file.write(
            '		<tr><td class="clrBkgrnd"><span style="font-weight:bold">Number of files: </span>'
            + str(number_of_tags) + ' </td></tr>')
        page_file.write('	</table>')
        page_file.write(' ')
        page_file.write('	</br></br>')
        page_file.write(' ')
        page_file.write(
            '	<div class="bkmkLblFiles" width="100%" border="1">Files</div>')
        page_file.write('	<a name="bk_obj13550"> </a>')
        page_file.write('<!--          Cabecalho        -->')
        page_file.write(' ')
        page_file.write(' ')
        page_file.write(' ')
        page_file.write(' ')

    def create_index_file(self, report_dir):
        index_file_name = os.path.join(report_dir, "index.html")
        index_file = open(index_file_name, 'w')
        index_file.write('<?xml version="1.0" encoding="UTF-8"?>')
        index_file.write('<html xmlns="http://www.w3.org/1999/xhtml">')
        index_file.write(" ")
        index_file.write("<head>")
        index_file.write(
            '	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>'
        )
        #        index_file.write("	<title> " + 'Instituto de Criminalística Carlos Éboli - DGPTC/PCERJ' + "</title>") # Danilo C M Marques - 27/10/2017
        index_file.write("	<title> " + 'My Institution' +
                         "</title>")  # Danilo C M Marques - 27/10/2017
        index_file.write("</head>")
        index_file.write(" ")
        index_file.write('<frameset cols="290,10%">')
        index_file.write(
            '	<frame src="Menu.html" name="navigate" frameborder="0"/>')
        index_file.write(
            '	<frame src="Informacoes.html" name="contents" frameborder="1"/>')
        index_file.write("	<noframes/>")
        index_file.write("</frameset>")
        index_file.write(" ")
        index_file.write("</html>")
        index_file.close()

    def create_info_page(self, report_dir):
        # get case specific information to put in the information.html file
        skCase = Case.getCurrentCase()

        # Open and write information.html file
        info_file_name = os.path.join(report_dir, "Informacoes.html")
        info_file = open(info_file_name, 'w')
        info_file.write('<?xml version="1.0" encoding="UTF-8"?>')
        info_file.write('<html xmlns="http://www.w3.org/1999/xhtml">')
        info_file.write(" ")
        info_file.write("<head>")
        info_file.write(
            '	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>'
        )
        info_file.write(
            '	<link rel="stylesheet" type="text/css" href="res/common.css"/>')
        info_file.write("	<title>Case Information</title>")
        info_file.write("</head>")
        info_file.write(" ")
        info_file.write(" ")
        info_file.write(" ")
        info_file.write(" ")
        info_file.write("<body>")
        info_file.write(" ")
        info_file.write(
            '	<div class="bkmkColHead" width="100%" border="1">Case information</div>'
        )
        info_file.write('	<table width="100%">')
        info_file.write("		<tr>")
        info_file.write(
            '			<td style="width:20%" class="bkmkValue labelBorderless clrBkgrnd">Title</td>'
        )
        info_file.write("			<td> " + self.Title_Case_TF.getText() + " </td>")
        info_file.write("		</tr>")
        info_file.write(" ")
        info_file.write("		<tr>")
        info_file.write(
            '			<td style="width:20%" class="bkmkValue labelBorderless clrBkgrnd">Report number</td>'
        )
        info_file.write("			<td> " + self.Report_Number_TF.getText() + "</td>")
        info_file.write("		</tr>")
        info_file.write(" ")
        info_file.write("		<tr>")
        info_file.write(
            '			<td style="width:20%" class="bkmkValue labelBorderless clrBkgrnd">Examiner(s)</td>'
        )
        info_file.write("			<td> " + self.Examiners_TF.getText() + " </td>")
        info_file.write("		</tr>")
        info_file.write(" ")
        info_file.write("		<tr>")
        info_file.write(
            '			<td style="width:20%" class="bkmkValue labelBorderless clrBkgrnd">Description</td>'
        )
        info_file.write("			<td> " + self.Description_TF.getText() + " </td>")
        info_file.write("		</tr>")
        info_file.write(" ")
        info_file.write("		<tr>")
        info_file.write(
            '			<td style="width:20%" class="bkmkValue labelBorderless clrBkgrnd">ATTENTION</td>'
        )
        info_file.write(
            "			<td>It is recommended to configure the browser to offline mode, in order to avoid that HTML temporary files be visualized in external servers</td>"
        )
        info_file.write("		</tr>")
        info_file.write("	</table>")
        info_file.write('	<p><img border="0" src="res/Footer.gif"/></p>')
        info_file.write(" ")
        info_file.write("</body>")
        info_file.write("</html>")

        # Close Info File
        info_file.close()

    def create_menu_file(self, report_dir):
        # get case specific information to put in the information.html file
        skCase = Case.getCurrentCase()

        # Open and write information.html file
        menu_file_name = os.path.join(report_dir, "menu.html")
        menu_file = open(menu_file_name, 'w')

        menu_file.write('<?xml version="1.0" encoding="UTF-8"?>')
        menu_file.write('<html xmlns="http://www.w3.org/1999/xhtml">')
        menu_file.write(' ')
        menu_file.write('<head>')
        menu_file.write(
            '	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>'
        )
        menu_file.write(
            '	<link rel="stylesheet" type="text/css" href="res/navigation.css"/>'
        )
        menu_file.write(
            '	<link rel="stylesheet" type="text/css" href="res/common.css"/>')
        menu_file.write('	<title>Summary</title>')
        menu_file.write('</head>')
        menu_file.write(' ')
        menu_file.write('<body background="res/Background.gif">')
        menu_file.write(' ')
        menu_file.write(
            '<!--	<img style="margin: 0px 70px" border="0" src="res/brasao.gif"/>-->'
        )
        menu_file.write(
            '	<img style="margin: 0px 70px" border="0" src="res/icon.ico"/>')
        menu_file.write('	<p> </p>')
        menu_file.write('	<div>')
        menu_file.write('		<h3><font color="white">Summary of Analysis<h3>')
        menu_file.write(
            '		<a class="sectionLinks" target="contents" href="Informacoes.html">'
        )
        menu_file.write(
            '			<span style="margin-left:15px"> Case Information </span>')
        menu_file.write('		</a>')
        menu_file.write('		<div> </div>')
        menu_file.write(
            '		<a class="sectionLinks" target="contents" href="Ajuda.htm">')
        #        menu_file.write('			<span style="margin-left:15px">Ajuda</span>') # Danilo C M Marques - 27/10/2017
        menu_file.write('			<span style="margin-left:15px">Help</span>')
        menu_file.write('		</a>')
        menu_file.write('		<div> </div> ')
        menu_file.write('		<h3>Selected Evidences<h3>')
        tag_number = 1
        for tag in self.tags_selected:
            menu_file.write(
                '		<a class="sectionLinks" target="contents" href="Bookmark' +
                str(tag_number) + 'Pagina1.html">')
            menu_file.write('			<span style="margin-left:30px">' +
                            tag.encode('utf-8') + '</span>')
            menu_file.write('		</a>')
            tag_number = tag_number + 1
        menu_file.write(' ')
        menu_file.write('	</div>')
        menu_file.write(' ')
        menu_file.write('</body>')
        menu_file.write('</html>')
        menu_file.close()

    def onchange_lb(self, event):
        self.tags_selected[:] = []
        self.tags_selected = self.List_Box_LB.getSelectedValuesList()

    def find_tags(self):
        tag_list = []
        sql_statement = "SELECT distinct(display_name) u_tag_name FROM content_tags INNER JOIN tag_names ON " + \
                        " content_tags.tag_name_id = tag_names.tag_name_id;"
        skCase = Case.getCurrentCase().getSleuthkitCase()
        dbquery = skCase.executeQuery(sql_statement)
        resultSet = dbquery.getResultSet()
        while resultSet.next():
            tag_list.append(resultSet.getString("u_tag_name"))
        dbquery.close()
        return tag_list
Ejemplo n.º 4
0
class VolatilitySettingsWithUISettingsPanel(IngestModuleIngestJobSettingsPanel
                                            ):
    # Note, we can't use a self.settings instance variable.
    # Rather, self.local_settings is used.
    # https://wiki.python.org/jython/UserGuide#javabean-properties
    # Jython Introspector generates a property - 'settings' on the basis
    # of getSettings() defined in this class. Since only getter function
    # is present, it creates a read-only 'settings' property. This auto-
    # generated read-only property overshadows the instance-variable -
    # 'settings'

    # We get passed in a previous version of the settings so that we can
    # prepopulate the UI
    # TODO: Update this for your UI
    def __init__(self, settings):
        self.local_settings = settings
        self.initComponents()
        self.customizeComponents()

    # Check to see if there are any entries that need to be populated from the database.
    def check_Database_entries(self):
        head, tail = os.path.split(os.path.abspath(__file__))
        settings_db = head + "\\GUI_Settings.db3"
        try:
            Class.forName("org.sqlite.JDBC").newInstance()
            dbConn = DriverManager.getConnection("jdbc:sqlite:%s" %
                                                 settings_db)
        except SQLException as e:
            self.Error_Message.setText("Error Opening Settings DB!")

        try:
            stmt = dbConn.createStatement()
            SQL_Statement = 'Select Setting_Name, Setting_Value from settings;'
            resultSet = stmt.executeQuery(SQL_Statement)
            while resultSet.next():
                if resultSet.getString(
                        "Setting_Name") == "Volatility_Executable_Directory":
                    self.Program_Executable_TF.setText(
                        resultSet.getString("Setting_Value"))
                    self.local_settings.setVolatility_Directory(
                        resultSet.getString("Setting_Value"))
                    self.local_settings.setVolatility_Dir_Found(True)
                # if resultSet.getString("Setting_Name") == "Volatility_Version":
                # self.Version_CB.setSelectedItem(resultSet.getString("Setting_Value"))
            self.Error_Message.setText("Settings Read successfully!")
        except SQLException as e:
            self.Error_Message.setText("Error Reading Settings Database")

        stmt.close()
        dbConn.close()

    # Save entries from the GUI to the database.
    def SaveSettings(self, e):

        head, tail = os.path.split(os.path.abspath(__file__))
        settings_db = head + "\\GUI_Settings.db3"
        try:
            Class.forName("org.sqlite.JDBC").newInstance()
            dbConn = DriverManager.getConnection("jdbc:sqlite:%s" %
                                                 settings_db)
        except SQLException as e:
            self.Error_Message.setText("Error Opening Settings")

        try:
            stmt = dbConn.createStatement()
            SQL_Statement = ""
            if (self.local_settings.getVolatility_Dir_Found()):
                SQL_Statement = 'Update settings set Setting_Value = "' + self.Program_Executable_TF.getText() + '"' + \
                                ' where setting_name = "Volatility_Executable_Directory";'
                # SQL_Statement2 = 'Update settings set Setting_Value = "' + self.Version_CB.getSelectedItem() + '"' + \
                # ' where setting_name = "Volatility_Version";'
            else:
                SQL_Statement = 'Insert into settings (Setting_Name, Setting_Value) values ("Volatility_Executable_Directory", "' +  \
                                self.Program_Executable_TF.getText() + '");'
                # SQL_Statement2 = 'Insert into settings (Setting_Name, Setting_Value) values ("Volatility_Version", "' +  \
                # self.Version_CB.getSelectedItem() + '");'

            stmt.execute(SQL_Statement)
            # stmt.execute(SQL_Statement2)
            self.Error_Message.setText("Volatility Executable Directory Saved")
            self.local_settings.setVolatility_Directory(
                self.Program_Executable_TF.getText())
        except SQLException as e:
            self.Error_Message.setText(e.getMessage())
        stmt.close()
        dbConn.close()

    # When button to find file is clicked then open dialog to find the file and return it.
    def Find_Dir(self, e):

        chooseFile = JFileChooser()
        filter = FileNameExtensionFilter("All", ["*.*"])
        chooseFile.addChoosableFileFilter(filter)
        #chooseFile.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)

        ret = chooseFile.showDialog(self.panel0, "Find Volatility Directory")

        if ret == JFileChooser.APPROVE_OPTION:
            file = chooseFile.getSelectedFile()
            Canonical_file = file.getCanonicalPath()
            #text = self.readPath(file)
            self.local_settings.setVolatility_Directory(Canonical_file)
            self.Program_Executable_TF.setText(Canonical_file)

    def keyPressed(self, event):
        self.local_settings.setProcessIDs(
            self.Process_Ids_To_Dump_TF.getText())
        #self.Error_Message.setText(self.Process_Ids_To_Dump_TF.getText())

    def checkBoxEvent(self, event):
        if self.Check_Box.isSelected():
            self.local_settings.setFlag(True)
        else:
            self.local_settings.setFlag(False)

    # Create the initial data fields/layout in the UI
    def initComponents(self):
        self.panel0 = JPanel()

        self.rbgPanel0 = ButtonGroup()
        self.gbPanel0 = GridBagLayout()
        self.gbcPanel0 = GridBagConstraints()
        self.panel0.setLayout(self.gbPanel0)

        self.Error_Message = JLabel("")
        self.Error_Message.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 31
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Error_Message, self.gbcPanel0)
        self.panel0.add(self.Error_Message)

        self.Label_1 = JLabel("Volatility Executable Directory")
        self.Label_1.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 1
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_1, self.gbcPanel0)
        self.panel0.add(self.Label_1)

        self.Program_Executable_TF = JTextField(10)
        self.Program_Executable_TF.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 3
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Program_Executable_TF,
                                     self.gbcPanel0)
        self.panel0.add(self.Program_Executable_TF)

        self.Find_Program_Exec_BTN = JButton("Find Dir",
                                             actionPerformed=self.Find_Dir)
        self.Find_Program_Exec_BTN.setEnabled(True)
        self.rbgPanel0.add(self.Find_Program_Exec_BTN)
        self.gbcPanel0.gridx = 6
        self.gbcPanel0.gridy = 3
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Find_Program_Exec_BTN,
                                     self.gbcPanel0)
        self.panel0.add(self.Find_Program_Exec_BTN)

        self.Blank_1 = JLabel(" ")
        self.Blank_1.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_1, self.gbcPanel0)
        self.panel0.add(self.Blank_1)

        self.Save_Settings_BTN = JButton("Save Volatility Exec Dir",
                                         actionPerformed=self.SaveSettings)
        self.Save_Settings_BTN.setEnabled(True)
        self.rbgPanel0.add(self.Save_Settings_BTN)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 7
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Save_Settings_BTN, self.gbcPanel0)
        self.panel0.add(self.Save_Settings_BTN)

        self.Blank_2 = JLabel(" ")
        self.Blank_2.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 9
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_2, self.gbcPanel0)
        self.panel0.add(self.Blank_2)

        self.Blank_3 = JLabel(" ")
        self.Blank_3.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 13
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_3, self.gbcPanel0)
        self.panel0.add(self.Blank_3)

        self.Check_Box = JCheckBox(
            "Extract and Create Memory Image from Hiberfile",
            actionPerformed=self.checkBoxEvent)
        self.Blank_1.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 15
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Check_Box, self.gbcPanel0)
        self.panel0.add(self.Check_Box)

        self.Blank_4 = JLabel(" ")
        self.Blank_4.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 17
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_4, self.gbcPanel0)
        self.panel0.add(self.Blank_4)

        self.Blank_5 = JLabel(" ")
        self.Blank_5.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 21
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_5, self.gbcPanel0)
        self.panel0.add(self.Blank_5)

        self.Blank_6 = JLabel(" ")
        self.Blank_6.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 27
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_6, self.gbcPanel0)
        self.panel0.add(self.Blank_6)

        self.Label_3 = JLabel("Message:")
        self.Label_3.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 29
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_3, self.gbcPanel0)
        self.panel0.add(self.Label_3)

        self.add(self.panel0)

    # Custom load any data field and initialize the values
    def customizeComponents(self):
        self.Check_Box.setSelected(self.local_settings.getFlag())
        self.check_Database_entries()
        #pass

    # Return the settings used
    def getSettings(self):
        return self.local_settings
Ejemplo n.º 5
0
class CuckooSettingsWithUISettingsPanel(IngestModuleIngestJobSettingsPanel):
    # Note, we can't use a self.settings instance variable.
    # Rather, self.local_settings is used.
    # https://wiki.python.org/jython/UserGuide#javabean-properties
    # Jython Introspector generates a property - 'settings' on the basis
    # of getSettings() defined in this class. Since only getter function
    # is present, it creates a read-only 'settings' property. This auto-
    # generated read-only property overshadows the instance-variable -
    # 'settings'

    # We get passed in a previous version of the settings so that we can
    # prepopulate the UI
    # TODO: Update this for your UI
    def __init__(self, settings):
        self.local_settings = settings
        self.tag_list = []
        self.initComponents()
        self.customizeComponents()
        self.path_to_cuckoo_exe = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), "cuckoo_api.exe")

    # Check the checkboxs to see what actions need to be taken
    def checkBoxEvent(self, event):
        if self.Submit_File_CB.isSelected():
            self.local_settings.setSubmit_File(True)
            self.local_settings.setSubmit_URL(False)
        else:
            self.local_settings.setSubmit_File(False)

        # if self.Submit_URL_CB.isSelected():
        # self.local_settings.setSubmit_URL(True)
        # self.local_settings.setSubmit_File(False)
        # else:
        # self.local_settings.setSubmit_URL(False)

    def onchange_lb(self, event):
        self.local_settings.cleartag_list()
        list_selected = self.List_Box_LB.getSelectedValuesList()
        self.local_settings.settag_list(list_selected)

    def find_tags(self):

        sql_statement = "SELECT distinct(display_name) u_tag_name FROM content_tags INNER JOIN tag_names ON " + \
                        " content_tags.tag_name_id = tag_names.tag_name_id;"
        skCase = Case.getCurrentCase().getSleuthkitCase()
        dbquery = skCase.executeQuery(sql_statement)
        resultSet = dbquery.getResultSet()
        while resultSet.next():
            self.tag_list.append(resultSet.getString("u_tag_name"))
        dbquery.close()

    # Check to see if there are any entries that need to be populated from the database.
    def check_Database_entries(self):
        head, tail = os.path.split(os.path.abspath(__file__))
        settings_db = head + "\\gui_Settings.db3"
        try:
            Class.forName("org.sqlite.JDBC").newInstance()
            dbConn = DriverManager.getConnection("jdbc:sqlite:%s" %
                                                 settings_db)
        except SQLException as e:
            self.Error_Message.setText("Error Opening Settings DB!")

        try:
            stmt = dbConn.createStatement()
            SQL_Statement = 'Select Protocol, cuckoo_host, cuckoo_port from cuckoo_server'
            resultSet = stmt.executeQuery(SQL_Statement)
            while resultSet.next():
                self.Protocol_TF.setText(resultSet.getString("Protocol"))
                self.IP_Address_TF.setText(resultSet.getString("cuckoo_host"))
                self.Port_Number_TF.setText(resultSet.getString("cuckoo_port"))
                self.local_settings.setProtocol(
                    resultSet.getString("Protocol"))
                self.local_settings.setIP_Address(
                    resultSet.getString("cuckoo_host"))
                self.local_settings.setPort_Number(
                    resultSet.getString("cuckoo_port"))
            self.Error_Message.setText("Settings Read successfully!")
        except SQLException as e:
            self.Error_Message.setText("Error Reading Settings Database")

        stmt.close()
        dbConn.close()

    # Save entries from the GUI to the database.
    def SaveSettings(self, e):

        head, tail = os.path.split(os.path.abspath(__file__))
        settings_db = head + "\\GUI_Settings.db3"
        try:
            Class.forName("org.sqlite.JDBC").newInstance()
            dbConn = DriverManager.getConnection("jdbc:sqlite:%s" %
                                                 settings_db)
        except SQLException as e:
            self.Error_Message.setText("Error Opening Settings")

        try:
            stmt = dbConn.createStatement()
            SQL_Statement = ""
            SQL_Statement = 'Update cuckoo_server set Protocol = "' + self.Protocol_TF.getText() + '", ' + \
                                '                     Cuckoo_Host = "' + self.IP_Address_TF.getText() + '", ' + \
                                '                     Cuckoo_port = "' + self.Port_Number_TF.getText() + '";'

            #self.Error_Message.setText(SQL_Statement)
            stmt.execute(SQL_Statement)
            self.Error_Message.setText("Cuckoo settings Saved")
            #self.local_settings.setCuckoo_Directory(self.Program_Executable_TF.getText())
        except SQLException as e:
            self.Error_Message.setText(e.getMessage())
        stmt.close()
        dbConn.close()

    # Check to see if the Cuckoo server is available and you can talk to it
    def Check_Server(self, e):

        pipe = Popen([
            self.path_to_cuckoo_exe,
            self.Protocol_TF.getText(),
            self.IP_Address_TF.getText(),
            self.Port_Number_TF.getText(), "cuckoo_status"
        ],
                     stdout=PIPE,
                     stderr=PIPE)

        out_text = pipe.communicate()[0]
        self.Error_Message.setText("Cuckoo Status is " + out_text)
        #self.log(Level.INFO, "Cuckoo Status is ==> " + out_text)

    # def onchange_cb(self, event):
    # self.local_settings.setComboBox(event.item)

    # Create the initial data fields/layout in the UI
    def initComponents(self):
        self.panel0 = JPanel()

        self.rbgPanel0 = ButtonGroup()
        self.gbPanel0 = GridBagLayout()
        self.gbcPanel0 = GridBagConstraints()
        self.panel0.setLayout(self.gbPanel0)

        self.Label_1 = JLabel("Protocol:")
        self.Label_1.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 1
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_1, self.gbcPanel0)
        self.panel0.add(self.Label_1)

        self.Protocol_TF = JTextField(20)
        self.Protocol_TF.setEnabled(True)
        self.gbcPanel0.gridx = 4
        self.gbcPanel0.gridy = 1
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Protocol_TF, self.gbcPanel0)
        self.panel0.add(self.Protocol_TF)

        self.Blank_1 = JLabel(" ")
        self.Blank_1.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 3
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_1, self.gbcPanel0)
        self.panel0.add(self.Blank_1)

        self.Label_2 = JLabel("Cuckoo IP Address")
        self.Label_2.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_2, self.gbcPanel0)
        self.panel0.add(self.Label_2)

        self.IP_Address_TF = JTextField(20)
        self.IP_Address_TF.setEnabled(True)
        self.gbcPanel0.gridx = 4
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.IP_Address_TF, self.gbcPanel0)
        self.panel0.add(self.IP_Address_TF)

        self.Blank_2 = JLabel(" ")
        self.Blank_2.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 7
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_2, self.gbcPanel0)
        self.panel0.add(self.Blank_2)

        self.Label_3 = JLabel("Port Number")
        self.Label_3.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 9
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_3, self.gbcPanel0)
        self.panel0.add(self.Label_3)

        self.Port_Number_TF = JTextField(20)
        self.Port_Number_TF.setEnabled(True)
        self.gbcPanel0.gridx = 4
        self.gbcPanel0.gridy = 9
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Port_Number_TF, self.gbcPanel0)
        self.panel0.add(self.Port_Number_TF)

        self.Blank_3 = JLabel(" ")
        self.Blank_3.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 11
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_3, self.gbcPanel0)
        self.panel0.add(self.Blank_3)

        self.Save_Settings_BTN = JButton("Save Setup",
                                         actionPerformed=self.SaveSettings)
        self.Save_Settings_BTN.setEnabled(True)
        self.rbgPanel0.add(self.Save_Settings_BTN)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 13
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Save_Settings_BTN, self.gbcPanel0)
        self.panel0.add(self.Save_Settings_BTN)

        self.Blank_4 = JLabel(" ")
        self.Blank_4.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 15
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_4, self.gbcPanel0)
        self.panel0.add(self.Blank_4)

        self.Blank_5 = JLabel("Tag to Choose: ")
        self.Blank_5.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 17
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_5, self.gbcPanel0)
        self.panel0.add(self.Blank_5)

        self.find_tags()
        self.List_Box_LB = JList(self.tag_list, valueChanged=self.onchange_lb)
        self.List_Box_LB.setVisibleRowCount(3)
        self.scpList_Box_LB = JScrollPane(self.List_Box_LB)
        self.gbcPanel0.gridx = 4
        self.gbcPanel0.gridy = 17
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 1
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.scpList_Box_LB, self.gbcPanel0)
        self.panel0.add(self.scpList_Box_LB)

        self.Blank_6 = JLabel(" ")
        self.Blank_6.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 19
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_6, self.gbcPanel0)
        self.panel0.add(self.Blank_6)

        self.Submit_File_CB = JCheckBox("Submit a File",
                                        actionPerformed=self.checkBoxEvent)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 21
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Submit_File_CB, self.gbcPanel0)
        self.panel0.add(self.Submit_File_CB)

        # self.Submit_URL_CB = JCheckBox("Submit a URL", actionPerformed=self.checkBoxEvent)
        # self.gbcPanel0.gridx = 2
        # self.gbcPanel0.gridy = 23
        # self.gbcPanel0.gridwidth = 1
        # self.gbcPanel0.gridheight = 1
        # self.gbcPanel0.fill = GridBagConstraints.BOTH
        # self.gbcPanel0.weightx = 1
        # self.gbcPanel0.weighty = 0
        # self.gbcPanel0.anchor = GridBagConstraints.NORTH
        # self.gbPanel0.setConstraints( self.Submit_URL_CB, self.gbcPanel0 )
        # self.panel0.add( self.Submit_URL_CB )

        self.Check_Server_Status_BTN = JButton(
            "Check Server Status", actionPerformed=self.Check_Server)
        self.Check_Server_Status_BTN.setEnabled(True)
        self.rbgPanel0.add(self.Save_Settings_BTN)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 25
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Check_Server_Status_BTN,
                                     self.gbcPanel0)
        self.panel0.add(self.Check_Server_Status_BTN)

        self.Error_Message = JLabel("")
        self.Error_Message.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 27
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Error_Message, self.gbcPanel0)
        self.panel0.add(self.Error_Message)

        self.add(self.panel0)

    # Custom load any data field and initialize the values
    def customizeComponents(self):
        #self.Exclude_File_Sources_CB.setSelected(self.local_settings.getExclude_File_Sources())
        #self.Run_Cuckoo_CB.setSelected(self.local_settings.getRun_Cuckoo())
        #self.Import_Cuckoo_CB.setSelected(self.local_settings.getImport_Cuckoo())
        self.check_Database_entries()

    # Return the settings used
    def getSettings(self):
        return self.local_settings
class GUI_Test_SQLSettingsWithUISettingsPanel(IngestModuleIngestJobSettingsPanel):
    # Note, we can't use a self.settings instance variable.
    # Rather, self.local_settings is used.
    # https://wiki.python.org/jython/UserGuide#javabean-properties
    # Jython Introspector generates a property - 'settings' on the basis
    # of getSettings() defined in this class. Since only getter function
    # is present, it creates a read-only 'settings' property. This auto-
    # generated read-only property overshadows the instance-variable -
    # 'settings'
    
    # We get passed in a previous version of the settings so that we can
    # prepopulate the UI
    # TODO: Update this for your UI
    def __init__(self, settings):
        self.local_settings = settings
        self.initComponents()
        self.customizeComponents()
    
    # Check the checkboxs to see what actions need to be taken
    def checkBoxEvent(self, event):
        if self.Exec_Program_CB.isSelected():
            self.local_settings.setExec_Prog_Flag(True)
            self.Program_Executable_TF.setEnabled(True)
            self.Find_Program_Exec_BTN.setEnabled(True)
        else:
            self.local_settings.setExec_Prog_Flag(False)
            self.Program_Executable_TF.setText("")
            self.Program_Executable_TF.setEnabled(False)
            self.Find_Program_Exec_BTN.setEnabled(False)

    # Check to see if there are any entries that need to be populated from the database.        
    def check_Database_entries(self):
        head, tail = os.path.split(os.path.abspath(__file__)) 
        settings_db = head + "\\GUI_Settings.db3"
        try: 
            Class.forName("org.sqlite.JDBC").newInstance()
            dbConn = DriverManager.getConnection("jdbc:sqlite:%s"  % settings_db)
        except SQLException as e:
            self.Error_Message.setText("Error Opening Settings DB!")
 
        try:
           stmt = dbConn.createStatement()
           SQL_Statement = 'Select Setting_Name, Setting_Value from settings;' 
           resultSet = stmt.executeQuery(SQL_Statement)
           while resultSet.next():
               if resultSet.getString("Setting_Name") == "Program_Exec_Name":
                   self.Program_Executable_TF.setText(resultSet.getString("Setting_Value"))
                   self.local_settings.setExecFile(resultSet.getString("Setting_Value"))
                   self.local_settings.setExec_Prog_Flag(True)
                   self.Exec_Program_CB.setSelected(True)
                   self.Program_Executable_TF.setEnabled(True)
                   self.Find_Program_Exec_BTN.setEnabled(True)
           self.Error_Message.setText("Settings Read successfully!")
        except SQLException as e:
            self.Error_Message.setText("Error Reading Settings Database")

        stmt.close()
        dbConn.close()

    # Save entries from the GUI to the database.
    def SaveSettings(self, e):
        
        head, tail = os.path.split(os.path.abspath(__file__)) 
        settings_db = head + "\\GUI_Settings.db3"
        try: 
            Class.forName("org.sqlite.JDBC").newInstance()
            dbConn = DriverManager.getConnection("jdbc:sqlite:%s"  % settings_db)
        except SQLException as e:
            self.Error_Message.setText("Error Opening Settings")
 
        try:
           stmt = dbConn.createStatement()
           SQL_Statement = 'Insert into settings (Setting_Name, Setting_Value) values ("Program_Exec_Name", "' +  \
                           self.Program_Executable_TF.getText() + '");' 
           
           resultSet = stmt.executeQuery(SQL_Statement)
           self.Error_Message.setText("Settings Saved")
        except SQLException as e:
           self.Error_Message.setText("Error Inserting Settings")
        stmt.close()
        dbConn.close()
           
    # When button to find file is clicked then open dialog to find the file and return it.       
    def onClick(self, e):

       chooseFile = JFileChooser()
       filter = FileNameExtensionFilter("SQLite", ["sqlite"])
       chooseFile.addChoosableFileFilter(filter)

       ret = chooseFile.showDialog(self.panel0, "Select SQLite")

       if ret == JFileChooser.APPROVE_OPTION:
           file = chooseFile.getSelectedFile()
           Canonical_file = file.getCanonicalPath()
           #text = self.readPath(file)
           self.local_settings.setExecFile(Canonical_file)
           self.Program_Executable_TF.setText(Canonical_file)

    # Create the initial data fields/layout in the UI
    def initComponents(self):
        self.panel0 = JPanel()

        self.rbgPanel0 = ButtonGroup() 
        self.gbPanel0 = GridBagLayout() 
        self.gbcPanel0 = GridBagConstraints() 
        self.panel0.setLayout( self.gbPanel0 ) 

        self.Exec_Program_CB = JCheckBox("Execute Program", actionPerformed=self.checkBoxEvent)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 1 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Exec_Program_CB, self.gbcPanel0 ) 
        self.panel0.add( self.Exec_Program_CB ) 

        self.Program_Executable_TF = JTextField(20) 
        self.Program_Executable_TF.setEnabled(False)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 3 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Program_Executable_TF, self.gbcPanel0 ) 
        self.panel0.add( self.Program_Executable_TF ) 

        self.Find_Program_Exec_BTN = JButton( "Find Exec", actionPerformed=self.onClick)
        self.Find_Program_Exec_BTN.setEnabled(False)
        self.rbgPanel0.add( self.Find_Program_Exec_BTN ) 
        self.gbcPanel0.gridx = 6 
        self.gbcPanel0.gridy = 3 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Find_Program_Exec_BTN, self.gbcPanel0 ) 
        self.panel0.add( self.Find_Program_Exec_BTN ) 

        self.Blank_1 = JLabel( " ") 
        self.Blank_1.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_1, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_1 ) 

        self.Save_Settings_BTN = JButton( "Save Settings", actionPerformed=self.SaveSettings) 
        self.Save_Settings_BTN.setEnabled(True)
        self.rbgPanel0.add( self.Save_Settings_BTN ) 
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 7
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Save_Settings_BTN, self.gbcPanel0 ) 
        self.panel0.add( self.Save_Settings_BTN ) 

        self.Blank_2 = JLabel( " ") 
        self.Blank_2.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 9
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_2, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_2 ) 

        self.Label_1 = JLabel( "Error Message:") 
        self.Label_1.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 11
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_1, self.gbcPanel0 ) 
        self.panel0.add( self.Label_1 ) 
		
        self.Error_Message = JLabel( "") 
        self.Error_Message.setEnabled(True)
        self.gbcPanel0.gridx = 6
        self.gbcPanel0.gridy = 11
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints( self.Error_Message, self.gbcPanel0 ) 
        self.panel0.add( self.Error_Message ) 

        self.add(self.panel0)

    # Custom load any data field and initialize the values
    def customizeComponents(self):
        self.Exec_Program_CB.setSelected(self.local_settings.getExec_Prog_Flag())
        self.check_Database_entries()

    # Return the settings used
    def getSettings(self):
        return self.local_settings
Ejemplo n.º 7
0
class Remove_ArtifactsWithUISettingsPanel(IngestModuleIngestJobSettingsPanel):
    # Note, we can't use a self.settings instance variable.
    # Rather, self.local_settings is used.
    # https://wiki.python.org/jython/UserGuide#javabean-properties
    # Jython Introspector generates a property - 'settings' on the basis
    # of getSettings() defined in this class. Since only getter function
    # is present, it creates a read-only 'settings' property. This auto-
    # generated read-only property overshadows the instance-variable -
    # 'settings'

    # We get passed in a previous version of the settings so that we can
    # prepopulate the UI
    # TODO: Update this for your UI
    def __init__(self, settings):
        self.local_settings = settings
        self.artifact_list = []
        self.initComponents()
        self.customizeComponents()

    # Check to see if there are any entries that need to be populated from the database.
    def checkBoxEvent(self, event):
        if self.All_Artifacts_CB.isSelected():
            self.local_settings.setSetting('allArtifacts', 'true')
            self.List_Box_LB.setEnabled(False)
        else:
            self.local_settings.setSetting('allArtifacts', 'false')
            self.List_Box_LB.setEnabled(True)

        if self.All_Attributes_CB.isSelected():
            self.local_settings.setSetting('allAttributes', 'true')
            self.List_Box_LB.setEnabled(False)
        else:
            self.local_settings.setSetting('allAttributes', 'false')
            self.List_Box_LB.setEnabled(True)

    def onchange_lb(self, event):
        self.local_settings.setSetting('listSelected', '')
        list_selected = self.List_Box_LB.getSelectedValuesList()
        self.local_settings.setSetting('listSelected', list_selected)

    def get_artifacts(self):

        sql_statement = "select distinct(type_name) 'type_name' from blackboard_artifacts a, blackboard_artifact_types b " + \
                        " where a.artifact_type_id = b.artifact_type_id;"
        skCase = Case.getCurrentCase().getSleuthkitCase()
        dbquery = skCase.executeQuery(sql_statement)
        resultSet = dbquery.getResultSet()
        while resultSet.next():
            self.artifact_list.append(resultSet.getString("type_name"))
        dbquery.close()

    # Create the initial data fields/layout in the UI
    def initComponents(self):
        self.panel0 = JPanel()

        self.rbgPanel0 = ButtonGroup()
        self.gbPanel0 = GridBagLayout()
        self.gbcPanel0 = GridBagConstraints()
        self.panel0.setLayout(self.gbPanel0)

        self.All_Artifacts_CB = JCheckBox("Remove All Custom Artifacts",
                                          actionPerformed=self.checkBoxEvent)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 1
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.All_Artifacts_CB, self.gbcPanel0)
        self.panel0.add(self.All_Artifacts_CB)

        self.All_Attributes_CB = JCheckBox("Remove All Custom Attributes",
                                           actionPerformed=self.checkBoxEvent)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 3
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.All_Attributes_CB, self.gbcPanel0)
        self.panel0.add(self.All_Attributes_CB)

        self.Blank_0 = JLabel(" ")
        self.Blank_0.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_0, self.gbcPanel0)
        self.panel0.add(self.Blank_0)

        self.Label_0 = JLabel("Remove selected Artifacts")
        self.Label_0.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_0, self.gbcPanel0)
        self.panel0.add(self.Label_0)

        self.Blank_0 = JLabel(" ")
        self.Blank_0.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_0, self.gbcPanel0)
        self.panel0.add(self.Blank_0)

        self.get_artifacts()
        self.List_Box_LB = JList(self.artifact_list,
                                 valueChanged=self.onchange_lb)
        self.List_Box_LB.setVisibleRowCount(3)
        self.scpList_Box_LB = JScrollPane(self.List_Box_LB)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 7
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 1
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.scpList_Box_LB, self.gbcPanel0)
        self.panel0.add(self.scpList_Box_LB)

        self.Blank_1 = JLabel(" ")
        self.Blank_1.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 9
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_1, self.gbcPanel0)
        self.panel0.add(self.Blank_1)

        self.Label_1 = JLabel("Message:")
        self.Label_1.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 11
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_1, self.gbcPanel0)
        self.panel0.add(self.Label_1)

        self.Blank_2 = JLabel(" ")
        self.Blank_2.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 13
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_2, self.gbcPanel0)
        self.panel0.add(self.Blank_2)

        self.Error_Message = JLabel(
            "For developer purposes only, it may fubar your case")
        self.Error_Message.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 15
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Error_Message, self.gbcPanel0)
        self.panel0.add(self.Error_Message)

        self.add(self.panel0)

    # Custom load any data field and initialize the values
    def customizeComponents(self):
        self.All_Artifacts_CB.setSelected(
            self.local_settings.getSetting('allArtifacts') == 'true')
        self.All_Attributes_CB.setSelected(
            self.local_settings.getSetting('allAttributes') == 'true')

    # Return the settings used
    def getSettings(self):
        return self.local_settings
class GUI_Test_SQLSettingsWithUISettingsPanel(IngestModuleIngestJobSettingsPanel):
    # Note, we can't use a self.settings instance variable.
    # Rather, self.local_settings is used.
    # https://wiki.python.org/jython/UserGuide#javabean-properties
    # Jython Introspector generates a property - 'settings' on the basis
    # of getSettings() defined in this class. Since only getter function
    # is present, it creates a read-only 'settings' property. This auto-
    # generated read-only property overshadows the instance-variable -
    # 'settings'
    
    # We get passed in a previous version of the settings so that we can
    # prepopulate the UI
    # TODO: Update this for your UI
    def __init__(self, settings):
        self.local_settings = settings
        self.initComponents()
        self.customizeComponents()
    
    # Check the checkboxs to see what actions need to be taken
    def checkBoxEvent(self, event):
        if self.Exec_Program_CB.isSelected():
            self.local_settings.setSetting('Exec_Prog_Flag', 'true')
            self.Program_Executable_TF.setEnabled(True)
            self.Find_Program_Exec_BTN.setEnabled(True)
        else:
            self.local_settings.setSetting('Exec_Prog_Flag', 'false')
            self.Program_Executable_TF.setText("")
            self.Program_Executable_TF.setEnabled(False)
            self.Find_Program_Exec_BTN.setEnabled(False)

    # Check to see if there are any entries that need to be populated from the database.        
    def check_Database_entries(self):
        head, tail = os.path.split(os.path.abspath(__file__)) 
        settings_db = os.path.join(head, "GUI_Settings.db3")
        try: 
            Class.forName("org.sqlite.JDBC").newInstance()
            dbConn = DriverManager.getConnection("jdbc:sqlite:%s"  % settings_db)
        except SQLException as e:
            self.Error_Message.setText("Error Opening Settings DB!")
 
        try:
           stmt = dbConn.createStatement()
           SQL_Statement = 'Select Setting_Name, Setting_Value from settings;' 
           resultSet = stmt.executeQuery(SQL_Statement)
           while resultSet.next():
               if resultSet.getString("Setting_Name") == "Program_Exec_Name":
                   self.Program_Executable_TF.setText(resultSet.getString("Setting_Value"))
                   self.local_settings.setSetting('ExecFile', resultSet.getString("Setting_Value"))
                   self.local_settings.setSetting('Exec_Prog_Flag', 'true')
                   self.Exec_Program_CB.setSelected(True)
                   self.Program_Executable_TF.setEnabled(True)
                   self.Find_Program_Exec_BTN.setEnabled(True)
           self.Error_Message.setText("Settings Read successfully!")
        except SQLException as e:
            self.Error_Message.setText("Error Reading Settings Database")

        stmt.close()
        dbConn.close()

    # Save entries from the GUI to the database.
    def SaveSettings(self, e):
        
        head, tail = os.path.split(os.path.abspath(__file__)) 
        settings_db = os.path.join(head, "GUI_Settings.db3")
        try: 
            Class.forName("org.sqlite.JDBC").newInstance()
            dbConn = DriverManager.getConnection("jdbc:sqlite:%s"  % settings_db)
        except SQLException as e:
            self.Error_Message.setText("Error Opening Settings")
 
        try:
           stmt = dbConn.createStatement()
           SQL_Statement = 'Insert into settings (Setting_Name, Setting_Value) values ("Program_Exec_Name", "' +  \
                           self.Program_Executable_TF.getText() + '");' 
           
           resultSet = stmt.executeQuery(SQL_Statement)
           self.Error_Message.setText("Settings Saved")
        except SQLException as e:
           self.Error_Message.setText("Error Inserting Settings " + str(e))
        stmt.close()
        dbConn.close()
           
    # When button to find file is clicked then open dialog to find the file and return it.       
    def onClick(self, e):

       chooseFile = JFileChooser()
       filter = FileNameExtensionFilter("SQLite", ["sqlite"])
       chooseFile.addChoosableFileFilter(filter)

       ret = chooseFile.showDialog(self.panel0, "Select SQLite")

       if ret == JFileChooser.APPROVE_OPTION:
           file = chooseFile.getSelectedFile()
           Canonical_file = file.getCanonicalPath()
           #text = self.readPath(file)
           self.local_settings.setSetting('ExecFile', Canonical_file)
           self.Program_Executable_TF.setText(Canonical_file)

    # Create the initial data fields/layout in the UI
    def initComponents(self):
        self.panel0 = JPanel()

        self.rbgPanel0 = ButtonGroup() 
        self.gbPanel0 = GridBagLayout() 
        self.gbcPanel0 = GridBagConstraints() 
        self.panel0.setLayout( self.gbPanel0 ) 

        self.Exec_Program_CB = JCheckBox("Execute Program", actionPerformed=self.checkBoxEvent)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 1 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Exec_Program_CB, self.gbcPanel0 ) 
        self.panel0.add( self.Exec_Program_CB ) 

        self.Program_Executable_TF = JTextField(20) 
        self.Program_Executable_TF.setEnabled(False)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 3 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Program_Executable_TF, self.gbcPanel0 ) 
        self.panel0.add( self.Program_Executable_TF ) 

        self.Find_Program_Exec_BTN = JButton( "Find Exec", actionPerformed=self.onClick)
        self.Find_Program_Exec_BTN.setEnabled(False)
        self.rbgPanel0.add( self.Find_Program_Exec_BTN ) 
        self.gbcPanel0.gridx = 6 
        self.gbcPanel0.gridy = 3 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Find_Program_Exec_BTN, self.gbcPanel0 ) 
        self.panel0.add( self.Find_Program_Exec_BTN ) 

        self.Blank_1 = JLabel( " ") 
        self.Blank_1.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_1, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_1 ) 

        self.Save_Settings_BTN = JButton( "Save Settings", actionPerformed=self.SaveSettings) 
        self.Save_Settings_BTN.setEnabled(True)
        self.rbgPanel0.add( self.Save_Settings_BTN ) 
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 7
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Save_Settings_BTN, self.gbcPanel0 ) 
        self.panel0.add( self.Save_Settings_BTN ) 

        self.Blank_2 = JLabel( " ") 
        self.Blank_2.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 9
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_2, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_2 ) 

        self.Label_1 = JLabel( "Error Message:") 
        self.Label_1.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 11
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_1, self.gbcPanel0 ) 
        self.panel0.add( self.Label_1 ) 
		
        self.Error_Message = JLabel( "") 
        self.Error_Message.setEnabled(True)
        self.gbcPanel0.gridx = 6
        self.gbcPanel0.gridy = 11
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints( self.Error_Message, self.gbcPanel0 ) 
        self.panel0.add( self.Error_Message ) 

        self.add(self.panel0)

    # Custom load any data field and initialize the values
    def customizeComponents(self):
        self.Exec_Program_CB.setSelected(self.local_settings.getSetting('Exec_Prog_Flag') == 'true')
        self.check_Database_entries()

    # Return the settings used
    def getSettings(self):
        return self.local_settings
Ejemplo n.º 9
0
class CuckooSettingsWithUISettingsPanel(IngestModuleIngestJobSettingsPanel):
    # Note, we can't use a self.settings instance variable.
    # Rather, self.local_settings is used.
    # https://wiki.python.org/jython/UserGuide#javabean-properties
    # Jython Introspector generates a property - 'settings' on the basis
    # of getSettings() defined in this class. Since only getter function
    # is present, it creates a read-only 'settings' property. This auto-
    # generated read-only property overshadows the instance-variable -
    # 'settings'

    # We get passed in a previous version of the settings so that we can
    # prepopulate the UI
    # TODO: Update this for your UI
    def __init__(self, settings):
        self.local_settings = settings
        self.tag_list = []
        self.initComponents()
        self.customizeComponents()
        self.path_to_cuckoo_exe = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), "cuckoo_api.exe")

    # Check the checkboxs to see what actions need to be taken
    def checkBoxEvent(self, event):
        if self.Submit_File_CB.isSelected():
            self.local_settings.setSetting('Submit_File', 'true')
            self.local_settings.setSetting('Submit_URL', 'false')
        else:
            self.local_settings.setSetting('Submit_File', 'false')

    def onchange_lb(self, event):
        self.local_settings.cleartag_list()
        list_selected = self.List_Box_LB.getSelectedValuesList()
        self.local_settings.setSetting('tag_list', str(list_selected))

    def find_tags(self):

        sql_statement = "SELECT distinct(display_name) u_tag_name FROM content_tags INNER JOIN tag_names ON " + \
                        " content_tags.tag_name_id = tag_names.tag_name_id;"
        skCase = Case.getCurrentCase().getSleuthkitCase()
        dbquery = skCase.executeQuery(sql_statement)
        resultSet = dbquery.getResultSet()
        while resultSet.next():
            self.tag_list.append(resultSet.getString("u_tag_name"))
        dbquery.close()

    # Check to see if the Cuckoo server is available and you can talk to it
    def Check_Server(self, e):

        pipe = Popen([
            self.path_to_cuckoo_exe,
            self.Protocol_TF.getText(),
            self.IP_Address_TF.getText(),
            self.Port_Number_TF.getText(), "cuckoo_status"
        ],
                     stdout=PIPE,
                     stderr=PIPE)

        out_text = pipe.communicate()[0]
        self.Error_Message.setText("Cuckoo Status is " + out_text)
        #self.log(Level.INFO, "Cuckoo Status is ==> " + out_text)

    def setIPAddress(self, event):
        self.local_settings.setSetting('IP_Address',
                                       self.IP_Address_TF.getText())

    def setProtocol(self, event):
        self.local_settings.setSetting('Protocol', self.Protocol_TF.getText())

    def setPortNumber(self, event):
        self.local_settings.setSetting('Port_Number',
                                       self.Port_Number_TF.getText())

    # Create the initial data fields/layout in the UI
    def initComponents(self):
        self.panel0 = JPanel()

        self.rbgPanel0 = ButtonGroup()
        self.gbPanel0 = GridBagLayout()
        self.gbcPanel0 = GridBagConstraints()
        self.panel0.setLayout(self.gbPanel0)

        self.Label_1 = JLabel("Protocol:")
        self.Label_1.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 1
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_1, self.gbcPanel0)
        self.panel0.add(self.Label_1)

        self.Protocol_TF = JTextField(20, focusLost=self.setProtocol)
        self.Protocol_TF.setEnabled(True)
        self.gbcPanel0.gridx = 4
        self.gbcPanel0.gridy = 1
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Protocol_TF, self.gbcPanel0)
        self.panel0.add(self.Protocol_TF)

        self.Blank_1 = JLabel(" ")
        self.Blank_1.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 3
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_1, self.gbcPanel0)
        self.panel0.add(self.Blank_1)

        self.Label_2 = JLabel("Cuckoo IP Address")
        self.Label_2.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_2, self.gbcPanel0)
        self.panel0.add(self.Label_2)

        self.IP_Address_TF = JTextField(20, focusLost=self.setIPAddress)
        self.IP_Address_TF.setEnabled(True)
        self.gbcPanel0.gridx = 4
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.IP_Address_TF, self.gbcPanel0)
        self.panel0.add(self.IP_Address_TF)

        self.Blank_2 = JLabel(" ")
        self.Blank_2.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 7
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_2, self.gbcPanel0)
        self.panel0.add(self.Blank_2)

        self.Label_3 = JLabel("Port Number")
        self.Label_3.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 9
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_3, self.gbcPanel0)
        self.panel0.add(self.Label_3)

        self.Port_Number_TF = JTextField(20, focusLost=self.setPortNumber)
        self.Port_Number_TF.setEnabled(True)
        self.gbcPanel0.gridx = 4
        self.gbcPanel0.gridy = 9
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Port_Number_TF, self.gbcPanel0)
        self.panel0.add(self.Port_Number_TF)

        self.Blank_3 = JLabel(" ")
        self.Blank_3.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 11
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_3, self.gbcPanel0)
        self.panel0.add(self.Blank_3)

        self.Blank_5 = JLabel("Tag to Choose: ")
        self.Blank_5.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 13
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_5, self.gbcPanel0)
        self.panel0.add(self.Blank_5)

        self.find_tags()
        self.List_Box_LB = JList(self.tag_list, valueChanged=self.onchange_lb)
        self.List_Box_LB.setVisibleRowCount(3)
        self.scpList_Box_LB = JScrollPane(self.List_Box_LB)
        self.gbcPanel0.gridx = 4
        self.gbcPanel0.gridy = 13
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 1
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.scpList_Box_LB, self.gbcPanel0)
        self.panel0.add(self.scpList_Box_LB)

        self.Blank_6 = JLabel(" ")
        self.Blank_6.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 15
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_6, self.gbcPanel0)
        self.panel0.add(self.Blank_6)

        self.Submit_File_CB = JCheckBox("Submit a File",
                                        actionPerformed=self.checkBoxEvent)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 17
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Submit_File_CB, self.gbcPanel0)
        self.panel0.add(self.Submit_File_CB)

        # self.Submit_URL_CB = JCheckBox("Submit a URL", actionPerformed=self.checkBoxEvent)
        # self.gbcPanel0.gridx = 2
        # self.gbcPanel0.gridy = 23
        # self.gbcPanel0.gridwidth = 1
        # self.gbcPanel0.gridheight = 1
        # self.gbcPanel0.fill = GridBagConstraints.BOTH
        # self.gbcPanel0.weightx = 1
        # self.gbcPanel0.weighty = 0
        # self.gbcPanel0.anchor = GridBagConstraints.NORTH
        # self.gbPanel0.setConstraints( self.Submit_URL_CB, self.gbcPanel0 )
        # self.panel0.add( self.Submit_URL_CB )

        self.Check_Server_Status_BTN = JButton(
            "Check Server Status", actionPerformed=self.Check_Server)
        self.Check_Server_Status_BTN.setEnabled(True)
        self.rbgPanel0.add(self.Check_Server_Status_BTN)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 19
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Check_Server_Status_BTN,
                                     self.gbcPanel0)
        self.panel0.add(self.Check_Server_Status_BTN)

        self.Error_Message = JLabel("")
        self.Error_Message.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 21
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Error_Message, self.gbcPanel0)
        self.panel0.add(self.Error_Message)

        self.add(self.panel0)

    # Custom load any data field and initialize the values
    def customizeComponents(self):
        #self.Exclude_File_Sources_CB.setSelected(self.local_settings.getExclude_File_Sources())
        #self.Run_Cuckoo_CB.setSelected(self.local_settings.getSetting('Submit_File') == 'true')
        #self.Import_Cuckoo_CB.setSelected(self.local_settings.getImport_Cuckoo())
        self.Port_Number_TF.setText(
            self.local_settings.getSetting('Port_Number'))
        self.IP_Address_TF.setText(
            self.local_settings.getSetting('IP_Address'))
        self.Protocol_TF.setText(self.local_settings.getSetting('Protocol'))

    # Return the settings used
    def getSettings(self):
        return self.local_settings
Ejemplo n.º 10
0
class VolatilitySettingsWithUISettingsPanel(IngestModuleIngestJobSettingsPanel
                                            ):
    # Note, we can't use a self.settings instance variable.
    # Rather, self.local_settings is used.
    # https://wiki.python.org/jython/UserGuide#javabean-properties
    # Jython Introspector generates a property - 'settings' on the basis
    # of getSettings() defined in this class. Since only getter function
    # is present, it creates a read-only 'settings' property. This auto-
    # generated read-only property overshadows the instance-variable -
    # 'settings'

    # We get passed in a previous version of the settings so that we can
    # prepopulate the UI
    # TODO: Update this for your UI
    def __init__(self, settings):
        self.local_settings = settings
        self.initComponents()
        self.customizeComponents()

    # When button to find file is clicked then open dialog to find the file and return it.
    def Find_Dir(self, e):

        chooseFile = JFileChooser()
        filter = FileNameExtensionFilter("All", ["*.*"])
        chooseFile.addChoosableFileFilter(filter)
        #chooseFile.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)

        ret = chooseFile.showDialog(self.panel0, "Find Volatility Directory")

        if ret == JFileChooser.APPROVE_OPTION:
            file = chooseFile.getSelectedFile()
            Canonical_file = file.getCanonicalPath()
            #text = self.readPath(file)
            self.local_settings.setSetting('Volatility_Directory',
                                           Canonical_file)
            self.Program_Executable_TF.setText(Canonical_file)

    def keyPressed(self, event):
        self.local_settings.setProcessIDs(
            self.Process_Ids_To_Dump_TF.getText())
        #self.Error_Message.setText(self.Process_Ids_To_Dump_TF.getText())

    def checkBoxEvent(self, event):
        if self.Check_Box.isSelected():
            self.local_settings.setSetting('Flag', 'true')
        else:
            self.local_settings.setSetting('Flag', 'False')

    # Create the initial data fields/layout in the UI
    def initComponents(self):
        self.panel0 = JPanel()

        self.rbgPanel0 = ButtonGroup()
        self.gbPanel0 = GridBagLayout()
        self.gbcPanel0 = GridBagConstraints()
        self.panel0.setLayout(self.gbPanel0)

        self.Error_Message = JLabel("")
        self.Error_Message.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 15
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Error_Message, self.gbcPanel0)
        self.panel0.add(self.Error_Message)

        self.Label_1 = JLabel("Volatility Executable Directory")
        self.Label_1.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 1
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_1, self.gbcPanel0)
        self.panel0.add(self.Label_1)

        self.Program_Executable_TF = JTextField(10)
        self.Program_Executable_TF.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 3
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Program_Executable_TF,
                                     self.gbcPanel0)
        self.panel0.add(self.Program_Executable_TF)

        self.Find_Program_Exec_BTN = JButton("Find Dir",
                                             actionPerformed=self.Find_Dir)
        self.Find_Program_Exec_BTN.setEnabled(True)
        self.rbgPanel0.add(self.Find_Program_Exec_BTN)
        self.gbcPanel0.gridx = 6
        self.gbcPanel0.gridy = 3
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Find_Program_Exec_BTN,
                                     self.gbcPanel0)
        self.panel0.add(self.Find_Program_Exec_BTN)

        self.Blank_1 = JLabel(" ")
        self.Blank_1.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_1, self.gbcPanel0)
        self.panel0.add(self.Blank_1)

        self.Blank_3 = JLabel(" ")
        self.Blank_3.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 7
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_3, self.gbcPanel0)
        self.panel0.add(self.Blank_3)

        self.Check_Box = JCheckBox(
            "Extract and Create Memory Image from Hiberfile",
            actionPerformed=self.checkBoxEvent)
        self.Blank_1.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 9
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Check_Box, self.gbcPanel0)
        self.panel0.add(self.Check_Box)

        self.Blank_4 = JLabel(" ")
        self.Blank_4.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 11
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_4, self.gbcPanel0)
        self.panel0.add(self.Blank_4)

        self.Label_3 = JLabel("Message:")
        self.Label_3.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 13
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_3, self.gbcPanel0)
        self.panel0.add(self.Label_3)

        self.add(self.panel0)

    # Custom load any data field and initialize the values
    def customizeComponents(self):
        self.Check_Box.setSelected(
            self.local_settings.getSetting('Flag') == 'true')
        self.Program_Executable_TF.setText(
            self.local_settings.getSetting('Volatility_Directory'))
        #pass

    # Return the settings used
    def getSettings(self):
        return self.local_settings
Ejemplo n.º 11
0
class CloudtopsyWithUISettingsPanel(IngestModuleIngestJobSettingsPanel):
    # Note, we can't use a self.settings instance variable.
    # Rather, self.local_settings is used.
    # https://wiki.python.org/jython/UserGuide#javabean-properties
    # Jython Introspector generates a property - 'settings' on the basis
    # of getSettings() defined in this class. Since only getter function
    # is present, it creates a read-only 'settings' property. This auto-
    # generated read-only property overshadows the instance-variable -
    # 'settings'

    # We get passed in a previous version of the settings so that we can
    # prepopulate the UI
    # TODO: Update this for your UI
    def __init__(self, settings):
        self.local_settings = settings
        self.initComponents()
        self.customizeComponents()

    # Check to see if there are any entries that need to be populated from the database.
    def check_Database_entries(self):
        head, tail = os.path.split(os.path.abspath(__file__))
        settings_db = head + "\\config.db"

        try:
            Class.forName("org.sqlite.JDBC").newInstance()
            dbConn = DriverManager.getConnection("jdbc:sqlite:%s" %
                                                 settings_db)
        except SQLException as e:
            self.Error_Message.setText("Error Opening Settings DB!")

        if os.path.exists(settings_db):

            try:
                stmt = dbConn.createStatement()
                SQL_Statement = 'Select Key_Name, Key_Value from CONFIG;'
                resultSet = stmt.executeQuery(SQL_Statement)
                while resultSet.next():
                    if resultSet.getString("Key_Name") == "BUCKET":
                        self.local_settings.setBucket(
                            resultSet.getString("Key_Value"))
                        self.Bucket_TF.setText(
                            resultSet.getString("Key_Value"))
                    if resultSet.getString("Key_Name") == "ACCESS_KEY":
                        self.local_settings.setAccessKey(
                            resultSet.getString("Key_Value"))
                        self.Access_Key_TF.setText(
                            resultSet.getString("Key_Value"))
                    if resultSet.getString("Key_Name") == "SECRET_KEY":
                        self.local_settings.setSecretKey(
                            resultSet.getString("Key_Value"))
                        self.Secret_Key_TF.setText(
                            resultSet.getString("Key_Value"))
                    if resultSet.getString("Key_Name") == "AWS_REGION":
                        self.local_settings.setRegion(
                            resultSet.getString("Key_Value"))
                        self.Region_TF.setText(
                            resultSet.getString("Key_Value"))
                self.Error_Message.setText("Settings Read successfully!")
            except SQLException as e:
                self.Error_Message.setText("Error Reading Settings Database")

        else:

            try:
                stmt = dbConn.createStatement()
                SQL_Statement = 'CREATE TABLE CONFIG ( Setting_Name Text, Setting_Value Text)'
                resultSet = stmt.executeQuery(SQL_Statement)
            except SQLException as e:
                self.Error_Message.setText("Error Creating Settings Database")

        stmt.close()
        dbConn.close()

    # Save entries from the GUI to the database.
    def SaveSettings(self, e):
        error = False
        head, tail = os.path.split(os.path.abspath(__file__))
        head, tail = os.path.split(os.path.abspath(__file__))
        settings_db = head + "\\config.db"
        try:
            Class.forName("org.sqlite.JDBC").newInstance()
            dbConn = DriverManager.getConnection("jdbc:sqlite:%s" %
                                                 settings_db)
        except SQLException as e:
            self.Error_Message.setText("Error Opening Settings")

        try:
            stmt = dbConn.createStatement()
            SQL_Statement = 'UPDATE CONFIG SET Key_Value = "' + self.Bucket_TF.getText(
            ) + '" WHERE Key_Name = "BUCKET";'
            resultSet = stmt.executeQuery(SQL_Statement)
        except:
            pass

        if re.match(r'[A-Z0-9]{20}', self.Access_Key_TF.getText()):
            try:
                stmt = dbConn.createStatement()
                SQL_Statement = 'UPDATE CONFIG SET Key_Value = "' + self.Access_Key_TF.getText(
                ) + '" WHERE Key_Name = "ACCESS_KEY";'
                resultSet = stmt.executeQuery(SQL_Statement)
            except:
                pass
        else:
            error = True
            self.Error_Message.setText("Access Key Invalid")

        if re.match(r'[A-Za-z0-9/+=]{40}', self.Secret_Key_TF.getText()):
            try:
                stmt = dbConn.createStatement()
                SQL_Statement = 'UPDATE CONFIG SET Key_Value = "' + self.Secret_Key_TF.getText(
                ) + '" WHERE Key_Name = "SECRET_KEY";'
                resultSet = stmt.executeQuery(SQL_Statement)
            except:
                pass
        else:
            error = True
            self.Error_Message.setText("Secret Key Invalid")

        if re.match(
                r'[a-z]{2}-(gov-)?(north|south|east|west|central)(east|west)?-\d(\w)?',
                self.Region_TF.getText()):
            try:
                stmt = dbConn.createStatement()
                SQL_Statement = 'UPDATE CONFIG SET Key_Value = "' + self.Region_TF.getText(
                ) + '" WHERE Key_Name = "AWS_REGION";'
                resultSet = stmt.executeQuery(SQL_Statement)
            except:
                pass
        else:
            error = True
            self.Error_Message.setText("AWS Region Invalid")

        if not error:
            self.Error_Message.setText("Settings Saved")
        stmt.close()
        dbConn.close()

    # Create the initial data fields/layout in the UI
    def initComponents(self):
        self.panel0 = JPanel()

        self.rbgPanel0 = ButtonGroup()
        self.gbPanel0 = GridBagLayout()
        self.gbcPanel0 = GridBagConstraints()
        self.panel0.setLayout(self.gbPanel0)

        self.LabelA = JLabel("S3 Bucket:")
        self.LabelA.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 1
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.LabelA, self.gbcPanel0)
        self.panel0.add(self.LabelA)

        self.Bucket_TF = JTextField(20)
        self.Bucket_TF.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 3
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Bucket_TF, self.gbcPanel0)
        self.panel0.add(self.Bucket_TF)

        self.Blank_1 = JLabel(" ")
        self.Blank_1.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 4
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_1, self.gbcPanel0)
        self.panel0.add(self.Blank_1)

        self.LabelB = JLabel("AWS Access Key:")
        self.LabelB.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.LabelB, self.gbcPanel0)
        self.panel0.add(self.LabelB)

        self.Access_Key_TF = JTextField(20)
        self.Access_Key_TF.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 7
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Access_Key_TF, self.gbcPanel0)
        self.panel0.add(self.Access_Key_TF)

        self.Blank_2 = JLabel(" ")
        self.Blank_2.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 8
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_2, self.gbcPanel0)
        self.panel0.add(self.Blank_2)

        self.LabelC = JLabel("AWS Secret Key:")
        self.LabelC.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 9
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.LabelC, self.gbcPanel0)
        self.panel0.add(self.LabelC)

        self.Secret_Key_TF = JTextField(20)
        self.Secret_Key_TF.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 11
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Secret_Key_TF, self.gbcPanel0)
        self.panel0.add(self.Secret_Key_TF)

        self.Blank_3 = JLabel(" ")
        self.Blank_3.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 12
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_3, self.gbcPanel0)
        self.panel0.add(self.Blank_3)

        self.LabelD = JLabel("AWS Region:")
        self.LabelD.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 13
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.LabelD, self.gbcPanel0)
        self.panel0.add(self.LabelD)

        self.Region_TF = JTextField(20)
        self.Region_TF.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 15
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Region_TF, self.gbcPanel0)
        self.panel0.add(self.Region_TF)

        self.Blank_4 = JLabel(" ")
        self.Blank_4.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 16
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_4, self.gbcPanel0)
        self.panel0.add(self.Blank_4)

        self.Save_Settings_BTN = JButton("Save Settings",
                                         actionPerformed=self.SaveSettings)
        self.Save_Settings_BTN.setEnabled(True)
        self.rbgPanel0.add(self.Save_Settings_BTN)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 17
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Save_Settings_BTN, self.gbcPanel0)
        self.panel0.add(self.Save_Settings_BTN)

        self.Label_1 = JLabel("Error Message:")
        self.Label_1.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 18
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_1, self.gbcPanel0)
        self.panel0.add(self.Label_1)

        self.Error_Message = JLabel("")
        self.Error_Message.setEnabled(True)
        self.gbcPanel0.gridx = 6
        self.gbcPanel0.gridy = 19
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Error_Message, self.gbcPanel0)
        self.panel0.add(self.Error_Message)

        self.add(self.panel0)

    # Custom load any data field and initialize the values
    def customizeComponents(self):
        self.check_Database_entries()

    # Return the settings used
    def getSettings(self):
        return self.local_settings
Ejemplo n.º 12
0
class CuckooSettingsWithUISettingsPanel(IngestModuleIngestJobSettingsPanel):
    # Note, we can't use a self.settings instance variable.
    # Rather, self.local_settings is used.
    # https://wiki.python.org/jython/UserGuide#javabean-properties
    # Jython Introspector generates a property - 'settings' on the basis
    # of getSettings() defined in this class. Since only getter function
    # is present, it creates a read-only 'settings' property. This auto-
    # generated read-only property overshadows the instance-variable -
    # 'settings'
    
    # We get passed in a previous version of the settings so that we can
    # prepopulate the UI
    # TODO: Update this for your UI
    def __init__(self, settings):
        self.local_settings = settings
        self.tag_list = []
        self.initComponents()
        self.customizeComponents()
        self.path_to_cuckoo_exe = os.path.join(os.path.dirname(os.path.abspath(__file__)), "cuckoo_api.exe")
 
    # Check the checkboxs to see what actions need to be taken
    def checkBoxEvent(self, event):
        if self.Submit_File_CB.isSelected():
            self.local_settings.setSetting('Submit_File', 'true')
            self.local_settings.setSetting('Submit_URL', 'false')
        else:
            self.local_settings.setSetting('Submit_File', 'false')
            
    def onchange_lb(self, event):
        self.local_settings.cleartag_list()
        list_selected = self.List_Box_LB.getSelectedValuesList()
        self.local_settings.setSetting('tag_list', str(list_selected))      

    def find_tags(self):
        
        sql_statement = "SELECT distinct(display_name) u_tag_name FROM content_tags INNER JOIN tag_names ON " + \
                        " content_tags.tag_name_id = tag_names.tag_name_id;"
        skCase = Case.getCurrentCase().getSleuthkitCase()
        dbquery = skCase.executeQuery(sql_statement)
        resultSet = dbquery.getResultSet()
        while resultSet.next():
             self.tag_list.append(resultSet.getString("u_tag_name"))
        dbquery.close()

    # Check to see if the Cuckoo server is available and you can talk to it
    def Check_Server(self, e):

       pipe = Popen([self.path_to_cuckoo_exe, self.Protocol_TF.getText(),self.IP_Address_TF.getText(), self.Port_Number_TF.getText(), "cuckoo_status" ], stdout=PIPE, stderr=PIPE)
        
       out_text = pipe.communicate()[0]
       self.Error_Message.setText("Cuckoo Status is " + out_text)
       #self.log(Level.INFO, "Cuckoo Status is ==> " + out_text)

           
    def setIPAddress(self, event):
        self.local_settings.setSetting('IP_Address', self.IP_Address_TF.getText()) 

    def setProtocol(self, event):
        self.local_settings.setSetting('Protocol', self.Protocol_TF.getText()) 

    def setPortNumber(self, event):
        self.local_settings.setSetting('Port_Number', self.Port_Number_TF.getText()) 

    # Create the initial data fields/layout in the UI
    def initComponents(self):
        self.panel0 = JPanel()

        self.rbgPanel0 = ButtonGroup() 
        self.gbPanel0 = GridBagLayout() 
        self.gbcPanel0 = GridBagConstraints() 
        self.panel0.setLayout( self.gbPanel0 ) 

        self.Label_1 = JLabel("Protocol:")
        self.Label_1.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 1 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_1, self.gbcPanel0 ) 
        self.panel0.add( self.Label_1 ) 

        self.Protocol_TF = JTextField(20, focusLost=self.setProtocol) 
        self.Protocol_TF.setEnabled(True)
        self.gbcPanel0.gridx = 4 
        self.gbcPanel0.gridy = 1 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Protocol_TF, self.gbcPanel0 ) 
        self.panel0.add( self.Protocol_TF ) 

        self.Blank_1 = JLabel( " ") 
        self.Blank_1.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 3
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_1, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_1 ) 

        self.Label_2 = JLabel("Cuckoo IP Address")
        self.Label_2.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 5 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_2, self.gbcPanel0 ) 
        self.panel0.add( self.Label_2 ) 

        self.IP_Address_TF = JTextField(20, focusLost=self.setIPAddress) 
        self.IP_Address_TF.setEnabled(True)
        self.gbcPanel0.gridx = 4 
        self.gbcPanel0.gridy = 5 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.IP_Address_TF, self.gbcPanel0 ) 
        self.panel0.add( self.IP_Address_TF ) 

        self.Blank_2 = JLabel( " ") 
        self.Blank_2.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 7
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_2, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_2 ) 

        self.Label_3 = JLabel("Port Number")
        self.Label_3.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 9 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_3, self.gbcPanel0 ) 
        self.panel0.add( self.Label_3 ) 

        self.Port_Number_TF = JTextField(20, focusLost=self.setPortNumber) 
        self.Port_Number_TF.setEnabled(True)
        self.gbcPanel0.gridx = 4 
        self.gbcPanel0.gridy = 9 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Port_Number_TF, self.gbcPanel0 ) 
        self.panel0.add( self.Port_Number_TF ) 

        self.Blank_3 = JLabel( " ") 
        self.Blank_3.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 11
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_3, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_3 ) 

        
        self.Blank_5 = JLabel( "Tag to Choose: ") 
        self.Blank_5.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 13
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_5, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_5 ) 

        self.find_tags()
        self.List_Box_LB = JList( self.tag_list, valueChanged=self.onchange_lb)
        self.List_Box_LB.setVisibleRowCount( 3 ) 
        self.scpList_Box_LB = JScrollPane( self.List_Box_LB ) 
        self.gbcPanel0.gridx = 4 
        self.gbcPanel0.gridy = 13 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 1 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.scpList_Box_LB, self.gbcPanel0 ) 
        self.panel0.add( self.scpList_Box_LB ) 

        self.Blank_6 = JLabel( " ") 
        self.Blank_6.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 15
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_6, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_6 ) 

        self.Submit_File_CB = JCheckBox("Submit a File", actionPerformed=self.checkBoxEvent)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 17 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Submit_File_CB, self.gbcPanel0 ) 
        self.panel0.add( self.Submit_File_CB ) 

        # self.Submit_URL_CB = JCheckBox("Submit a URL", actionPerformed=self.checkBoxEvent)
        # self.gbcPanel0.gridx = 2 
        # self.gbcPanel0.gridy = 23 
        # self.gbcPanel0.gridwidth = 1 
        # self.gbcPanel0.gridheight = 1 
        # self.gbcPanel0.fill = GridBagConstraints.BOTH 
        # self.gbcPanel0.weightx = 1 
        # self.gbcPanel0.weighty = 0 
        # self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        # self.gbPanel0.setConstraints( self.Submit_URL_CB, self.gbcPanel0 ) 
        # self.panel0.add( self.Submit_URL_CB ) 

        self.Check_Server_Status_BTN = JButton( "Check Server Status", actionPerformed=self.Check_Server) 
        self.Check_Server_Status_BTN.setEnabled(True)
        self.rbgPanel0.add( self.Check_Server_Status_BTN ) 
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 19
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Check_Server_Status_BTN, self.gbcPanel0 ) 
        self.panel0.add( self.Check_Server_Status_BTN ) 

        self.Error_Message = JLabel( "") 
        self.Error_Message.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 21
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints( self.Error_Message, self.gbcPanel0 ) 
        self.panel0.add( self.Error_Message ) 


        self.add(self.panel0)

    # Custom load any data field and initialize the values
    def customizeComponents(self):
        #self.Exclude_File_Sources_CB.setSelected(self.local_settings.getExclude_File_Sources())
        #self.Run_Cuckoo_CB.setSelected(self.local_settings.getSetting('Submit_File') == 'true')
        #self.Import_Cuckoo_CB.setSelected(self.local_settings.getImport_Cuckoo())
        self.Port_Number_TF.setText(self.local_settings.getSetting('Port_Number'))
        self.IP_Address_TF.setText(self.local_settings.getSetting('IP_Address'))
        self.Protocol_TF.setText(self.local_settings.getSetting('Protocol'))
        

    # Return the settings used
    def getSettings(self):
        return self.local_settings
Ejemplo n.º 13
0
class MacFSEventsSettingsWithUISettingsPanel(IngestModuleIngestJobSettingsPanel
                                             ):
    # Note, we can't use a self.settings instance variable.
    # Rather, self.local_settings is used.
    # https://wiki.python.org/jython/UserGuide#javabean-properties
    # Jython Introspector generates a property - 'settings' on the basis
    # of getSettings() defined in this class. Since only getter function
    # is present, it creates a read-only 'settings' property. This auto-
    # generated read-only property overshadows the instance-variable -
    # 'settings'

    # We get passed in a previous version of the settings so that we can
    # prepopulate the UI
    # TODO: Update this for your UI
    def __init__(self, settings):
        self.local_settings = settings
        self.initComponents()
        self.customizeComponents()

    def onchange_plugins_lb(self, event):
        self.local_settings.clearPluginListBox()
        list_selected = self.Plugin_LB.getSelectedValuesList()
        self.local_settings.setPluginListBox(list_selected)

    # Create the initial data fields/layout in the UI
    def initComponents(self):
        self.panel0 = JPanel()

        self.rbgPanel0 = ButtonGroup()
        self.gbPanel0 = GridBagLayout()
        self.gbcPanel0 = GridBagConstraints()
        self.panel0.setLayout(self.gbPanel0)

        self.Error_Message = JLabel("")
        self.Error_Message.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 31
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Error_Message, self.gbcPanel0)
        self.panel0.add(self.Error_Message)

        # self.Label_1 = JLabel("MacFSEvents To Include:")
        # self.Label_1.setEnabled(True)
        # self.gbcPanel0.gridx = 2
        # self.gbcPanel0.gridy = 1
        # self.gbcPanel0.gridwidth = 1
        # self.gbcPanel0.gridheight = 1
        # self.gbcPanel0.fill = GridBagConstraints.BOTH
        # self.gbcPanel0.weightx = 1
        # self.gbcPanel0.weighty = 0
        # self.gbcPanel0.anchor = GridBagConstraints.NORTH
        # self.gbPanel0.setConstraints( self.Label_1, self.gbcPanel0 )
        # self.panel0.add( self.Label_1 )

        # self.Blank_1 = JLabel( " ")
        # self.Blank_1.setEnabled(True)
        # self.gbcPanel0.gridx = 2
        # self.gbcPanel0.gridy = 5
        # self.gbcPanel0.gridwidth = 1
        # self.gbcPanel0.gridheight = 1
        # self.gbcPanel0.fill = GridBagConstraints.BOTH
        # self.gbcPanel0.weightx = 1
        # self.gbcPanel0.weighty = 0
        # self.gbcPanel0.anchor = GridBagConstraints.NORTH
        # self.gbPanel0.setConstraints( self.Blank_1, self.gbcPanel0 )
        # self.panel0.add( self.Blank_1 )

        # self.Plugin_list =  ('FolderEvent','Mount','Unmount','EndOfTransaction','LastHardLinkRemoved','HardLink', \
        # 'SymbolicLink','FileEvent','PermissionChange','ExtendedAttrModified','ExtendedAttrRemoved', \
        # 'DocumentRevisioning','Created','Removed','InodeMetaMod','Renamed','Modified', \
        # 'Exchange','FinderInfoMod','FolderCreated')
        # self.Plugin_LB = JList( self.Plugin_list, valueChanged=self.onchange_plugins_lb)
        # self.Plugin_LB.setVisibleRowCount( 7 )
        # self.scpPlugin_LB = JScrollPane( self.Plugin_LB )
        # self.gbcPanel0.gridx = 2
        # self.gbcPanel0.gridy = 7
        # self.gbcPanel0.gridwidth = 1
        # self.gbcPanel0.gridheight = 1
        # self.gbcPanel0.fill = GridBagConstraints.BOTH
        # self.gbcPanel0.weightx = 1
        # self.gbcPanel0.weighty = 1
        # self.gbcPanel0.anchor = GridBagConstraints.NORTH
        # self.gbPanel0.setConstraints( self.scpPlugin_LB, self.gbcPanel0 )
        # self.panel0.add( self.scpPlugin_LB )

        self.Blank_4 = JLabel(" ")
        self.Blank_4.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 17
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_4, self.gbcPanel0)
        self.panel0.add(self.Blank_4)

        # self.Label_3 = JLabel( "Message:")
        # self.Label_3.setEnabled(True)
        # self.gbcPanel0.gridx = 2
        # self.gbcPanel0.gridy = 29
        # self.gbcPanel0.gridwidth = 1
        # self.gbcPanel0.gridheight = 1
        # self.gbcPanel0.fill = GridBagConstraints.BOTH
        # self.gbcPanel0.weightx = 1
        # self.gbcPanel0.weighty = 0
        # self.gbcPanel0.anchor = GridBagConstraints.NORTH
        # self.gbPanel0.setConstraints( self.Label_3, self.gbcPanel0 )
        # self.panel0.add( self.Label_3 )

        self.add(self.panel0)

    # Custom load any data field and initialize the values
    def customizeComponents(self):
        #self.Exclude_File_Sources_CB.setSelected(self.local_settings.getExclude_File_Sources())
        #self.Run_Plaso_CB.setSelected(self.local_settings.getRun_Plaso())
        #self.Import_Plaso_CB.setSelected(self.local_settings.getImport_Plaso())
        #self.check_Database_entries()
        pass

    # Return the settings used
    def getSettings(self):
        return self.local_settings
class MassExportByExtensionSettingsWithUISettingsPanel(
        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
    def __init__(self, settings):
        self.local_settings = settings
        self.tag_list = []
        self.initComponents()
        self.customizeComponents()

    def setFileExtension(self, event):
        self.local_settings.setSetting('fileExtension',
                                       self.fileExtension_TF.getText())

    # Create the initial data fields/layout in the UI
    def initComponents(self):
        self.panel0 = JPanel()

        self.rbgPanel0 = ButtonGroup()
        self.gbPanel0 = GridBagLayout()
        self.gbcPanel0 = GridBagConstraints()
        self.panel0.setLayout(self.gbPanel0)

        self.Label_2 = JLabel(
            "List of File Extensions to Export, Comma Seperated no dots (.)")
        self.Label_2.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_2, self.gbcPanel0)
        self.panel0.add(self.Label_2)

        self.fileExtension_TF = JTextField(30, focusLost=self.setFileExtension)
        self.fileExtension_TF.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 7
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.fileExtension_TF, self.gbcPanel0)
        self.panel0.add(self.fileExtension_TF)

        self.Blank_2 = JLabel(" ")
        self.Blank_2.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 9
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_2, self.gbcPanel0)
        self.panel0.add(self.Blank_2)

        self.add(self.panel0)

    # Custom load any data field and initialize the values
    def customizeComponents(self):
        self.fileExtension_TF.setText(
            self.local_settings.getSetting('fileExtension'))

    # Return the settings used
    def getSettings(self):
        return self.local_settings
Ejemplo n.º 15
0
class SelectionCellRenderer(TreeCellRenderer):
    def __init__(self, tree, mapContext):
        self.tree = tree
        self.mapContext = mapContext
        self.lblGroup = JLabel()
        self.lblGroup.setBackground(Color(222, 227, 233))  #.BLUE.brighter())
        self.lblGroup.setOpaque(True)
        self.lblGroup.setText(
            "plddddddddddddddddddddddddddddddddddddddddddddddddddddddd")

        self.lblGroupPreferredSize = self.lblGroup.getPreferredSize()
        #h = self.lblGroupPreferredSize.getHeight()
        #w = self.lblGroupPreferredSize.getWidth()
        #self.lblGroupPreferredSize.setSize(h, w)
        self.pnlLayer = JPanel()
        self.pnlLayer.setOpaque(False)

        self.pnlLayer.setLayout(FlowLayout(FlowLayout.LEFT))

        self.lblClean = JLabel()

        self.chkLayerVisibility = JCheckBox()
        self.chkLayerVisibility.setOpaque(False)
        self.lblLayerName = JLabel()
        self.lblLayerIcon = JLabel()
        self.lblFeatureSelecteds = JLabel()

        self.pnlLayer.add(self.chkLayerVisibility)
        self.pnlLayer.add(self.lblClean)
        self.pnlLayer.add(self.lblFeatureSelecteds)
        self.pnlLayer.add(self.lblLayerIcon)
        self.pnlLayer.add(self.lblLayerName)
        self.tree.setRowHeight(
            int(self.pnlLayer.getPreferredSize().getHeight()) - 3)
        self.lblUnknown = JLabel()

        ## Feature
        self.lblFeatureIcon = JLabel()
        self.lblFeatureName = JLabel()
        i18n = ToolsLocator.getI18nManager()
        self.lblFeatureName.setText(i18n.getTranslation("_Feature"))
        self.pnlFeature = JPanel()
        self.pnlFeature.setOpaque(False)
        self.pnlFeature.setLayout(FlowLayout(FlowLayout.LEFT))
        self.pnlFeature.add(self.lblFeatureIcon)
        self.pnlFeature.add(self.lblFeatureName)

    def getTreeCellRendererComponent(self, tree, value, selected, expanded,
                                     leaf, row, hasFocus):
        uo = value.getUserObject()
        if isinstance(uo, DataGroup):
            text = "[" + str(value.getChildCount()) + "] " + uo.getName()
            self.lblGroup.setText(text)
            self.lblGroup.setPreferredSize(self.lblGroupPreferredSize)
            return self.lblGroup
        if isinstance(uo, DataLayer):
            layer = uo.getLayer()

            self.lblLayerName.setText(uo.getName())
            self.lblLayerIcon.setIcon(getIconFromLayer(layer))
            if layer.isVisible():
                self.lblLayerName.setEnabled(True)
            else:
                self.lblLayerName.setEnabled(False)
            self.lblClean.setIcon(getIconByName("edit-clear"))
            self.chkLayerVisibility.setSelected(layer.isVisible())
            if layer.isWithinScale(
                    self.mapContext.getScaleView()):  # and layer.isVisible():
                self.chkLayerVisibility.setEnabled(True)
            else:
                self.chkLayerVisibility.setEnabled(False)
            if layer.getDataStore() != None and layer.getDataStore(
            ).getSelection() != None and layer.getDataStore().getSelection(
            ).getSize() != 0:  # and layer.isVisible():
                self.lblClean.setEnabled(True)
                self.lblFeatureSelecteds.setText(
                    str(layer.getDataStore().getSelection().getSize()))
                self.lblFeatureSelecteds.setEnabled(True)
            else:
                self.lblClean.setEnabled(False)
                self.lblFeatureSelecteds.setText("0")
                self.lblFeatureSelecteds.setEnabled(False)

            font = self.lblLayerName.getFont()
            self.lblLayerName.setForeground(Color.BLACK)
            if layer.isEditing():
                self.lblLayerName.setForeground(Color.RED)
            #if layer.isActive():
            if layer.isActive():  # and not font.isBold():
                newfont = font.deriveFont(Font.BOLD)
                self.lblLayerName.setFont(newfont)
            else:
                newfont = font.deriveFont(Font.PLAIN)
                self.lblLayerName.setFont(newfont)

            return self.pnlLayer
        if isinstance(uo, FeatureDataLayerNode):
            self.lblFeatureName.setText(uo.getFeature().toString())
            self.lblFeatureIcon.setIcon(getIconByName("edit-clear"))

            return self.pnlFeature
        self.lblUnknown.setText("")
        self.lblUnknown.setPreferredSize(Dimension(0, 0))
        return self.lblUnknown
class VolatilitySettingsWithUISettingsPanel(IngestModuleIngestJobSettingsPanel):
    # Note, we can't use a self.settings instance variable.
    # Rather, self.local_settings is used.
    # https://wiki.python.org/jython/UserGuide#javabean-properties
    # Jython Introspector generates a property - 'settings' on the basis
    # of getSettings() defined in this class. Since only getter function
    # is present, it creates a read-only 'settings' property. This auto-
    # generated read-only property overshadows the instance-variable -
    # 'settings'
    
    # We get passed in a previous version of the settings so that we can
    # prepopulate the UI
    # TODO: Update this for your UI
    def __init__(self, settings):
        self.local_settings = settings
        self.initComponents()
        self.customizeComponents()
           
    # When button to find file is clicked then open dialog to find the file and return it.       
    def Find_Dir(self, e):

       chooseFile = JFileChooser()
       filter = FileNameExtensionFilter("All", ["*.*"])
       chooseFile.addChoosableFileFilter(filter)
       #chooseFile.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)

       ret = chooseFile.showDialog(self.panel0, "Find Volatility Directory")

       if ret == JFileChooser.APPROVE_OPTION:
           file = chooseFile.getSelectedFile()
           Canonical_file = file.getCanonicalPath()
           #text = self.readPath(file)
           self.local_settings.setSetting('Volatility_Directory', Canonical_file)
           self.Program_Executable_TF.setText(Canonical_file)

    def keyPressed(self, event):
        self.local_settings.setProcessIDs(self.Process_Ids_To_Dump_TF.getText()) 
        #self.Error_Message.setText(self.Process_Ids_To_Dump_TF.getText())
        
    def checkBoxEvent(self, event):
        if self.Check_Box.isSelected():
            self.local_settings.setSetting('Flag', 'true')
        else:
            self.local_settings.setSetting('Flag', 'False')
        
    # Create the initial data fields/layout in the UI
    def initComponents(self):
        self.panel0 = JPanel()

        self.rbgPanel0 = ButtonGroup() 
        self.gbPanel0 = GridBagLayout() 
        self.gbcPanel0 = GridBagConstraints() 
        self.panel0.setLayout( self.gbPanel0 ) 

        self.Error_Message = JLabel( "") 
        self.Error_Message.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 15
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints( self.Error_Message, self.gbcPanel0 ) 
        self.panel0.add( self.Error_Message ) 

        self.Label_1 = JLabel("Volatility Executable Directory")
        self.Label_1.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 1 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_1, self.gbcPanel0 ) 
        self.panel0.add( self.Label_1 ) 

        self.Program_Executable_TF = JTextField(10) 
        self.Program_Executable_TF.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 3 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Program_Executable_TF, self.gbcPanel0 ) 
        self.panel0.add( self.Program_Executable_TF ) 

        self.Find_Program_Exec_BTN = JButton( "Find Dir", actionPerformed=self.Find_Dir)
        self.Find_Program_Exec_BTN.setEnabled(True)
        self.rbgPanel0.add( self.Find_Program_Exec_BTN ) 
        self.gbcPanel0.gridx = 6 
        self.gbcPanel0.gridy = 3 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Find_Program_Exec_BTN, self.gbcPanel0 ) 
        self.panel0.add( self.Find_Program_Exec_BTN ) 

        self.Blank_1 = JLabel( " ") 
        self.Blank_1.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_1, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_1 ) 

        self.Blank_3 = JLabel( " ") 
        self.Blank_3.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 7
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_3, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_3 ) 

        self.Check_Box = JCheckBox("Extract and Create Memory Image from Hiberfile", actionPerformed=self.checkBoxEvent) 
        self.Blank_1.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 9
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Check_Box, self.gbcPanel0 ) 
        self.panel0.add( self.Check_Box ) 

        self.Blank_4 = JLabel( " ") 
        self.Blank_4.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 11
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_4, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_4 ) 

        self.Label_3 = JLabel( "Message:") 
        self.Label_3.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 13
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_3, self.gbcPanel0 ) 
        self.panel0.add( self.Label_3 ) 
		
        self.add(self.panel0)

    # Custom load any data field and initialize the values
    def customizeComponents(self):
        self.Check_Box.setSelected(self.local_settings.getSetting('Flag') == 'true')
        self.Program_Executable_TF.setText(self.local_settings.getSetting('Volatility_Directory'))
        #pass
        
    # Return the settings used
    def getSettings(self):
        return self.local_settings
Ejemplo n.º 17
0
class HashImageSettingsWithUISettingsPanel(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
    def __init__(self, settings):
        self.local_settings = settings
        self.initComponents()
        self.customizeComponents()
    
    def FindFTKTxtFile(self, e):

       chooseFile = JFileChooser()
       filter = FileNameExtensionFilter("ALL", ["*.*"])
       chooseFile.addChoosableFileFilter(filter)

       ret = chooseFile.showDialog(self.panel0, "Find FTK Log File")
       
       if ret == JFileChooser.APPROVE_OPTION:
           file = chooseFile.getSelectedFile()
           Canonical_file = file.getCanonicalPath()
           #text = self.readPath(file)
           self.local_settings.setFTKLogFile(Canonical_file)
           self.FTKLogFile_TF.setText(Canonical_file)

    def keyPressedMD5(self, event):  
        self.local_settings.setMD5HashValue(self.MD5HashValue_TF.getText())

    def keyPressedSHA1(self, event):  
        self.local_settings.setSHA1HashValue(self.SHA1HashValue_TF.getText())

    # Create the initial data fields/layout in the UI
    def initComponents(self):
        self.panel0 = JPanel()

        self.rbgPanel0 = ButtonGroup() 
        self.gbPanel0 = GridBagLayout() 
        self.gbcPanel0 = GridBagConstraints() 
        self.panel0.setLayout( self.gbPanel0 ) 

        self.Label_1 = JLabel("MD5 Hash Value To Verify")
        self.Label_1.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 1 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_1, self.gbcPanel0 ) 
        self.panel0.add( self.Label_1 ) 

        self.MD5HashValue_TF = JTextField(20, focusLost=self.keyPressedMD5) 
        self.MD5HashValue_TF.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 3 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.MD5HashValue_TF, self.gbcPanel0 ) 
        self.panel0.add( self.MD5HashValue_TF ) 

        self.Blank_1 = JLabel( " ") 
        self.Blank_1.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_1, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_1 ) 

        self.Label_2 = JLabel("SHA1 Hash Value To Verify")
        self.Label_2.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 7 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_2, self.gbcPanel0 ) 
        self.panel0.add( self.Label_2 ) 

        self.SHA1HashValue_TF = JTextField(20, focusLost=self.keyPressedSHA1) 
        self.SHA1HashValue_TF.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 9 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.SHA1HashValue_TF, self.gbcPanel0 ) 
        self.panel0.add( self.SHA1HashValue_TF ) 

        self.Blank_2 = JLabel( " ") 
        self.Blank_2.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 11
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_1, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_1 ) 

        self.Label_3 = JLabel("FTK Log File")
        self.Label_3.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 13 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_3, self.gbcPanel0 ) 
        self.panel0.add( self.Label_3 ) 

        self.FTKLogFile_TF = JTextField(20) 
        self.FTKLogFile_TF.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 15 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.FTKLogFile_TF, self.gbcPanel0 ) 
        self.panel0.add( self.FTKLogFile_TF ) 

        self.FTKLogFile_BTN = JButton( "Find File", actionPerformed=self.FindFTKTxtFile)
        self.FTKLogFile_BTN.setEnabled(True)
        self.rbgPanel0.add( self.FTKLogFile_BTN ) 
        self.gbcPanel0.gridx = 6 
        self.gbcPanel0.gridy = 15 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.FTKLogFile_BTN, self.gbcPanel0 ) 
        self.panel0.add( self.FTKLogFile_BTN ) 

        self.Label_4 = JLabel( "Message:") 
        self.Label_4.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 29
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_4, self.gbcPanel0 ) 
        self.panel0.add( self.Label_4 ) 
		
        self.Error_Message = JLabel( "") 
        self.Error_Message.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 31
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints( self.Error_Message, self.gbcPanel0 ) 
        self.panel0.add( self.Error_Message ) 

        self.add(self.panel0)

    # Custom load any data field and initialize the values
    def customizeComponents(self):
        pass
        
    # Return the settings used
    def getSettings(self):
        self.local_settings.setMD5HashValue(self.MD5HashValue_TF.getText())
        self.local_settings.setSHA1HashValue(self.SHA1HashValue_TF.getText())
        return self.local_settings
Ejemplo n.º 18
0
class VolatilitySettingsWithUISettingsPanel(IngestModuleIngestJobSettingsPanel):
    # Note, we can't use a self.settings instance variable.
    # Rather, self.local_settings is used.
    # https://wiki.python.org/jython/UserGuide#javabean-properties
    # Jython Introspector generates a property - 'settings' on the basis
    # of getSettings() defined in this class. Since only getter function
    # is present, it creates a read-only 'settings' property. This auto-
    # generated read-only property overshadows the instance-variable -
    # 'settings'
    
    # We get passed in a previous version of the settings so that we can
    # prepopulate the UI
    # TODO: Update this for your UI
    
    _logger = Logger.getLogger(VolatilityIngestModuleFactory.moduleName)

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

    def __init__(self, settings):
        self.local_settings = settings
        self.initComponents()
        self.customizeComponents()
    
    # Check the checkboxs to see what actions need to be taken
    def checkBoxEvent(self, event):
        if self.Exclude_File_Sources_CB.isSelected():
            self.local_settings.setSetting('Exclude_File_Sources', 'true')
        else:
            self.local_settings.setSetting('Exclude_File_Sources', 'false')

    def get_plugins(self):
        head, tail = os.path.split(os.path.abspath(__file__))
        settings_db = os.path.join(head, "GUI_Settings.db3")
        try: 
            Class.forName("org.sqlite.JDBC").newInstance()
            dbConn = DriverManager.getConnection("jdbc:sqlite:%s"  % settings_db)
            self.Error_Message.setText("Database opened")
        except SQLException as e:
            self.Error_Message.setText("Error Opening Settings DB!")
 
        try:
           stmt = dbConn.createStatement()
           SQL_Statement = "select plugin_name from plugins where volatility_version = '" + self.Version_CB.getSelectedItem() + "';" 
           resultSet = stmt.executeQuery(SQL_Statement)
           plugin_list = []
           while resultSet.next():
              plugin_list.append(resultSet.getString("plugin_name"))

           stmt.close()
           dbConn.close()
           return plugin_list
        except SQLException as e:
            self.Error_Message.setText("Error Reading plugins")
            stmt.close()
            dbConn.close()
            return "Error"

    def get_profiles(self):
        head, tail = os.path.split(os.path.abspath(__file__)) 
        settings_db = os.path.join(head, "GUI_Settings.db3")
        try: 
            Class.forName("org.sqlite.JDBC").newInstance()
            dbConn = DriverManager.getConnection("jdbc:sqlite:%s"  % settings_db)
            self.Error_Message.setText("Database opened")
        except SQLException as e:
            self.Error_Message.setText("Error Opening Settings DB!")
 
        try:
           stmt = dbConn.createStatement()
           SQL_Statement = "select profile_name from profiles where volatility_version = '" + self.Version_CB.getSelectedItem() + "';" 
           resultSet = stmt.executeQuery(SQL_Statement)
           profile_list = []
           while resultSet.next():
              profile_list.append(resultSet.getString("profile_name"))

           stmt.close()
           dbConn.close()
           return profile_list
        except SQLException as e:
            self.Error_Message.setText("Error Reading plugins")
            stmt.close()
            dbConn.close()
            return "Error"

    # When button to find file is clicked then open dialog to find the file and return it.       
    def Find_Dir(self, e):

       chooseFile = JFileChooser()
       filter = FileNameExtensionFilter("All", ["*.*"])
       chooseFile.addChoosableFileFilter(filter)
       #chooseFile.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)

       ret = chooseFile.showDialog(self.panel0, "Find Volatility Directory")

       if ret == JFileChooser.APPROVE_OPTION:
           file = chooseFile.getSelectedFile()
           Canonical_file = file.getCanonicalPath()
           #text = self.readPath(file)
           self.local_settings.setSetting('Volatility_Directory', Canonical_file)
           self.Program_Executable_TF.setText(Canonical_file)

    def keyPressed(self, event):
        self.local_settings.setSetting('AdditionalParms', self.Additional_Parms_TF.getText()) 
        #self.Error_Message.setText(self.Additional_Parms_TF.getText())
        
    def onchange_version(self, event):
        self.local_settings.setSetting('Version', event.item)        
        plugin_list = self.get_plugins()
        profile_list = self.get_profiles()
        self.Profile_CB.removeAllItems()
        self.Plugin_LB.clearSelection()
        self.Plugin_LB.setListData(plugin_list)
        for profile in profile_list:
            self.Profile_CB.addItem(profile)
        #self.Profile_CB.addItems(profile)
        self.panel0.repaint()
        
    def onchange_plugins_lb(self, event):
        self.local_settings.setSetting('PluginListBox' , '')
        list_selected = self.Plugin_LB.getSelectedValuesList()
        self.local_settings.setSetting('PluginListBox', str(list_selected))      
 
    def onchange_profile_cb(self, event):
        self.local_settings.setSetting('Profile', event.item) 

    # Create the initial data fields/layout in the UI
    def initComponents(self):
        self.panel0 = JPanel()

        self.rbgPanel0 = ButtonGroup() 
        self.gbPanel0 = GridBagLayout() 
        self.gbcPanel0 = GridBagConstraints() 
        self.panel0.setLayout( self.gbPanel0 ) 

        self.Error_Message = JLabel( "") 
        self.Error_Message.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 31
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints( self.Error_Message, self.gbcPanel0 ) 
        self.panel0.add( self.Error_Message ) 

        self.Label_1 = JLabel("Volatility Executable Directory")
        self.Label_1.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 1 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_1, self.gbcPanel0 ) 
        self.panel0.add( self.Label_1 ) 

        self.Program_Executable_TF = JTextField(10) 
        self.Program_Executable_TF.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 3 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Program_Executable_TF, self.gbcPanel0 ) 
        self.panel0.add( self.Program_Executable_TF ) 

        self.Find_Program_Exec_BTN = JButton( "Find Dir", actionPerformed=self.Find_Dir)
        self.Find_Program_Exec_BTN.setEnabled(True)
        self.rbgPanel0.add( self.Find_Program_Exec_BTN ) 
        self.gbcPanel0.gridx = 6 
        self.gbcPanel0.gridy = 3 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Find_Program_Exec_BTN, self.gbcPanel0 ) 
        self.panel0.add( self.Find_Program_Exec_BTN ) 

        self.Blank_1 = JLabel( " ") 
        self.Blank_1.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_1, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_1 ) 

        self.Version_Label_1 = JLabel( "Version:") 
        self.Blank_1.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 11
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Version_Label_1, self.gbcPanel0 ) 
        self.panel0.add( self.Version_Label_1 ) 
        
        self.Version_List = ("2.5", "2.6") 
        self.Version_CB = JComboBox( self.Version_List)
        self.Version_CB.itemStateChanged = self.onchange_version        
        self.gbcPanel0.gridx = 6 
        self.gbcPanel0.gridy = 11 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Version_CB, self.gbcPanel0 ) 
        self.panel0.add( self.Version_CB ) 

        self.Blank_3 = JLabel( " ") 
        self.Blank_3.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 13
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_3, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_3 ) 

        self.Plugin_Label_1 = JLabel( "Plugins:") 
        self.Blank_1.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 15
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Plugin_Label_1, self.gbcPanel0 ) 
        self.panel0.add( self.Plugin_Label_1 ) 
        
        self.Plugin_list = self.get_plugins()
        self.Plugin_LB = JList( self.Plugin_list, valueChanged=self.onchange_plugins_lb)
        self.Plugin_LB.setVisibleRowCount( 3 ) 
        self.scpPlugin_LB = JScrollPane( self.Plugin_LB ) 
        self.gbcPanel0.gridx = 6 
        self.gbcPanel0.gridy = 15 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 1 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.scpPlugin_LB, self.gbcPanel0 ) 
        self.panel0.add( self.scpPlugin_LB ) 

        self.Blank_4 = JLabel( " ") 
        self.Blank_4.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 17
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_4, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_4 ) 

        self.Profile_Label_1 = JLabel( "Profile:") 
        self.Blank_1.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 19
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Profile_Label_1, self.gbcPanel0 ) 
        self.panel0.add( self.Profile_Label_1 ) 
        
        self.Profile_List = self.get_profiles()
        self.Profile_CB = JComboBox( self.Profile_List)
        self.Profile_CB.itemStateChanged = self.onchange_profile_cb        
        self.gbcPanel0.gridx = 6 
        self.gbcPanel0.gridy = 19 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 1 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Profile_CB, self.gbcPanel0 ) 
        self.panel0.add( self.Profile_CB ) 

        self.Blank_5 = JLabel( " ") 
        self.Blank_5.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 21
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_5, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_5 ) 

        self.Label_2 = JLabel("Additional Parameters To Run With:")
        self.Label_2.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 23 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_2, self.gbcPanel0 ) 
        self.panel0.add( self.Label_2 ) 

        self.Additional_Parms_TF = JTextField(10,focusLost=self.keyPressed) 
        #self.Additional_Parms_TF.getDocument().addDocumentListener()
        self.Additional_Parms_TF.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 25 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Additional_Parms_TF, self.gbcPanel0 ) 
        self.panel0.add( self.Additional_Parms_TF ) 

        self.Blank_6 = JLabel( " ") 
        self.Blank_6.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 27
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_6, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_6 ) 

        self.Label_3 = JLabel( "Message:") 
        self.Label_3.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 29
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_3, self.gbcPanel0 ) 
        self.panel0.add( self.Label_3 ) 
		
        self.add(self.panel0)

    # Custom load any data field and initialize the values
    def customizeComponents(self):
        self.Program_Executable_TF.setText(self.local_settings.getSetting('Volatility_Directory'))
        #pass
        
    # Return the settings used
    def getSettings(self):
        return self.local_settings
class Remove_ArtifactsWithUISettingsPanel(IngestModuleIngestJobSettingsPanel):
    # Note, we can't use a self.settings instance variable.
    # Rather, self.local_settings is used.
    # https://wiki.python.org/jython/UserGuide#javabean-properties
    # Jython Introspector generates a property - 'settings' on the basis
    # of getSettings() defined in this class. Since only getter function
    # is present, it creates a read-only 'settings' property. This auto-
    # generated read-only property overshadows the instance-variable -
    # 'settings'
    
    # We get passed in a previous version of the settings so that we can
    # prepopulate the UI
    # TODO: Update this for your UI
    def __init__(self, settings):
        self.local_settings = settings
        self.artifact_list = []
        self.initComponents()
        self.customizeComponents()
    
    # Check to see if there are any entries that need to be populated from the database.        
    def checkBoxEvent(self, event):
        if self.All_Artifacts_CB.isSelected():
            self.local_settings.setSetting('allArtifacts', 'true')
            self.List_Box_LB.setEnabled(False)
        else:
            self.local_settings.setSetting('allArtifacts', 'false')
            self.List_Box_LB.setEnabled(True)

        if self.All_Attributes_CB.isSelected():
            self.local_settings.setSetting('allAttributes', 'true')
            self.List_Box_LB.setEnabled(False)
        else:
            self.local_settings.setSetting('allAttributes', 'false')
            self.List_Box_LB.setEnabled(True)

    def onchange_lb(self, event):
        self.local_settings.setSetting('listSelected', '')
        list_selected = self.List_Box_LB.getSelectedValuesList()
        self.local_settings.setSetting('listSelected', list_selected)      

    def get_artifacts(self):
    
        sql_statement = "select distinct(type_name) 'type_name' from blackboard_artifacts a, blackboard_artifact_types b " + \
                        " where a.artifact_type_id = b.artifact_type_id;"
        skCase = Case.getCurrentCase().getSleuthkitCase()
        dbquery = skCase.executeQuery(sql_statement)
        resultSet = dbquery.getResultSet()
        while resultSet.next():
             self.artifact_list.append(resultSet.getString("type_name"))
        dbquery.close()
        
    

    # Create the initial data fields/layout in the UI
    def initComponents(self):
        self.panel0 = JPanel()

        self.rbgPanel0 = ButtonGroup() 
        self.gbPanel0 = GridBagLayout() 
        self.gbcPanel0 = GridBagConstraints() 
        self.panel0.setLayout( self.gbPanel0 ) 

        self.All_Artifacts_CB = JCheckBox("Remove All Custom Artifacts", actionPerformed=self.checkBoxEvent)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 1 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.All_Artifacts_CB, self.gbcPanel0 ) 
        self.panel0.add( self.All_Artifacts_CB ) 

        self.All_Attributes_CB = JCheckBox("Remove All Custom Attributes", actionPerformed=self.checkBoxEvent)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 3 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.All_Attributes_CB, self.gbcPanel0 ) 
        self.panel0.add( self.All_Attributes_CB ) 

        self.Blank_0 = JLabel( " ") 
        self.Blank_0.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_0, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_0 ) 

        self.Label_0 = JLabel( "Remove selected Artifacts") 
        self.Label_0.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_0, self.gbcPanel0 ) 
        self.panel0.add( self.Label_0 ) 

        self.Blank_0 = JLabel( " ") 
        self.Blank_0.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_0, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_0 ) 

        self.get_artifacts()
        self.List_Box_LB = JList( self.artifact_list, valueChanged=self.onchange_lb)
        self.List_Box_LB.setVisibleRowCount( 3 ) 
        self.scpList_Box_LB = JScrollPane( self.List_Box_LB ) 
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 7 
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 1 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.scpList_Box_LB, self.gbcPanel0 ) 
        self.panel0.add( self.scpList_Box_LB ) 

        self.Blank_1 = JLabel( " ") 
        self.Blank_1.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 9
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_1, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_1 ) 

        self.Label_1 = JLabel( "Message:") 
        self.Label_1.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 11
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Label_1, self.gbcPanel0 ) 
        self.panel0.add( self.Label_1 ) 
		
        self.Blank_2 = JLabel( " ") 
        self.Blank_2.setEnabled(True)
        self.gbcPanel0.gridx = 2 
        self.gbcPanel0.gridy = 13
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH 
        self.gbPanel0.setConstraints( self.Blank_2, self.gbcPanel0 ) 
        self.panel0.add( self.Blank_2 ) 

        self.Error_Message = JLabel( "For developer purposes only, it may fubar your case") 
        self.Error_Message.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 15
        self.gbcPanel0.gridwidth = 1 
        self.gbcPanel0.gridheight = 1 
        self.gbcPanel0.fill = GridBagConstraints.BOTH 
        self.gbcPanel0.weightx = 1 
        self.gbcPanel0.weighty = 0 
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints( self.Error_Message, self.gbcPanel0 ) 
        self.panel0.add( self.Error_Message ) 

        self.add(self.panel0)

    # Custom load any data field and initialize the values
    def customizeComponents(self):
        self.All_Artifacts_CB.setSelected(self.local_settings.getSetting('allArtifacts') == 'true')
        self.All_Attributes_CB.setSelected(self.local_settings.getSetting('allAttributes') == 'true')

    # Return the settings used
    def getSettings(self):
        return self.local_settings