Autopsy  4.13.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
RecentDocumentsByLnk.java
Go to the documentation of this file.
1  /*
2  *
3  * Autopsy Forensic Browser
4  *
5  * Copyright 2012-2014 Basis Technology Corp.
6  *
7  * Copyright 2012 42six Solutions.
8  * Contact: aebadirad <at> 42six <dot> com
9  * Project Contact/Architect: carrier <at> sleuthkit <dot> org
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23 package org.sleuthkit.autopsy.recentactivity;
24 
25 import java.util.ArrayList;
26 import java.util.List;
27 import java.util.logging.Level;
28 
29 import org.openide.util.NbBundle;
31 import java.util.Collection;
32 import org.openide.util.NbBundle.Messages;
38 import org.sleuthkit.datamodel.BlackboardArtifact;
39 import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
40 import org.sleuthkit.datamodel.BlackboardAttribute;
41 import org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
42 import org.sleuthkit.datamodel.Content;
43 import org.sleuthkit.datamodel.*;
44 
49 class RecentDocumentsByLnk extends Extract {
50 
51  private static final Logger logger = Logger.getLogger(RecentDocumentsByLnk.class.getName());
52  private Content dataSource;
53  private IngestJobContext context;
54 
55  @Messages({
56  "Progress_Message_Extract_Resent_Docs=Recent Documents",
57  })
58 
66  private void getRecentDocuments() {
67 
68  org.sleuthkit.autopsy.casemodule.services.FileManager fileManager = currentCase.getServices().getFileManager();
69  List<AbstractFile> recentFiles;
70  try {
71  recentFiles = fileManager.findFiles(dataSource, "%.lnk", "Recent"); //NON-NLS
72  } catch (TskCoreException ex) {
73  logger.log(Level.WARNING, "Error searching for .lnk files."); //NON-NLS
74  this.addErrorMessage(
75  NbBundle.getMessage(this.getClass(), "RecentDocumentsByLnk.getRecDoc.errMsg.errGetLnkFiles",
76  this.getName()));
77  return;
78  }
79 
80  if (recentFiles.isEmpty()) {
81  logger.log(Level.INFO, "Didn't find any recent files."); //NON-NLS
82  return;
83  }
84 
85  dataFound = true;
86  List<BlackboardArtifact> bbartifacts = new ArrayList<>();
87  for (AbstractFile recentFile : recentFiles) {
88  if (context.dataSourceIngestIsCancelled()) {
89  break;
90  }
91 
92  if (recentFile.getSize() == 0) {
93  continue;
94  }
95  JLNK lnk;
96  JLnkParser lnkParser = new JLnkParser(new ReadContentInputStream(recentFile), (int) recentFile.getSize());
97  try {
98  lnk = lnkParser.parse();
99  } catch (JLnkParserException e) {
100  //TODO should throw a specific checked exception
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); //NON-NLS
105  }
106  continue;
107  }
108 
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"),
114  path));
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);
124  if(bba != null) {
125  bbartifacts.add(bba);
126  }
127  }
128 
129  postArtifacts(bbartifacts);
130  }
131 
132  @Override
133  public void process(Content dataSource, IngestJobContext context, DataSourceIngestModuleProgress progressBar) {
134  this.dataSource = dataSource;
135  this.context = context;
136  dataFound = false;
137 
138  progressBar.progress(Bundle.Progress_Message_Extract_Resent_Docs());
139  this.getRecentDocuments();
140  }
141 }
synchronized List< AbstractFile > findFiles(String fileName)

Copyright © 2012-2019 Basis Technology. Generated on: Tue Jan 7 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.