diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/HighlightedMatchesSource.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/HighlightedMatchesSource.java index 21719340b8..d6677fdfd0 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/HighlightedMatchesSource.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/HighlightedMatchesSource.java @@ -100,7 +100,11 @@ class HighlightedMatchesSource implements MarkupSource,HighlightLookup { if (isRegex) 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) // q.setQuery(highLightField + ":" + highlightQuery); diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchUtil.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchUtil.java index 6edeb6a457..db7a016d78 100755 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchUtil.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchUtil.java @@ -68,15 +68,31 @@ public class KeywordSearchUtil { */ public static String escapeLuceneQuery(String query, boolean escapeLuceneChars, boolean encode) { String queryEscaped = null; - String inputString = query; + String inputString = query.trim(); + + if (inputString.length() == 0) { + return inputString; + } if (escapeLuceneChars == true) { final String ESCAPE_CHARS = "/+-&|!(){}[]^\"~*?:\\"; StringBuilder sb = new StringBuilder(); - for (int i = 0; i < inputString.length(); ++i) { - char c = inputString.charAt(i); + final int length = inputString.length(); + + //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))) { - sb.append("\\"); + //escape if not outter quotes + if (quotedQuery == false || (i > 0 && i < length - 1)) { + sb.append("\\"); + } } sb.append(c); } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/LuceneQuery.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/LuceneQuery.java index 99ccbdbbfb..ec3d6c185c 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/LuceneQuery.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/LuceneQuery.java @@ -327,7 +327,9 @@ public class LuceneQuery implements KeywordSearchQuery { if (isRegex) { q.setQuery(highlightField + ":" + "\"" + query + "\""); } 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.addHighlightField(highlightField); diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Firefox.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Firefox.java index 42c3d8e5e2..4ae3be6e29 100644 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Firefox.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Firefox.java @@ -16,6 +16,7 @@ import java.lang.*; import java.util.*; import java.io.File; import java.io.IOException; +import java.net.URLDecoder; import org.sleuthkit.autopsy.ingest.IngestImageWorkerController; import org.sleuthkit.autopsy.ingest.IngestManager; 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_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_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")); bbart.addAttributes(bbattributes); diff --git a/Report/src/org/sleuthkit/autopsy/report/BrowserControl.java b/Report/src/org/sleuthkit/autopsy/report/BrowserControl.java new file mode 100644 index 0000000000..08f201f83f --- /dev/null +++ b/Report/src/org/sleuthkit/autopsy/report/BrowserControl.java @@ -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(); +} +} +} diff --git a/Report/src/org/sleuthkit/autopsy/report/Bundle.properties b/Report/src/org/sleuthkit/autopsy/report/Bundle.properties index 96e0030dd7..3cfbe706b7 100644 --- a/Report/src/org/sleuthkit/autopsy/report/Bundle.properties +++ b/Report/src/org/sleuthkit/autopsy/report/Bundle.properties @@ -6,7 +6,6 @@ reportFilter.jCheckBox4.text=Hashlist Hits reportFilter.jCheckBox5.text=System Information reportFilter.jButton1.text=Generate Report Toolbars/Reports/org-sleuthkit-autopsy-report-reportAction.shadow=Reports -reportPanel.jEditorPane1.contentType=text/html reportPanel.jButton1.text=Close reportFilter.cancelButton.text=Cancel reportFilter.cancelButton.actionCommand= @@ -14,5 +13,6 @@ reportFilter.jButton2.actionCommand= reportFilter.jButton2.label= reportFilter.jButton2.text= reportPanel.saveReport.actionCommand= -reportPanel.saveReport.text=Save Report +reportPanel.saveReport.text=Export Report... reportFilter.progBar.string= +reportPanel.jLabel1.text=jLabel1 diff --git a/Report/src/org/sleuthkit/autopsy/report/reportHTML.java b/Report/src/org/sleuthkit/autopsy/report/reportHTML.java index c15af1b79c..b7bfc91923 100644 --- a/Report/src/org/sleuthkit/autopsy/report/reportHTML.java +++ b/Report/src/org/sleuthkit/autopsy/report/reportHTML.java @@ -363,7 +363,7 @@ public reportHTML (HashMap> re formatted_Report.append(""); formatted_header.append(formatted_Report); - unformatted_header.append(formatted_Report); + // unformatted_header.append(formatted_Report); htmlPath = currentCase.getCaseDirectory()+"/Reports/" + caseName + "-" + datenotime + ".html"; Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(htmlPath), "UTF-8")); out.write(formatted_header.toString()); diff --git a/Report/src/org/sleuthkit/autopsy/report/reportPanel.form b/Report/src/org/sleuthkit/autopsy/report/reportPanel.form index 624e825e98..25b5456d3b 100644 --- a/Report/src/org/sleuthkit/autopsy/report/reportPanel.form +++ b/Report/src/org/sleuthkit/autopsy/report/reportPanel.form @@ -28,14 +28,13 @@ - + - + - - + @@ -45,10 +44,10 @@ - - - - + + + + @@ -59,23 +58,6 @@ - - - - - - - - - - - - - - - - - @@ -96,5 +78,12 @@ + + + + + + + diff --git a/Report/src/org/sleuthkit/autopsy/report/reportPanel.java b/Report/src/org/sleuthkit/autopsy/report/reportPanel.java index 88d1ccac39..bd431208db 100644 --- a/Report/src/org/sleuthkit/autopsy/report/reportPanel.java +++ b/Report/src/org/sleuthkit/autopsy/report/reportPanel.java @@ -15,7 +15,9 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; 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.HyperlinkListener; import org.jdom.output.XMLOutputter; @@ -43,14 +45,9 @@ public class reportPanel extends javax.swing.JPanel { jFileChooser1 = new javax.swing.JFileChooser(); jOptionPane1 = new javax.swing.JOptionPane(); - jScrollPane1 = new javax.swing.JScrollPane(); - jEditorPane1 = new javax.swing.JEditorPane(); jButton1 = new javax.swing.JButton(); saveReport = new javax.swing.JButton(); - - jEditorPane1.setContentType(org.openide.util.NbBundle.getMessage(reportPanel.class, "reportPanel.jEditorPane1.contentType")); // NOI18N - jEditorPane1.setEditable(false); - jScrollPane1.setViewportView(jEditorPane1); + jLabel1 = new javax.swing.JLabel(); 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); this.setLayout(layout); layout.setHorizontalGroup( @@ -69,20 +68,19 @@ public class reportPanel extends javax.swing.JPanel { .addGroup(layout.createSequentialGroup() .addContainerGap() .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() - .addGap(320, 320, 320) .addComponent(jButton1) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 391, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 128, Short.MAX_VALUE) .addComponent(saveReport))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 547, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton1) .addComponent(saveReport)) @@ -109,20 +107,27 @@ private void saveReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI try{ String str = evt.getDescription(); - jEditorPane1.scrollToReference(str.substring(1)); + // jEditorPane1.scrollToReference(str.substring(1)); } catch(Exception e){ String whater = ""; } } public void setjEditorPane1EventListener(HyperlinkListener evt){ - jEditorPane1.addHyperlinkListener(evt); + // jEditorPane1.addHyperlinkListener(evt); } private void setReportWindow(String report) { - jEditorPane1.setText(report); - jEditorPane1.setCaretPosition(0); + // jEditorPane1.setText(report); + // 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 private javax.swing.JButton jButton1; - private javax.swing.JEditorPane jEditorPane1; private javax.swing.JFileChooser jFileChooser1; + private javax.swing.JLabel jLabel1; private javax.swing.JOptionPane jOptionPane1; - private javax.swing.JScrollPane jScrollPane1; private javax.swing.JButton saveReport; // End of variables declaration//GEN-END:variables diff --git a/Report/src/org/sleuthkit/autopsy/report/reportPanelAction.java b/Report/src/org/sleuthkit/autopsy/report/reportPanelAction.java index 6fe76733e7..99e1f9fd46 100644 --- a/Report/src/org/sleuthkit/autopsy/report/reportPanelAction.java +++ b/Report/src/org/sleuthkit/autopsy/report/reportPanelAction.java @@ -79,7 +79,8 @@ public class reportPanelAction { public void run() { 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(); popUpWindow.setLocation((int) ((screenDimension.getWidth() - w) / 2), (int) ((screenDimension.getHeight() - h) / 2)); rr.progBarDone(); + panel.setFinishedReportText(); popUpWindow.setVisible(true); xmlthread.join();