Autopsy  4.10.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
InterestingArtifactCreatorIngestModule.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2018 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.test;
20 
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.logging.Level;
24 
25 import org.openide.util.Exceptions;
26 import org.openide.util.NbBundle;
33 import org.sleuthkit.datamodel.AbstractFile;
34 import org.sleuthkit.datamodel.BlackboardArtifact;
35 import org.sleuthkit.datamodel.BlackboardAttribute;
36 import org.sleuthkit.datamodel.TskCoreException;
37 
42 @NbBundle.Messages({
43  "InterestingArtifactCreatorIngestModule.exceptionMessage.errorCreatingCustomType=Error creating custom artifact type."
44 })
45 final class InterestingArtifactCreatorIngestModule extends FileIngestModuleAdapter {
46 
47  private static final Logger logger = Logger.getLogger(InterestingArtifactCreatorIngestModule.class.getName());
48  private static final String MODULE_NAME = InterestingArtifactCreatorIngestModuleFactory.getModuleName();
49  private static final String[] ARTIFACT_TYPE_NAMES = {"TSK_WEB_BOOKMARK", "TSK_KEYWORD_HIT", "TSK_CALLLOG"};
50  private static final String[] ARTIFACT_DISPLAY_NAMES = {"Web Bookmarks", "Keyword Hits", "Call Logs"};
51  private static final String INT_ARTIFACT_TYPE_NAME = BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getLabel();
52  private static final String INT_ARTIFACT_DISPLAY_NAME = BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getDisplayName();
53  private BlackboardArtifact.Type artifactType;
54 
55  @Override
56  public void startUp(IngestJobContext context) throws IngestModuleException {
57  try {
58  Blackboard blackboard = Case.getCurrentCaseThrows().getServices().getBlackboard();
59  artifactType = blackboard.getOrAddArtifactType(INT_ARTIFACT_TYPE_NAME, INT_ARTIFACT_DISPLAY_NAME);
60  } catch (Blackboard.BlackboardException | NoCurrentCaseException ex) {
61  throw new IngestModuleException(Bundle.InterestingArtifactCreatorIngestModule_exceptionMessage_errorCreatingCustomType(), ex);
62  }
63  }
64 
65  @Override
66  public ProcessResult process(AbstractFile file) {
67  /*
68  * Skip directories and virtual files.
69  */
70  if (file.isDir() || file.isVirtual()) {
71  return ProcessResult.OK;
72  }
73 
74  try {
75  /*
76  * Add a custom artifact with one custom attribute of each value
77  * type.
78  */
79  int randomArtIndex = (int) (Math.random() * 3);
80  Blackboard blackboard = Case.getCurrentCaseThrows().getServices().getBlackboard();
81  BlackboardArtifact.Type artifactTypeBase = blackboard.getOrAddArtifactType(ARTIFACT_TYPE_NAMES[randomArtIndex], ARTIFACT_DISPLAY_NAMES[randomArtIndex]);
82  BlackboardArtifact artifactBase = file.newArtifact(artifactTypeBase.getTypeID());
83  Collection<BlackboardAttribute> baseAttributes = new ArrayList<>();
84  String commentTxt;
85  BlackboardAttribute baseAttr;
86  switch (artifactBase.getArtifactTypeID()) {
87  case 2:
88  commentTxt = "www.placeholderWebsiteDOTCOM";
89  baseAttr = new BlackboardAttribute(
90  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL, "Fake Web BookMark", "www.thisWebsiteIsStillFake.com");
91  baseAttributes.add(baseAttr);
92  break;
93  case 9:
94  commentTxt = "fakeKeyword";
95  baseAttr = new BlackboardAttribute(
96  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD_PREVIEW, "Fake Keyword Search", "Fake Keyword Preview Text");
97  BlackboardAttribute set = new BlackboardAttribute(
98  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME, "Fake Keyword Search", "Fake");
99  BlackboardAttribute keyword = new BlackboardAttribute(
100  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD, "Fake Keyword Search", "FakeKeyword");
101  baseAttributes.add(baseAttr);
102  baseAttributes.add(set);
103  baseAttributes.add(keyword);
104  break;
105  case 25:
106  commentTxt = "fake phone number from";
107  baseAttr = new BlackboardAttribute(
108  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM, "Fake Call Log Whatever", "555-555-5555");
109  baseAttributes.add(baseAttr);
110  break;
111  default:
112  commentTxt = "DEPENDENT ON ARTIFACT TYPE";
113  break;
114  }
115  artifactBase.addAttributes(baseAttributes);
116  BlackboardArtifact artifact = file.newArtifact(artifactType.getTypeID());
117  Collection<BlackboardAttribute> attributes = new ArrayList<>();
118  BlackboardAttribute att = new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME, MODULE_NAME, "ArtifactsAndTxt");
119 
120  BlackboardAttribute att2 = new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_COMMENT, MODULE_NAME, commentTxt);
121  BlackboardAttribute att3 = new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_CATEGORY, MODULE_NAME, "");
122  attributes.add(att);
123  attributes.add(att2);
124  attributes.add(att3);
125  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT, MODULE_NAME, artifactBase.getArtifactID()));
126  artifact.addAttributes(attributes);
127  } catch (TskCoreException | NoCurrentCaseException ex) {
128  logger.log(Level.SEVERE, String.format("Failed to process file (obj_id = %d)", file.getId()), ex);
129  return ProcessResult.ERROR;
130  } catch (Blackboard.BlackboardException ex) {
131  Exceptions.printStackTrace(ex);
132  }
133  return ProcessResult.OK;
134  }
135 
136 }

Copyright © 2012-2018 Basis Technology. Generated on: Fri Mar 22 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.