第八章 内存马分析-java01-nacos

文章发布时间:

最后更新时间:

文章总字数:
947

预计阅读时间:
4 分钟

页面浏览: 加载中...

简介:

ssh root@ip 密码xjnacos 启动 /var/local/下的 autorun.sh即可正常启动
问题 1 nacos 用户密码的密文值作为 flag 提交 flag{密文}
问题 2 shiro 的key为多少 shiro 的 key 请记录下来 (备注请记录下,可能有用)
问题 3 靶机内核版本为 flag{}
问题 4 尝试应急分析,运行 get_flag 然后尝试 check_flag 通过后提交 flag
问题 5 尝试修复 nacos 并且自行用 poc 测试是否成功

1.

nacos 用户密码的密文值作为 flag 提交 flag{密文}

启动靶机先看一下nacos的端口,为8848,nacos首页为 http://52.82.30.99:8848/nacos/#/login,fscan扫了一下是存在nacos常见的漏洞的,比如改密码,后台也是弱口令(nacos/nacos),但是这里要的是密文

image

image

这里我们直接去nacos的配置文件里看密文即可,nacos用户密码设置是在nacos-mysql.sql里,flag{$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu}

image

image

2.

shiro 的key为多少 shiro 的 key 请记录下来 (请记录下来,会有用的)

找了一圈没有找到这个shiro的key,非常的郁闷,最后对这个zip备份下手了,解压看看

image

果然在这里面直接搜shiro就找到了,grep -rni "shiro",flag{KduO0i+zUIMcNNJnsZwU9Q==}

image

image

3.

靶机内核版本为

uname -a即可查看版本信息。flag{5.4.0-164-generic}

image

4.

尝试应急分析,运行 get_flag 然后尝试 check_flag 通过后提交 flag

有点懵,先找一下程序的路径,因为题目也没说怎么应急,将这两个程序逆向看看怎么个事

image

die查一下两个都是pyinstaller打包的,那我们把源码复原就好,如下,由Check_User 和 Check_process 两个函数可知,只要我们清楚后门用户、保持nacos服务运行即可

image

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
# uncompyle6 version 3.9.2
# Python bytecode version base 3.8.0 (3413)
# Decompiled from: Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
# Embedded file name: check_flag
import re, hashlib

def Get_flag():
part1 = "vuln"
part2 = "tar"
part3 = "get-m-01"
text = part1 + part2 + part3
hash_object = hashlib.md5(text.encode())
hash_hex = hash_object.hexdigest()
flag = "flag{" + hash_hex + "}"
return flag


def check():
try:
Check_flag = str(input("[+] please input your flag: "))
if Check_flag == Get_flag():
print("[+] 恭喜,当前机器应急成功!")
else:
print("[-] sorry, 应急失败~请继续检查...")
except Exception as e:
try:
print("[-] ERROR 程序报错")
finally:
e = None
del e


if __name__ == "__main__":
check()
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# uncompyle6 version 3.9.2
# Python bytecode version base 3.8.0 (3413)
# Decompiled from: Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
# Embedded file name: get_flag.py
import time, hashlib, subprocess

def Get_FLag():
current_time = str(int(time.time()))
hash_object = hashlib.md5(current_time.encode())
hash_hex = hash_object.hexdigest()
print(f"[+] current time: {time.ctime()}")
print("[-] flag{" + hash_hex + "}")


def Get_flag():
part1 = "vuln"
part2 = "tar"
part3 = "get-m-01"
text = part1 + part2 + part3
hash_object = hashlib.md5(text.encode())
hash_hex = hash_object.hexdigest()
print("[+] flag{" + hash_hex + "}")


def Check_process():
keyword = "nacos"
command = f"ps aux | grep '{keyword}'"
output = subprocess.getoutput(command)
if "nacos-server" in output:
print("[+] info nacos程序存在...")
return True
print("[-] ERROR")
return False


def Check_User():
keyword = "adrla7IBSf"
command = f"cat /etc/passwd | grep '{keyword}'"
output = subprocess.getoutput(command)
if "adrla7IBSfTZQ" in output:
print("[-] ERROR")
return False
print("[+] info 后门用户已清除...")
return True


def Check_flag():
if Check_User() and Check_process():
Get_flag()
else:
Get_FLag()


if __name__ == "__main__":
Check_flag()

nacos服务是运行的,不用管,我们cat /etc/passwd发现bt用户好像是和root绑定的,我们直接将该行删除即可,flag{6c3742aaf26a6dea7fe9d7731de59517}

image

image

5.

尝试修复 nacos 并且自行用 poc 测试是否成功 此题无flag

尝试了几个常见的poc路径都是404,应该不存在这些漏洞

1
2
/v1/auth/users/login  #重置用户密码
/v1/auth/users #修改用户

那么修复的话,只要把后台弱口令修改,nacos默认key修改即可