Skip to content

Commit 9e4dc2d

Browse files
committed
call/jmp to immediate value
1 parent 065ea84 commit 9e4dc2d

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

volatility3/framework/plugins/windows/inlinehooks.py

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]
4343
requirements.VersionRequirement(
4444
name="modules",
4545
component=modules.Modules,
46-
version=(3, 0, 0), # Updated from 2.0.0 to 3.0.0
46+
version=(3, 0, 0),
4747
),
4848
requirements.VersionRequirement(
4949
name="pe_symbols", component=pe_symbols.PESymbols, version=(3, 0, 0)
5050
),
5151
requirements.ListRequirement(
5252
name="pid",
53-
description="Filter on specific process IDs",
53+
description="Process IDs to include (all other processes are excluded)",
5454
element_type=int,
5555
optional=True,
5656
),
@@ -59,15 +59,18 @@ def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]
5959
def _count_until_padding(self, data: bytes) -> int:
6060
# Check for padding sequences
6161
for i in range(len(data)):
62+
6263
# Double int3 (CC CC)
6364
if i + 1 < len(data) and data[i] == 0xCC and data[i + 1] == 0xCC:
6465
return i
66+
6567
# 11-byte NOP (66 66 66 0f 1f 84 00 00 00 00 00)
6668
if (
6769
i + 11 <= len(data)
6870
and data[i : i + 11] == b"\x66\x66\x66\x0f\x1f\x84\x00\x00\x00\x00\x00"
6971
):
7072
return i
73+
7174
# 2-byte NOP (66 66)
7275
if i + 2 <= len(data) and data[i : i + 2] == b"\x66\x66":
7376
return i
@@ -139,16 +142,37 @@ def check_inline_hook(
139142
):
140143
return (data, "Early RET")
141144

142-
# Check for JMP relative hooks
143-
if disasm[0].bytes[0] == 0xE9 and func_insn_count >= MIN_FUNC_SIZE_FOR_JMP:
144-
return (data, "JMP relative")
145+
# Check for JMP relative/Register JMP hooks
146+
if func_insn_count >= MIN_FUNC_SIZE_FOR_JMP:
147+
if (
148+
(disasm[0].bytes[0] == 0xE9)
149+
or (
150+
func_insn_count >= 2
151+
and disasm[0].mnemonic == "mov"
152+
and disasm[0].operands[0].type == capstone.x86.X86_OP_REG
153+
and disasm[0].operands[1].type == capstone.x86.X86_OP_IMM
154+
and disasm[1].mnemonic == "jmp"
155+
and disasm[1].operands[0].type == capstone.x86.X86_OP_REG
156+
and disasm[1].operands[0].reg == disasm[0].operands[0].reg
157+
)
158+
):
159+
return (data, "Early JMP")
145160

146-
# Check for Early CALL hooks
147-
if (
148-
func_insn_count >= MIN_FUNC_SIZE_FOR_CALL
149-
and disasm[0].mnemonic == "call"
150-
):
151-
return (data, "Early CALL")
161+
# Check for Early CALL/Register CALL hooks
162+
if func_insn_count >= MIN_FUNC_SIZE_FOR_CALL:
163+
if (
164+
(disasm[0].mnemonic == "call")
165+
or (
166+
func_insn_count >= 2
167+
and disasm[0].mnemonic == "mov"
168+
and disasm[0].operands[0].type == capstone.x86.X86_OP_REG
169+
and disasm[0].operands[1].type == capstone.x86.X86_OP_IMM
170+
and disasm[1].mnemonic == "call"
171+
and disasm[1].operands[0].type == capstone.x86.X86_OP_REG
172+
and disasm[1].operands[0].reg == disasm[0].operands[0].reg
173+
)
174+
):
175+
return (data, "Early CALL")
152176

153177
except Exception as e:
154178
vollog.debug(f"Error during disassembly at {addr:#x}: {e}")

0 commit comments

Comments
 (0)