#panda #callback #guest #interfacing #syscalls #bindings #analysis

panda-re

The official library for interfacing with PANDA (Platform for Architecture-Neutral Dynamic Analysis)

43 breaking releases

0.46.2 Jan 31, 2024
0.46.1 Jul 12, 2023
0.46.0 Jan 3, 2023
0.45.0 Dec 13, 2022
0.3.0 Dec 18, 2020

#597 in Rust patterns

Download history 7/week @ 2023-12-20 2/week @ 2023-12-27 175/week @ 2024-01-03 236/week @ 2024-01-10 70/week @ 2024-01-17 154/week @ 2024-01-24 88/week @ 2024-01-31 39/week @ 2024-02-07 105/week @ 2024-02-14 519/week @ 2024-02-21 74/week @ 2024-02-28 49/week @ 2024-03-06 73/week @ 2024-03-13 32/week @ 2024-03-20 56/week @ 2024-03-27 70/week @ 2024-04-03

244 downloads per month

GPL-2.0 license

465KB
9K SLoC

panda-rs is a set of Rust bindings for PANDA.

The following are provided:

  • Callbacks to various PANDA events in the form of attribute macros
  • Callbacks for when guest syscalls happen
  • Bindings to various core PANDA plugins (hooks2, osi, etc)
  • Safe bindings to the core PANDA API
  • An API for driving PANDA via libpanda
  • Access to raw PANDA and QEMU API bindings via panda_sys

Feature flags:

  • libpanda - enable libpanda mode. This is used to allow for compiling as a binary that links against libpanda, for pypanda-style use.

Architecture-specific features

PANDA supports multiple architectures, but requires plugins to be compiled for each architecture. In order to target a specific guest arch, use exactly one of the following: x86_64, i386, arm, aarch64, mips, mipsel, mips64, ppc

Typically PANDA plugins forward each of these features in their Cargo.toml:

[features]
x86_64 = ["panda/x86_64"]
i386 = ["panda/i386"]
# ...

Callbacks

panda-rs makes extensive use of callbacks for handling analyses on various events. To use callbacks, you simply apply the callback's attribute to any functions which should be called for the given callback. In order to use a callback in a PANDA plugin (not to be confused with an application that uses libpanda), one function must be marked #[panda::init], otherwise the plugin will not work in PANDA.

Callbacks come in two forms: free form functions (which use the attribute macros) mentioned above) and closure callbacks, which use the Callback API.

libpanda Mode

PANDA also offers a dynamic library (libpanda). panda-rs allows linking against libpanda instead of linking as a PANDA plugin. This creates a executable that requires libpanda to run. To compile in libpanda mode, make sure the PANDA_PATH environment variable is set to your PANDA build folder.

Important Popular Callbacks Popular Plugins
init before_block_exec osi
Panda virt_mem_after_read proc_start_linux
[mod@hook] virt_mem_after_write hooks2
on_sys asid_changed guest_plugin_manager
uninit before_block_exec_invalidate_opt
regs insn_translate
PandaArgs insn_exec

Dependencies

~15MB
~404K SLoC