Merge branch 'master' of github.com:sleuthkit/autopsy

This commit is contained in:
Dick Fickling 2012-03-30 15:23:20 -04:00
commit 528b523a17
10 changed files with 124 additions and 55 deletions

View File

@ -100,7 +100,11 @@ class HighlightedMatchesSource implements MarkupSource,HighlightLookup {
if (isRegex) if (isRegex)
q.setQuery(highLightField + ":" + "\"" + highlightQuery + "\""); q.setQuery(highLightField + ":" + "\"" + highlightQuery + "\"");
else q.setQuery("\"" + highlightQuery + "\""); //use default field, simplifies query else {
//use default field, simplifies query
//quote only if user supplies quotes
q.setQuery(highlightQuery);
}
//if (isRegex) //if (isRegex)
// q.setQuery(highLightField + ":" + highlightQuery); // q.setQuery(highLightField + ":" + highlightQuery);

View File

@ -68,16 +68,32 @@ public class KeywordSearchUtil {
*/ */
public static String escapeLuceneQuery(String query, boolean escapeLuceneChars, boolean encode) { public static String escapeLuceneQuery(String query, boolean escapeLuceneChars, boolean encode) {
String queryEscaped = null; String queryEscaped = null;
String inputString = query; String inputString = query.trim();
if (inputString.length() == 0) {
return inputString;
}
if (escapeLuceneChars == true) { if (escapeLuceneChars == true) {
final String ESCAPE_CHARS = "/+-&|!(){}[]^\"~*?:\\"; final String ESCAPE_CHARS = "/+-&|!(){}[]^\"~*?:\\";
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < inputString.length(); ++i) { final int length = inputString.length();
char c = inputString.charAt(i);
//see if the quoery is quoted
boolean quotedQuery = false;
if (length > 1 && inputString.charAt(0) == '"' && inputString.charAt(length - 1) == '"') {
quotedQuery = true;
}
for (int i = 0; i < length; ++i) {
final char c = inputString.charAt(i);
if (ESCAPE_CHARS.contains(Character.toString(c))) { if (ESCAPE_CHARS.contains(Character.toString(c))) {
//escape if not outter quotes
if (quotedQuery == false || (i > 0 && i < length - 1)) {
sb.append("\\"); sb.append("\\");
} }
}
sb.append(c); sb.append(c);
} }
queryEscaped = inputString = sb.toString(); queryEscaped = inputString = sb.toString();

View File

@ -327,7 +327,9 @@ public class LuceneQuery implements KeywordSearchQuery {
if (isRegex) { if (isRegex) {
q.setQuery(highlightField + ":" + "\"" + query + "\""); q.setQuery(highlightField + ":" + "\"" + query + "\"");
} else { } else {
q.setQuery("\"" + query + "\""); //simplify query/escaping and use default field //simplify query/escaping and use default field
//quote only if user supplies quotes
q.setQuery(query);
} }
q.addFilterQuery("id:" + contentID); q.addFilterQuery("id:" + contentID);
q.addHighlightField(highlightField); q.addHighlightField(highlightField);

View File

@ -16,6 +16,7 @@ import java.lang.*;
import java.util.*; import java.util.*;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URLDecoder;
import org.sleuthkit.autopsy.ingest.IngestImageWorkerController; import org.sleuthkit.autopsy.ingest.IngestImageWorkerController;
import org.sleuthkit.autopsy.ingest.IngestManager; import org.sleuthkit.autopsy.ingest.IngestManager;
import org.sleuthkit.autopsy.ingest.ServiceDataEvent; import org.sleuthkit.autopsy.ingest.ServiceDataEvent;
@ -254,7 +255,8 @@ public class Firefox {
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_LAST_ACCESSED.getTypeID(),"RecentActivity","Last Visited",temprs.getString("startTime"))); bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_LAST_ACCESSED.getTypeID(),"RecentActivity","Last Visited",temprs.getString("startTime")));
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_URL.getTypeID(), "RecentActivity","",((temprs.getString("source") != null) ? temprs.getString("source") : ""))); bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_URL.getTypeID(), "RecentActivity","",((temprs.getString("source") != null) ? temprs.getString("source") : "")));
//bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_NAME.getTypeID(), "RecentActivity","", ((temprs.getString("title") != null) ? temprs.getString("title").replaceAll("'", "''") : ""))); //bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_NAME.getTypeID(), "RecentActivity","", ((temprs.getString("title") != null) ? temprs.getString("title").replaceAll("'", "''") : "")));
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PATH.getTypeID(), "Recent Activity", "", temprs.getString("target"))); String urldecodedtarget = URLDecoder.decode(temprs.getString("target").replaceAll("file:///", ""), "UTF-8");
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PATH.getTypeID(), "Recent Activity", "", urldecodedtarget));
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID(),"RecentActivity","","FireFox")); bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID(),"RecentActivity","","FireFox"));
bbart.addAttributes(bbattributes); bbart.addAttributes(bbattributes);

