{"slug": "reverse-engineer-a-stripped-binary-with-rea-step-by-step", "title": "Reverse engineer a stripped binary with REA, step by step", "summary": "A developer used REA's MCP tools in Claude Code, backed by Ghidra 12.1.4, to reverse engineer a self-built stripped x86-64 Linux ELF binary, recovering the license key DEMO-2CC99E78, the hash and XOR key, and an XOR-obfuscated update URL from the binary alone; the real program accepted the recovered key and the decoded URL matched what the program prints. The run began by decompiling the entry point to identify main at FUN_001010a0, then read 96 bytes at 0x103d80 to map a 24-byte-per-entry command dispatcher table linking check, version and unlock to their handlers. The analysis was completed without consulting the source, which the author published alongside the walkthrough as of 23 November 2026.", "body_md": "# Reverse engineer a stripped binary with REA, step by step\n\nA real run on my own stripped binary: REA with Ghidra finds main, the license check, the hash and XOR key, then I test the key. Mistakes and source included.\n\nI built a small stripped Linux program with a license check, a hashed key and an XOR-obfuscated update URL, then used REA (with its Ghidra backend) to recover all three from the binary alone. The recovered key `DEMO-2CC99E78` was accepted by the real program, and the decoded URL matched what the program prints.\n\nAs of 23 November 2026. I ran this with REA's MCP tools in Claude Code, backed by Ghidra 12.1.4, on an x86-64 Linux ELF. Everything below was output I saw, trimmed for length. I did not look at the source until the analysis was finished. If you have not set REA up yet, start with [Getting started with REA](https://reversedwithai.com/learn/getting-started-with-rea) and the [REA tool page](https://reversedwithai.com/tools/rea).\n\n## [What was the target?](#what-was-the-target)\n\nI wrote a small C program for this and compiled it stripped with optimisation:\n\n```\ngcc -O2 -s -o target target.c\nfile target\ntarget: ELF 64-bit LSB pie executable, x86-64, dynamically linked, stripped\n```\n\nIt has four commands (`check`, `unlock`, `info`, `version`), a key check and an encrypted string. The full source is at the end of this guide so you can rebuild it. I moved it into a separate folder before opening anything in REA. It is my own code, so there was nothing to clear before analysing it.\n\nThe run followed three stages, shown below with the addresses I used.\n\n## [How did I get a first look?](#how-did-i-get-a-first-look)\n\nI opened the file and asked for an overview.\n\n``` php\nopen_binary  path=.../rea-run/target\n-> {\"format\":\"elf\",\"kind\":\"executable\",\"architecture\":\"x86_64\"}\n\nbinary_overview\n-> \"procedure_count\":45, \"string_count\":60\n   .text 0x1010a0-0x101502 (1122 bytes)\n```\n\nForty-five procedures sounds like a lot, but most are PLT thunks and startup code. `.text` is only 1,122 bytes. Then I listed procedures and strings. The imports told me the shape of the program before I read any code: `strchr`, `snprintf` and `strcmp` together suggest a key being split, formatted and compared. The strings had `license: valid`, `license: invalid`, `unlock: premium features enabled`, `update server: %s` and the command names `check`, `version` and `unlock`.\n\nOne odd string stood out, at `0x1020e2`:\n\n```\n.*)`uu/*>;.?)t?\";7*6?t34,;63>u,k\n```\n\nThat is not a message anyone writes. I marked it as encrypted data to come back to.\n\n## [How do I find main in a stripped binary?](#how-do-i-find-main-in-a-stripped-binary)\n\nDecompile the entry point. The only useful thing it does is call `__libc_start_main`, and the first argument is main.\n\n``` php\nprocedure_pseudo_code  procedure=entry\n-> __libc_start_main(FUN_001010a0, param_2, &stack0x00000008, 0, 0, param_1, auStack_8);\n```\n\nSo `FUN_001010a0` is main. Its pseudocode loops four times, calling `strcmp` against a table that starts at `0x103d80`, and ends with an indirect call. Ghidra added this warning:\n\n```\nWARNING: Could not recover jumptable at 0x00101184. Too many branches\nWARNING: Treating indirect jump as call\n```\n\nThat is not a jump table. It is a table of function pointers, a command dispatcher. I read the table with `read_bytes` instead of trusting the decompiler's pointer arithmetic:\n\n``` php\nread_bytes  address=0x103d80  length=96\n-> 9c2010000000000050141000000000000100000000000000\n   a22010000000000090141000000000000000000000000000\n   a72010000000000e0121000000000000000000000000000\n   af2010000000000010141000000000000100000000000000\n```\n\nEach entry is 24 bytes: a pointer to the command name, a pointer to the handler and an integer flag. Reading the little-endian values gave me `check` to `0x101450` with flag 1, a name at `0x1020a2` to `0x101490` with flag 0, `version` to `0x1012e0` with flag 0 and `unlock` to `0x101410` with flag 1. The flag matches the `%s needs an argument` string, so I named it \"needs an argument\".\n\n## [Where is the license check?](#where-is-the-license-check)\n\nBoth `0x101450` and `0x101410` print a verdict after calling `FUN_00101300`. `procedure_callers` confirmed that only those two call it:\n\n``` php\nprocedure_callers  procedure=0x101300\n-> [\"0x101410\",\"0x101450\"]\n```\n\n`FUN_00101300` is the key check. Its decompiled body, trimmed:\n\n```\npcVar3 = strchr(param_1, 0x2d);               // '-'\nif (pcVar3 == 0 || 0xd < (pcVar3 - param_1) - 3) return false;\n... copy the part before the dash ...\nuVar5 = 0x811c9dc5;\ndo {\n  uVar1 = *p++;\n  uVar5 = (uVar1 ^ uVar5) * 0x20003260 | (uVar1 ^ uVar5) * 0x1000193 >> 0x1b;\n} while (*p != 0);\nsnprintf(local_48, 0x10, \"%08X\", uVar5 ^ 0xa5a5a5a5);\nreturn strcmp(pcVar3 + 1, local_48) == 0;\n```\n\nIn plain terms, the key is `NAME-XXXXXXXX`. The program hashes the name and compares the result, printed as eight uppercase hex digits, with the text after the dash. The length test allows 3 to 16 characters before the dash.\n\n## [How did I recover the hash?](#how-did-i-recover-the-hash)\n\n`0x811c9dc5` is the FNV-1 32-bit offset basis, and `0x1000193` is the FNV prime, so my first thought was FNV. But the line has two different multipliers joined by `|`, which looked wrong. I checked the arithmetic:\n\n```\n(0x1000193 << 5) & 0xffffffff  = 0x20003260\n0x811c9dc5 ^ 0xa5a5a5a5        = 0x24b93860\n```\n\nThe first value is the second multiplier shifted left by 5, and `>> 0x1b` is a shift right by 27. Together they are a 32-bit rotate left by 5 of `x * 0x1000193`. The decompiler had distributed the rotate across the multiplication. The second value is the empty-name constant `0x24b93860` that the decompiler printed in an `if` branch. That confirms the final XOR with `0xa5a5a5a5`.\n\nSo the hash is: start at the FNV offset basis, then for each byte XOR it in, multiply by the FNV prime and rotate left 5, and finish with an XOR against `0xa5a5a5a5`. I wrote that down literally in Python, using the decompiler's expression rather than my own simplification, so a mistake in my reading would show up in the test:\n\n``` python\nM = 0xFFFFFFFF\ndef h(name):\n    v = 0x811c9dc5\n    for c in name.encode():\n        x = (c ^ v) & M\n        v = ((x * 0x20003260) & M) | (((x * 0x1000193) & M) >> 0x1b)\n    return v ^ 0xa5a5a5a5\n```\n\n## [How did I recover the XOR key?](#how-did-i-recover-the-xor-key)\n\nThe function at `0x101490` prints `update server: %s`. Its loop starts with a constant and a XOR:\n\n```\nbVar2 = 0x32;\ndo {\n  *pbVar3 = bVar2 ^ 0x5a;\n  bVar2 = (&DAT_001020e1)[lVar4];\n  ...\n} while (bVar2 != 0);\n```\n\nThe key is `0x5a`. The blob starts one byte before `DAT_001020e1`, at `0x1020e0`, with the first byte `0x32` held in a register. The strings list had put it at `0x1020e2`, which is two bytes late, so I read the bytes myself:\n\n``` php\nread_bytes  address=0x1020e0  length=36\n-> 322e2e2a296075752f2a3e3b2e3f29743f223b372a363f7433342c3b36333e752c6b00\n```\n\nXOR with `0x5a` gives `https://updates.example.invalid/v1`.\n\n## [How did I rename things?](#how-did-i-rename-things)\n\nI named what I had proven, in one call, so the next decompile would read better:\n\n```\nset_addresses_names  names={\n  \"0x1010a0\":\"main\", \"0x101300\":\"check_key\",\n  \"0x101410\":\"cmd_unlock\", \"0x101450\":\"cmd_check\",\n  \"0x101490\":\"cmd_info\", \"0x1012e0\":\"cmd_version\",\n  \"0x103d80\":\"command_table\", \"0x1020e0\":\"enc_url\"}\n-> all eight: true\n```\n\nREA renames only live in the session. They are discarded on close, so write down anything you want to keep.\n\n## [Did the recovered key work?](#did-the-recovered-key-work)\n\nI generated a key for the name `DEMO` with the Python above and ran the real binary:\n\n``` bash\n$ python3 solve.py DEMO\nhttps://updates.example.invalid/v1\nDEMO-2CC99E78\n$ ./target check DEMO-2CC99E78\nlicense: valid\n$ ./target unlock DEMO-2CC99E78\nunlock: premium features enabled\n$ ./target check DEMO-00000000\nlicense: invalid\n```\n\nI also tried more names. `ALICE-E9DDA17F` was valid. `AB-33BBE073` had the correct hash but was rejected, and so was an 18-character name with a correct hash, which fits the 3 to 16 length rule I read in the decompiler. Then I closed the session with `close_binary`.\n\n## [Where did the AI go wrong?](#where-did-the-ai-go-wrong)\n\nThese are the real mistakes and misleading outputs, including some of mine.\n\n- **An empty \"success\".** I called`batch_decompile` without loading its schema first. It returned`{\"items\":[],\"total\":0,\"succeeded\":0,\"failed\":0}` , which looks fine and decompiled nothing. I noticed because I had no code to read. Check counts, not just status.\n- **A rejected call.** My first`set_addresses_names` call omitted the`names` field and failed schema validation. The error said what was wrong and I fixed it on the second call.\n- **The strings list was misaligned.** The encrypted blob was reported at`0x1020e2` , not`0x1020e0` . The decompiler's`0x32` literal and`DAT_001020e1` gave it away. Decoding from the listed address would have produced garbage.\n- **A missing string.** The command name at`0x1020a2` was not in the string list. I only saw it as a pointer in the table. Ghidra's string list covers defined strings only, and REA says so in its limitations.\n- **Arguments disappeared.** The decompiler showed`FUN_00101300()` with no arguments, and`printf(\"update server: %s\\n\")` with no buffer. The values were in registers that the compiler passed straight through. The decompiled code alone suggests a check that takes no input.\n- **The hash looked like two operations.** The`|` between two multipliers was a rotate. I checked it numerically before using it.\n- **The renaming spilled.** After I named`0x103d80` , the decompiler showed the handler field as`&PTR_cmd_check_00103d88` . The name`cmd_check` appeared on a slot that holds all four handlers. The table has not been retyped, so the label misleads.\n\n## [What did the decompiler lose compared with the source?](#what-did-the-decompiler-lose-compared-with-the-source)\n\nAfter the run I read the source. The logic was right in every case. What the decompiler lost:\n\n- The `rotl32` and`mix_hash` helpers were inlined into`check_key` , so my renames cover fewer functions than the source has.\n- `decode_url` was inlined into`cmd_info` , with the first byte peeled out of the loop.\n- The `command_t` struct was gone. It showed as a pointer array indexed by`lVar3 * 3` and an int array indexed by`lVar3 * 6` , which are the same 24-byte stride written two ways.\n- `XOR_KEY` became the literal`0x5a` , and`rotl32(..., 5)` became shift constants.\n- Return types became `undefined8` or`bool` , and handlers lost their`const char *arg` parameter.\n- The empty-name branch with the constant `0x24b93860` is dead code in the source, because the length check rejects names under 3 characters. The decompiler still printed it.\n- The memcpy was a byte loop with `n & 0x3f` . The`& 0x3f` is a compiler artefact and is harmless because the length is already at most 16.\n\n## [Check it yourself](#check-it-yourself)\n\n1. Set up REA with a Ghidra backend by following [Getting started with REA](https://reversedwithai.com/learn/getting-started-with-rea) .\n2. Save the source below as `target.c` and compile it with`gcc -O2 -s -o target target.c` . A different compiler version will give different addresses, so substitute your own.\n3. Move `target.c` out of the folder where you work. Do not give it to the agent.\n4. Ask your agent to open the binary with REA, find main from `entry` , find the function with`strchr` and`snprintf` , recover the hash and the XOR key, and produce a valid key. Tell it to show the address and decompiled code for each claim.\n5. Test any key it gives you with `./target check KEY` . Do not accept the agent's word that it works.\n6. Compare with the source and list what was lost.\n\n```\n#include <stdio.h>\n#include <string.h>\n#include <stdint.h>\n#include <stdlib.h>\n\n#define XOR_KEY 0x5Au\n\n/* \"https://updates.example.invalid/v1\" XOR 0x5A */\nstatic const uint8_t enc_url[] = {\n    0x32,0x2e,0x2e,0x2a,0x29,0x60,0x75,0x75,0x2f,0x2a,0x3e,0x3b,0x2e,0x3f,0x29,\n    0x74,0x3f,0x22,0x3b,0x37,0x2a,0x36,0x3f,0x74,0x33,0x34,0x2c,0x3b,0x36,0x33,\n    0x3e,0x75,0x2c,0x6b,0x00\n};\n\ntypedef struct {\n    const char *name;\n    int (*handler)(const char *arg);\n    int needs_arg;\n} command_t;\n\nstatic uint32_t rotl32(uint32_t v, int n) { return (v << n) | (v >> (32 - n)); }\n\nstatic uint32_t mix_hash(const char *s) {\n    uint32_t h = 0x811C9DC5u;\n    for (; *s; s++) {\n        h ^= (uint8_t)*s;\n        h *= 0x01000193u;\n        h = rotl32(h, 5);\n    }\n    return h ^ 0xA5A5A5A5u;\n}\n\n/* key format: NAME-XXXXXXXX where X = hex of mix_hash(NAME) */\nstatic int check_key(const char *key) {\n    const char *dash = strchr(key, '-');\n    char name[32];\n    if (!dash) return 0;\n    size_t n = (size_t)(dash - key);\n    if (n < 3 || n > 16) return 0;\n    memcpy(name, key, n);\n    name[n] = 0;\n    char expect[16];\n    snprintf(expect, sizeof expect, \"%08X\", mix_hash(name));\n    return strcmp(dash + 1, expect) == 0;\n}\n\nstatic void decode_url(char *out) {\n    size_t i = 0;\n    for (; enc_url[i]; i++) out[i] = (char)(enc_url[i] ^ XOR_KEY);\n    out[i] = 0;\n}\n\nstatic int cmd_check(const char *arg) {\n    if (check_key(arg)) { puts(\"license: valid\"); return 0; }\n    puts(\"license: invalid\");\n    return 1;\n}\n\nstatic int cmd_info(const char *arg) {\n    (void)arg;\n    char url[64];\n    decode_url(url);\n    printf(\"update server: %s\\n\", url);\n    return 0;\n}\n\nstatic int cmd_version(const char *arg) {\n    (void)arg;\n    puts(\"demo 1.4.2\");\n    return 0;\n}\n\nstatic int cmd_unlock(const char *arg) {\n    if (!check_key(arg)) { puts(\"unlock: denied\"); return 2; }\n    puts(\"unlock: premium features enabled\");\n    return 0;\n}\n\nstatic const command_t commands[] = {\n    { \"check\",   cmd_check,   1 },\n    { \"info\",    cmd_info,    0 },\n    { \"version\", cmd_version, 0 },\n    { \"unlock\",  cmd_unlock,  1 },\n};\n\nint main(int argc, char **argv) {\n    if (argc < 2) {\n        fprintf(stderr, \"usage: %s <command> [arg]\\n\", argv[0]);\n        return 64;\n    }\n    for (size_t i = 0; i < sizeof commands / sizeof commands[0]; i++) {\n        if (strcmp(argv[1], commands[i].name) == 0) {\n            if (commands[i].needs_arg && argc < 3) {\n                fprintf(stderr, \"%s needs an argument\\n\", commands[i].name);\n                return 64;\n            }\n            return commands[i].handler(argc > 2 ? argv[2] : \"\");\n        }\n    }\n    fprintf(stderr, \"unknown command: %s\\n\", argv[1]);\n    return 64;\n}\n```\n\n", "url": "https://wpnews.pro/news/reverse-engineer-a-stripped-binary-with-rea-step-by-step", "canonical_source": "https://reversedwithai.com/learn/reverse-engineer-a-stripped-binary-with-rea-step-by-step", "published_at": "2026-11-23 00:00:00+00:00", "updated_at": "2026-11-23 15:14:39.788572+00:00", "lang": "en", "topics": ["ai-tools", "ai-agents", "developer-tools"], "entities": ["REA", "Ghidra 12.1.4", "Claude Code", "DEMO-2CC99E78"], "also_reported_by": [], "takeaway": "When Ghidra reports 'Could not recover jumptable' and 'Treating indirect jump as call' on a stripped binary, read the raw bytes with read_bytes instead of trusting the decompiler's pointer arithmetic: the table at 0x103d80 held 24-byte entries of name pointer, handler pointer and flag, yielding chec", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/reverse-engineer-a-stripped-binary-with-rea-step-by-step", "markdown": "https://wpnews.pro/news/reverse-engineer-a-stripped-binary-with-rea-step-by-step.md", "text": "https://wpnews.pro/news/reverse-engineer-a-stripped-binary-with-rea-step-by-step.txt", "jsonld": "https://wpnews.pro/news/reverse-engineer-a-stripped-binary-with-rea-step-by-step.jsonld"}}