Skip to content

Commit 4d8d2b8

Browse files
committed
Ignore WinRAR files without error message, Resolve hostname using /etc/hosname. v2.1.3
1 parent f14a7bf commit 4d8d2b8

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
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 (log4j 2.15.0) and CVE-2021-4104 (log4j 1.x) vulnerabilities.
44

55
### Download
6-
* [log4j2-scan 2.1.2 (Windows x64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.1.2/logpresso-log4j2-scan-2.1.2-win64.7z)
6+
* [log4j2-scan 2.1.3 (Windows x64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.1.3/logpresso-log4j2-scan-2.1.3-win64.7z)
77
* If you get `VCRUNTIME140.dll not found` error, install [Visual C++ Redistributable](https://docs.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170).
88
* If native executable doesn't work, use the JAR instead. 32bit is not supported.
9-
* [log4j2-scan 2.1.2 (Linux x64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.1.2/logpresso-log4j2-scan-2.1.2-linux.tar.gz)
9+
* [log4j2-scan 2.1.3 (Linux x64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.1.3/logpresso-log4j2-scan-2.1.3-linux.tar.gz)
1010
* If native executable doesn't work, use the JAR instead. 32bit is not supported.
11-
* [log4j2-scan 2.1.2 (Any OS, 20KB)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.1.2/logpresso-log4j2-scan-2.1.2.jar)
11+
* [log4j2-scan 2.1.3 (Any OS, 20KB)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.1.3/logpresso-log4j2-scan-2.1.3.jar)
1212

1313
### Build
1414
* [How to build Native Image](https://github.com/logpresso/CVE-2021-44228-Scanner/wiki/FAQ#how-to-build-native-image)
@@ -18,7 +18,7 @@ Just run log4j2-scan.exe or log4j2-scan with target directory path.
1818

1919
Usage
2020
```
21-
Logpresso CVE-2021-44228 Vulnerability Scanner 2.1.2 (2021-12-17)
21+
Logpresso CVE-2021-44228 Vulnerability Scanner 2.1.3 (2021-12-17)
2222
Usage: log4j2-scan [--fix] target_path1 target_path2
2323
2424
--fix
@@ -71,7 +71,7 @@ On Linux
7171
```
7272
On UNIX (AIX, Solaris, and so on)
7373
```
74-
java -jar logpresso-log4j2-scan-2.1.2.jar [--fix] target_path
74+
java -jar logpresso-log4j2-scan-2.1.3.jar [--fix] target_path
7575
```
7676

7777
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>2.1.2</version>
9+
<version>2.1.3</version>
1010
<packaging>jar</packaging>
1111
<name>Logpresso Log4j2 Scanner</name>
1212

src/main/java/com/logpresso/scanner/Log4j2Scanner.java

+20-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import java.util.zip.ZipOutputStream;
4242

4343
public class Log4j2Scanner {
44-
private static final String BANNER = "Logpresso CVE-2021-44228 Vulnerability Scanner 2.1.2 (2021-12-17)";
44+
private static final String BANNER = "Logpresso CVE-2021-44228 Vulnerability Scanner 2.1.3 (2021-12-17)";
4545

4646
public enum Status {
4747
NOT_VULNERABLE, MITIGATED, POTENTIALLY_VULNERABLE, VULNERABLE;
@@ -1316,12 +1316,29 @@ private void ensureClose(ZipFile zipFile) {
13161316
}
13171317
}
13181318

1319-
private static String getHostname() {
1319+
private String getHostname() {
13201320
// Try to fetch hostname without DNS resolving for closed network
13211321
if (isWindows) {
13221322
return System.getenv("COMPUTERNAME");
13231323
} else {
1324-
return System.getenv("HOSTNAME");
1324+
String hostname = System.getenv("HOSTNAME");
1325+
if (hostname != null && !hostname.trim().isEmpty())
1326+
return hostname;
1327+
1328+
// try /etc/hostname
1329+
File f = new File("/etc/hostname");
1330+
if (!f.exists() || !f.canRead())
1331+
return null;
1332+
1333+
BufferedReader br = null;
1334+
try {
1335+
br = new BufferedReader(new InputStreamReader(new FileInputStream(f)));
1336+
return br.readLine();
1337+
} catch (IOException e) {
1338+
return null;
1339+
} finally {
1340+
ensureClose(br);
1341+
}
13251342
}
13261343
}
13271344
}

0 commit comments

Comments
 (0)