Hash nodes added.

This commit is contained in:
devin148 2012-07-27 14:58:15 -04:00
parent 402c428d3e
commit d3e07d350d
6 changed files with 121 additions and 66 deletions

View File

@ -53,3 +53,4 @@ HashDbSearchPanel.searchButton.text=Search
HashDbSearchPanel.removeButton.text=Remove Selected HashDbSearchPanel.removeButton.text=Remove Selected
HashDbSearchPanel.titleLabel.text=Search for files with the following MD5 hash(es): HashDbSearchPanel.titleLabel.text=Search for files with the following MD5 hash(es):
HashDbSearchPanel.errorField.text=Error: Not all files have been hashed. HashDbSearchPanel.errorField.text=Error: Not all files have been hashed.
HashDbSearchPanel.saveBox.text=Remember Hashes

View File

@ -1,61 +1,71 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011 Basis Technology Corp. * Copyright 2011 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.sleuthkit.autopsy.hashdatabase; package org.sleuthkit.autopsy.hashdatabase;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import org.openide.util.HelpCtx; import java.awt.event.WindowAdapter;
import org.openide.util.actions.CallableSystemAction; import java.awt.event.WindowEvent;
import org.sleuthkit.autopsy.corecomponents.AdvancedConfigurationCleanDialog; import org.openide.util.HelpCtx;
import org.openide.util.actions.CallableSystemAction;
/** import org.sleuthkit.autopsy.corecomponents.AdvancedConfigurationCleanDialog;
* The HashDbSearchAction opens the HashDbSearchPanel in a dialog.
*/ /**
class HashDbSearchAction extends CallableSystemAction { * The HashDbSearchAction opens the HashDbSearchPanel in a dialog.
*/
static final String ACTION_NAME = "Hash File Search"; class HashDbSearchAction extends CallableSystemAction {
@Override static final String ACTION_NAME = "Hash File Search";
public void performAction() {
final HashDbSearchPanel panel = HashDbSearchPanel.getDefault(); @Override
final AdvancedConfigurationCleanDialog dialog = new AdvancedConfigurationCleanDialog(); public void performAction() {
panel.cancelButtonListener(new ActionListener() { final HashDbSearchPanel panel = HashDbSearchPanel.getDefault();
@Override final AdvancedConfigurationCleanDialog dialog = new AdvancedConfigurationCleanDialog();
public void actionPerformed(ActionEvent e) { panel.cancelButtonListener(new ActionListener() {
dialog.close(); @Override
} public void actionPerformed(ActionEvent e) {
}); panel.clear();
dialog.display(panel); dialog.close();
} }
});
@Override dialog.addWindowListener(new WindowAdapter() {
public String getName() { @Override
return ACTION_NAME; public void windowClosing(WindowEvent e) {
} panel.clear();
dialog.close();
@Override }
public HelpCtx getHelpCtx() { });
return HelpCtx.DEFAULT_HELP; dialog.display(panel);
} }
@Override @Override
protected boolean asynchronous() { public String getName() {
return false; return ACTION_NAME;
} }
}
@Override
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}
@Override
protected boolean asynchronous() {
return false;
}
}

View File

