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;
 
   37 class EvalNetworkShareObj 
extends EvaluatableObject {
 
   39     private final WindowsNetworkShare obj;
 
   41     public EvalNetworkShareObj(WindowsNetworkShare a_obj, String a_id, String a_spacing) {
 
   48     public synchronized ObservableResult evaluate() {
 
   52         if ((obj.getNetname() == null) && (obj.getLocalPath() == null)) {
 
   53             return new ObservableResult(
id, 
"NetworkShareObjet: No remote name or local path found", 
 
   54                     spacing, ObservableResult.ObservableState.INDETERMINATE, null);
 
   58         String searchString = 
"";
 
   59         if (obj.getNetname() != null) {
 
   60             searchString += 
"Netname \"" + obj.getNetname().getValue() + 
"\""; 
 
   64             if ((obj.getNetname().getApplyCondition() != null)
 
   65                     && (obj.getNetname().getApplyCondition() != ConditionApplicationEnum.ANY)) {
 
   66                 addWarning(
"Apply condition " + obj.getNetname().getApplyCondition().value() 
 
   67                         + 
" may not work correctly"); 
 
   70         if (obj.getLocalPath() != null) {
 
   71             if (!searchString.isEmpty()) {
 
   72                 searchString += 
" and "; 
 
   74             searchString += 
"LocalPath \"" + obj.getLocalPath().getValue() + 
"\""; 
 
   78             if ((obj.getLocalPath().getApplyCondition() != null)
 
   79                     && (obj.getLocalPath().getApplyCondition() != ConditionApplicationEnum.ANY)) {
 
   80                 addWarning(
"Apply condition " + obj.getLocalPath().getApplyCondition().value() 
 
   81                         + 
" may not work correctly"); 
 
   85         setUnsupportedFieldWarnings();
 
   90             List<BlackboardArtifact> finalHits = 
new ArrayList<BlackboardArtifact>();
 
   92             Case case1 = Case.getCurrentCaseThrows();
 
   93             SleuthkitCase sleuthkitCase = case1.getSleuthkitCase();
 
   94             List<BlackboardArtifact> artList
 
   95                     = sleuthkitCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_REMOTE_DRIVE);
 
   97             for (BlackboardArtifact art : artList) {
 
   98                 boolean foundRemotePathMatch = 
false;
 
   99                 boolean foundLocalPathMatch = 
false;
 
  101                 for (BlackboardAttribute attr : art.getAttributes()) {
 
  102                     if ((attr.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_REMOTE_PATH.getTypeID())
 
  103                             && (obj.getNetname() != null)) {
 
  104                         foundRemotePathMatch = compareStringObject(obj.getNetname(), attr.getValueString());
 
  106                     if ((attr.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_LOCAL_PATH.getTypeID())
 
  107                             && (obj.getLocalPath() != null)) {
 
  108                         foundLocalPathMatch = compareStringObject(obj.getLocalPath(), attr.getValueString());
 
  113                 if (((foundRemotePathMatch) || (obj.getNetname() == null))
 
  114                         && ((foundLocalPathMatch) || (obj.getLocalPath() == null))) {
 
  120             if (!finalHits.isEmpty()) {
 
  121                 List<StixArtifactData> artData = 
new ArrayList<StixArtifactData>();
 
  122                 for (BlackboardArtifact a : finalHits) {
 
  123                     artData.add(
new StixArtifactData(a.getObjectID(), id, 
"NetworkShare")); 
 
  125                 return new ObservableResult(
id, 
"NetworkShareObject: Found a match for " + searchString, 
 
  126                         spacing, ObservableResult.ObservableState.TRUE, artData);
 
  130             return new ObservableResult(
id, 
"NetworkObject: No matches found for " + searchString, 
 
  131                     spacing, ObservableResult.ObservableState.FALSE, null);
 
  132         } 
catch (TskCoreException | NoCurrentCaseException ex) {
 
  133             return new ObservableResult(
id, 
"NetworkObject: Exception during evaluation: " + ex.getLocalizedMessage(), 
 
  134                     spacing, ObservableResult.ObservableState.INDETERMINATE, null);
 
  138     private void setUnsupportedFieldWarnings() {
 
  139         List<String> fieldNames = 
new ArrayList<String>();
 
  141         if (obj.getCurrentUses() != null) {
 
  142             fieldNames.add(
"Current_Uses"); 
 
  144         if (obj.getMaxUses() != null) {
 
  145             fieldNames.add(
"Max_Uses"); 
 
  147         if (obj.getType() != null) {
 
  148             fieldNames.add(
"Type"); 
 
  151         String warningStr = 
"";
 
  152         for (String name : fieldNames) {
 
  153             if (!warningStr.isEmpty()) {
 
  159         addWarning(
"Unsupported field(s): " + warningStr);