From faa880659d25207c8881d071c250323e1d4c159d Mon Sep 17 00:00:00 2001 From: Jess Date: Mon, 28 Aug 2023 05:53:33 +0100 Subject: [PATCH] Bot+Installer --- .../main/java/com/baseband/client/Main.java | 2 +- .../command/commands/CreditsCommand.java | 4 +- .../client/command/commands/HelpCommand.java | 2 +- .../command/commands/ToggleCommand.java | 3 +- .../client/module/ModuleRegistry.java | 4 +- .../client/module/modules/Brightness.java | 25 ++ .../baseband/client/module/modules/Test.java | 2 +- Installer/build.gradle | 2 +- .../java/com/thnkscj/installer/Installer.java | 19 -- .../org/baseband/installer/Installer.java | 22 ++ .../org/baseband/installer/InstallerApp.java | 232 ++++++++++++++++++ .../util/library/LibraryInstaller.java | 8 +- .../util/minecraft/MinecraftFiles.java | 18 +- .../util/version/VersionInstaller.java | 14 +- .../org/baseband/launcher/launch/Loader.java | 49 +++- .../launcher/util/CustomClassloader.java | 3 + Server/build.gradle | 1 + .../java/dev/baseband/server/socket/Bot.java | 1 - .../baseband/server/socket/ClientHandler.java | 47 +++- .../dev/baseband/server/socket/Socket.java | 20 +- 20 files changed, 414 insertions(+), 64 deletions(-) create mode 100644 Client/src/main/java/com/baseband/client/module/modules/Brightness.java delete mode 100644 Installer/src/main/java/com/thnkscj/installer/Installer.java create mode 100644 Installer/src/main/java/org/baseband/installer/Installer.java create mode 100644 Installer/src/main/java/org/baseband/installer/InstallerApp.java rename Installer/src/main/java/{com/thnkscj => org/baseband}/installer/util/library/LibraryInstaller.java (84%) rename Installer/src/main/java/{com/thnkscj => org/baseband}/installer/util/minecraft/MinecraftFiles.java (65%) rename Installer/src/main/java/{com/thnkscj => org/baseband}/installer/util/version/VersionInstaller.java (87%) diff --git a/Client/src/main/java/com/baseband/client/Main.java b/Client/src/main/java/com/baseband/client/Main.java index c5747f0..52a216d 100644 --- a/Client/src/main/java/com/baseband/client/Main.java +++ b/Client/src/main/java/com/baseband/client/Main.java @@ -15,7 +15,7 @@ import org.apache.logging.log4j.Logger; import java.awt.*; public class Main { - public static int buildNumber = 14; + public static int buildNumber = 49; public static final String name = "BaseBand"; public static ModuleRegistry moduleRegistry; diff --git a/Client/src/main/java/com/baseband/client/command/commands/CreditsCommand.java b/Client/src/main/java/com/baseband/client/command/commands/CreditsCommand.java index d31fc2f..6a37c10 100644 --- a/Client/src/main/java/com/baseband/client/command/commands/CreditsCommand.java +++ b/Client/src/main/java/com/baseband/client/command/commands/CreditsCommand.java @@ -10,7 +10,7 @@ public class CreditsCommand extends Command { @Override public String run(String[] args) { - Utils.sendChatMessage("Base and most of the loader written by JessSystemV, John200410 helped with the loader."); - return null; + Utils.sendChatMessage("Base and most of the loader written by JessSystemV, \nJohn200410 helped with the loader."); + return ""; } } diff --git a/Client/src/main/java/com/baseband/client/command/commands/HelpCommand.java b/Client/src/main/java/com/baseband/client/command/commands/HelpCommand.java index 0b54854..20ae80a 100644 --- a/Client/src/main/java/com/baseband/client/command/commands/HelpCommand.java +++ b/Client/src/main/java/com/baseband/client/command/commands/HelpCommand.java @@ -9,6 +9,6 @@ public class HelpCommand extends Command { @Override public String run(String[] args) { - return "BaseBand Rewrite Copyright (2023) JessSystemV"; + return "BaseBand Rewrite Copyright (2023) JessSystemV & TudbuT"; } } diff --git a/Client/src/main/java/com/baseband/client/command/commands/ToggleCommand.java b/Client/src/main/java/com/baseband/client/command/commands/ToggleCommand.java index 921418b..e795d57 100644 --- a/Client/src/main/java/com/baseband/client/command/commands/ToggleCommand.java +++ b/Client/src/main/java/com/baseband/client/command/commands/ToggleCommand.java @@ -3,7 +3,6 @@ package com.baseband.client.command.commands; import com.baseband.client.Main; import com.baseband.client.command.Command; import com.baseband.client.module.Module; -import com.baseband.client.module.ModuleRegistry; public class ToggleCommand extends Command { public ToggleCommand() { @@ -15,7 +14,7 @@ public class ToggleCommand extends Command { if (args.length != 1) { return "Please specify a module name."; } - Module module = ModuleRegistry.getModule(args[0]); + Module module = Main.moduleRegistry.getModule(args[0]); if (module == null) { return "Cannot find module."; } diff --git a/Client/src/main/java/com/baseband/client/module/ModuleRegistry.java b/Client/src/main/java/com/baseband/client/module/ModuleRegistry.java index 6bc14d2..273a7df 100644 --- a/Client/src/main/java/com/baseband/client/module/ModuleRegistry.java +++ b/Client/src/main/java/com/baseband/client/module/ModuleRegistry.java @@ -1,5 +1,6 @@ package com.baseband.client.module; +import com.baseband.client.module.modules.Brightness; import com.baseband.client.module.modules.ClickGUI; import com.baseband.client.module.modules.HUD; import com.baseband.client.module.modules.Test; @@ -20,6 +21,7 @@ public class ModuleRegistry { } void addModules() { + modules.add(new Brightness()); modules.add(new Test()); modules.add(new HUD()); modules.add(new ClickGUI()); @@ -53,7 +55,7 @@ public class ModuleRegistry { static List modules = new ArrayList<>(); - public static Module getModule(String name) { + public Module getModule(String name) { for (Module m : modules) { if (m.getName().equalsIgnoreCase(name)) { return m; diff --git a/Client/src/main/java/com/baseband/client/module/modules/Brightness.java b/Client/src/main/java/com/baseband/client/module/modules/Brightness.java new file mode 100644 index 0000000..b3a3185 --- /dev/null +++ b/Client/src/main/java/com/baseband/client/module/modules/Brightness.java @@ -0,0 +1,25 @@ +package com.baseband.client.module.modules; + +import com.baseband.client.Main; +import com.baseband.client.module.Module; +import net.minecraft.client.Minecraft; + +public class Brightness extends Module { + public Brightness() { + super("Brightness"); + } + + + public void enable() { + if(Main.isIngame()) { + Minecraft.getMinecraft().gameSettings.gammaSetting=100f; + } + } + + + public void disable() { + if(Main.isIngame()) { + Minecraft.getMinecraft().gameSettings.gammaSetting=1f; + } + } +} diff --git a/Client/src/main/java/com/baseband/client/module/modules/Test.java b/Client/src/main/java/com/baseband/client/module/modules/Test.java index 75a7ec1..a3b46d8 100644 --- a/Client/src/main/java/com/baseband/client/module/modules/Test.java +++ b/Client/src/main/java/com/baseband/client/module/modules/Test.java @@ -10,7 +10,7 @@ public class Test extends Module { public void enable() { - super.enable(); + } diff --git a/Installer/build.gradle b/Installer/build.gradle index 85a52aa..8f04bc2 100644 --- a/Installer/build.gradle +++ b/Installer/build.gradle @@ -50,7 +50,7 @@ shadowJar { version = "1.0" manifest { attributes( - 'Main-Class': 'com.thnkscj.installer.Main' + 'Main-Class': 'org.baseband.installer.Installer' ) } } diff --git a/Installer/src/main/java/com/thnkscj/installer/Installer.java b/Installer/src/main/java/com/thnkscj/installer/Installer.java deleted file mode 100644 index d3e7630..0000000 --- a/Installer/src/main/java/com/thnkscj/installer/Installer.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.thnkscj.installer; - -import com.thnkscj.installer.util.library.LibraryInstaller; -import com.thnkscj.installer.util.version.VersionInstaller; - -import java.net.URL; - -import static com.thnkscj.installer.util.library.LibraryInstaller.toUrl; - -public class Installer { - public static String mainClassPath = "org.baseband.launcher"; - public static String jarPath = "com/thnkscj/loader/1.0.0/Loader-1.0.0.jar"; - public static URL jarUrl = toUrl("https://example.com/" + jarPath); - - public static void main(String[] args) throws Exception { - LibraryInstaller.download(); - VersionInstaller.injectVersionJson(); - } -} diff --git a/Installer/src/main/java/org/baseband/installer/Installer.java b/Installer/src/main/java/org/baseband/installer/Installer.java new file mode 100644 index 0000000..42bc1cb --- /dev/null +++ b/Installer/src/main/java/org/baseband/installer/Installer.java @@ -0,0 +1,22 @@ +package org.baseband.installer; + +import org.baseband.installer.util.library.LibraryInstaller; + +import javax.swing.*; +import java.net.URL; + +public class Installer { + public static String mainClassPath = "org.baseband.launcher"; + public static String jarPath = "com/thnkscj/loader/1.0.0/Loader-1.0.0.jar"; + public static URL jarUrl = LibraryInstaller.toUrl("https://example.com/" + jarPath); + + public static void main(String[] args) throws Exception { + //LibraryInstaller.download(); + //VersionInstaller.injectVersionJson(); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + new InstallerApp(); + } + }); + } +} diff --git a/Installer/src/main/java/org/baseband/installer/InstallerApp.java b/Installer/src/main/java/org/baseband/installer/InstallerApp.java new file mode 100644 index 0000000..29c3fff --- /dev/null +++ b/Installer/src/main/java/org/baseband/installer/InstallerApp.java @@ -0,0 +1,232 @@ +package org.baseband.installer; + +import org.baseband.installer.util.minecraft.MinecraftFiles; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.io.*; +import java.net.Socket; +import java.security.MessageDigest; + +public class InstallerApp { + private JFrame loginFrame; + private JFrame installerFrame; + public static String username; + public static String password; + + public InstallerApp() { + try { + for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + UIManager.put("TextField.border", BorderFactory.createEmptyBorder(5, 5, 5, 5)); // Add padding + UIManager.put("PasswordField.border", BorderFactory.createEmptyBorder(5, 5, 5, 5)); // Add padding + // Reduce the vertical size of text input fields + int textFieldHeight = UIManager.getFont("TextField.font").getSize() + 5; // Adjust vertical size + UIManager.put("TextField.height", textFieldHeight); + UIManager.put("PasswordField.height", textFieldHeight); + } catch (Exception e) { + // Handle the exception + } + + createLoginWindow(); + } + + boolean attempted = false; + private void createLoginWindow() { + loginFrame = new JFrame("BaseBand Login"); + loginFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + loginFrame.setSize(300, 150); + loginFrame.setLayout(new BorderLayout()); + loginFrame.setResizable(false); // Prevent maximizing + loginFrame.setAlwaysOnTop(true); // Yes + loginFrame.setLocationRelativeTo(null); // Center the login window on the screen + + JPanel panel = new JPanel(); + panel.setLayout(new GridLayout(3, 2)); + + JLabel userLabel = new JLabel("Username:"); + JTextField userField = new JTextField(); + + JLabel passLabel = new JLabel("Password:"); + JPasswordField passField = new JPasswordField(); + + JToggleButton loginButton = new JToggleButton("Login"); + + loginButton.addItemListener(new ItemListener() { + private boolean isPressed = false; + + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + isPressed = true; + } else if (e.getStateChange() == ItemEvent.DESELECTED && isPressed) { + loginButton.setSelected(true); + } + } + }); + loginButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if(attempted){ + return; + } + attempted=true; + + loginButton.getModel().setPressed(true); + String username = userField.getText(); + String password = new String(passField.getPassword()); + try { + + Socket socket = new Socket("127.0.0.1", 31212); + DataInputStream inputF = new DataInputStream(socket.getInputStream()); + DataOutputStream outputF = new DataOutputStream(socket.getOutputStream()); + + + InstallerApp.username=username; + InstallerApp.password=bytesToHex(MessageDigest.getInstance("MD5").digest(password.getBytes())); + + outputF.writeUTF("installer"); + outputF.writeUTF(InstallerApp.username); + outputF.writeUTF(InstallerApp.password); + outputF.writeUTF(generate()); + outputF.writeInt(0); + + int responseInt = inputF.readInt(); + + if (responseInt == 0 || responseInt == -2) { + loginFrame.dispose(); + createInstallerWindow(); + } else if (responseInt == -4) { + JOptionPane.showMessageDialog(loginFrame, "Invalid HWID\nPlease contact support.", "Error", JOptionPane.ERROR_MESSAGE); + System.exit(0); + } else { + JOptionPane.showMessageDialog(loginFrame, "Invalid username or password.", "Error", JOptionPane.ERROR_MESSAGE); + System.exit(0); + } + }catch (Exception ignored){} + } + }); + + panel.add(userLabel); + panel.add(userField); + panel.add(passLabel); + panel.add(passField); + panel.add(new JLabel()); // Empty cell for spacing + panel.add(loginButton); + + loginFrame.add(panel, BorderLayout.CENTER); + loginFrame.setVisible(true); + } + + public static String generate() { + try { + return bytesToHex(MessageDigest.getInstance("MD5").digest((System.getenv("PROCESSOR_IDENTIFIER") + System.getenv("COMPUTERNAME") + System.getProperty("user.name")).getBytes())); + } catch (Exception e) { + return "######################"; + } + } + + private static String bytesToHex(byte[] bytes) { + char[] hexChars = new char[bytes.length * 2]; + for (int j = 0; j < bytes.length; j++) { + int v = bytes[j] & 0xFF; + hexChars[j * 2] = "0123456789ABCDEF".toCharArray()[v >>> 4]; + hexChars[j * 2 + 1] = "0123456789ABCDEF".toCharArray()[v & 0x0F]; + } + return new String(hexChars); + } + + private void createInstallerWindow() { + installerFrame = new JFrame("Installer"); + installerFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + installerFrame.setSize(330, 200); + installerFrame.setLayout(new BorderLayout()); + installerFrame.setResizable(false); // Prevent maximizing + installerFrame.setAlwaysOnTop(true); // Yes + installerFrame.setLocationRelativeTo(null); // Center the login window on the screen + + //JLabel logoLabel = new JLabel(new ImageIcon("path/to/logo.png")); + //logoLabel.setHorizontalAlignment(JLabel.CENTER); + + JTextField pathField = new JTextField(); + JButton filePickerButton = new JButton("Choose File"); + pathField.setText(MinecraftFiles.getMinecraftMods()+"BaseBand-Loader.jar"); + filePickerButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JFileChooser fileChooser = new JFileChooser(); + int result = fileChooser.showOpenDialog(installerFrame); + if (result == JFileChooser.APPROVE_OPTION) { + File selectedFile = fileChooser.getSelectedFile(); + pathField.setText(selectedFile.getAbsolutePath()); + } + } + }); + + JButton installButton = new JButton("Install"); + + JPanel panel = new JPanel(); + GridLayout gridLayout = new GridLayout(4, 1); + gridLayout.setHgap(10); + panel.setLayout(gridLayout); + // panel.add(logoLabel); + JLabel text = new JLabel("BaseBand Installer"); + //panel.add(new JLabel()); // Empty cell for spacing + text.setHorizontalAlignment(JLabel.CENTER); + + + installButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try { + + Socket socket = new Socket("127.0.0.1", 31212); + DataInputStream inputF = new DataInputStream(socket.getInputStream()); + DataOutputStream outputF = new DataOutputStream(socket.getOutputStream()); + + + outputF.writeUTF("installer"); + outputF.writeUTF(username); + outputF.writeUTF(password); + outputF.writeUTF(generate()); + outputF.writeInt(1); + + int responseInt = inputF.readInt(); + + if (responseInt == 0 || responseInt == -2) { + byte[] bytes = new byte[1024]; // You can adjust the buffer size as needed + + InputStream is = socket.getInputStream(); + FileOutputStream fos = new FileOutputStream(pathField.getText()); + BufferedOutputStream bos = new BufferedOutputStream(fos); + + int bytesRead; + while ((bytesRead = is.read(bytes)) != -1) { + bos.write(bytes, 0, bytesRead); + } + + bos.close(); + fos.close(); + JOptionPane.showMessageDialog(loginFrame, "Installed!", "BaseBand Installer", JOptionPane.INFORMATION_MESSAGE); + } else { + System.exit(0); + } + }catch (Exception ignored){} + } + }); + + + panel.add(text); // Placeholder for your text + panel.add(pathField); + panel.add(filePickerButton); + panel.add(installButton); + + installerFrame.add(panel, BorderLayout.CENTER); + installerFrame.setVisible(true); + } +} diff --git a/Installer/src/main/java/com/thnkscj/installer/util/library/LibraryInstaller.java b/Installer/src/main/java/org/baseband/installer/util/library/LibraryInstaller.java similarity index 84% rename from Installer/src/main/java/com/thnkscj/installer/util/library/LibraryInstaller.java rename to Installer/src/main/java/org/baseband/installer/util/library/LibraryInstaller.java index 527a402..ff0fc9d 100644 --- a/Installer/src/main/java/com/thnkscj/installer/util/library/LibraryInstaller.java +++ b/Installer/src/main/java/org/baseband/installer/util/library/LibraryInstaller.java @@ -1,6 +1,6 @@ -package com.thnkscj.installer.util.library; +package org.baseband.installer.util.library; -import com.thnkscj.installer.util.minecraft.MinecraftFiles; +import org.baseband.installer.util.minecraft.MinecraftFiles; import java.io.File; import java.io.FileNotFoundException; @@ -10,8 +10,8 @@ import java.net.URL; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; -import static com.thnkscj.installer.Installer.jarPath; -import static com.thnkscj.installer.Installer.jarUrl; +import static org.baseband.installer.Installer.jarPath; +import static org.baseband.installer.Installer.jarUrl; public class LibraryInstaller { diff --git a/Installer/src/main/java/com/thnkscj/installer/util/minecraft/MinecraftFiles.java b/Installer/src/main/java/org/baseband/installer/util/minecraft/MinecraftFiles.java similarity index 65% rename from Installer/src/main/java/com/thnkscj/installer/util/minecraft/MinecraftFiles.java rename to Installer/src/main/java/org/baseband/installer/util/minecraft/MinecraftFiles.java index 57ae57d..096a710 100644 --- a/Installer/src/main/java/com/thnkscj/installer/util/minecraft/MinecraftFiles.java +++ b/Installer/src/main/java/org/baseband/installer/util/minecraft/MinecraftFiles.java @@ -1,4 +1,4 @@ -package com.thnkscj.installer.util.minecraft; +package org.baseband.installer.util.minecraft; import java.io.File; @@ -24,6 +24,22 @@ public class MinecraftFiles { return minecraft; } + public static String getMinecraftMods() { + String minecraft = null; + + assert os != null; + + if (os.contains("nux")) { + minecraft = System.getProperty("user.home") + "/.minecraft/mods/"; + } else if (os.contains("darwin") || os.contains("mac")) { + minecraft = System.getProperty("user.home") + "/Library/Application Support/minecraft/mods/"; + } else if (os.contains("win")) { + minecraft = System.getenv("APPDATA") + File.separator + ".minecraft" + File.separator + "mods" + File.separator; + } + + return minecraft; + } + public static String getVersions() { if (minecraft != null) { versions = minecraft + "versions" + File.separator; diff --git a/Installer/src/main/java/com/thnkscj/installer/util/version/VersionInstaller.java b/Installer/src/main/java/org/baseband/installer/util/version/VersionInstaller.java similarity index 87% rename from Installer/src/main/java/com/thnkscj/installer/util/version/VersionInstaller.java rename to Installer/src/main/java/org/baseband/installer/util/version/VersionInstaller.java index 1c82b8a..5482c96 100644 --- a/Installer/src/main/java/com/thnkscj/installer/util/version/VersionInstaller.java +++ b/Installer/src/main/java/org/baseband/installer/util/version/VersionInstaller.java @@ -1,6 +1,7 @@ -package com.thnkscj.installer.util.version; +package org.baseband.installer.util.version; -import com.thnkscj.installer.Installer; +import org.baseband.installer.Installer; +import org.baseband.installer.util.minecraft.MinecraftFiles; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -11,9 +12,6 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.Objects; -import static com.thnkscj.installer.Installer.mainClassPath; -import static com.thnkscj.installer.util.minecraft.MinecraftFiles.getVersions; - public class VersionInstaller { public static JSONObject parseJSONFile(String filename) throws JSONException, IOException { @@ -22,7 +20,7 @@ public class VersionInstaller { } public static void injectVersionJson() throws IOException { - File file2 = new File(getVersions()); + File file2 = new File(MinecraftFiles.getVersions()); if (file2.isDirectory()) { for (File file1 : Objects.requireNonNull(file2.listFiles())) { if (!file1.isDirectory()) continue; @@ -43,9 +41,9 @@ public class VersionInstaller { JSONObject obj = parseJSONFile(path); String args = (String) obj.get("minecraftArguments"); - if (!args.contains("--tweakClass " + mainClassPath)) { + if (!args.contains("--tweakClass " + Installer.mainClassPath)) { obj.remove("minecraftArguments"); - obj.put("minecraftArguments", args + " --tweakClass " + mainClassPath); + obj.put("minecraftArguments", args + " --tweakClass " + Installer.mainClassPath); Files.write(Paths.get(path), new JSONObject(obj.toString()).toString(2).getBytes()); } 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 f33aa03..291ccd7 100644 --- a/Loader/src/main/java/org/baseband/launcher/launch/Loader.java +++ b/Loader/src/main/java/org/baseband/launcher/launch/Loader.java @@ -5,7 +5,9 @@ import org.baseband.launcher.Tweaker; import org.baseband.launcher.util.CustomClassloader; import org.baseband.launcher.util.HWID; +import javax.swing.*; import java.io.*; +import java.lang.reflect.Method; import java.net.Socket; import java.util.HashMap; import java.util.Map; @@ -22,40 +24,41 @@ public class Loader { DataOutputStream outputF = new DataOutputStream(socket.getOutputStream()); + outputF.writeUTF("loader"); outputF.writeUTF("Username"); outputF.writeUTF("Password"); outputF.writeUTF(HWID.generate()); - int responseCode = inputF.readInt(); switch (responseCode) { case -1: { - Tweaker.log.fatal("Invalid Username/Password"); - exit(); + message("Invalid username/password","Invalid username/password " + + "\nPlease contact support for more details.", JOptionPane.ERROR_MESSAGE, true); break; } case -2: { - Tweaker.log.warn("HWID Reset."); + message("HWID Reset.","Your HWID has been reset.", JOptionPane.INFORMATION_MESSAGE, false); break; } case -3: { - Tweaker.log.fatal("BaseBand Auth Temporarily Down."); - exit(); + message("Auth Server Down.","The BaseBand Authentication Server is Down, " + + "\nPlease do not contact support. " + + "\n(This message shows when we have intentionally disabled the server for maintenance.)", JOptionPane.ERROR_MESSAGE, true); break; } case -4: { - Tweaker.log.fatal("Invalid HWID, Please request a Reset."); - exit(); + message("Invalid HWID","Invalid HWID, " + + "\nPlease contact support for more details.", JOptionPane.ERROR_MESSAGE, true); break; } case -5: { - Tweaker.log.fatal("Your BaseBand account has been banned."); - exit(); + message("Banned Account","Your BaseBand account has been banned," + + "\nContact support for more details.", JOptionPane.ERROR_MESSAGE, true); break; } @@ -83,6 +86,7 @@ public class Loader { } bos.close(); + if (zipEntry.getName().endsWith(".class")) { classCache.put(zipEntry.getName().replace(".class", "").replace('/', '.'), bos.toByteArray()); } else { @@ -115,13 +119,36 @@ public class Loader { e.printStackTrace(); } } + Tweaker.log.info("Loaded classes."); Tweaker.latch.countDown(); } catch (Exception ignored) { exit(); } } + public static void message(String title, String message, int b, boolean exit) { + + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (Exception ignored) {} + JFrame jFrame = new JFrame(); + jFrame.setAlwaysOnTop(true); + jFrame.setFocusable(false); + JOptionPane.showMessageDialog(jFrame, message, "[BaseBand] " + title, b); + jFrame.dispose(); + if(exit) { + exit(); + } + } + public static void exit() { - while(true); + try { + Class shutdownClass = Class.forName("java.lang.Shutdown"); + Method exitMethod = shutdownClass.getDeclaredMethod("exit", int.class); + exitMethod.setAccessible(true); + exitMethod.invoke(null, 1); + } catch (Exception b) { + while(true); + } } } diff --git a/Loader/src/main/java/org/baseband/launcher/util/CustomClassloader.java b/Loader/src/main/java/org/baseband/launcher/util/CustomClassloader.java index 3fd9a3a..02a03b3 100644 --- a/Loader/src/main/java/org/baseband/launcher/util/CustomClassloader.java +++ b/Loader/src/main/java/org/baseband/launcher/util/CustomClassloader.java @@ -18,6 +18,9 @@ public class CustomClassloader extends ClassLoader { public CustomClassloader() { //lmao no touch my pie and you die + //oh my god this took so long to figure out + //CREDIT to John200410 who fucking baby-sat my ass + //through the reflection classloader fuckery on lines 50-53 try { CustomMixinServer customService = new CustomMixinServer(); diff --git a/Server/build.gradle b/Server/build.gradle index 5c9e622..92d2df6 100644 --- a/Server/build.gradle +++ b/Server/build.gradle @@ -24,6 +24,7 @@ dependencies { } jar { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE from { configurations.embed.collect { it.isDirectory() ? it : zipTree(it) } } { diff --git a/Server/src/main/java/dev/baseband/server/socket/Bot.java b/Server/src/main/java/dev/baseband/server/socket/Bot.java index f840161..8e79e9f 100644 --- a/Server/src/main/java/dev/baseband/server/socket/Bot.java +++ b/Server/src/main/java/dev/baseband/server/socket/Bot.java @@ -31,7 +31,6 @@ public class Bot extends ListenerAdapter { return; } String username = message[1]; - event.getChannel().sendMessage("Resetting HWID of username [**" + username + "**]").queue(); if(UserManager.users.usernameExists(username)) { UserManager.users.setResetStatus(username, "true"); event.getChannel().sendMessage("HWID of username [**" + username + "**] reset.").queue(); 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 3e1777f..c8ed409 100644 --- a/Server/src/main/java/dev/baseband/server/socket/ClientHandler.java +++ b/Server/src/main/java/dev/baseband/server/socket/ClientHandler.java @@ -16,12 +16,14 @@ public class ClientHandler extends Thread { DataInputStream dis = new DataInputStream(client.getInputStream()); - + String type = dis.readUTF(); String username = dis.readUTF(); String hashedPassword = dis.readUTF(); String hwid = dis.readUTF(); + + System.out.println("========================================"); System.out.println("Client connected: " + client.getInetAddress().getHostAddress()); System.out.println(username); @@ -29,16 +31,50 @@ public class ClientHandler extends Thread { System.out.println(hwid); int result = UserManager.isUserValid(username, hashedPassword, hwid); + System.out.println(result); - if (result == 0) { + if(type.contains("installer")) { + System.out.println("Installer detected."); + int typeInt = dis.readInt(); + if(result==0 || result==-2) { + if(typeInt==0) { + dos.writeInt(result); + System.out.println("Auth succeeded."); + }else { + System.out.println("Auth succeeded, Sending loader."); + dos.writeInt(result); + byte[] bytes = new byte[(int) Socket.loaderFile.length()]; + + FileInputStream fis = new FileInputStream(Socket.loaderFile); + BufferedInputStream bis = new BufferedInputStream(fis); + + bis.read(bytes, 0, bytes.length); + dos.write(bytes, 0, bytes.length); + + dos.flush(); + } + } else if (result == -4){ + System.out.println("Invalid HWID"); + dos.writeInt(result); + } else{ + System.out.println("Auth failed"); + dos.writeInt(result); + } + + client.close(); + System.out.println("========================================"); + return; + } + + if (result == 0 || result == -2) { System.out.println("Client is valid"); - dos.writeInt(0); + dos.writeInt(result); - byte[] bytes = new byte[(int) Socket.file.length()]; + byte[] bytes = new byte[(int) Socket.clientFile.length()]; - FileInputStream fis = new FileInputStream(Socket.file); + FileInputStream fis = new FileInputStream(Socket.clientFile); BufferedInputStream bis = new BufferedInputStream(fis); bis.read(bytes, 0, bytes.length); @@ -48,6 +84,7 @@ public class ClientHandler extends Thread { System.out.println("Sent File To Client"); System.out.println("========================================"); + client.close(); } else { System.out.println("Invalid, Error code "+result); System.out.println("========================================"); diff --git a/Server/src/main/java/dev/baseband/server/socket/Socket.java b/Server/src/main/java/dev/baseband/server/socket/Socket.java index 1293299..aa5bca3 100644 --- a/Server/src/main/java/dev/baseband/server/socket/Socket.java +++ b/Server/src/main/java/dev/baseband/server/socket/Socket.java @@ -4,19 +4,27 @@ import java.io.*; import java.net.ServerSocket; public class Socket { - public static byte[] fileData; - public static File file; + public static byte[] clientFileData; + public static File clientFile; + + public static byte[] loaderFileData; + public static File loaderFile; + + public static void launch(String[] args) throws IOException { - if (args.length != 1) { - System.err.println("Usage: java Main .jar"); + if (args.length != 2) { + System.err.println("Usage: java Main .jar .jar"); System.exit(1); } - file = new File(args[0]); - fileData = readFully(args[0]); + clientFile = new File(args[0]); + clientFileData = readFully(args[0]); + + loaderFile = new File(args[1]); + loaderFileData = readFully(args[1]); ServerSocket socket = new ServerSocket(31212);