Key finders
A key finder reads a capture and reports bytes that look like key material. It does not know whether the bytes are a live key. Every hit is a candidate. This page explains what each finder detects, the traps that produce wrong answers, the path from a process in a full image to a verified key, and how to join a hit to its heap chunk and memory mapping.
The finders only read bytes that were captured. A structure that straddles a
capture gap or a failed page is never found in invented zeros, and every result
carries coverage and truncated. An empty result is not proof of absence.
Read those two fields first.
The finders
List them, with their parameters, on any surface:
memdiver keys list
Finder |
Detects |
Traps |
|---|---|---|
|
Expanded AES-128/192/256 round-key schedules, recognised by the schedule’s own structure. Confidence is matched derived words over derived words, so a truncated or partly overwritten schedule still scores. |
See AES byte order. Without the right orientation or byte order a real key is missed silently. |
|
DER PKCS#1 and PKCS#8 RSA private keys. A hit is accepted only when |
Finds serialised keys only. Most TLS servers never hold one in memory. |
|
PEM private-key blocks, with the RSA or OpenSSH body verified. |
Needs the |
|
A prime factor of a known RSA modulus stored as raw big-integer bytes (OpenSSL |
See RSA factors. It needs a modulus. |
|
Key-sized windows (16, 24, 32, 48, 64 bytes by default) of near-random bytes. |
The least specific finder. Compressed data, hashes and ciphertext are high entropy too. Treat hits as a shortlist for an oracle, not as keys. |
|
ChaCha20 keys proven by the cipher state stored beside them: a libtomcrypt |
See Key proof. 4-byte (sigma) or 8-byte (provider) aligned states only; self-test keys ( |
|
OpenSSH (>= 8.1) shielded private keys (sshd host keys, |
See Key proof. The struct, its pre-key and its blob must lie in one page-aligned, VA-contiguous window: a heap split by an uncaptured page is not searched across the gap. 64-bit processes only. |
AES byte order
OpenSSL stores AES_KEY as host-endian 32-bit words. On a little-endian host
every word of the schedule is byte-reversed in memory. aes_schedule therefore
tries two byte orders, natural and swapped32, and two orientations,
forward and inverse (the reversed schedule with InvMixColumns applied to the
middle rounds, used by OpenSSL and AES-NI for decryption). The default
parameters cover all of them. This was checked against real libcrypto
structures for 128, 192 and 256 bits: without swapped32 all six would be
missed. If you narrow aes_byte_orders or aes_orientations to speed up a
scan, you give that coverage up.
On a real TLS 1.3 client process (openssl_run_13_1, an aarch64 glibc
process), the finder reports nine AES-256 forward/natural schedules. Two of them
are the AES-256-GCM keys derived from CLIENT_TRAFFIC_SECRET_0 and
SERVER_TRAFFIC_SECRET_0. The scan takes well under a second on the process
capture.
Key proof
chacha_state (and, as additive metadata, aes_schedule) put a proof block in each
hit’s metadata: proof is proven or unverified, proof_class is D (memory-only:
the key’s own stored state re-computes from it) and proof_detail is live key, role unknown or candidate key, role unknown. Which session or peer a key serves is not
known. For aes_schedule, proven means every derived schedule word matched
(confidence 1.0). chacha_state hits carry key_hex, key_offset, family
(chacha-sigma / chacha-openssl-prov) and layout.
openssh_shielded_key puts the same proof block in each hit (proven only for a
proven verdict). OpenSSH 8.1 and later encrypts a long-lived private key with
AES-256-CTR under the SHA-512 of a 16 KiB random pre-key that lives in the same process,
so the capture holds everything needed to unshield it. A hit is proven when the
unshielded plaintext parses as one OpenSSH private serialisation with its 01 02 03 ...
padding and its private part re-derives its public key: Ed25519 seed to public key,
ECDSA d * G == Q on the curve, RSA n == p * q, e * d == 1 mod lcm(p-1, q-1) and
iqmp. The hits carry key_type, key_size, verdict (proven, unverified or
rejected), checks, fingerprint (SHA256:, as ssh-keygen -l prints it),
public_key (the .pub line), detail, and prekey_offset, shielded_offset and
shielded_len in the scanned window’s coordinates. They never carry private key bytes.
memdiver keys scan sshd.msl --finder openssh_shielded_key
The struct’s members are virtual addresses, so the finder works out the window’s base
address from the bytes themselves and needs the struct, its pre-key and its blob in one
page-aligned, VA-contiguous window (every captured .msl run, or a raw dump of whole
pages). On the extracted v2b sshd .msl slices of the published reference capture it
found the same 3 proven keys as the Volatility 3 plugin memdiver.ssh_hostkeys, in the
va and vas views, each inside ptmalloc user data (--heap-policy annotate). The
plugin runs the same engine on a full image or a .msl slice and can export the proven
keys as OpenSSH key files; see the plugin reference.
RSA factors
rsa_factor finds a prime that divides a public modulus. If you give it no
modulus, it harvests moduli from the same capture: SPKI blobs, certificates,
RSAPublicKey structures and ssh-rsa blobs. It then slides a window over the
capture looking for a run of bytes that divides one of them. It looks for
little-endian limbs (stride 8 by default) and big-endian bytes (stride 1).
Little-endian limbs are the fast, normal case. OpenSSL stores
BIGNUMlimbs little-endian. The big-endian pass at stride 1 is several times slower and is mainly for other libraries.No modulus in memory means no result. If the process holds no public key, certificate or
ssh-rsablob, the finder has nothing to divide by and reports nothing. Supply the modulus yourself with thersa_moduliparameter.Verify the pair. On a real Cumulus nginx process the finder located both 2048-bit primes of a 4096-bit key as limbs inside two adjacent heap chunks.
pdiffers fromq, both are probable primes, andp*qequals the harvested modulus. A key rebuilt from them signed and verified. That check is cheap, so do it.
What the other layers add
Heap-role restriction. With
heap_policy="mask", a hit survives only when its first and last byte lie inside one allocator chunk’s user data. This removes hits in chunk headers, free-list links and allocator metadata. It depends on the allocator parser, so check the result ofheap_detectfirst.Oracle verification. A schedule or a factor proves the bytes have the right shape. Only decrypting something known proves they are the key. See Verify the hit.
Strings, IOCs and YARA
Two other scans work on the same .msl and the same hit model. They find
evidence of where a key was used, rather than the key itself.
Strings table (
memdiver strings table DUMP). Extracts ASCII, UTF-8 and UTF-16LE strings with their addresses and files them as thestringscase table with IOC columns: URLs, e-mail addresses, IPv4, Unix and Windows paths, executables, archives, PEM markers, base64 and hex runs. The IOC patterns are heuristics with known noise. IPv4 matches dotted version numbers and 4-part OIDs, and base64 matches long identifiers. A string such asSSLKEYLOGFILE=/output/keylog_raw.txtin a process environment is a lead, not a key.YARA (
memdiver yara check RULEandmemdiver yara scan RULE DUMP). Scans the captured bytes of one dump with a rule and returns rows withaddr,space,va,coverageandtruncated.yara checkreports the line and column of a compile error. libyara reports an identifier error at the end of the rule, so MemDiver relocates it to the offending token. Rules can be stored in a library or in a case and run by name with--rule-name. The olderscan-yaracommand is a census over N dumps without window or VA detail. Useyara scanwhen you need the location of every match.
Detector fixtures
A finder or a YARA rule can be wrong in two ways: it misses a real key, or it fires on noise. Detector fixtures test that on known samples before you rely on the scan.
memdiver fixtures run --kind keyfinder aes_schedule
memdiver fixtures run --kind yara rule.yar
The bundled aes_schedule fixtures hold four positives (128-bit forward,
inverse, swapped32, 256-bit forward) and three decoys (zeros, 0x09 fill, a
schedule with a corrupted w[Nk]). The verdict has three states, and
indeterminate proves nothing:
Exit code |
Verdict |
Meaning |
|---|---|---|
|
pass |
Every positive was found and every decoy stayed silent. |
|
fail |
A positive was missed, a decoy fired, a rule did not compile or a finder raised. |
|
indeterminate |
There are no fixtures, or the sample was padded or too short to judge. Never read it as a pass. |
In the web UI the same verdict appears as a badge on the Key finders panel and on the YARA panel.
From a process to a verified key
The route is the same on every surface: image process, .msl, heap, finders,
oracle. Use it when you start from a full memory image and you do not yet
have a per-process capture. If you already hold a .msl, start at step 3.
Sandbox
When MEMDIVER_ALLOWED_ROOTS is set, every input path must lie in those roots
and output paths in the MemDiver home. A denial returns path.outside_sandbox.
Fix the path rather than retrying.
Open the process. Resolve a profile, then open a process view:
memdiver image open IMAGE --view process --pid PID --case mycase
The command prints the view descriptor path (
view_path). It lands in<case>/views/.Extract it to
.msl. This takes minutes on a large image:memdiver image extract VIEW.mdview --out process.msl
The result is a normal capture. It keeps its virtual-address view and every page-state fact, so everything below works on it like on any other
.msl.Parse the heap. Start with detection and check the allocator it chose:
memdiver heap detect process.msl
Treat
partialorheuristicallocators (jemalloc, generic) with suspicion. Themaskpolicy is only as good as this parse. Chunks and the chunk around an address come frommemdiver heap chunksandmemdiver heap at. See Heap allocator awareness.Run the finders.
memdiver keys scan process.msl --finder aes_schedule \ --heap-policy annotate --case mycase \ --candidates-out candidates.json
--findercan be repeated.--heap-policyisoff,annotate(the default; each hit shows the chunk that holds it) ormask(only hits inside one chunk’s user data).--viewdefaults tovafor an.msl.--offsetand--lengthrestrict the scan to a window in those coordinates. With--case, the hits become thekey_hitstable andkey_hitannotations;--no-annotatefiles the table only. A cut at--limit(default 10000) setstruncated.New
--heap-policy user_data(CLI, MCP, REST, key finders) uses the heap as a filter: it keeps only bytes inside heap chunk user data; freed slots are kept and flaggedheap.freed; each candidate lists its overlapping chunks inheap.chunks[]; the removed bytes are counted instages.heap_outside_user_data. See heap filtering support for supported allocators. An empty heap map cannot supply this filter. Measured 2026-11-20 on the in-repo samples (single dumps, entropy-only): wolfSSH client 3,504 → 1,888 candidate bytes (-46 %), libssh client 9,560 → 9,392, with the same known keys covered as underannotate.Verify (next section). A key that nothing verified is not a result.
Step |
Web UI |
CLI |
MCP tool |
|---|---|---|---|
Open and extract |
Image panel |
|
|
Inspect the capture |
Hex workspace |
|
|
Heap |
Heap tab |
|
|
Find |
Key finders panel |
|
|
Verify |
Verify button on a hit |
|
|
In the web UI, the Key finders panel lets you pick finders and a region (the whole view or the current selection), choose the heap policy, and run. A scan above 64 MiB of captured bytes runs as a job with progress and Cancel. Each hit row shows the finder, label, address, length, confidence, the heap role and the permissions of its mapping. Copy copies the key. Verify opens the oracle dialog for that hit. Clicking a row jumps to it in the hex view and highlights it.
For an agent, the MCP playbook image_to_process_keys walks these same steps
with the exact parameters and the traps to check.
Verify the hit
A hit is a candidate. Verify it before you report it.
Known ciphertext.
memdiver verify DUMP --offset OFFSET --length 32 --ciphertext-hex HEX --cipher NAMEdecrypts known ciphertext with the bytes at that offset. For AEAD ciphers add--nonce-hex,--aad-hexand--tag-hex.--offsetis read in the byte view you name with--view(vasby default for an.msl), so give the offset in the same coordinates as the hit.A TLS capture. For a key that belongs to a TLS session,
inspect-pcapsummarises the sessions in the capture, and a recovered key can be proven by decrypting the real capture. See Key-log export.A known key. If you already hold the key from a key log,
memdiver locate-keyfinds it across N dumps and tells you which dumps still contain it. See Locating a known key.A user oracle.
candidates.jsonfrom--candidates-outis the input tomemdiver brute-force, which runs every candidate through your oracle script.
Report the verification result, never the raw hit count alone. A hit inside a
freed chunk (heap_state) may be a key that was once live. It is not
evidence of a live key.
Join a hit to its chunk and mapping
Every hit has an addr, a space and a location. With the heap policy
annotate or mask, the key_hits table already carries the holding chunk
(heap_chunk_va, heap_chunk_size, heap_role, heap_state) and the mapping
(region_start, region_end, region_perms, region_path). For anything
beyond that, file the capture’s tables in the case and join them with one
read-only query:
memdiver case export process.msl --case mycase --what msl_regions
memdiver case export process.msl --case mycase --what heap_chunks
memdiver case schema --case mycase
case schema lists the tables, their real column names and which columns are
addresses. Read it before you write SQL, because the query below is a shape and
not a promise. Join on the hit’s va, which is a virtual address even when
addr is a packed-stream offset:
memdiver case query --case mycase --sql "
SELECT k.finder, k.label, k.va, c.addr AS chunk, c.size AS chunk_size,
c.state, r.addr AS vma, r.size AS vma_size, r.protection
FROM key_hits k
LEFT JOIN heap_chunks c ON k.va >= c.addr AND k.va < c.addr + c.size
LEFT JOIN msl_regions r ON k.va >= r.addr AND k.va < r.addr + r.size"
Bind values with --param, never by string formatting.
On the real TLS capture above, this join places the client key at a heap
address inside a 976-byte in_use chunk (user data), and the server key in
another 976-byte chunk. Both lie in one rw- mapping of [heap]. The RSA
primes on the Cumulus nginx process sit in 272-byte in_use chunks of the
[heap] mapping: the 2048-bit limbs plus a header.
To ask “what contains this address?” for any address, use case context-at:
memdiver case context-at --case mycase \
--location '{"space":"msl_va","value":<ADDRESS>,"capture_id":"<id>"}'
It lists the table rows and annotations that contain the address, outermost
first. The MCP tools are case_query, case_schema and context_at. Large
address values are exact integers on every surface.
What to do with the result
A verified key is the start of the next question, not the end. Search for the same bytes across the other dumps with Locating a known key, or learn the object that holds it across N dumps and ship a plugin that finds it in one image. See Object model: learn from N dumps, find in one.