
Costruttore automatico di catene ROP che estrae e analizza gadget da binari utilizzando query semantiche, supportando le architetture X86/X64 con un'API Python e una CLI.

ROPium (ex-ROPGenerator) è una libreria/strumento che semplifica gli exploit ROP. Estrae e analizza automaticamente i gadget dai binari e permette di trovare catene ROP con query semantiche. ROPium supporta le architetture X86 e X64, presto esteso con ARM.
Caratteristiche principali:
rax=rbx+8, [rdi+0x20]=rax, rsi=[rbx+16], 0x08040212(1, 2, rax), [0xdeadbeaf] = "/bin/sh\x00", sys_execve(0xdeadbeef, 0, 0), sys_0x1(0), ...Prima installa il framework di disassemblaggio Capstone:
sudo apt-get install libcapstone-dev
Hai anche bisogno dell'ultima versione di ROPgadget:
git clone https://github.com/JonathanSalwan/ROPgadget && cd ROPgadget
python setup.py install --user
Per usare lo strumento CLI, installa prompt_toolkit:
pip3 install prompt_toolkit
Infine installa ROPium:
git clone https://github.com/Boyan-MILANOV/ropium && cd ropium
make
make test
sudo make install
Grazie a un wrapper a riga di comando, puoi usare ROPium in modo interattivo per costruire rapidamente catene ROP:
Hai bisogno di integrare le catene ROP direttamente nei tuoi script? Buone notizie, ROPium ha un'API Python!
Caricare un binario e trovare catene ROP:
from ropium import *
rop = ROPium(ARCH.X64)
rop.load('/lib/x86_64-linux-gnu/libc-2.27.so')
chain = rop.compile('rbx = [rax + 0x20]')
Esportare una catena ROP in vari formati:
>>> print( chain.dump() )
0x000000000009a851 (sub rax, 0x10; ret)
0x0000000000130018 (mov rax, qword ptr [rax + 0x30]; ret)
0x0000000000052240 (push rax; pop rbx; ret)
>>> print(chain.dump('python'))
from struct import pack
off = 0x0
p = ''
p += pack('<Q', 0x000000000009a851+off) # sub rax, 0x10; ret
p += pack('<Q', 0x0000000000130018+off) # mov rax, qword ptr [rax + 0x30]; ret
p += pack('<Q', 0x0000000000052240+off) # push rax; pop rbx; ret
>>> print(chain.dump('raw'))
b'Q\xa8\t\x00\x00\x00\x00\x00\x18\x00\x13\x00\x00\x00\x00\x00@"\x05\x00\x00\x00\x00\x00'
Imposta vincoli sulle catene ROP:
# Bytes that should not appear in the ropchain
rop.bad_bytes = [0x00, 0x0a, 0x0b]
# Register that should not be clobbered by the ropchain
rop.keep_regs = ['rsi', 'rdx']
# Enable/Forbid ropchain to dereference registers that might hold invalid addresses
# Safe mode is 'True' by default
rop.safe_mem = False
# Specify which ABI you want to use when calling functions
rop.abi = ABI.X86_CDECL
# Specify which system to target when doing syscalls
rop.os = OS.LINUX
Se necessario, puoi eseguire ROPium in un contenitore Docker. Il contenitore può essere generato dal Dockerfile come segue:
# Create your docker image (this will take time!)
docker build . --tag ropium
# Run the image in interactive mode, bind mounting the file to analyze
docker run --rm -it -v /FULL/HOST/PATH/FILE:/tmp/FILE:ro ropium
(ropium)> load -a X86 /tmp/FILE
L'immagine effettiva è di circa 200 MB basata su Debian Stretch con Python 3.7.3 installato.
Boyan MILANOV - boyan.milanov (at) hotmail (dot) fr
ROPium è fornito con licenza MIT.
Contributori:
ROPium utilizza i seguenti fantastici progetti: