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();
102 List<BlackboardArtifact> finalHits =
new ArrayList<BlackboardArtifact>();
105 List<BlackboardArtifact> artList
106 = sleuthkitCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT);
108 for (BlackboardArtifact art : artList) {
110 for (BlackboardAttribute attr : art.getAttributes()) {
111 if (attr.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD.getTypeID()) {
113 String modifiedAttrString = attr.getValueString();
114 if (modifiedAttrString != null) {
115 modifiedAttrString = modifiedAttrString.toLowerCase();
116 modifiedAttrString = modifiedAttrString.replaceAll(
"http(s)?://",
"");
119 if (compareStringObject(modifiedAddressStr, obj.getValue().getCondition(),
120 obj.getValue().getApplyCondition(), modifiedAttrString)) {
127 if (!finalHits.isEmpty()) {
128 List<StixArtifactData> artData =
new ArrayList<StixArtifactData>();
129 for (BlackboardArtifact a : finalHits) {
130 artData.add(
new StixArtifactData(a.getObjectID(), id,
"UriObject"));
132 return new ObservableResult(
id,
"UriObject: Found a match for " + addressStr,
133 spacing, ObservableResult.ObservableState.TRUE, artData);
136 return new ObservableResult(
id,
"URIObject: Found no matches for " + addressStr,
137 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);