Skip to content

About

A store-and-query database for Android SO execution traces. Recover runtime behavior the binary itself does not contain.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

简体中文

SO Trace Database

SO Trace Database stores and queries Android SO (shared-library) execution traces. It lets an analyst recover runtime behavior the binary does not contain: branches taken, memory writes, register values, calls, and thread events that exist only while the library runs.

It is not a trace collector and does not replace Frida, Pin, or DynamoRIO. It is not a symbolic-execution framework. Collectors feed it; it answers questions about what they recorded.

Three ways in:

  • CLI — sotrace, for saving a trace and querying it from a shell.
  • HTTP API — sotrace-server, plus a React UI, for interactive analysis.
  • MCP — sotrace-mcp, so an AI agent can import, query, and analyze traces directly.

Apache-2.0 licensed.

Install

Linux x86_64. Either download the published binaries or build them from this tree.

CLI

curl -fsSL -o sotrace https://github.com/android-security-engineer/so-trace-database/releases/download/v0.1.0/sotrace-linux-x86_64
chmod +x sotrace
./sotrace --help

HTTP server — the API refuses to start without a token:

curl -fsSL -o sotrace-server https://github.com/android-security-engineer/so-trace-database/releases/download/v0.1.0/sotrace-server-linux-x86_64
chmod +x sotrace-server
SOTRACE_AUTH_TOKEN="$(openssl rand -hex 32)" SOTRACE_DATA_DIR=./data ./sotrace-server

The server listens on 0.0.0.0:8080. Check it with curl -fsS http://127.0.0.1:8080/api/v1/health. Set SOTRACE_BIND to change the address.

From source (Rust stable, and Node 20+ for the UI):

cargo build --release -p sotrace-cli -p sotrace-server -p sotrace-mcp
( cd frontend && npm install && npm run build )

Binaries land in target/release/. The UI dev server runs with npm run dev in frontend/ and proxies /api to the backend (override the target with API_PROXY_TARGET).

Hand this to your agent

Paste the block below to an agent (Claude Code, Cursor, or anything that runs shell commands). It detects the platform, installs the CLI, the server, and the MCP server, and wires the MCP server into Claude Code.

