SMALL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #!/usr/bin/python from subprocess import Popen , PIPE from time import sleep # shellcode shellcode = "\x41" * 1000 + "\n" # opens gdb with parameter executable # you can also manage stdout and stderr here proc = Popen( ['gdb' , 'executable'] , bufsize=1 ,stdin=PIPE ) # sample breakpoint # notice the new line after each command proc.stdin.write('b *DEADBEEF\n') # half a second of sleep after each command sleep(0.5) # r or run to start debugging the program with GDB proc.stdin.write('r\n') sleep(0.5) # any other commands go here # this is a loop, will get every command and pass it to GDB # "leave" == quit GDB and terminate process # "dump" == paste shellcode while True: mycommand = raw_input() if (mycommand == "leave"): # quit gdb proc.stdin.write("quit\n") break # paste shellcode if (mycommand == "dump"): proc.stdin.write(shellcode) # more custom commands go here # not a custom command? send it as-is else: mycommand = mycommand + '\n' proc.stdin.write(mycommand) sleep(0.5) # close our pipe proc.stdin.close() 위의 코드에서 write 하는 값만 적절하게 넣어주면 gdb를 이용한 자동 디버깅이 가능하다. [퍼옴] : http://oulth.tistory.com/95 | cs |
LIST
'기타[etc]' 카테고리의 다른 글
펌웨어 수정 (0) | 2018.11.08 |
---|---|
python thread 병렬처리 (0) | 2018.04.12 |
QEMU 네트워크 브릿지 구성 (6) | 2018.03.13 |
파이썬 타이핑 (0) | 2017.08.20 |
[Volatility] Profile 만들기 (0) | 2017.07.22 |