@ -50,9 +50,9 @@ public class HashDbSearchManager {
for(String s : map.keySet()) { for(String s : map.keySet()) {
for(FsContent file : map.get(s)) { for(FsContent file : map.get(s)) {
Map<String, Object> keyMap = new LinkedHashMap<String, Object>(); Map<String, Object> keyMap = new LinkedHashMap<String, Object>();
keyMap.put("Hash", s); keyMap.put("MD5 Hash", s);
AbstractFsContentNode.fillPropertyMap(keyMap, file); AbstractFsContentNode.fillPropertyMap(keyMap, file);
KeyValue kv = new KeyValue("MD5 - Name", keyMap, ++id); KeyValue kv = new KeyValue(file.getName(), keyMap, ++id);
keyValues.add(kv); keyValues.add(kv);
} }
} }

View File

@ -44,6 +44,8 @@
<Component id="addButton" min="-2" max="-2" attributes="0"/> <Component id="addButton" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="removeButton" min="-2" max="-2" attributes="0"/> <Component id="removeButton" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="saveBox" min="-2" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/> <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
@ -71,6 +73,7 @@
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="addButton" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="addButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="removeButton" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="removeButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="saveBox" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace pref="27" max="32767" attributes="0"/> <EmptySpace pref="27" max="32767" attributes="0"/>
<Component id="jSeparator1" min="-2" pref="10" max="-2" attributes="0"/> <Component id="jSeparator1" min="-2" pref="10" max="-2" attributes="0"/>
@ -179,5 +182,15 @@
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JCheckBox" name="saveBox">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/hashdatabase/Bundle.properties" key="HashDbSearchPanel.saveBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveBoxActionPerformed"/>
</Events>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

View File

@ -128,6 +128,7 @@ public class HashDbSearchPanel extends javax.swing.JPanel implements ActionListe
jSeparator1 = new javax.swing.JSeparator(); jSeparator1 = new javax.swing.JSeparator();
titleLabel = new javax.swing.JLabel(); titleLabel = new javax.swing.JLabel();
errorField = new javax.swing.JLabel(); errorField = new javax.swing.JLabel();
saveBox = new javax.swing.JCheckBox();
hashTable.setModel(new javax.swing.table.DefaultTableModel( hashTable.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] { new Object [][] {
@ -173,6 +174,13 @@ public class HashDbSearchPanel extends javax.swing.JPanel implements ActionListe
errorField.setForeground(new java.awt.Color(255, 0, 0)); errorField.setForeground(new java.awt.Color(255, 0, 0));
org.openide.awt.Mnemonics.setLocalizedText(errorField, org.openide.util.NbBundle.getMessage(HashDbSearchPanel.class, "HashDbSearchPanel.errorField.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(errorField, org.openide.util.NbBundle.getMessage(HashDbSearchPanel.class, "HashDbSearchPanel.errorField.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(saveBox, org.openide.util.NbBundle.getMessage(HashDbSearchPanel.class, "HashDbSearchPanel.saveBox.text")); // NOI18N
saveBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
saveBoxActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
@ -202,7 +210,9 @@ public class HashDbSearchPanel extends javax.swing.JPanel implements ActionListe
.addGap(61, 61, 61) .addGap(61, 61, 61)
.addComponent(addButton) .addComponent(addButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(removeButton))) .addComponent(removeButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(saveBox)))
.addGap(0, 0, Short.MAX_VALUE))))) .addGap(0, 0, Short.MAX_VALUE)))))
.addContainerGap()) .addContainerGap())
); );
@ -220,7 +230,8 @@ public class HashDbSearchPanel extends javax.swing.JPanel implements ActionListe
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(addButton) .addComponent(addButton)
.addComponent(removeButton)) .addComponent(removeButton)
.addComponent(saveBox))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
@ -231,6 +242,11 @@ public class HashDbSearchPanel extends javax.swing.JPanel implements ActionListe
.addContainerGap()) .addContainerGap())
); );
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void saveBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveBoxActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_saveBoxActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton addButton; private javax.swing.JButton addButton;
private javax.swing.JButton cancelButton; private javax.swing.JButton cancelButton;
@ -241,6 +257,7 @@ public class HashDbSearchPanel extends javax.swing.JPanel implements ActionListe
private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSeparator jSeparator1; private javax.swing.JSeparator jSeparator1;
private javax.swing.JButton removeButton; private javax.swing.JButton removeButton;
private javax.swing.JCheckBox saveBox;
private javax.swing.JButton searchButton; private javax.swing.JButton searchButton;
private javax.swing.JLabel titleLabel; private javax.swing.JLabel titleLabel;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
@ -306,4 +323,17 @@ public class HashDbSearchPanel extends javax.swing.JPanel implements ActionListe
model.removeRow(rows[i]); model.removeRow(rows[i]);
} }
} }
/**
* Clears the table of hashes
*/
void clear() {
if(!saveBox.isSelected()) {
DefaultTableModel model = (DefaultTableModel) hashTable.getModel();
int numRows = hashTable.getRowCount();
for(int i=0; i<numRows; i++) {
model.removeRow(i);
}
}
}
} }

View File

@ -8,6 +8,7 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.openide.nodes.ChildFactory; import org.openide.nodes.ChildFactory;
import org.openide.nodes.Children;
import org.openide.nodes.Node; import org.openide.nodes.Node;
import org.sleuthkit.autopsy.datamodel.KeyValue; import org.sleuthkit.autopsy.datamodel.KeyValue;
import org.sleuthkit.autopsy.datamodel.KeyValueNode; import org.sleuthkit.autopsy.datamodel.KeyValueNode;
@ -34,6 +35,6 @@ public class HashDbSearchResultFactory extends ChildFactory<KeyValue> {
@Override @Override
protected Node createNodeForKey(KeyValue thing) { protected Node createNodeForKey(KeyValue thing) {
return new KeyValueNode(thing, null); return new KeyValueNode(thing, Children.LEAF);
} }
} }