Skip to content

Commit 41102e5

Browse files
committed
Support deep nested JAR and patch for spring boot JAR, Added --silent option.
1 parent 7fc29c3 commit 41102e5

File tree

4 files changed

+252
-62
lines changed

4 files changed

+252
-62
lines changed

README.md

+17-15
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,42 @@
33
log4j2-scan is a single binary command-line tool for CVE-2021-44228 vulnerability scanning and mitigation patch. It also supports nested JAR file scanning and patch. It also detects CVE-2021-45046 vulnerability (log4j 2.15.0).
44

55
### Download
6-
* [log4j2-scan 1.4.0 (Windows x64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v1.4.0/logpresso-log4j2-scan-1.4.0-win64.7z)
6+
* [log4j2-scan 1.5.0 (Windows x64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v1.5.0/logpresso-log4j2-scan-1.5.0-win64.7z)
77
* If native executable doesn't work, use the JAR instead. 32bit is not supported.
8-
* [log4j2-scan 1.4.0 (Linux x64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v1.4.0/logpresso-log4j2-scan-1.4.0-linux.tar.gz)
8+
* [log4j2-scan 1.5.0 (Linux x64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v1.5.0/logpresso-log4j2-scan-1.5.0-linux.tar.gz)
99
* If native executable doesn't work, use the JAR instead. 32bit is not supported.
10-
* [log4j2-scan 1.4.0 (Any OS, 10KB)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v1.4.0/logpresso-log4j2-scan-1.4.0.jar)
10+
* [log4j2-scan 1.5.0 (Any OS, 10KB)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v1.5.0/logpresso-log4j2-scan-1.5.0.jar)
1111

1212
### How to use
1313
Just run log4j2-scan.exe or log4j2-scan with target directory path.
1414

1515
Usage
1616
```
17-
Logpresso CVE-2021-44228 Vulnerability Scanner 1.4.0 (2021-12-15)
17+
Logpresso CVE-2021-44228 Vulnerability Scanner 1.5.0 (2021-12-15)
1818
Usage: log4j2-scan [--fix] target_path
1919
2020
--fix
21-
Backup original file and remove JndiLookup.class from JAR recursively.
21+
Backup original file and remove JndiLookup.class from JAR recursively.
2222
--force-fix
23-
Do not prompt confirmation. Don't use this option unless you know what you are doing.
23+
Do not prompt confirmation. Don't use this option unless you know what you are doing.
2424
--debug
25-
Print exception stacktrace for debugging.
25+
Print exception stacktrace for debugging.
2626
--trace
27-
Print all directories and files while scanning.
27+
Print all directories and files while scanning.
28+
--silent
29+
Do not print anything until scan is completed.
2830
--scan-zip
29-
Scan also .zip extension files. This option may slow down scanning.
31+
Scan also .zip extension files. This option may slow down scanning.
3032
--no-symlink
31-
Do not detect symlink as vulnerable file.
33+
Do not detect symlink as vulnerable file.
3234
--exclude [path_prefix]
33-
Exclude specified paths. You can specify multiple --exclude [path_prefix] pairs
35+
Exclude specified paths. You can specify multiple --exclude [path_prefix] pairs
3436
--exclude-config [file_path]
35-
Specify exclude path list in text file. Paths should be separated by new line. Prepend # for comment.
37+
Specify exclude path list in text file. Paths should be separated by new line. Prepend # for comment.
3638
--all-drives
37-
Scan all drives on Windows
39+
Scan all drives on Windows
3840
--drives c,d
39-
Scan specified drives on Windows. Spaces are not allowed here.
41+
Scan specified drives on Windows. Spaces are not allowed here.
4042
```
4143

4244
On Windows
@@ -49,7 +51,7 @@ On Linux
4951
```
5052
On UNIX (AIX, Solaris, and so on)
5153
```
52-
java -jar logpresso-log4j2-scan-1.4.0.jar [--fix] target_path
54+
java -jar logpresso-log4j2-scan-1.5.0.jar [--fix] target_path
5355
```
5456

5557
If you add `--fix` option, this program will copy vulnerable original JAR file to .bak file, and create new JAR file without `org/apache/logging/log4j/core/lookup/JndiLookup.class` entry. In most environments, JNDI lookup feature will not be used. However, you must use this option at your own risk. It is necessary to shutdown any running JVM process before applying patch. Start affected JVM process after fix.

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<modelVersion>4.0.0</modelVersion>
77
<groupId>com.logpresso</groupId>
88
<artifactId>log4j2-scanner</artifactId>
9-
<version>1.4.0</version>
9+
<version>1.5.0</version>
1010
<packaging>jar</packaging>
1111
<name>Logpresso Log4j2 Scanner</name>
1212

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package com.logpresso.scanner;
2+
3+
import java.io.IOException;
4+
import java.io.InputStream;
5+
6+
// don't close underlying InputStream on close
7+
public class DummyInputStream extends InputStream {
8+
9+
private InputStream is;
10+
11+
public DummyInputStream(InputStream is) {
12+
this.is = is;
13+
}
14+
15+
@Override
16+
public int read() throws IOException {
17+
return is.read();
18+
}
19+
20+
@Override
21+
public int read(byte[] b) throws IOException {
22+
return is.read(b);
23+
}
24+
25+
@Override
26+
public int read(byte[] b, int off, int len) throws IOException {
27+
return is.read(b, off, len);
28+
}
29+
30+
@Override
31+
public long skip(long n) throws IOException {
32+
return is.skip(n);
33+
}
34+
35+
@Override
36+
public int available() throws IOException {
37+
return is.available();
38+
}
39+
40+
@Override
41+
public void close() throws IOException {
42+
// ignore intentionally
43+
}
44+
45+
@Override
46+
public synchronized void mark(int readlimit) {
47+
is.mark(readlimit);
48+
}
49+
50+
@Override
51+
public synchronized void reset() throws IOException {
52+
is.reset();
53+
}
54+
55+
@Override
56+
public boolean markSupported() {
57+
return is.markSupported();
58+
}
59+
60+
@Override
61+
public int hashCode() {
62+
return is.hashCode();
63+
}
64+
65+
@Override
66+
public boolean equals(Object obj) {
67+
return is.equals(obj);
68+
}
69+
70+
@Override
71+
public String toString() {
72+
return is.toString();
73+
}
74+
}

0 commit comments

Comments
 (0)