19 package org.sleuthkit.autopsy.test;
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.logging.Level;
24 import org.openide.util.NbBundle;
41 "InterestingArtifactCreatorIngestModule.exceptionMessage.errorCreatingCustomType=Error creating custom artifact type."
43 final class InterestingArtifactCreatorIngestModule extends FileIngestModuleAdapter {
45 private static final Logger logger = Logger.getLogger(InterestingArtifactCreatorIngestModule.class.getName());
46 private static final String MODULE_NAME = InterestingArtifactCreatorIngestModuleFactory.getModuleName();
47 private static final String[] ARTIFACT_TYPE_NAMES = {
"TSK_WEB_BOOKMARK",
"TSK_KEYWORD_HIT",
"TSK_CALLLOG"};
48 private static final String[] ARTIFACT_DISPLAY_NAMES = {
"Web Bookmarks",
"Keyword Hits",
"Call Logs"};
49 private static final String INT_ARTIFACT_TYPE_NAME = BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getLabel();
50 private static final String INT_ARTIFACT_DISPLAY_NAME = BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getDisplayName();
51 private BlackboardArtifact.Type artifactType;
54 public void startUp(IngestJobContext context)
throws IngestModuleException {
56 Blackboard blackboard = Case.getCurrentCaseThrows().getServices().getArtifactsBlackboard();
57 artifactType = blackboard.getOrAddArtifactType(INT_ARTIFACT_TYPE_NAME, INT_ARTIFACT_DISPLAY_NAME);
58 }
catch (Blackboard.BlackboardException | NoCurrentCaseException ex) {
59 throw new IngestModuleException(Bundle.InterestingArtifactCreatorIngestModule_exceptionMessage_errorCreatingCustomType(), ex);
64 public ProcessResult process(AbstractFile file) {
68 if (file.isDir() || file.isVirtual()) {
69 return ProcessResult.OK;
77 int randomArtIndex = (int) (Math.random() * 3);
78 Blackboard blackboard = Case.getCurrentCaseThrows().getServices().getArtifactsBlackboard();
79 BlackboardArtifact.Type artifactTypeBase = blackboard.getOrAddArtifactType(ARTIFACT_TYPE_NAMES[randomArtIndex], ARTIFACT_DISPLAY_NAMES[randomArtIndex]);
80 BlackboardArtifact artifactBase = file.newArtifact(artifactTypeBase.getTypeID());
81 Collection<BlackboardAttribute> baseAttributes =
new ArrayList<>();
83 BlackboardAttribute baseAttr;
84 switch (artifactBase.getArtifactTypeID()) {
86 commentTxt =
"www.placeholderWebsiteDOTCOM";
87 baseAttr =
new BlackboardAttribute(
88 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL,
"Fake Web BookMark",
"www.thisWebsiteIsStillFake.com");
89 baseAttributes.add(baseAttr);
92 commentTxt =
"fakeKeyword";
93 baseAttr =
new BlackboardAttribute(
94 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD_PREVIEW,
"Fake Keyword Search",
"Fake Keyword Preview Text");
95 BlackboardAttribute set =
new BlackboardAttribute(
96 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME,
"Fake Keyword Search",
"Fake");
97 BlackboardAttribute keyword =
new BlackboardAttribute(
98 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD,
"Fake Keyword Search",
"FakeKeyword");
99 baseAttributes.add(baseAttr);
100 baseAttributes.add(set);
101 baseAttributes.add(keyword);
104 commentTxt =
"fake phone number from";
105 baseAttr =
new BlackboardAttribute(
106 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM,
"Fake Call Log Whatever",
"555-555-5555");
107 baseAttributes.add(baseAttr);
110 commentTxt =
"DEPENDENT ON ARTIFACT TYPE";
113 artifactBase.addAttributes(baseAttributes);
114 BlackboardArtifact artifact = file.newArtifact(artifactType.getTypeID());
115 Collection<BlackboardAttribute> attributes =
new ArrayList<>();
116 BlackboardAttribute att =
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME, MODULE_NAME,
"ArtifactsAndTxt");
118 BlackboardAttribute att2 =
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_COMMENT, MODULE_NAME, commentTxt);
119 BlackboardAttribute att3 =
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_CATEGORY, MODULE_NAME,
"");
121 attributes.add(att2);
122 attributes.add(att3);
123 attributes.add(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT, MODULE_NAME, artifactBase.getArtifactID()));
124 artifact.addAttributes(attributes);
125 }
catch (TskCoreException | NoCurrentCaseException ex) {
126 logger.log(Level.SEVERE, String.format(
"Failed to process file (obj_id = %d)", file.getId()), ex);
127 return ProcessResult.ERROR;
128 }
catch (Blackboard.BlackboardException ex) {
129 logger.log(Level.WARNING,
"Blackboard Exception processing file with obj_id = " + file.getId(), ex);
131 return ProcessResult.OK;