19 package org.sleuthkit.autopsy.casemodule;
22 import java.nio.file.Path;
23 import javax.swing.JPanel;
24 import java.util.ArrayList;
25 import java.util.Calendar;
26 import java.util.List;
27 import java.util.logging.Level;
28 import java.util.UUID;
29 import javax.swing.filechooser.FileFilter;
30 import org.openide.util.NbBundle;
31 import org.openide.util.lookup.ServiceProvider;
32 import org.openide.util.lookup.ServiceProviders;
53 @ServiceProviders(value = {
54 @ServiceProvider(service = DataSourceProcessor.class),
55 @ServiceProvider(service = AutoIngestDataSourceProcessor.class)}
59 private final static String DATA_SOURCE_TYPE = NbBundle.getMessage(
ImageDSProcessor.class,
"ImageDSProcessor.dsType.text");
61 private static final List<String> allExt =
new ArrayList<>();
65 private static final String ALL_DESC = NbBundle.getMessage(
ImageDSProcessor.class,
"ImageDSProcessor.allDesc.text");
67 private static final List<FileFilter> filtersList =
new ArrayList<>();
71 private Image image = null;
84 private Host host = null;
87 filtersList.add(allFilter);
88 filtersList.add(rawFilter);
89 filtersList.add(encaseFilter);
92 if (!System.getProperty(
"os.name").toLowerCase().contains(
"mac")) {
93 filtersList.add(virtualMachineFilter);
113 static List<FileFilter> getFileFiltersList() {
125 return DATA_SOURCE_TYPE;
184 run(null, progressMonitor, callback);
204 ingestStream =
new DefaultIngestStream();
205 readConfigSettings();
209 new String[]{imagePath}, sectorSize, timeZone, md5, sha1, sha256, deviceId, this.host);
210 }
catch (TskCoreException ex) {
211 logger.log(Level.SEVERE,
"Error adding data source with path " + imagePath +
" to database", ex);
212 final List<String> errors =
new ArrayList<>();
213 errors.add(ex.getMessage());
218 doAddImageProcess(deviceId, imagePath, sectorSize, timeZone, ignoreFatOrphanFiles, md5, sha1, sha256, progressMonitor, callback);
241 runWithIngestStream(null, settings, progress, callBack);
267 readConfigSettings();
273 new String[]{imagePath}, sectorSize, timeZone, md5, sha1, sha256, deviceId, this.host);
274 }
catch (TskCoreException ex) {
275 logger.log(Level.SEVERE,
"Error adding data source with path " + imagePath +
" to database", ex);
276 final List<String> errors =
new ArrayList<>();
277 errors.add(ex.getMessage());
285 }
catch (TskCoreException ex) {
286 logger.log(Level.SEVERE,
"Error starting ingest modules", ex);
290 ingestStream =
new DefaultIngestStream();
293 doAddImageProcess(deviceId, imagePath, sectorSize, timeZone, ignoreFatOrphanFiles, md5, sha1, sha256, progress, callBack);
301 deviceId = UUID.randomUUID().toString();
306 md5 = configPanel.getMd5();
310 sha1 = configPanel.getSha1();
311 if (sha1.isEmpty()) {
314 sha256 = configPanel.getSha256();
315 if (sha256.isEmpty()) {
352 ingestStream =
new DefaultIngestStream();
355 new String[]{imagePath}, sectorSize, timeZone,
"",
"",
"", deviceId);
356 }
catch (TskCoreException ex) {
357 logger.log(Level.SEVERE,
"Error adding data source with path " + imagePath +
" to database", ex);
358 final List<String> errors =
new ArrayList<>();
359 errors.add(ex.getMessage());
364 doAddImageProcess(deviceId, imagePath, 0, timeZone, ignoreFatOrphanFiles, null, null, null, progressMonitor, callback);
399 if (ingestStream == null) {
400 String message =
"Ingest stream was not initialized before running the add image process on " + imagePath;
401 logger.log(Level.SEVERE, message);
402 final List<String> errors =
new ArrayList<>();
408 String message =
"Image was not added to database before running the add image process on " + imagePath;
409 logger.log(Level.SEVERE, message);
410 final List<String> errors =
new ArrayList<>();
416 AddImageTask.ImageDetails imageDetails =
new AddImageTask.ImageDetails(deviceId, image, sectorSize, timeZone, ignoreFatOrphanFiles, md5, sha1, sha256, null);
417 addImageTask =
new AddImageTask(imageDetails,
419 new StreamingAddDataSourceCallbacks(ingestStream),
420 new StreamingAddImageTaskCallback(ingestStream, callback));
421 new Thread(addImageTask).start();
433 if (null != addImageTask) {
434 addImageTask.cancelTask();
436 if (ingestStream != null) {
450 ignoreFatOrphanFiles =
false;
456 for (FileFilter filter : filters) {
457 if (filter.accept(file)) {
468 if (!isAcceptedByFiler(dataSourcePath.toFile(), filtersList)) {
478 }
catch (Exception ex) {
488 process(deviceId, dataSourcePath, null, progressMonitor, callBack);
494 this.deviceId = deviceId;
495 this.imagePath = dataSourcePath.toString();
497 this.timeZone = Calendar.getInstance().getTimeZone().getID();
499 this.ignoreFatOrphanFiles =
false;
501 ingestStream =
new DefaultIngestStream();
504 new String[]{imagePath}, sectorSize, timeZone,
"",
"",
"", deviceId, host);
505 }
catch (TskCoreException ex) {
506 logger.log(Level.SEVERE,
"Error adding data source with path " + imagePath +
" to database", ex);
507 final List<String> errors =
new ArrayList<>();
508 errors.add(ex.getMessage());
513 doAddImageProcess(deviceId, dataSourcePath.toString(), sectorSize, timeZone, ignoreFatOrphanFiles, null, null, null, progressMonitor, callBack);
518 return processWithIngestStream(deviceId, dataSourcePath, null, settings, progressMonitor, callBack);
524 this.deviceId = deviceId;
525 this.imagePath = dataSourcePath.toString();
527 this.timeZone = Calendar.getInstance().getTimeZone().getID();
529 this.ignoreFatOrphanFiles =
false;
534 new String[]{imagePath}, sectorSize, timeZone, md5, sha1, sha256, deviceId, host);
535 }
catch (TskCoreException ex) {
536 logger.log(Level.SEVERE,
"Error adding data source with path " + imagePath +
" to database", ex);
537 final List<String> errors =
new ArrayList<>();
538 errors.add(ex.getMessage());
546 }
catch (TskCoreException ex) {
547 logger.log(Level.SEVERE,
"Error starting ingest modules", ex);
548 final List<String> errors =
new ArrayList<>();
549 errors.add(ex.getMessage());
554 doAddImageProcess(deviceId, dataSourcePath.toString(), sectorSize, timeZone, ignoreFatOrphanFiles, null, null, null, progressMonitor, callBack);
IngestStream openIngestStream(DataSource dataSource, IngestJobSettings settings)
static synchronized IngestManager getInstance()
boolean getNoFatOrphans()
void run(Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
void readConfigSettings()
void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack)
String getDataSourceType()
static boolean isAcceptedByFiler(File file, List< FileFilter > filters)
boolean supportsIngestStream()
static final String RAW_IMAGE_DESC
static final String VIRTUAL_MACHINE_DESC
static synchronized ImageFilePanel createInstance(String context, List< FileFilter > fileChooserFilters)
IngestStream processWithIngestStream(String deviceId, Path dataSourcePath, IngestJobSettings settings, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack)
AddImageTask addImageTask
void run(String deviceId, String imagePath, String timeZone, boolean ignoreFatOrphanFiles, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
static final String ENCASE_IMAGE_DESC
void done(DataSourceProcessorResult result, List< String > errList, List< Content > newDataSources)
IngestStream processWithIngestStream(String deviceId, Path dataSourcePath, Host host, IngestJobSettings settings, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack)
boolean ignoreFatOrphanFiles
static final List< String > VIRTUAL_MACHINE_EXTS
static final List< String > ENCASE_IMAGE_EXTS
SleuthkitCase getSleuthkitCase()
void doAddImageProcess(String deviceId, String imagePath, int sectorSize, String timeZone, boolean ignoreFatOrphanFiles, String md5, String sha1, String sha256, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
static boolean imageHasFileSystem(Path dataSourcePath)
void process(String deviceId, Path dataSourcePath, Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack)
void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
void runWithIngestStream(IngestJobSettings settings, DataSourceProcessorProgressMonitor progress, DataSourceProcessorCallback callBack)
final ImageFilePanel configPanel
void runWithIngestStream(Host host, IngestJobSettings settings, DataSourceProcessorProgressMonitor progress, DataSourceProcessorCallback callBack)
static final List< String > RAW_IMAGE_EXTS
int canProcess(Path dataSourcePath)