명령어
1.pdisas :disas를 알록달록하게
2.find : string검색기능
find "pattern" "범위" (범위 설정 안하면 binary 영역으로 셋팅)
find /bin/sh libc
3.checksec
4.context : code/register/stack 영역을 한번에 볼수 있게함
context "code/register/stack/all"
5.session save, restore : 브레이크포인트와 같은 설정을 저장할 수 있음
session save 파일명
session restore 파일명
6.snapshot save. restore : 스냅샷을 찍음
snapshot save 파일명
snapshot restore 파일명
7.vmmap : 현재 디버깅 중인 프로세스의 메모리 영역을 보여줌
vmmap "all/binary/libc/stack/ld .."
8.nxtest : nx가 걸려있는지 테스트
9.procinfo : 현재 디버깅중인 프로세스의 정보
10.elfsymbol : 현재 디버깅 중인 바이너리의 plt주소, got주소 등을 알 수 있음
11.elfheader : 현재 디버깅 중인 바이너리의 header주소를 알려줌
elfheader .bss
12.ropgadget, ropsearch, dumprop : ROP를 할 때 필요한 가젯들을 쉽게 찾을 수 있도록 도와주는 명령어
gdb-peda$ ropgadget binary/libc/vdso/all ... ( 인자를 생략하면 ropgadget binary 와 같습니다. )
gdb-peda$ ropsearch "gadget" "범위" ( gadget 부분을 '' 로 빈 상태로 보내면 모든 가젯을 찾습니다. )
gdb-peda$ dumprop "범위" ( 인자를 생략하면 dumprop binary 와 같습니다.
gdb-peda$ ropgadget
gdb-peda$ ropgadget libc
gdb-peda$ ropsearch "add esp, ?" binary
gdb-peda$ ropsearch "int 0x80" libc
gdb-peda$ ropsearch "" binary ( binary 범위에서 모든 가젯을 찾습니다. )
gdb-peda$ ropsearch "pop ?" 0x08048000 0x0804b000
gdb-peda$ dumprop binary
gdb-peda$ dumprop 0x08048000 0x0804b000
13.shellcode
shellcode generate
shellcode generate x86/linux exec
14.pattern : 패턴 찾기
pattern create 264
pattern search
- 16진수 => 10진수
(gdb) print/d 0x400
$1 =1024
또는
(gdb) print 0x400
$1 =1024
- 10진수 => 16진수
(gdb) print/x 1024
$2 =0x400
- 산술식
(gdb) print/x 0x400-0x200
$3 0x200
(gdb) print 0x400-0x200
$4 512
GDB 실행중에 user input 넣기
파일 내용을 입력
(gdb) r < filename
스크립트 또는 명령어 실행 결과를 임시 파일에 저장 후 임시 파일 내용을 입력
(gdb) r python -c 'print "A"*10' > tmp < tmp
(gdb) r echo "AAAAAAAAAA" > tmp < tmp
임시 파일 없이 스크립트 또는 명령어 실행 결과를 입력
(gdb) r < <(python -c 'print "A"*10')
(gdb) r < <(echo "AAAAAAAAAA")
문자열을 입력 (r <<< Here Strings)
(gdb) r <<< $(python -c 'print "A"*10')
(gdb) r <<< "AAAAAAAAAA"
두 명령어의 결과를 비교할 때 사용하는 방법
$ diff <(cmd) <(cmd)