mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
First cut at saving files
This commit is contained in:
parent
44ab48e001
commit
35c00ec388
@ -22,18 +22,16 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.report;
|
package org.sleuthkit.autopsy.report;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import com.fasterxml.jackson.core.JsonEncoding;
|
import com.fasterxml.jackson.core.JsonEncoding;
|
||||||
import com.fasterxml.jackson.core.JsonFactory;
|
import com.fasterxml.jackson.core.JsonFactory;
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
import org.openide.util.Exceptions;
|
import org.openide.util.Exceptions;
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
@ -110,13 +108,16 @@ class ReportCaseUco implements GeneralReportModule {
|
|||||||
|
|
||||||
// Run query to get all files
|
// Run query to get all files
|
||||||
try {
|
try {
|
||||||
|
masterCatalog = jsonGeneratorFactory.createGenerator(reportFile, JsonEncoding.UTF8);
|
||||||
|
|
||||||
// exclude non-fs files/dirs and . and .. files
|
// exclude non-fs files/dirs and . and .. files
|
||||||
final String query = "type = " + TskData.TSK_DB_FILES_TYPE_ENUM.FS.getFileType() //NON-NLS
|
final String query = "select obj_id, name, size, ctime, crtime, atime, mtime, md5, parent_path, mime_type, extension from tsk_files where type = " + TskData.TSK_DB_FILES_TYPE_ENUM.FS.getFileType() //NON-NLS
|
||||||
+ " AND name != '.' AND name != '..'"; //NON-NLS
|
+ " AND name != '.' AND name != '..'"; //NON-NLS
|
||||||
|
|
||||||
progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportCaseUco.progress.loading"));
|
progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportCaseUco.progress.loading"));
|
||||||
List<AbstractFile> fs = skCase.findAllFilesWhere(query);
|
|
||||||
|
|
||||||
|
SleuthkitCase.CaseDbQuery queryResult = skCase.executeQuery(query);
|
||||||
|
ResultSet resultSet = queryResult.getResultSet();
|
||||||
// Check if ingest has finished
|
// Check if ingest has finished
|
||||||
String ingestwarning = "";
|
String ingestwarning = "";
|
||||||
if (IngestManager.getInstance().isIngestRunning()) {
|
if (IngestManager.getInstance().isIngestRunning()) {
|
||||||
@ -124,24 +125,38 @@ class ReportCaseUco implements GeneralReportModule {
|
|||||||
}
|
}
|
||||||
// ELTODO what to do with this warning?
|
// ELTODO what to do with this warning?
|
||||||
|
|
||||||
int size = fs.size();
|
int numFiles = 1000; // ELTODO resultSet.size();
|
||||||
progressPanel.setMaximumProgress(size / 100);
|
progressPanel.setMaximumProgress(numFiles / 100);
|
||||||
|
|
||||||
masterCatalog = jsonGeneratorFactory.createGenerator(reportFile, JsonEncoding.UTF8);
|
|
||||||
|
|
||||||
// Loop files and write info to report
|
// Loop files and write info to report
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (AbstractFile file : fs) {
|
while (resultSet.next()) {
|
||||||
|
|
||||||
if (progressPanel.getStatus() == ReportStatus.CANCELED) {
|
if (progressPanel.getStatus() == ReportStatus.CANCELED) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (count++ == 100) {
|
|
||||||
|
Long objectId = resultSet.getLong(1);
|
||||||
|
String dataSourceName = resultSet.getString(2);
|
||||||
|
long size = resultSet.getLong("size");
|
||||||
|
long ctime = resultSet.getLong("ctime");
|
||||||
|
long crtime = resultSet.getLong("crtime");
|
||||||
|
long atime = resultSet.getLong("atime");
|
||||||
|
long mtime = resultSet.getLong("mtime");
|
||||||
|
String md5Hash = resultSet.getString("md5");
|
||||||
|
String parent_path = resultSet.getString("parent_path");
|
||||||
|
String mime_type = resultSet.getString("mime_type");
|
||||||
|
String extension = resultSet.getString("extension");
|
||||||
|
|
||||||
|
addFile(objectId, dataSourceName, parent_path, md5Hash, mime_type, masterCatalog);
|
||||||
|
|
||||||
|
/* ELTODO if (count++ == 100) {
|
||||||
progressPanel.increment();
|
progressPanel.increment();
|
||||||
progressPanel.updateStatusLabel(
|
progressPanel.updateStatusLabel(
|
||||||
NbBundle.getMessage(this.getClass(), "ReportCaseUco.progress.processing",
|
NbBundle.getMessage(this.getClass(), "ReportCaseUco.progress.processing",
|
||||||
file.getName()));
|
file.getName()));
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
progressPanel.complete(ReportStatus.COMPLETE);
|
progressPanel.complete(ReportStatus.COMPLETE);
|
||||||
@ -149,6 +164,8 @@ class ReportCaseUco implements GeneralReportModule {
|
|||||||
logger.log(Level.SEVERE, "Failed to get the unique path.", ex); //NON-NLS
|
logger.log(Level.SEVERE, "Failed to get the unique path.", ex); //NON-NLS
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
logger.log(Level.SEVERE, "Failed to create JSON output for the CASE/UCO report", ex); //NON-NLS
|
logger.log(Level.SEVERE, "Failed to create JSON output for the CASE/UCO report", ex); //NON-NLS
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
logger.log(Level.WARNING, "Unable to read result set", ex); //NON-NLS
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
masterCatalog.close();
|
masterCatalog.close();
|
||||||
@ -158,9 +175,26 @@ class ReportCaseUco implements GeneralReportModule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addFile(Long objectId, String dataSourceName, String parent_path, String md5Hash, String mime_type, JsonGenerator catalog) throws IOException {
|
||||||
|
catalog.writeStartObject();
|
||||||
|
catalog.writeStringField("@id", "file-"+objectId);
|
||||||
|
catalog.writeStringField("@type", "Trace");
|
||||||
|
catalog.writeFieldName("propertyBundle");
|
||||||
|
catalog.writeStartArray();
|
||||||
|
catalog.writeStartObject();
|
||||||
|
catalog.writeStringField("@type", "File");
|
||||||
|
catalog.writeStringField("fileName", dataSourceName);
|
||||||
|
catalog.writeStringField("filePath", parent_path);
|
||||||
|
|
||||||
|
catalog.writeEndObject();
|
||||||
|
catalog.writeEndArray();
|
||||||
|
catalog.writeEndObject();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
String name = NbBundle.getMessage(this.getClass(), "ReportCaseUco.getName.text");
|
//String name = NbBundle.getMessage(this.getClass(), "ReportCaseUco.getName.text");
|
||||||
|
String name = "CASE/UCO";
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +205,8 @@ class ReportCaseUco implements GeneralReportModule {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
String desc = NbBundle.getMessage(this.getClass(), "ReportCaseUco.getDesc.text");
|
//String desc = NbBundle.getMessage(this.getClass(), "ReportCaseUco.getDesc.text");
|
||||||
|
String desc = "CASE/UCO Report";
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user