23package org.sleuthkit.autopsy.report.modules.bodyfile;
25import org.sleuthkit.autopsy.report.GeneralReportModule;
26import java.io.BufferedWriter;
27import java.io.FileWriter;
28import java.io.IOException;
30import java.util.logging.Level;
31import java.util.stream.Collectors;
32import javax.swing.JPanel;
34import org.openide.util.NbBundle;
35import org.sleuthkit.autopsy.casemodule.Case;
36import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
37import org.sleuthkit.autopsy.coreutils.Logger;
38import org.sleuthkit.autopsy.ingest.IngestManager;
39import org.sleuthkit.autopsy.report.GeneralReportSettings;
40import org.sleuthkit.autopsy.report.ReportProgressPanel;
41import org.sleuthkit.autopsy.report.ReportProgressPanel.ReportStatus;
42import org.sleuthkit.datamodel.*;
52 private static BodyFileReport instance =
null;
54 private Case currentCase;
55 private SleuthkitCase skCase;
57 private String reportPath;
60 private BodyFileReport() {
64 public static synchronized BodyFileReport getDefault() {
65 if (instance ==
null) {
66 instance =
new BodyFileReport();
88 logger.log(Level.SEVERE,
"Exception while getting open case.", ex);
92 progressPanel.
start();
93 progressPanel.
updateStatusLabel(NbBundle.getMessage(
this.getClass(),
"ReportBodyFile.progress.querying"));
101 final String query =
"type = " + TskData.TSK_DB_FILES_TYPE_ENUM.FS.getFileType()
102 +
" AND name != '.' AND name != '..'";
104 progressPanel.
updateStatusLabel(NbBundle.getMessage(
this.getClass(),
"ReportBodyFile.progress.loading"));
107 List<AbstractFile> fs = skCase.findAllFilesWhere(query).stream()
115 .collect(Collectors.toList());
118 String ingestwarning =
"";
120 ingestwarning = NbBundle.getMessage(this.getClass(),
"ReportBodyFile.ingestWarning.text");
123 int size = fs.size();
126 BufferedWriter out =
null;
129 out =
new BufferedWriter(
new FileWriter(reportPath,
true));
130 out.write(ingestwarning);
133 for (AbstractFile
file : fs) {
137 if (count++ == 100) {
140 NbBundle.getMessage(
this.getClass(),
"ReportBodyFile.progress.processing",
145 if (
file.getMd5Hash() !=
null) {
146 out.write(
file.getMd5Hash());
149 if (
file.getUniquePath() !=
null) {
150 out.write(
file.getUniquePath());
153 out.write(Long.toString(
file.getMetaAddr()));
155 String modeString =
file.getModesAsString();
156 if (modeString !=
null) {
157 out.write(modeString);
160 out.write(Long.toString(
file.getUid()));
162 out.write(Long.toString(
file.getGid()));
164 out.write(Long.toString(
file.getSize()));
166 out.write(Long.toString(
file.getAtime()));
168 out.write(Long.toString(
file.getMtime()));
170 out.write(Long.toString(
file.getCtime()));
172 out.write(Long.toString(
file.getCrtime()));
175 }
catch (IOException ex) {
176 logger.log(Level.WARNING,
"Could not write the temp body file report.", ex);
183 NbBundle.getMessage(
this.getClass(),
184 "ReportBodyFile.generateReport.srcModuleName.text"),
"");
187 }
catch (IOException ex) {
188 logger.log(Level.WARNING,
"Could not flush and close the BufferedWriter.", ex);
190 String errorMessage = String.format(
"Error adding %s to case as a report", reportPath);
191 logger.log(Level.SEVERE, errorMessage, ex);
195 }
catch (TskCoreException ex) {
196 logger.log(Level.WARNING,
"Failed to get the unique path.", ex);
202 String name = NbBundle.getMessage(this.getClass(),
"ReportBodyFile.getName.text");
208 return NbBundle.getMessage(this.getClass(),
"ReportBodyFile.getFilePath.text");
213 String desc = NbBundle.getMessage(this.getClass(),
"ReportBodyFile.getDesc.text");
SleuthkitCase getSleuthkitCase()
static Case getCurrentCaseThrows()
void addReport(String localPath, String srcModuleName, String reportName)
synchronized static Logger getLogger(String name)
static synchronized IngestManager getInstance()
boolean isIngestRunning()
String getReportDirectoryPath()
List< Long > getSelectedDataSources()
void updateStatusLabel(String statusMessage)
void complete(ReportStatus reportStatus)
void setIndeterminate(boolean indeterminate)
void setMaximumProgress(int max)
default boolean supportsDataSourceSelection()
default JPanel getConfigurationPanel()
String getRelativeFilePath()