View File

@ -0,0 +1,50 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.sleuthkit.autopsy.report;
/**
*
* @author Alex
*/
import java.lang.reflect.Method;
public class BrowserControl{
/**
* Method to Open the Browser with Given URL
* @param url
*/
public static void openUrl(String url){
String os = System.getProperty("os.name");
Runtime runtime=Runtime.getRuntime();
try{
// Block for Windows Platform
if (os.startsWith("Windows")){
String cmd = "rundll32 url.dll,FileProtocolHandler "+ url;
Process p = runtime.exec(cmd);
}
//Block for Mac OS
else if(os.startsWith("Mac OS")){
Class fileMgr = Class.forName("com.apple.eio.FileManager");
Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] {String.class});
openURL.invoke(null, new Object[] {url});
}
//Block for UNIX Platform
else {
String[] browsers = {"firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" };
String browser = null;
for (int count = 0; count < browsers.length && browser == null; count++)
if (runtime.exec(new String[] {"which", browsers[count]}).waitFor() == 0)
browser = browsers[count];
if (browser == null)
throw new Exception("Could not find web browser");
else
runtime.exec(new String[] {browser, url});
}
}catch(Exception x){
System.err.println("Exception occurd while invoking Browser!");
x.printStackTrace();
}
}
}

View File

@ -6,7 +6,6 @@ reportFilter.jCheckBox4.text=Hashlist Hits
reportFilter.jCheckBox5.text=System Information reportFilter.jCheckBox5.text=System Information
reportFilter.jButton1.text=Generate Report reportFilter.jButton1.text=Generate Report
Toolbars/Reports/org-sleuthkit-autopsy-report-reportAction.shadow=Reports Toolbars/Reports/org-sleuthkit-autopsy-report-reportAction.shadow=Reports
reportPanel.jEditorPane1.contentType=text/html
reportPanel.jButton1.text=Close reportPanel.jButton1.text=Close
reportFilter.cancelButton.text=Cancel reportFilter.cancelButton.text=Cancel
reportFilter.cancelButton.actionCommand= reportFilter.cancelButton.actionCommand=
@ -14,5 +13,6 @@ reportFilter.jButton2.actionCommand=
reportFilter.jButton2.label= reportFilter.jButton2.label=
reportFilter.jButton2.text= reportFilter.jButton2.text=
reportPanel.saveReport.actionCommand= reportPanel.saveReport.actionCommand=
reportPanel.saveReport.text=Save Report reportPanel.saveReport.text=Export Report...
reportFilter.progBar.string= reportFilter.progBar.string=
reportPanel.jLabel1.text=jLabel1

View File

@ -363,7 +363,7 @@ public reportHTML (HashMap<BlackboardArtifact,ArrayList<BlackboardAttribute>> re
formatted_Report.append("</div></div></body></html>"); formatted_Report.append("</div></div></body></html>");
formatted_header.append(formatted_Report); formatted_header.append(formatted_Report);
unformatted_header.append(formatted_Report); // unformatted_header.append(formatted_Report);
htmlPath = currentCase.getCaseDirectory()+"/Reports/" + caseName + "-" + datenotime + ".html"; htmlPath = currentCase.getCaseDirectory()+"/Reports/" + caseName + "-" + datenotime + ".html";
Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(htmlPath), "UTF-8")); Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(htmlPath), "UTF-8"));
out.write(formatted_header.toString()); out.write(formatted_header.toString());

View File

@ -28,14 +28,13 @@
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="863" max="32767" attributes="0"/> <Component id="jLabel1" alignment="0" pref="300" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="320" max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/> <Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="391" max="32767" attributes="0"/> <EmptySpace pref="128" max="32767" attributes="0"/>
<Component id="saveReport" min="-2" max="-2" attributes="0"/> <Component id="saveReport" min="-2" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
@ -45,10 +44,10 @@
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="547" max="32767" attributes="0"/> <Component id="jLabel1" pref="26" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="saveReport" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="saveReport" alignment="3" min="-2" max="-2" attributes="0"/>
@ -59,23 +58,6 @@
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
<SubComponents> <SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JEditorPane" name="jEditorPane1">
<Properties>
<Property name="contentType" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/report/Bundle.properties" key="reportPanel.jEditorPane1.contentType" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="editable" type="boolean" value="false"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="jButton1"> <Component class="javax.swing.JButton" name="jButton1">
<Properties> <Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
@ -96,5 +78,12 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveReportActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveReportActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/report/Bundle.properties" key="reportPanel.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

View File

