
x86-64 바이너리를 위한 심볼릭 실행 기반 자동 ROP 체인 생성기. 지원: 레지스터/메모리 쓰기, 함수 호출, 시스템 콜, 배드캐릭터 회피, 스택 피봇팅, 및 retpoline 재작성을 통한 커널 모드.
Triton 기호 실행을 기반으로 한 x86-64 바이너리용 자동 ROP 체인 생성기입니다.
rdi=0x41414141, rdi=rax)open("/etc/passwd", 0))pip install git+https://github.com/d4em0n/exrop.git
이 명령은 exrop와 그 Python 의존성(pyelftools, ROPGadget, triton-library)을 설치합니다.
참고:
triton-librarypip 패키지는 모든 플랫폼에서 작동하지 않을 수 있습니다. 설치가 실패하면 Triton을 소스에서 빌드하고 Triton 의존성 없이 exrop를 설치하세요: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 완화가 적용된 Linux 커널의 경우, kernel_mode=True는 썽크 심볼을 자동으로 감지하고 가젯을 재작성하며 .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 명령은 피벗 선택 및 C 코드 출력을 포함한 커널 ROP 체인 생성을 위한 대화형 워크플로우를 제공합니다:
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/ 디렉토리에서 확인할 수 있습니다.