
مولد أوتوماتيكي لسلسلة ROP للملفات الثنائية x86-64 باستخدام التنفيذ الرمزي. يدعم كتابة السجلات/الذاكرة، استدعاء الدوال، استدعاءات النظام (syscalls)، تجنب badchar، تحويل المكدس (stack pivoting)، ووضع النواة مع إعادة كتابة retpoline.
مُولِّد سلسلة ROP تلقائي للثنائيات x86-64، مدعوم بالتنفيذ الرمزي Triton.
rdi=0x41414141, rdi=rax)open("/etc/passwd", 0))pip install git+https://github.com/d4em0n/exrop.git
يُثبِّت هذا الأمر exrop وتبعياته في بايثون (pyelftools, ROPGadget, triton-library).
ملاحظة: قد لا تعمل حزمة
triton-librarypip على جميع المنصات. إذا فشل التثبيت، قم ببناء Triton من المصدر وقم بتثبيت exrop بدون تبعية Triton:pip install --no-deps git+https://github.com/d4em0n/exrop.git pip install pyelftools ROPGadget
للتطوير (تثبيت قابل للتعديل مع تبعيات الاختبار):
git clone https://github.com/d4em0n/exrop.git
cd exrop
pip install -e ".[dev]"
git clone https://github.com/d4em0n/exrop.git
export PYTHONPATH=/path/to/exrop:$PYTHONPATH
from Exrop import Exrop
rop = Exrop("/bin/ls")
rop.find_gadgets(cache=True)
# ضبط المسجلات
chain = rop.set_regs({'rdi': 0x41414141, 'rsi': 0x42424242, 'rdx': 0x43434343})
chain.dump()
# الكتابة إلى الذاكرة
chain = rop.set_writes({0x41414141: 0xdeadbeefff, 0x43434343: 0x00110011})
chain.dump()
# كتابة سلسلة إلى الذاكرة
chain = rop.set_string({0x41414141: "Hello world!\n"})
chain.dump()
# استدعاء دالة
chain = rop.func_call(0x41414141, (0x20, 0x30, "Hello"), 0x7fffff00)
chain.dump()
المخرجات:
$RSP+0x0000 : 0x00000000000060d0 # pop rbx; ret
$RSP+0x0008 : 0x0000000044444444
$RSP+0x0010 : 0x0000000000014852 # mov rax, rbx; pop rbx; ret
$RSP+0x0018 : 0x0000000000000000
$RSP+0x0020 : 0x0000000000004ce5 # pop rdi; ret
$RSP+0x0028 : 0x0000000041414141
$RSP+0x0030 : 0x000000000000629c # pop rsi; ret
$RSP+0x0038 : 0x0000000042424242
$RSP+0x0040 : 0x0000000000003a62 # pop rdx; ret
$RSP+0x0048 : 0x0000000043434343
$RSP+0x0050 : 0x00000000000060d0 # pop rbx; ret
$RSP+0x0058 : 0x0000000045454545
لنواة لينكس مع تخفيفات retpoline، يقوم kernel_mode=True تلقائياً بكشف رموز thunk وإعادة كتابة القطع والاقتصار على مقطع .text:
from Exrop import Exrop
rop = Exrop("/path/to/vmlinux")
rop.find_gadgets(cache=True, kernel_mode=True)
rop.clean_only = True # استبعاد القطع ذات الكتابات الجانبية الخطيرة
# ضبط المسجلات
chain = rop.set_regs({'rdi': 0x41414141, 'rsi': 0})
chain.dump()
# البحث عن قطع تحويل المكدس (مباشرة، متسلسلة JOP، غير مباشرة)
pivots = rop.stack_pivot_reg('rdi')
for p in pivots[:5]:
p.dump()
# بناء حمولة لتحويل المكدس
payload = pivots[0].build_payload(chain)
يوفر أمر exkrop سير عمل تفاعلي لتوليد سلسلة ROP للنواة مع اختيار المحور (pivot) وإخراج كود C:
exkrop <vmlinux>
# أو: python3 -m exkrop <vmlinux>
الميزات: قوالب استغلال (رفع الامتيازات، كتابة core_pattern)، إخراج نسبي لـKASLR، متصفح قطع المحور، معالجة الإزاحات المحجوزة، وتوليد كود C. راجع exkrop/README.md للتفاصيل.
from pwn import *
from Exrop import Exrop
libc = ELF("/lib/x86_64-linux-gnu/libc.so.6", checksec=False)
rop = Exrop(libc.path)
rop.find_gadgets(cache=True)
bss = libc.bss()
chain = rop.func_call(libc.symbols['open'], ("/etc/passwd", 0), bss)
chain.set_base_addr(0x00007ffff79e4000)
chain.dump()
chain = rop.func_call(libc.symbols['read'], ('rax', bss, 0x100))
chain.set_base_addr(0x00007ffff79e4000)
chain.dump()
chain = rop.func_call(libc.symbols['write'], (1, bss, 0x100))
chain.set_base_addr(0x00007ffff79e4000)
chain.dump()
المزيد من الأمثلة في مجلد examples/.