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

Commit 2ac85e6

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 a438e76 commit 2ac85e6

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
@@ -216,10 +223,37 @@ def findcookie(self, kernel_space):
216223
debug.warning("Cannot find NT module")
217224
return False
218225

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

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

230264
# in theory...but so far we haven't tested 32-bits
231-
model = meta.get("memory_model")
232265
if model == "32bit":
233266
mode = distorm3.Decode32Bits
234267
else:
@@ -331,6 +364,9 @@ def TypeIndex(self):
331364
addr = self.obj_offset
332365
indx = int(self.m("TypeIndex"))
333366

367+
if cook is None:
368+
debug.error("Cannot obtain nt!ObHeaderCookie value")
369+
334370
return ((addr >> 8) ^ cook ^ indx) & 0xFF
335371

336372
def is_valid(self):
@@ -1144,4 +1180,4 @@ class Win10x64_19041(obj.Profile):
11441180
_md_minor = 4
11451181
_md_build = 19041
11461182
_md_vtype_module = 'volatility.plugins.overlays.windows.win10_x64_19041_vtypes'
1147-
_md_product = ["NtProductWinNt"]
1183+
_md_product = ["NtProductWinNt"]

0 commit comments

Comments
 (0)