23 package org.sleuthkit.autopsy.recentactivity;
25 import java.util.ArrayList;
26 import java.util.List;
27 import java.util.logging.Level;
29 import org.openide.util.NbBundle;
31 import java.util.Collection;
32 import org.openide.util.NbBundle.Messages;
39 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
41 import org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
49 class RecentDocumentsByLnk
extends Extract {
51 private static final Logger logger = Logger.getLogger(RecentDocumentsByLnk.class.getName());
52 private Content dataSource;
53 private IngestJobContext context;
56 "Progress_Message_Extract_Resent_Docs=Recent Documents",
66 private void getRecentDocuments() {
69 List<AbstractFile> recentFiles;
71 recentFiles = fileManager.
findFiles(dataSource,
"%.lnk",
"Recent");
72 }
catch (TskCoreException ex) {
73 logger.log(Level.WARNING,
"Error searching for .lnk files.");
75 NbBundle.getMessage(
this.getClass(),
"RecentDocumentsByLnk.getRecDoc.errMsg.errGetLnkFiles",
80 if (recentFiles.isEmpty()) {
81 logger.log(Level.INFO,
"Didn't find any recent files.");
86 List<BlackboardArtifact> bbartifacts =
new ArrayList<>();
87 for (AbstractFile recentFile : recentFiles) {
88 if (context.dataSourceIngestIsCancelled()) {
92 if (recentFile.getSize() == 0) {
96 JLnkParser lnkParser =
new JLnkParser(
new ReadContentInputStream(recentFile), (
int) recentFile.getSize());
98 lnk = lnkParser.parse();
99 }
catch (JLnkParserException e) {
101 boolean unalloc = recentFile.isMetaFlagSet(TskData.TSK_FS_META_FLAG_ENUM.UNALLOC)
102 || recentFile.isDirNameFlagSet(TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC);
103 if (unalloc ==
false) {
104 logger.log(Level.WARNING,
"Error lnk parsing the file to get recent files {0}", recentFile);
109 Collection<BlackboardAttribute> bbattributes =
new ArrayList<>();
110 String path = lnk.getBestPath();
111 bbattributes.add(
new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PATH,
112 NbBundle.getMessage(
this.getClass(),
113 "RecentDocumentsByLnk.parentModuleName.noSpace"),
115 bbattributes.add(
new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PATH_ID,
116 NbBundle.getMessage(
this.getClass(),
117 "RecentDocumentsByLnk.parentModuleName.noSpace"),
118 Util.findID(dataSource, path)));
119 bbattributes.add(
new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DATETIME,
120 NbBundle.getMessage(
this.getClass(),
121 "RecentDocumentsByLnk.parentModuleName.noSpace"),
122 recentFile.getCrtime()));
123 BlackboardArtifact bba = createArtifactWithAttributes(ARTIFACT_TYPE.TSK_RECENT_OBJECT, recentFile, bbattributes);
125 bbartifacts.add(bba);
129 postArtifacts(bbartifacts);
133 public void process(Content dataSource, IngestJobContext context, DataSourceIngestModuleProgress progressBar) {
134 this.dataSource = dataSource;
135 this.context = context;
138 progressBar.progress(Bundle.Progress_Message_Extract_Resent_Docs());
139 this.getRecentDocuments();
synchronized List< AbstractFile > findFiles(String fileName)