|
| 1 | +--- |
| 2 | +title: Dumping Non-Readable ELF Binaries with xodump, a practical example |
| 3 | +author: Fozl |
| 4 | +categories: [Misc] |
| 5 | +date: 2025-07-11 |
| 6 | +description: Reading an executable-only ELF binary with xodump. |
| 7 | +tags: |
| 8 | + - xodump |
| 9 | + - elf |
| 10 | + - ctf |
| 11 | + - reverse |
| 12 | +image: |
| 13 | + path: /assets/img/Misc/misc.png |
| 14 | +--- |
| 15 | + |
| 16 | +## Dumping a Non-Readable ELF Binary with xodump |
| 17 | + |
| 18 | +Sometimes, especially in CTFs or hardened environments, you get an ELF binary that is executable but not readable: |
| 19 | + |
| 20 | +```bash |
| 21 | +sonic@pc:~$ ls -lsah crackme |
| 22 | +16K -rwx--x--x 1 root root 16K Jul 11 18:11 crackme |
| 23 | +```` |
| 24 | + |
| 25 | +When executed: |
| 26 | + |
| 27 | +```bash |
| 28 | +sonic@pc:~$ ./crackme |
| 29 | +Enter password: eggman |
| 30 | +Wrong password! |
| 31 | +``` |
| 32 | + |
| 33 | +You cannot open it, copy it, or run any static analysis directly. |
| 34 | + |
| 35 | +Solution: use [xodump](https://github.com/StroppaFR/xodump). |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +## Method |
| 40 | + |
| 41 | +1. **Compile xodump** (on the target if you have a compiler, otherwise compile elsewhere and upload): |
| 42 | + |
| 43 | + ```bash |
| 44 | + git clone https://github.com/StroppaFR/xodump.git |
| 45 | + cd xodump |
| 46 | + make |
| 47 | + ``` |
| 48 | + |
| 49 | +2. **Dump the memory-mapped binary:** |
| 50 | + |
| 51 | + ```bash |
| 52 | + ./xodump crackme > out |
| 53 | + will try to dump mapped executable /home/sonic/crackme |
| 54 | + dumping memory mapping from 0x555555554000 to 0x555555555000 |
| 55 | + ... |
| 56 | + successfully dumped 0x5000 bytes from mapped executable /home/sonic/crackme |
| 57 | + child process exited correctly after dump |
| 58 | + ``` |
| 59 | + |
| 60 | +3. **Analyze the dump:** |
| 61 | + |
| 62 | + ```bash |
| 63 | + strings out |
| 64 | + ``` |
| 65 | + |
| 66 | + Immediately you get the password string used in the binary: |
| 67 | + |
| 68 | + ``` |
| 69 | + Enter password: |
| 70 | + GottaGoFast |
| 71 | + Good password! |
| 72 | + Wrong password! |
| 73 | + ``` |
| 74 | + |
| 75 | +Of course, in real use, you'll load `out` into IDA or Ghidra, and the binaries won't be a simple crackme. |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +## Notes |
| 80 | + |
| 81 | +* This only works if you can execute the binary. If you do not trust the binary, do not run it. |
| 82 | +* Works even with setuid binaries. |
| 83 | +* All credits to [nikost](https://github.com/StroppaFR) for xodump, which improves on the old [XOcopy](http://reverse.lostrealm.com/tools/xocopy.html). |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +## Example crackme used: |
| 88 | + |
| 89 | +```c |
| 90 | +#include <stdio.h> |
| 91 | +#include <stdlib.h> |
| 92 | +#include <string.h> |
| 93 | +
|
| 94 | +int main() { |
| 95 | + char password[20]; |
| 96 | + printf("Enter password: "); |
| 97 | + fgets(password, 20, stdin); |
| 98 | + if (strcmp(password, "GottaGoFast\n") == 0) { |
| 99 | + printf("Good password!\n"); |
| 100 | + } else { |
| 101 | + printf("Wrong password!\n"); |
| 102 | + } |
| 103 | + return 0; |
| 104 | +} |
| 105 | +``` |
| 106 | +
|
| 107 | +--- |
| 108 | +
|
| 109 | +## TL;DR |
| 110 | +
|
| 111 | +* If you can execute an ELF binary, you can dump it from memory with xodump, even if it is not readable. |
| 112 | +* Useful for CTF, pentest, any situation with “execute-only” binaries. |
| 113 | +
|
| 114 | +--- |
0 commit comments