Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b392edb

Browse files
Introduced protections against predictable RNG abuse (#7)
Co-authored-by: pixeebot[bot] <104101892+pixeebot[bot]@users.noreply.github.com>
1 parent e83877f commit b392edb

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

Ghidra/Features/BytePatterns/src/main/java/ghidra/bytepatterns/bitcluster/FacePatterns.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.io.IOException;
1919
import java.io.Writer;
20+
import java.security.SecureRandom;
2021
import java.util.*;
2122

2223
public class FacePatterns {
@@ -138,7 +139,7 @@ public void outputTopPatterns(Writer writer) throws IOException {
138139
//Samples a list of byte sequences.
139140
static private ArrayList<byte[]> sample(ArrayList<byte[]> li, int numOfSamples) {
140141
ArrayList<byte[]> result = new ArrayList<byte[]>();
141-
Random rand = new Random();
142+
Random rand = new SecureRandom();
142143
for (int s = 0; s < numOfSamples; s++) {
143144
int r = rand.nextInt(li.size());
144145
result.add(li.get(r));

Ghidra/Features/CodeCompare/src/main/java/ghidra/feature/vt/api/correlator/address/DebugUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package ghidra.feature.vt.api.correlator.address;
1717

1818
import java.awt.Color;
19+
import java.security.SecureRandom;
1920
import java.util.*;
2021
import java.util.Map.Entry;
2122

@@ -163,7 +164,7 @@ private static IntRangeMap getColorRangeMap(Program program, boolean create) {
163164
return map;
164165
}
165166

166-
private static Random RAND = new Random();
167+
private static Random RAND = new SecureRandom();
167168

168169
private static Color pickColor(CorrelationContainer container) {
169170
float saturation;

Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/dex/DexToSmaliFileSystem.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.io.File;
1919
import java.io.IOException;
2020
import java.nio.file.AccessMode;
21+
import java.security.SecureRandom;
2122
import java.util.*;
2223

2324
import org.apache.commons.io.FileUtils;
@@ -89,7 +90,7 @@ public boolean isValid(TaskMonitor monitor) throws IOException {
8990
public void open(TaskMonitor monitor) throws IOException, CryptoException, CancelledException {
9091
monitor.setMessage("Converting DEX to SMALI...");
9192

92-
int rand = new Random().nextInt() & 0xffff;
93+
int rand = new SecureRandom().nextInt() & 0xffff;
9394
File outputDir = new File(Application.getUserTempDirectory(), "ghidra_file_system_" + rand);
9495

9596
DexFile dexFile =

Ghidra/Framework/DB/src/main/java/db/buffers/LocalBufferFile.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package db.buffers;
1717

1818
import java.io.*;
19+
import java.security.SecureRandom;
1920
import java.util.*;
2021

2122
import ghidra.framework.Application;
@@ -45,7 +46,7 @@ public class LocalBufferFile implements BufferFile {
4546
// ?? Should be changed !!
4647
private static final int MINIMUM_BLOCK_SIZE = 128;
4748

48-
private static final Random random = new Random();
49+
private static final Random random = new SecureRandom();
4950

5051
/**
5152
* Current file header format version number.

0 commit comments

Comments
 (0)