@ -15,7 +15,9 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.Writer; import java.io.Writer;
import java.net.URL; import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener; import javax.swing.event.HyperlinkListener;
import org.jdom.output.XMLOutputter; import org.jdom.output.XMLOutputter;
@ -43,14 +45,9 @@ public class reportPanel extends javax.swing.JPanel {
jFileChooser1 = new javax.swing.JFileChooser(); jFileChooser1 = new javax.swing.JFileChooser();
jOptionPane1 = new javax.swing.JOptionPane(); jOptionPane1 = new javax.swing.JOptionPane();
jScrollPane1 = new javax.swing.JScrollPane();
jEditorPane1 = new javax.swing.JEditorPane();
jButton1 = new javax.swing.JButton(); jButton1 = new javax.swing.JButton();
saveReport = new javax.swing.JButton(); saveReport = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jEditorPane1.setContentType(org.openide.util.NbBundle.getMessage(reportPanel.class, "reportPanel.jEditorPane1.contentType")); // NOI18N
jEditorPane1.setEditable(false);
jScrollPane1.setViewportView(jEditorPane1);
jButton1.setText(org.openide.util.NbBundle.getMessage(reportPanel.class, "reportPanel.jButton1.text")); // NOI18N jButton1.setText(org.openide.util.NbBundle.getMessage(reportPanel.class, "reportPanel.jButton1.text")); // NOI18N
@ -62,6 +59,8 @@ public class reportPanel extends javax.swing.JPanel {
} }
}); });
jLabel1.setText(org.openide.util.NbBundle.getMessage(reportPanel.class, "reportPanel.jLabel1.text")); // NOI18N
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(
@ -69,20 +68,19 @@ public class reportPanel extends javax.swing.JPanel {
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 863, Short.MAX_VALUE) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(320, 320, 320)
.addComponent(jButton1) .addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 391, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 128, Short.MAX_VALUE)
.addComponent(saveReport))) .addComponent(saveReport)))
.addContainerGap()) .addContainerGap())
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 547, Short.MAX_VALUE) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1) .addComponent(jButton1)
.addComponent(saveReport)) .addComponent(saveReport))
@ -109,20 +107,27 @@ private void saveReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI
try{ try{
String str = evt.getDescription(); String str = evt.getDescription();
jEditorPane1.scrollToReference(str.substring(1)); // jEditorPane1.scrollToReference(str.substring(1));
} }
catch(Exception e){ catch(Exception e){
String whater = ""; String whater = "";
} }
} }
public void setjEditorPane1EventListener(HyperlinkListener evt){ public void setjEditorPane1EventListener(HyperlinkListener evt){
jEditorPane1.addHyperlinkListener(evt); // jEditorPane1.addHyperlinkListener(evt);
} }
private void setReportWindow(String report) private void setReportWindow(String report)
{ {
jEditorPane1.setText(report); // jEditorPane1.setText(report);
jEditorPane1.setCaretPosition(0); // jEditorPane1.setCaretPosition(0);
}
public void setFinishedReportText(){
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date();
String reportText = "Report was sucessfully generated at " + dateFormat.format(date) + ".";
jLabel1.setText(reportText);
} }
@ -163,10 +168,9 @@ private void saveReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1; private javax.swing.JButton jButton1;
private javax.swing.JEditorPane jEditorPane1;
private javax.swing.JFileChooser jFileChooser1; private javax.swing.JFileChooser jFileChooser1;
private javax.swing.JLabel jLabel1;
private javax.swing.JOptionPane jOptionPane1; private javax.swing.JOptionPane jOptionPane1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JButton saveReport; private javax.swing.JButton saveReport;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables

View File

@ -79,7 +79,8 @@ public class reportPanelAction {
public void run() public void run()
{ {
reportHTML htmlReport = new reportHTML(Results,rr); reportHTML htmlReport = new reportHTML(Results,rr);
viewReport.append(reportHTML.unformatted_header.toString()); BrowserControl.openUrl(htmlReport.htmlPath);
// viewReport.append(reportHTML.unformatted_header.toString());
} }
}); });
@ -134,6 +135,7 @@ public class reportPanelAction {
double h = popUpWindow.getSize().getHeight(); double h = popUpWindow.getSize().getHeight();
popUpWindow.setLocation((int) ((screenDimension.getWidth() - w) / 2), (int) ((screenDimension.getHeight() - h) / 2)); popUpWindow.setLocation((int) ((screenDimension.getWidth() - w) / 2), (int) ((screenDimension.getHeight() - h) / 2));
rr.progBarDone(); rr.progBarDone();
panel.setFinishedReportText();
popUpWindow.setVisible(true); popUpWindow.setVisible(true);
xmlthread.join(); xmlthread.join();