Install SO Trace Database (https://github.com/android-security-engineer/so-trace-database) on this machine and verify it works. Do the whole thing; only stop if a command needs something you cannot grant yourself.

1. Pick an install dir: ~/.local/share/sotrace for the binaries, ~/.local/bin on PATH. Create both.

2. Get the binaries. Prefer the published Linux x86_64 release:
   curl -fsSL -o ~/.local/bin/sotrace https://github.com/android-security-engineer/so-trace-database/releases/download/v0.1.0/sotrace-linux-x86_64
   curl -fsSL -o ~/.local/bin/sotrace-server https://github.com/android-security-engineer/so-trace-database/releases/download/v0.1.0/sotrace-server-linux-x86_64
   chmod +x ~/.local/bin/sotrace ~/.local/bin/sotrace-server
   If this is not Linux x86_64, or the download fails, clone the repo and run `cargo build --release -p sotrace-cli -p sotrace-server -p sotrace-mcp`, then copy target/release/{sotrace,sotrace-server,sotrace-mcp} into ~/.local/bin. Install Rust from https://rustup.rs first if cargo is missing.

3. Build the MCP server too if step 2 used the release binaries (the release does not ship it): clone and `cargo build --release -p sotrace-mcp`, copy target/release/sotrace-mcp to ~/.local/bin.

4. Choose a data directory, default ~/.local/share/sotrace/data. To spread storage across several disks, set SOTRACE_DATA_DIR to a `:`-separated list of paths and SOTRACE_REPLICATION_FACTOR to how many copies each trace should keep (for example `SOTRACE_DATA_DIR=/data/disk1:/data/disk2:/data/disk3 SOTRACE_REPLICATION_FACTOR=2`). One directory is the default and needs nothing set.

5. Generate a token and start the server in the background:
   export SOTRACE_AUTH_TOKEN="$(openssl rand -hex 32)"
   SOTRACE_DATA_DIR=~/.local/share/sotrace/data ~/.local/bin/sotrace-server
   Wait until `curl -fsS http://127.0.0.1:8080/api/v1/health` returns. Remember the token and tell me it.

6. Register the MCP server with Claude Code so I can drive it later:
   claude mcp add sotrace -- ~/.local/bin/sotrace-mcp
   and persist SOTRACE_DATA_DIR (and SOTRACE_SERVER_URL=http://127.0.0.1:8080) into that server's environment. If `claude` is not installed, skip this and print the JSON entry I should add by hand.

7. Verify: `sotrace --help` exits 0, the health endpoint answers, and report the install paths, data directory, bind address, and token.

Store and query

trace-save reads a trace file and prints the id it stored. query reads it back. --data-dir chooses where data lives (default ./.sotrace); repeat it, or join paths with :, to use more than one disk.

./sotrace --data-dir ./data trace-save trace.json          # prints the stored trace id
./sotrace --data-dir ./data query --trace-id 1 instructions 0 1000

--format selects the input: native (the JSON envelope), or Frida, DynamoRIO, and Pin output. Other collectors — QEMU, Valgrind, strace, ltrace, perf, GDB, LLDB, Ghidra, IDA, Binary Ninja, rizin, and more — are covered by the plugins under plugins/.

Storage that spans disks and machines

A trace corpus outgrows one disk, and one disk is a single point of failure. The storage layout is volumes plus replica sharding:

  • A volume is a directory. SOTRACE_DATA_DIR=/data/a:/data/b:/data/c (or repeated --data-dir flags) puts traces on all three. Mount extra disks and list them.
  • A trace is the unit of sharding. Trace id lives on shard id % shard_count, and SOTRACE_REPLICATION_FACTOR=2 keeps a byte-identical copy on the next volume. Reads try the primary, then each replica, so losing a disk loses no trace as long as one copy survives.
  • SO files are small and mirrored to every volume, so function names resolve wherever a trace replica is.
  • One directory behaves exactly as before. Nothing about existing data changes.

The same rule is how more than one machine shares the data: a remote machine is a volume this process does not host. Membership goes in <first volume>/cluster.json. After a node commits a trace it pushes a byte-identical copy to the peers that cluster.json assigns the replica shards to, and a query that lands on a node without the trace pulls it back from the peer that has it, so any node answers. Set the same SOTRACE_CLUSTER_TOKEN on every node; without it a node refuses cluster calls and never dials its peers. The server also tells you where a trace lives:

curl -fsS -H "Authorization: Bearer $SOTRACE_AUTH_TOKEN" http://127.0.0.1:8080/api/v1/cluster
curl -fsS -H "Authorization: Bearer $SOTRACE_AUTH_TOKEN" http://127.0.0.1:8080/api/v1/cluster/placement/42

The design is in docs/ARCHITECTURE.md §4.5.

Configuration

Variable Who reads it Meaning Default
SOTRACE_DATA_DIR server, CLI, MCP Volume path, or a :/;-separated list of them ./data (server), ./.sotrace (CLI), unset = in-memory only (MCP)
SOTRACE_SHARD_COUNT server, CLI, MCP Slots in the shard ring number of volumes
SOTRACE_REPLICATION_FACTOR server, CLI, MCP Copies of each trace, primary included 1
SOTRACE_BIND server Listen address 0.0.0.0:8080
SOTRACE_AUTH_TOKEN server Bearer token; required, the server exits without it none
SOTRACE_CLUSTER_TOKEN server, CLI, MCP Shared secret for node-to-node replication; empty disables it none
SOTRACE_JWT_SECRET server Signs access tokens from /auth/login a fixed dev secret
SOTRACE_SERVER_URL MCP HTTP server the GUI-control tools talk to unset

CLI flags mirror the first three: --data-dir (repeatable), --shard-count, --replication-factor.

Documentation

About

A store-and-query database for Android SO execution traces. Recover runtime behavior the binary itself does not contain.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages