diff --git a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/Bundle.properties b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/Bundle.properties index 295f82f1cb..f4089caff7 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/Bundle.properties @@ -17,3 +17,5 @@ PhotoRecIngestModule.cancelledByUser=PhotoRec cancelled by user. PhotoRecIngestModule.error.exitValue=PhotoRec carver returned error exit value \= {0} when scanning {1} PhotoRecIngestModule.error.msg=Error processing {0} with PhotoRec carver. PhotoRecIngestModule.complete.numberOfErrors=Number of Errors while Carving\: +PhotoRecCarverIngestJobSettingsPanel.detectionSettingsLabel.text=PhotoRec Settings +PhotoRecCarverIngestJobSettingsPanel.keepCorruptedFilesCheckbox.text=Keep corrupted files diff --git a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverFileIngestModule.java b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverFileIngestModule.java index 75e4f2afe6..446da55940 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverFileIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverFileIngestModule.java @@ -78,6 +78,8 @@ import org.sleuthkit.datamodel.TskData; }) final class PhotoRecCarverFileIngestModule implements FileIngestModule { + static final boolean DEFAULT_CONFIG_KEEP_CORRUPTED_FILES = false; + private static final String PHOTOREC_DIRECTORY = "photorec_exec"; //NON-NLS private static final String PHOTOREC_EXECUTABLE = "photorec_win.exe"; //NON-NLS private static final String PHOTOREC_LINUX_EXECUTABLE = "photorec"; @@ -95,15 +97,24 @@ final class PhotoRecCarverFileIngestModule implements FileIngestModule { private Path rootOutputDirPath; private File executableFile; private IngestServices services; - private UNCPathUtilities uncPathUtilities = new UNCPathUtilities(); + private final UNCPathUtilities uncPathUtilities = new UNCPathUtilities(); private long jobId; + + private final boolean keepCorruptedFiles; private static class IngestJobTotals { - - private AtomicLong totalItemsRecovered = new AtomicLong(0); - private AtomicLong totalItemsWithErrors = new AtomicLong(0); - private AtomicLong totalWritetime = new AtomicLong(0); - private AtomicLong totalParsetime = new AtomicLong(0); + private final AtomicLong totalItemsRecovered = new AtomicLong(0); + private final AtomicLong totalItemsWithErrors = new AtomicLong(0); + private final AtomicLong totalWritetime = new AtomicLong(0); + private final AtomicLong totalParsetime = new AtomicLong(0); + } + /** + * Create a PhotoRec Carver ingest module instance. + * + * @param settings Ingest job settings used to configure the module. + */ + PhotoRecCarverFileIngestModule(PhotoRecCarverIngestJobSettings settings) { + keepCorruptedFiles = settings.isKeepCorruptedFiles(); } private static synchronized IngestJobTotals getTotalsForIngestJobs(long ingestJobId) { @@ -229,8 +240,12 @@ final class PhotoRecCarverFileIngestModule implements FileIngestModule { "/d", // NON-NLS outputDirPath.toAbsolutePath().toString() + File.separator + PHOTOREC_RESULTS_BASE, "/cmd", // NON-NLS - tempFilePath.toFile().toString(), - "search"); // NON-NLS + tempFilePath.toFile().toString()); + if (keepCorruptedFiles) { + processAndSettings.command().add("options,keep_corrupted_file,search"); // NON-NLS + } else { + processAndSettings.command().add("search"); // NON-NLS + } // Add environment variable to force PhotoRec to run with the same permissions Autopsy uses processAndSettings.environment().put("__COMPAT_LAYER", "RunAsInvoker"); //NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverIngestJobSettings.java b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverIngestJobSettings.java new file mode 100755 index 0000000000..93de74f1d6 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverIngestJobSettings.java @@ -0,0 +1,70 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2018 Basis Technology Corp. + * Contact: carrier sleuthkit org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.sleuthkit.autopsy.modules.photoreccarver; + +import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettings; + +/** + * Ingest job settings for the PhotoRec Carver module. + */ +final class PhotoRecCarverIngestJobSettings implements IngestModuleIngestJobSettings { + + private static final long serialVersionUID = 1L; + + private boolean keepCorruptedFiles; + + /** + * Instantiate the ingest job settings with default values. + */ + PhotoRecCarverIngestJobSettings() { + this.keepCorruptedFiles = PhotoRecCarverFileIngestModule.DEFAULT_CONFIG_KEEP_CORRUPTED_FILES; + } + + /** + * Instantiate the ingest job settings. + * + * @param keepCorruptedFiles Keep corrupted files. + */ + PhotoRecCarverIngestJobSettings(boolean keepCorruptedFiles) { + this.keepCorruptedFiles = keepCorruptedFiles; + } + + @Override + public long getVersionNumber() { + return serialVersionUID; + } + + /** + * Are corrupted files being kept? + * + * @return True if keeping corrupted files; otherwise false. + */ + boolean isKeepCorruptedFiles() { + return keepCorruptedFiles; + } + + /** + * Keep or disgard corrupted files. + * + * @param keepCorruptedFiles Are corrupted files being kept? + */ + void setKeepCorruptedFiles(boolean keepCorruptedFiles) { + this.keepCorruptedFiles = keepCorruptedFiles; + } +} diff --git a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverIngestJobSettingsPanel.form b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverIngestJobSettingsPanel.form new file mode 100755 index 0000000000..2fe8e89dba --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverIngestJobSettingsPanel.form @@ -0,0 +1,63 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverIngestJobSettingsPanel.java b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverIngestJobSettingsPanel.java new file mode 100755 index 0000000000..9af6902a2d --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverIngestJobSettingsPanel.java @@ -0,0 +1,99 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2018 Basis Technology Corp. + * Contact: carrier sleuthkit org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.sleuthkit.autopsy.modules.photoreccarver; + +import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettings; +import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettingsPanel; + +/** + * Ingest job settings panel for the Encryption Detection module. + */ +final class PhotoRecCarverIngestJobSettingsPanel extends IngestModuleIngestJobSettingsPanel { + + /** + * Instantiate the ingest job settings panel. + * + * @param settings The ingest job settings. + */ + public PhotoRecCarverIngestJobSettingsPanel(PhotoRecCarverIngestJobSettings settings) { + initComponents(); + customizeComponents(settings); + } + + /** + * Update components with values from the ingest job settings. + * + * @param settings The ingest job settings. + */ + private void customizeComponents(PhotoRecCarverIngestJobSettings settings) { + keepCorruptedFilesCheckbox.setSelected(settings.isKeepCorruptedFiles()); + } + + @Override + public IngestModuleIngestJobSettings getSettings() { + return new PhotoRecCarverIngestJobSettings( + keepCorruptedFilesCheckbox.isSelected()); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + keepCorruptedFilesCheckbox = new javax.swing.JCheckBox(); + detectionSettingsLabel = new javax.swing.JLabel(); + + org.openide.awt.Mnemonics.setLocalizedText(keepCorruptedFilesCheckbox, org.openide.util.NbBundle.getMessage(PhotoRecCarverIngestJobSettingsPanel.class, "PhotoRecCarverIngestJobSettingsPanel.keepCorruptedFilesCheckbox.text")); // NOI18N + + detectionSettingsLabel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(detectionSettingsLabel, org.openide.util.NbBundle.getMessage(PhotoRecCarverIngestJobSettingsPanel.class, "PhotoRecCarverIngestJobSettingsPanel.detectionSettingsLabel.text")); // NOI18N + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(10, 10, 10) + .addComponent(keepCorruptedFilesCheckbox)) + .addComponent(detectionSettingsLabel)) + .addContainerGap(159, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(detectionSettingsLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(keepCorruptedFilesCheckbox) + .addContainerGap(145, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel detectionSettingsLabel; + private javax.swing.JCheckBox keepCorruptedFilesCheckbox; + // End of variables declaration//GEN-END:variables +} diff --git a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverIngestModuleFactory.java b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverIngestModuleFactory.java index 0898f20928..47658b55e0 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverIngestModuleFactory.java +++ b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverIngestModuleFactory.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011-2016 Basis Technology Corp. + * Copyright 2011-2018 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,6 +24,7 @@ import org.sleuthkit.autopsy.ingest.FileIngestModule; import org.sleuthkit.autopsy.ingest.IngestModuleFactory; import org.sleuthkit.autopsy.ingest.IngestModuleFactoryAdapter; import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettings; +import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettingsPanel; /** * A factory for creating instances of file ingest modules that carve @@ -32,7 +33,7 @@ import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettings; @ServiceProvider(service = IngestModuleFactory.class) public class PhotoRecCarverIngestModuleFactory extends IngestModuleFactoryAdapter { - private static final String VERSION = "7.0"; + private static final String VERSION = "7.0"; // Version should match the PhotoRec tool version. /** * Gets the ingest module name for use within this package. @@ -65,7 +66,22 @@ public class PhotoRecCarverIngestModuleFactory extends IngestModuleFactoryAdapte @Override public FileIngestModule createFileIngestModule(IngestModuleIngestJobSettings settings) { - return new PhotoRecCarverFileIngestModule(); + return new PhotoRecCarverFileIngestModule((PhotoRecCarverIngestJobSettings) settings); + } + + @Override + public IngestModuleIngestJobSettings getDefaultIngestJobSettings() { + return new PhotoRecCarverIngestJobSettings(); + } + + @Override + public boolean hasIngestJobSettingsPanel() { + return true; + } + + @Override + public IngestModuleIngestJobSettingsPanel getIngestJobSettingsPanel(IngestModuleIngestJobSettings settings) { + return new PhotoRecCarverIngestJobSettingsPanel((PhotoRecCarverIngestJobSettings) settings); } }