Skip to content

Commit 62b9fd1

Browse files
committed
binja: fix up the analysis for the al-khaser_x64.exe_ file. Fix mandiant#2507
1 parent ec156cf commit 62b9fd1

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
- binja: fix crash when the IL of certain functions are not available. #2249 @xusheng6
4444
- binja: major performance improvement on the binja extractor. #1414 @xusheng6
4545
- cape: make Process model flexible and procmemory optional to load newest reports #2466 @mr-tz
46+
- binja: fix unit test failure by fixing up the analysis for file al-khaser_x64.exe_ #2507 @xusheng6
4647

4748
### capa Explorer Web
4849

capa/features/extractors/binja/insn.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,15 @@ def is_stub_function(bv: BinaryView, addr: int) -> Optional[int]:
4545
]:
4646
return None
4747

48-
if llil.dest.value.type not in [
49-
RegisterValueType.ImportedAddressValue,
50-
RegisterValueType.ConstantValue,
51-
RegisterValueType.ConstantPointerValue,
48+
# The LLIL instruction retrieved by `get_llil_instr_at_addr` did not go through a full analysis, so we cannot check
49+
# `llil.dest.value.type` here
50+
if llil.dest.operation not in [
51+
LowLevelILOperation.LLIL_CONST,
52+
LowLevelILOperation.LLIL_CONST_PTR,
5253
]:
5354
return None
5455

55-
return llil.dest.value.value
56+
return llil.dest.constant
5657

5758

5859
def extract_insn_api_features(fh: FunctionHandle, bbh: BBHandle, ih: InsnHandle) -> Iterator[tuple[Feature, Address]]:

tests/fixtures.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ def get_binja_extractor(path: Path):
180180
if path.name.endswith("kernel32-64.dll_"):
181181
settings.set_bool("pdb.loadGlobalSymbols", old_pdb)
182182

183+
# Temporary fix for https://github.com/mandiant/capa/issues/2507. Remove this once it is fixed in binja
184+
if "al-khaser_x64.exe_" in path.name:
185+
bv.create_user_function(0x14004b4f0)
186+
bv.update_analysis_and_wait()
187+
183188
extractor = capa.features.extractors.binja.extractor.BinjaFeatureExtractor(bv)
184189

185190
# overload the extractor so that the fixture exposes `extractor.path`

0 commit comments

Comments
 (0)