19 package org.sleuthkit.autopsy.casemodule;
22 import java.io.IOException;
23 import java.nio.file.Path;
24 import java.nio.file.Paths;
25 import java.util.ArrayList;
26 import java.util.Arrays;
27 import java.util.List;
28 import java.util.UUID;
29 import java.util.logging.Level;
30 import javax.swing.JPanel;
31 import javax.swing.filechooser.FileFilter;
32 import org.apache.commons.io.FilenameUtils;
33 import org.openide.modules.InstalledFileLocator;
34 import org.openide.util.NbBundle;
35 import org.openide.util.NbBundle.Messages;
36 import org.openide.util.lookup.ServiceProvider;
37 import org.openide.util.lookup.ServiceProviders;
54 @ServiceProviders(value = {
55 @ServiceProvider(service = DataSourceProcessor.class),
56 @ServiceProvider(service = AutoIngestDataSourceProcessor.class)
59 "LocalFilesDSProcessor.logicalEvidenceFilter.desc=Logical Evidence Files (L01)"
63 private static final String DATA_SOURCE_TYPE = NbBundle.getMessage(
LocalFilesDSProcessor.class,
"LocalFilesDSProcessor.dsType");
66 private static final String L01_EXTRACTION_DIR =
"L01";
67 private static final String UNIQUENESS_CONSTRAINT_SEPERATOR =
"_";
68 private static final String EWFEXPORT_DIR =
"ewfexport_exec";
69 private static final String EWFEXPORT_32_BIT_DIR =
"32-bit";
70 private static final String EWFEXPORT_64_BIT_DIR =
"64-bit";
71 private static final String EWFEXPORT_WINDOWS_EXE =
"ewfexport.exe";
72 private static final String LOG_FILE_EXTENSION =
".txt";
73 private static final List<String> LOGICAL_EVIDENCE_EXTENSIONS = Arrays.asList(
".l01");
74 private static final String LOGICAL_EVIDENCE_DESC = Bundle.LocalFilesDSProcessor_logicalEvidenceFilter_desc();
89 configPanel = LogicalFilesDspPanel.getDefault();
100 return DATA_SOURCE_TYPE;
112 return DATA_SOURCE_TYPE;
125 configPanel.select();
138 return configPanel.validatePanel();
157 run(null, progressMonitor, callback);
178 localFilePaths = configPanel.getContentPaths();
179 boolean createTimestamp = configPanel.getCreateTimestamp();
180 boolean modifiedTimestamp = configPanel.getModifiedTimestamp();
181 boolean accessTimestamp = configPanel.getAccessTimestamp();
182 if (configPanel.subTypeIsLogicalEvidencePanel()) {
185 localFilePaths = extractLogicalEvidenceFileContents(localFilePaths);
188 final List<String> errors =
new ArrayList<>();
189 errors.add(ex.getMessage());
193 logger.log(Level.WARNING,
"Exception while getting open case.", ex);
197 run(UUID.randomUUID().toString(), configPanel.getFileSetName(), localFilePaths, host, createTimestamp,
198 accessTimestamp, modifiedTimestamp, progressMonitor, callback);
214 final List<String> extractedPaths =
new ArrayList<>();
216 ewfexportPath = locateEwfexportExecutable();
217 List<String> command =
new ArrayList<>();
218 for (
final String l01Path : logicalEvidenceFilePaths) {
220 command.add(ewfexportPath.toAbsolutePath().toString());
222 command.add(
"files");
225 if (!l01Dir.exists()) {
228 Path dirPath = Paths.get(FilenameUtils.getBaseName(l01Path) + UNIQUENESS_CONSTRAINT_SEPERATOR + System.currentTimeMillis());
230 command.add(dirPath.toString());
231 command.add(l01Path);
232 ProcessBuilder processBuilder =
new ProcessBuilder(command);
233 processBuilder.directory(l01Dir);
236 Path logFileName = Paths.get(l01Dir.toString(), dirPath.toString() + LOG_FILE_EXTENSION);
237 File logFile =
new File(logFileName.toString());
238 Path errFileName = Paths.get(l01Dir.toString(), dirPath.toString() + LOG_FILE_EXTENSION);
239 File errFile =
new File(errFileName.toString());
240 processBuilder.redirectError(ProcessBuilder.Redirect.appendTo(errFile));
241 processBuilder.redirectOutput(ProcessBuilder.Redirect.appendTo(logFile));
244 if (l01Dir.toPath().resolve(dirPath).toFile().exists()) {
245 extractedPaths.add(l01Dir.toPath().resolve(dirPath).toString());
247 throw new L01Exception(
"Can not process the selected L01 file, ewfExport was unable to extract any files from it.");
250 }
catch (SecurityException ex) {
251 throw new L01Exception(
"Security exception occcured while trying to extract l01 contents", ex);
252 }
catch (IOException ex) {
253 throw new L01Exception(
"IOException occcured while trying to extract l01 contents", ex);
256 return extractedPaths;
264 static FileFilter getLogicalEvidenceFilter() {
265 return LOGICAL_EVIDENCE_FILTER;
279 throw new L01Exception(
"L01 files are only supported on windows currently");
284 final File ewfRoot = InstalledFileLocator.getDefault().locate(EWFEXPORT_DIR,
LocalFilesDSProcessor.class.getPackage().getName(),
false);
288 executablePath = Paths.get(
289 ewfRoot.getAbsolutePath(),
290 EWFEXPORT_64_BIT_DIR,
291 EWFEXPORT_WINDOWS_EXE);
293 executablePath = Paths.get(
294 ewfRoot.getAbsolutePath(),
295 EWFEXPORT_32_BIT_DIR,
296 EWFEXPORT_WINDOWS_EXE);
301 final File ewfexport = executablePath.toFile();
302 if (null == ewfexport || !ewfexport.exists()) {
305 if (!ewfexport.canExecute()) {
309 return executablePath;
337 new Thread(
new AddLocalFilesTask(deviceId, rootVirtualDirectoryName, localFilePaths, host,
false,
false,
false,progressMonitor, callback)).start();
367 public void run(String deviceId, String rootVirtualDirectoryName, List<String> localFilePaths, Host host,
boolean createTimestamp,
boolean accessTimestamp,
369 new Thread(
new AddLocalFilesTask(deviceId, rootVirtualDirectoryName, localFilePaths, host, createTimestamp, accessTimestamp, modifiedTimestamp,
370 progressMonitor, callback)).start();
397 run(deviceId, rootVirtualDirectoryName, localFilePaths, null, progressMonitor, callback);
420 configPanel.select();
421 localFilePaths = null;
430 List<String> filePaths = Arrays.asList(
new String[]{dataSourcePath.toString()});
433 if (filePaths.size() == 1) {
434 for (
final String path : filePaths) {
435 if (
new File(path).isFile() && LOGICAL_EVIDENCE_FILTER.
accept(
new File(path))) {
438 filePaths = extractLogicalEvidenceFileContents(filePaths);
439 }
catch (L01Exception ex) {
440 logger.log(Level.WARNING,
"File extension was .l01 but contents of logical evidence file were unable to be extracted", ex);
444 logger.log(Level.WARNING,
"Exception while getting open case.", ex);
455 process(deviceId, dataSourcePath, null, progressMonitor, callBack);
460 List<String> filePaths = Arrays.asList(
new String[]{dataSourcePath.toString()});
461 run(deviceId,
"", filePaths, host, progressMonitor, callBack);
467 private final class L01Exception
extends Exception {
469 private static final long serialVersionUID = 1L;
471 L01Exception(
final String message) {
475 L01Exception(
final String message,
final Throwable cause) {
476 super(message, cause);
List< String > localFilePaths
final LogicalFilesDspPanel configPanel
void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
static int execute(ProcessBuilder processBuilder)
void run(String deviceId, String rootVirtualDirectoryName, List< String > localFilePaths, Host host, boolean createTimestamp, boolean accessTimestamp, boolean modifiedTimestamp, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
String getDataSourceType()
void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack)
void done(DataSourceProcessorResult result, List< String > errList, List< Content > newDataSources)
List< String > extractLogicalEvidenceFileContents(final List< String > logicalEvidenceFilePaths)
void run(String deviceId, String rootVirtualDirectoryName, List< String > localFilePaths, Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
String getModuleDirectory()
Path locateEwfexportExecutable()
int canProcess(Path dataSourcePath)
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
void process(String deviceId, Path dataSourcePath, Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack)
void run(String deviceId, String rootVirtualDirectoryName, List< String > localFilePaths, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
void run(Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)