Skip to content

Commit 12a1e83

Browse files
committed
Fix the java version check, remove deprecated getStackTraceElement, update README
1 parent 3877668 commit 12a1e83

File tree

4 files changed

+14
-38
lines changed

4 files changed

+14
-38
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 2.0.1 (27/10/2022)
4+
### Changed
5+
- Fix the java version check
6+
- Remove deprecated usage of getStackTraceElement in LoggingUtils.java
7+
38
## 2.0.0 (25/10/2022)
49
### Added
510
- Print execution time

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SIMTester
22

3-
SIMtester assess SIM card security in two dimensions:
3+
SIMTester assess SIM card security in two dimensions:
44

55
- **Cryptanalytic attack surface**: Collect cryptographic signatures and encryptions of known plaintexts
66
- **Application attack surface**: Generate a list of all application identifiers (TAR) and find "unprotected" (MSL=0) applications
@@ -19,7 +19,7 @@ SIMtester assess SIM card security in two dimensions:
1919
java -jar SIMTester.jar <arguments>
2020
```
2121

22-
In case Java has problems to find the libpcsclite shared object, just submit the path manually:
22+
In case Java has problems to find the libpcsclite shared object, just submit the path manually (adjust it to your system):
2323

2424
```bash
2525
java -Dsun.security.smartcardio.library=/lib/x86_64-linux-gnu/libpcsclite.so.1 -jar SIMTester.jar <arguments>

SIMLibrary/src/de/srlabs/simlib/ChannelHandler.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,9 @@ public static void initReset() {
4444

4545
version = m.group(1);
4646

47-
if (m.groupCount() == 1) { // got version only
48-
patchversion = 0;
49-
} else { // got version and patch
50-
patchversion = Integer.valueOf(m.group(2));
51-
}
47+
patchversion = m.group(2) == null ? 0: Integer.parseInt(m.group(2));
5248

53-
trueCardReset = (Helpers.versionCompare(version, "1.8.0") >= 0 && patchversion >= 20); // Java 1.8.0_20 and above have the correct behavior by default
49+
trueCardReset = (Helpers.versionCompare(version, "1.8.0") > 0 || (Helpers.versionCompare(version, "1.8.0") == 0 && patchversion >= 20)); // Java 1.8.0_20 and above have the correct behavior by default
5450
} else {
5551
System.err.println("Unable to detect Java version correctly, setting invertCardReset to TRUE and trying to continue, do not be surprised if card resets won't work!");
5652
System.setProperty("sun.security.smartcardio.invertCardReset", "true");
Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,18 @@
11
package de.srlabs.simlib;
22

3-
import java.lang.reflect.InvocationTargetException;
4-
import java.lang.reflect.Method;
5-
63
public class LoggingUtils {
74

8-
private static Method m;
9-
10-
static {
11-
try {
12-
m = Throwable.class.getDeclaredMethod("getStackTraceElement", int.class);
13-
m.setAccessible(true);
14-
} catch (NoSuchMethodException e) { // this should never happen really
15-
e.printStackTrace(System.err);
16-
}
17-
}
18-
195
public static String formatDebugMessage(String message) {
20-
String result = "[" + getClassName(1) + ", " + getMethodName(1) + "] " + message;
21-
return result;
6+
return "[" + getClassName(1) + ", " + getMethodName(1) + "] " + message;
227
}
238

249
private static String getMethodName(final int depth) {
25-
try {
26-
StackTraceElement element = (StackTraceElement) m.invoke(new Throwable(), depth + 1);
27-
return element.getMethodName();
28-
} catch (IllegalAccessException | InvocationTargetException e) {
29-
e.printStackTrace(System.err);
30-
return null;
31-
}
10+
StackTraceElement element = (new Throwable()).getStackTrace()[depth+ 1];
11+
return element.getMethodName();
3212
}
3313

3414
private static String getClassName(final int depth) {
35-
try {
36-
StackTraceElement element = (StackTraceElement) m.invoke(new Throwable(), depth + 1);
37-
return element.getClassName();
38-
} catch (IllegalAccessException | InvocationTargetException e) {
39-
e.printStackTrace(System.err);
40-
return null;
41-
}
15+
StackTraceElement element = (new Throwable()).getStackTrace()[depth+ 1];
16+
return element.getClassName();
4217
}
4318
}

0 commit comments

Comments
 (0)