-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcryptor.java
More file actions
60 lines (49 loc) · 1.98 KB
/
cryptor.java
File metadata and controls
60 lines (49 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package exe;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class Exe {
public static void main(String[] args) throws IOException, NoSuchAlgorithmException {
File inputFile = new File("native_loader.exe");
File outputFile = new File("VL.exe");
File hashFile = new File("bin1.bin");
byte[] originalBytes = Files.readAllBytes(inputFile.toPath());
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
outputStream.write(originalBytes);
byte[] signedBytes = outputStream.toByteArray();
Files.write(outputFile.toPath(), signedBytes);
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(signedBytes);
String hashHex = bytesToHexXOR(hash, "KASDLKASLDKASLDZX$(*#@$)");
Files.writeString(hashFile.toPath(), hashHex);
}
public static String bytesToHex(byte[] bytes) {
StringBuilder sb = new StringBuilder();
for (byte b : bytes) {
sb.append(String.format("%02X", b));
}
return sb.toString();
}
private static String bytesToHexXOR(byte[] data, String keyString) {
byte[] keyBytes = keyString.getBytes();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < data.length; i++) {
byte xored = (byte) (data[i] ^ keyBytes[i % keyBytes.length]);
sb.append(String.format("%02X", xored));
}
return sb.toString();
}
private static byte[] hexToBytesXOR(String hex, String keyString) {
byte[] keyBytes = keyString.getBytes();
int len = hex.length();
byte[] result = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
int val = Integer.parseInt(hex.substring(i, i + 2), 16);
result[i / 2] = (byte) (val ^ keyBytes[(i / 2) % keyBytes.length]);
}
return result;
}
}