19 package org.sleuthkit.autopsy.modules.stix;
 
   27 import java.util.List;
 
   28 import java.util.ArrayList;
 
   30 import org.mitre.cybox.objects.AccountObjectType;
 
   31 import org.mitre.cybox.objects.UserAccountObjectType;
 
   32 import org.mitre.cybox.objects.WindowsUserAccount;
 
   37 class EvalAccountObj 
extends EvaluatableObject {
 
   39     private AccountObjectType obj;
 
   41     public EvalAccountObj(AccountObjectType a_obj, String a_id, String a_spacing) {
 
   48     public synchronized ObservableResult evaluate() {
 
   55         if (!(obj instanceof UserAccountObjectType)) {
 
   56             return new ObservableResult(
id, 
"AccountObject: Can not process \"Account\" - need a User_Account or Windows_User_Account", 
 
   57                     spacing, ObservableResult.ObservableState.INDETERMINATE, null);
 
   61         String searchString = 
"";
 
   64         boolean haveHomeDir = 
false;
 
   65         boolean haveUsername = 
false;
 
   66         boolean haveSID = 
false;
 
   68         UserAccountObjectType userAccountObj = (UserAccountObjectType) obj;
 
   69         if (userAccountObj.getHomeDirectory() != null) {
 
   71             searchString = 
"HomeDir \"" + userAccountObj.getHomeDirectory().getValue().toString() + 
"\""; 
 
   73         if (userAccountObj.getUsername() != null) {
 
   75             if (!searchString.isEmpty()) {
 
   76                 searchString += 
" and "; 
 
   78             searchString += 
"Username \"" + userAccountObj.getUsername().getValue().toString() + 
"\""; 
 
   81         WindowsUserAccount winUserObj = null;
 
   82         if (obj instanceof WindowsUserAccount) {
 
   83             winUserObj = (WindowsUserAccount) obj;
 
   85             if (winUserObj.getSecurityID() != null) {
 
   87                 if (!searchString.isEmpty()) {
 
   88                     searchString += 
" and "; 
 
   90                 searchString += 
"SID \"" + winUserObj.getSecurityID().getValue().toString() + 
"\""; 
 
   94         if (!(haveHomeDir || haveUsername || haveSID)) {
 
   95             return new ObservableResult(
id, 
"AccountObject: No evaluatable fields found", 
 
   96                     spacing, ObservableResult.ObservableState.INDETERMINATE, null);
 
  100         setUnsupportedFieldWarnings();
 
  105             List<BlackboardArtifact> finalHits = 
new ArrayList<BlackboardArtifact>();
 
  109             List<BlackboardArtifact> artList
 
  113                 boolean foundHomeDirMatch = 
false;
 
  114                 boolean foundUsernameMatch = 
false;
 
  115                 boolean foundSIDMatch = 
false;
 
  120                         foundHomeDirMatch = compareStringObject(userAccountObj.getHomeDirectory(), attr.getValueString());
 
  124                         foundUsernameMatch = compareStringObject(userAccountObj.getUsername(), attr.getValueString());
 
  127                             && (haveSID) && (winUserObj != null)) {
 
  128                         foundSIDMatch = compareStringObject(winUserObj.getSecurityID(), attr.getValueString());
 
  132                 if (((!haveHomeDir) || foundHomeDirMatch)
 
  133                         && ((!haveUsername) || foundUsernameMatch)
 
  134                         && ((!haveSID) || foundSIDMatch)) {
 
  141             if (!finalHits.isEmpty()) {
 
  142                 List<StixArtifactData> artData = 
new ArrayList<StixArtifactData>();
 
  144                     artData.add(
new StixArtifactData(a.getObjectID(), id, 
"Account")); 
 
  146                 return new ObservableResult(
id, 
"AccountObject: Found a match for " + searchString, 
 
  147                         spacing, ObservableResult.ObservableState.TRUE, artData);
 
  151             return new ObservableResult(
id, 
"AccountObject: No matches found for " + searchString, 
 
  152                     spacing, ObservableResult.ObservableState.FALSE, null);
 
  154             return new ObservableResult(
id, 
"AccountObject: Exception during evaluation: " + ex.getLocalizedMessage(), 
 
  155                     spacing, ObservableResult.ObservableState.INDETERMINATE, null);
 
  163     private void setUnsupportedFieldWarnings() {
 
  164         List<String> fieldNames = 
new ArrayList<String>();
 
  166         if (obj.getDescription() != null) {
 
  167             fieldNames.add(
"Description"); 
 
  169         if (obj.getDomain() != null) {
 
  170             fieldNames.add(
"Domain"); 
 
  172         if (obj.getAuthentications() != null) {
 
  173             fieldNames.add(
"Authentication"); 
 
  175         if (obj.getCreationDate() != null) {
 
  176             fieldNames.add(
"Creation_Date"); 
 
  178         if (obj.getModifiedDate() != null) {
 
  179             fieldNames.add(
"Modified_Date"); 
 
  181         if (obj.getLastAccessedTime() != null) {
 
  182             fieldNames.add(
"Last_Accessed_Time"); 
 
  185         if (obj instanceof UserAccountObjectType) {
 
  186             UserAccountObjectType userAccountObj = (UserAccountObjectType) obj;
 
  187             if (userAccountObj.getFullName() != null) {
 
  188                 fieldNames.add(
"Full_Name"); 
 
  190             if (userAccountObj.getGroupList() != null) {
 
  191                 fieldNames.add(
"Group_List"); 
 
  193             if (userAccountObj.getLastLogin() != null) {
 
  194                 fieldNames.add(
"Last_Login"); 
 
  196             if (userAccountObj.getPrivilegeList() != null) {
 
  197                 fieldNames.add(
"Privilege_List"); 
 
  199             if (userAccountObj.getScriptPath() != null) {
 
  200                 fieldNames.add(
"Script_Path"); 
 
  202             if (userAccountObj.getUserPasswordAge() != null) {
 
  203                 fieldNames.add(
"User_Password_Age"); 
 
  207         if (obj instanceof WindowsUserAccount) {
 
  208             WindowsUserAccount winUserObj = (WindowsUserAccount) obj;
 
  210             if (winUserObj.getSecurityType() != null) {
 
  211                 fieldNames.add(
"Security_Type"); 
 
  215         String warningStr = 
"";
 
  216         for (String name : fieldNames) {
 
  217             if (!warningStr.isEmpty()) {
 
  223         addWarning(
"Unsupported field(s): " + warningStr); 
 
ArrayList< BlackboardArtifact > getBlackboardArtifacts(int artifactTypeID)
static Case getCurrentCase()