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;
38 class EvalSystemObj
extends EvaluatableObject {
40 private final SystemObjectType obj;
42 public EvalSystemObj(SystemObjectType a_obj, String a_id, String a_spacing) {
49 public synchronized ObservableResult evaluate() {
54 String searchString =
"";
57 boolean haveHostname =
false;
59 boolean haveProcArch =
false;
60 boolean haveTempDir =
false;
61 boolean haveProductName =
false;
62 boolean haveSystemRoot =
false;
63 boolean haveProductID =
false;
64 boolean haveOwner =
false;
65 boolean haveOrganization =
false;
67 if (obj.getHostname() != null) {
69 searchString =
"Hostname \"" + obj.getHostname().getValue().toString() +
"\"";
71 if (obj.getProcessorArchitecture() != null) {
73 if (!searchString.isEmpty()) {
74 searchString +=
" and ";
76 searchString +=
"Processor architecture \"" + obj.getProcessorArchitecture().getValue().toString() +
"\"";
79 WindowsSystem winSysObj = null;
80 if (obj instanceof WindowsSystem) {
81 winSysObj = (WindowsSystem) obj;
83 if (winSysObj.getProductID() != null) {
85 if (!searchString.isEmpty()) {
86 searchString +=
" and ";
88 searchString +=
"Product ID \"" + winSysObj.getProductID().getValue().toString() +
"\"";
90 if (winSysObj.getProductName() != null) {
91 haveProductName =
true;
92 if (!searchString.isEmpty()) {
93 searchString +=
" and ";
95 searchString +=
"Product Name \"" + winSysObj.getProductName().getValue().toString() +
"\"";
97 if (winSysObj.getRegisteredOrganization() != null) {
98 haveOrganization =
true;
99 if (!searchString.isEmpty()) {
100 searchString +=
" and ";
102 searchString +=
"Registered Org \"" + winSysObj.getRegisteredOrganization().getValue().toString() +
"\"";
104 if (winSysObj.getRegisteredOwner() != null) {
106 if (!searchString.isEmpty()) {
107 searchString +=
" and ";
109 searchString +=
"Registered Owner \"" + winSysObj.getRegisteredOwner().getValue().toString() +
"\"";
111 if (winSysObj.getWindowsSystemDirectory() != null) {
112 haveSystemRoot =
true;
113 if (!searchString.isEmpty()) {
114 searchString +=
" and ";
116 searchString +=
"System root \"" + winSysObj.getWindowsSystemDirectory().getValue().toString() +
"\"";
118 if (winSysObj.getWindowsTempDirectory() != null) {
120 if (!searchString.isEmpty()) {
121 searchString +=
" and ";
123 searchString +=
"Temp dir \"" + winSysObj.getWindowsTempDirectory().getValue().toString() +
"\"";
128 if (!(haveHostname || haveProcArch
129 || haveTempDir || haveProductName || haveSystemRoot || haveProductID
130 || haveOwner || haveOrganization)) {
131 return new ObservableResult(
id,
"SystemObject: No evaluatable fields found",
132 spacing, ObservableResult.ObservableState.INDETERMINATE, null);
135 setUnsupportedFieldWarnings();
138 Case case1 = Case.getCurrentCase();
139 SleuthkitCase sleuthkitCase = case1.getSleuthkitCase();
140 List<OSInfo> osInfoList = OSUtility.getOSInfo(sleuthkitCase);
142 List<BlackboardArtifact> finalHits =
new ArrayList<BlackboardArtifact>();
144 if (!osInfoList.isEmpty()) {
145 for (OSInfo info : osInfoList) {
147 boolean foundHostnameMatch =
false;
149 boolean foundProcArchMatch =
false;
150 boolean foundTempDirMatch =
false;
151 boolean foundProductNameMatch =
false;
152 boolean foundSystemRootMatch =
false;
153 boolean foundProductIDMatch =
false;
154 boolean foundOwnerMatch =
false;
155 boolean foundOrganizationMatch =
false;
158 foundHostnameMatch = compareStringObject(obj.getHostname(), info.getCompName());
161 foundProcArchMatch = compareStringObject(obj.getProcessorArchitecture().getValue().toString(),
162 obj.getProcessorArchitecture().getCondition(),
163 obj.getProcessorArchitecture().getApplyCondition(),
164 info.getAttributeValue(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROCESSOR_ARCHITECTURE));
166 if (haveTempDir && (winSysObj != null)) {
167 foundTempDirMatch = compareStringObject(winSysObj.getWindowsTempDirectory(),
168 info.getAttributeValue(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TEMP_DIR));
170 if (haveProductName && (winSysObj != null)) {
171 foundProductNameMatch = compareStringObject(winSysObj.getProductName(),
172 info.getAttributeValue(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME));
174 if (haveSystemRoot && (winSysObj != null)) {
175 foundSystemRootMatch = compareStringObject(winSysObj.getWindowsSystemDirectory(),
176 info.getAttributeValue(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH));
178 if (haveProductID && (winSysObj != null)) {
179 foundProductIDMatch = compareStringObject(winSysObj.getProductID(),
180 info.getAttributeValue(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PRODUCT_ID));
182 if (haveOwner && (winSysObj != null)) {
183 foundOwnerMatch = compareStringObject(winSysObj.getRegisteredOwner(),
184 info.getAttributeValue(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_OWNER));
186 if (haveOrganization && (winSysObj != null)) {
187 foundOrganizationMatch = compareStringObject(winSysObj.getRegisteredOrganization(),
188 info.getAttributeValue(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ORGANIZATION));
191 if (((!haveHostname) || foundHostnameMatch)
192 && ((!haveProcArch) || foundProcArchMatch)
193 && ((!haveTempDir) || foundTempDirMatch)
194 && ((!haveProductName) || foundProductNameMatch)
195 && ((!haveSystemRoot) || foundSystemRootMatch)
196 && ((!haveProductID) || foundProductIDMatch)
197 && ((!haveOwner) || foundOwnerMatch)
198 && ((!haveOrganization) || foundOrganizationMatch)) {
200 finalHits.addAll(info.getArtifacts());
204 if (!finalHits.isEmpty()) {
205 List<StixArtifactData> artData =
new ArrayList<StixArtifactData>();
206 for (BlackboardArtifact a : finalHits) {
207 artData.add(
new StixArtifactData(a.getObjectID(), id,
"System"));
209 return new ObservableResult(
id,
"SystemObject: Found a match for " + searchString,
210 spacing, ObservableResult.ObservableState.TRUE, artData);
214 return new ObservableResult(
id,
"SystemObject: No matches found for " + searchString,
215 spacing, ObservableResult.ObservableState.FALSE, null);
217 return new ObservableResult(
id,
"SystemObject: No OS artifacts found",
218 spacing, ObservableResult.ObservableState.INDETERMINATE, null);
220 }
catch (TskCoreException ex) {
221 return new ObservableResult(
id,
"SystemObject: Exception during evaluation: " + ex.getLocalizedMessage(),
222 spacing, ObservableResult.ObservableState.INDETERMINATE, null);
229 private void setUnsupportedFieldWarnings() {
230 List<String> fieldNames =
new ArrayList<String>();
232 if (obj.getAvailablePhysicalMemory() != null) {
233 fieldNames.add(
"Available_Physical_Memory");
235 if (obj.getBIOSInfo() != null) {
236 fieldNames.add(
"BIOS_Info");
238 if (obj.getDate() != null) {
239 fieldNames.add(
"Date");
241 if (obj.getLocalTime() != null) {
242 fieldNames.add(
"Local_Time");
244 if (obj.getNetworkInterfaceList() != null) {
245 fieldNames.add(
"Network_Interface_List");
247 if (obj.getOS() != null) {
248 fieldNames.add(
"OS");
250 if (obj.getProcessor() != null) {
251 fieldNames.add(
"Processor");
253 if (obj.getSystemTime() != null) {
254 fieldNames.add(
"System_Time");
256 if (obj.getTimezoneDST() != null) {
257 fieldNames.add(
"Timezone_DST");
259 if (obj.getTimezoneStandard() != null) {
260 fieldNames.add(
"Timezone_Standard");
262 if (obj.getTotalPhysicalMemory() != null) {
263 fieldNames.add(
"Total_Physical_Memory");
265 if (obj.getUptime() != null) {
266 fieldNames.add(
"Uptime");
268 if (obj.getUsername() != null) {
269 fieldNames.add(
"Username");
272 if (obj instanceof WindowsSystem) {
273 WindowsSystem winSysObj = (WindowsSystem) obj;
275 if (winSysObj.getDomains() != null) {
276 fieldNames.add(
"Domain");
278 if (winSysObj.getGlobalFlagList() != null) {
279 fieldNames.add(
"Global_Flag_List");
281 if (winSysObj.getNetBIOSName() != null) {
282 fieldNames.add(
"NetBIOS_Name");
284 if (winSysObj.getOpenHandleList() != null) {
285 fieldNames.add(
"Open_Handle_List");
287 if (winSysObj.getWindowsDirectory() != null) {
288 fieldNames.add(
"Windows_Directory");
292 String warningStr =
"";
293 for (String name : fieldNames) {
294 if (!warningStr.isEmpty()) {
300 addWarning(
"Unsupported field(s): " + warningStr);