19 package org.sleuthkit.autopsy.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;
36 class EvalURIObj
extends EvaluatableObject {
38 private final URIObjectType obj;
40 public EvalURIObj(URIObjectType a_obj, String a_id, String a_spacing) {
47 public synchronized ObservableResult evaluate() {
51 if (obj.getValue() == null) {
52 return new ObservableResult(
id,
"URIObject: No URI value field found",
53 spacing, ObservableResult.ObservableState.INDETERMINATE, null);
55 String addressStr = obj.getValue().getValue().toString();
58 String modifiedAddressStr = addressStr.toLowerCase();
59 modifiedAddressStr = modifiedAddressStr.replaceAll(
"http(s)?://",
"");
62 if (!((obj.getValue().getApplyCondition() == null)
63 || (obj.getValue().getApplyCondition() == ConditionApplicationEnum.ANY))) {
64 return new ObservableResult(
id,
"URIObject: Can not process apply condition " + obj.getValue().getApplyCondition().toString()
65 +
" on URI object", spacing, ObservableResult.ObservableState.INDETERMINATE, null);
68 Case case1 = Case.getCurrentCase();
69 SleuthkitCase sleuthkitCase = case1.getSleuthkitCase();
104 List<BlackboardArtifact> finalHits =
new ArrayList<BlackboardArtifact>();
107 List<BlackboardArtifact> artList
108 = sleuthkitCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT);
110 for (BlackboardArtifact art : artList) {
112 for (BlackboardAttribute attr : art.getAttributes()) {
113 if (attr.getAttributeTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD.getTypeID()) {
115 String modifiedAttrString = attr.getValueString();
116 if (modifiedAttrString != null) {
117 modifiedAttrString = modifiedAttrString.toLowerCase();
118 modifiedAttrString = modifiedAttrString.replaceAll(
"http(s)?://",
"");
121 if (compareStringObject(modifiedAddressStr, obj.getValue().getCondition(),
122 obj.getValue().getApplyCondition(), modifiedAttrString)) {
129 if (!finalHits.isEmpty()) {
130 List<StixArtifactData> artData =
new ArrayList<StixArtifactData>();
131 for (BlackboardArtifact a : finalHits) {
132 artData.add(
new StixArtifactData(a.getObjectID(), id,
"UriObject"));
134 return new ObservableResult(
id,
"UriObject: Found a match for " + addressStr,
135 spacing, ObservableResult.ObservableState.TRUE, artData);
138 return new ObservableResult(
id,
"URIObject: Found no matches for " + addressStr,
139 spacing, ObservableResult.ObservableState.FALSE, null);
142 }
catch (TskCoreException ex) {
143 return new ObservableResult(
id,
"URIObject: Exception during evaluation: " + ex.getLocalizedMessage(),
144 spacing, ObservableResult.ObservableState.INDETERMINATE, null);