mirror of
https://github.com/mandiant/capa.git
synced 2026-06-12 19:11:32 -07:00
fix: unpack getByteDef offset to correctly check ENDBRANCH at target address
getByteDef returns (offset, segment_bytes); the old code indexed [1] to get segment_bytes and called startswith() on the whole buffer, which checked whether the segment itself begins with ENDBRANCH rather than the target address. Unpacking both values and slicing _buf[_offset:] fixes the check.
This commit is contained in:
committed by
Willi Ballenthin
parent
4b99c506fa
commit
56fcdd32ed
@@ -49,6 +49,7 @@
|
||||
- fix: Scopes.from_dict uses cls instead of self so subclasses return the correct type @williballenthin
|
||||
- fix: correct wrong dict key in VMRay _compute_monitor_threads assertion (used thread_id instead of process_id) @williballenthin
|
||||
- fix: replace assert with isinstance guard in get_callee for invalid MethodSpec tokens @williballenthin
|
||||
- fix: unpack getByteDef offset and slice buffer so ENDBRANCH check applies to target address, not segment start @williballenthin (SURF-45)
|
||||
- fix: correct inverted loop structure in extract_function_loop so each block edge is recorded as (src, dest) @williballenthin (SURF-44)
|
||||
- fix: initialize addr to None in Ghidra import extractors to prevent UnboundLocalError when external functions have no data references @williballenthin (SURF-43)
|
||||
- fix: assign ConfigDict to model_config in ConciseModel so extra="ignore" is actually applied @williballenthin (SURF-42)
|
||||
|
||||
@@ -158,7 +158,8 @@ def extract_insn_api_features(fh: FunctionHandle, bb, ih: InsnHandle) -> Iterato
|
||||
yield API(name), ih.address
|
||||
|
||||
# if jump leads to an ENDBRANCH instruction, skip it
|
||||
if f.vw.getByteDef(target)[1].startswith(b"\xf3\x0f\x1e"):
|
||||
_offset, _buf = f.vw.getByteDef(target)
|
||||
if _buf[_offset:].startswith(b"\xf3\x0f\x1e"):
|
||||
target += 4
|
||||
|
||||
target = capa.features.extractors.viv.helpers.get_coderef_from(f.vw, target)
|
||||
|
||||
Reference in New Issue
Block a user