Autopsy  4.4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
EvalDomainObj.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.modules.stix;
20 
21 import java.util.ArrayList;
22 import java.util.List;
23 import org.mitre.cybox.common_2.ConditionApplicationEnum;
24 import org.mitre.cybox.common_2.ConditionTypeEnum;
25 import org.mitre.cybox.objects.DomainName;
26 import org.sleuthkit.datamodel.BlackboardArtifact;
27 import org.sleuthkit.datamodel.BlackboardAttribute;
28 import org.sleuthkit.datamodel.TskCoreException;
30 import org.sleuthkit.datamodel.SleuthkitCase;
31 
35 class EvalDomainObj extends EvaluatableObject {
36 
37  private final DomainName obj;
38 
39  public EvalDomainObj(DomainName a_obj, String a_id, String a_spacing) {
40  obj = a_obj;
41  id = a_id;
42  spacing = a_spacing;
43  }
44 
45  @Override
46  public synchronized ObservableResult evaluate() {
47 
48  setWarnings("");
49 
50  if (obj.getValue() == null) {
51  return new ObservableResult(id, "DomainObject: No domain value field found", //NON-NLS
52  spacing, ObservableResult.ObservableState.INDETERMINATE, null);
53  }
54 
55  // Since we have single URL artifacts, ALL and NONE conditions probably don't make sense to test
56  if (!((obj.getValue().getApplyCondition() == null)
57  || (obj.getValue().getApplyCondition() == ConditionApplicationEnum.ANY))) {
58  return new ObservableResult(id, "DomainObject: Can not process apply condition " + obj.getValue().getApplyCondition().toString() //NON-NLS
59  + " on Domain object", spacing, ObservableResult.ObservableState.INDETERMINATE, null); //NON-NLS
60  }
61 
62  // If the condition is not "CONTAINS", add a warning that it's being ignored
63  if ((obj.getValue().getCondition() != null)
64  && (obj.getValue().getCondition() != ConditionTypeEnum.CONTAINS)) {
65  addWarning("Warning: Ignoring condition " + obj.getValue().getCondition().toString() //NON-NLS
66  + " on DomainName - using substring comparison"); //NON-NLS
67  }
68 
69  Case case1 = Case.getCurrentCase();
70  SleuthkitCase sleuthkitCase = case1.getSleuthkitCase();
71 
72  try {
73  // Set up the list of matching artifacts
74  List<BlackboardArtifact> finalHits = new ArrayList<BlackboardArtifact>();
75 
76  // Get all the URL artifacts
77  List<BlackboardArtifact> artList
78  = sleuthkitCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT);
79 
80  for (BlackboardArtifact art : artList) {
81 
82  for (BlackboardAttribute attr : art.getAttributes()) {
83  if (attr.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD.getTypeID()) {
84  String url = attr.getValueString();
85 
86  // Check whether the domain name is a substring of the URL (regardless
87  // of the condition on the domain name object)
88  if (compareStringObject(obj.getValue().getValue().toString(), ConditionTypeEnum.CONTAINS,
89  obj.getValue().getApplyCondition(), url)) {
90  finalHits.add(art);
91  }
92  }
93  }
94  }
95 
96  if (!finalHits.isEmpty()) {
97  List<StixArtifactData> artData = new ArrayList<StixArtifactData>();
98  for (BlackboardArtifact a : finalHits) {
99  artData.add(new StixArtifactData(a.getObjectID(), id, "DomainNameObject")); //NON-NLS
100  }
101  return new ObservableResult(id, "DomainNameObject: Found a match for " + obj.getValue().getValue().toString() //NON-NLS
102  + " " + getPrintableWarnings(),
103  spacing, ObservableResult.ObservableState.TRUE, artData);
104  }
105 
106  return new ObservableResult(id, "DomainNameObject: Found no matches for " + obj.getValue().getValue().toString() //NON-NLS
107  + " " + getPrintableWarnings(),
108  spacing, ObservableResult.ObservableState.FALSE, null);
109  } catch (TskCoreException ex) {
110  return new ObservableResult(id, "DomainNameObject: Exception during evaluation: " + ex.getLocalizedMessage(), //NON-NLS
111  spacing, ObservableResult.ObservableState.INDETERMINATE, null);
112  }
113 
114  }
115 
116 }

Copyright © 2012-2016 Basis Technology. Generated on: Fri Sep 29 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.