19 package org.sleuthkit.autopsy.modules.stix;
29 import java.util.List;
30 import java.util.ArrayList;
32 import org.mitre.cybox.objects.SystemObjectType;
33 import org.mitre.cybox.objects.WindowsSystem;
39 class EvalSystemObj
extends EvaluatableObject {
41 private final SystemObjectType obj;
43 public EvalSystemObj(SystemObjectType a_obj, String a_id, String a_spacing) {
50 public synchronized ObservableResult evaluate() {
55 String searchString =
"";
58 boolean haveHostname =
false;
60 boolean haveProcArch =
false;
61 boolean haveTempDir =
false;
62 boolean haveProductName =
false;
63 boolean haveSystemRoot =
false;
64 boolean haveProductID =
false;
65 boolean haveOwner =
false;
66 boolean haveOrganization =
false;
68 if (obj.getHostname() != null) {
70 searchString =
"Hostname \"" + obj.getHostname().getValue().toString() +
"\"";
72 if (obj.getProcessorArchitecture() != null) {
74 if (!searchString.isEmpty()) {
75 searchString +=
" and ";
77 searchString +=
"Processor architecture \"" + obj.getProcessorArchitecture().getValue().toString() +
"\"";
80 WindowsSystem winSysObj = null;
81 if (obj instanceof WindowsSystem) {
82 winSysObj = (WindowsSystem) obj;
84 if (winSysObj.getProductID() != null) {
86 if (!searchString.isEmpty()) {
87 searchString +=
" and ";
89 searchString +=
"Product ID \"" + winSysObj.getProductID().getValue().toString() +
"\"";
91 if (winSysObj.getProductName() != null) {
92 haveProductName =
true;
93 if (!searchString.isEmpty()) {
94 searchString +=
" and ";
96 searchString +=
"Product Name \"" + winSysObj.getProductName().getValue().toString() +
"\"";
98 if (winSysObj.getRegisteredOrganization() != null) {
99 haveOrganization =
true;
100 if (!searchString.isEmpty()) {
101 searchString +=
" and ";
103 searchString +=
"Registered Org \"" + winSysObj.getRegisteredOrganization().getValue().toString() +
"\"";
105 if (winSysObj.getRegisteredOwner() != null) {
107 if (!searchString.isEmpty()) {
108 searchString +=
" and ";
110 searchString +=
"Registered Owner \"" + winSysObj.getRegisteredOwner().getValue().toString() +
"\"";
112 if (winSysObj.getWindowsSystemDirectory() != null) {
113 haveSystemRoot =
true;
114 if (!searchString.isEmpty()) {
115 searchString +=
" and ";
117 searchString +=
"System root \"" + winSysObj.getWindowsSystemDirectory().getValue().toString() +
"\"";
119 if (winSysObj.getWindowsTempDirectory() != null) {
121 if (!searchString.isEmpty()) {
122 searchString +=
" and ";
124 searchString +=
"Temp dir \"" + winSysObj.getWindowsTempDirectory().getValue().toString() +
"\"";
129 if (!(haveHostname || haveProcArch
130 || haveTempDir || haveProductName || haveSystemRoot || haveProductID
131 || haveOwner || haveOrganization)) {
132 return new ObservableResult(
id,
"SystemObject: No evaluatable fields found",
133 spacing, ObservableResult.ObservableState.INDETERMINATE, null);
136 setUnsupportedFieldWarnings();
139 Case case1 = Case.getCurrentCaseThrows();
140 SleuthkitCase sleuthkitCase = case1.getSleuthkitCase();
141 List<OSInfo> osInfoList = OSUtility.getOSInfo(sleuthkitCase);
143 List<BlackboardArtifact> finalHits =
new ArrayList<BlackboardArtifact>();
145 if (!osInfoList.isEmpty()) {
146 for (OSInfo info : osInfoList) {
148 boolean foundHostnameMatch =
false;
150 boolean foundProcArchMatch =
false;
151 boolean foundTempDirMatch =
false;
152 boolean foundProductNameMatch =
false;
153 boolean foundSystemRootMatch =
false;
154 boolean foundProductIDMatch =
false;
155 boolean foundOwnerMatch =
false;
156 boolean foundOrganizationMatch =
false;
159 foundHostnameMatch = compareStringObject(obj.getHostname(), info.getCompName());
162 foundProcArchMatch = compareStringObject(obj.getProcessorArchitecture().getValue().toString(),
163 obj.getProcessorArchitecture().getCondition(),
164 obj.getProcessorArchitecture().getApplyCondition(),
165 info.getAttributeValue(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROCESSOR_ARCHITECTURE));
167 if (haveTempDir && (winSysObj != null)) {
168 foundTempDirMatch = compareStringObject(winSysObj.getWindowsTempDirectory(),
169 info.getAttributeValue(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TEMP_DIR));
171 if (haveProductName && (winSysObj != null)) {
172 foundProductNameMatch = compareStringObject(winSysObj.getProductName(),
173 info.getAttributeValue(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME));
175 if (haveSystemRoot && (winSysObj != null)) {
176 foundSystemRootMatch = compareStringObject(winSysObj.getWindowsSystemDirectory(),
177 info.getAttributeValue(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH));
179 if (haveProductID && (winSysObj != null)) {
180 foundProductIDMatch = compareStringObject(winSysObj.getProductID(),
181 info.getAttributeValue(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PRODUCT_ID));
183 if (haveOwner && (winSysObj != null)) {
184 foundOwnerMatch = compareStringObject(winSysObj.getRegisteredOwner(),
185 info.getAttributeValue(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_OWNER));
187 if (haveOrganization && (winSysObj != null)) {
188 foundOrganizationMatch = compareStringObject(winSysObj.getRegisteredOrganization(),
189 info.getAttributeValue(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ORGANIZATION));
192 if (((!haveHostname) || foundHostnameMatch)
193 && ((!haveProcArch) || foundProcArchMatch)
194 && ((!haveTempDir) || foundTempDirMatch)
195 && ((!haveProductName) || foundProductNameMatch)
196 && ((!haveSystemRoot) || foundSystemRootMatch)
197 && ((!haveProductID) || foundProductIDMatch)
198 && ((!haveOwner) || foundOwnerMatch)
199 && ((!haveOrganization) || foundOrganizationMatch)) {
201 finalHits.addAll(info.getArtifacts());
205 if (!finalHits.isEmpty()) {
206 List<StixArtifactData> artData =
new ArrayList<StixArtifactData>();
207 for (BlackboardArtifact a : finalHits) {
208 artData.add(
new StixArtifactData(a.getObjectID(), id,
"System"));
210 return new ObservableResult(
id,
"SystemObject: Found a match for " + searchString,
211 spacing, ObservableResult.ObservableState.TRUE, artData);
215 return new ObservableResult(
id,
"SystemObject: No matches found for " + searchString,
216 spacing, ObservableResult.ObservableState.FALSE, null);
218 return new ObservableResult(
id,
"SystemObject: No OS artifacts found",
219 spacing, ObservableResult.ObservableState.INDETERMINATE, null);
221 }
catch (TskCoreException | NoCurrentCaseException ex) {
222 return new ObservableResult(
id,
"SystemObject: Exception during evaluation: " + ex.getLocalizedMessage(),
223 spacing, ObservableResult.ObservableState.INDETERMINATE, null);
230 private void setUnsupportedFieldWarnings() {
231 List<String> fieldNames =
new ArrayList<String>();
233 if (obj.getAvailablePhysicalMemory() != null) {
234 fieldNames.add(
"Available_Physical_Memory");
236 if (obj.getBIOSInfo() != null) {
237 fieldNames.add(
"BIOS_Info");
239 if (obj.getDate() != null) {
240 fieldNames.add(
"Date");
242 if (obj.getLocalTime() != null) {
243 fieldNames.add(
"Local_Time");
245 if (obj.getNetworkInterfaceList() != null) {
246 fieldNames.add(
"Network_Interface_List");
248 if (obj.getOS() != null) {
249 fieldNames.add(
"OS");
251 if (obj.getProcessor() != null) {
252 fieldNames.add(
"Processor");
254 if (obj.getSystemTime() != null) {
255 fieldNames.add(
"System_Time");
257 if (obj.getTimezoneDST() != null) {
258 fieldNames.add(
"Timezone_DST");
260 if (obj.getTimezoneStandard() != null) {
261 fieldNames.add(
"Timezone_Standard");
263 if (obj.getTotalPhysicalMemory() != null) {
264 fieldNames.add(
"Total_Physical_Memory");
266 if (obj.getUptime() != null) {
267 fieldNames.add(
"Uptime");
269 if (obj.getUsername() != null) {
270 fieldNames.add(
"Username");
273 if (obj instanceof WindowsSystem) {
274 WindowsSystem winSysObj = (WindowsSystem) obj;
276 if (winSysObj.getDomains() != null) {
277 fieldNames.add(
"Domain");
279 if (winSysObj.getGlobalFlagList() != null) {
280 fieldNames.add(
"Global_Flag_List");
282 if (winSysObj.getNetBIOSName() != null) {
283 fieldNames.add(
"NetBIOS_Name");
285 if (winSysObj.getOpenHandleList() != null) {
286 fieldNames.add(
"Open_Handle_List");
288 if (winSysObj.getWindowsDirectory() != null) {
289 fieldNames.add(
"Windows_Directory");
293 String warningStr =
"";
294 for (String name : fieldNames) {
295 if (!warningStr.isEmpty()) {
301 addWarning(
"Unsupported field(s): " + warningStr);