
log4j2-scan 是一款用于 CVE-2021-44228 漏洞扫描与缓解修复的单一二进制命令行工具。它还支持嵌套 JAR 文件扫描与修复。
直接运行 log4j2-scan.exe 或 log4j2-scan,并指定目标目录路径。
用法
Logpresso CVE-2021-44228 Vulnerability Scanner 1.3.1 (2021-12-15)
Usage: log4j2-scan [--fix] target_path
--fix
Backup original file and remove JndiLookup.class from JAR recursively.
--force-fix
Do not prompt confirmation. Don't use this option unless you know what you are doing.
--trace
Print all directories and files while scanning.
--exclude [path_prefix]
Exclude specified paths. You can specify multiple --exclude [path_prefix] pairs
--exclude-config [file_path]
Specify exclude path list in text file. Paths should be separated by new line. Prepend # for comment.
--all-drives
Scan all drives on Windows
--drives c,d
Scan specified drives on Windows. Spaces are not allowed here.
在 Windows 上
log4j2-scan [--fix] target_path
在 Linux 上
./log4j2-scan [--fix] target_path
在 UNIX(AIX、Solaris 等)上
java -jar logpresso-log4j2-scan-1.3.1.jar [--fix] target_path
如果添加 --fix 选项,该程序会将存在漏洞的原始 JAR 文件复制为 .bak 文件,并创建不含 org/apache/logging/log4j/core/lookup/JndiLookup.class 条目的新 JAR 文件。在大多数环境中,不会使用 JNDI 查找功能。但是,您必须自行承担使用此选项的风险。在应用补丁之前,需要关闭所有正在运行的 JVM 进程。修复完成后,再启动受影响的 JVM 进程。
如果要自动化修补任务,请使用 --force-fix 选项。使用此选项后,程序将不再提示确认。
如果 JAR 文件中已移除 org/apache/logging/log4j/core/lookup/JndiLookup.class 条目,将显示 (mitigated) 标记。
如果添加 --trace 选项,该程序将打印所有访问过的目录和文件。请仅将此选项用于调试。
在 Windows 上:
CMD> log4j2-scan.exe D:\tmp
[*] Found CVE-2021-44228 vulnerability in D:\tmp\elasticsearch-7.16.0\bin\elasticsearch-sql-cli-7.16.0.jar, log4j 2.11.1
[*] Found CVE-2021-44228 vulnerability in D:\tmp\elasticsearch-7.16.0\lib\log4j-core-2.11.1.jar, log4j 2.11.1
[*] Found CVE-2021-44228 vulnerability in D:\tmp\flink-1.14.0\lib\log4j-core-2.14.1.jar, log4j 2.14.1
[*] Found CVE-2021-44228 vulnerability in D:\tmp\logstash-7.16.0\logstash-core\lib\jars\log4j-core-2.14.0.jar, log4j 2.14.0
[*] Found CVE-2021-44228 vulnerability in D:\tmp\logstash-7.16.0\vendor\bundle\jruby\2.5.0\gems\logstash-input-tcp-6.2.1-java\vendor\jar-dependencies\org\logstash\inputs\logstash-input-tcp\6.2.1\logstash-input-tcp-6.2.1.jar, log4j 2.9.1
[*] Found CVE-2021-44228 vulnerability in D:\tmp\solr-7.7.3\solr-7.7.3\contrib\prometheus-exporter\lib\log4j-core-2.11.0.jar, log4j 2.11.0
[*] Found CVE-2021-44228 vulnerability in D:\tmp\solr-7.7.3\solr-7.7.3\server\lib\ext\log4j-core-2.11.0.jar, log4j 2.11.0
[*] Found CVE-2021-44228 vulnerability in D:\tmp\solr-8.11.0\contrib\prometheus-exporter\lib\log4j-core-2.14.1.jar, log4j 2.14.1
[*] Found CVE-2021-44228 vulnerability in D:\tmp\solr-8.11.0\server\lib\ext\log4j-core-2.14.1.jar, log4j 2.14.1
Scanned 5047 directories and 26251 files
Found 9 vulnerable files
Completed in 0.42 seconds
分 5 步运行:
META-INF/maven/org.apache.logging.log4j/log4j-core/pom.properties 条目。如果您有任何问题或疑问,请在本存储库中创建 issue。