From 67911c8e05991cf02d447d7636bcc4f1b91cd119 Mon Sep 17 00:00:00 2001 From: Jess Date: Wed, 26 Jun 2024 03:13:22 +0100 Subject: [PATCH] LOL ok now that should be it --- .../java/de/com/baseband/login/Hasher.java | 144 ++++++++++++++++++ .../de/com/baseband/login/LoginGenerator.java | 3 +- .../java/de/com/baseband/launcher/Loader.java | 2 +- 3 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 Installer/src/main/java/de/com/baseband/login/Hasher.java diff --git a/Installer/src/main/java/de/com/baseband/login/Hasher.java b/Installer/src/main/java/de/com/baseband/login/Hasher.java new file mode 100644 index 0000000..7e707d6 --- /dev/null +++ b/Installer/src/main/java/de/com/baseband/login/Hasher.java @@ -0,0 +1,144 @@ +package de.com.baseband.login; + +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class Hasher { + public static final String TYPE_SHA256HEX = "sha256hex"; + public static final String TYPE_SHA512HEX = "sha512hex"; + public static final String TYPE_INT = "int"; + @SuppressWarnings("CanBeFinal") + public static String LETTERS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"§$%&/()=?#_-.:,;µ<>|^°{[]}\\ "; + + public static String sha256hex(String toHash) { + MessageDigest digest; + try { + digest = MessageDigest.getInstance("SHA-256"); + } + catch (NoSuchAlgorithmException e) { + throw new RuntimeException("Impossible condition reached"); + } + return hash(toHash, digest); + } + + public static String sha512hex(String toHash) { + MessageDigest digest; + try { + digest = MessageDigest.getInstance("SHA-512"); + } + catch (NoSuchAlgorithmException e) { + throw new RuntimeException("Impossible condition reached"); + } + return hash(toHash, digest); + } + + private static String hash(String toHash, MessageDigest digest) { + byte[] hash = digest.digest( + toHash.getBytes(StandardCharsets.UTF_8)); + StringBuilder hexString = new StringBuilder(); + for (byte b : hash) { + String hex = Integer.toHexString(0xff & b); + if (hex.length() == 1) hexString.append('0'); + hexString.append(hex); + } + return hexString.toString(); + } + + public static String bruteforce(String type, String hash, int beginAt) { + switch (type) { + case TYPE_SHA256HEX: + return bf_sha256hex(hash, beginAt); + case TYPE_SHA512HEX: + return bf_sha512hex(hash, beginAt); + case TYPE_INT: + return bf_int(Integer.parseInt(hash), beginAt); + } + return null; + } + + private static String bf_int(int hash, int beginAt) { + for (int length = beginAt; true; length++) { + String s; + if ((s = bf_int_tryGenChar("", 0, length, hash)) != null) { + if (s.hashCode() == hash) + return s; + } + } + } + + private static String bf_int_tryGenChar(String str, int pos, int length, int hash) { + if (length == 0) { + if (str.hashCode() == hash) + return str; + } + else { + if (pos != 0) { + pos = 0; + } + for (int i = pos; i < LETTERS.toCharArray().length; i++) { + String s; + if ((s = bf_int_tryGenChar(str + LETTERS.charAt(i), i, length - 1, hash)) != null) { + return s; + } + } + } + return null; + } + + private static String bf_sha256hex(String hash, int beginAt) { + for (int length = beginAt; true; length++) { + String s; + if ((s = bf_sha256hex_tryGenChar("", 0, length, hash)) != null) { + return s; + } + } + } + + private static String bf_sha256hex_tryGenChar(String str, int pos, int length, String hash) { + if (length == 0) { + if (sha256hex(str).equals(hash)) + return str; + } + else { + if (pos != 0) { + pos = 0; + } + for (int i = pos; i < LETTERS.toCharArray().length; i++) { + String s; + if ((s = bf_sha256hex_tryGenChar(str + LETTERS.charAt(i), i, length - 1, hash)) != null) { + return s; + } + } + } + return null; + } + + private static String bf_sha512hex(String hash, int beginAt) { + for (int length = beginAt; true; length++) { + String s; + if ((s = bf_sha512hex_tryGenChar("", 0, length, hash)) != null) { + return s; + } + } + } + + private static String bf_sha512hex_tryGenChar(String str, int pos, int length, String hash) { + if (length == 0) { + if (sha512hex(str).equals(hash)) + return str; + } + else { + if (pos != 0) { + pos = 0; + } + for (int i = pos; i < LETTERS.toCharArray().length; i++) { + String s; + if ((s = bf_sha512hex_tryGenChar(str + LETTERS.charAt(i), i, length - 1, hash)) != null) { + return s; + } + } + } + return null; + } +} \ No newline at end of file diff --git a/Installer/src/main/java/de/com/baseband/login/LoginGenerator.java b/Installer/src/main/java/de/com/baseband/login/LoginGenerator.java index 2e4f413..d050922 100644 --- a/Installer/src/main/java/de/com/baseband/login/LoginGenerator.java +++ b/Installer/src/main/java/de/com/baseband/login/LoginGenerator.java @@ -23,9 +23,10 @@ public class LoginGenerator { Key k = new Key(key); FileOutputStream fos = new FileOutputStream("baseband.login"); PrintWriter writer = new PrintWriter(fos); + writer.println(k.encryptString(Hasher.sha512hex(key))); writer.println(k.encryptString(username)); writer.println(k.encryptString(password)); - writer.println(k.encryptString("GENERATED USING " + LoginGenerator.class.getName() + "!!")); + writer.println(k.encryptString("dev login file! if you find this on an end-user pc something has gone terribly wrong.")); //dumb as rocks writer.flush(); fos.flush(); diff --git a/Loader/src/main/java/de/com/baseband/launcher/Loader.java b/Loader/src/main/java/de/com/baseband/launcher/Loader.java index bdea4ef..98636e6 100644 --- a/Loader/src/main/java/de/com/baseband/launcher/Loader.java +++ b/Loader/src/main/java/de/com/baseband/launcher/Loader.java @@ -319,7 +319,7 @@ public class Loader implements Util { FileReader fileReader = new FileReader(file); BufferedReader reader = new BufferedReader(fileReader); - if(!key.decryptString(reader.readLine()).equals("baseband_login")) { + if(!key.decryptString(reader.readLine()).equals(key)) { LOGGER.fatal("Login Data Checksum Not Matching!"); LOGGER.fatal("This usually only happens when your HWID changes,"); LOGGER.fatal("Rerun the Installer.");