
log4shell(CVE-2021-44228, CVE-2021-45046) 및 기타 취약한(CVE-2017-5645, CVE-2019-17571, CVE-2022-23305, CVE-2022-23307 ...) log4j 라이브러리 인스턴스를 위한 가장 빠른 파일시스템 스캐너입니다. 뛰어난 성능과 낮은 메모리 사용량을 제공합니다.

https://github.com/mergebase/log4j-detector 의 Python 포트입니다. log4j-detector는 Copyright (C) Copyright 2021 Mergebase Software Inc. https://mergebase.com/ 의 저작권입니다. GPLv3로 라이선스됩니다.
Python으로 포팅한 동기는 성능 향상, 메모리 소비 감소, 코드 가독성 향상이었습니다. 아래의 성능 비교 섹션을 참조하세요.
그리고 이것은 가장 빠르면서 메모리 요구량이 가장 낮은 스캐닝 도구인 것으로 보입니다.
파일 시스템에서 CVE-2021-44228, CVE-2021-45046 및 기타 여러 취약점에 취약한 log4j (1.x), reload4j (1.2.18+) 및 log4j-core (2.x) 버전을 식별합니다 - 아래 표 참조. 더 큰 애플리케이션에 여러 계층 깊이로 포함된 인스턴스를 찾을 수 있습니다. Linux, Windows, Mac 또는 Python 3.8+가 실행되는 모든 곳에서 작동합니다.
실행 가능한 spring-boot jar/war 내부의 log4j, uber jar에 혼합된 의존성, shaded jar, 그리고 파일 시스템에 압축되지 않은 채 있는 exploded jar 파일(*.class)까지도 정확하게 감지할 수 있습니다.
또한 shaded 클래스 파일(.esclazz(elastic) 및 .classdata(Azure) 확장자)도 처리할 수 있습니다.
검색되는 Java 아카이브 확장자: .zip, .jar, .war, .ear, .aar, .jpi,
.hpi, .rar, .nar, .wab, .eba, .ejb, .sar, .apk, .par, .kar
각 인스턴스는 해당하는 CVE 목록과 함께 보고됩니다. 각 CVE에 대해 log4j 라이브러리 파일이 권장 완화 조치(예: JndiLookup.class 또는 JMSAppender.class 제거)가 적용되었는지 분석되며, 적용된 경우 취약하지 않은 것으로 간주됩니다. 상태 STRANGE는 log4j-core pom.properties 파일은 있지만 실제 바이트코드 클래스가 없는 아카이브에 대해 보고되며, 일반적으로 소스 패키지이므로 무시할 수 있습니다.
경고
--fix기능은 실험적이며, 사용에 따른 위험은 본인이 감수해야 합니다. 사용하기 전에 jar 파일을 백업하세요.
--fix 인자는 JndiLookup.class의 인스턴스를 JndiLookup.vulne으로 이름을 변경하여 클래스가 로드되지 않도록 시도합니다. Java 아카이브 내에서는 제자리 이름 변경으로 수행되며, 아카이브를 다시 압축할 필요가 없고 즉시 빠르게 처리됩니다.
Linux 64bit, MS Windows 64bit 및 32bit용 바이너리는 Releases에서 확인할 수 있습니다.
지원되는 최소 Python 버전은 3.8입니다. 테스트에 따르면 Python 3.6의 zip 구현은 테스트 데이터에 있는 많은
.jar파일을 열 수 없습니다.
log4shell finder는 성능과 낮은 메모리 사용량에 최적화되어 있습니다.
2022년 1월 23일 업데이트, 2005개 폴더의 26237개 파일이 있는 디렉토리에서 측정된 성능입니다.
런타임은 절반으로, 메모리 소비는 2/3로, 파일 시스템 읽기는 최소 90% 감소했습니다.
Command being timed: "./test_log4shell.py /home/hynek/war/ --exclude-dirs /mnt --same-fs"
User time (seconds): 17.68
System time (seconds): 1.20
Percent of CPU this job got: 127%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:14.47
Maximum resident set size (kbytes): 64144
File system inputs: 114424
Command being timed: "./log4j-finder.py /home/hynek/war/"
User time (seconds): 23.59
System time (seconds): 1.09
Percent of CPU this job got: 99%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:26.18
Maximum resident set size (kbytes): 38604
File system inputs: 142824
Command being timed: "java -jar log4j-detector-latest.jar /home/hynek/war"
User time (seconds): 30.56
System time (seconds): 1.39
Percent of CPU this job got: 113%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:28.26
Maximum resident set size (kbytes): 214116
File system inputs: 14416
Command being timed: "./log4j2-scan /home/hynek/war --scan-log4j1 --scan-zip"
User time (seconds): 52.05
System time (seconds): 25.32
Percent of CPU this job got: 88%
Elapsed (wall clock) time (h:mm:ss or m:ss): 1:27.86
Maximum resident set size (kbytes): 593080
File system inputs: 215416
all 매개변수를 사용하여 mswin에서 모든 로컬 드라이브 자동 감지--no-csv-header--threads 매개변수--cvs-clean 매개변수--cvs-stats 매개변수--fix 명령이 .jar 아카이브를 손상시킬 수 있었습니다.이전 변경 사항은 릴리스 노트를 참조하세요.
Python 인터프리터에서 실행하거나 dist 폴더의 Windows/Linux 바이너리를 사용하세요.
전체 파일 시스템에 대한 접근 권한(최소한 읽기 전용)이 있는 사용자로 실행해야 합니다. log4shell-finder는 접근할 수 있는 폴더만 탐색하며 권한 거부 오류를 보고하지 않습니다.
PS C:\D\log4shell_finder> python3 .\test_log4shell.py --help
usage: Type "test_log4shell.py --help" for more information
On Windows "test_log4shell.py c:\ d:\"
On Linux "test_log4shell.py /"
Searches file system for vulnerable log4j version.
positional arguments:
folders List of folders or files to scan. Use "-" to read list of files from stdin. On MS Windows use "all" to scan all local drives.
optional arguments:
-h, --help show this help message and exit
--exclude-dirs DIR [DIR ...]
Exclude given directories from search.
-s, --same-fs Don't scan mounted volumens.
-j [FILE], --json-out [FILE]
Save results to json file.
-c [FILE], --csv-out [FILE]
Save results to csv file.
--csv-clean Add CLEAN status line in case no entries found
--csv-stats Add STATS line into csv output.
--no-csv-header Don't write CSV header to the output file.
-f, --fix Fix vulnerable by renaming JndiLookup.class into JndiLookup.vulne.
--threads [THREADS] Specify number of threads to use for parallel processing, default is 6.
--file-log [LOGFILE] Enable logging to log file, default is log4shell-finder.log.
--progress [SEC] Report progress every SEC seconds, default is 10 seconds.
--no-errors Suppress printing of file system errors.
--strange Report also strange occurences with pom.properties without binary classes (e.g. source or test packages)
-d, --debug Increase verbosity, mainly for debugging purposes.
-v, --version show program's version number and exit
추가 Python 라이브러리가 필요하지 않습니다.
바이너리는 다음 명령으로 생성되었습니다:
pip install pyinstaller
pyinstaller -F ./test_log4shell.py
32비트 버전을 빌드하려면 32비트 Python 인터프리터를 설치하고 pyinstaller를 다음과 같이 설치하세요:
C:\Users\User\AppData\Local\Programs\Python\Python38-32\python.exe -m pip install pyinstaller
그런 다음:
C:\Users\User\AppData\Local\Programs\Python\Python38-32\Scripts\pyinstaller.exe -n test_log4shell-mswin32 -F test_log4shell.py
Linux에서는 다음과 같이 실행할 수 있습니다:
python3 ./test_log4shell.py / /opt --same-fs --no-errors
MS Windows의 경우:
python3 .\test_log4shell.py c:\ d:\ --same-fs --no-errors
MS Windows에서:
pywin32가 설치되어 있는지 확인하세요(예: pip install pywin32).
PS C:\D\log4shell_finder> python3 .\test_log4shell.py c:\ --same-fs --no-errors
8 .8 8 8 8 d'b o 8
8 d'8 8 8 8 8 8
8 .oPYo. .oPYo. d' 8 .oPYo. 8oPYo. .oPYo. 8 8 o8P o8 odYo. .oPYo8 .oPYo. oPYo.
8 8 8 8 8 Pooooo Yb.. 8 8 8oooo8 8 8 8 8 8' `8 8 8 8oooo8 8 `'
8 8 8 8 8 8 'Yb. 8 8 8. 8 8 8 8 8 8 8 8 8. 8
8 `YooP' `YooP8 8 `YooP' 8 8 `Yooo' 8 8 8 8 8 8 `YooP' `Yooo' 8
..:.....::....8 ::::..::.....:..:::..:.....:....:::::::..:::....::..:.....::.....:..::::
:::::::::::ooP'.::::::::::::::::::::::::::::::::: Version 1.17-20220105 ::::::::::::
:::::::::::...::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Parameters: .\test_log4shell.py c:\ --same-fs --no-errors
Host info: 'hostname': 'TESTHOST', 'fqdn': 'TESTHOST.example.com', 'ip': '10.0.0.1', 'system': 'Windows', 'release': '10', 'version': '10.0.19043', 'machine': 'AMD64', 'cpu': 'Intel64 Family 6 Model 142 Stepping 12, GenuineIntel'
[+] [CVE-2021-4104 (8.1)] Package c:\Program Files\Microsoft SQL Server\150\DTS\Extensions\Common\Jars\log4j-1.2.17.jar contains Log4J-1.2.17 <= 1.2.17, JMSAppender.class found
[+] [CVE-2021-44832 (6.6), CVE-2021-45046 (9.0), CVE-2021-45105 (5.9)] Package c:\Program Files\OWASP\Zed Attack Proxy\lib\log4j-core-2.15.0.jar contains Log4J-2.15.0 == 2.15.0
[+] [CVE-2021-44228 (10.0), CVE-2021-44832 (6.6), CVE-2021-45046 (9.0), CVE-2021-45105 (5.9)] Package c:\Users\testuser\Downloads\sqldeveloper-20.4.1.407.0006-x64.zip -> sqldeveloper/sqldeveloper/lib/log4j-core.jar contains Log4J-2.13.3 >= 2.10.0
[+] [CVE-2021-44228 (10.0), CVE-2021-44832 (6.6), CVE-2021-45046 (9.0), CVE-2021-45105 (5.9)] Package c:\Users\testuser\Downloads\sqldeveloper-20.4.1.407.0006-x64\sqldeveloper\sqldeveloper\lib\log4j-core.jar contains Log4J-2.13.3 >= 2.10.0
Scanned 1162924 files in 286638 folders.
Found 1 instances vulnerable to CVE-2021-4104 (8.1)
Found 2 instances vulnerable to CVE-2021-44228 (10.0)
Found 3 instances vulnerable to CVE-2021-44832 (6.6)
Found 3 instances vulnerable to CVE-2021-45046 (9.0)
Found 3 instances vulnerable to CVE-2021-45105 (5.9)
1초마다 진행 상황을 보고하고 zip-bomb 폴더를 제외한 Kali 스캔:
root@kali:/home/hynek/log4shell-finder# python3 test_log4shell.py / --same-fs --no-errors --progress 1 --exclude-dirs /usr/share/seclists/Payloads/Zip-Bombs/
8 .8 8 8 8 d'b o 8
8 d'8 8 8 8 8 8
8 .oPYo. .oPYo. d' 8 .oPYo. 8oPYo. .oPYo. 8 8 o8P o8 odYo. .oPYo8 .oPYo. oPYo.
8 8 8 8 8 Pooooo Yb.. 8 8 8oooo8 8 8 8 8 8' `8 8 8 8oooo8 8 `'
8 8 8 8 8 8 'Yb. 8 8 8. 8 8 8 8 8 8 8 8 8. 8
8 `YooP' `YooP8 8 `YooP' 8 8 `Yooo' 8 8 8 8 8 8 `YooP' `Yooo' 8
..:.....::....8 ::::..::.....:..:::..:.....:....:::::::..:::....::..:.....::.....:..::::
:::::::::::ooP'.::::::::::::::::::::::::::::::::: Version 1.18-20220106 ::::::::::::
:::::::::::...::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Parameters: test_log4shell.py / --same-fs --no-errors --progress 1 --exclude-dirs /usr/share/seclists/Payloads/Zip-Bombs/
Host info: 'hostname': 'kali', 'fqdn': 'kali', 'ip': '10.0.0.2', 'system': 'Linux', 'release': '5.14.0-kali4-amd64', 'version': '#1 SMP Debian 5.14.16-1kali1 (2021-11-05)', 'machine': 'x86_64', 'cpu': ''
Skipping mount point: /data
Skipping mount point: /home
Skipping mount point: /dev
Skipping mount point: /sys
[+] [CVE-2021-4104 (8.1)] Package /usr/share/paros/paros.jar contains Log4J-1.x <= 1.2.17, JMSAppender.class found
After 1 secs, scanned 119762 files in 4853 folders.
Currently at: /usr/share/icons/hicolor/48x48/apps/kali-jd-gui.png
Skipping blaclisted folder: /usr/share/seclists/Payloads/Zip-Bombs
After 2 secs, scanned 190067 files in 12980 folders.
Currently at: /usr/share/plasma/desktoptheme/kali/metadata.desktop
[+] [CVE-2021-44228 (10.0), CVE-2021-44832 (6.6), CVE-2021-45046 (9.0), CVE-2021-45105 (5.9)] Package /usr/share/jsql-injection/jsql-injection.jar contains Log4J-2.14.0 >= 2.10.0
After 3 secs, scanned 221233 files in 17725 folders.
Currently at: /usr/share/maltego/maltego-ui/modules/com-paterva-maltego-transform-finder.jar
[+] [CVE-2021-44228 (10.0), CVE-2021-44832 (6.6), CVE-2021-45046 (9.0), CVE-2021-45105 (5.9)] Package /usr/share/zaproxy/lib/log4j-core-2.14.1.jar contains Log4J-2.14.1 >= 2.10.0
[+] [CVE-2021-4104 (8.1)] Package /usr/share/javasnoop/lib/log4j-1.2.16.jar contains Log4J-1.2.16 <= 1.2.17, JMSAppender.class found
After 7 secs, scanned 233394 files in 18705 folders.
Currently at: /usr/share/images/desktop-base/login-background.svg
After 8 secs, scanned 301417 files in 27952 folders.
Currently at: /usr/lib/python3/dist-packages/faraday_plugins/plugins/repo/dirb/plugin.py
After 9 secs, scanned 342342 files in 34421 folders.
Currently at: /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jexec
Skipping mount point: /run
Skipping mount point: /proc
Scanned 379253 files in 37742 folders in 9.9 seconds.
Found 2 instances vulnerable to CVE-2021-4104 (8.1)
Found 2 instances vulnerable to CVE-2021-44228 (10.0)
Found 2 instances vulnerable to CVE-2021-44832 (6.6)
Found 2 instances vulnerable to CVE-2021-45046 (9.0)
Found 2 instances vulnerable to CVE-2021-45105 (5.9)
json 출력에는 호스트 정보와 발견된 모든 항목이 포함됩니다:
{
"hostname": "myserver",
"fqdn": "myserver",
"ip": "10.0.0.1",
"system": "Linux",
"release": "5.4.0-58-generic",
"version": "#64-Ubuntu SMP Wed Dec 9 08:16:25 UTC 2020",
"machine": "x86_64",
"cpu": "x86_64",
"cmdline": "./test_log4shell.py / --exclude-dirs /mnt --same-fs --csv-out --json-out",
"starttime": "2021-12-22 07:07:54",
"items": [
{
"container": "Package",
"path": "/home/hynek/.m2/repository/org/apache/logging/log4j/log4j-core/2.14.1/log4j-core-2.14.1.jar",
"status": "CVE_2021_44228",
"message": "contains Log4J-2.14.1 >= 2.10.0",
"pom_version": "2.14.1"
},
{
"container": "Package",
"path": "/home/hynek/.m2/repository/org/apache/logging/log4j/log4j-core/2.16.0/log4j-core-2.16.0.jar",
"status": "NOTOKAY",
"message": "contains Log4J-2.16.0 == 2.16.0",
"pom_version": "2.16.0"
},
{
"container": "Package",
"path": "/home/hynek/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar",
"status": "CVE_2021_4104",
"message": "contains Log4J-1.2.17 <= 1.2.17, JMSAppender.class found",
"pom_version": "1.2.17"
},
{
"container": "Package",
"path": "/home/hynek/.m2/repository/log4j/log4j/1.2.12/log4j-1.2.12.jar",
"status": "CVE_2021_4104",
"message": "contains Log4J-1.x <= 1.2.17, JMSAppender.class found",
"pom_version": "1.x"
},
{
"container": "Package",
"path": "/home/hynek/war/elastic-apm-java-aws-lambda-layer-1.28.1.zip:elastic-apm-agent-1.28.1.jar",
"status": "MAYBESAFE",
"message": "contains Log4J-2.12.1 <= 2.0-beta8 (JndiLookup.class not present)",
"pom_version": "2.12.1"
}
]
}
다음 열로 구성됩니다:
"datetime","ver","ip","fqdn","OS","Release","arch","container","status","path","message","pom_version","product"
"2022-01-24 10:59:36","1.22pre-20220123","10.0.0.1","mylinux","Linux","5.4.0-58-generic","x86_64","Folder","CVE-2022-23302 (6.6), CVE-2022-23305 (8.1), CVE-2022-23307 (8.1)","/home/hynek/war.bak/reload4j/reload4j-1.2.18.0/org/apache/log4j","contains log4j-1.2.18.0","1.2.18.0","log4j"
"2022-01-24 10:59:36","1.22pre-20220123","10.0.0.1","mylinux","Linux","5.4.0-58-generic","x86_64","Package","OLDSAFE","/home/hynek/war.bak/reload4j/reload4j-1.2.18.2.jar","contains reload4j-1.2.18.2","1.2.18.2","reload4j"
"2022-01-24 10:59:36","1.22pre-20220123","10.0.0.1","mylinux","Linux","5.4.0-58-generic","x86_64","Package","OLDSAFE","/home/hynek/war.bak/reload4j/reload4j-1.2.18.1.jar","contains reload4j-1.2.18.1","1.2.18.1","reload4j"
"2022-01-24 10:59:36","1.22pre-20220123","10.0.0.1","mylinux","Linux","5.4.0-58-generic","x86_64","Package","CVE-2019-17571 (9.8), CVE-2021-4104 (7.5), CVE-2022-23302 (6.6), CVE-2022-23305 (8.1), CVE-2022-23307 (8.1)","/home/hynek/war.bak/reload4j/log4j-1.2.17.jar","contains log4j-1.2.17","1.2.17","log4j"
"2022-01-24 10:59:36","1.22pre-20220123","10.0.0.1","mylinux","Linux","5.4.0-58-generic","x86_64","Package","CVE-2022-23302 (6.6), CVE-2022-23305 (8.1), CVE-2022-23307 (8.1)","/home/hynek/war.bak/reload4j/reload4j-1.2.18.0.jar","contains log4j-1.2.18.0","1.2.18.0","log4j"
| 감지 | CVE | CVSSv3 | 심각도 | Java | 취약 시작 | 취약 범위 | 수정 버전 | 라이브러리 |
|---|
| 예 | CVE-2021-44228 | 10.0 | 치명적 | 8 | 2.0-beta9 | 2.14.1 | 2.15.0 | log4jv2 |
| 예 | CVE-2017-5645 | 9.8 | 치명적 | 7 | 2.0-alpha1 | 2.8.1 | 2.8.2 | log4jv2 |
| 예 | CVE-2019-17571 | 9.8 | 치명적 | 1.2.0 | 1.2.17 | 수정 없음 | log4jv1 | |
| 예 | CVE-2021-45046 | 9.0 | 치명적 | 7/8 | 2.0-beta9 | 2.15.0 (2.12.2 제외) | 2.12.2/2.16.0 | log4jv2 |
| 예 | CVE-2022-23305 | 9.8 | 치명적 | 1.2.0 | 1.2.17 | 수정 없음 / 1.2.18.1 | log4jv1, reload4j | |
| 예 | CVE-2022-23307 | 9.8 | 치명적 | 1.2.0 | 1.2.17 | 수정 없음 / 1.2.18.1 | log4jv1, reload4j | |
| 예 | CVE-2022-23302 | 8.8 | 높음 | 1.0 | 1.2.17 | 수정 없음 / 1.2.18.1 | log4jv1, reload4j | |
| 예 | CVE-2021-4104 | 7.5 | 높음 | - | 1.0 | 1.2.17 | 수정 없음 | log4jv1 |
| 예 | CVE-2021-44832 | 6.6 | 중간 | 6/7/8 | 2.0-alpha7 | 2.17.0 (2.3.2/2.12.4 제외) | 2.3.2/2.12.4/2.17.1 | log4jv2 |
| - | CVE-2021-42550 | 6.6 | 중간 | - | 1.0 | 1.2.7 | 1.2.8 | logback |
| 예 | CVE-2021-45105 | 5.9 | 중간 | 6/7/8 | 2.0-beta9 | 2.16.0 (2.12.3 제외) | 2.3.1/2.12.3/2.17.0 | log4jv2 |
| - | CVE-2020-9488 | 3.7 | 낮음 | 7/8 | 2.0-alpha1 | 2.13.1 | 2.12.3/2.13.2 | log4jv2 |