A memory acquisition tool that captures process memory snapshots into the MSL (Memory Slice) binary format. Supports multiple debugger backends (Frida, GDB, LLDB) and targets across Windows, Linux, macOS, Android, and iOS. Designed for forensic analysis, reverse engineering, and security research.
- Pluggable backends: Frida (local, USB, remote), GDB (MI3 protocol), LLDB (Python API)
- Investigation mode: Captures system-wide context — process tables, network connections, file handles, boot time, OS details
- AEAD encryption: AES-256-GCM with Argon2id key derivation (default in investigation mode)
- MSL binary format with region metadata, module info, and page-level granularity
- Compression support: zstd, lz4, or none
- BLAKE3 integrity chain across all blocks
- Region filtering by memory protection, address range, or path patterns
- Page-level acquisition with quality assessment
- RWX region detection for forensic analysis
- Progress reporting with per-region and per-page statistics
- Companion log file captures all debug output regardless of verbosity flag
- Cross-platform OS information collection for forensic context
Analyzing slices (see Emulating & analyzing slices):
- Emulator (
memslicer-emu, Unicorn + Capstone): single-step and reverse execution, multi-arch - Per-thread emulation: list captured threads and seed from any of them
- Vector/FP registers (XMM/YMM) seeded at full width for SIMD/crypto code
- fs/gs base & Windows TEB/PEB resolution for TLS / PEB-relative accesses
- Self-modifying-code / unpacking detection — flags write-then-execute and dumps the recovered payload
- Symbolic execution (angr) and a behavior graph (control flow + syscalls/APIs)
- radare2 plugins to open, inspect (maps, symbols, PE exports) and emulated-debug a slice
pip install memslicerThis installs memslicer with all backends (Frida, GDB, LLDB).
git clone git@github.com:MemorySlice/memslicer.git
cd memslicer
pip install -e .Requires Python >= 3.10. Backend-specific requirements:
- Frida: A compatible Frida agent on the target device (for USB/remote targets)
- GDB:
gdbbinary with MI3 support (installed separately) - LLDB: LLDB Python module on
PYTHONPATH(typically via Xcode on macOS)
Reading another process's address space is a privileged operation on every
supported OS. A capture needs either elevated privileges, or a relaxed
ptrace policy — memslicer cannot grant itself either one.
These are requirements imposed by the operating system, not by memslicer. The tool diagnoses them before it touches the target and refuses with exit code 3 rather than failing halfway.
Either of these works:
1. Run elevated.
sudo memslicer 1234or grant CAP_SYS_PTRACE to the binary, if you would rather not run the whole
capture as root.
2. Set Yama ptrace_scope to 0, and run as the user that owns the target.
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope # until reboot
sudo sysctl -w kernel.yama.ptrace_scope=0 # equivalentMake it survive a reboot with a file in /etc/sysctl.d/.
ptrace_scope = 0is not a substitute for root. It restores classic same-uidptrace— it does not let an unprivileged user attach to a process owned by somebody else. Capturing another user's process still needs root orCAP_SYS_PTRACE, whatever the scope is set to.
ptrace_scope |
Meaning |
|---|---|
0 |
Classic — any process may attach to another process of the same uid. |
1 |
Distro default — only a direct parent, or a PR_SET_PTRACER grantee, may attach. |
2 |
Admin-only — attaching requires CAP_SYS_PTRACE. |
3 |
ptrace disabled system-wide. One-way latch: it cannot be relaxed at runtime. Reboot with kernel.yama.ptrace_scope set to 0–2 via /etc/sysctl.d/, and record the constraint in the case notes. |
memslicer never changes ptrace_scope itself. It reports the value it
found and prints the command to change it; making and documenting that change
is the examiner's decision. Silently relaxing a kernel security control
mid-acquisition would be both a forensic and a security problem.
An AppArmor or SELinux profile on the target can deny ptrace even for root.
If an attach fails with ptrace_scope at 0 and root in hand, check
sudo dmesg | grep -i apparmor for a DENIED line.
The preflight check runs on Linux, for a numeric PID. Attaching by process name, or to a remote device, skips it — a failure there surfaces from the backend instead, without the diagnosis.
task_for_pid requires root for any process not signed with the
com.apple.security.get-task-allow entitlement:
sudo memslicer 1234 -b lldbWith System Integrity Protection enabled, Apple-signed and hardened-runtime processes cannot be attached at all, root or not. memslicer warns when it detects this:
macOS System Integrity Protection (SIP) is enabled. Attaching to Apple-signed or hardened-runtime processes will fail. Only debug builds with
com.apple.security.get-task-allowentitlement can be debugged. Disable SIP or use the Frida backend for broader process access.
Check the current state with csrutil status.
Opening another user's process, or a service, requires Administrator —
SeDebugPrivilege is what actually grants it. Run the terminal elevated.
Note that memslicer does not request SeDebugPrivilege itself; it relies
on the backend and on the token it inherits. Without elevation the capture may
still succeed for a process you own, but investigation mode degrades: the
handle table comes back empty rather than failing the capture.
frida-server must be running as root on the device:
adb shell "su -c '/data/local/tmp/frida-server &'"
memslicer com.example.app -Umemslicer probes for root-management markers (Magisk, KernelSU, APatch, Zygisk) and records what it finds as forensic metadata. That detection is advisory only — it never gates a capture, and a rooted device should not be assumed to have intact runtime integrity.
The GDB backend is a poor fit here, and memslicer says so: SELinux policy may
block attachment and /proc access, and ART managed-heap data will be opaque.
Prefer -b frida -U.
A jailbroken device with frida-server installed. Stock iOS sandboxing
blocks the process access memslicer needs, and utilities such as ps and
lsof may be missing entirely, which thins out investigation mode.
Using the LLDB backend remotely additionally requires debugserver on the
device. The Frida backend is the more reliable route for iOS.
A refused attach names the cause and the fix, and touches nothing on the target:
Error: cannot attach to PID 3145: Yama ptrace_scope is 2 — attaching is admin-only and requires CAP_SYS_PTRACE
also: target runs as uid 0 while this process runs as euid 501 without CAP_SYS_PTRACE
→ Yama ptrace_scope is 2 (admin-only): attaching requires CAP_SYS_PTRACE. Run as root, or: sudo sysctl -w kernel.yama.ptrace_scope=0
→ Run the acquisition as root (sudo), or grant CAP_SYS_PTRACE to the memslicer binary.
Full environment record: dump.msl.log
Each → line is a remediation for one blocker. A Probable cause: line
appears when something was observed that did not itself block — an AppArmor
profile on the target, for instance.
The full privilege situation at capture time — uid, capabilities,
ptrace_scope, LSM profile, tracer PID — is written to the companion
.msl.log even when the capture succeeds, so the constraint is documented in
the case file.
Dump a process by name (Frida backend, default):
memslicer chromeDump a process by PID:
memslicer 1234Specify output file and compression:
memslicer chrome -o chrome_dump.msl -c zstdNeeds root, CAP_SYS_PTRACE, or ptrace_scope = 0 with a same-uid target — see Privileges.
Dump a local process using Frida (default backend):
memslicer 1234Use GDB backend (no Frida dependency required):
memslicer 1234 -b gdbInvestigation mode with full system context (encrypted by default):
memslicer 1234 -I -vThis captures process tables, network connections, file handles, boot time, hostname, and OS details from /proc alongside the memory dump. The output is encrypted with AES-256-GCM; you will be prompted for a passphrase.
Investigation mode without encryption:
memslicer 1234 -I --no-encryptNeeds frida-server running as root on the device — see Privileges.
Dump a process on a USB-connected Android device (requires Frida server on device):
memslicer com.example.app -UOverride OS detection if auto-detection fails:
memslicer com.example.app -U --os androidInvestigation mode on Android (captures system properties, process table, network state):
memslicer com.example.app -U -IConnect to a remote Frida server on Android (e.g., over Wi-Fi):
memslicer com.example.app -R 192.168.1.10:27042 --os androidDump by PID on a USB Android device:
memslicer 12345 -U --os android -o app_dump.msl -c zstdOn Android 14+ (API 36) even a trivial app maps roughly 3.3 GB of readable
memory, of which only about 100 MB is resident: the two 1 GB
[anon:dalvik-LinearAlloc] reservations and the ~600 MB ART heap
reservation are untouched zero pages, while the system libraries account for
only ~300 MB. --scope app alone therefore saves little; --resident-only
is what shrinks the dump. Combine the two for the smallest useful slice.
Dump only the app's heap and stacks of a running app:
memslicer com.example.app -U --scope heap,stackShrink a dump to resident pages (never-touched anonymous pages are skipped and
recorded as PageState NotResident):
memslicer com.example.app -U --scope app --resident-only -c zstdPreview what a dump would contain (enumerates and classifies regions, writes nothing; the Frida agent is still injected):
memslicer com.example.app -U --scope heap,stack --dry-runExclude a module (glob on the basename; the .bss attributed to it is
excluded with it):
memslicer com.example.app -U --exclude-module 'libhwui*' --exclude-module 'libGLES*'macOS needs root unless the target carries get-task-allow; iOS needs a jailbroken device — see Privileges.
Use LLDB backend on macOS (no Frida needed):
memslicer 1234 -b lldbDump a process on a USB-connected iOS device (jailbroken, Frida):
memslicer SpringBoard -U --os ios -INeeds Administrator for another user's process or a service — see Privileges.
Dump a local process on Windows:
memslicer 1234 -b gdbOr with Frida:
memslicer notepad.exeForensic capture with full debug log:
memslicer 4892 -v -o evidence.msl -c zstdInvestigation mode with encryption (default):
memslicer 4892 -I -o investigation.mslCapture only readable and writable regions:
memslicer chrome --filter-prot rw-Capture a specific address range:
memslicer chrome --filter-addr 0x7fff00000000-0x7fffffffffffInclude regions without read permission (for completeness):
memslicer chrome --include-unreadableLimit region size and set a per-read timeout:
memslicer chrome --max-region-size 104857600 --read-timeout 30memslicer verify checks a slice's PrevHash chain (spec §4.4) and its
EndOfCapture FileHash, using the hash algorithm recorded in the file
(BLAKE3, SHA-256 or SHA-512/256):
$ memslicer verify dump.msl
hash=BLAKE3 encrypted=no blocks=97 (header BlockCount=0, EoC BlockCount=97)
chain: OK
FileHash: OK
extensions: 0 segment(s)
VALID
Encrypted slices are decrypted first (the AEAD tags are checked) and the
FileHash is verified over the plaintext; pass --passphrase or enter it when
prompted. A missing EndOfCapture, a legacy zero Block-0 PrevHash and bytes
after the last verified segment (trailing: N byte(s)) are printed as
warnings and do not fail verification. A header or EoC BlockCount that
disagrees with the blocks on disk is an error.
Every extension segment after the EndOfCapture (spec §4.6) is checked for
chain continuity, SegmentHash and BlockCount and printed as
segment k: OK (...) or segment k: BROKEN (...); a broken segment makes
the slice INVALID. A slice produced by memslicer-enrich therefore shows:
$ memslicer verify dump.enriched.msl
hash=BLAKE3 encrypted=no blocks=97 (header BlockCount=0, EoC BlockCount=97)
chain: OK
FileHash: OK
extensions: 1 segment(s)
segment 1: OK (2 blocks, producer=memslicer-enrich/0.5.0)
VALID
memslicer-enrich <slice> [-o OUT | --in-place] adds ELF build-ids that were
not available at capture time. The capture segment -- header, every block and
the original EndOfCapture -- is copied verbatim and the build-id manifest goes
into a new extension segment (spec §4.6) appended after it, closed by an
EndOfExtension block (0x0FFE). The original EoC FileHash stays valid and
memslicer verify lists the segment. Running it again on an enriched slice
prints nothing to enrich and writes nothing.
Encrypted slices are enriched with --passphrase P (prompted for when
omitted): the manifest goes into a sealed extension segment (spec §10.8),
encrypted under its own segment key and chained to the previous AEAD tag, and
appended after the last sealed segment in a single write -- the primary
ciphertext and tag are never rewritten, and --in-place appends to the
original directly. memslicer verify then reports sealed=N. Only slices
written with CipherLen (memslicer >= 1.1.1 to a seekable file) can take
sealed segments; older ones, and slices with unverified trailing bytes, are
refused unchanged.
memslicer has two subcommands: acquire (capture a process) and verify
(check a slice). memslicer <target> ... is shorthand for
memslicer acquire <target> .... A process literally named acquire or
verify must be given as memslicer acquire <name> (or by PID).
Usage: memslicer acquire [OPTIONS] TARGET
Dump process memory to MSL format.
TARGET is a PID (integer) or process name (string).
Supports 4 acquisition modes:
Analysis unencrypted (default), Analysis encrypted (-E),
Investigation encrypted (-I, default), Investigation unencrypted (-I --no-encrypt).
Options:
-b, --backend [frida|gdb|lldb] Debugger backend. [default: frida]
-o, --output PATH Output .msl file path.
-c, --compress [none|zstd|lz4] Compression algorithm. [default: none]
-U, --usb Connect to a USB device (Frida only).
-R, --remote HOST:PORT Connect to a remote Frida server (Frida only).
--os [windows|linux|macos|android|ios]
Override automatic OS detection.
--filter-prot TEXT Filter regions by protection (e.g. 'rw-', 'r--').
--filter-addr TEXT Filter regions by address range (e.g. '0x1000-0x2000').
-v, --verbose Enable verbose/debug output.
--read-timeout FLOAT Per-read timeout in seconds. [default: 10]
--include-unreadable Include memory regions with no read permission.
--skip-kernel-pseudo Skip kernel pseudo-mappings ([vvar], [vsyscall])
instead of attempting them.
--max-region-size INT Skip regions larger than this size (0 = no limit).
--scope TEXT Which memory to capture: full (default), app (drop
clean read-only mappings of system libraries and
device memory), heap (every native and managed heap),
stack (thread stacks). Combine with commas, e.g.
heap,stack (alias: heapstack).
--exclude-module PATTERN Skip regions belonging to modules matching this glob
(basename, e.g. 'libhwui*'; full path when the
pattern contains '/'). Repeatable.
--app-path PREFIX Treat files under this path prefix as app-owned for
--scope app. Repeatable.
--resident-only Skip anonymous pages that were never touched (not
resident, not swapped); they read as zero. Needs
/proc/<pid>/pagemap or mincore in the target; falls
back to full reads with a warning.
--dry-run Enumerate and classify regions, print what would be
captured under the current options, and exit without
writing a file. On the Frida backend this still
injects the agent into the target.
--no-registers Do not capture thread register state (no Thread
Context blocks). Thread stack pointers are then
only queried for --scope heap/stack.
-I, --investigation Investigation mode: capture system-wide context.
-E, --encrypt Enable AEAD encryption (AES-256-GCM + Argon2id).
--no-encrypt Disable encryption (overrides -I default).
--passphrase TEXT Encryption passphrase (prompted if not provided).
--key-hints Hook Windows CNG key-derivation APIs
(BCryptGenerateSymmetricKey, NCryptDeriveKey)
during capture and record where derived key
material lives as KeyHint blocks (Frida only).
--help Show this message and exit.
--scope selects which regions are captured; the module list and the VAS Map
always stay complete. Tokens can be combined with commas (heap,stack;
heapstack is an alias); full cannot be combined with other tokens.
appdrops clean read-only/executable mappings of system-owned files and device mappings (/dev/*, dmabuf). System-owned means Android/system,/system_ext,/apex,/vendor,/odm,/product,/oem,/data/dalvik-cache; Linux/lib*,/usr/lib*,/usr/libexec,/usr/share,/usr/bin,/usr/sbin,/bin,/sbin,/etc; macOS/iOS/usr/lib,/System,/Library/Apple, the cryptexes and the dyld shared cache; Windows<drive>:\Windows. It keeps the writable.data/.bssof system libraries, the main executable, everything under--app-path, and all anonymous memory.heapkeeps every heap:[heap], scudo/libc_malloc/GWP-ASan/bionic_alloc/ jemalloc arenas, every ART/Dalvik space including the boot/app image.artspaces and legacy/dev/ashmem/dalvik-*, and unnamed writable anonymous memory (glibc arenas, macOS malloc zones, Windows private heaps, custom allocators) that is not a detected thread stack.stackkeeps[stack],[anon:stack_and_tls:*], signal stacks, TLS and, on platforms without named stacks, the unnamed regions that contain a thread's current stack pointer (FridaenumerateThreads, GDB$sp, LLDB frame SP).
--exclude-module PATTERN is a repeatable glob matched against the module
basename, the full path when the pattern contains /, the module name, or an
anonymous label such as dalvik-LinearAlloc. A .bss attributed to the
adjacent module is excluded together with it. --app-path PREFIX (repeatable)
marks files under that prefix as app-owned for --scope app.
--resident-only skips anonymous pages that are neither present nor swapped;
they read as zero. It is never applied to file-backed mappings. Residency comes
from /proc/self/pagemap, read inside the target by the Frida agent, or from
mincore combined with the per-mapping Swap: figures of /proc/self/smaps
(a mapping that holds swapped pages is read in full, because mincore cannot
see swapped pages); local GDB/LLDB captures read /proc/<pid>/pagemap on the
host. On Android an app may not open its own pagemap (SELinux), so the Frida
backend uses the mincore path there. Without either source memslicer falls
back to full reads and prints a warning. Skipped pages are recorded with
PageState NotResident (value 3, spec 1.1 Table 24) so readers can tell them
from read failures; readers that predate the value must treat it as a 0-byte
page.
Reading a page is itself a write to the page tables: the first dump of a
process faults every untouched anonymous page in (it is backed by the kernel
zero page afterwards), and from then on residency sources report it as
present. --resident-only therefore only shrinks the first capture of a
process; a second capture of the same process finds almost everything
resident. Measured on an API 36 emulator: a never-dumped Clock app read
615 MB instead of 3.3 GB (2.6 GiB skipped) in 15 s, and --scope heap,stack --resident-only read 94 MB in 3.4 s.
Regions left out by --scope or --exclude-module are listed in a
RegionOmissionManifest block (0x005B, a non-spec extension) carrying the
scope, the exclude patterns and one row per omitted region (base, size,
protection, region type, reason, name). The block is only written when
something was omitted.
--dry-run enumerates and classifies the target's regions and prints what the
current options would capture, per category and per owner, without writing a
file (on the Frida backend the agent is still injected):
MemSlicer - Dry run for com.example.app (nothing is written)
Backend: frida | Device: USB | OS: Android | Scope: heap,stack | Exclude: none
Regions : 2874 enumerated, page size 4,096
category regions kept bytes kept regions skipped bytes skipped
anon-named 0 0 B 318 2.1 GiB
heap-managed 41 612.3 MiB 0 0 B
image 0 0 B 1402 291.7 MiB
device 0 0 B 58 120.0 MiB
heap-native 23 96.5 MiB 0 0 B
stack 118 94.2 MiB 0 0 B
mapped-file 0 0 B 611 88.4 MiB
bss 0 0 B 202 14.9 MiB
anon 37 12.6 MiB 0 0 B
shared-mem 0 0 B 64 9.3 MiB
kernel 0 0 B 2 8.0 KiB
Top owners:
owner bytes kept bytes skipped
dalvik-LinearAlloc 0 B 2.0 GiB
dalvik-main space (region space) 512.0 MiB 0 B
libhwui.so 0 B 41.2 MiB
dalvik-zygote space 38.7 MiB 0 B
scudo:primary 31.9 MiB 0 B
stack_and_tls:12345 8.0 MiB 0 B
Would capture 815.6 MiB of 3.2 GiB readable bytes across 219 of 2874 regions
Skipped :
2597 outside selected --scope (heap,stack)
58 no read permission (use --include-unreadable to include)
Every thread's register file is written as a Thread Context block (0x0011,
spec §5.7) on the Frida, GDB and LLDB backends; --no-registers turns this
off. On Android, Frida enumerates threads of ordinary apps but none for privileged
system apps (priv_app, platform_app), so such captures carry no
Thread Context blocks and the log notes it once. A thread whose register file
lacks a program counter or stack pointer cannot be written (spec §5.7); such
threads are left out and listed in a single warning (thread ids and the
missing register), with a separate message when no thread survives.
Register names are the canonical mnemonics of spec Table 19g whatever the
backend calls them (ARM64 fp/lr/cpsr are written as x29/x30/pstate,
x86_64 eflags as rflags), and the TLS role is set only on the register the
target OS uses as thread pointer (fs_base on Linux x86_64, gs_base on
Windows x64, tpidr_el0 on Linux ARM64, ...). A Frida CpuContext carries no
segment base, so on Windows x86/x64 the agent reads each thread's TEB with
NtQueryInformationThread and records it as gs_base (x64) / fs_base (x86).
LLDB also records vector and x87 registers (xmm*, ymm*, stmm*, ...) at
their full width.
Usage: memslicer verify [OPTIONS] FILE
Verify an MSL slice's PrevHash chain and EoC FileHash.
FILE is the .msl slice to check. Exits 0 when valid, 1 otherwise.
Options:
--passphrase TEXT Decryption passphrase (prompted if the slice is encrypted
and not provided)
-h, --help Show this message and exit.
MemSlicer includes a behavior graph engine that reconstructs execution traces, control flow, syscalls, and Windows API calls from MSL memory snapshots into Dynamic Control-Flow Graphs (DFCG).
# Extract basic-block CFG in IDA Pro disassembly style
memslicer-behavior dump.msl --stublib -g block -o graph.dot
memslicer-behavior dump.msl --stublib -o graph.json
# Extract high-level function call graph
memslicer-behavior dump.msl --stublib -g function -o callgraph.json
# Pass an input argument (e.g., password string in RCX)
memslicer-behavior dump.msl --arg0 "S3cr3tKey!" -g block -o graph.dot-g, --granularity [block|instruction|function]:block(default): Basic-block level Control Flow Graph (CFG).instruction: Single-step instruction execution trace.function: High-level Call Graph summarizing function-to-function calls and API interactions (collapses thousands of basic blocks for analyzing massive binaries without clutter).
--style [ida|basic]:ida(default): Renders IDA Pro / Binary Ninja style disassembly tables with memory addresses, hex opcodes, assembly mnemonics, and resolved symbol comments.basic: Simple node boxes for basic DOT renderers.
--arg0, --rcx TEXT: Pass an input string or memory argument inRCXregister for analyzing functions that expect arguments.--start ADDR: Override the start address (default: the captured PC).-n, --max-steps N: Cap on emulated instructions (default100000).-f, --format [json|dot|graphml|gexf]: Output format (otherwise inferred from the-oextension).--premap-stack / --no-premap-stack(default on): a slice only captures a few pages around the captured stack pointer, so deeper frames used to stop the trace withUC_ERR_*_UNMAPPED. The emulator now backs a 64 MB window around SP with blank RW pages. Because that turns a loud fault into a quiet zero, every read of such invented memory is tracked and reported (graph.meta['synthetic_stack_reads']and in the run summary). Use--no-premap-stackto get the old fail-loud behaviour.- Sub-Graph Module Clustering (
subgraph cluster_*): Automatically groups basic blocks and API call nodes by their owning module (notepad.exe,USER32.dll,win32u.dll, etc.) inside dashed bounding boxes. - Color-Coded Branching:
- Green (
#2e7d32): Conditional branch taken (jump_true). - Red (
#c62828): Conditional branch not taken / fallthrough (jump_false). - Dashed Gray: API and Syscall invocations.
- Dashed Orange: Dataflow / buffer pointer relationships.
- Green (
Open tools/graph_viewer.html in any web browser (file:// supported) and drag & drop your generated graph.json file. It renders an interactive 2D D3.js visualization with HTML5 disassembly cards, color-coded branching, search, and filtering options.
MemSlicerRev integrates an advanced symbolic execution bridge powered by angr to explore execution paths, deobfuscate memory, and solve path constraints directly from .msl snapshot files.
python -m memslicer.cli_symbex <dump.msl> --find <TARGET_ADDR> --avoid <FAIL_ADDR> [OPTIONS]-f, --find ADDR/-a, --avoid ADDR: Address(es) to reach / bypass (repeatable, hex or decimal).--find-max-steps N: Give up a--find/--find-rax-successsearch afterNsimulation steps (default2000,0= no limit).-m, --avoid-module NAME|LO-HI: Avoid every address inside a module (by name) or an address range (repeatable).-s, --steps N: Step forward N symbolic steps when no--findtarget is given (prints live progress).-r, --find-rax-success: Look for paths where the function returnsRAX == 1. Only meaningful for license/key-check style targets; on generic real-world code almost any function can return 1, so prefer--find.-v, --veritesting: Hybrid static/dynamic symbolic execution (Veritesting) to merge states and limit path explosion in loops.-b, --bypass-anti-analysis: Hook common anti-debug APIs and mask PEB debug flags (see feature 3).-u / --no-auto-map-unmapped(default on): Automatically map unmapped pages and stub missing code/APIs (see feature 4).--no-syscall-handler: Do not hook syscall instructions with the generic stub; angr's own syscall models (e.g. a symbolic-stdinread) are used instead (see feature 4).--raw-blob:DUMPis a raw x86-64 code blob mapped at0x0, not an MSL slice. Without it, a file that is not a valid slice is an error.
Symbolic buffer injection. A plain run starts from the exact captured state. A symbolic buffer is written over captured memory only when one of these options is given:
-k, --sym-bytes N: Inject anN-byte buffer (default16when another injection option is given). Printable ASCII (0x20-0x7E) followed by a NUL, like a C-string key.--binary-key: Unconstrained raw bytes, with no trailing NUL.--buffer-addr ADDR: Explicit address for the buffer (otherwise aRBP-0x40/RSP+0x20heuristic is used).--use-key-hints: Place the buffer at a live-captured KeyHint (see feature 5) and adopt its key length as--sym-bytes; no NUL is written after the key. An explicit--buffer-addrstill wins.-e, --entry ADDR: Override the start PC (useful when the slice was captured parked inSleep/fgets).-c, --call-function ADDR: Build a clean call state for the function atADDR, passing the buffer as its first argument.
The CLI automatically inspects SMT solver constraints upon reaching target addresses and classifies input vectors by source:
- CPU Registers: Formatted in canonical 64/32-bit hexadecimal notation (
0x...). - RAM Memory & Pointer Linkage: Automatically maps CPU pointers to resolved memory buffers (e.g.,
RCX (0xc000000000000000) ---> Points to text: 'S3cr3tKey!'). - Memory Region Classification: Categorizes virtual addresses (Stack, Heap, Executable Image, or Symbolic Virtual Memory).
- Multi-Channel Classification: Symbolic inputs are grouped by the name of their symbolic variable (STDIN, files, sockets,
argv, environment). This only applies when those inputs are actually symbolic in the state; a slice loaded from a real dump normally only has the injected buffer.
Reduces if-else) into unified boolean expressions inside the Z3 solver pool.
Includes dedicated SimProcedure stubs and PEB sanitization to bypass evasion checks in malware:
- API Stubs: Intercepts
IsDebuggerPresent,CheckRemoteDebuggerPresent, andNtQueryInformationProcess(ProcessDebugPort,ProcessDebugFlags). - PEB Masking: Sanitizes
BeingDebugged(0) andNtGlobalFlag(0) in process memory. - Works on real multi-module dumps: angr only loads the region holding the captured PC as a real CLE
object, so other DLLs have no symbol table. When symbol hooking finds nothing, the APIs are resolved by
parsing each module's PE export table directly from captured memory (forwarders are skipped) and hooked
by address. Use it from the CLI with
--bypass-anti-analysis.
from memslicer.symbex.angr_loader import load_angr
from memslicer.symbex.anti_analysis import apply_anti_analysis_bypass
# Load MSL slice and apply anti-debugging bypass
project, state = load_angr("snapshot.msl")
apply_anti_analysis_bypass(project, state)
# Explore symbolically
simgr = project.factory.simgr(state, veritesting=True)
simgr.explore(find=0x14000175e, avoid=0x140001765)A slice only contains what was captured, so symbolic paths regularly touch memory or code that is not in it.
With auto-mapping on (the default), the stack is pre-mapped around SP, missing data pages are mapped on demand,
and calls into missing code get a generic return stub. Recovery only applies to genuinely new (synthetic)
memory, never to already-loaded code that is simply revisited. Every syscall/sysenter/int 0x80/int 0x2e/svc
instruction found by a linear sweep of the loaded code is hooked (the instruction alone, so the instructions
before it still run) with a stub that logs the call resolved per OS/arch (Windows NT and Linux tables) and
returns 0; a state that errored on a syscall is repaired by skipping the instruction. Syscalls have no real
side effects. --no-syscall-handler turns both off and leaves syscalls to angr.
memslicer acquire <pid> --backend frida --key-hints hooks the Windows CNG key-derivation APIs
(BCryptGenerateSymmetricKey, NCryptDeriveKey) during the capture and records where the derived key
material lives as KeyHint blocks (region + offset + length). memslicer-symbex --use-key-hints then injects
the symbolic buffer exactly there instead of guessing:
memslicer acquire 1234 --backend frida --os windows --key-hints -o target.msl
memslicer-symbex target.msl --use-key-hints --steps 50
# [+] Using KeyHint at 0x7ff7bebf4020, key_len=32 -> --sym-bytes 32 (BCryptGenerateSymmetricKey)Only keys derived while the capture is running are caught (hooks are armed at attach time); a one-shot
derivation that happens before or after the capture window produces no hint. The header's CryptoHints
capability bit is set whenever the hooks could be armed, even if no key was derived during the capture.
Useful for targeted symbolic extraction of comparison-based logic and common Windows x64 anti-debug bypass. It does not unpack, defeat anti-VM checks, model real syscall effects or follow other processes.
MemSlicer writes memory snapshots to the MSL (Memory Slice) binary format. Each file contains:
- A file header (MSL 1.1, format version
0x0101) with target metadata and capture timestamp; the header's BlockCount stays 0, the EndOfCapture block carries the exact count - Process identity block (ppid, session ID, start time, executable path, command line)
- Thread Context blocks (0x0011), one per thread, with thread ID, state, name and register
file (Frida, GDB and LLDB; none with
--no-registers) - Module list with base addresses, sizes, and paths
- Per-region records with base address, size, protection flags, and page-level data
- A VAS Map block (0x1001) listing every enumerated mapping -- captured, filter-skipped or
left unread by an abort -- sorted by base address, with protection, region type and the
full mapping name (e.g.
[anon:dalvik-main space (region space)],[anon:scudo:primary]). A VAS entry without a matching region record is a range whose bytes were not stored. Every entry records itsNameSource(spec §5.8). - A RegionOmissionManifest block (0x005B, non-spec extension) when
--scopeor--exclude-moduleleft regions out: the scope, the exclude patterns and one row per omitted region (base, size, protection, region type, reason, name) - Per-page states; anonymous pages skipped by
--resident-onlycarry PageStateNotResident(3, spec 1.1 Table 24) and 0 bytes of data, distinct from read failures - BLAKE3 integrity chain across all blocks
- Zero or more extension segments after the EndOfCapture (spec §4.6), each closed by an
EndOfExtensionblock (0x0FFE) carryingSegmentHash,BlockCountand the producer;memslicer-enrichappends its build-id manifest this way - Optional compressed data blocks (zstd or lz4)
- Optional AEAD encryption (AES-256-GCM + Argon2id)
When investigation mode (-I) is enabled, the MSL file additionally contains:
- System context: boot time, hostname, domain, OS detail string
- System-wide process table (all running processes)
- Network connection table (TCP/UDP, IPv4/IPv6)
- File handle table (open file descriptors for the target process)
A companion .log file is written alongside every .msl file and contains the full debug output of the capture session, regardless of whether -v was passed.
MemSlicer - Dumping chrome -> chrome_1773528836.msl
Backend: frida | Compression: none | Device: local
Progress: [##################################################] 100.00% Complete
Regions : 2621/4199 (1578 filtered out)
1578 no read permission (use --include-unreadable to include)
Pages : 12,500/12,800 captured (97.7%)
Excluded: 3 pages in kernel pseudo-mappings ([vvar], [vvar_vclock]) — unreadable by design, not counted as data loss
Bytes : 51,200,000 / 52,428,800 readable (97.7%)
Missing : 2 unreadable range(s)
0x7f2c00a000-0x7f2c00c000 (8,192 bytes)
Modules : 142
Threads : 37
Duration: 12.34s
File : chrome_1773528836.msl (48,234,567 bytes)
Log : chrome_1773528836.msl.log
Quality : GOOD (page-level: 97.7%)
Excluded: counts kernel-provided mappings ([vvar], [vvar_vclock],
[vsyscall]) that appear readable in /proc/<pid>/maps but fault on every
ptrace read. They are not data loss, so they are kept out of the quality
figure — but they are always named rather than silently dropped. [vdso] is
genuinely readable and is captured normally.
Threads: counts the Thread Context blocks written, followed by
(N dropped: no PC/SP) when threads were left out for lacking a program
counter or stack pointer. The line is absent when no thread was enumerated
(--no-registers, or a privileged Android system app).
With --scope, --exclude-module or --resident-only the summary gains lines
that are omitted from a plain full capture:
Scope : heap,stack
Exclude : libhwui*
Omitted : 2655 regions recorded in RegionOmissionManifest (0x005B)
Resident: 785,412 pages (3.0 GiB) skipped as never-touched (method: pagemap)
Scope/Exclude echo the options, Omitted counts the regions listed in the
0x005B block, and Resident reports the anonymous pages --resident-only left
out together with the residency source (pagemap or mincore). If residency
information was unavailable a Note line says so and every page was read.
| Code | Meaning |
|---|---|
0 |
Capture completed. |
1 |
Capture failed, or was aborted. |
2 |
Invalid command-line usage. |
3 |
Attach refused by preflight — the environment forbids this capture and nothing on the target was touched. |
Exit code 3 is accompanied by the reason and concrete remediation, and the
full environment record (uid, capabilities, ptrace_scope, LSM profile) is
written to the companion .msl.log so the constraint is documented in the case
file. See Privileges for what each refusal means and how to
resolve it.
memslicer verify uses its own exit codes:
| Code | Meaning |
|---|---|
0 |
Slice is VALID (warnings, if any, do not change this). |
1 |
Slice is INVALID: broken PrevHash chain, FileHash mismatch, BlockCount mismatch, broken extension segment, failed decryption, unreadable header, or no passphrase for an encrypted slice. |
When a slice captures thread registers (the default; disable with
--no-registers), its execution can be advanced by emulation — a slice is a
static snapshot, so there is no live process to step.
A first-party emulator built on Unicorn + Capstone. Install the extra and step:
pip install memslicer[emu]
memslicer-emu dump.msl --steps 5 -r
# arch : x86_64
# entry : 0x401000
# 0x00401000 mov rax, 1 [rax=0x1 rip=0x401007]
# 0x00401007 mov rbx, 2 [rbx=0x2 rip=0x40100e]
# ...Other useful options: --pc ADDR overrides the start PC, --max-steps N caps --until, -r/--registers
dumps registers after stepping, --unwind-depth N bounds the stack scan of --resume-from-syscall, and
--no-premap-stack turns off the blank stack window described below.
It is also usable as a library for programmatic / differential analysis:
from memslicer.emu import open_slice
emu = open_slice("dump.msl") # registers seeded from the Thread Context
emu.step()
print(hex(emu.read_reg("rax")))
print(hex(emu.read_reg("xmm0"))) # vector/FP registers (XMM/YMM) too
emu.step_back() # reverse execution (undo the last step)Captured vector/FP registers (XMM/YMM/...) are seeded at full width when the slice carries them, so SIMD/crypto code emulates from the real CPU state.
It also supports reverse execution (emu.step_back(), or --back N on the
CLI): a CPU-context snapshot plus a memory-write journal per step lets it undo
instructions, reverting both registers and memory.
Self-modifying code / unpacking. The emulator tracks every byte the code writes and flags when execution enters previously-written memory — the moment a packer jumps into its decoded payload. Recover that payload to disk:
memslicer-emu packed.msl -u 0x401000 --dump-written ./unpacked
# [self-modifying code: 1 write-then-execute site(s)]
# W->X @ 0x000000401020
# [wrote 1 dirtied range(s) to ./unpacked]
# 0x000000401020-0x000000402000 0xfe0 bytes (executed) -> ./unpacked/written_0x401020_0x402000.binemu.step_until(0x401000)
emu.self_modified_exec() # [0x401020] — addresses run from written memory
emu.written_ranges() # coalesced dirtied byte ranges
emu.dump_written("out/") # write each range out (executed ones = the payload)Parked in a syscall. A process is often captured blocked in a library/kernel
call (a Sleep, a wait, a recv), so the captured PC sits in ntdll/kernel
and stepping forward would hit a syscall the emulator can't service. Unwind back
to your own code with --resume-from-syscall (-R): it scans the stack for the
caller's return address into the program image and continues there as if the
call had returned.
memslicer-emu parked.msl -R --until 0xb1070 -r
# [resume-from-syscall] pc = 0x7c90e514 (ntdll.dll+0x...)
# caller return @ 0xb3275 (sample.exe) [stack 0x..., depth 3]
# resumed: pc -> 0xb3275, esp -> 0x...For a stdcall API that cleans up its own arguments (e.g. Sleep's ret 4), add
--pop-bytes N so the caller's stack is left balanced. Override the auto-detected
image with --image-range LO:HI. As a library:
emu.in_system_call() # True — PC is outside the program image
frame = emu.resume_from_syscall(pop_bytes=4) # find caller, reposition pc/sp
emu.pc == frame.return_addr # now back in the image; keep steppingA slice can capture more than one thread (one Thread Context block each). By default the emulator seeds from the Current thread, but any captured thread can be selected:
memslicer-emu dump.msl --list-threads # list captured threads (Current = '*')
memslicer-emu dump.msl --thread 200 -s 5 -r # emulate thread tid=200 insteademu = open_slice("dump.msl", thread=200) # seed from tid 200
emu.switch_thread(100) # re-seed from another thread laterSegment bases & Windows TEB/PEB. Captured fs_base / gs_base are seeded,
so TEB/PEB- and TLS-relative accesses (gs:[...] on x64, fs:[...] on x86)
resolve during emulation:
emu.segment_base("gs") # captured GS base (TEB on Windows x64)
emu.peb_address() # follow gs:[0x60] / fs:[0x30] to the Windows PEBOn Windows the Frida backend recovers each thread's TEB (via
NtQueryInformationThread) and records it as gs_base (x64) / fs_base (x86),
since the CPU context alone carries no segment base. On x86 the emulator installs
a synthetic GDT for the captured base (32-bit FS/GS can't be set as a
register), so SEH prologues that read fs:[0] emulate correctly.
Stack beyond the captured window. A slice only captures a few pages around the stack pointer, so
deeper frames used to end emulation with UC_ERR_*_UNMAPPED. The emulator now pre-maps a 64 MB blank RW
window around the captured SP (open_slice(..., premap_stack_mb=64), 0 disables it; --no-premap-stack
on memslicer-emu and memslicer-behavior). Reads of that invented memory are tracked so they are never
mistaken for captured data, and both CLIs print a note when any happened:
emu.synthetic_ranges() # pre-mapped [lo, hi) windows
emu.is_synthetic(addr) # True if addr lies in a pre-mapped window (even if the code wrote it since)
emu.synthetic_read_count() # reads of pre-mapped bytes the code had not written (also in behavior graph meta)
emu.synthetic_read_sites() # distinct instructions that made such readsLoad a slice into angr for symbolic execution from the exact
captured point — the memory and a thread's registers become an angr SimState
(the Current thread by default; load_angr(..., thread=tid) selects another):
pip install memslicer[symbex]
memslicer-symbex dump.msl --find 0x401050 --avoid 0x401080from memslicer.symbex import load_angr
project, state = load_angr("dump.msl") # state at the captured PC
simgr = project.factory.simgr(state)
simgr.explore(find=0x401050)Emulate a slice and extract a behavior graph — control flow (basic blocks or instructions) plus the system interactions (syscalls / APIs) the code performs — for graph-based dynamic analysis:
pip install memslicer[emu]
# 1. discover which system calls the code makes
memslicer-behavior dump.msl --emit-stubs stubs.py -o graph.dot
# 2. edit stubs.py so each call returns what your investigation needs,
# then re-run with the edited stubs
memslicer-behavior dump.msl --stubs stubs.py -o graph.jsonA static snapshot has no OS, so system calls cannot be truly executed. Each one
is modelled by an analyst-editable stub (the Speakeasy/Qiling approach): the
first run auto-generates a skeleton (one function per observed call, pre-filled
with the observed arguments); you fill in the bodies to return handles, buffers
or errors and --stubs reloads them so emulation advances down the path of
interest. Output is JSON (node-link) or Graphviz DOT; granularity switches
between basic blocks and instructions with --granularity.
API calls are handled the same way: when a call lands on a module's export
it is resolved to module!Export, intercepted, routed to the same stub registry
(Win64/SysV calling conventions), recorded as a behavior node and returned to
the caller — so the API body is never emulated. Both PE exports (Windows)
and ELF .dynsym / PLT-GOT imports (Linux) are resolved; the latter uses
the captured process's already-bound GOT, so call func@plt resolves to the
owning library's lib!symbol. Other addresses are labelled module+offset, and
syscalls are named from per-architecture Linux tables.
Bundled stub library. Instead of writing stubs by hand you can start from a
curated, categorized library covering the APIs malware most often touches
(file / network / registry / process / memory / library / crypto / system).
Each stub decodes its interesting arguments, logs them readably, and returns a
plausible value (a fresh handle, an allocation address, success) so emulation
keeps advancing. --stublib enables it; --stubs merges your edits on top:
memslicer-behavior dump.msl --stublib -o graph.json # bundled stubs
memslicer-behavior dump.msl --stublib --stubs mine.py -o g.json # + overridesEvery syscall / API node carries a behavior category, so the graph groups by what the code does, not just which symbol it called.
Data-flow edges. A lightweight value-equality taint links calls causally:
a dataflow edge when one call's return value is later passed as an argument
(the handle CreateFile returns, consumed by WriteFile; the address
VirtualAlloc returns, written by WriteProcessMemory), and a buffer edge
when two calls share the same pointer/handle argument (ReadFile fills a
buffer, send ships it). Both run automatically for either backend.
Memory annotations (--memory, on by default). Writes into executable
memory — unpacking, self-modifying code, code injection — are flagged (the
writing block is highlighted), every write is bucketed by its target region
type (heap / stack / image / …), and statically-RWX regions are listed under
meta.memory.
Dynamic call graph (--call-graph). Overlays function nodes and
call/ret edges (a shadow call stack tracks the current function) on top of
the basic-block CFG.
High-fidelity Windows emulation (Speakeasy). For Windows, --backend speakeasy drives Speakeasy — built on
the same Unicorn engine but shipping hundreds of real API handlers plus
PEB/TEB, the object manager and a fake filesystem/registry/network — and
projects its emulation onto the same behavior graph. Your --stublib/--stubs
stubs still override individual handlers when you want to steer a path:
pip install 'memslicer[speakeasy]' # git head; the PyPI release pins unicorn 1.x
memslicer-behavior dump.msl --backend speakeasy -o graph.jsonExport & features. The graph serializes to JSON, Graphviz DOT, GraphML
and GEXF (-f, or inferred from the .json/.dot/.graphml/.gexf
extension; the XML formats need no extra dependency). --features writes a
fixed-key numeric feature vector (node/edge counts by kind/type, calls per
category, memory and data-flow tallies) ready to stack into an ML matrix.
BehaviorGraph.to_networkx() returns a live MultiDiGraph with the optional
graph extra.
For deeper analysis you can also hand a live emulator off to angr (concrete → symbolic) and let angr's SimOS model the OS from that point on:
from memslicer.emu import open_slice
from memslicer.symbex import handoff_to_angr
emu = open_slice("dump.msl")
for _ in range(20):
emu.step() # run concretely to a point of interest
project, state = handoff_to_angr(emu) # continue symbolically from here
simgr = project.factory.simgr(state)from memslicer.behavior import trace_slice
graph = trace_slice("dump.msl") # registers seeded, hooks installed
print(graph.meta, len(graph.nodes), graph.events)
open("graph.dot", "w").write(graph.to_dot())A slice can also be opened in radare2
via the io.msl / bin.msl / debug.msl / core.msl plugins:
r2 dump.msl # static analysis: maps, arch, entrypoint
r2 -qc 'il; is' dump.msl # modules (libraries) and symbols / PE exports
r2 -D msl -d msl://dump.msl # emulated debugging: ds / dr step via ESIL
# > dpt list captured threads > dpt=<tid> switch the seeded threadThe plugins live in radareorg/radare2-extras
under msl/ (see its README.md). bin.msl exposes captured modules as
libraries and symbols, including PE export tables so call targets are named;
debug.msl lists/selects threads (dpt). The msl:// io plugin decodes lz4
slices; zstd slices are not decodable by radare2 (no zstd) — use -c lz4/
-c none or memslicer-emu. Encrypted slices are not supported by the
plugins. memslicer-emu handles both zstd and lz4.
src/memslicer/
cli.py CLI entry point (click)
acquirer/
engine.py Backend-agnostic acquisition engine
bridge.py DebuggerBridge protocol definition
frida_bridge.py Frida backend
gdb_bridge.py GDB/MI3 backend
lldb_bridge.py LLDB Python API backend
frida_acquirer.py Backward-compatible Frida wrapper
investigation.py InvestigationCollector protocol
attach_preflight.py Linux ptrace preflight diagnosis
errors.py Error types and exit codes
platform_detect.py OS and architecture detection
region_filter.py Region filtering logic
collectors/
__init__.py Factory: create_collector()
linux.py Linux collector (/proc)
android.py Android collector (SELinux-aware + system properties)
darwin.py macOS collector (sysctl, ps, lsof)
ios.py iOS collector (sandbox-aware, SystemVersion.plist)
windows.py Windows collector (wmic, tasklist, netstat)
frida_remote.py Remote collector via Frida JS RPC
fallback.py NullCollector for unsupported platforms
constants.py Shared constants (protocols, handle types)
msl/
writer.py MSL file writer
encryption.py AES-256-GCM + Argon2id encryption
constants.py Format constants and enumerations
integrity.py BLAKE3 integrity chain
types.py MSL data types
utils/
protection.py Memory protection parsing
padding.py Alignment utilities
timestamps.py Timestamp helpers
git clone git@github.com:MemorySlice/memslicer.git
cd memslicer
pip install -e ".[dev]"Dev dependencies include pytest, pytest-cov, and ruff.
pytestWith coverage:
pytest --cov=memslicer --cov-report=term-missingtests/tools/make_android_fixture.py [OUTPUT.msl] writes a small Android-style .msl
(Dalvik/ART, scudo, libc_malloc, stack_and_tls, cfi shadow, vdso mappings plus a
planted 32-byte key in a scudo region) for downstream reader tests. Without an
argument it writes MemDiver's tests/fixtures/android/memslicer_android.msl.
tests/data/region_name_vectors.json is shared byte-identically with MemDiver's
tests/fixtures/region_name_vectors.json.
ruff check src/
ruff format src/CI (.github/workflows/tests.yml) runs ruff and the test suite on every pull
request and on pushes to main, across Python 3.10 and 3.12.
Releases are automated by .github/workflows/publish.yml, triggered by the
version in pyproject.toml. To cut a release:
- Bump
versionunder[project]inpyproject.toml(e.g.0.2.7→0.2.8). - Open a PR and merge it to
main.
On that push to main the workflow:
- Detects that the version changed (compares
pyproject.tomlatHEADvsHEAD~1; merges that don't change the version skip publishing entirely). - Runs the test suite on Python 3.10–3.12.
- Builds the sdist + wheel and publishes to PyPI via OIDC trusted publishing (no API token stored).
- Creates and pushes the
vX.Y.Zgit tag.
A separate workflow (changelog.yml) regenerates the CHANGELOG.md section for
the new version from the commit messages since the previous tag.
Before the first PyPI release, two things must be set up:
- PyPI trusted publisher — configure it once at pypi.org → memslicer →
Publishing: owner
reverseame, repositorymemslicer, workflowpublish.yml, environmentpypi. Without it the publish step fails at the OIDC token exchange (invalid-publisher). - The
speakeasyextra — it pins a direct git source, and PyPI rejects distributions that declare direct-reference (@ git+https://…) dependencies. Drop or rework that extra (e.g. document installing Speakeasy manually) before publishing, otherwise the upload is rejected even after OIDC is configured.
| Package | Version | Purpose |
|---|---|---|
| frida-tools | >=12.0 | Frida backend and agent |
| blake3 | >=0.4 | BLAKE3 integrity checksums |
| click | >=8.0 | CLI framework |
| zstandard | >=0.20 | Zstd compression |
| lz4 | >=4.0 | LZ4 compression |
| cryptography | >=42.0 | AES-256-GCM encryption |
| argon2-cffi | >=23.1 | Argon2id key derivation |
Apache 2.0