19 package org.sleuthkit.autopsy.report.modules.stix;
27 import java.util.List;
28 import java.util.ArrayList;
29 import org.mitre.cybox.common_2.ConditionApplicationEnum;
31 import org.mitre.cybox.objects.URIObjectType;
37 class EvalURIObj
extends EvaluatableObject {
39 private final URIObjectType obj;
41 public EvalURIObj(URIObjectType a_obj, String a_id, String a_spacing) {
48 public synchronized ObservableResult evaluate() {
52 if (obj.getValue() == null) {
53 return new ObservableResult(
id,
"URIObject: No URI value field found",
54 spacing, ObservableResult.ObservableState.INDETERMINATE, null);
59 case1 = Case.getCurrentCaseThrows();
60 }
catch (NoCurrentCaseException ex) {
61 return new ObservableResult(
id,
"Exception while getting open case: " + ex.getLocalizedMessage(),
62 spacing, ObservableResult.ObservableState.FALSE, null);
65 String addressStr = obj.getValue().getValue().toString();
68 String modifiedAddressStr = addressStr.toLowerCase();
69 modifiedAddressStr = modifiedAddressStr.replaceAll(
"http(s)?://",
"");
72 if (!((obj.getValue().getApplyCondition() == null)
73 || (obj.getValue().getApplyCondition() == ConditionApplicationEnum.ANY))) {
74 return new ObservableResult(
id,
"URIObject: Can not process apply condition " + obj.getValue().getApplyCondition().toString()
75 +
" on URI object", spacing, ObservableResult.ObservableState.INDETERMINATE, null);
78 SleuthkitCase sleuthkitCase = case1.getSleuthkitCase();
111 List<BlackboardArtifact> finalHits =
new ArrayList<BlackboardArtifact>();
114 List<BlackboardArtifact> artList
115 = sleuthkitCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT);
117 for (BlackboardArtifact art : artList) {
119 for (BlackboardAttribute attr : art.getAttributes()) {
120 if (attr.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD.getTypeID()) {
122 String modifiedAttrString = attr.getValueString();
123 if (modifiedAttrString != null) {
124 modifiedAttrString = modifiedAttrString.toLowerCase();
125 modifiedAttrString = modifiedAttrString.replaceAll(
"http(s)?://",
"");
128 if (compareStringObject(modifiedAddressStr, obj.getValue().getCondition(),
129 obj.getValue().getApplyCondition(), modifiedAttrString)) {
136 if (!finalHits.isEmpty()) {
137 List<StixArtifactData> artData =
new ArrayList<StixArtifactData>();
138 for (BlackboardArtifact a : finalHits) {
139 artData.add(
new StixArtifactData(a.getObjectID(), id,
"UriObject"));
141 return new ObservableResult(
id,
"UriObject: Found a match for " + addressStr,
142 spacing, ObservableResult.ObservableState.TRUE, artData);
145 return new ObservableResult(
id,
"URIObject: Found no matches for " + addressStr,
146 spacing, ObservableResult.ObservableState.FALSE, null);
151 }
catch (TskCoreException ex) {
152 return new ObservableResult(
id,
"URIObject: Exception during evaluation: " + ex.getLocalizedMessage(),
153 spacing, ObservableResult.ObservableState.INDETERMINATE, null);