19 package org.sleuthkit.autopsy.modules.stix;
21 import java.util.ArrayList;
28 import java.util.List;
29 import org.mitre.cybox.common_2.ConditionApplicationEnum;
31 import org.mitre.cybox.objects.WindowsNetworkShare;
36 class EvalNetworkShareObj
extends EvaluatableObject {
38 private final WindowsNetworkShare obj;
40 public EvalNetworkShareObj(WindowsNetworkShare a_obj, String a_id, String a_spacing) {
47 public synchronized ObservableResult evaluate() {
51 if ((obj.getNetname() == null) && (obj.getLocalPath() == null)) {
52 return new ObservableResult(
id,
"NetworkShareObjet: No remote name or local path found",
53 spacing, ObservableResult.ObservableState.INDETERMINATE, null);
57 String searchString =
"";
58 if (obj.getNetname() != null) {
59 searchString +=
"Netname \"" + obj.getNetname().getValue() +
"\"";
63 if ((obj.getNetname().getApplyCondition() != null)
64 && (obj.getNetname().getApplyCondition() != ConditionApplicationEnum.ANY)) {
65 addWarning(
"Apply condition " + obj.getNetname().getApplyCondition().value()
66 +
" may not work correctly");
69 if (obj.getLocalPath() != null) {
70 if (!searchString.isEmpty()) {
71 searchString +=
" and ";
73 searchString +=
"LocalPath \"" + obj.getLocalPath().getValue() +
"\"";
77 if ((obj.getLocalPath().getApplyCondition() != null)
78 && (obj.getLocalPath().getApplyCondition() != ConditionApplicationEnum.ANY)) {
79 addWarning(
"Apply condition " + obj.getLocalPath().getApplyCondition().value()
80 +
" may not work correctly");
84 setUnsupportedFieldWarnings();
89 List<BlackboardArtifact> finalHits =
new ArrayList<BlackboardArtifact>();
91 Case case1 = Case.getCurrentCase();
92 SleuthkitCase sleuthkitCase = case1.getSleuthkitCase();
93 List<BlackboardArtifact> artList
94 = sleuthkitCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_REMOTE_DRIVE);
96 for (BlackboardArtifact art : artList) {
97 boolean foundRemotePathMatch =
false;
98 boolean foundLocalPathMatch =
false;
100 for (BlackboardAttribute attr : art.getAttributes()) {
101 if ((attr.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_REMOTE_PATH.getTypeID())
102 && (obj.getNetname() != null)) {
103 foundRemotePathMatch = compareStringObject(obj.getNetname(), attr.getValueString());
105 if ((attr.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_LOCAL_PATH.getTypeID())
106 && (obj.getLocalPath() != null)) {
107 foundLocalPathMatch = compareStringObject(obj.getLocalPath(), attr.getValueString());
112 if (((foundRemotePathMatch) || (obj.getNetname() == null))
113 && ((foundLocalPathMatch) || (obj.getLocalPath() == null))) {
119 if (!finalHits.isEmpty()) {
120 List<StixArtifactData> artData =
new ArrayList<StixArtifactData>();
121 for (BlackboardArtifact a : finalHits) {
122 artData.add(
new StixArtifactData(a.getObjectID(), id,
"NetworkShare"));
124 return new ObservableResult(
id,
"NetworkShareObject: Found a match for " + searchString,
125 spacing, ObservableResult.ObservableState.TRUE, artData);
129 return new ObservableResult(
id,
"NetworkObject: No matches found for " + searchString,
130 spacing, ObservableResult.ObservableState.FALSE, null);
131 }
catch (TskCoreException ex) {
132 return new ObservableResult(
id,
"NetworkObject: Exception during evaluation: " + ex.getLocalizedMessage(),
133 spacing, ObservableResult.ObservableState.INDETERMINATE, null);
137 private void setUnsupportedFieldWarnings() {
138 List<String> fieldNames =
new ArrayList<String>();
140 if (obj.getCurrentUses() != null) {
141 fieldNames.add(
"Current_Uses");
143 if (obj.getMaxUses() != null) {
144 fieldNames.add(
"Max_Uses");
146 if (obj.getType() != null) {
147 fieldNames.add(
"Type");
150 String warningStr =
"";
151 for (String name : fieldNames) {
152 if (!warningStr.isEmpty()) {
158 addWarning(
"Unsupported field(s): " + warningStr);