Autopsy  4.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-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.io.*;
26 import java.io.File;
27 import java.text.ParseException;
28 import java.text.SimpleDateFormat;
29 import java.util.*;
30 import java.util.logging.Level;
31 import javax.xml.parsers.DocumentBuilder;
32 import javax.xml.parsers.DocumentBuilderFactory;
33 import javax.xml.parsers.ParserConfigurationException;
34 import org.openide.modules.InstalledFileLocator;
35 import org.openide.util.NbBundle;
43 import org.sleuthkit.datamodel.*;
44 import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
45 import org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
46 import org.w3c.dom.Document;
47 import org.w3c.dom.Element;
48 import org.w3c.dom.Node;
49 import org.w3c.dom.NodeList;
50 import org.xml.sax.InputSource;
51 import org.xml.sax.SAXException;
52 import java.nio.file.Path;
54 
61 @NbBundle.Messages({
62  "RegRipperNotFound=Autopsy RegRipper executable not found.",
63  "RegRipperFullNotFound=Full version RegRipper executable not found."
64 })
65 class ExtractRegistry extends Extract {
66 
67  private final Logger logger = Logger.getLogger(this.getClass().getName());
68  private String RR_PATH;
69  private String RR_FULL_PATH;
70  private Path rrHome; // Path to the Autopsy version of RegRipper
71  private Path rrFullHome; // Path to the full version of RegRipper
72  private Content dataSource;
73  private IngestJobContext context;
74  final private static UsbDeviceIdMapper USB_MAPPER = new UsbDeviceIdMapper();
75  final private static String RIP_EXE = "rip.exe";
76  final private static String RIP_PL = "rip.pl";
77  final private static String PERL = "perl ";
78 
79  ExtractRegistry() throws IngestModuleException {
80  moduleName = NbBundle.getMessage(ExtractIE.class, "ExtractRegistry.moduleName.text");
81  final File rrRoot = InstalledFileLocator.getDefault().locate("rr", ExtractRegistry.class.getPackage().getName(), false); //NON-NLS
82  if (rrRoot == null) {
83  throw new IngestModuleException(Bundle.RegRipperNotFound());
84  }
85 
86  final File rrFullRoot = InstalledFileLocator.getDefault().locate("rr-full", ExtractRegistry.class.getPackage().getName(), false); //NON-NLS
87  if (rrFullRoot == null) {
88  throw new IngestModuleException(Bundle.RegRipperFullNotFound());
89  }
90 
91  String executableToRun = RIP_EXE;
92  if (!PlatformUtil.isWindowsOS()) {
93  executableToRun = RIP_PL;
94  }
95  rrHome = rrRoot.toPath();
96  RR_PATH = rrHome.resolve(executableToRun).toString();
97  rrFullHome = rrFullRoot.toPath();
98  RR_FULL_PATH = rrFullHome.resolve(executableToRun).toString();
99 
100  if (!(new File(RR_PATH).exists())) {
101  throw new IngestModuleException(Bundle.RegRipperNotFound());
102  }
103  if (!(new File(RR_FULL_PATH).exists())) {
104  throw new IngestModuleException(Bundle.RegRipperFullNotFound());
105  }
106 
107  if (!PlatformUtil.isWindowsOS()) {
108  RR_PATH = PERL + RR_PATH;
109  RR_FULL_PATH = PERL + RR_FULL_PATH;
110  }
111  }
112 
116  private List<AbstractFile> findRegistryFiles() {
117  List<AbstractFile> allRegistryFiles = new ArrayList<>();
118  org.sleuthkit.autopsy.casemodule.services.FileManager fileManager = currentCase.getServices().getFileManager();
119 
120  // find the user-specific ntuser-dat files
121  try {
122  allRegistryFiles.addAll(fileManager.findFiles(dataSource, "ntuser.dat")); //NON-NLS
123  } catch (TskCoreException ex) {
124  logger.log(Level.WARNING, "Error fetching 'ntuser.dat' file."); //NON-NLS
125  }
126 
127  // find the system hives'
128  String[] regFileNames = new String[]{"system", "software", "security", "sam"}; //NON-NLS
129  for (String regFileName : regFileNames) {
130  try {
131  allRegistryFiles.addAll(fileManager.findFiles(dataSource, regFileName, "/system32/config")); //NON-NLS
132  } catch (TskCoreException ex) {
133  String msg = NbBundle.getMessage(this.getClass(),
134  "ExtractRegistry.findRegFiles.errMsg.errReadingFile", regFileName);
135  logger.log(Level.WARNING, msg);
136  this.addErrorMessage(this.getName() + ": " + msg);
137  }
138  }
139  return allRegistryFiles;
140  }
141 
146  private void analyzeRegistryFiles() {
147  List<AbstractFile> allRegistryFiles = findRegistryFiles();
148 
149  // open the log file
150  FileWriter logFile = null;
151  try {
152  logFile = new FileWriter(RAImageIngestModule.getRAOutputPath(currentCase, "reg") + File.separator + "regripper-info.txt"); //NON-NLS
153  } catch (IOException ex) {
154  logger.log(Level.SEVERE, null, ex);
155  }
156 
157  int j = 0;
158  for (AbstractFile regFile : allRegistryFiles) {
159  String regFileName = regFile.getName();
160  String regFileNameLocal = RAImageIngestModule.getRATempPath(currentCase, "reg") + File.separator + regFileName;
161  String outputPathBase = RAImageIngestModule.getRAOutputPath(currentCase, "reg") + File.separator + regFileName + "-regripper-" + Integer.toString(j++); //NON-NLS
162  File regFileNameLocalFile = new File(regFileNameLocal);
163  try {
164  ContentUtils.writeToFile(regFile, regFileNameLocalFile, context::dataSourceIngestIsCancelled);
165  } catch (IOException ex) {
166  logger.log(Level.SEVERE, "Error writing the temp registry file. {0}", ex); //NON-NLS
167  this.addErrorMessage(
168  NbBundle.getMessage(this.getClass(), "ExtractRegistry.analyzeRegFiles.errMsg.errWritingTemp",
169  this.getName(), regFileName));
170  continue;
171  }
172 
173  if (context.dataSourceIngestIsCancelled()) {
174  break;
175  }
176 
177  try {
178  if (logFile != null) {
179  logFile.write(Integer.toString(j - 1) + "\t" + regFile.getUniquePath() + "\n");
180  }
181  } catch (TskCoreException | IOException ex) {
182  logger.log(Level.SEVERE, null, ex);
183  }
184 
185  logger.log(Level.INFO, "{0}- Now getting registry information from {1}", new Object[]{moduleName, regFileNameLocal}); //NON-NLS
186  RegOutputFiles regOutputFiles = ripRegistryFile(regFileNameLocal, outputPathBase);
187  if (context.dataSourceIngestIsCancelled()) {
188  break;
189  }
190 
191  // parse the autopsy-specific output
192  if (regOutputFiles.autopsyPlugins.isEmpty() == false) {
193  if (parseAutopsyPluginOutput(regOutputFiles.autopsyPlugins, regFile) == false) {
194  this.addErrorMessage(
195  NbBundle.getMessage(this.getClass(), "ExtractRegistry.analyzeRegFiles.failedParsingResults",
196  this.getName(), regFileName));
197  }
198  }
199 
200  // create a report for the full output
201  if (!regOutputFiles.fullPlugins.isEmpty()) {
202  try {
203  currentCase.addReport(regOutputFiles.fullPlugins, NbBundle.getMessage(this.getClass(), "ExtractRegistry.parentModuleName.noSpace"), "RegRipper " + regFile.getUniquePath()); //NON-NLS
204  } catch (TskCoreException e) {
205  this.addErrorMessage("Error adding regripper output as Autopsy report: " + e.getLocalizedMessage()); //NON-NLS
206  }
207  }
208 
209  // delete the hive
210  regFileNameLocalFile.delete();
211  }
212 
213  try {
214  if (logFile != null) {
215  logFile.close();
216  }
217  } catch (IOException ex) {
218  logger.log(Level.SEVERE, null, ex);
219  }
220  }
221 
222  private class RegOutputFiles {
223 
224  public String autopsyPlugins = "";
225  public String fullPlugins = "";
226  }
227 
235  private RegOutputFiles ripRegistryFile(String regFilePath, String outFilePathBase) {
236  String autopsyType = ""; // Type argument for rr for autopsy-specific modules
237  String fullType; // Type argument for rr for full set of modules
238 
239  RegOutputFiles regOutputFiles = new RegOutputFiles();
240 
241  if (regFilePath.toLowerCase().contains("system")) { //NON-NLS
242  autopsyType = "autopsysystem"; //NON-NLS
243  fullType = "system"; //NON-NLS
244  } else if (regFilePath.toLowerCase().contains("software")) { //NON-NLS
245  autopsyType = "autopsysoftware"; //NON-NLS
246  fullType = "software"; //NON-NLS
247  } else if (regFilePath.toLowerCase().contains("ntuser")) { //NON-NLS
248  autopsyType = "autopsyntuser"; //NON-NLS
249  fullType = "ntuser"; //NON-NLS
250  } else if (regFilePath.toLowerCase().contains("sam")) { //NON-NLS
251  fullType = "sam"; //NON-NLS
252  } else if (regFilePath.toLowerCase().contains("security")) { //NON-NLS
253  fullType = "security"; //NON-NLS
254  } else {
255  return regOutputFiles;
256  }
257 
258  // run the autopsy-specific set of modules
259  if (!autopsyType.isEmpty()) {
260  regOutputFiles.autopsyPlugins = outFilePathBase + "-autopsy.txt"; //NON-NLS
261  String errFilePath = outFilePathBase + "-autopsy.err.txt"; //NON-NLS
262  logger.log(Level.INFO, "Writing RegRipper results to: {0}", regOutputFiles.autopsyPlugins); //NON-NLS
263  executeRegRipper(RR_PATH, rrHome, regFilePath, autopsyType, regOutputFiles.autopsyPlugins, errFilePath);
264  }
265  if (context.dataSourceIngestIsCancelled()) {
266  return regOutputFiles;
267  }
268 
269  // run the full set of rr modules
270  if (!fullType.isEmpty()) {
271  regOutputFiles.fullPlugins = outFilePathBase + "-full.txt"; //NON-NLS
272  String errFilePath = outFilePathBase + "-full.err.txt"; //NON-NLS
273  logger.log(Level.INFO, "Writing Full RegRipper results to: {0}", regOutputFiles.fullPlugins); //NON-NLS
274  executeRegRipper(RR_FULL_PATH, rrFullHome, regFilePath, fullType, regOutputFiles.fullPlugins, errFilePath);
275  }
276  return regOutputFiles;
277  }
278 
279  private void executeRegRipper(String regRipperPath, Path regRipperHomeDir, String hiveFilePath, String hiveFileType, String outputFile, String errFile) {
280  try {
281  List<String> commandLine = new ArrayList<>();
282  commandLine.add(regRipperPath);
283  commandLine.add("-r"); //NON-NLS
284  commandLine.add(hiveFilePath);
285  commandLine.add("-f"); //NON-NLS
286  commandLine.add(hiveFileType);
287 
288  ProcessBuilder processBuilder = new ProcessBuilder(commandLine);
289  processBuilder.directory(regRipperHomeDir.toFile()); // RegRipper 2.8 has to be run from its own directory
290  processBuilder.redirectOutput(new File(outputFile));
291  processBuilder.redirectError(new File(errFile));
292  ExecUtil.execute(processBuilder, new DataSourceIngestModuleProcessTerminator(context));
293  } catch (IOException ex) {
294  logger.log(Level.SEVERE, "Unable to run RegRipper", ex); //NON-NLS
295  this.addErrorMessage(NbBundle.getMessage(this.getClass(), "ExtractRegistry.execRegRip.errMsg.failedAnalyzeRegFile", this.getName()));
296  }
297  }
298 
299  // @@@ VERIFY that we are doing the right thing when we parse multiple NTUSER.DAT
308  private boolean parseAutopsyPluginOutput(String regFilePath, AbstractFile regFile) {
309  FileInputStream fstream = null;
310  try {
311  SleuthkitCase tempDb = currentCase.getSleuthkitCase();
312 
313  // Read the file in and create a Document and elements
314  File regfile = new File(regFilePath);
315  fstream = new FileInputStream(regfile);
316 
317  String regString = new Scanner(fstream, "UTF-8").useDelimiter("\\Z").next(); //NON-NLS
318  String startdoc = "<?xml version=\"1.0\"?><document>"; //NON-NLS
319  String result = regString.replaceAll("----------------------------------------", "");
320  result = result.replaceAll("\\n", ""); //NON-NLS
321  result = result.replaceAll("\\r", ""); //NON-NLS
322  result = result.replaceAll("'", "&apos;"); //NON-NLS
323  result = result.replaceAll("&", "&amp;"); //NON-NLS
324  result = result.replace('\0', ' '); // NON-NLS
325  String enddoc = "</document>"; //NON-NLS
326  String stringdoc = startdoc + result + enddoc;
327  DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
328  Document doc = builder.parse(new InputSource(new StringReader(stringdoc)));
329 
330  // cycle through the elements in the doc
331  Element oroot = doc.getDocumentElement();
332  NodeList children = oroot.getChildNodes();
333  int len = children.getLength();
334  for (int i = 0; i < len; i++) {
335  Element tempnode = (Element) children.item(i);
336 
337  String dataType = tempnode.getNodeName();
338 
339  NodeList timenodes = tempnode.getElementsByTagName("mtime"); //NON-NLS
340  Long mtime = null;
341  if (timenodes.getLength() > 0) {
342  Element timenode = (Element) timenodes.item(0);
343  String etime = timenode.getTextContent();
344  try {
345  Long epochtime = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy").parse(etime).getTime();
346  mtime = epochtime;
347  String Tempdate = mtime.toString();
348  mtime = Long.valueOf(Tempdate) / 1000;
349  } catch (ParseException ex) {
350  logger.log(Level.WARNING, "Failed to parse epoch time when parsing the registry."); //NON-NLS
351  }
352  }
353 
354  NodeList artroots = tempnode.getElementsByTagName("artifacts"); //NON-NLS
355  if (artroots.getLength() == 0) {
356  // If there isn't an artifact node, skip this entry
357  continue;
358  }
359 
360  Element artroot = (Element) artroots.item(0);
361  NodeList myartlist = artroot.getChildNodes();
362  String parentModuleName = NbBundle.getMessage(this.getClass(), "ExtractRegistry.parentModuleName.noSpace");
363  String winver = "";
364 
365  // If all artifact nodes should really go under one Blackboard artifact, need to process it differently
366  switch (dataType) {
367  case "WinVersion": //NON-NLS
368  String version = "";
369  String systemRoot = "";
370  String productId = "";
371  String regOwner = "";
372  String regOrg = "";
373  Long installtime = null;
374  for (int j = 0; j < myartlist.getLength(); j++) {
375  Node artchild = myartlist.item(j);
376  // If it has attributes, then it is an Element (based off API)
377  if (artchild.hasAttributes()) {
378  Element artnode = (Element) artchild;
379 
380  String value = artnode.getTextContent().trim();
381  String name = artnode.getAttribute("name"); //NON-NLS
382  switch (name) {
383  case "ProductName": // NON-NLS
384  version = value;
385  break;
386  case "CSDVersion": // NON-NLS
387  // This is dependant on the fact that ProductName shows up first in the module output
388  version = version + " " + value;
389  break;
390  case "SystemRoot": //NON-NLS
391  systemRoot = value;
392  break;
393  case "ProductId": //NON-NLS
394  productId = value;
395  break;
396  case "RegisteredOwner": //NON-NLS
397  regOwner = value;
398  break;
399  case "RegisteredOrganization": //NON-NLS
400  regOrg = value;
401  break;
402  case "InstallDate": //NON-NLS
403  try {
404  Long epochtime = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy").parse(value).getTime();
405  installtime = epochtime;
406  String Tempdate = installtime.toString();
407  installtime = Long.valueOf(Tempdate) / 1000;
408  } catch (ParseException e) {
409  logger.log(Level.SEVERE, "RegRipper::Conversion on DateTime -> ", e); //NON-NLS
410  } break;
411  default:
412  break;
413  }
414  }
415  } try {
416  Collection<BlackboardAttribute> bbattributes = new ArrayList<>();
417  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PROG_NAME, parentModuleName, version));
418  if (installtime != null) {
419  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DATETIME, parentModuleName, installtime));
420  }
421  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PATH, parentModuleName, systemRoot));
422  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PRODUCT_ID, parentModuleName, productId));
423  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_OWNER, parentModuleName, regOwner));
424  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_ORGANIZATION, parentModuleName, regOrg));
425 
426  // Check if there is already an OS_INFO artifact for this file, and add to that if possible.
427  ArrayList<BlackboardArtifact> results = tempDb.getBlackboardArtifacts(ARTIFACT_TYPE.TSK_OS_INFO, regFile.getId());
428  if (results.isEmpty()) {
429  BlackboardArtifact bbart = regFile.newArtifact(ARTIFACT_TYPE.TSK_OS_INFO);
430  bbart.addAttributes(bbattributes);
431 
432  // index the artifact for keyword search
433  this.indexArtifact(bbart);
434  } else {
435  results.get(0).addAttributes(bbattributes);
436  }
437 
438  } catch (TskCoreException ex) {
439  logger.log(Level.SEVERE, "Error adding installed program artifact to blackboard."); //NON-NLS
440  }
441  break;
442  case "Profiler": // NON-NLS
443  String os = "";
444  String procArch = "";
445  String procId = "";
446  String tempDir = "";
447  for (int j = 0; j < myartlist.getLength(); j++) {
448  Node artchild = myartlist.item(j);
449  // If it has attributes, then it is an Element (based off API)
450  if (artchild.hasAttributes()) {
451  Element artnode = (Element) artchild;
452 
453  String value = artnode.getTextContent().trim();
454  String name = artnode.getAttribute("name"); //NON-NLS
455  switch (name) {
456  case "OS": // NON-NLS
457  os = value;
458  break;
459  case "PROCESSOR_ARCHITECTURE": // NON-NLS
460  procArch = value;
461  break;
462  case "PROCESSOR_IDENTIFIER": //NON-NLS
463  procId = value;
464  break;
465  case "TEMP": //NON-NLS
466  tempDir = value;
467  break;
468  default:
469  break;
470  }
471  }
472  } try {
473  Collection<BlackboardAttribute> bbattributes = new ArrayList<>();
474  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_VERSION, parentModuleName, os));
475  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PROCESSOR_ARCHITECTURE, parentModuleName, procArch));
476  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_TEMP_DIR, parentModuleName, tempDir));
477 
478  // Check if there is already an OS_INFO artifact for this file and add to that if possible
479  ArrayList<BlackboardArtifact> results = tempDb.getBlackboardArtifacts(ARTIFACT_TYPE.TSK_OS_INFO, regFile.getId());
480  if (results.isEmpty()) {
481  BlackboardArtifact bbart = regFile.newArtifact(ARTIFACT_TYPE.TSK_OS_INFO);
482  bbart.addAttributes(bbattributes);
483 
484  // index the artifact for keyword search
485  this.indexArtifact(bbart);
486  } else {
487  results.get(0).addAttributes(bbattributes);
488  }
489  } catch (TskCoreException ex) {
490  logger.log(Level.SEVERE, "Error adding os info artifact to blackboard."); //NON-NLS
491  }
492  break;
493  case "CompName": // NON-NLS
494  String compName = "";
495  String domain = "";
496  for (int j = 0; j < myartlist.getLength(); j++) {
497  Node artchild = myartlist.item(j);
498  // If it has attributes, then it is an Element (based off API)
499  if (artchild.hasAttributes()) {
500  Element artnode = (Element) artchild;
501 
502  String value = artnode.getTextContent().trim();
503  String name = artnode.getAttribute("name"); //NON-NLS
504 
505  if (name.equals("ComputerName")) { // NON-NLS
506  compName = value;
507  } else if (name.equals("Domain")) { // NON-NLS
508  domain = value;
509  }
510  }
511  } try {
512  Collection<BlackboardAttribute> bbattributes = new ArrayList<>();
513  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_NAME, parentModuleName, compName));
514  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DOMAIN, parentModuleName, domain));
515 
516  // Check if there is already an OS_INFO artifact for this file and add to that if possible
517  ArrayList<BlackboardArtifact> results = tempDb.getBlackboardArtifacts(ARTIFACT_TYPE.TSK_OS_INFO, regFile.getId());
518  if (results.isEmpty()) {
519  BlackboardArtifact bbart = regFile.newArtifact(ARTIFACT_TYPE.TSK_OS_INFO);
520  bbart.addAttributes(bbattributes);
521 
522  // index the artifact for keyword search
523  this.indexArtifact(bbart);
524  } else {
525  results.get(0).addAttributes(bbattributes);
526  }
527  } catch (TskCoreException ex) {
528  logger.log(Level.SEVERE, "Error adding os info artifact to blackboard."); //NON-NLS
529  }
530  break;
531  default:
532  for (int j = 0; j < myartlist.getLength(); j++) {
533  Node artchild = myartlist.item(j);
534  // If it has attributes, then it is an Element (based off API)
535  if (artchild.hasAttributes()) {
536  Element artnode = (Element) artchild;
537 
538  String value = artnode.getTextContent().trim();
539  Collection<BlackboardAttribute> bbattributes = new ArrayList<>();
540 
541  switch (dataType) {
542  case "recentdocs": //NON-NLS
543  // BlackboardArtifact bbart = tempDb.getContentById(orgId).newArtifact(ARTIFACT_TYPE.TSK_RECENT_OBJECT);
544  // bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_LAST_ACCESSED.getTypeID(), "RecentActivity", dataType, mtime));
545  // bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_NAME.getTypeID(), "RecentActivity", dataType, mtimeItem));
546  // bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_VALUE.getTypeID(), "RecentActivity", dataType, value));
547  // bbart.addAttributes(bbattributes);
548  // @@@ BC: Why are we ignoring this...
549  break;
550  case "usb": //NON-NLS
551  try {
552  Long usbMtime = Long.parseLong(artnode.getAttribute("mtime")); //NON-NLS
553  usbMtime = Long.valueOf(usbMtime.toString());
554 
555  BlackboardArtifact bbart = regFile.newArtifact(ARTIFACT_TYPE.TSK_DEVICE_ATTACHED);
556  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DATETIME, parentModuleName, usbMtime));
557  String dev = artnode.getAttribute("dev"); //NON-NLS
558  String make = "";
559  String model = dev;
560  if (dev.toLowerCase().contains("vid")) { //NON-NLS
561  USBInfo info = USB_MAPPER.parseAndLookup(dev);
562  if (info.getVendor() != null) {
563  make = info.getVendor();
564  }
565  if (info.getProduct() != null) {
566  model = info.getProduct();
567  }
568  }
569  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DEVICE_MAKE, parentModuleName, make));
570  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DEVICE_MODEL, parentModuleName, model));
571  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DEVICE_ID, parentModuleName, value));
572  bbart.addAttributes(bbattributes);
573 
574  // index the artifact for keyword search
575  this.indexArtifact(bbart);
576  } catch (TskCoreException ex) {
577  logger.log(Level.SEVERE, "Error adding device attached artifact to blackboard."); //NON-NLS
578  }
579  break;
580  case "uninstall": //NON-NLS
581  Long itemMtime = null;
582  try {
583  Long epochtime = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy").parse(artnode.getAttribute("mtime")).getTime(); //NON-NLS
584  itemMtime = epochtime;
585  itemMtime = itemMtime / 1000;
586  } catch (ParseException e) {
587  logger.log(Level.WARNING, "Failed to parse epoch time for installed program artifact."); //NON-NLS
588  }
589 
590  try {
591  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PROG_NAME, parentModuleName, value));
592  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DATETIME, parentModuleName, itemMtime));
593  BlackboardArtifact bbart = regFile.newArtifact(ARTIFACT_TYPE.TSK_INSTALLED_PROG);
594  bbart.addAttributes(bbattributes);
595 
596  // index the artifact for keyword search
597  this.indexArtifact(bbart);
598  } catch (TskCoreException ex) {
599  logger.log(Level.SEVERE, "Error adding installed program artifact to blackboard."); //NON-NLS
600  }
601  break;
602  case "office": //NON-NLS
603  String officeName = artnode.getAttribute("name"); //NON-NLS
604 
605  try {
606  BlackboardArtifact bbart = regFile.newArtifact(ARTIFACT_TYPE.TSK_RECENT_OBJECT);
607  // @@@ BC: Consider removing this after some more testing. It looks like an Mtime associated with the root key and not the individual item
608  if (mtime != null) {
609  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DATETIME_ACCESSED, parentModuleName, mtime));
610  }
611  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_NAME, parentModuleName, officeName));
612  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_VALUE, parentModuleName, value));
613  bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PROG_NAME, parentModuleName, artnode.getNodeName()));
614  bbart.addAttributes(bbattributes);
615 
616  // index the artifact for keyword search
617  this.indexArtifact(bbart);
618  } catch (TskCoreException ex) {
619  logger.log(Level.SEVERE, "Error adding recent object artifact to blackboard."); //NON-NLS
620  }
621  break;
622 
623  case "ProcessorArchitecture": //NON-NLS
624  // Architecture is now included under Profiler
625  //try {
626  // String processorArchitecture = value;
627  // if (processorArchitecture.equals("AMD64"))
628  // processorArchitecture = "x86-64";
629 
630  // BlackboardArtifact bbart = regFile.newArtifact(ARTIFACT_TYPE.TSK_OS_INFO);
631  // bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PROCESSOR_ARCHITECTURE.getTypeID(), parentModuleName, processorArchitecture));
632  // bbart.addAttributes(bbattributes);
633  //} catch (TskCoreException ex) {
634  // logger.log(Level.SEVERE, "Error adding os info artifact to blackboard."); //NON-NLS
635  //}
636  break;
637 
638  case "ProfileList": //NON-NLS
639  try {
640 
641  String homeDir = value;
642  String sid = artnode.getAttribute("sid"); //NON-NLS
643  String username = artnode.getAttribute("username"); //NON-NLS
644 
645  BlackboardArtifact bbart = regFile.newArtifact(ARTIFACT_TYPE.TSK_OS_ACCOUNT);
646  bbart.addAttribute(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_USER_NAME,
647  parentModuleName, username));
648  bbart.addAttribute(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_USER_ID,
649  parentModuleName, sid));
650  bbart.addAttribute(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PATH,
651  parentModuleName, homeDir));
652  // index the artifact for keyword search
653  this.indexArtifact(bbart);
654  } catch (TskCoreException ex) {
655  logger.log(Level.SEVERE, "Error adding account artifact to blackboard."); //NON-NLS
656  }
657  break;
658 
659  case "NtuserNetwork": // NON-NLS
660  try {
661  String localPath = artnode.getAttribute("localPath"); //NON-NLS
662  String remoteName = value;
663  BlackboardArtifact bbart = regFile.newArtifact(ARTIFACT_TYPE.TSK_REMOTE_DRIVE);
664  bbart.addAttribute(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_LOCAL_PATH,
665  parentModuleName, localPath));
666  bbart.addAttribute(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_REMOTE_PATH,
667  parentModuleName, remoteName));
668  // index the artifact for keyword search
669  this.indexArtifact(bbart);
670  } catch (TskCoreException ex) {
671  logger.log(Level.SEVERE, "Error adding network artifact to blackboard."); //NON-NLS
672  }
673  break;
674 
675  case "shellfolders": // NON-NLS
676  // The User Shell Folders subkey stores the paths to Windows Explorer folders for the current user of the computer
677  // (https://technet.microsoft.com/en-us/library/Cc962613.aspx).
678  // No useful information. Skip.
679  break;
680 
681  default:
682  logger.log(Level.WARNING, "Unrecognized node name: {0}", dataType); //NON-NLS
683  break;
684  }
685  }
686  } break;
687  }
688  }
689  return true;
690  } catch (FileNotFoundException ex) {
691  logger.log(Level.SEVERE, "Error finding the registry file."); //NON-NLS
692  } catch (SAXException ex) {
693  logger.log(Level.SEVERE, "Error parsing the registry XML: {0}", ex); //NON-NLS
694  } catch (IOException ex) {
695  logger.log(Level.SEVERE, "Error building the document parser: {0}", ex); //NON-NLS
696  } catch (ParserConfigurationException ex) {
697  logger.log(Level.SEVERE, "Error configuring the registry parser: {0}", ex); //NON-NLS
698  } finally {
699  try {
700  if (fstream != null) {
701  fstream.close();
702  }
703  } catch (IOException ex) {
704  }
705  }
706  return false;
707  }
708 
709  @Override
710  public void process(Content dataSource, IngestJobContext context) {
711  this.dataSource = dataSource;
712  this.context = context;
713  analyzeRegistryFiles();
714  }
715 }

Copyright © 2012-2016 Basis Technology. Generated on: Mon Jan 2 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.