From f6a09ec4953cae2ca7b37d9c3dde977b66904fb0 Mon Sep 17 00:00:00 2001 From: Jess Date: Mon, 9 Oct 2023 07:02:56 +0100 Subject: [PATCH] moar --- .../main/java/com/baseband/client/BaseBand.java | 6 +++--- .../java/org/baseband/launcher/launch/Loader.java | 6 +++--- .../src/main/java/dev/baseband/server/Main.java | 4 ++-- .../dev/baseband/server/socket/ClientHandler.java | 15 ++++++++------- .../socket/{Socket.java => SocketHandler.java} | 8 +++++--- 5 files changed, 21 insertions(+), 18 deletions(-) rename Server/src/main/java/dev/baseband/server/socket/{Socket.java => SocketHandler.java} (96%) diff --git a/Client/src/main/java/com/baseband/client/BaseBand.java b/Client/src/main/java/com/baseband/client/BaseBand.java index c5c7e4e..7bb9ebf 100644 --- a/Client/src/main/java/com/baseband/client/BaseBand.java +++ b/Client/src/main/java/com/baseband/client/BaseBand.java @@ -34,11 +34,11 @@ import java.util.function.Consumer; public class BaseBand { public static int majorVersion = 1; - public static int buildNumber = 466; - public static String hash = "1d2648358af42270"; + public static int buildNumber = 468; + public static String hash = "2714cbd106927da2"; public static String name = "BaseBand"; - public long timeOfCompile = 1696820768856L; + public long timeOfCompile = 1696830524662L; public CommandManager commandRegistry; public EventBus eventBus; public ArrayList modules = new ArrayList<>(); diff --git a/Loader/src/main/java/org/baseband/launcher/launch/Loader.java b/Loader/src/main/java/org/baseband/launcher/launch/Loader.java index 2629a22..26b5803 100644 --- a/Loader/src/main/java/org/baseband/launcher/launch/Loader.java +++ b/Loader/src/main/java/org/baseband/launcher/launch/Loader.java @@ -94,8 +94,8 @@ public class Loader { resourceKey = new DataKeeper<>(dynamicPermissionManager, defaultStrictness, new Key()); try { - Socket socket = new Socket("127.0.0.1", 31212); -// Socket socket = new Socket("88.208.243.108", 31212); + // Socket socket = new Socket("127.0.0.1", 31212); + Socket socket = new Socket("88.208.243.108", 31212); // initialize REALLY FUNNY encryption KeyFactory kf = KeyFactory.getInstance("RSA"); @@ -242,7 +242,7 @@ public class Loader { } case -9: { - message("Update", "The Loader has been updated, " + + message("Update", "Re-run the installer. " + "\nPlease re-run the installer.", JOptionPane.ERROR_MESSAGE, true); break; } diff --git a/Server/src/main/java/dev/baseband/server/Main.java b/Server/src/main/java/dev/baseband/server/Main.java index 2ada077..6e9a847 100644 --- a/Server/src/main/java/dev/baseband/server/Main.java +++ b/Server/src/main/java/dev/baseband/server/Main.java @@ -1,7 +1,7 @@ package dev.baseband.server; import dev.baseband.server.socket.Bot; -import dev.baseband.server.socket.Socket; +import dev.baseband.server.socket.SocketHandler; import java.io.IOException; import java.security.NoSuchAlgorithmException; @@ -10,6 +10,6 @@ import java.security.spec.InvalidKeySpecException; public class Main { public static void main(String[] args) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException { Bot.start(); - Socket.launch(args); + SocketHandler.launch(args); } } diff --git a/Server/src/main/java/dev/baseband/server/socket/ClientHandler.java b/Server/src/main/java/dev/baseband/server/socket/ClientHandler.java index ef0b532..06b670e 100644 --- a/Server/src/main/java/dev/baseband/server/socket/ClientHandler.java +++ b/Server/src/main/java/dev/baseband/server/socket/ClientHandler.java @@ -11,14 +11,15 @@ import java.io.BufferedReader; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.InputStreamReader; +import java.net.Socket; import java.net.URL; import java.security.MessageDigest; import java.util.Base64; public class ClientHandler extends Thread { - final java.net.Socket client; + final Socket client; - public ClientHandler(java.net.Socket client) { + public ClientHandler(Socket client) { this.client = client; } @@ -32,7 +33,7 @@ public class ClientHandler extends Thread { DataInputStream dis = new DataInputStream(client.getInputStream()); Cipher decrypt = Cipher.getInstance("RSA"); - decrypt.init(Cipher.DECRYPT_MODE, Socket.key.getPrivate()); + decrypt.init(Cipher.DECRYPT_MODE, SocketHandler.key.getPrivate()); byte[] aesBytes = new byte[dis.readInt()]; dis.readFully(aesBytes); @@ -141,7 +142,7 @@ public class ClientHandler extends Thread { System.out.println("Auth succeeded, Sending loader."); dos.writeInt(result); - byte[] encryptedBytes = key.encryptByte(aesE.doFinal(Socket.loaderFileData)); + byte[] encryptedBytes = key.encryptByte(aesE.doFinal(SocketHandler.loaderFileData)); dos.writeInt(encryptedBytes.length); dos.write(encryptedBytes, 0, encryptedBytes.length); dos.flush(); @@ -162,7 +163,7 @@ public class ClientHandler extends Thread { return; } - if(!Socket.currentJarHash.equals(jarHash) && !Socket.pastJarHashes.contains(jarHash) && result >= 0) { + if(!SocketHandler.currentJarHash.equals(jarHash) && !SocketHandler.pastJarHashes.contains(jarHash) && result >= 0) { dos.writeInt(-8); System.out.println("JAR HASH MISMATCH, banning."); UserManager.setBanned(username, true); @@ -171,7 +172,7 @@ public class ClientHandler extends Thread { return; } - if(!Socket.currentJarHash.equals(jarHash) && Socket.pastJarHashes.contains(jarHash) && result >= 0) { + if(!SocketHandler.currentJarHash.equals(jarHash) && SocketHandler.pastJarHashes.contains(jarHash) && result >= 0) { dos.writeInt(-8); System.out.println("JAR HASH MISMATCH, denying."); System.out.println("But it matches an old version, so tell them to redownload it"); @@ -185,7 +186,7 @@ public class ClientHandler extends Thread { System.out.println("Client is valid"); dos.writeInt(result); - byte[] encryptedBytes = key.encryptByte(aesE.doFinal(Socket.clientFileData)); + byte[] encryptedBytes = key.encryptByte(aesE.doFinal(SocketHandler.clientFileData)); dos.writeInt(encryptedBytes.length); dos.write(encryptedBytes, 0, encryptedBytes.length); dos.flush(); diff --git a/Server/src/main/java/dev/baseband/server/socket/Socket.java b/Server/src/main/java/dev/baseband/server/socket/SocketHandler.java similarity index 96% rename from Server/src/main/java/dev/baseband/server/socket/Socket.java rename to Server/src/main/java/dev/baseband/server/socket/SocketHandler.java index 7e3dbdf..33b9f0a 100644 --- a/Server/src/main/java/dev/baseband/server/socket/Socket.java +++ b/Server/src/main/java/dev/baseband/server/socket/SocketHandler.java @@ -10,7 +10,7 @@ import java.util.Base64; import java.util.HashSet; import java.util.Set; -public class Socket { +public class SocketHandler { public static KeyPair key; public static KeyFactory factory; public static byte[] clientFileData; @@ -94,14 +94,16 @@ public class Socket { System.out.println("Current valid jar hash: " + jarHash); currentJarHash = jarHash.toString(); FileOutputStream validHashesOut = new FileOutputStream("valid_hashes.txt", true); - new PrintStream(validHashesOut).println(jarHash); validHashesOut.close(); HashSet hashes = new HashSet<>(); BufferedReader reader = new BufferedReader(new FileReader("valid_hashes.txt")); String s; while ((s = reader.readLine()) != null) hashes.add(s); - Socket.pastJarHashes = hashes; + if(!hashes.contains(currentJarHash)) { + new PrintStream(validHashesOut).println(jarHash); + } + SocketHandler.pastJarHashes = hashes; ServerSocket socket = new ServerSocket(31212);