19 package org.sleuthkit.autopsy.test;
21 import java.util.logging.Level;
23 import org.openide.util.Exceptions;
24 import org.openide.util.NbBundle;
40 "InterestingArtifactCreatorIngestModule.exceptionMessage.errorCreatingCustomType=Error creating custom artifact type."
42 final class InterestingArtifactCreatorIngestModule extends FileIngestModuleAdapter {
44 private static final Logger logger = Logger.getLogger(InterestingArtifactCreatorIngestModule.class.getName());
45 private static final String MODULE_NAME = InterestingArtifactCreatorIngestModuleFactory.getModuleName();
46 private static final String[] ARTIFACT_TYPE_NAMES = {
"TSK_WEB_BOOKMARK",
"TSK_KEYWORD_HIT",
"TSK_CALLLOG"};
47 private static final String[] ARTIFACT_DISPLAY_NAMES = {
"Web Bookmarks",
"Keyword Hits",
"Call Logs"};
48 private static final String INT_ARTIFACT_TYPE_NAME = BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getLabel();
49 private static final String INT_ARTIFACT_DISPLAY_NAME = BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getDisplayName();
50 private BlackboardArtifact.Type artifactType;
53 public void startUp(IngestJobContext context)
throws IngestModuleException {
54 Blackboard blackboard = Case.getCurrentCase().getServices().getBlackboard();
56 artifactType = blackboard.getOrAddArtifactType(INT_ARTIFACT_TYPE_NAME, INT_ARTIFACT_DISPLAY_NAME);
57 }
catch (Blackboard.BlackboardException ex) {
58 throw new IngestModuleException(Bundle.InterestingArtifactCreatorIngestModule_exceptionMessage_errorCreatingCustomType(), ex);
63 public ProcessResult process(AbstractFile file) {
67 if (file.isDir() || file.isVirtual()) {
68 return ProcessResult.OK;
76 int randomArtIndex = (int) (Math.random() * 3);
77 Blackboard blackboard = Case.getCurrentCase().getServices().getBlackboard();
78 BlackboardArtifact.Type artifactTypeBase = blackboard.getOrAddArtifactType(ARTIFACT_TYPE_NAMES[randomArtIndex], ARTIFACT_DISPLAY_NAMES[randomArtIndex]);
79 BlackboardArtifact artifactBase = file.newArtifact(artifactTypeBase.getTypeID());
81 BlackboardAttribute baseAttr;
82 switch (artifactBase.getArtifactTypeID()) {
84 commentTxt =
"www.placeholderWebsiteDOTCOM";
85 baseAttr =
new BlackboardAttribute(
86 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL,
"Fake Web BookMark",
"www.thisWebsiteIsStillFake.com");
87 artifactBase.addAttribute(baseAttr);
90 commentTxt =
"fakeKeyword";
91 baseAttr =
new BlackboardAttribute(
92 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD_PREVIEW,
"Fake Keyword Search",
"Fake Keyword Preview Text");
93 BlackboardAttribute set =
new BlackboardAttribute(
94 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME,
"Fake Keyword Search",
"Fake");
95 BlackboardAttribute keyword =
new BlackboardAttribute(
96 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD,
"Fake Keyword Search",
"FakeKeyword");
97 artifactBase.addAttribute(baseAttr);
98 artifactBase.addAttribute(set);
99 artifactBase.addAttribute(keyword);
102 commentTxt =
"fake phone number from";
103 baseAttr =
new BlackboardAttribute(
104 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM,
"Fake Call Log Whatever",
"555-555-5555");
105 artifactBase.addAttribute(baseAttr);
108 commentTxt =
"DEPENDENT ON ARTIFACT TYPE";
111 BlackboardArtifact artifact = file.newArtifact(artifactType.getTypeID());
112 BlackboardAttribute att =
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME, MODULE_NAME,
"ArtifactsAndTxt");
114 BlackboardAttribute att2 =
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_COMMENT, MODULE_NAME, commentTxt);
115 BlackboardAttribute att3 =
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_CATEGORY, MODULE_NAME,
"");
116 artifact.addAttribute(att);
117 artifact.addAttribute(att2);
118 artifact.addAttribute(att3);
119 artifact.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT, MODULE_NAME, artifactBase.getArtifactID()));
120 }
catch (TskCoreException ex) {
121 logger.log(Level.SEVERE, String.format(
"Failed to process file (obj_id = %d)", file.getId()), ex);
122 return ProcessResult.ERROR;
123 }
catch (Blackboard.BlackboardException ex) {
124 Exceptions.printStackTrace(ex);
126 return ProcessResult.OK;