Commit graph

56 commits

Author SHA1 Message Date
Yan Shoshitaishvili
90062a9914
Support native AIL Abs expressions in light engines (#6683)
* Fix AIL Abs unary operation dispatch

* Fix Abs regression test lint
2026-07-24 00:43:03 -07:00
Yan Shoshitaishvili
cf54c35b9b
AIL: handle HAddV operations (#6680)
* AIL: handle HAddV operations

* Fix HAddV CI diagnostics
2026-07-23 21:10:10 -07:00
Kevin Phoenix
d145bd41fd
Remove global condition from SimState (#6641) 2026-07-20 10:06:54 -07:00
Kevin Phoenix
1944e72e90
Remove widen() from state api (#6632) 2026-07-17 13:23:53 -07:00
Fish
9235f7fd27
Migrate AIL classes to Rust (#5967)
This PR migrates AIL classes (Block, Statement, Expression, etc.) to Rust. Key changes include:

- Block, Statement, and Expression are native Rust objects. Every access to their properties will create a new Python class object. Therefore, `expr.dst is expr.dst` will always evaluate to False. You'll want to do `expr.dst == expr.dst` instead.

- However, keep in mind that `expr_0 == expr_1` can be expensive because equality checks may potentially go over two expression trees and compare every single node. In this case, you may want to resort to `expr_0.idx == expr_1.idx`. There are still a few places where `idx` is reused; we plan to remove all such cases and guarantee the uniqueness of `idx` for all Statements and Expressions during a single decompilation run.

- `type(expr) is Const` no longer works. You must use `isinstance(expr, Const)` instead. `isinstance(..., ExpressionCls/StatementCls)` is also more expensive than before due to the use of custom meta classes.

- New changes to AIL requires rebuilding the Rust component to land. You can do `python setup.py build_rust --inplace --release` to rebuild the angr Rust component in-place in an editable install.

---------

Co-authored-by: Kevin Phoenix <kevin@kphoenix.us>
2026-07-08 02:10:07 -07:00
Fish
14f0650d3b
Decompiler: Use VariableMap to track Atom-Variable mapping. (#6470) 2026-06-05 16:28:58 -07:00
Kevin Phoenix
f939c5b88c
Enable ruff isort rule (#6452)
* Enable ruff isort rule

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-06-02 14:48:07 -07:00
Kevin Phoenix
6ac26cac27
Refactor AIL symbolic execution to store block indexes in state.scratch (#6443)
* Refactor AIL sybolic execution to store block indexes in state.scratch

* Verify states are ail-mode

* Add magic to addr.setter to handle ail address tuples

* Add docs
2026-05-28 18:24:47 -07:00
Kevin Phoenix
b65d954dca
Move all icicle engine state into the state plugin (#6398)
* Move all icicle engine state into the state plugin

* Move IcicleStateTranslationData to state plugin module
2026-05-13 11:38:44 -07:00
Kevin Phoenix
128bc2cbb6
Deduplicate icicle engine syncing logic (#6372) 2026-04-27 14:01:25 -07:00
Kevin Phoenix
85678cac76
Icicle: use snapshot mode unconditionally (#6366)
* Icicle: auto-invalidate code cache on memory mutations.

Before this change, calling mem_write/mem_unmap/mem_protect from Python
on an address whose page had been executed would raise SelfModifyingCode
(from the VM's SMC detection) or silently leave a stale lifted/JIT
block in place, so subsequent runs executed the old code.

mem_write/mem_unmap/mem_protect now call an internal invalidate_code_range
that drops any BlockGroup, JIT compilation, and cached disassembly
overlapping the written range. SMC detection is disabled at construction
since explicit invalidation replaces it for our sync writes. restore_snapshot
additionally calls Vm::reset before Vm::restore so lifted code, JIT cache,
and prev_isa_mode — none of which the snapshot covers — are discarded.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* IcicleEngine: re-sync simproc breakpoints on every run.

SimProcedure.call() creates new extern hooks on demand (for instance, the
continuation targets of __libc_start_main), so the simproc set grows
during execution. IcicleEngine's full-init path seeded the emu's
breakpoint table once, but neither the continuation nor the snapshot-
restore paths re-synced new entries.

Before this, a main() return landing on a dynamically-created
after_main extern silently fell through to zero bytes in the extern
region (SIGSEGV in fauxware fully- or partly-snapshot-mode runs).

add_breakpoint is idempotent so iterating over project._sim_procedures
before each run is cheap.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* IcicleEngine: fix continuation sync for BV addresses and stale path tracer.

Two related fixes uncovered while chasing fauxware failures when snapshot
mode is forced on:

1. The SimInspect mem_write hook only recorded dirty pages when
   `mem_write_address` and `mem_write_length` were Python ints. In
   practice both are typically claripy BitVectors (concrete addresses
   wrapped), and `state.memory.store(addr, bvv)` is commonly called
   without an explicit size, so `length` arrives as None. Normalise BV
   args to int via `.concrete_value`, and fall back to
   `mem_write_expr.size() // 8` when length is absent. Without this,
   data written by SimProcedures between icicle runs (e.g. `read`
   writing into the stack password buffer) never made it into
   dirty_pages, so the next continuation-sync run left the emu holding
   pre-read zeros and comparisons downstream took the wrong branch.

2. The path tracer isn't cleared on continuation, so
   `emu.recent_blocks` accumulates blocks across every reused run.
   `__convert_icicle_state_to_angr` then re-appends the whole list each
   time, duplicating prior blocks in `state.history.bbl_addrs`. Call
   `emu.clear_path_tracer()` at the start of a continuation run so
   recent_blocks reflects only this run's blocks.

With these two fixes plus the earlier simproc-breakpoint re-sync, all
61 icicle/emulator/fuzzer tests pass with `_snapshot_mode` forced True,
matching the snapshot-off baseline.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* IcicleEngine: make snapshot mode the default; remove the opt-in.

The first call always saves a snapshot of the fresh VM; subsequent calls
either continue with the cached emu or restore the snapshot and
delta-sync. Dropped `enable_snapshot_mode()` and the `_snapshot_mode`
flag — with the earlier sync fixes on this branch, the restore-based
path passes the same tests as the prior full-init-each-call behaviour
and runs roughly 3x faster on the fauxware suite.

- Removes the `enable_snapshot_mode()` method and its callers in three
  tests (now redundant) and in the Rust fuzzer executor.
- Updates the class docstring.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-04-27 11:09:03 -07:00
Kevin Phoenix
acdfa73516
Remove ConcreteEngine; make IcicleEngine subclass SuccessorsEngine directly (#6354)
The ConcreteEngine abstract base added an unnecessary layer on top of
SuccessorsEngine. Fold its single implementation responsibility into
IcicleEngine's process_successors, drop the concrete.py module, and
retype Emulator against SimState / SuccessorsEngine.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 18:52:04 -07:00
rileyseefeldt
3c37bca09a
icicle: add snapshot mode and continuation detection for VM reuse (#6345)
- Save/restore icicle VM snapshots across multiple runs
- Track dirty pages to avoid full memory sync on snapshot restore
- SimStateIcicle plugin detects continuations after hooks/syscalls
- Continuation path syncs only registers + dirty pages (no snapshot restore)
- COW identity check skips unchanged pages during snapshot sync
- Edge hitmap preserved across snapshot restore/continuation cycles
2026-04-14 09:09:17 -07:00
rileyseefeldt
bb1105285d
icicle: fix TLS sync, syscall jumpkind, symbolic memory, page metadata (#6313)
* icicle: fix TLS sync, syscall jumpkind, symbolic memory, page metadata, breakpoints

- Sync FS_OFFSET/GS_OFFSET for AMD64/X86 TLS access (stack canary, TLS vars)
- Map Syscall exception to arch-specific jumpkind (int80 vs syscall) and advance IP
- Handle symbolic page content via concrete_load bitmap fallback
- Respect None entries in paged memory (explicitly unmapped pages)
- add_breakpoint returns bool; skip breakpoints on unmapped pages
- Fix icount_limit to be absolute when VM is reused

* typecheck
2026-04-10 22:29:50 -07:00
rileyseefeldt
d3dcb26db1
Dirty Page Tracking for Icicle Engine (#6227)
* faster

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: rileyseefeldt <riley@evilcomputer2.localdomain>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-03-16 08:52:33 -07:00
rileyseefeldt
21f8254125
Cache Icicle State (#6202)
* adds checkpoint for converting angr state to icicle

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix ruff errors

* sync snapshot mapping/perms and added test

* lint fix

* changed test to use angr engine

* ruff

---------

Co-authored-by: rileyseefeldt <riley@evilcomputer2.localdomain>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: rileyseefeldt <seatbeltman@evilcomputer.localdomain>
2026-03-09 09:26:45 -07:00
Kevin Phoenix
22bd9f6a08
Refactor AIL Call into Call and SideEffectStatement (#6115)
* Refactor AIL Call into Call and SideEffectStatement

* Fix test_ail_exec.py tests

* Improve purity engine

* Remove backwards compatibility code claude added

* Fix errors

* Remove Call from statement.py to prevent accidental import

* Fix test imports

* More fixes

* Fix more bugs
2026-02-16 16:07:13 -07:00
Fish
5ee75140ff
Dev: Switch from black to ruff format. (#6097)
* Dev: Switch from black to ruff format.

* Reformat all the files.
2026-02-05 14:29:21 -07:00
Kevin Phoenix
ae829f491d
Refactor coverage to use a dedicated state plugin (#6098) 2026-02-05 13:34:49 -07:00
Kevin Phoenix
b1b1b9c1ad
Refactor icicle engine to use extra_stop_points (#6095) 2026-02-04 17:24:19 -07:00
pre-commit-ci[bot]
563fb5f862
[pre-commit.ci] pre-commit autoupdate (#6025)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.14.11 → v0.14.13](https://github.com/astral-sh/ruff-pre-commit/compare/v0.14.11...v0.14.13)
- [github.com/psf/black-pre-commit-mirror: 25.12.0 → 26.1.0](https://github.com/psf/black-pre-commit-mirror/compare/25.12.0...26.1.0)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-01-19 13:37:06 -07:00
Yan Shoshitaishvili
9f143fe7cf
adapting test cases for cle's new auto_load_libs default (#5374)
* explicitly auto_load_libs where needed

* oops
2026-01-12 15:44:12 -07:00
Wil Gibbs
0cbba79138
Ensure that vvar is added to frame even when inline or callless (#5982)
* Ensure that vvar is added to frame even when inline or callless

* Explicitly look for tuple
2026-01-06 12:15:27 -07:00
Kevin Phoenix
a654196b35
Prefer short VS over long ValueSet constructor (#5980) 2026-01-05 12:21:17 -07:00
Wil Gibbs
4284eaab2c
Do not raise an error when PHI expressions are unresolvable, use top as an alternative (#5966) 2025-12-31 03:02:26 -07:00
Wil Gibbs
9f4a81a057
fix/ail varargs (#5962)
* Fix varargs ingestion via ail

* Add test cases to ensure that multi and unused varargs are fine

* remove unnecessary comments

* remove unnecessary comments

* Raise error if fewer args passed in

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* it was good the way it was

* ignore arguments passed in after the size of args_vvars

* linter

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-12-23 19:49:18 -07:00
Wil Gibbs
f3e0686293
fix/ail bool expr (#5963)
* Rectify non-boolean expressions in ail bool exprs

* Add test for 1 instead of true

* linting

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-12-23 18:55:33 -07:00
Wil Gibbs
0ca8aae5ba
fix/ail unused return (#5960)
* AIL Call can be a statement even when the callee returns a value (e.g., `memset(...)` used for side effects).
In that case `ret_expr`/`fp_ret_expr` will be None and the return value is intentionally unused.
Also, some SimProcedures may provide extra return values. Only error when a required return is missing.

* Add testcase for unused return

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Move import to top-level

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-12-23 16:55:16 -07:00
Wil Gibbs
588b17b84d
fix/ail vex ccall (#5961)
* Vexcall requires the state as the first parameter to handlers

* Add testcase that exercises vexccall

* Remove comments

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-12-23 13:32:55 -07:00
Audrey Dutcher
4c2030682e
Add AIL symbolic execution (#5825)
* Add AIL symbolic execution

* Fixes

* minor callstack fixes

* tests and lint

* lint

* "typecheck"

* tinker with SimStatePlugin.copy until typechecking works

* augh remove logic for copy with extra args

* Add testcase, fix actual bug that testcase found

* typecheck

* lint

* Address review comments

* Make ail_call_state more flexible
2025-11-24 23:27:48 -07:00
Matt Borgerson
9689017c1b tests: Remove many @slow_test markers 2025-11-17 10:36:50 -07:00
Kevin Phoenix
9b6b083cc5
Fix Icicle breakpoints not reliably working in thumb mode (#5688)
Icicle does not set the thumb bit when considering to break for a
breakpoint. So for instance, if a breakpoint is set at 0x1001,
Icicle will never hit this, it would instead hit 0x1000. Since angr
prefers to pretend the thumb bit is set in the pc this makes sure it
is always unset before being communicated to Icicle.
2025-09-26 14:57:40 -07:00
Kevin Phoenix
64265d8f45
IcicleEngine: Default to thumb mode for cortex-m states (#5666)
* IcicleEngine: Default to thumb mode for cortex-m states

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-09-18 09:51:43 -07:00
Kevin Phoenix
8098709feb
Add AFL-style edge hitmap support to Icicle engine (#5593)
* Add AFL-style edge hitmap support to Icicle engine

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-07-09 11:40:56 -07:00
Kevin Phoenix
6288399047
Add block tracing capability to Icicle engine (#5572)
* Add block tracing capability to Icicle engine

* Add a test case

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix lint

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-07-01 14:08:29 -07:00
Kevin Phoenix
e0a6a82282
Add Emulator and ConcreteEngine; Adapt IcicleEngine to ConcreteEngine (#5529)
* Add Emulator and ConcreteEngine; Adapt IcicleEngine to ConcreteEngine

* Remove redundant assertions

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Move test_emulator.py to tests/sim/

* Fix missed rename

* Add HeavyConcreteState to __all__

* Fix lint

* Put it in the right place

* Move it to the top level

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-06-13 12:46:02 -07:00
Kevin Phoenix
1f9a763a78
Add icicle engine (#5435)
* Add icicle engine

* Improve docs and lint

* Format

* More lint

* Improve permissions mapping

* Add function for more complex arch conversion

* Improve page handling logic

* Add support and tests for thumb mode and switching

* Use backers instead of object segments to find all pages

* Add special case for gs on x86

* Fix thumb mode issues

* Reimplement icicle engine to integrate python bindings

* cargo fmt

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-05-19 10:58:24 -04:00
Kevin Phoenix
0bcefe9c98
Clean up broken tests (#5149)
* Clean up broken tests

* Improve lint

* Improve lint more
2025-01-06 19:26:55 -07:00
Kevin Phoenix
bd1a00ee8c
Unpack SimActionObjects in irop before passing them to claripy (#5060)
* Unpack SimActionObjects in irop before passing them to claripy

* Add test case

* Minor imporovements

* Fix import

* Improve lint
2024-12-04 14:42:59 -07:00
Kevin Phoenix
a4ed39c8a3
Rewrite TestSignedDiv to run cross-platform (#4956) 2024-10-14 13:39:10 -07:00
Ricky Zhou
15fc9fbeab
Fix checking of invalid instructions against the dirty addresses set. (#4935)
* Fix checking of invalid instructions against the dirty addresses set.

When an instruction cannot be disassembled, VEX can output an IMark with
an instruction length 0. Before this change, such instructions would
never trigger the dirty addresses set, so even after they have been
overwritten with a valid instruction, the engine would continue
emulating the stale, pre-overwrite IR. Fix this by conservatively
assuming that unknown-length instruction have the maximum instruction
length when checking whether they overlap a dirty addresses.
2024-10-07 09:50:14 -07:00
Jiaxin Peng
5b182a7c06
Use a newer libc.so.6 for x86_64/test_ioctl (#4903) 2024-10-02 12:34:21 -07:00
Kevin Phoenix
fa56ba3668
Use ruff TID252 to prevent reletive imports from parents (#4916) 2024-10-01 09:06:33 -07:00
Brian Caswell
e427875cbd
Fix typos (#4812)
* fix typos

This mostly fixes comments, but in a handful of places fixes bugs due to typos.

One example:
```
-            insn_op_idx=None if cmsg.operand_idx == -1 else cmsg.opearnd_idx,
+            insn_op_idx=None if cmsg.operand_idx == -1 else cmsg.operand_idx,
```

* more typo fixes

* address lint issues

* more import fixes?

* address feedback from PR

---------

Co-authored-by: Brian Caswell <bcaswell@microsoft.com>
2024-09-09 08:23:20 -07:00
Kevin Phoenix
819e910cf7
Use Base.identical instead of BackendVSA.convert() (#4815)
* Use Base.identical instead of BackendVSA.convert()

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Another one

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-09-06 15:13:00 -07:00
Kevin Phoenix
ec31174d18
Apply ruff RUF lints (#4794)
* Apply RUF lints

* Fix StopIteration bug
2024-08-29 18:44:14 -07:00
Kevin Phoenix
feda6f6909
Apply ruff SIM lints (#4793)
* Apply SIM lints

* Fix some failing tests

* Fix more bugs
2024-08-29 16:56:53 -07:00
Kevin Phoenix
28c3d3785e
Adopt ruff UP lints (#4792) 2024-08-29 13:03:39 -07:00
Kevin Phoenix
ee464d0338
Adopt from __future__ import annotations (#4790) 2024-08-28 18:31:43 -07:00
Matt Borgerson
b25fe9d7e4 vex: Fix pc_actions_SMUL intermediate result width 2024-08-28 00:39:47 -07:00