
ELF, PE, Mach-O, 및 Raw 바이너리에서 x86, ARM, MIPS, 및 RISC-V 아키텍처에 걸쳐 ROP gadgets를 검색합니다. 자동화된 ROP chain generation 및 interactive console mode를 지원합니다.
이 도구는 바이너리에서 가젯을 검색하여 ROP 공격을 용이하게 해줍니다. ROPgadget은 x86, x64, ARM, ARM64, PowerPC, SPARC, MIPS, RISC-V 64 및 RISC-V Compressed 아키텍처에서 ELF/PE/Mach-O/Raw 형식을 지원합니다.
가장 쉬운 방법은 PyPi에서 ROPgadget을 설치하는 것입니다:
$ sudo apt install python3-pip
$ sudo -H python3 -m pip install ROPgadget
$ ROPgadget --help
또는 소스에서 ROPgadget을 설치할 수 있습니다. 먼저 Capstone을 설치해야 합니다.
nix 머신에서 Capstone 설치:
$ sudo apt install python3-pip
$ sudo -H python3 -m pip install capstone
Capstone은 여러 플랫폼(Windows, iOS, Android, Cygwin 등)을 지원합니다. 크로스 컴파일에 대해서는 https://github.com/capstone-engine/capstone/blob/master/COMPILE.TXT 파일을 참조하세요.
Capstone 설치 후 ROPgadget을 독립형 도구로 사용할 수 있습니다:
$ python3 ROPgadget.py --help
또는 Python site-packages 라이브러리에 설치하여 $PATH에서 실행할 수 있습니다.
$ sudo -H python3 setup.py install
$ ROPgadget --help
usage: ROPgadget.py [-h] [-v] [-c] [--binary <binary>] [--opcode <opcodes>]
[--string <string>] [--memstr <string>] [--depth <nbyte>]
[--only <key>] [--filter <key>] [--range <start-end>]
[--badbytes <byte>] [--rawArch <arch>] [--rawMode <mode>]
[--rawEndian <endian>] [--re <re>] [--offset <hexaddr>]
[--ropchain] [--thumb] [--console] [--norop] [--nojop]
[--callPreceded] [--nosys] [--multibr] [--all] [--noinstr]
[--dump] [--silent] [--align ALIGN] [--mipsrop <rtype>]
설명:
ROPgadget을 사용하면 바이너리에서 가젯을 검색할 수 있습니다. 여러 파일 형식과
아키텍처를 지원하며 검색 엔진으로 Capstone 디스어셈블러를 사용합니다.
지원되는 형식:
- ELF
- PE
- Mach-O
- Raw
지원되는 아키텍처:
- x86
- x86-64
- ARM
- ARM64
- MIPS
- PowerPC
- Sparc
- RISC-V 64
- RISC-V Compressed
선택적 인자:
-h, --help 이 도움말 메시지를 표시하고 종료합니다
-v, --version ROPgadget의 버전을 표시합니다
-c, --checkUpdate 새 버전이 있는지 확인합니다
--binary <binary> 분석할 바이너리 파일명을 지정합니다
--opcode <opcodes> 실행 가능한 세그먼트에서 opcode를 검색합니다
--string <string> 읽기 가능한 세그먼트에서 문자열을 검색합니다
--memstr <string> 모든 읽기 가능한 세그먼트에서 각 바이트를 검색합니다
--depth <nbyte> 검색 엔진의 깊이 (기본값 10)
--only <key> 특정 명령어만 표시합니다
--filter <key> 특정 니모닉을 제외합니다
--range <start-end> 두 주소 사이에서 검색합니다 (0x...-0x...)
--badbytes <byte> 가젯 주소에서 특정 바이트를 거부합니다
--rawArch <arch> 원시 파일의 아키텍처를 지정합니다
x86|arm|arm64|sparc|mips|ppc|riscv
--rawMode <mode> 원시 파일의 모드를 지정합니다 32|64|arm|thumb
--rawEndian <endian> 원시 파일의 엔디언을 지정합니다 little|big
--re <re> 정규 표현식
--offset <hexaddr> 가젯 주소의 오프셋을 지정합니다
--ropchain ROP 체인 생성을 활성화합니다
--thumb 검색 엔진에 thumb 모드를 사용합니다 (ARM 전용)
--console 검색 엔진에 대화형 콘솔을 사용합니다
--norop ROP 검색 엔진을 비활성화합니다
--nojop JOP 검색 엔진을 비활성화합니다
--callPreceded 호출 앞에 오는 가젯만 표시합니다
--nosys SYS 검색 엔진을 비활성화합니다
--multibr 다중 분기 가젯을 활성화합니다
--all 중복 가젯 제거를 비활성화합니다
--noinstr 가젯 명령어 콘솔 출력을 비활성화합니다
--dump 가젯 바이트를 출력합니다
--silent 분석 중 가젯 출력을 비활성화합니다
--align ALIGN 가젯 주소를 정렬합니다 (바이트 단위)
--mipsrop <rtype> MIPS 유용한 가젯 찾기
stackfinder|system|tails|lia0|registers
예제:
ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86
ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --ropchain
ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --depth 3
ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --string "main"
ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --string "m..n"
ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --opcode c9c3
ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --only "mov|ret"
ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --only "mov|pop|xor|ret"
ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --filter "xchg|add|sub|cmov.*"
ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --norop --nosys
ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --range 0x08041000-0x08042000
ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --string main --range 0x080c9aaa-0x080c9aba
ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --memstr "/bin/sh"
ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --console
ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --badbytes "00|01-1f|7f|42"
ROPgadget.py --binary ./test-suite-binaries/Linux_lib64.so --offset 0xdeadbeef00000000
ROPgadget.py --binary ./test-suite-binaries/elf-ARMv7-ls --depth 5
ROPgadget.py --binary ./test-suite-binaries/elf-ARM64-bash --depth 5
ROPgadget.py --binary ./test-suite-binaries/raw-x86.raw --rawArch=x86 --rawMode=32
ROPgadget.py --binary ./test-suite-binaries/elf-Linux-RISCV_64 --depth 8
버그 신고, 풀 리퀘스트 제출 등은 GitHub https://github.com/JonathanSalwan/ROPgadget 에서 해주세요.
LICENSE_BSD.txt와 모든 소스 파일의 라이선스 헤더를 참조하세요.
x64
ARM
Sparc
MIPS
PowerPC
ROP 체인