diff --git a/Core/build.xml b/Core/build.xml
index 28e64b83e5..0e5c90ef04 100644
--- a/Core/build.xml
+++ b/Core/build.xml
@@ -137,7 +137,7 @@
-
+
diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/CaseInformationPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/CaseInformationPanel.java
index a6494fe22b..76b56138d7 100644
--- a/Core/src/org/sleuthkit/autopsy/casemodule/CaseInformationPanel.java
+++ b/Core/src/org/sleuthkit/autopsy/casemodule/CaseInformationPanel.java
@@ -162,6 +162,8 @@ class CaseInformationPanel extends javax.swing.JPanel {
editCasePropertiesDialog.setResizable(true);
editCasePropertiesDialog.pack();
editCasePropertiesDialog.setLocationRelativeTo(this);
+ // Workaround to ensure dialog is not hidden on macOS
+ editCasePropertiesDialog.setAlwaysOnTop(true);
editCasePropertiesDialog.setVisible(true);
editCasePropertiesDialog.toFront();
caseDetailsPanel.updateCaseInfo();
diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/CaseOpenAction.java b/Core/src/org/sleuthkit/autopsy/casemodule/CaseOpenAction.java
index cc07148ba0..0ba92c7bce 100644
--- a/Core/src/org/sleuthkit/autopsy/casemodule/CaseOpenAction.java
+++ b/Core/src/org/sleuthkit/autopsy/casemodule/CaseOpenAction.java
@@ -18,6 +18,7 @@
*/
package org.sleuthkit.autopsy.casemodule;
+import java.awt.Component;
import java.awt.Cursor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -84,10 +85,17 @@ public final class CaseOpenAction extends CallableSystemAction implements Action
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setMultiSelectionEnabled(false);
fileChooser.setFileFilter(caseMetadataFileFilter);
+
if (null != ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_BASECASE)) {
fileChooser.setCurrentDirectory(new File(ModuleSettings.getConfigSetting("Case", PROP_BASECASE))); //NON-NLS
}
-
+
+ /**
+ * If the open multi user case dialog is open make sure it's not set
+ * to always be on top as this hides the file chooser on macOS.
+ */
+ OpenMultiUserCaseDialog multiUserCaseDialog = OpenMultiUserCaseDialog.getInstance();
+ multiUserCaseDialog.setAlwaysOnTop(false);
String optionsDlgTitle = NbBundle.getMessage(Case.class, "CloseCaseWhileIngesting.Warning.title");
String optionsDlgMessage = NbBundle.getMessage(Case.class, "CloseCaseWhileIngesting.Warning");
if (IngestRunningCheck.checkAndConfirmProceed(optionsDlgTitle, optionsDlgMessage)) {
@@ -95,7 +103,12 @@ public final class CaseOpenAction extends CallableSystemAction implements Action
* Pop up a file chooser to allow the user to select a case metadata
* file (.aut file).
*/
- int retval = fileChooser.showOpenDialog(WindowManager.getDefault().getMainWindow());
+ /**
+ * The parent of the fileChooser will either be the multi user
+ * case dialog or the startup window.
+ */
+ int retval = fileChooser.showOpenDialog(multiUserCaseDialog.isVisible()
+ ? multiUserCaseDialog : (Component) StartupWindowProvider.getInstance().getStartupWindow());
if (retval == JFileChooser.APPROVE_OPTION) {
/*
* Close the startup window, if it is open.
@@ -105,7 +118,7 @@ public final class CaseOpenAction extends CallableSystemAction implements Action
/*
* Close the Open Multi-User Case window, if it is open.
*/
- OpenMultiUserCaseDialog.getInstance().setVisible(false);
+ multiUserCaseDialog.setVisible(false);
/*
* Try to open the case associated with the case metadata file
@@ -159,6 +172,8 @@ public final class CaseOpenAction extends CallableSystemAction implements Action
OpenMultiUserCaseDialog multiUserCaseWindow = OpenMultiUserCaseDialog.getInstance();
multiUserCaseWindow.setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
+ // Workaround to ensure that dialog is not hidden on macOS.
+ multiUserCaseWindow.setAlwaysOnTop(true);
multiUserCaseWindow.setVisible(true);
WindowManager.getDefault().getMainWindow().setCursor(null);
diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/CueBannerPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/CueBannerPanel.java
index 3ddb97fcfd..37c6c7c8b8 100644
--- a/Core/src/org/sleuthkit/autopsy/casemodule/CueBannerPanel.java
+++ b/Core/src/org/sleuthkit/autopsy/casemodule/CueBannerPanel.java
@@ -249,6 +249,8 @@ public class CueBannerPanel extends javax.swing.JPanel {
private void openRecentCaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openRecentCaseButtonActionPerformed
recentCasesWindow.setLocationRelativeTo(this);
OpenRecentCasePanel.getInstance(); //refreshes the recent cases table
+ // Workaround to ensure that dialog is not hidden on macOS.
+ recentCasesWindow.setAlwaysOnTop(true);
recentCasesWindow.setVisible(true);
}//GEN-LAST:event_openRecentCaseButtonActionPerformed
diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardAction.java b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardAction.java
index 50688b1ac1..c5e6ece78d 100644
--- a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardAction.java
+++ b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardAction.java
@@ -71,6 +71,8 @@ final class NewCaseWizardAction extends CallableSystemAction {
wizardDescriptor.setTitleFormat(new MessageFormat("{0}"));
wizardDescriptor.setTitle(NbBundle.getMessage(this.getClass(), "NewCaseWizardAction.newCase.windowTitle.text"));
Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
+ // Workaround to ensure new case dialog is not hidden on macOS
+ dialog.setAlwaysOnTop(true);
dialog.setVisible(true);
dialog.toFront();
if (wizardDescriptor.getValue() == WizardDescriptor.FINISH_OPTION) {
diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/StartupWindowProvider.java b/Core/src/org/sleuthkit/autopsy/casemodule/StartupWindowProvider.java
index 13aae1c0de..8bec55f53c 100644
--- a/Core/src/org/sleuthkit/autopsy/casemodule/StartupWindowProvider.java
+++ b/Core/src/org/sleuthkit/autopsy/casemodule/StartupWindowProvider.java
@@ -144,4 +144,13 @@ public class StartupWindowProvider implements StartupWindowInterface {
startupWindowToUse.close();
}
}
+
+ /**
+ * Get the chosen startup window.
+ *
+ * @return The startup window.
+ */
+ public StartupWindowInterface getStartupWindow() {
+ return startupWindowToUse;
+ }
}
diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/IngestEventsListener.java b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/IngestEventsListener.java
index 282e225135..355c7c8dbc 100644
--- a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/IngestEventsListener.java
+++ b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/IngestEventsListener.java
@@ -224,6 +224,7 @@ public class IngestEventsListener {
* in the central repository.
*
* @param originalArtifact the artifact to create the interesting item for
+ * @param caseDisplayNames the case names the artifact was previously seen in
*/
@NbBundle.Messages({"IngestEventsListener.prevExists.text=Previously Seen Devices (Central Repository)",
"# {0} - typeName",
diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/Bundle.properties b/Core/src/org/sleuthkit/autopsy/contentviewers/Bundle.properties
index c799a17d61..b3a384ce48 100644
--- a/Core/src/org/sleuthkit/autopsy/contentviewers/Bundle.properties
+++ b/Core/src/org/sleuthkit/autopsy/contentviewers/Bundle.properties
@@ -84,9 +84,12 @@ MediaViewImagePanel.zoomTextField.text=
MediaViewImagePanel.rotationTextField.text=
MediaViewImagePanel.rotateLeftButton.toolTipText=
HtmlPanel.showImagesToggleButton.text=Download Images
-MediaPlayerPanel.audioSlider.toolTipText=
-MediaPlayerPanel.VolumeIcon.text=\ \ \ \ \ Volume
+MediaViewImagePanel.tagsMenu.text_1=Tags Menu
MediaPlayerPanel.progressLabel.text=00:00:00/00:00:00
+MediaPlayerPanel.audioSlider.toolTipText=
+MediaPlayerPanel.rewindButton.text=\u2bc7\u2bc7
+MediaPlayerPanel.fastForwardButton.text=\u2bc8\u2bc8
MediaPlayerPanel.playButton.text=\u25ba
MediaPlayerPanel.infoLabel.text=No Errors
-MediaViewImagePanel.tagsMenu.text_1=Tags Menu
+MediaPlayerPanel.VolumeIcon.text=Volume
+MediaPlayerPanel.playBackSpeedLabel.text=Speed:
diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/contentviewers/Bundle.properties-MERGED
index ff3341b60f..ba39d1d419 100755
--- a/Core/src/org/sleuthkit/autopsy/contentviewers/Bundle.properties-MERGED
+++ b/Core/src/org/sleuthkit/autopsy/contentviewers/Bundle.properties-MERGED
@@ -154,12 +154,15 @@ MediaViewImagePanel.zoomTextField.text=
MediaViewImagePanel.rotationTextField.text=
MediaViewImagePanel.rotateLeftButton.toolTipText=
HtmlPanel.showImagesToggleButton.text=Download Images
-MediaPlayerPanel.audioSlider.toolTipText=
-MediaPlayerPanel.VolumeIcon.text=\ \ \ \ \ Volume
+MediaViewImagePanel.tagsMenu.text_1=Tags Menu
MediaPlayerPanel.progressLabel.text=00:00:00/00:00:00
+MediaPlayerPanel.audioSlider.toolTipText=
+MediaPlayerPanel.rewindButton.text=\u2bc7\u2bc7
+MediaPlayerPanel.fastForwardButton.text=\u2bc8\u2bc8
MediaPlayerPanel.playButton.text=\u25ba
MediaPlayerPanel.infoLabel.text=No Errors
-MediaViewImagePanel.tagsMenu.text_1=Tags Menu
+MediaPlayerPanel.VolumeIcon.text=Volume
+MediaPlayerPanel.playBackSpeedLabel.text=Speed:
# {0} - tableName
SQLiteViewer.readTable.errorText=Error getting rows for table: {0}
# {0} - tableName
diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/MediaPlayerPanel.form b/Core/src/org/sleuthkit/autopsy/contentviewers/MediaPlayerPanel.form
index 880528e787..d8433a907b 100755
--- a/Core/src/org/sleuthkit/autopsy/contentviewers/MediaPlayerPanel.form
+++ b/Core/src/org/sleuthkit/autopsy/contentviewers/MediaPlayerPanel.form
@@ -1,6 +1,6 @@
-
+For this tutorial, you can start by deleting the contents of the existing process() method in the sample module. The full source code is linked to at the end of this blog and shows more detail about a fully fledged module. We'll just cover the analytics in the blog.
+
+\subsubsection python_tutorial2_getting_files Getting Files
+Because data source-level ingest modules are not passed in specific files to analyze, nearly all of these types of modules will need to use the org.sleuthkit.autopsy.casemodule.services.FileManager service to find relevant files. Check out the methods on that class to see the different ways that you can find files.
+
+NOTE: See the \ref python_tutorial2_running_exes section for an example of when you simply want to run a command line tool on a disk image instead of querying for files to analyze.
+
+For our example, we want to find all files named "contacts.db". The org.sleuthkit.autopsy.casemodule.services.FileManager class contains several findFiles() methods to help. You can search for all files with a given name or files with a given name in a particular folder. You can also use SQL syntax to match file patterns, such as "%.jpg" to find all files with a JPEG extension.
+
+Our example needs these two lines to get the FileManager for the current case and to find the files.
+\verbatim
+fileManager = Case.getCurrentCase().getServices().getFileManager()
+files = fileManager.findFiles(dataSource, "contacts.db")\endverbatim
+
+findFiles() returns a list of AbstractFile objects. This gives you access to the file's metadata and content.
+
+For our example, we are going to open these SQLite files. That means that we need to save them to disk. This is less than ideal because it wastes time writing the data to disk and then reading it back in, but it is the only option with many libraries. If you are doing some other type analysis on the content, then you do not need to write it to disk. You can read directly from the AbstractFile (see the sample modules for specific code to do this).
+
+The org.sleuthkit.autopsy.datamodel.ContentUtils class provides a utility to save file content to disk. We'll make a path in the temp folder of our case directory. To prevent naming collisions, we'll name the file based on its unique ID. The following two lines save the file to lclDbPath.
+
+\verbatim
+lclDbPath = os.path.join(Case.getCurrentCase().getTempDirectory(), str(file.getId()) + ".db")
+ContentUtils.writeToFile(file, File(lclDbPath))\endverbatim
+
+\subsubsection python_tutorial2_analyzing_sqlite Analyzing SQLite
+Next, we need to open the SQLite database. We are going to use the Java JDBC infrastructure for this. JDBC is Java's generic way of dealing with different types of databases. To open the database, we do this:
+\verbatim
+Class.forName("org.sqlite.JDBC").newInstance()
+dbConn = DriverManager.getConnection("jdbc:sqlite:%s" % lclDbPath)\endverbatim
+
+With our connection in hand, we can do some queries. In our sample database, we have a single table named "contacts", which has columns for name, email, and phone. We first start by querying for all rows in our simple table:
+\verbatim
+stmt = dbConn.createStatement()
+resultSet = stmt.executeQuery("SELECT * FROM contacts")\endverbatim
+
+For each row, we are going to get the values for the name, e-mail, and phone number and make a TSK_CONTACT artifact. Recall from the first tutorial that posting artifacts to the blackboard allows modules to communicate with each other and also allows you to easily display data to the user. The TSK_CONTACT artifact is for storing contact information.
+
+The basic approach in our example is to make an artifact of a given type (TSK_CONTACT) and have it be associated with the database it came from. We then make attributes for the name, email, and phone. The following code does this for each row in the database:
+\verbatim
+while resultSet.next():
+
+ # Make an artifact on the blackboard and give it attributes
+ art = file.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_CONTACT)
+
+ name = resultSet.getString("name")
+ art.addAttribute(BlackboardAttribute(
+ BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME_PERSON.getTypeID(),
+ ContactsDbIngestModuleFactory.moduleName, name))
+
+ email = resultSet.getString("email")
+ art.addAttribute(BlackboardAttribute(
+ BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL.getTypeID(),
+ ContactsDbIngestModuleFactory.moduleName, email))
+
+ phone = resultSet.getString("phone")
+ art.addAttribute(BlackboardAttribute(
+ BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER.getTypeID(),
+ ContactsDbIngestModuleFactory.moduleName, phone))\endverbatim
+
+That's it. We've just found the databases, queried them, and made artifacts for the user to see. There are some final things though. First, we should fire off an event so that the UI updates and refreshes with the new artifacts. We can fire just one event after each database is parsed (or you could fire one for each artifact - it's up to you).
+
+\verbatim
+IngestServices.getInstance().fireModuleDataEvent(
+ ModuleDataEvent(ContactsDbIngestModuleFactory.moduleName,
+ BlackboardArtifact.ARTIFACT_TYPE.TSK_CONTACT, None))\endverbatim
+
+And the final thing is to clean up. We should close the database connections and delete our temporary file.
+\verbatim
+stmt.close()
+dbConn.close()
+os.remove(lclDbPath)\endverbatim
+
+\subsection python_tutorial2_niceties Niceties
+
+Data source-level ingest modules can run for quite some time. Therefore, data source-level ingest modules should do some additional things that file-level ingest modules do not need to.
+
+- Progress bars: Each data source-level ingest module will have its own progress bar in the lower right. A reference to it is passed into the process() method. You should update it to provide user feedback.
+- Cancellation: A user could cancel ingest while your module is running. You should periodically check if that occurred so that you can bail out as soon as possible. You can do that with a check of:
+\verbatim if self.context.isJobCancelled():\endverbatim
+
+
+\subsection python_tutorial2_tips Debugging and Development Tips
+
+You can find the full file along with a small sample database on github. To use the database, add it as a logical file and run your module on it.
+
+Whenever you have syntax errors or other errors in your script, you will get some form of dialog from Autopsy when you try to run ingest modules. If that happens, fix the problem and run ingest modules again. You don't need to restart Autopsy each time!
+
+The sample module has some log statements in there to help debug what is going on since we don't know of better ways to debug the scripts while running in Autopsy.
+
+\section python_tutorial2_running_exes Running Executables
+While the above example outlined using the FileManager to find files to analyze, the other common use of data source-level ingest modules is to wrap a command line tool that takes a disk image as input. A sample program (RunExe.py) that does that can be found on github. I'll cover the big topics of that program in this section. There are more details in the script about error checking and such.
+
+\subsection python_tutorial2_finding_exe Finding The Executable
+
+To write this kind of data source-level ingest module, put the executable in your module's folder (the DemoScript2 folder we previously made). Use "__file__" to get the path to where your script is and then use some os.path methods to get to the executable in the same folder.
+\verbatim
+path_to_exe = os.path.join(os.path.dirname(os.path.abspath(__file__)), "img_stat.exe")\endverbatim
+
+In our sample program, we do this and verify we can find it in the startup() method so that if we don't, then ingest never starts.
+
+\subsection python_tutorial2_running_the_exe Running The Executable
+
+Data sources can be disk images, but they can also be a folder of files. We only want to run our executable on a disk image. So, verify that:
+\verbatim
+if not isinstance(dataSource, Image):
+ self.log(Level.INFO, "Ignoring data source. Not an image")
+ return IngestModule.ProcessResult.OK \endverbatim
+
+You can get the path to the disk image using dataSource.getPaths().
+
+Once you have the EXE and the disk image, you can use the various subprocess methods to run them.
+
+\subsection python_tutorial2_showing_results Showing the User Results
+
+After the command line tool runs, you have the option of either showing the user the raw output of the tool or parsing it into individual artifacts. Refer to previous sections of this tutorial and the previous tutorial for making artifacts. If you want to simply show the user the output of the tool, then save the output to the Reports folder in the Case directory:
+\verbatim
+reportPath = os.path.join(Case.getCurrentCase().getCaseDirectory(),
+ "Reports", "img_stat-" + str(dataSource.getId()) + ".txt") \endverbatim
+
+Then you can add the report to the case so that it shows up in the tree in the main UI panel.
+\verbatim Case.getCurrentCase().addReport(reportPath, "Run EXE", "img_stat output")\endverbatim
+
+\section python_tutorial2_conclusion Conclusion
+
+Data source-level ingest modules allow you to query for a subset of files by name or to run on an entire disk image. This tutorial has shown an example of both use cases and shown how to use SQLite in Jython.
+
+
+*/
\ No newline at end of file
diff --git a/docs/doxygen/modDevPython.dox b/docs/doxygen/modDevPython.dox
index 8878d97cdb..85b420a4be 100644
--- a/docs/doxygen/modDevPython.dox
+++ b/docs/doxygen/modDevPython.dox
@@ -15,11 +15,10 @@ Using it is very easy though in Autopsy and it allows you to access all of the J
To develop a module, you should follow this section to get your environment setup and then read the later sections on the different types of modules.
-There are also a set of tutorials that Basis Technology published on their blog. While not as thorough as this documentation, they are an easy introduction to the general ideas.
-
-- File Ingest Modules: http://www.basistech.com/python-autopsy-module-tutorial-1-the-file-ingest-module/
-- Data Source Ingest Modules: http://www.basistech.com/python-autopsy-module-tutorial-2-the-data-source-ingest-module/
-- Report Modules: http://www.basistech.com/python-autopsy-module-tutorial-3-the-report-module/
+There are also a set of tutorials that provide an easy introduction to the general ideas.
+- File Ingest Modules: \subpage mod_python_file_ingest_tutorial_page
+- Data Source Ingest Modules: \subpage mod_python_ds_ingest_tutorial_page
+- Report Modules: \subpage mod_python_report_tutorial_page
\section mod_dev_py_setup Basic Setup
diff --git a/docs/doxygen/modFileIngestTutorial.dox b/docs/doxygen/modFileIngestTutorial.dox
new file mode 100644
index 0000000000..7873513a4f
--- /dev/null
+++ b/docs/doxygen/modFileIngestTutorial.dox
@@ -0,0 +1,154 @@
+/*! \page mod_python_file_ingest_tutorial_page Python Tutorial #1: Writing a File Ingest Module
+
+
+\section python_tutorial1_why Why Write a File Ingest Module?
+
+- Autopsy hides the fact that a file is coming from a file system, was carved, was from inside of a ZIP file, or was part of a local file. So, you don't need to spend time supporting all of the ways that your user may want to get data to you. You just need to worry about analyzing the content.
+- Autopsy displays files automatically and can include them in reports if you use standard blackboard artifacts (described later). That means you don't need to worry about UIs and reports.
+- Autopsy gives you access to results from other modules. So, you can build on top of their results instead of duplicating them.
+
+
+\section python_tutorial1_ingest_modules Ingest Modules
+
+For our first example, we're going to write an ingest module. Ingest modules in Autopsy run on the data sources that are added to a case. When you add a disk image (or local drive or logical folder) in Autopsy, you'll be presented with a list of modules to run (such as hash lookup and keyword search).
+
+\image html ingest-modules.PNG
+
+Those are all ingest modules. We're going to write one of those. There are two types of ingest modules that we can build:
+
+- File Ingest Modules are the easiest to write. During their lifetime, they will get passed in each file in the data source. This includes files that are found via carving or inside of ZIP files (if those modules are also enabled).
+- Data Source Ingest Modules require slightly more work because you have to query the database for the files of interest. If you only care about a small number of files, know their name, and know they won't be inside of ZIP files, then these are your best bet.
+
+
+For this first tutorial, we're going to write a file ingest module. The \ref mod_python_ds_ingest_tutorial_page "second tutorial" will focus on data source ingest modules. Regardless of the type of ingest module you are writing, you will need to work with two classes:
+
+- The factory class provides Autopsy with module information such as display name and version. It also creates instances of ingest modules as needed.
+- The ingest module class will do the actual analysis. One of these will be created per thread. For file ingest modules, Autopsy will typically create two or more of these at a time so that it can analyze files in parallel. If you keep things simple, and don't use static variables, then you don't have to think about anything multithreaded.
+
+
+\section python_tutorial1_getting_started Getting Started
+
+To write your first file ingest module, you'll need:
+
+- An installed copy of Autopsy available from SleuthKit
+- A text editor.
+- A copy of the sample file ingest module from Github
+
+
+Some other general notes are that you will be writing in Jython, which converts Python-looking code into Java. It has some limitations, including:
+
+- You can't use Python 3 (you are limited to Python 2.7)
+- You can't use libraries that use native code
+
+
+But, Jython will give you access to all of the Java classes and services that Autopsy provides. So, if you want to stray from this example, then refer to the Developer docs on what classes and methods you have access to. The comments in the sample file will identify what type of object is being passed in along with a URL to its documentation.
+
+\subsection python_tutorial1_folder Making Your Module Folder
+
+Every Python module in Autopsy gets its own folder. This reduces naming collisions between modules. To find out where you should put your Python module, launch Autopsy and choose the Tools -> Python Plugins menu item. That will open a folder in your AppData folder, such as "C:\Users\JDoe\AppData\Roaming\Autopsy\python_modules".
+
+Make a folder inside of there to store your module. Call it "DemoScript". Copy the fileIngestModule.py sample file listed above into the this new folder and rename it to FindBigRoundFiles.py. Your folder should look like this:
+
+\image html demoScript_folder.png
+
+\subsection python_tutorial1_writing Writing the Script
+
+We are going to write a script that flags any file that is larger than 10MB and whose size is a multiple of 4096. We'll call these big and round files. This kind of technique could be useful for finding encrypted files. An additional check would be for entropy of the file, but we'll keep the example simple.
+
+Open the FindBigRoundFiles.py file in your favorite python text editor. The sample Autopsy Python modules all have TODO entries in them to let you know what you should change. The below steps jump from one TODO to the next.
+
+- Factory Class Name: The first thing to do is rename the sample class name from "SampleJythonFileIngestModuleFactory" to "FindBigRoundFilesIngestModuleFactory". In the sample module, there are several uses of this class name, so you should search and replace for these strings.
+- Name and Description: The next TODO entries are for names and descriptions. These are shown to users. For this example, we'll name it "Big and Round File Finder". The description can be anything you want. Note that Autopsy requires that modules have unique names, so don't make it too generic.
+- Ingest Module Class Name: The next thing to do is rename the ingest module class from "SampleJythonFileIngestModule" to "FindBigRoundFilesIngestModule". Our usual naming convention is that this class is the same as the factory class with "Factory" removed from the end.
+- startUp() method: The startUp() method is where each module initializes. For our example, we don't need to do anything special in here. Typically though, this is where you want to do stuff that could fail because throwing an exception here causes the entire ingest to stop.
+- process() method: This is where we do our analysis. The sample module is well documented with what it does. It ignores non-files, looks at the file name, and makes a blackboard artifact for ".txt" files. There are also a bunch of other things that it does to show examples for easy copy and pasting, but we don't need them in our module. We'll cover what goes into this method in the next section.
+- shutdown() method: The shutDown() method either frees resources that were allocated or sends summary messages. For our module, it will do nothing.
+
+
+\subsection python_tutorial1_process The process() Method
+
+The process() method is passed in a reference to an AbstractFile Object. With this, you have access to all of a file's contents and metadata. We want to flag files that are larger than 10MB and that are a multiple of 4096 bytes. The following code does that:
+
+\verbatim if ((file.getSize() > 10485760) and ((file.getSize() % 4096) == 0)):
+\endverbatim
+
+Now that we have found the files, we want to do something with them. In our situation, we just want to alert the user to them. We do this by making an "Interesting Item" blackboard artifact. The Blackboard is where ingest modules can communicate with each other and with the Autopsy GUI. The blackboard has a set of artifacts on it and each artifact:
+
+- Has a type
+- Is associated with a file
+- Has one or more attributes. Attributes are simply name and value pairs.
+
+
+For our example, we are going to make an artifact of type "TSK_INTERESTING_FILE" whenever we find a big and round file. These are one of the most generic artifact types and are simply a way of alerting the user that a file is interesting for some reason. Once you make the artifact, it will be shown in the UI. The below code makes an artifact for the file and puts it into the set of "Big and Round Files". You can create whatever set names you want. The Autopsy GUI organizes Interesting Files by their set name.
+\verbatim
+ art = file.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT)
+ att = BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME.getTypeID(),
+ FindBigRoundFilesIngestModuleFactory.moduleName, "Big and Round Files")
+ art.addAttribute(att)\endverbatim
+
+The above code adds the artifact and a single attribute to the blackboard in the embedded database, but it does not notify other modules or the UI. The UI will eventually refresh, but it is faster to fire an event with this:
+\verbatim
+ IngestServices.getInstance().fireModuleDataEvent(
+ ModuleDataEvent(FindBigRoundFilesIngestModuleFactory.moduleName,
+ BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT, None))\endverbatim
+
+That's it. Your process() method should look something like this:
+\verbatim
+ def process(self, file):
+
+ # Skip non-files
+
+ if ((file.getType() == TskData.TSK_DB_FILES_TYPE_ENUM.UNALLOC_BLOCKS) or
+
+ (file.getType() == TskData.TSK_DB_FILES_TYPE_ENUM.UNUSED_BLOCKS) or
+
+ (file.isFile() == False)):
+
+ return IngestModule.ProcessResult.OK
+
+
+
+ # Look for files bigger than 10MB that are a multiple of 4096
+
+ if ((file.getSize() > 10485760) and ((file.getSize() % 4096) == 0)):
+
+
+
+ # Make an artifact on the blackboard. TSK_INTERESTING_FILE_HIT is a generic type of
+
+ # artifact. Refer to the developer docs for other examples.
+
+ art = file.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT)
+
+ att = BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME.getTypeID(),
+
+ FindBigRoundFilesIngestModuleFactory.moduleName, "Big and Round Files")
+
+ art.addAttribute(att)
+
+
+
+ # Fire an event to notify the UI and others that there is a new artifact
+
+ IngestServices.getInstance().fireModuleDataEvent(
+
+ ModuleDataEvent(FindBigRoundFilesIngestModuleFactory.moduleName,
+
+ BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT, None))
+
+
+
+ return IngestModule.ProcessResult.OK\endverbatim
+
+Save this file and run the module on some of your data. If you have any big and round files, you should see an entry under the "Interesting Items" node in the tree.
+
+\image html bigAndRoundFiles.png
+
+\subsection python_tutorial1_debug Debugging and Development Tips
+
+Whenever you have syntax errors or other errors in your script, you will get some form of dialog from Autopsy when you try to run ingest modules. If that happens, fix the problem and run ingest modules again. You don't need to restart Autopsy each time!
+
+The sample module has some log statements in there to help debug what is going on since we don't know of better ways to debug the scripts while running in Autopsy.
+
+
+*/
diff --git a/docs/doxygen/modReportModuleTutorial.dox b/docs/doxygen/modReportModuleTutorial.dox
new file mode 100644
index 0000000000..26cb14564e
--- /dev/null
+++ b/docs/doxygen/modReportModuleTutorial.dox
@@ -0,0 +1,123 @@
+/*! \page mod_python_report_tutorial_page Python Tutorial #3: Writing a Report Module
+
+In our last two tutorials, we built a Python Autopsy \ref mod_python_file_ingest_tutorial_page "file ingest modules" and \ref mod_python_ds_ingest_tutorial_page "data source ingest modules" that analyzed the data sources as they were added to cases. In our third post, we're going to make an entirely different kind of module, a report module.
+
+Report modules are typically run after the user has completed their analysis. Autopsy comes with report modules to generate HTML, Excel, KML, and other types of reports. We're going to make a report module that outputs data in CSV.
+
+Like in the second tutorial, we are going to assume that you've read at least the \ref mod_python_file_ingest_tutorial_page "first tutorial" to know how to get your environment set up. As a reminder, Python modules in Autopsy are written in Jython and have access to all of the Java classes (which is why we have links to Java documentation below).
+
+\section python_tutorial3_report_modules Report Modules
+
+Autopsy report modules are often run after the user has run some ingest modules, reviewed the results, and tagged some files of interest. The user will be given a list of report modules to choose from.
+
+\image html reports_select.png
+
+The main reasons for writing an Autopsy report module are:
+
+- You need the results in a custom output format, such as XML or JSON.
+- You want to upload results to a central location.
+- You want to perform additional analysis after all ingest modules have run. While the modules have the word "report" in them, there is no actual requirement that they produce a report or export data. The module can simply perform data analysis and post artifacts to the blackboard like ingest modules do.
+
+
+As we dive into the details, you will notice that the report module API is fairly generic. This is because reports are created at a case level, not a data source level. So, when a user chooses to run a report module, all Autopsy does is tell it to run and gives it a path to a directory to store its results in. The report module can store whatever it wants in the directory.
+
+Note that if you look at the \ref mod_report_page "full developer docs", there are other report module types that are supported in Java. These are not supported though in Python.
+
+\subsection python_tutorial3_getting_content Getting Content
+
+With report modules, it is up to you to find the content that you want to include in your report or analysis. Generally, you will want to access some or all of the files, tagged files, or blackboard artifacts. As you may recall from the previous tutorials, blackboard artifacts are how ingest modules in Autopsy store their results so that they can be shown in the UI, used by other modules, and included in the final report. In this tutorial, we will introduce the SleuthkitCase class, which we generally don't introduce to module writers because it has lots of methods, many of which are low-level, and there are other classes, such as FileManager, that are more focused and easier to use.
+
+\subsubsection python_tutorial3_getting_files Getting Files
+
+You have three choices for getting files to report on. You can use the FileManager, which we used in \ref mod_python_ds_ingest_tutorial_page "the last Data Source-level Ingest Module tutorial". The only change is that you will need to call it multiple times, one for each data source in the case. You will have code that looks something like this:
+\verbatim
+dataSources = Case.getCurrentCase().getDataSources()
+fileManager = Case.getCurrentCase().getServices().getFileManager()
+
+for dataSource in dataSources:
+ files = fileManager.findFiles(dataSource, "%.txt")\endverbatim
+
+Another approach is to use the SleuthkitCase.findAllFilesWhere() method that allows you to specify a SQL query. To use this method, you must know the schema of the database (which makes this a bit more challenging, but more powerful). The schema is defined on the wiki.
+
+Usually, you just need to focus on the tsk_files table. You may run into memory problems and you can also use SleuthkitCase.findAllFileIdsWhere() to get just the IDs and then call SleuthkitCase.getAbstractFileById() to get files as needed.
+
+A third approach is to call org.sleuthkit.autopsy.casemodule.Case.getDataSources(), and then recursively call getChildren() on each Content object. This will traverse all of the folders and files in the case. This is the most memory efficient, but also more complex to code.
+
+\subsubsection python_tutorial3_getting_artifacts Getting Blackboard Artifacts
+
+The blackboard is where modules store their analysis results. If you want to include them in your report, then there are several methods that you could use. If you want all artifacts of a given type, then you can use SleuthkitCase.getBlackboardArtifacts(). There are many variations of this method that take different arguments. Look at them to find the one that is most convenient for you.
+
+\subsubsection python_tutorial3_getting_tags Getting Tagged Files or Artifacts
+
+If you want to find files or artifacts that are tagged, then you can use the org.sleuthkit.autopsy.casemodule.services.TagsManager. It has methods to get all tags of a given name, such as org.sleuthkit.autopsy.casemodule.services.TagsManager.getContentTagsByTagName().
+
+\section python_tutorial3_getting_started Getting Started
+
+\subsection python_tutorial3_making_the_folder Making the Folder
+
+We'll start by making our module folder. As we learned in \ref mod_python_file_ingest_tutorial_page "the first tutorial", every Python module in Autopsy gets its own folder. To find out where you should put your Python module, launch Autopsy and choose the Tools->Python Plugins menu item. That will open a subfolder in your AppData folder, such as "C:\Users\JDoe\AppData\Roaming\Autopsy\python_modules".
+
+Make a folder inside of there to store your module. Call it "DemoScript3". Copy the reportmodule.py sample file into the this new folder and rename it to CSVReport.py.
+
+\subsection python_tutorial3_writing_script Writing the Script
+
+We are going to write a script that makes some basic CSV output: file name and MD5 hash. Open the CSVReport.py file in your favorite Python text editor. The sample Autopsy Python modules all have TODO entries in them to let you know what you should change. The below steps jump from one TODO to the next.
+
+
+- Factory Class Name: The first thing to do is rename the sample class name from "SampleGeneralReportModule" to "CSVReportModule". In the sample module, there are several uses of this class name, so you should search and replace for these strings.
+- Name and Description: The next TODO entries are for names and descriptions. These are shown to users. For this example, we'll name it "CSV Hash Report Module". The description can be anything you want. Note that Autopsy requires that modules have unique names, so don't make it too generic.
+- Relative File Path: The next step is to specify the filename that your module is going to use for the report. Autopsy will later provide you with a folder name to save your report in. If you have multiple file names, then pick the main one. This path will be shown to the user after the report has been generated so that they can open it. For this example, we'll call it "hashes.csv" in the getRelativeFilePath() method.
+- generateReport() Method: This method is what is called when the user wants to run the module. It gets passed in the base directory to store the results in and a progress bar. It is responsible for making the report and calling Case.addReport() so that it will be shown in the tree. We'll cover the details of this method in a later section.
+
+
+\subsection python_tutorial3_generate_report The generateReport() method
+
+The generateReport() method is where the work is done. The baseReportDir argument is a string for the base directory to store results in. The progressBar argument is a org.sleuthkit.autopsy.report.ReportProgressPanel
+that shows the user progress while making long reports and to make the progress bar red if an error occurs.
+
+We'll use one of the basic ideas from the sample, so you can copy and paste from that as you see fit to make this method. Our general approach is going to be this:
+
+- Open the CSV file.
+- Query for all files.
+- Cycle through each of the files and print a line of text.
+- Add the report to the Case database.
+
+
+To focus on the essential code, we'll skip the progress bar details. However, the final solution that we'll link to at the end contains the progress bar code.
+
+To open the report file in the right folder, we'll need a line such as this:
+\verbatim
+fileName = os.path.join(baseReportDir, self.getRelativeFilePath())
+report = open(fileName, 'w')\endverbatim
+
+Next we need to query for the files. In our case, we want all of the files, but can skip the directories. We'll use lines such as this to get the current case and then call the SleuthkitCase.findAllFilesWhere() method.
+\verbatim
+sleuthkitCase = Case.getCurrentCase().getSleuthkitCase()
+files = sleuthkitCase.findAllFilesWhere("NOT meta_type = " +
+ str(TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_DIR.getValue()))\endverbatim
+
+Now, we want to print a line for each file. To do this, you'll need something like:
+\verbatim
+for file in files:
+ md5 = file.getMd5Hash()
+
+ if md5 is None:
+ md5 = ""
+
+ report.write(file.getParentPath() + file.getName() + "," + md5 + "n")\endverbatim
+
+Note that the file will only have an MD5 value if the Hash Lookup ingest module was run on the data source.
+
+Lastly, we want to add the report to the case database so that the user can later find it from the tree and we want to report that we completed successfully.
+\verbatim
+Case.getCurrentCase().addReport(fileName, self.moduleName, "Hashes CSV")
+progressBar.complete(ReportStatus.COMPLETE)\endverbatim
+
+That's it. The final code can be found on github.
+
+\subsection python_tutorial3_conclusions Conclusions
+
+In this tutorial, we made a basic report module that creates a custom CSV file. The most challenging part of writing a report module is knowing how to get all of the data that you need. Hopefully, the \ref python_tutorial3_getting_content section above covered what you need, but if not, then go on the Sleuthkit forum and we'll try to point you in the right direction.
+
+
+*/
\ No newline at end of file
diff --git a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/EmailMessage.java b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/EmailMessage.java
index 40f2fc0933..09a6637e6e 100644
--- a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/EmailMessage.java
+++ b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/EmailMessage.java
@@ -83,7 +83,7 @@ class EmailMessage {
void setSubject(String subject) {
if (subject != null) {
this.subject = subject;
- if(subject.matches("^[R|r][E|e].*?:.*")) {
+ if (subject.matches("^[R|r][E|e].*?:.*")) {
this.simplifiedSubject = subject.replaceAll("[R|r][E|e].*?:", "").trim();
replySubject = true;
} else {
@@ -93,19 +93,19 @@ class EmailMessage {
this.simplifiedSubject = "";
}
}
-
+
/**
* Returns the orginal subject with the "RE:" stripped off".
- *
+ *
* @return Message subject with the "RE" stripped off
*/
String getSimplifiedSubject() {
return simplifiedSubject;
}
-
+
/**
* Returns whether or not the message subject started with "RE:"
- *
+ *
* @return true if the original subject started with RE otherwise false.
*/
boolean isReplySubject() {
@@ -121,6 +121,7 @@ class EmailMessage {
this.headers = headers;
}
}
+
String getTextBody() {
return textBody;
}
@@ -211,75 +212,80 @@ class EmailMessage {
this.localPath = localPath;
}
}
-
+
/**
- * Returns the value of the Message-ID header field of this message or
- * empty string if it is not present.
- *
+ * Returns the value of the Message-ID header field of this message or empty
+ * string if it is not present.
+ *
* @return the identifier of this message.
*/
String getMessageID() {
return messageID;
}
-
+
/**
* Sets the identifier of this message.
- *
+ *
* @param messageID identifer of this message
*/
void setMessageID(String messageID) {
- this.messageID = messageID;
+ if (messageID != null) {
+ this.messageID = messageID;
+ } else {
+ this.messageID = "";
+ }
}
-
+
/**
- * Returns the messageID of the parent message or empty String if not present.
- *
+ * Returns the messageID of the parent message or empty String if not
+ * present.
+ *
* @return the idenifier of the message parent
*/
String getInReplyToID() {
return inReplyToID;
}
-
+
/**
* Sets the messageID of the parent message.
- *
+ *
* @param inReplyToID messageID of the parent message.
*/
void setInReplyToID(String inReplyToID) {
this.inReplyToID = inReplyToID;
}
-
+
/**
- * Returns a list of Message-IDs listing the parent, grandparent,
- * great-grandparent, and so on, of this message.
- *
+ * Returns a list of Message-IDs listing the parent, grandparent,
+ * great-grandparent, and so on, of this message.
+ *
* @return The reference list or empty string if none is available.
*/
List getReferences() {
return references;
}
-
+
/**
* Set the list of reference message-IDs from the email message header.
- *
- * @param references
+ *
+ * @param references
*/
void setReferences(List references) {
this.references = references;
}
-
+
/**
* Sets the ThreadID of this message.
- *
+ *
* @param threadID - the thread ID to set
*/
void setMessageThreadID(String threadID) {
this.messageThreadID = threadID;
}
-
+
/**
* Returns the ThreadID for this message.
- *
+ *
* @return - the message thread ID or "" is non is available
*/
String getMessageThreadID() {
@@ -308,7 +314,7 @@ class EmailMessage {
private long aTime = 0L;
private long mTime = 0L;
-
+
private TskData.EncodingType encodingType = TskData.EncodingType.NONE;
String getName() {
@@ -394,14 +400,14 @@ class EmailMessage {
this.mTime = mTime.getTime() / 1000;
}
}
-
- void setEncodingType(TskData.EncodingType encodingType){
+
+ void setEncodingType(TskData.EncodingType encodingType) {
this.encodingType = encodingType;
}
-
- TskData.EncodingType getEncodingType(){
+
+ TskData.EncodingType getEncodingType() {
return encodingType;
}
-
+
}
}