Autopsy  4.19.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
ExtractRegistry.java
Go to the documentation of this file.
1 /*
2  *
3  * Autopsy Forensic Browser
4  *
5  * Copyright 2012-2021 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.io.BufferedReader;
26 import java.io.File;
27 import java.io.FileInputStream;
28 import java.io.FileNotFoundException;
29 import java.io.FileReader;
30 import java.io.FileWriter;
31 import java.io.IOException;
32 import java.io.InputStreamReader;
33 import java.io.StringReader;
34 import java.nio.charset.StandardCharsets;
35 import java.text.ParseException;
36 import java.text.SimpleDateFormat;
37 import java.util.logging.Level;
38 import javax.xml.parsers.DocumentBuilder;
39 import javax.xml.parsers.DocumentBuilderFactory;
40 import javax.xml.parsers.ParserConfigurationException;
41 import org.apache.commons.io.FilenameUtils;
42 import org.openide.modules.InstalledFileLocator;
43 import org.openide.util.NbBundle;
51 import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
52 import org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
53 import org.w3c.dom.Document;
54 import org.w3c.dom.Element;
55 import org.w3c.dom.Node;
56 import org.w3c.dom.NodeList;
57 import org.xml.sax.InputSource;
58 import org.xml.sax.SAXException;
59 import java.nio.file.Path;
60 import java.util.AbstractMap;
61 import java.util.ArrayList;
62 import java.util.List;
63 import java.util.Collection;
64 import java.util.Collections;
65 import java.util.Date;
66 import java.util.HashMap;
67 import java.util.Map;
68 import java.util.Scanner;
69 import java.util.Set;
70 import java.util.HashSet;
71 import static java.util.Locale.US;
72 import java.util.Optional;
73 import static java.util.TimeZone.getTimeZone;
74 import java.util.stream.Collectors;
75 import org.openide.util.Lookup;
80 import org.sleuthkit.datamodel.AbstractFile;
81 import org.sleuthkit.datamodel.Account;
82 import org.sleuthkit.datamodel.Blackboard.BlackboardException;
83 import org.sleuthkit.datamodel.BlackboardArtifact;
84 import org.sleuthkit.datamodel.BlackboardAttribute;
85 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_COMMENT;
86 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME;
87 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_ACCESSED;
88 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED;
89 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_MODIFIED;
90 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DEVICE_ID;
91 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME;
92 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH;
93 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_HOME_DIR;
94 import org.sleuthkit.datamodel.Content;
95 import org.sleuthkit.datamodel.DataArtifact;
96 import org.sleuthkit.datamodel.DataSource;
97 import org.sleuthkit.datamodel.Host;
98 import org.sleuthkit.datamodel.HostManager;
99 import org.sleuthkit.datamodel.OsAccount;
100 import org.sleuthkit.datamodel.OsAccount.OsAccountAttribute;
101 import org.sleuthkit.datamodel.OsAccountInstance;
102 import org.sleuthkit.datamodel.OsAccountManager;
103 import org.sleuthkit.datamodel.OsAccountManager.NotUserSIDException;
104 import org.sleuthkit.datamodel.OsAccountManager.OsAccountUpdateResult;
105 import org.sleuthkit.datamodel.OsAccountRealm;
106 import org.sleuthkit.datamodel.ReadContentInputStream.ReadContentInputStreamException;
107 import org.sleuthkit.datamodel.Report;
108 import org.sleuthkit.datamodel.TskCoreException;
109 import org.sleuthkit.datamodel.TskDataException;
110 
117 @NbBundle.Messages({
118  "RegRipperNotFound=Autopsy RegRipper executable not found.",
119  "RegRipperFullNotFound=Full version RegRipper executable not found.",
120  "Progress_Message_Analyze_Registry=Analyzing Registry Files",
121  "Shellbag_Artifact_Display_Name=Shell Bags",
122  "Shellbag_Key_Attribute_Display_Name=Key",
123  "Shellbag_Last_Write_Attribute_Display_Name=Last Write",
124  "Recently_Used_Artifacts_Office_Trustrecords=Stored in TrustRecords because Office security exception was granted",
125  "Recently_Used_Artifacts_ArcHistory=Recently opened by 7Zip",
126  "Recently_Used_Artifacts_Applets=Recently opened according to Applets registry key",
127  "Recently_Used_Artifacts_Mmc=Recently opened according to Windows Management Console MRU",
128  "Recently_Used_Artifacts_Winrar=Recently opened according to WinRAR MRU",
129  "Recently_Used_Artifacts_Officedocs=Recently opened according to Office MRU",
130  "Recently_Used_Artifacts_Adobe=Recently opened according to Adobe MRU",
131  "Recently_Used_Artifacts_Mediaplayer=Recently opened according to Media Player MRU",
132  "Registry_System_Bam=Recently Executed according to Background Activity Moderator (BAM)"
133 })
134 class ExtractRegistry extends Extract {
135 
136  private static final String USERNAME_KEY = "Username"; //NON-NLS
137  private static final String SID_KEY = "SID"; //NON-NLS
138  private static final String RID_KEY = "RID"; //NON-NLS
139  private static final String ACCOUNT_CREATED_KEY = "Account Created"; //NON-NLS
140  private static final String LAST_LOGIN_KEY = "Last Login Date"; //NON-NLS
141  private static final String LOGIN_COUNT_KEY = "Login Count"; //NON-NLS
142  private static final String FULL_NAME_KEY = "Full Name"; //NON-NLS
143  private static final String USER_COMMENT_KEY = "User Comment"; //NON-NLS
144  private static final String ACCOUNT_TYPE_KEY = "Account Type"; //NON-NLS
145  private static final String NAME_KEY = "Name"; //NON-NLS
146  private static final String PWD_RESET_KEY = "Pwd Rest Date"; //NON-NLS
147  private static final String PWD_FAILE_KEY = "Pwd Fail Date"; //NON-NLS
148  private static final String INTERNET_NAME_KEY = "InternetName"; //NON-NLS
149  private static final String PWD_DOES_NOT_EXPIRE_KEY = "Password does not expire"; //NON-NLS
150  private static final String ACCOUNT_DISABLED_KEY = "Account Disabled"; //NON-NLS
151  private static final String PWD_NOT_REQUIRED_KEY = "Password not required"; //NON-NLS
152  private static final String NORMAL_ACCOUNT_KEY = "Normal user account"; //NON-NLS
153  private static final String HOME_DIRECTORY_REQUIRED_KEY = "Home directory required";
154  private static final String TEMPORARY_DUPLICATE_ACCOUNT = "Temporary duplicate account";
155  private static final String MNS_LOGON_ACCOUNT_KEY = "MNS logon user account";
156  private static final String INTERDOMAIN_TRUST_ACCOUNT_KEY = "Interdomain trust account";
157  private static final String WORKSTATION_TRUST_ACCOUNT = "Workstation trust account";
158  private static final String SERVER_TRUST_ACCOUNT = "Server trust account";
159  private static final String ACCOUNT_AUTO_LOCKED = "Account auto locked";
160  private static final String PASSWORD_HINT = "Password Hint";
161 
162  private static final String[] PASSWORD_SETTINGS_FLAGS = {PWD_DOES_NOT_EXPIRE_KEY, PWD_NOT_REQUIRED_KEY};
163  private static final String[] ACCOUNT_SETTINGS_FLAGS = {ACCOUNT_AUTO_LOCKED, HOME_DIRECTORY_REQUIRED_KEY, ACCOUNT_DISABLED_KEY};
164  private static final String[] ACCOUNT_TYPE_FLAGS = {NORMAL_ACCOUNT_KEY, SERVER_TRUST_ACCOUNT, WORKSTATION_TRUST_ACCOUNT, INTERDOMAIN_TRUST_ACCOUNT_KEY, MNS_LOGON_ACCOUNT_KEY, TEMPORARY_DUPLICATE_ACCOUNT};
165 
166  final private static UsbDeviceIdMapper USB_MAPPER = new UsbDeviceIdMapper();
167  final private static String RIP_EXE = "rip.exe";
168  final private static String RIP_PL = "rip.pl";
169  final private static String RIP_PL_INCLUDE_FLAG = "-I";
170  final private static int MS_IN_SEC = 1000;
171  final private static String NEVER_DATE = "Never";
172  final private static String SECTION_DIVIDER = "-------------------------";
173  final private static Logger logger = Logger.getLogger(ExtractRegistry.class.getName());
174  private final List<String> rrCmd = new ArrayList<>();
175  private final List<String> rrFullCmd = new ArrayList<>();
176  private final Path rrHome; // Path to the Autopsy version of RegRipper
177  private final Path rrFullHome; // Path to the full version of RegRipper
178  private Content dataSource;
179  private IngestJobContext context;
180  private Map<String, String> userNameMap;
181 
182  private String compName = "";
183  private String domainName = "";
184 
185  private static final String SHELLBAG_ARTIFACT_NAME = "RA_SHELL_BAG"; //NON-NLS
186  private static final String SHELLBAG_ATTRIBUTE_LAST_WRITE = "RA_SHELL_BAG_LAST_WRITE"; //NON-NLS
187  private static final String SHELLBAG_ATTRIBUTE_KEY = "RA_SHELL_BAG_KEY"; //NON-NLS
188 
189  private static final SimpleDateFormat REG_RIPPER_TIME_FORMAT = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy 'Z'", US);
190 
191  private BlackboardArtifact.Type shellBagArtifactType = null;
192  private BlackboardAttribute.Type shellBagKeyAttributeType = null;
193  private BlackboardAttribute.Type shellBagLastWriteAttributeType = null;
194 
195  static {
196  REG_RIPPER_TIME_FORMAT.setTimeZone(getTimeZone("GMT"));
197  }
198 
199  ExtractRegistry() throws IngestModuleException {
200  super(NbBundle.getMessage(ExtractIE.class, "ExtractRegistry.moduleName.text"));
201 
202  final File rrRoot = InstalledFileLocator.getDefault().locate("rr", ExtractRegistry.class.getPackage().getName(), false); //NON-NLS
203  if (rrRoot == null) {
204  throw new IngestModuleException(Bundle.RegRipperNotFound());
205  }
206 
207  final File rrFullRoot = InstalledFileLocator.getDefault().locate("rr-full", ExtractRegistry.class.getPackage().getName(), false); //NON-NLS
208  if (rrFullRoot == null) {
209  throw new IngestModuleException(Bundle.RegRipperFullNotFound());
210  }
211 
212  String executableToRun = RIP_EXE;
213  if (!PlatformUtil.isWindowsOS()) {
214  executableToRun = RIP_PL;
215  }
216  rrHome = rrRoot.toPath();
217  String rrPath = rrHome.resolve(executableToRun).toString();
218  rrFullHome = rrFullRoot.toPath();
219 
220  if (!(new File(rrPath).exists())) {
221  throw new IngestModuleException(Bundle.RegRipperNotFound());
222  }
223  String rrFullPath = rrFullHome.resolve(executableToRun).toString();
224  if (!(new File(rrFullPath).exists())) {
225  throw new IngestModuleException(Bundle.RegRipperFullNotFound());
226  }
227  if (PlatformUtil.isWindowsOS()) {
228  rrCmd.add(rrPath);
229  rrFullCmd.add(rrFullPath);
230  } else {
231  String perl;
232  File usrBin = new File("/usr/bin/perl");
233  File usrLocalBin = new File("/usr/local/bin/perl");
234  if (usrBin.canExecute() && usrBin.exists() && !usrBin.isDirectory()) {
235  perl = "/usr/bin/perl";
236  } else if (usrLocalBin.canExecute() && usrLocalBin.exists() && !usrLocalBin.isDirectory()) {
237  perl = "/usr/local/bin/perl";
238  } else {
239  throw new IngestModuleException("perl not found in your system");
240  }
241  rrCmd.add(perl);
242  rrCmd.add(RIP_PL_INCLUDE_FLAG);
243  rrCmd.add(rrHome.toString());
244  rrCmd.add(rrPath);
245  rrFullCmd.add(perl);
246  rrFullCmd.add(RIP_PL_INCLUDE_FLAG);
247  rrFullCmd.add(rrFullHome.toString());
248  rrFullCmd.add(rrFullPath);
249  }
250  }
251 
255  private List<AbstractFile> findRegistryFiles() {
256  List<AbstractFile> allRegistryFiles = new ArrayList<>();
257  org.sleuthkit.autopsy.casemodule.services.FileManager fileManager = currentCase.getServices().getFileManager();
258 
259  // find the sam hives', process this first so we can map the user id's and sids for later use
260  try {
261  allRegistryFiles.addAll(fileManager.findFiles(dataSource, "sam", "/system32/config")); //NON-NLS
262  } catch (TskCoreException ex) {
263  String msg = NbBundle.getMessage(this.getClass(),
264  "ExtractRegistry.findRegFiles.errMsg.errReadingFile", "sam");
265  logger.log(Level.WARNING, msg, ex);
266  this.addErrorMessage(this.getName() + ": " + msg);
267  }
268 
269  // find the user-specific ntuser-dat files
270  try {
271  allRegistryFiles.addAll(fileManager.findFiles(dataSource, "ntuser.dat")); //NON-NLS
272  } catch (TskCoreException ex) {
273  logger.log(Level.WARNING, "Error fetching 'ntuser.dat' file."); //NON-NLS
274  }
275 
276  // find the user-specific ntuser-dat files
277  try {
278  allRegistryFiles.addAll(fileManager.findFiles(dataSource, "usrclass.dat")); //NON-NLS
279  } catch (TskCoreException ex) {
280  logger.log(Level.WARNING, String.format("Error finding 'usrclass.dat' files."), ex); //NON-NLS
281  }
282 
283  // find the system hives'
284  String[] regFileNames = new String[]{"system", "software", "security"}; //NON-NLS
285  for (String regFileName : regFileNames) {
286  try {
287  allRegistryFiles.addAll(fileManager.findFiles(dataSource, regFileName, "/system32/config")); //NON-NLS
288  } catch (TskCoreException ex) {
289  String msg = NbBundle.getMessage(this.getClass(),
290  "ExtractRegistry.findRegFiles.errMsg.errReadingFile", regFileName);
291  logger.log(Level.WARNING, msg, ex);
292  this.addErrorMessage(this.getName() + ": " + msg);
293  }
294  }
295  return allRegistryFiles;
296  }
297 
303  private void analyzeRegistryFiles(long ingestJobId) {
304  List<AbstractFile> allRegistryFiles = findRegistryFiles();
305 
306  // open the log file
307  FileWriter logFile = null;
308  try {
309  logFile = new FileWriter(RAImageIngestModule.getRAOutputPath(currentCase, "reg", ingestJobId) + File.separator + "regripper-info.txt"); //NON-NLS
310  } catch (IOException ex) {
311  logger.log(Level.SEVERE, null, ex);
312  }
313 
314  for (AbstractFile regFile : allRegistryFiles) {
315  if (context.dataSourceIngestIsCancelled()) {
316  return;
317  }
318 
319  String regFileName = regFile.getName();
320  long regFileId = regFile.getId();
321  String regFileNameLocal = RAImageIngestModule.getRATempPath(currentCase, "reg", ingestJobId) + File.separator + regFileName;
322  String outputPathBase = RAImageIngestModule.getRAOutputPath(currentCase, "reg", ingestJobId) + File.separator + regFileName + "-regripper-" + Long.toString(regFileId); //NON-NLS
323  File regFileNameLocalFile = new File(regFileNameLocal);
324  try {
325  ContentUtils.writeToFile(regFile, regFileNameLocalFile, context::dataSourceIngestIsCancelled);
326  } catch (ReadContentInputStreamException ex) {
327  logger.log(Level.WARNING, String.format("Error reading registry file '%s' (id=%d).",
328  regFile.getName(), regFileId), ex); //NON-NLS
329  this.addErrorMessage(
330  NbBundle.getMessage(this.getClass(), "ExtractRegistry.analyzeRegFiles.errMsg.errWritingTemp",
331  this.getName(), regFileName));
332  continue;
333  } catch (IOException ex) {
334  logger.log(Level.SEVERE, String.format("Error writing temp registry file '%s' for registry file '%s' (id=%d).",
335  regFileNameLocal, regFile.getName(), regFileId), ex); //NON-NLS
336  this.addErrorMessage(
337  NbBundle.getMessage(this.getClass(), "ExtractRegistry.analyzeRegFiles.errMsg.errWritingTemp",
338  this.getName(), regFileName));
339  continue;
340  }
341 
342  if (context.dataSourceIngestIsCancelled()) {
343  break;
344  }
345 
346  try {
347  if (logFile != null) {
348  logFile.write(Long.toString(regFileId) + "\t" + regFile.getUniquePath() + "\n");
349  }
350  } catch (TskCoreException | IOException ex) {
351  logger.log(Level.SEVERE, null, ex);
352  }
353 
354  logger.log(Level.INFO, "{0}- Now getting registry information from {1}", new Object[]{getName(), regFileNameLocal}); //NON-NLS
355  RegOutputFiles regOutputFiles = ripRegistryFile(regFileNameLocal, outputPathBase);
356  if (context.dataSourceIngestIsCancelled()) {
357  break;
358  }
359 
360  // parse the autopsy-specific output
361  if (regOutputFiles.autopsyPlugins.isEmpty() == false && parseAutopsyPluginOutput(regOutputFiles.autopsyPlugins, regFile) == false) {
362  this.addErrorMessage(
363  NbBundle.getMessage(this.getClass(), "ExtractRegistry.analyzeRegFiles.failedParsingResults",
364  this.getName(), regFileName));
365  }
366 
367  if (context.dataSourceIngestIsCancelled()) {
368  return;
369  }
370 
371  // create a report for the full output
372  if (!regOutputFiles.fullPlugins.isEmpty()) {
373  //parse the full regripper output from SAM hive files
374  if (regFileNameLocal.toLowerCase().contains("sam") && parseSamPluginOutput(regOutputFiles.fullPlugins, regFile, ingestJobId) == false) {
375  this.addErrorMessage(
376  NbBundle.getMessage(this.getClass(), "ExtractRegistry.analyzeRegFiles.failedParsingResults",
377  this.getName(), regFileName));
378  } else if (regFileNameLocal.toLowerCase().contains("ntuser") || regFileNameLocal.toLowerCase().contains("usrclass")) {
379  try {
380  List<ShellBag> shellbags = ShellBagParser.parseShellbagOutput(regOutputFiles.fullPlugins);
381  createShellBagArtifacts(regFile, shellbags);
382  createRecentlyUsedArtifacts(regOutputFiles.fullPlugins, regFile);
383  } catch (IOException | TskCoreException ex) {
384  logger.log(Level.WARNING, String.format("Unable to get shell bags from file %s", regOutputFiles.fullPlugins), ex);
385  }
386  } else if (regFileNameLocal.toLowerCase().contains("system") && parseSystemPluginOutput(regOutputFiles.fullPlugins, regFile) == false) {
387  this.addErrorMessage(
388  NbBundle.getMessage(this.getClass(), "ExtractRegistry.analyzeRegFiles.failedParsingResults",
389  this.getName(), regFileName));
390  }
391 
392  if (context.dataSourceIngestIsCancelled()) {
393  return;
394  }
395 
396  try {
397  Report report = currentCase.addReport(regOutputFiles.fullPlugins,
398  NbBundle.getMessage(this.getClass(), "ExtractRegistry.parentModuleName.noSpace"),
399  "RegRipper " + regFile.getUniquePath(), regFile); //NON-NLS
400 
401  // Index the report content so that it will be available for keyword search.
402  KeywordSearchService searchService = Lookup.getDefault().lookup(KeywordSearchService.class);
403  if (null == searchService) {
404  logger.log(Level.WARNING, "Keyword search service not found. Report will not be indexed");
405  } else {
406  searchService.index(report);
407  report.close();
408  }
409  } catch (TskCoreException e) {
410  this.addErrorMessage("Error adding regripper output as Autopsy report: " + e.getLocalizedMessage()); //NON-NLS
411  }
412  }
413  // delete the hive
414  regFileNameLocalFile.delete();
415  }
416 
417  try {
418  if (logFile != null) {
419  logFile.close();
420  }
421  } catch (IOException ex) {
422  logger.log(Level.SEVERE, null, ex);
423  }
424  }
425 
433  private RegOutputFiles ripRegistryFile(String regFilePath, String outFilePathBase) {
434  String autopsyType = ""; // Type argument for rr for autopsy-specific modules
435  String fullType; // Type argument for rr for full set of modules
436 
437  RegOutputFiles regOutputFiles = new RegOutputFiles();
438 
439  if (regFilePath.toLowerCase().contains("system")) { //NON-NLS
440  autopsyType = "autopsysystem"; //NON-NLS
441  fullType = "system"; //NON-NLS
442  } else if (regFilePath.toLowerCase().contains("software")) { //NON-NLS
443  autopsyType = "autopsysoftware"; //NON-NLS
444  fullType = "software"; //NON-NLS
445  } else if (regFilePath.toLowerCase().contains("ntuser")) { //NON-NLS
446  autopsyType = "autopsyntuser"; //NON-NLS
447  fullType = "ntuser"; //NON-NLS
448  } else if (regFilePath.toLowerCase().contains("sam")) { //NON-NLS
449  //fullType sam output files are parsed for user information
450  fullType = "sam"; //NON-NLS
451  } else if (regFilePath.toLowerCase().contains("security")) { //NON-NLS
452  fullType = "security"; //NON-NLS
453  } else if (regFilePath.toLowerCase().contains("usrclass")) { //NON-NLS
454  fullType = "usrclass"; //NON-NLS
455  } else {
456  return regOutputFiles;
457  }
458 
459  // run the autopsy-specific set of modules
460  if (!autopsyType.isEmpty()) {
461  regOutputFiles.autopsyPlugins = outFilePathBase + "-autopsy.txt"; //NON-NLS
462  String errFilePath = outFilePathBase + "-autopsy.err.txt"; //NON-NLS
463  logger.log(Level.INFO, "Writing RegRipper results to: {0}", regOutputFiles.autopsyPlugins); //NON-NLS
464  executeRegRipper(rrCmd, rrHome, regFilePath, autopsyType, regOutputFiles.autopsyPlugins, errFilePath);
465  }
466  if (context.dataSourceIngestIsCancelled()) {
467  return regOutputFiles;
468  }
469 
470  // run the full set of rr modules
471  if (!fullType.isEmpty()) {
472  regOutputFiles.fullPlugins = outFilePathBase + "-full.txt"; //NON-NLS
473  String errFilePath = outFilePathBase + "-full.err.txt"; //NON-NLS
474  logger.log(Level.INFO, "Writing Full RegRipper results to: {0}", regOutputFiles.fullPlugins); //NON-NLS
475  executeRegRipper(rrFullCmd, rrFullHome, regFilePath, fullType, regOutputFiles.fullPlugins, errFilePath);
476  try {
477  scanErrorLogs(errFilePath);
478  } catch (IOException ex) {
479  logger.log(Level.SEVERE, String.format("Unable to run RegRipper on %s", regFilePath), ex); //NON-NLS
480  this.addErrorMessage(NbBundle.getMessage(this.getClass(), "ExtractRegistry.execRegRip.errMsg.failedAnalyzeRegFile", this.getName(), regFilePath));
481  }
482  }
483  return regOutputFiles;
484  }
485 
486  private void scanErrorLogs(String errFilePath) throws IOException {
487  File regfile = new File(errFilePath);
488  try (BufferedReader reader = new BufferedReader(new FileReader(regfile))) {
489  String line = reader.readLine();
490  while (line != null) {
491  line = line.trim();
492  if (line.toLowerCase().contains("error") || line.toLowerCase().contains("@inc")) {
493  logger.log(Level.WARNING, "Regripper file {0} contains errors from run", errFilePath); //NON-NLS
494 
495  }
496  line = reader.readLine();
497  }
498  }
499  }
500 
501  private void executeRegRipper(List<String> regRipperPath, Path regRipperHomeDir, String hiveFilePath, String hiveFileType, String outputFile, String errFile) {
502  try {
503  List<String> commandLine = new ArrayList<>();
504  for (String cmd : regRipperPath) {
505  commandLine.add(cmd);
506  }
507  commandLine.add("-r"); //NON-NLS
508  commandLine.add(hiveFilePath);
509  commandLine.add("-f"); //NON-NLS
510  commandLine.add(hiveFileType);
511 
512  ProcessBuilder processBuilder = new ProcessBuilder(commandLine);
513  processBuilder.directory(regRipperHomeDir.toFile()); // RegRipper 2.8 has to be run from its own directory
514  processBuilder.redirectOutput(new File(outputFile));
515  processBuilder.redirectError(new File(errFile));
516  ExecUtil.execute(processBuilder, new DataSourceIngestModuleProcessTerminator(context, true));
517  } catch (IOException ex) {
518  logger.log(Level.SEVERE, String.format("Error running RegRipper on %s", hiveFilePath), ex); //NON-NLS
519  this.addErrorMessage(NbBundle.getMessage(this.getClass(), "ExtractRegistry.execRegRip.errMsg.failedAnalyzeRegFile", this.getName(), hiveFilePath));
520  }
521  }
522 
523  // @@@ VERIFY that we are doing the right thing when we parse multiple NTUSER.DAT
532  private boolean parseAutopsyPluginOutput(String regFilePath, AbstractFile regFile) {
533  FileInputStream fstream = null;
534  List<BlackboardArtifact> newArtifacts = new ArrayList<>();
535  try {
536  // Read the file in and create a Document and elements
537  File regfile = new File(regFilePath);
538  fstream = new FileInputStream(regfile);
539  String regString = new Scanner(fstream, "UTF-8").useDelimiter("\\Z").next(); //NON-NLS
540  String startdoc = "<?xml version=\"1.0\"?><document>"; //NON-NLS
541  String result = regString.replaceAll("----------------------------------------", "");
542  result = result.replaceAll("\\n", ""); //NON-NLS
543  result = result.replaceAll("\\r", ""); //NON-NLS
544  result = result.replaceAll("'", "&apos;"); //NON-NLS
545  result = result.replaceAll("&", "&amp;"); //NON-NLS
546  result = result.replace('\0', ' '); // NON-NLS
547  String enddoc = "</document>"; //NON-NLS
548  String stringdoc = startdoc + result + enddoc;
549  DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
550  Document doc = builder.parse(new InputSource(new StringReader(stringdoc)));
551 
552  // cycle through the elements in the doc
553  Element oroot = doc.getDocumentElement();
554  NodeList children = oroot.getChildNodes();
555  int len = children.getLength();
556  for (int i = 0; i < len; i++) {
557 
558  if (context.dataSourceIngestIsCancelled()) {
559  return false;
560  }
561 
562  Element tempnode = (Element) children.item(i);
563 
564  String dataType = tempnode.getNodeName();
565  NodeList timenodes = tempnode.getElementsByTagName("mtime"); //NON-NLS
566  Long mtime = null;
567  if (timenodes.getLength() > 0) {
568  Element timenode = (Element) timenodes.item(0);
569  String etime = timenode.getTextContent();
570  //sometimes etime will be an empty string and therefore can not be parsed into a date
571  if (etime != null && !etime.isEmpty()) {
572  try {
573  mtime = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy", US).parse(etime).getTime();
574  String Tempdate = mtime.toString();
575  mtime = Long.valueOf(Tempdate) / MS_IN_SEC;
576  } catch (ParseException ex) {
577  logger.log(Level.WARNING, "Failed to parse epoch time when parsing the registry.", ex); //NON-NLS
578  }
579  }
580  }
581 
582  NodeList artroots = tempnode.getElementsByTagName("artifacts"); //NON-NLS
583  if (artroots.getLength() == 0) {
584  // If there isn't an artifact node, skip this entry
585  continue;
586  }
587 
588  Element artroot = (Element) artroots.item(0);
589  NodeList myartlist = artroot.getChildNodes();
590  String parentModuleName = RecentActivityExtracterModuleFactory.getModuleName();
591 
592  // If all artifact nodes should really go under one Blackboard artifact, need to process it differently
593  switch (dataType) {
594  case "WinVersion": //NON-NLS
595  String version = "";
596  String systemRoot = "";
597  String productId = "";
598  String regOwner = "";
599  String regOrg = "";
600  Long installtime = null;
601  for (int j = 0; j < myartlist.getLength(); j++) {
602  Node artchild = myartlist.item(j);
603  // If it has attributes, then it is an Element (based off API)
604  if (artchild.hasAttributes()) {
605  Element artnode = (Element) artchild;
606 
607  String value = artnode.getTextContent();
608  if (value != null) {
609  value = value.trim();
610  }
611  String name = artnode.getAttribute("name"); //NON-NLS
612  if (name == null) {
613  continue;
614  }
615  switch (name) {
616  case "ProductName": // NON-NLS
617  version = value;
618  break;
619  case "CSDVersion": // NON-NLS
620  // This is dependant on the fact that ProductName shows up first in the module output
621  version = version + " " + value;
622  break;
623  case "SystemRoot": //NON-NLS
624  systemRoot = value;
625  break;
626  case "ProductId": //NON-NLS
627  productId = value;
628  break;
629  case "RegisteredOwner": //NON-NLS
630  regOwner = value;
631  break;
632  case "RegisteredOrganization": //NON-NLS
633  regOrg = value;
634  break;
635  case "InstallDate": //NON-NLS
636  if (value != null && !value.isEmpty()) {
637  try {
638  installtime = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyyZ", US).parse(value+"+0000").getTime();
639  String Tempdate = installtime.toString();
640  installtime = Long.valueOf(Tempdate) / MS_IN_SEC;
641  } catch (ParseException e) {
642  logger.log(Level.WARNING, "RegRipper::Conversion on DateTime -> ", e); //NON-NLS
643  }
644  }
645  break;
646  default:
647  break;
648  }
649  }
650  }
651  try {
652  Collection<BlackboardAttribute> bbattributes = new ArrayList<>();
653  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PROG_NAME, parentModuleName, version));
654  if (installtime != null) {
655  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DATETIME, parentModuleName, installtime));
656  }
657  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PATH, parentModuleName, systemRoot));
658  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PRODUCT_ID, parentModuleName, productId));
659  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_OWNER, parentModuleName, regOwner));
660  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_ORGANIZATION, parentModuleName, regOrg));
661 
662  // Check if there is already an OS_INFO artifact for this file, and add to that if possible.
663  ArrayList<BlackboardArtifact> results = tskCase.getBlackboardArtifacts(ARTIFACT_TYPE.TSK_OS_INFO, regFile.getId());
664  if (results.isEmpty()) {
665  newArtifacts.add(createArtifactWithAttributes(ARTIFACT_TYPE.TSK_OS_INFO, regFile, bbattributes));
666  } else {
667  results.get(0).addAttributes(bbattributes);
668  }
669 
670  } catch (TskCoreException ex) {
671  logger.log(Level.SEVERE, String.format("Error adding installed program artifact to blackboard for file %d.", regFile.getId()), ex); //NON-NLS
672  }
673  break;
674  case "Profiler": // NON-NLS
675  String os = "";
676  String procArch = "";
677  String tempDir = "";
678  for (int j = 0; j < myartlist.getLength(); j++) {
679  Node artchild = myartlist.item(j);
680  // If it has attributes, then it is an Element (based off API)
681  if (artchild.hasAttributes()) {
682  Element artnode = (Element) artchild;
683 
684  String value = artnode.getTextContent().trim();
685  String name = artnode.getAttribute("name"); //NON-NLS
686  switch (name) {
687  case "OS": // NON-NLS
688  os = value;
689  break;
690  case "PROCESSOR_ARCHITECTURE": // NON-NLS
691  procArch = value;
692  break;
693  case "PROCESSOR_IDENTIFIER": //NON-NLS
694  break;
695  case "TEMP": //NON-NLS
696  tempDir = value;
697  break;
698  default:
699  break;
700  }
701  }
702  }
703  try {
704  Collection<BlackboardAttribute> bbattributes = new ArrayList<>();
705  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_VERSION, parentModuleName, os));
706  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PROCESSOR_ARCHITECTURE, parentModuleName, procArch));
707  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_TEMP_DIR, parentModuleName, tempDir));
708 
709  // Check if there is already an OS_INFO artifact for this file and add to that if possible
710  ArrayList<BlackboardArtifact> results = tskCase.getBlackboardArtifacts(ARTIFACT_TYPE.TSK_OS_INFO, regFile.getId());
711  if (results.isEmpty()) {
712  newArtifacts.add(createArtifactWithAttributes(ARTIFACT_TYPE.TSK_OS_INFO, regFile, bbattributes));
713  } else {
714  results.get(0).addAttributes(bbattributes);
715  }
716  } catch (TskCoreException ex) {
717  logger.log(Level.SEVERE, String.format("Error adding installed os_info to blackboard for file %d.", regFile.getId()), ex); //NON-NLS
718  }
719  break;
720  case "CompName": // NON-NLS
721  for (int j = 0; j < myartlist.getLength(); j++) {
722  Node artchild = myartlist.item(j);
723  // If it has attributes, then it is an Element (based off API)
724  if (artchild.hasAttributes()) {
725  Element artnode = (Element) artchild;
726 
727  String value = artnode.getTextContent().trim();
728  String name = artnode.getAttribute("name"); //NON-NLS
729 
730  if (name.equals("ComputerName")) { // NON-NLS
731  compName = value;
732  } else if (name.equals("Domain")) { // NON-NLS
733  domainName = value;
734  }
735  }
736  }
737  try {
738  Collection<BlackboardAttribute> bbattributes = new ArrayList<>();
739  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_NAME, parentModuleName, compName));
740  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DOMAIN, parentModuleName, domainName));
741 
742  // Check if there is already an OS_INFO artifact for this file and add to that if possible
743  ArrayList<BlackboardArtifact> results = tskCase.getBlackboardArtifacts(ARTIFACT_TYPE.TSK_OS_INFO, regFile.getId());
744  if (results.isEmpty()) {
745  newArtifacts.add(createArtifactWithAttributes(ARTIFACT_TYPE.TSK_OS_INFO, regFile, bbattributes));
746  } else {
747  results.get(0).addAttributes(bbattributes);
748  }
749  for (Map.Entry<String, String> userMap : getUserNameMap().entrySet()) {
750  String sid = "";
751  try{
752  sid = userMap.getKey();
753  String userName = userMap.getValue();
754  // Accounts in the SAM are all local accounts
755  createOrUpdateOsAccount(regFile, sid, userName, null, null, OsAccountRealm.RealmScope.LOCAL);
756  } catch(TskCoreException | TskDataException | NotUserSIDException ex) {
757  logger.log(Level.WARNING, String.format("Failed to update Domain for existing OsAccount: %s, sid: %s", regFile.getId(), sid), ex);
758  }
759  }
760  } catch (TskCoreException ex) {
761  logger.log(Level.SEVERE, String.format("Error adding os_info artifact to blackboard for file %d.", regFile.getId()), ex); //NON-NLS
762  }
763  break;
764  default:
765  for (int j = 0; j < myartlist.getLength(); j++) {
766  Node artchild = myartlist.item(j);
767  // If it has attributes, then it is an Element (based off API)
768  if (artchild.hasAttributes()) {
769  Element artnode = (Element) artchild;
770 
771  String value = artnode.getTextContent().trim();
772  Collection<BlackboardAttribute> bbattributes = new ArrayList<>();
773 
774  switch (dataType) {
775  case "recentdocs": //NON-NLS
776  // BlackboardArtifact bbart = tskCase.getContentById(orgId).newArtifact(ARTIFACT_TYPE.TSK_RECENT_OBJECT);
777  // bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_LAST_ACCESSED.getTypeID(), "RecentActivity", dataType, mtime));
778  // bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_NAME.getTypeID(), "RecentActivity", dataType, mtimeItem));
779  // bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_VALUE.getTypeID(), "RecentActivity", dataType, value));
780  // bbart.addAttributes(bbattributes);
781  // @@@ BC: Why are we ignoring this...
782  break;
783  case "usb": //NON-NLS
784  try {
785  Long usbMtime = Long.parseLong(artnode.getAttribute("mtime")); //NON-NLS
786  usbMtime = Long.valueOf(usbMtime.toString());
787  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DATETIME, parentModuleName, usbMtime));
788  String dev = artnode.getAttribute("dev"); //NON-NLS
789  String make = "";
790  String model = dev;
791  if (dev.toLowerCase().contains("vid")) { //NON-NLS
792  USBInfo info = USB_MAPPER.parseAndLookup(dev);
793  if (info.getVendor() != null) {
794  make = info.getVendor();
795  }
796  if (info.getProduct() != null) {
797  model = info.getProduct();
798  }
799  }
800  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DEVICE_MAKE, parentModuleName, make));
801  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DEVICE_MODEL, parentModuleName, model));
802  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DEVICE_ID, parentModuleName, value));
803  newArtifacts.add(createArtifactWithAttributes(ARTIFACT_TYPE.TSK_DEVICE_ATTACHED, regFile, bbattributes));
804  } catch (TskCoreException ex) {
805  logger.log(Level.SEVERE, String.format("Error adding device_attached artifact to blackboard for file %d.", regFile.getId()), ex); //NON-NLS
806  }
807  break;
808  case "uninstall": //NON-NLS
809  Long itemMtime = null;
810  try {
811  String mTimeAttr = artnode.getAttribute("mtime");
812  if (mTimeAttr != null && !mTimeAttr.isEmpty()) {
813  itemMtime = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy", US).parse(mTimeAttr).getTime(); //NON-NLS
814  itemMtime /= MS_IN_SEC;
815  }
816  } catch (ParseException ex) {
817  logger.log(Level.SEVERE, "Failed to parse epoch time for installed program artifact.", ex); //NON-NLS
818  }
819 
820  try {
821  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PROG_NAME, parentModuleName, value));
822  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DATETIME, parentModuleName, itemMtime));
823  BlackboardArtifact bbart = regFile.newDataArtifact(new BlackboardArtifact.Type(ARTIFACT_TYPE.TSK_INSTALLED_PROG), bbattributes);
824  newArtifacts.add(bbart);
825  } catch (TskCoreException ex) {
826  logger.log(Level.SEVERE, "Error adding installed program artifact to blackboard.", ex); //NON-NLS
827  }
828  break;
829  case "office": //NON-NLS
830  String officeName = artnode.getAttribute("name"); //NON-NLS
831 
832  try {
833  // @@@ BC: Consider removing this after some more testing. It looks like an Mtime associated with the root key and not the individual item
834  if (mtime != null) {
835  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DATETIME_ACCESSED, parentModuleName, mtime));
836  }
837  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_NAME, parentModuleName, officeName));
838  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_VALUE, parentModuleName, value));
839  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PROG_NAME, parentModuleName, artnode.getNodeName()));
840  BlackboardArtifact bbart = regFile.newDataArtifact(new BlackboardArtifact.Type(ARTIFACT_TYPE.TSK_RECENT_OBJECT), bbattributes);
841 
842  newArtifacts.add(bbart);
843  } catch (TskCoreException ex) {
844  logger.log(Level.SEVERE, "Error adding recent object artifact to blackboard.", ex); //NON-NLS
845  }
846  break;
847 
848  case "ProcessorArchitecture": //NON-NLS
849  // Architecture is now included under Profiler
850  //try {
851  // String processorArchitecture = value;
852  // if (processorArchitecture.equals("AMD64"))
853  // processorArchitecture = "x86-64";
854 
855  // BlackboardArtifact bbart = regFile.newArtifact(ARTIFACT_TYPE.TSK_OS_INFO);
856  // bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PROCESSOR_ARCHITECTURE.getTypeID(), parentModuleName, processorArchitecture));
857  // bbart.addAttributes(bbattributes);
858  //} catch (TskCoreException ex) {
859  // logger.log(Level.SEVERE, "Error adding os info artifact to blackboard."); //NON-NLS
860  //}
861  break;
862 
863  case "ProfileList": //NON-NLS
864  String homeDir = value;
865  String sid = artnode.getAttribute("sid"); //NON-NLS
866  String username = artnode.getAttribute("username"); //NON-NLS
867  String domName = domainName;
868 
869  // accounts in profileList can be either domain or local
870  // Assume domain unless the SID was seen before in the SAM (which is only local).
871  OsAccountRealm.RealmScope scope = OsAccountRealm.RealmScope.DOMAIN;
872  if(knownMachineSID(sid)) {
873  domName = null;
874  scope = OsAccountRealm.RealmScope.LOCAL;
875  }
876 
877  try{
878  createOrUpdateOsAccount(regFile, sid, username, homeDir, domName, scope);
879  } catch(TskCoreException | TskDataException | NotUserSIDException ex) {
880  logger.log(Level.SEVERE, String.format("Failed to create OsAccount for file: %s, sid: %s", regFile.getId(), sid), ex);
881  }
882  break;
883 
884  case "NtuserNetwork": // NON-NLS
885  try {
886  String localPath = artnode.getAttribute("localPath"); //NON-NLS
887  String remoteName = value;
888 
889  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_LOCAL_PATH,
890  parentModuleName, localPath));
891  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_REMOTE_PATH,
892  parentModuleName, remoteName));
893  BlackboardArtifact bbart = regFile.newDataArtifact(new BlackboardArtifact.Type(ARTIFACT_TYPE.TSK_REMOTE_DRIVE), bbattributes);
894  newArtifacts.add(bbart);
895  } catch (TskCoreException ex) {
896  logger.log(Level.SEVERE, "Error adding network artifact to blackboard.", ex); //NON-NLS
897  }
898  break;
899  case "SSID": // NON-NLS
900  String adapter = artnode.getAttribute("adapter"); //NON-NLS
901  try {
902  Long lastWriteTime = Long.parseLong(artnode.getAttribute("writeTime")); //NON-NLS
903  lastWriteTime = Long.valueOf(lastWriteTime.toString());
904  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_SSID, parentModuleName, value));
905  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DATETIME, parentModuleName, lastWriteTime));
906  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DEVICE_ID, parentModuleName, adapter));
907  BlackboardArtifact bbart = regFile.newDataArtifact(new BlackboardArtifact.Type(ARTIFACT_TYPE.TSK_WIFI_NETWORK), bbattributes);
908  newArtifacts.add(bbart);
909  } catch (TskCoreException ex) {
910  logger.log(Level.SEVERE, "Error adding SSID artifact to blackboard.", ex); //NON-NLS
911  }
912  break;
913  case "shellfolders": // NON-NLS
914  // The User Shell Folders subkey stores the paths to Windows Explorer folders for the current user of the computer
915  // (https://technet.microsoft.com/en-us/library/Cc962613.aspx).
916  // No useful information. Skip.
917  break;
918 
919  default:
920  logger.log(Level.SEVERE, "Unrecognized node name: {0}", dataType); //NON-NLS
921  break;
922  }
923  }
924  }
925  break;
926  }
927  } // for
928  return true;
929  } catch (FileNotFoundException ex) {
930  logger.log(Level.WARNING, String.format("Error finding the registry file: %s", regFilePath), ex); //NON-NLS
931  } catch (SAXException ex) {
932  logger.log(Level.WARNING, String.format("Error parsing the registry XML: %s", regFilePath), ex); //NON-NLS
933  } catch (IOException ex) {
934  logger.log(Level.WARNING, String.format("Error building the document parser: %s", regFilePath), ex); //NON-NLS
935  } catch (ParserConfigurationException ex) {
936  logger.log(Level.WARNING, String.format("Error configuring the registry parser: %s", regFilePath), ex); //NON-NLS
937  } finally {
938  try {
939  if (fstream != null) {
940  fstream.close();
941  }
942  } catch (IOException ex) {
943  }
944 
945  if (!context.dataSourceIngestIsCancelled()) {
946  postArtifacts(newArtifacts);
947  }
948  }
949  return false;
950  }
951 
952  private boolean parseSystemPluginOutput(String regfilePath, AbstractFile regAbstractFile) {
953  File regfile = new File(regfilePath);
954  try (BufferedReader reader = new BufferedReader(new FileReader(regfile))) {
955  String line = reader.readLine();
956  while (line != null) {
957  line = line.trim();
958 
959  if (line.toLowerCase().matches("^bam v.*")) {
960  parseBamKey(regAbstractFile, reader, Bundle.Registry_System_Bam());
961  } else if (line.toLowerCase().matches("^bthport v..*")) {
962  parseBlueToothDevices(regAbstractFile, reader);
963  }
964  line = reader.readLine();
965  }
966  return true;
967  } catch (FileNotFoundException ex) {
968  logger.log(Level.WARNING, "Error finding the registry file.", ex); //NON-NLS
969  } catch (IOException ex) {
970  logger.log(Level.WARNING, "Error reading the system hive: {0}", ex); //NON-NLS
971  }
972 
973  return false;
974 
975  }
976 
989  private void parseBlueToothDevices(AbstractFile regFile, BufferedReader reader) throws FileNotFoundException, IOException {
990  List<BlackboardArtifact> bbartifacts = new ArrayList<>();
991  String line = reader.readLine();
992  while ((line != null) && (!line.contains(SECTION_DIVIDER))) {
993  line = reader.readLine();
994 
995  if (line != null) {
996  line = line.trim();
997  }
998 
999  if ((line != null) && (line.toLowerCase().contains("device unique id"))) {
1000  // Columns are seperated by colons :
1001  // Data : Values
1002  // Record is 4 lines in length (Device Unique Id, Name, Last Seen, LastConnected
1003  while (line != null && !line.contains(SECTION_DIVIDER) && !line.isEmpty() && !line.toLowerCase().contains("radio support not found")) {
1004  Collection<BlackboardAttribute> attributes = new ArrayList<>();
1005  addBlueToothAttribute(line, attributes, TSK_DEVICE_ID);
1006  line = reader.readLine();
1007  // Name may not exist, check for it to make sure.
1008  if ((line != null) && (line.toLowerCase().contains("name"))) {
1009  addBlueToothAttribute(line, attributes, TSK_NAME);
1010  line = reader.readLine();
1011  }
1012  addBlueToothAttribute(line, attributes, TSK_DATETIME);
1013  line = reader.readLine();
1014  addBlueToothAttribute(line, attributes, TSK_DATETIME_ACCESSED);
1015 
1016  try {
1017  bbartifacts.add(createArtifactWithAttributes(ARTIFACT_TYPE.TSK_BLUETOOTH_PAIRING, regFile, attributes));
1018  } catch (TskCoreException ex) {
1019  logger.log(Level.SEVERE, String.format("Failed to create bluetooth_pairing artifact for file %d", regFile.getId()), ex);
1020  }
1021  // Read blank line between records then next read line is start of next block
1022  reader.readLine();
1023  line = reader.readLine();
1024  }
1025 
1026  if (line != null) {
1027  line = line.trim();
1028  }
1029  }
1030  }
1031 
1032  if (!bbartifacts.isEmpty() && !context.dataSourceIngestIsCancelled()) {
1033  postArtifacts(bbartifacts);
1034  }
1035  }
1036 
1037  private void addBlueToothAttribute(String line, Collection<BlackboardAttribute> attributes, ATTRIBUTE_TYPE attributeType) {
1038  if (line == null) {
1039  return;
1040  }
1041 
1042  String tokens[] = line.split(": ");
1043  if (tokens.length > 1 && !tokens[1].isEmpty()) {
1044  String tokenString = tokens[1];
1045  if (attributeType.getDisplayName().toLowerCase().contains("date")) {
1046  String dateString = tokenString.toLowerCase().replace(" z", "");
1047  // date format for plugin Tue Jun 23 10:27:54 2020 Z
1048  SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy", US);
1049  Long dateLong = Long.valueOf(0);
1050  try {
1051  Date newDate = dateFormat.parse(dateString);
1052  dateLong = newDate.getTime() / 1000;
1053  } catch (ParseException ex) {
1054  // catching error and displaying date that could not be parsed
1055  // we set the timestamp to 0 and continue on processing
1056  logger.log(Level.WARNING, String.format("Failed to parse date/time %s for Bluetooth Last Seen attribute.", dateString), ex); //NON-NLS
1057  }
1058  attributes.add(new BlackboardAttribute(attributeType, getName(), dateLong));
1059  } else {
1060  attributes.add(new BlackboardAttribute(attributeType, getName(), tokenString));
1061  }
1062  }
1063  }
1064 
1075  private boolean parseSamPluginOutput(String regFilePath, AbstractFile regAbstractFile, long ingestJobId) {
1076 
1077  File regfile = new File(regFilePath);
1078  List<BlackboardArtifact> newArtifacts = new ArrayList<>();
1079  try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(regfile), StandardCharsets.UTF_8))) {
1080  // Read the file in and create a Document and elements
1081  String userInfoSection = "User Information";
1082  String previousLine = null;
1083  String line = bufferedReader.readLine();
1084  Set<Map<String, String>> userSet = new HashSet<>();
1085  Map<String, List<String>> groupMap = null;
1086  while (line != null) {
1087  if (line.contains(SECTION_DIVIDER) && previousLine != null && previousLine.contains(userInfoSection)) {
1088  readUsers(bufferedReader, userSet);
1089  }
1090 
1091  if (line.contains(SECTION_DIVIDER) && previousLine != null && previousLine.contains("Group Membership Information")) {
1092  groupMap = readGroups(bufferedReader);
1093  }
1094 
1095  previousLine = line;
1096  line = bufferedReader.readLine();
1097  }
1098  Map<String, Map<String, String>> userInfoMap = new HashMap<>();
1099  //load all the user info which was read into a map
1100  for (Map<String, String> userInfo : userSet) {
1101  userInfoMap.put(userInfo.get(SID_KEY), userInfo);
1102  }
1103 
1104  // New OsAccount Code
1105  OsAccountManager accountMgr = tskCase.getOsAccountManager();
1106  HostManager hostMrg = tskCase.getHostManager();
1107  Host host = hostMrg.getHostByDataSource((DataSource)dataSource);
1108 
1109  List<OsAccount> existingAccounts = accountMgr.getOsAccounts(host);
1110  for(OsAccount osAccount: existingAccounts) {
1111  Optional<String> optional = osAccount.getAddr();
1112  if(!optional.isPresent()) {
1113  continue;
1114  }
1115 
1116  String sid = optional.get();
1117  Map<String, String> userInfo = userInfoMap.remove(sid);
1118  if(userInfo != null) {
1119  addAccountInstance(accountMgr, osAccount, (DataSource)dataSource);
1120  updateOsAccount(osAccount, userInfo, groupMap.get(sid), regAbstractFile);
1121  }
1122  }
1123 
1124  //add remaining userinfos as accounts;
1125  for (Map<String, String> userInfo : userInfoMap.values()) {
1126  OsAccount osAccount = accountMgr.newWindowsOsAccount(userInfo.get(SID_KEY), null, null, host, OsAccountRealm.RealmScope.LOCAL);
1127  accountMgr.newOsAccountInstance(osAccount, (DataSource)dataSource, OsAccountInstance.OsAccountInstanceType.LAUNCHED);
1128  updateOsAccount(osAccount, userInfo, groupMap.get(userInfo.get(SID_KEY)), regAbstractFile);
1129  }
1130  return true;
1131  } catch (FileNotFoundException ex) {
1132  logger.log(Level.WARNING, "Error finding the registry file.", ex); //NON-NLS
1133  } catch (IOException ex) {
1134  logger.log(Level.WARNING, "Error building the document parser: {0}", ex); //NON-NLS
1135  } catch (TskDataException | TskCoreException ex) {
1136  logger.log(Level.WARNING, "Error updating TSK_OS_ACCOUNT artifacts to include newly parsed data.", ex); //NON-NLS
1137  } catch (OsAccountManager.NotUserSIDException ex) {
1138  logger.log(Level.WARNING, "Error creating OS Account, input SID is not a user SID.", ex); //NON-NLS
1139  }
1140  finally {
1141  if (!context.dataSourceIngestIsCancelled()) {
1142  postArtifacts(newArtifacts);
1143  }
1144  }
1145  return false;
1146  }
1147 
1159  private void readUsers(BufferedReader bufferedReader, Set<Map<String, String>> users) throws IOException {
1160  String line = bufferedReader.readLine();
1161  //read until end of file or next section divider
1162  String userName = "";
1163  String user_rid = "";
1164  while (line != null && !line.contains(SECTION_DIVIDER)) {
1165  //when a user name field exists read the name and id number
1166  if (line.contains(USERNAME_KEY)) {
1167  String regx = USERNAME_KEY + "\\s*?:";
1168  String userNameAndIdString = line.replaceAll(regx, "");
1169  userName = userNameAndIdString.substring(0, userNameAndIdString.lastIndexOf('[')).trim();
1170  user_rid = userNameAndIdString.substring(userNameAndIdString.lastIndexOf('['), userNameAndIdString.lastIndexOf(']'));
1171  } else if (line.contains(SID_KEY) && !userName.isEmpty()) {
1172  Map.Entry<String, String> entry = getSAMKeyValue(line);
1173 
1174  HashMap<String, String> userInfo = new HashMap<>();
1175  userInfo.put(USERNAME_KEY, userName);
1176  userInfo.put(RID_KEY, user_rid);
1177  userInfo.put(entry.getKey(), entry.getValue());
1178 
1179  //continue reading this users information until end of file or a blank line between users
1180  line = bufferedReader.readLine();
1181  while (line != null && !line.isEmpty()) {
1182  entry = getSAMKeyValue(line);
1183  if (entry != null) {
1184  userInfo.put(entry.getKey(), entry.getValue());
1185  }
1186  line = bufferedReader.readLine();
1187  }
1188  users.add(userInfo);
1189 
1190  userName = "";
1191  }
1192  line = bufferedReader.readLine();
1193  }
1194  }
1195 
1205  private void createRecentlyUsedArtifacts(String regFileName, AbstractFile regFile) throws FileNotFoundException, IOException {
1206  File regfile = new File(regFileName);
1207  try (BufferedReader reader = new BufferedReader(new FileReader(regfile))) {
1208  String line = reader.readLine();
1209  while (line != null) {
1210  line = line.trim();
1211 
1212  if (line.matches("^adoberdr v.*")) {
1213  parseAdobeMRUList(regFile, reader, Bundle.Recently_Used_Artifacts_Adobe());
1214  } else if (line.matches("^mpmru v.*")) {
1215  parseMediaPlayerMRUList(regFile, reader, Bundle.Recently_Used_Artifacts_Mediaplayer());
1216  } else if (line.matches("^trustrecords v.*")) {
1217  parseOfficeTrustRecords(regFile, reader, Bundle.Recently_Used_Artifacts_Office_Trustrecords());
1218  } else if (line.matches("^ArcHistory:")) {
1219  parse7ZipMRU(regFile, reader, Bundle.Recently_Used_Artifacts_ArcHistory());
1220  } else if (line.matches("^applets v.*")) {
1221  parseGenericMRUList(regFile, reader, Bundle.Recently_Used_Artifacts_Applets());
1222  } else if (line.matches("^mmc v.*")) {
1223  parseGenericMRUList(regFile, reader, Bundle.Recently_Used_Artifacts_Mmc());
1224  } else if (line.matches("^winrar v.*")) {
1225  parseWinRARMRUList(regFile, reader, Bundle.Recently_Used_Artifacts_Winrar());
1226  } else if (line.matches("^officedocs2010 v.*")) {
1227  parseOfficeDocs2010MRUList(regFile, reader, Bundle.Recently_Used_Artifacts_Officedocs());
1228  }
1229  line = reader.readLine();
1230  }
1231  }
1232  }
1233 
1245  private void parseBamKey(AbstractFile regFile, BufferedReader reader, String comment) throws FileNotFoundException, IOException {
1246  List<BlackboardArtifact> bbartifacts = new ArrayList<>();
1247  String line = reader.readLine();
1248  // Read thru first bam output to get to second bam output which is the same but delimited
1249  while (!line.contains(SECTION_DIVIDER)) {
1250  line = reader.readLine();
1251  line = line.trim();
1252  }
1253  line = reader.readLine();
1254  line = line.trim();
1255  while (!line.contains(SECTION_DIVIDER)) {
1256  // Split the line into it parts based on delimiter of "|"
1257  // 1570493613|BAM|||\Device\HarddiskVolume3\Program Files\TechSmith\Snagit 2018\Snagit32.exe (S-1-5-21-3042408413-2583535980-1301764466-1001)
1258  String tokens[] = line.split("\\|");
1259  Long progRunDateTime = Long.valueOf(tokens[0]);
1260  // Split on " (S-" as this signifies a User SID, if S- not used then may have issues becuase of (x86) in path is valid.
1261  // We can add the S- back to the string that we split on since S- is a valid beginning of a User SID
1262  String fileNameSid[] = tokens[4].split("\\s+\\(S-");
1263  String userSid = "S-" + fileNameSid[1].substring(0, fileNameSid[1].length() - 1);
1264  String userName = getUserNameMap().get(userSid);
1265  if (userName == null) {
1266  userName = userSid;
1267  }
1268  String fileName = fileNameSid[0];
1269  if (fileName.startsWith("\\Device\\HarddiskVolume")) {
1270  // Start at point past the 2nd slash
1271  int fileNameStart = fileName.indexOf('\\', 16);
1272  fileName = fileName.substring(fileNameStart, fileName.length());
1273 
1274  }
1275  Collection<BlackboardAttribute> attributes = new ArrayList<>();
1276  attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PROG_NAME, getName(), fileName));
1277  attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_USER_NAME, getName(), userName));
1278  attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DATETIME, getName(), progRunDateTime));
1279  attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_COMMENT, getName(), comment));
1280 
1281  try {
1282  BlackboardArtifact bba = createArtifactWithAttributes(ARTIFACT_TYPE.TSK_PROG_RUN, regFile, attributes);
1283  bbartifacts.add(bba);
1284  bba = createAssociatedArtifact(FilenameUtils.normalize(fileName, true), bba);
1285  if (bba != null) {
1286  bbartifacts.add(bba);
1287  }
1288  } catch (TskCoreException ex) {
1289  logger.log(Level.SEVERE, String.format("Failed to create TSK_PROG_RUN artifact for file %d", regFile.getId()), ex);
1290  }
1291  line = reader.readLine();
1292  }
1293  if (!bbartifacts.isEmpty() && !context.dataSourceIngestIsCancelled()) {
1294  postArtifacts(bbartifacts);
1295  }
1296  }
1297 
1309  private void parseAdobeMRUList(AbstractFile regFile, BufferedReader reader, String comment) throws FileNotFoundException, IOException {
1310  List<BlackboardArtifact> bbartifacts = new ArrayList<>();
1311  String line = reader.readLine();
1312  SimpleDateFormat adobePluginDateFormat = new SimpleDateFormat("yyyyMMddHHmmssZ", US);
1313  Long adobeUsedTime = Long.valueOf(0);
1314  while (!line.contains(SECTION_DIVIDER)) {
1315  line = reader.readLine();
1316  line = line.trim();
1317  if (line.matches("^Key name,file name,sDate,uFileSize,uPageCount")) {
1318  line = reader.readLine();
1319  // Columns are
1320  // Key name, file name, sDate, uFileSize, uPageCount
1321  while (!line.contains(SECTION_DIVIDER)) {
1322  // Split csv line, handles double quotes around individual file names
1323  // since file names can contain commas
1324  String tokens[] = line.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)");
1325  String fileName = tokens[1].substring(0, tokens[1].length() - 1);
1326  fileName = fileName.replace("\"", "");
1327  if (fileName.charAt(0) == '/') {
1328  fileName = fileName.substring(1, fileName.length() - 1);
1329  fileName = fileName.replaceFirst("/", ":/");
1330  }
1331  // Check to see if more then 2 tokens, Date may not be populated, will default to 0
1332  if (tokens.length > 2) {
1333  // Time in the format of 20200131104456-05'00'
1334  try {
1335  String fileUsedTime = tokens[2].replaceAll("'", "");
1336  Date usedDate = adobePluginDateFormat.parse(fileUsedTime);
1337  adobeUsedTime = usedDate.getTime() / 1000;
1338  } catch (ParseException ex) {
1339  // catching error and displaying date that could not be parsed
1340  // we set the timestamp to 0 and continue on processing
1341  logger.log(Level.WARNING, String.format("Failed to parse date/time %s for adobe file artifact.", tokens[2]), ex); //NON-NLS
1342  }
1343  }
1344  Collection<BlackboardAttribute> attributes = new ArrayList<>();
1345  attributes.add(new BlackboardAttribute(TSK_PATH, getName(), fileName));
1346  attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DATETIME_ACCESSED, getName(), adobeUsedTime));
1347  attributes.add(new BlackboardAttribute(TSK_COMMENT, getName(), comment));
1348  try{
1349  BlackboardArtifact bba = createArtifactWithAttributes(ARTIFACT_TYPE.TSK_RECENT_OBJECT, regFile, attributes);
1350  if (bba != null) {
1351  bbartifacts.add(bba);
1352  fileName = fileName.replace("\0", "");
1353  bba = createAssociatedArtifact(FilenameUtils.normalize(fileName, true), bba);
1354  if (bba != null) {
1355  bbartifacts.add(bba);
1356  }
1357  }
1358  } catch(TskCoreException ex) {
1359  logger.log(Level.SEVERE, String.format("Failed to create TSK_RECENT_OBJECT artifact for file %d", regFile.getId()), ex);
1360  }
1361  line = reader.readLine();
1362  }
1363  line = line.trim();
1364  }
1365  }
1366  if (!bbartifacts.isEmpty() && !context.dataSourceIngestIsCancelled()) {
1367  postArtifacts(bbartifacts);
1368  }
1369  }
1370 
1383  private void parseMediaPlayerMRUList(AbstractFile regFile, BufferedReader reader, String comment) throws FileNotFoundException, IOException {
1384  List<BlackboardArtifact> bbartifacts = new ArrayList<>();
1385  String line = reader.readLine();
1386  while (!line.contains(SECTION_DIVIDER)) {
1387  line = reader.readLine();
1388  line = line.trim();
1389  if (line.contains("LastWrite")) {
1390  line = reader.readLine();
1391  // Columns are
1392  // FileX -> <Media file>
1393  while (!line.contains(SECTION_DIVIDER) && !line.contains("RecentFileList has no values.")) {
1394  // Split line on "> " which is the record delimiter between position and file
1395  String tokens[] = line.split("> ");
1396  String fileName = tokens[1];
1397  Collection<BlackboardAttribute> attributes = new ArrayList<>();
1398  attributes.add(new BlackboardAttribute(TSK_PATH, getName(), fileName));
1399  attributes.add(new BlackboardAttribute(TSK_COMMENT, getName(), comment));
1400  try{
1401  BlackboardArtifact bba = createArtifactWithAttributes(ARTIFACT_TYPE.TSK_RECENT_OBJECT, regFile, attributes);
1402  if (bba != null) {
1403  bbartifacts.add(bba);
1404  bba = createAssociatedArtifact(fileName, bba);
1405  if (bba != null) {
1406  bbartifacts.add(bba);
1407  bba = createAssociatedArtifact(FilenameUtils.normalize(fileName, true), bba);
1408  if (bba != null) {
1409  bbartifacts.add(bba);
1410  }
1411  }
1412  }
1413  } catch(TskCoreException ex) {
1414  logger.log(Level.SEVERE, String.format("Failed to create TSK_RECENT_OBJECT artifact for file %d", regFile.getId()), ex);
1415  }
1416  line = reader.readLine();
1417  }
1418  line = line.trim();
1419  }
1420  }
1421  if (!bbartifacts.isEmpty()&& !context.dataSourceIngestIsCancelled()) {
1422  postArtifacts(bbartifacts);
1423  }
1424  }
1425 
1438  private void parseGenericMRUList(AbstractFile regFile, BufferedReader reader, String comment) throws FileNotFoundException, IOException {
1439  List<BlackboardArtifact> bbartifacts = new ArrayList<>();
1440  String line = reader.readLine();
1441  while (!line.contains(SECTION_DIVIDER)) {
1442  line = reader.readLine();
1443  line = line.trim();
1444  if (line.contains("LastWrite")) {
1445  line = reader.readLine();
1446  // Columns are
1447  // FileX -> <file>
1448  while (!line.contains(SECTION_DIVIDER) && !line.isEmpty() && !line.contains("Applets")
1449  && !line.contains(("Recent File List"))) {
1450  // Split line on "> " which is the record delimiter between position and file
1451  String tokens[] = line.split("> ");
1452  if (tokens.length > 1) {
1453  String fileName = tokens[1];
1454  Collection<BlackboardAttribute> attributes = new ArrayList<>();
1455  attributes.add(new BlackboardAttribute(TSK_PATH, getName(), fileName));
1456  attributes.add(new BlackboardAttribute(TSK_COMMENT, getName(), comment));
1457  try{
1458  BlackboardArtifact bba = createArtifactWithAttributes(ARTIFACT_TYPE.TSK_RECENT_OBJECT, regFile, attributes);
1459  if (bba != null) {
1460  bbartifacts.add(bba);
1461  bba = createAssociatedArtifact(FilenameUtils.normalize(fileName, true), bba);
1462  if (bba != null) {
1463  bbartifacts.add(bba);
1464  }
1465  }
1466  } catch(TskCoreException ex) {
1467  logger.log(Level.SEVERE, String.format("Failed to create TSK_RECENT_OBJECT artifact for file %d", regFile.getId()), ex);
1468  }
1469  }
1470  line = reader.readLine();
1471  }
1472  line = line.trim();
1473  }
1474  }
1475  if (!bbartifacts.isEmpty() && !context.dataSourceIngestIsCancelled()) {
1476  postArtifacts(bbartifacts);
1477  }
1478  }
1479 
1492  private void parseWinRARMRUList(AbstractFile regFile, BufferedReader reader, String comment) throws FileNotFoundException, IOException {
1493  List<BlackboardArtifact> bbartifacts = new ArrayList<>();
1494  String line = reader.readLine();
1495  while (!line.contains(SECTION_DIVIDER)) {
1496  line = reader.readLine();
1497  line = line.trim();
1498  if (line.contains("LastWrite")) {
1499  line = reader.readLine();
1500  // Columns are
1501  // FileX -> <Media file>
1502  if (!line.isEmpty()) {
1503  while (!line.contains(SECTION_DIVIDER)) {
1504  // Split line on "> " which is the record delimiter between position and file
1505  String tokens[] = line.split("> ");
1506  String fileName = tokens[1];
1507  Collection<BlackboardAttribute> attributes = new ArrayList<>();
1508  attributes.add(new BlackboardAttribute(TSK_PATH, getName(), fileName));
1509  attributes.add(new BlackboardAttribute(TSK_COMMENT, getName(), comment));
1510  try{
1511  BlackboardArtifact bba = createArtifactWithAttributes(ARTIFACT_TYPE.TSK_RECENT_OBJECT, regFile, attributes);
1512  bbartifacts.add(bba);
1513  bba = createAssociatedArtifact(FilenameUtils.normalize(fileName, true), bba);
1514  if (bba != null) {
1515  bbartifacts.add(bba);
1516  }
1517  } catch(TskCoreException ex) {
1518  logger.log(Level.SEVERE, String.format("Failed to create TSK_RECENT_OBJECT artifact for file %d", regFile.getId()), ex);
1519  }
1520  line = reader.readLine();
1521  }
1522  }
1523  line = line.trim();
1524  }
1525  }
1526  if (!bbartifacts.isEmpty() && !context.dataSourceIngestIsCancelled()) {
1527  postArtifacts(bbartifacts);
1528  }
1529  }
1530 
1543  private void parse7ZipMRU(AbstractFile regFile, BufferedReader reader, String comment) throws FileNotFoundException, IOException {
1544  List<BlackboardArtifact> bbartifacts = new ArrayList<>();
1545  String line = reader.readLine();
1546  line = line.trim();
1547  if (!line.contains("PathHistory:")) {
1548  while (!line.contains("PathHistory:") && !line.isEmpty()) {
1549  // Columns are
1550  // <fileName>
1551  String fileName = line;
1552  Collection<BlackboardAttribute> attributes = new ArrayList<>();
1553  attributes.add(new BlackboardAttribute(TSK_PATH, getName(), fileName));
1554  attributes.add(new BlackboardAttribute(TSK_COMMENT, getName(), comment));
1555  try{
1556  BlackboardArtifact bba = createArtifactWithAttributes(ARTIFACT_TYPE.TSK_RECENT_OBJECT, regFile, attributes);
1557  bbartifacts.add(bba);
1558  bba = createAssociatedArtifact(FilenameUtils.normalize(fileName, true), bba);
1559  if (bba != null) {
1560  bbartifacts.add(bba);
1561  }
1562 
1563  } catch(TskCoreException ex) {
1564  logger.log(Level.SEVERE, String.format("Failed to create TSK_RECENT_OBJECT artifact for file %d", regFile.getId()), ex);
1565  }
1566  line = reader.readLine();
1567  line = line.trim();
1568  }
1569  }
1570  if (!bbartifacts.isEmpty() && !context.dataSourceIngestIsCancelled()) {
1571  postArtifacts(bbartifacts);
1572  }
1573  }
1574 
1587  private void parseOfficeDocs2010MRUList(AbstractFile regFile, BufferedReader reader, String comment) throws FileNotFoundException, IOException {
1588  List<BlackboardArtifact> bbartifacts = new ArrayList<>();
1589  String line = reader.readLine();
1590  line = line.trim();
1591  // Reading to the SECTION DIVIDER to get next section of records to process. Dates appear to have
1592  // multiple spaces in them that makes it harder to parse so next section will be easier to parse
1593  while (!line.contains(SECTION_DIVIDER)) {
1594  line = reader.readLine();
1595  }
1596  line = reader.readLine();
1597  while (!line.contains(SECTION_DIVIDER)) {
1598  // record has the following format
1599  // 1294283922|REG|||OfficeDocs2010 - F:\Windows_time_Rules_xp.doc
1600  String tokens[] = line.split("\\|");
1601  Long docDate = Long.valueOf(tokens[0]);
1602  String fileNameTokens[] = tokens[4].split(" - ");
1603  String fileName = fileNameTokens[1];
1604  Collection<BlackboardAttribute> attributes = new ArrayList<>();
1605  attributes.add(new BlackboardAttribute(TSK_PATH, getName(), fileName));
1606  attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DATETIME_ACCESSED, getName(), docDate));
1607  attributes.add(new BlackboardAttribute(TSK_COMMENT, getName(), comment));
1608  try{
1609  BlackboardArtifact bba = createArtifactWithAttributes(ARTIFACT_TYPE.TSK_RECENT_OBJECT, regFile, attributes);
1610  bbartifacts.add(bba);
1611  bba = createAssociatedArtifact(FilenameUtils.normalize(fileName, true), bba);
1612  if (bba != null) {
1613  bbartifacts.add(bba);
1614  }
1615  } catch(TskCoreException ex) {
1616  logger.log(Level.SEVERE, String.format("Failed to create TSK_RECENT_OBJECT artifact for file %d", regFile.getId()), ex);
1617  }
1618  line = reader.readLine();
1619  line = line.trim();
1620  }
1621  if (!bbartifacts.isEmpty() && !context.dataSourceIngestIsCancelled()) {
1622  postArtifacts(bbartifacts);
1623  }
1624  }
1625 
1638  private void parseOfficeTrustRecords(AbstractFile regFile, BufferedReader reader, String comment) throws FileNotFoundException, IOException {
1639  String userProfile = regFile.getParentPath();
1640  userProfile = userProfile.substring(0, userProfile.length() - 1);
1641  List<BlackboardArtifact> bbartifacts = new ArrayList<>();
1642  SimpleDateFormat pluginDateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy", US);
1643  Long usedTime = Long.valueOf(0);
1644  String line = reader.readLine();
1645  while (!line.contains(SECTION_DIVIDER)) {
1646  line = reader.readLine();
1647  line = line.trim();
1648  usedTime = Long.valueOf(0);
1649  if (!line.contains("**") && !line.contains("----------") && !line.contains("LastWrite")
1650  && !line.contains(SECTION_DIVIDER) && !line.isEmpty() && !line.contains("TrustRecords")
1651  && !line.contains("VBAWarnings =")) {
1652  // Columns are
1653  // Date : <File Name>/<Website>
1654  // Split line on " : " which is the record delimiter between position and file
1655  String fileName = null;
1656  String tokens[] = line.split(" : ");
1657  fileName = tokens[1];
1658  fileName = fileName.replace("%USERPROFILE%", userProfile);
1659  // Time in the format of Wed May 31 14:33:03 2017 Z
1660  try {
1661  String fileUsedTime = tokens[0].replaceAll(" Z", "");
1662  Date usedDate = pluginDateFormat.parse(fileUsedTime);
1663  usedTime = usedDate.getTime() / 1000;
1664  } catch (ParseException ex) {
1665  // catching error and displaying date that could not be parsed
1666  // we set the timestamp to 0 and continue on processing
1667  logger.log(Level.WARNING, String.format("Failed to parse date/time %s for TrustRecords artifact.", tokens[0]), ex); //NON-NLS
1668  }
1669  Collection<BlackboardAttribute> attributes = new ArrayList<>();
1670  attributes.add(new BlackboardAttribute(TSK_PATH, getName(), fileName));
1671  attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DATETIME_ACCESSED, getName(), usedTime));
1672  attributes.add(new BlackboardAttribute(TSK_COMMENT, getName(), comment));
1673  try{
1674  BlackboardArtifact bba = createArtifactWithAttributes(ARTIFACT_TYPE.TSK_RECENT_OBJECT, regFile, attributes);
1675  bbartifacts.add(bba);
1676  bba = createAssociatedArtifact(FilenameUtils.normalize(fileName, true), bba);
1677  if (bba != null) {
1678  bbartifacts.add(bba);
1679  }
1680  } catch(TskCoreException ex) {
1681  logger.log(Level.SEVERE, String.format("Failed to create TSK_RECENT_OBJECT artifact for file %d", regFile.getId()), ex);
1682  }
1683  line = line.trim();
1684  }
1685  }
1686  if (!bbartifacts.isEmpty() && !context.dataSourceIngestIsCancelled()) {
1687  postArtifacts(bbartifacts);
1688  }
1689  }
1690 
1701  private BlackboardArtifact createAssociatedArtifact(String filePathName, BlackboardArtifact bba) {
1702  String fileName = FilenameUtils.getName(filePathName);
1703  String filePath = FilenameUtils.getPath(filePathName);
1704  List<AbstractFile> sourceFiles;
1705  try {
1706  sourceFiles = currentCase.getSleuthkitCase().getFileManager().findFilesExactNameExactPath(dataSource, fileName, filePath);
1707  if (!sourceFiles.isEmpty()) {
1708  return createAssociatedArtifact(sourceFiles.get(0), bba);
1709  }
1710  } catch (TskCoreException ex) {
1711  // only catching the error and displaying the message as the file may not exist on the
1712  // system anymore
1713  logger.log(Level.WARNING, String.format("Error finding actual file %s. file may not exist", filePathName)); //NON-NLS
1714  }
1715 
1716  return null;
1717  }
1718 
1729  private Map<String, String> makeUserNameMap(Content dataSource) throws TskCoreException {
1730  Map<String, String> map = new HashMap<>();
1731 
1732  for(OsAccount account: tskCase.getOsAccountManager().getOsAccounts(((DataSource)dataSource).getHost())) {
1733  Optional<String> userName = account.getLoginName();
1734  // @@@ BC: Seems like this should be calling account.getAddr() to get the SID.
1735  map.put(account.getName(), userName.isPresent() ? userName.get() : "");
1736  }
1737 
1738  return map;
1739  }
1740 
1749  private String getMachineSID(String osAccountSID) {
1750  // @@@ We should add checks about mininum number of dashes.
1751  // and we should really call this stripRelativeIdentifierFromSID().
1752  int index = osAccountSID.lastIndexOf("-");
1753  return osAccountSID.substring(0, index);
1754  }
1755 
1756  private final List<String> machineSIDs = new ArrayList<>();
1765  // @@@ BC: This is probably more accurately called 'knownDomainIdSID'
1766  private boolean knownMachineSID(String osAccountSID) {
1767  if (machineSIDs.isEmpty()) {
1768  Map<String, String> userMap = getUserNameMap();
1769  for (String str : userMap.keySet()) {
1770  String temp = getMachineSID(str);
1771  if (!machineSIDs.contains(temp)) {
1772  machineSIDs.add(temp);
1773  }
1774  }
1775  }
1776  String machineSID = getMachineSID(osAccountSID);
1777  return machineSIDs.contains(machineSID);
1778  }
1779 
1785  private Map<String, String> getUserNameMap() {
1786  if(userNameMap == null) {
1787  // Get a mapping of user sids to user names and save globally so it can be used for other areas
1788  // of the registry, ie: BAM key
1789  try {
1790  userNameMap = makeUserNameMap(dataSource);
1791  } catch (TskCoreException ex) {
1792  logger.log(Level.WARNING, "Unable to create OS Account user name map", ex);
1793  // This is not the end of the world we will just continue without
1794  // user names
1795  userNameMap = new HashMap<>();
1796  }
1797  }
1798 
1799  return userNameMap;
1800  }
1801 
1812  private BlackboardAttribute getAttributeForArtifact(BlackboardArtifact artifact, BlackboardAttribute.ATTRIBUTE_TYPE type) throws TskCoreException {
1813  return artifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(type.getTypeID())));
1814  }
1815 
1824  void createShellBagArtifacts(AbstractFile regFile, List<ShellBag> shellbags) throws TskCoreException {
1825  List<BlackboardArtifact> artifacts = new ArrayList<>();
1826  List<DataArtifact> dataArtifacts = new ArrayList<>();
1827  try {
1828  for (ShellBag bag : shellbags) {
1829  Collection<BlackboardAttribute> attributes = new ArrayList<>();
1830  attributes.add(new BlackboardAttribute(TSK_PATH, getName(), bag.getResource()));
1831  attributes.add(new BlackboardAttribute(getKeyAttribute(), getName(), bag.getKey()));
1832 
1833  long time;
1834  time = bag.getLastWrite();
1835  if (time != 0) {
1836  attributes.add(new BlackboardAttribute(getLastWriteAttribute(), getName(), time));
1837  }
1838 
1839  time = bag.getModified();
1840  if (time != 0) {
1841  attributes.add(new BlackboardAttribute(TSK_DATETIME_MODIFIED, getName(), time));
1842  }
1843 
1844  time = bag.getCreated();
1845  if (time != 0) {
1846  attributes.add(new BlackboardAttribute(TSK_DATETIME_CREATED, getName(), time));
1847  }
1848 
1849  time = bag.getAccessed();
1850  if (time != 0) {
1851  attributes.add(new BlackboardAttribute(TSK_DATETIME_ACCESSED, getName(), time));
1852  }
1853 
1854  BlackboardArtifact artifact = createArtifactWithAttributes(getShellBagArtifact(), regFile, attributes);
1855  artifacts.add(artifact);
1856  dataArtifacts.add((DataArtifact)artifact);
1857  }
1858  } finally {
1859  if(!context.dataSourceIngestIsCancelled()) {
1860  postArtifacts(artifacts);
1861  context.addDataArtifactsToJob(dataArtifacts);
1862  }
1863  }
1864  }
1865 
1874  private BlackboardArtifact.Type getShellBagArtifact() throws TskCoreException {
1875  if (shellBagArtifactType == null) {
1876  try {
1877  shellBagArtifactType = tskCase.getBlackboard().getOrAddArtifactType(SHELLBAG_ARTIFACT_NAME, Bundle.Shellbag_Artifact_Display_Name());
1878  } catch (BlackboardException ex) {
1879  throw new TskCoreException(String.format("Failed to get shell bag artifact type", SHELLBAG_ARTIFACT_NAME), ex);
1880  }
1881  }
1882 
1883  return shellBagArtifactType;
1884  }
1885 
1894  private BlackboardAttribute.Type getLastWriteAttribute() throws TskCoreException {
1895  if (shellBagLastWriteAttributeType == null) {
1896  try {
1897  shellBagLastWriteAttributeType = tskCase.getBlackboard().getOrAddAttributeType(SHELLBAG_ATTRIBUTE_LAST_WRITE,
1898  BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DATETIME,
1899  Bundle.Shellbag_Last_Write_Attribute_Display_Name());
1900  } catch (BlackboardException ex) {
1901  // Attribute already exists get it from the case
1902  throw new TskCoreException(String.format("Failed to get custom attribute %s", SHELLBAG_ATTRIBUTE_LAST_WRITE), ex);
1903  }
1904  }
1905  return shellBagLastWriteAttributeType;
1906  }
1907 
1916  private BlackboardAttribute.Type getKeyAttribute() throws TskCoreException {
1917  if (shellBagKeyAttributeType == null) {
1918  try {
1919  shellBagKeyAttributeType = tskCase.getBlackboard().getOrAddAttributeType(SHELLBAG_ATTRIBUTE_KEY,
1920  BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.STRING,
1921  Bundle.Shellbag_Key_Attribute_Display_Name());
1922  } catch (BlackboardException ex) {
1923  throw new TskCoreException(String.format("Failed to get key attribute %s", SHELLBAG_ATTRIBUTE_KEY), ex);
1924  }
1925  }
1926  return shellBagKeyAttributeType;
1927  }
1928 
1938  Map<String, List<String>> readGroups(BufferedReader bufferedReader) throws IOException {
1939  Map<String, List<String>> groupMap = new HashMap<>();
1940 
1941  String line = bufferedReader.readLine();
1942 
1943  int userCount = 0;
1944  String groupName = null;
1945 
1946  while (line != null && !line.contains(SECTION_DIVIDER)) {
1947 
1948  if (line.contains("Group Name")) {
1949  String value = line.replaceAll("Group Name\\s*?:", "").trim();
1950  groupName = (value.replaceAll("\\[\\d*?\\]", "")).trim();
1951  int startIndex = value.indexOf(" [") + 1;
1952  int endIndex = value.indexOf(']');
1953 
1954  if (startIndex != -1 && endIndex != -1) {
1955  String countStr = value.substring(startIndex + 1, endIndex);
1956  userCount = Integer.parseInt(countStr);
1957  }
1958  } else if (line.matches("Users\\s*?:")) {
1959  for (int i = 0; i < userCount; i++) {
1960  line = bufferedReader.readLine();
1961  if (line != null) {
1962  String sid = line.trim();
1963  List<String> groupList = groupMap.get(sid);
1964  if (groupList == null) {
1965  groupList = new ArrayList<>();
1966  groupMap.put(sid, groupList);
1967  }
1968  groupList.add(groupName);
1969  }
1970  }
1971  groupName = null;
1972  }
1973  line = bufferedReader.readLine();
1974  }
1975  return groupMap;
1976  }
1977 
1986  private Map.Entry<String, String> getSAMKeyValue(String line) {
1987  int index = line.indexOf(':');
1988  Map.Entry<String, String> returnValue = null;
1989  String key = null;
1990  String value = null;
1991 
1992  if (index != -1) {
1993  key = line.substring(0, index).trim();
1994  if (index + 1 < line.length()) {
1995  value = line.substring(index + 1).trim();
1996  } else {
1997  value = "";
1998  }
1999 
2000  } else if (line.contains("-->")) {
2001  key = line.replace("-->", "").trim();
2002  value = "true";
2003  }
2004 
2005  if (key != null) {
2006  returnValue = new AbstractMap.SimpleEntry<>(key, value);
2007  }
2008 
2009  return returnValue;
2010  }
2011 
2012  @Override
2013  public void process(Content dataSource, IngestJobContext context, DataSourceIngestModuleProgress progressBar) {
2014  this.dataSource = dataSource;
2015  this.context = context;
2016 
2017  progressBar.progress(Bundle.Progress_Message_Analyze_Registry());
2018  analyzeRegistryFiles(context.getJobId());
2019 
2020  }
2021 
2025  private class RegOutputFiles {
2026 
2027  public String autopsyPlugins = "";
2028  public String fullPlugins = "";
2029  }
2030 
2043  private void createOrUpdateOsAccount(AbstractFile file, String sid, String userName, String homeDir, String domainName, OsAccountRealm.RealmScope realmScope) throws TskCoreException, TskDataException, NotUserSIDException {
2044  OsAccountManager accountMgr = tskCase.getOsAccountManager();
2045  HostManager hostMrg = tskCase.getHostManager();
2046  Host host = hostMrg.getHostByDataSource((DataSource)dataSource);
2047 
2048  Optional<OsAccount> optional = accountMgr.getWindowsOsAccount(sid, null, null, host);
2049  OsAccount osAccount;
2050  if (!optional.isPresent()) {
2051  osAccount = accountMgr.newWindowsOsAccount(sid, userName != null && userName.isEmpty() ? null : userName, domainName, host, realmScope);
2052  accountMgr.newOsAccountInstance(osAccount, (DataSource)dataSource, OsAccountInstance.OsAccountInstanceType.LAUNCHED);
2053  } else {
2054  osAccount = optional.get();
2055  addAccountInstance(accountMgr, osAccount, (DataSource)dataSource);
2056  if (userName != null && !userName.isEmpty()) {
2057  OsAccountUpdateResult updateResult= accountMgr.updateCoreWindowsOsAccountAttributes(osAccount, null, userName, (domainName == null || domainName.isEmpty()) ? null : domainName, host);
2058  osAccount = updateResult.getUpdatedAccount().orElse(osAccount);
2059  }
2060  }
2061 
2062  if (homeDir != null && !homeDir.isEmpty()) {
2063  List<OsAccountAttribute> attributes = new ArrayList<>();
2064  String dir = homeDir.replaceFirst("^(%\\w*%)", "");
2065  dir = dir.replace("\\", "/");
2066  attributes.add(createOsAccountAttribute(TSK_HOME_DIR, dir, osAccount, host, file));
2067  accountMgr.addExtendedOsAccountAttributes(osAccount, attributes);
2068  }
2069 
2070  }
2071 
2078  private void addEmailAccount(AbstractFile regFile, String emailAddress) {
2079  try {
2080  currentCase.getSleuthkitCase()
2081  .getCommunicationsManager()
2082  .createAccountFileInstance(Account.Type.EMAIL,
2083  emailAddress, getRAModuleName(), regFile);
2084  } catch (TskCoreException ex) {
2085  logger.log(Level.SEVERE,
2086  String.format("Error adding email account with value "
2087  + "%s, to the case database for file %s [objId=%d]",
2088  emailAddress, regFile.getName(), regFile.getId()), ex);
2089  }
2090  }
2091 
2100  private Long parseRegRipTime(String value) {
2101  try {
2102  return REG_RIPPER_TIME_FORMAT.parse(value).getTime() / MS_IN_SEC;
2103  } catch (ParseException ex) {
2104  logger.log(Level.SEVERE, String.format("Failed to parse reg rip time: %s", value));
2105  }
2106  return null;
2107  }
2108 
2120  private void updateOsAccount(OsAccount osAccount, Map<String, String> userInfo, List<String> groupList, AbstractFile regFile) throws TskDataException, TskCoreException, NotUserSIDException {
2121  Host host = ((DataSource)dataSource).getHost();
2122 
2123  SimpleDateFormat regRipperTimeFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy 'Z'", US);
2124  regRipperTimeFormat.setTimeZone(getTimeZone("GMT"));
2125 
2126  List<OsAccountAttribute> attributes = new ArrayList<>();
2127 
2128  Long creationTime = null;
2129 
2130  String value = userInfo.get(ACCOUNT_CREATED_KEY);
2131  if (value != null && !value.isEmpty() && !value.equals(NEVER_DATE)) {
2132  creationTime = parseRegRipTime(value);
2133  }
2134 
2135  value = userInfo.get(LAST_LOGIN_KEY);
2136  if (value != null && !value.isEmpty() && !value.equals(NEVER_DATE)) {
2137  Long time = parseRegRipTime(value);
2138  if (time != null) {
2139  attributes.add(createOsAccountAttribute(TSK_DATETIME_ACCESSED,
2140  parseRegRipTime(value),
2141  osAccount, host, regFile));
2142  }
2143  }
2144 
2145  String loginName = null;
2146  value = userInfo.get(USERNAME_KEY);
2147  if (value != null && !value.isEmpty()) {
2148  loginName = value;
2149  }
2150 
2151  value = userInfo.get(LOGIN_COUNT_KEY);
2152  if (value != null && !value.isEmpty()) {
2153  attributes.add(createOsAccountAttribute(ATTRIBUTE_TYPE.TSK_COUNT,
2154  Integer.parseInt(value),
2155  osAccount, host, regFile));
2156  }
2157 
2158  // From regripper the possible values for this key are
2159  // "Default Admin User", "Custom Limited Acct"
2160  // and "Default Guest Acct"
2161  value = userInfo.get(ACCOUNT_TYPE_KEY);
2162  if (value != null && !value.isEmpty() && value.toLowerCase().contains("admin")) {
2163  attributes.add(createOsAccountAttribute(ATTRIBUTE_TYPE.TSK_IS_ADMIN,
2164  1, osAccount, host, regFile));
2165  }
2166 
2167  value = userInfo.get(USER_COMMENT_KEY);
2168  if (value != null && !value.isEmpty()) {
2169  attributes.add(createOsAccountAttribute(ATTRIBUTE_TYPE.TSK_DESCRIPTION,
2170  value, osAccount, host, regFile));
2171  }
2172 
2173  value = userInfo.get(INTERNET_NAME_KEY);
2174  if (value != null && !value.isEmpty()) {
2175  addEmailAccount(regFile, value);
2176 
2177  attributes.add(createOsAccountAttribute(ATTRIBUTE_TYPE.TSK_EMAIL,
2178  value, osAccount, host, regFile));
2179  }
2180 
2181  // FULL_NAME_KEY and NAME_KEY appear to be the same value.
2182  String fullName = null;
2183  value = userInfo.get(FULL_NAME_KEY);
2184  if (value != null && !value.isEmpty()) {
2185  fullName = value;
2186  } else {
2187  value = userInfo.get(NAME_KEY);
2188  if (value != null && !value.isEmpty()) {
2189  fullName = value;
2190  }
2191  }
2192 
2193  value = userInfo.get(PWD_RESET_KEY);
2194  if (value != null && !value.isEmpty() && !value.equals(NEVER_DATE)) {
2195  Long time = parseRegRipTime(value);
2196  if (time != null) {
2197  attributes.add(createOsAccountAttribute(ATTRIBUTE_TYPE.TSK_DATETIME_PASSWORD_RESET,
2198  time, osAccount, host, regFile));
2199  }
2200  }
2201 
2202  value = userInfo.get(PASSWORD_HINT);
2203  if (value != null && !value.isEmpty()) {
2204  attributes.add(createOsAccountAttribute(ATTRIBUTE_TYPE.TSK_PASSWORD_HINT,
2205  value, osAccount, host, regFile));
2206  }
2207 
2208  value = userInfo.get(PWD_FAILE_KEY);
2209  if (value != null && !value.isEmpty() && !value.equals(NEVER_DATE)) {
2210  Long time = parseRegRipTime(value);
2211  if (time != null) {
2212  attributes.add(createOsAccountAttribute(ATTRIBUTE_TYPE.TSK_DATETIME_PASSWORD_FAIL,
2213  time, osAccount, host, regFile));
2214  }
2215  }
2216 
2217  String settingString = getSettingsFromMap(PASSWORD_SETTINGS_FLAGS, userInfo);
2218  if (!settingString.isEmpty()) {
2219  attributes.add(createOsAccountAttribute(ATTRIBUTE_TYPE.TSK_PASSWORD_SETTINGS,
2220  settingString, osAccount, host, regFile));
2221  }
2222 
2223  settingString = getSettingsFromMap(ACCOUNT_SETTINGS_FLAGS, userInfo);
2224  if (!settingString.isEmpty()) {
2225  attributes.add(createOsAccountAttribute(ATTRIBUTE_TYPE.TSK_ACCOUNT_SETTINGS,
2226  settingString, osAccount, host, regFile));
2227  }
2228 
2229  settingString = getSettingsFromMap(ACCOUNT_TYPE_FLAGS, userInfo);
2230  if (!settingString.isEmpty()) {
2231  attributes.add(createOsAccountAttribute(ATTRIBUTE_TYPE.TSK_FLAG,
2232  settingString, osAccount, host, regFile));
2233  }
2234 
2235  if (groupList != null && groupList.isEmpty()) {
2236  String groups = groupList.stream()
2237  .map(String::valueOf)
2238  .collect(Collectors.joining(", "));
2239 
2240  attributes.add(createOsAccountAttribute(ATTRIBUTE_TYPE.TSK_GROUPS,
2241  groups, osAccount, host, regFile));
2242  }
2243 
2244  // add the attributes to account.
2245  OsAccountManager accountMgr = tskCase.getOsAccountManager();
2246  accountMgr.addExtendedOsAccountAttributes(osAccount, attributes);
2247 
2248  // update the loginname
2249  accountMgr.updateCoreWindowsOsAccountAttributes(osAccount, null, loginName, null, host);
2250 
2251  // update other standard attributes - fullname, creationdate
2252  accountMgr.updateStandardOsAccountAttributes(osAccount, fullName, null, null, creationTime);
2253 
2254 
2255  }
2256 
2265  private String getSettingsFromMap(String[] keys, Map<String, String> map) {
2266  List<String> settingsList = new ArrayList<>();
2267  for (String setting : keys) {
2268  if (map.containsKey(setting)) {
2269  settingsList.add(setting);
2270  }
2271  }
2272 
2273  if (!settingsList.isEmpty()) {
2274  return settingsList.stream()
2275  .map(String::valueOf)
2276  .collect(Collectors.joining(", "));
2277  }
2278 
2279  return "";
2280  }
2281 
2293  private OsAccountAttribute createOsAccountAttribute(BlackboardAttribute.ATTRIBUTE_TYPE type, String value, OsAccount osAccount, Host host, AbstractFile file) {
2294  return osAccount.new OsAccountAttribute(new BlackboardAttribute.Type(type), value, osAccount, host, file);
2295  }
2296 
2308  private OsAccountAttribute createOsAccountAttribute(BlackboardAttribute.ATTRIBUTE_TYPE type, Long value, OsAccount osAccount, Host host, AbstractFile file) {
2309  return osAccount.new OsAccountAttribute(new BlackboardAttribute.Type(type), value, osAccount, host, file);
2310  }
2311 
2323  private OsAccountAttribute createOsAccountAttribute(BlackboardAttribute.ATTRIBUTE_TYPE type, Integer value, OsAccount osAccount, Host host, AbstractFile file) {
2324  return osAccount.new OsAccountAttribute(new BlackboardAttribute.Type(type), value, osAccount, host, file);
2325  }
2326 
2336  private void addAccountInstance(OsAccountManager accountMgr, OsAccount osAccount, DataSource dataSource) throws TskCoreException {
2337  accountMgr.newOsAccountInstance(osAccount, dataSource, OsAccountInstance.OsAccountInstanceType.LAUNCHED);
2338  }
2339 }

Copyright © 2012-2021 Basis Technology. Generated on: Thu Sep 30 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.