diff --git a/CHANGELOG.md b/CHANGELOG.md index 649965337..cf18ff9c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,13 +6,15 @@ ### Breaking Changes -### New Rules (1) +### New Rules (2) - executable/pe/export/forwarded-export ronnie.salomonsen@mandiant.com - ### Bug Fixes +- Fix binja backend stack string detection. [#1473](https://github.com/mandiant/capa/issues/1473) [@xusheng6](https://github.com/xusheng6) + ### capa explorer IDA Pro plugin ### Development diff --git a/capa/features/extractors/binja/basicblock.py b/capa/features/extractors/binja/basicblock.py index 30af516da..568ecc7ad 100644 --- a/capa/features/extractors/binja/basicblock.py +++ b/capa/features/extractors/binja/basicblock.py @@ -75,10 +75,11 @@ def get_stack_string_len(f: Function, il: MediumLevelILInstruction) -> int: return 0 dest = il.params[0] - if dest.operation != MediumLevelILOperation.MLIL_ADDRESS_OF: + if dest.operation in [MediumLevelILOperation.MLIL_ADDRESS_OF, MediumLevelILOperation.MLIL_VAR]: + var = dest.src + else: return 0 - var = dest.src if var.source_type != VariableSourceType.StackVariableSourceType: return 0 diff --git a/pyproject.toml b/pyproject.toml index cb48f843e..fddb2a40b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -77,7 +77,7 @@ dev = [ "flake8-simplify==0.20.0", "flake8-use-pathlib==0.3.0", "flake8-copyright==0.2.4", - "ruff==0.0.278", + "ruff==0.0.280", "black==23.7.0", "isort==5.11.4", "mypy==1.4.1", diff --git a/rules b/rules index a49c174fe..3f39a4546 160000 --- a/rules +++ b/rules @@ -1 +1 @@ -Subproject commit a49c174fee5058ca3617a23e782bdcadacb12406 +Subproject commit 3f39a454650c75a26ed7e399af541007b92e00b7 diff --git a/tests/data b/tests/data index bfcf387b5..a34ba30f8 160000 --- a/tests/data +++ b/tests/data @@ -1 +1 @@ -Subproject commit bfcf387b5b55e65ef02ceb0cc5191ebe49ad5614 +Subproject commit a34ba30f8c5cee29b7539a56038f4976f8883b2b diff --git a/tests/test_binja_features.py b/tests/test_binja_features.py index 4daaa7901..a2f0cd78f 100644 --- a/tests/test_binja_features.py +++ b/tests/test_binja_features.py @@ -40,9 +40,6 @@ indirect=["sample", "scope"], ) def test_binja_features(sample, scope, feature, expected): - if feature == capa.features.common.Characteristic("stack string"): - pytest.xfail("skip failing Binja stack string detection temporarily, see #1473") - if isinstance(feature, capa.features.file.Export) and "." in str(feature.value): pytest.xfail("skip Binja unsupported forwarded export feature, see #1646")