Skip to content
This repository was archived by the owner on May 16, 2025. It is now read-only.

Commit b99173c

Browse files
author
Oliver Old
committed
Add fix for missing cookie value when using a Windows 10 profile
Use YARA and the DiscontigYaraScanner from malfind to find the address of nt!ObGetObjectType. Also put in a safeguard against TypeError when the nt!ObHeaderCookie value can't be obtained.
1 parent 5f685e5 commit b99173c

File tree

1 file changed

+40
-4
lines changed
  • volatility/plugins/overlays/windows

1 file changed

+40
-4
lines changed

volatility/plugins/overlays/windows/win10.py

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@
3939
except ImportError:
4040
has_distorm = False
4141

42+
try:
43+
import yara
44+
import volatility.plugins.malware.malfind as malfind
45+
has_yara = True
46+
except ImportError:
47+
has_yara = False
48+
4249
class _HMAP_ENTRY(obj.CType):
4350

4451
@property
@@ -212,10 +219,37 @@ def findcookie(self, kernel_space):
212219
debug.warning("Cannot find NT module")
213220
return False
214221

222+
model = meta.get("memory_model")
223+
215224
addr = nt_mod.getprocaddress("ObGetObjectType")
216225
if addr == None:
217-
debug.warning("Cannot find nt!ObGetObjectType")
218-
return False
226+
if not has_yara:
227+
debug.warning("Cannot find nt!ObGetObjectType")
228+
return False
229+
# Did not find nt!ObGetObjectType, trying with YARA instead.
230+
if model == "32bit":
231+
# 8bff mov edi, edi
232+
# 55 push ebp
233+
# 8bec mov ebp, esp
234+
# 8b4d08 mov ecx, dword ptr [ebp + 8]
235+
# 8d41e8 lea eax, dword ptr [ecx - 0x18]
236+
nt_ObGetObjectType_signature = "8bff 55 8bec 8b4d08 8d41e8"
237+
else:
238+
# 488d41d0 lea rax, qword ptr [rcx - 0x30]
239+
# 0fb649e8 movzx ecx, byte ptr [rcx - 0x18]
240+
nt_ObGetObjectType_signature = "488d41d0 0fb649e8"
241+
rule = 'rule r1 {strings: $a = {%s} condition: $a}' \
242+
% nt_ObGetObjectType_signature
243+
rules = yara.compile(source = rule)
244+
scanner = malfind.DiscontigYaraScanner(
245+
address_space = kernel_space,
246+
rules = rules)
247+
first_match = next(scanner.scan(), None)
248+
if not first_match:
249+
debug.warning("Cannot find nt!ObGetObjectType")
250+
return False
251+
_, addr = first_match
252+
addr -= nt_mod.DllBase
219253

220254
# produce an absolute address by adding the DLL base to the RVA
221255
addr += nt_mod.DllBase
@@ -224,7 +258,6 @@ def findcookie(self, kernel_space):
224258
return False
225259

226260
# in theory...but so far we haven't tested 32-bits
227-
model = meta.get("memory_model")
228261
if model == "32bit":
229262
mode = distorm3.Decode32Bits
230263
else:
@@ -327,6 +360,9 @@ def TypeIndex(self):
327360
addr = self.obj_offset
328361
indx = int(self.m("TypeIndex"))
329362

363+
if cook is None:
364+
debug.error("Cannot obtain nt!ObHeaderCookie value")
365+
330366
return ((addr >> 8) ^ cook ^ indx) & 0xFF
331367

332368
def is_valid(self):
@@ -1120,4 +1156,4 @@ class Win10x64_18362(obj.Profile):
11201156
_md_minor = 4
11211157
_md_build = 18362
11221158
_md_vtype_module = 'volatility.plugins.overlays.windows.win10_x64_18362_vtypes'
1123-
_md_product = ["NtProductWinNt"]
1159+
_md_product = ["NtProductWinNt"]

0 commit comments

Comments
 (0)