moar
This commit is contained in:
parent
c253224b48
commit
804cc47948
41 changed files with 1392 additions and 322 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
|||
# Project exclude paths
|
||||
/.gradle/
|
||||
/build/
|
||||
/obf/
|
||||
/Obf/
|
||||
|
|
|
@ -75,7 +75,7 @@ dependencies {
|
|||
}
|
||||
|
||||
compileJava {
|
||||
def targetFile = file("src/main/java/com/baseband/client/Main.java")
|
||||
def targetFile = file("src/main/java/com/baseband/client/BaseBand.java")
|
||||
def content = targetFile.text
|
||||
def updatedContent = content.replaceFirst("buildNumber = (\\d+)", { _, value -> "buildNumber = ${value.toInteger() + 1}" })
|
||||
targetFile.text = updatedContent
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.baseband.client;
|
|||
|
||||
import com.baseband.client.command.CommandManager;
|
||||
import com.baseband.client.event.EventBus;
|
||||
import com.baseband.client.event.events.SafeTickEvent;
|
||||
import com.baseband.client.module.ModuleRegistry;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
|
@ -15,13 +16,14 @@ import org.apache.logging.log4j.Logger;
|
|||
|
||||
import java.awt.*;
|
||||
|
||||
public class Main {
|
||||
public static int buildNumber = 3;
|
||||
public class BaseBand {
|
||||
public static int buildNumber = 71;
|
||||
|
||||
public static final String name = "BaseBand";
|
||||
public static ModuleRegistry moduleRegistry;
|
||||
public static CommandManager commandRegistry;
|
||||
public static EventBus eventBus;
|
||||
public static Config configManager;
|
||||
public static final Logger log = LogManager.getLogger("BaseBand");
|
||||
public static boolean authed = true; //TODO: make this update along with whatever protection Daniella's figuring out
|
||||
|
||||
|
@ -29,6 +31,8 @@ public class Main {
|
|||
moduleRegistry = new ModuleRegistry();
|
||||
commandRegistry = new CommandManager();
|
||||
eventBus = new EventBus();
|
||||
configManager = new Config();
|
||||
|
||||
|
||||
log.info("BaseBand Instantiated.");
|
||||
}
|
||||
|
@ -36,8 +40,7 @@ public class Main {
|
|||
@SubscribeEvent
|
||||
public void tick(TickEvent.ClientTickEvent e) {
|
||||
if(isIngame()) {
|
||||
//EVENT_MANAGER.publish(new SafeTickEvent());
|
||||
//TODO: implement better event manager
|
||||
eventBus.publish(new SafeTickEvent());
|
||||
}
|
||||
}
|
||||
|
58
Client/src/main/java/com/baseband/client/Config.java
Normal file
58
Client/src/main/java/com/baseband/client/Config.java
Normal file
|
@ -0,0 +1,58 @@
|
|||
package com.baseband.client;
|
||||
|
||||
import com.baseband.client.module.Module;
|
||||
import com.baseband.client.setting.Setting;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
|
||||
public class Config {
|
||||
//TODO: replace
|
||||
|
||||
public Config() {
|
||||
File directory = new File("BaseBand");
|
||||
directory.mkdir();
|
||||
|
||||
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(()->{
|
||||
for(Module m : BaseBand.moduleRegistry.getModuleList()) {
|
||||
Config.saveSettingsToFile(m.getSettings(), new File(directory, m.getName()).getPath());
|
||||
}
|
||||
BaseBand.log.info("Saved settings");
|
||||
}));
|
||||
|
||||
|
||||
for(Module m : BaseBand.moduleRegistry.getModuleList()) {
|
||||
try {
|
||||
m.setSettings(Config.loadSettingsFromFile(new File(directory, m.getName()).getPath()));
|
||||
BaseBand.log.info("Loaded settings");
|
||||
}catch (Exception e) {
|
||||
Config.saveSettingsToFile(m.getSettings(), new File(directory, m.getName()).getPath());
|
||||
BaseBand.log.info("Created settings");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Save a list of Setting<?> to a file
|
||||
public static void saveSettingsToFile(List<Setting<?>> settings, String filePath) {
|
||||
try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(filePath))) {
|
||||
oos.writeObject(settings);
|
||||
System.out.println("Settings saved to " + filePath);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Load a list of Setting<?> from a file
|
||||
public static List<Setting<?>> loadSettingsFromFile(String filePath) {
|
||||
try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(filePath))) {
|
||||
List<Setting<?>> settings = (List<Setting<?>>) ois.readObject();
|
||||
System.out.println("Settings loaded from " + filePath);
|
||||
return settings;
|
||||
} catch (IOException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
82
Client/src/main/java/com/baseband/client/MotionUtil.java
Normal file
82
Client/src/main/java/com/baseband/client/MotionUtil.java
Normal file
|
@ -0,0 +1,82 @@
|
|||
package com.baseband.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.init.MobEffects;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public class MotionUtil {
|
||||
//Needed for Speed, thanks Doogie.
|
||||
|
||||
static final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
public static double applySpeed(double speed) {
|
||||
|
||||
if (mc.player.isPotionActive(MobEffects.SPEED)) {
|
||||
|
||||
double amp = Objects.requireNonNull(mc.player.getActivePotionEffect(MobEffects.SPEED)).getAmplifier() + 1;
|
||||
speed *= 1.0f + 0.2f * amp;
|
||||
|
||||
}
|
||||
|
||||
return speed;
|
||||
|
||||
}
|
||||
|
||||
public static double applyJumpBoost(double height) {
|
||||
|
||||
if (mc.player.isPotionActive(MobEffects.JUMP_BOOST)) {
|
||||
return height + (Objects.requireNonNull(mc.player.getActivePotionEffect(MobEffects.JUMP_BOOST)).getAmplifier() + 1) * 0.1f;
|
||||
}
|
||||
|
||||
return height;
|
||||
|
||||
}
|
||||
|
||||
private static float getRotationYaw() {
|
||||
|
||||
return Minecraft.getMinecraft().player.rotationYaw;
|
||||
|
||||
}
|
||||
|
||||
public static double[] getMotion(double speed) {
|
||||
|
||||
if (mc.player.moveForward == 0 && mc.player.moveStrafing == 0)
|
||||
return new double[]{0, 0};
|
||||
|
||||
int strafing = 0;
|
||||
int forward = 0;
|
||||
|
||||
if (mc.player.moveStrafing < 0)
|
||||
strafing = -1;
|
||||
else if (mc.player.moveStrafing > 0)
|
||||
strafing = 1;
|
||||
|
||||
if (mc.player.moveForward < 0)
|
||||
forward = -1;
|
||||
else if (mc.player.moveForward > 0)
|
||||
forward = 1;
|
||||
|
||||
float strafe = 90 * strafing;
|
||||
strafe *= (forward != 0F) ? forward * 0.5F : 1;
|
||||
|
||||
float yaw = getRotationYaw() - strafe;
|
||||
yaw -= (mc.player.moveForward < 0F) ? 180 : 0;
|
||||
|
||||
return getMotion(speed, yaw);
|
||||
}
|
||||
|
||||
public static double[] getMotion(double speed, float yaw) {
|
||||
|
||||
// to radians
|
||||
yaw *= 0.017452006980803f;
|
||||
|
||||
double x = (-Math.sin(yaw) * speed);
|
||||
double z = (Math.cos(yaw) * speed);
|
||||
|
||||
return new double[]{x, z};
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -5,9 +5,9 @@ import net.minecraft.util.text.TextComponentString;
|
|||
|
||||
public class Utils {
|
||||
public static void sendChatMessage(String e) {
|
||||
if (Main.isIngame()) {
|
||||
if (BaseBand.isIngame()) {
|
||||
try {
|
||||
Minecraft.getMinecraft().player.sendMessage(new TextComponentString("[" + "§a" + Main.name + "§r" + "]" + " " + e));
|
||||
Minecraft.getMinecraft().player.sendMessage(new TextComponentString("[" + "§a" + BaseBand.name + "§r" + "]" + " " + e));
|
||||
} catch (Exception ee) {
|
||||
ee.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package com.baseband.client.command;
|
||||
|
||||
import com.baseband.client.Utils;
|
||||
import com.baseband.client.command.commands.CreditsCommand;
|
||||
import com.baseband.client.command.commands.HelpCommand;
|
||||
import com.baseband.client.command.commands.ToggleCommand;
|
||||
import com.baseband.client.command.commands.*;
|
||||
import net.minecraftforge.client.event.ClientChatEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
@ -28,6 +26,7 @@ public class CommandManager {
|
|||
commands.add(new CreditsCommand());
|
||||
commands.add(new HelpCommand());
|
||||
commands.add(new ToggleCommand());
|
||||
commands.add(new SetCommand());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -9,8 +9,11 @@ public class CreditsCommand extends Command {
|
|||
|
||||
@Override
|
||||
public String run(String[] args) {
|
||||
return "Base and most of the loader written by JessSystemV, " +
|
||||
"\nJohn200410 helped with the loader. " +
|
||||
"\nTudbuT made the GUI.";
|
||||
return "Credits:" +
|
||||
"\nBase and most of the loader written by JessSystemV, " +
|
||||
"\nJohn200410 helped with the loader, " +
|
||||
"\nTudbuT made the GUI, " +
|
||||
"\nDoogie13 provided the PacketFly.";
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.baseband.client.command.commands;
|
||||
|
||||
import com.baseband.client.Main;
|
||||
import com.baseband.client.BaseBand;
|
||||
import com.baseband.client.command.Command;
|
||||
|
||||
public class HelpCommand extends Command {
|
||||
|
@ -10,7 +10,7 @@ public class HelpCommand extends Command {
|
|||
|
||||
@Override
|
||||
public String run(String[] args) {
|
||||
return "BaseBand Rewrite Build" + Main.buildNumber +
|
||||
return "BaseBand Rewrite B" + BaseBand.buildNumber +
|
||||
"\nCopyright JessSystemV & TudbuT (2023)" +
|
||||
"\nAll rights reserved.";
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package com.baseband.client.command.commands;
|
||||
|
||||
import com.baseband.client.BaseBand;
|
||||
import com.baseband.client.command.Command;
|
||||
import com.baseband.client.module.Module;
|
||||
import com.baseband.client.setting.Setting;
|
||||
|
||||
public class SetCommand extends Command {
|
||||
public SetCommand() {
|
||||
super("set");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String run(String[] argz) {
|
||||
String module;
|
||||
String settingName;
|
||||
String value;
|
||||
try {
|
||||
module = argz[0];
|
||||
settingName = argz[1];
|
||||
value = argz[2];
|
||||
}catch (ArrayIndexOutOfBoundsException e) {
|
||||
return "Command usage, =set ModuleName SettingName Value";
|
||||
}
|
||||
|
||||
Module m = BaseBand.moduleRegistry.getModule(module);
|
||||
|
||||
if(m==null) {
|
||||
return "Cannot find module.";
|
||||
}
|
||||
|
||||
Setting<?> setting = m.getSetting(settingName);
|
||||
if(setting == null) {
|
||||
return "Cannot find setting.";
|
||||
}
|
||||
try {
|
||||
setting.setByClass(value);
|
||||
}catch (Exception e) {
|
||||
return e.getLocalizedMessage();
|
||||
}
|
||||
|
||||
return "Succeeded. (Set "+settingName+" to "+value+")";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package com.baseband.client.command.commands;
|
||||
|
||||
import com.baseband.client.Main;
|
||||
import com.baseband.client.BaseBand;
|
||||
import com.baseband.client.command.Command;
|
||||
import com.baseband.client.module.Module;
|
||||
|
||||
|
@ -14,7 +14,7 @@ public class ToggleCommand extends Command {
|
|||
if (args.length != 1) {
|
||||
return "Please specify a module name.";
|
||||
}
|
||||
Module module = Main.moduleRegistry.getModule(args[0]);
|
||||
Module module = BaseBand.moduleRegistry.getModule(args[0]);
|
||||
if (module == null) {
|
||||
return "Cannot find module.";
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package com.baseband.client.event.events;
|
||||
|
||||
import com.baseband.client.event.CancellableEvent;
|
||||
import net.minecraft.entity.MoverType;
|
||||
|
||||
public class MoveEvent extends CancellableEvent {
|
||||
public MoverType type;
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
|
||||
public MoveEvent(MoverType type, double x, double y, double z) {
|
||||
this.type = type;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package com.baseband.client.event.events;
|
||||
|
||||
import com.baseband.client.event.CancellableEvent;
|
||||
|
||||
public class SafeTickEvent extends CancellableEvent {
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.baseband.client.mixins;
|
||||
|
||||
import net.minecraft.network.play.server.SPacketPlayerPosLook;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(SPacketPlayerPosLook.class)
|
||||
public interface ISPacketPlayerPosLook {
|
||||
|
||||
@Accessor("x")
|
||||
void setX(double x);
|
||||
|
||||
@Accessor("y")
|
||||
void setY(double y);
|
||||
|
||||
@Accessor("z")
|
||||
void setZ(double z);
|
||||
|
||||
@Accessor("yaw")
|
||||
void setYaw(float yaw);
|
||||
|
||||
@Accessor("pitch")
|
||||
void setPitch(float pitch);
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.baseband.client.mixins;
|
||||
|
||||
import com.baseband.client.BaseBand;
|
||||
import com.baseband.client.event.events.MoveEvent;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.entity.MoverType;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(EntityPlayerSP.class)
|
||||
public class MixinEntityPlayerSP extends AbstractClientPlayer {
|
||||
|
||||
public MixinEntityPlayerSP(World worldIn, GameProfile playerProfile) {
|
||||
super(worldIn, playerProfile);
|
||||
}
|
||||
|
||||
|
||||
@Redirect(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/AbstractClientPlayer;move(Lnet/minecraft/entity/MoverType;DDD)V"))
|
||||
public void move(AbstractClientPlayer abstractClientPlayer, MoverType type, double x, double y, double z) {
|
||||
MoveEvent event = new MoveEvent(type, x, y, z);
|
||||
BaseBand.eventBus.publish(event);
|
||||
|
||||
if(!event.isCancelled()) {
|
||||
super.move(event.type, event.x, event.y, event.z);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package com.baseband.client.mixins;
|
||||
|
||||
import com.baseband.client.Main;
|
||||
import com.baseband.client.BaseBand;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
@ -14,6 +14,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
public class MixinMinecraft {
|
||||
@Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;checkGLError(Ljava/lang/String;)V", ordinal = 1, shift = At.Shift.AFTER))
|
||||
private void onInit(CallbackInfo ci) {
|
||||
Main.onInit();
|
||||
BaseBand.onInit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.baseband.client.mixins;
|
||||
|
||||
import com.baseband.client.Main;
|
||||
import com.baseband.client.BaseBand;
|
||||
import com.baseband.client.event.events.PacketEvent;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
|
@ -16,7 +16,7 @@ public class MixinNetworkManager {
|
|||
@Inject(method = "channelRead0", at = @At("HEAD"), cancellable = true)
|
||||
public void channelRead0(ChannelHandlerContext p_channelRead0_1_, Packet<?> p_channelRead0_2_, CallbackInfo ci) {
|
||||
PacketEvent.Read event = new PacketEvent.Read(p_channelRead0_2_);
|
||||
Main.eventBus.publish(event);
|
||||
BaseBand.eventBus.publish(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
ci.cancel();
|
||||
|
@ -25,7 +25,7 @@ public class MixinNetworkManager {
|
|||
@Inject(method = "sendPacket(Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true)
|
||||
public void channelRead0(Packet<?> packetIn, CallbackInfo ci) {
|
||||
PacketEvent.Write event = new PacketEvent.Write(packetIn);
|
||||
Main.eventBus.publish(event);
|
||||
BaseBand.eventBus.publish(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
ci.cancel();
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
package com.baseband.client.module;
|
||||
|
||||
import com.baseband.client.Main;
|
||||
import com.baseband.client.BaseBand;
|
||||
import com.baseband.client.setting.Setting;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Module {
|
||||
String name;
|
||||
boolean isEnabled = false;
|
||||
int key = 0;
|
||||
List<Setting<?>> settings = new ArrayList<>();
|
||||
|
||||
public Module(String name) {
|
||||
this.name = name;
|
||||
|
@ -19,13 +27,39 @@ public class Module {
|
|||
isEnabled=enabled;
|
||||
if(isEnabled) {
|
||||
enable();
|
||||
Main.eventBus.register(this);
|
||||
}else {
|
||||
BaseBand.eventBus.register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
} else {
|
||||
disable();
|
||||
Main.eventBus.unregister(this);
|
||||
BaseBand.eventBus.unregister(this);
|
||||
MinecraftForge.EVENT_BUS.unregister(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
public <T extends Setting<?>> T register(T setting) {
|
||||
settings.add(setting);
|
||||
return setting;
|
||||
}
|
||||
|
||||
public void setSettings(List<Setting<?>> settings) {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
public Setting<?> getSetting(String name) {
|
||||
for (Setting<?> setting : settings) {
|
||||
if (setting != null && setting.getName() != null && setting.getName().equalsIgnoreCase(name)) {
|
||||
return setting;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Setting<?>> getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public void setKey(int key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
|
|
@ -1,9 +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.PacketTest;
|
||||
import com.baseband.client.module.modules.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
@ -24,8 +21,10 @@ public class ModuleRegistry {
|
|||
modules.add(new Brightness());
|
||||
modules.add(new PacketTest());
|
||||
modules.add(new HUD());
|
||||
modules.add(new ClickGUI());
|
||||
//modules.add(new ClickGUI());
|
||||
modules.add(new PacketTest());
|
||||
modules.add(new PacketFly());
|
||||
modules.add(new Speed());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.baseband.client.module.modules;
|
||||
|
||||
import com.baseband.client.Main;
|
||||
import com.baseband.client.BaseBand;
|
||||
import com.baseband.client.module.Module;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
|
@ -11,14 +11,14 @@ public class Brightness extends Module {
|
|||
|
||||
|
||||
public void enable() {
|
||||
if(Main.isIngame()) {
|
||||
if(BaseBand.isIngame()) {
|
||||
Minecraft.getMinecraft().gameSettings.gammaSetting=100f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void disable() {
|
||||
if(Main.isIngame()) {
|
||||
if(BaseBand.isIngame()) {
|
||||
Minecraft.getMinecraft().gameSettings.gammaSetting=1f;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.baseband.client.module.modules;
|
||||
|
||||
import com.baseband.client.Main;
|
||||
import com.baseband.client.BaseBand;
|
||||
import com.baseband.client.module.Module;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
|
@ -18,11 +18,11 @@ public class HUD extends Module {
|
|||
@SubscribeEvent
|
||||
public void text(RenderGameOverlayEvent.Text e) {
|
||||
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
fr.drawStringWithShadow("BaseBand B" + Main.buildNumber, 2, 2, Color.GREEN.getRGB());
|
||||
fr.drawStringWithShadow("BaseBand B" + BaseBand.buildNumber, 2, 2, Color.GREEN.getRGB());
|
||||
int y = 12;
|
||||
for (Module m : Main.moduleRegistry.getModuleList()) {
|
||||
for (Module m : BaseBand.moduleRegistry.getModuleList()) {
|
||||
if(m.isEnabled()) {
|
||||
fr.drawStringWithShadow(m.getName(), 2, 2, Color.GREEN.getRGB());
|
||||
fr.drawStringWithShadow(m.getName(), 2, y, Color.GREEN.getRGB());
|
||||
y=y+fr.FONT_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,286 @@
|
|||
package com.baseband.client.module.modules;
|
||||
|
||||
import com.baseband.client.event.Subscribe;
|
||||
import com.baseband.client.event.events.MoveEvent;
|
||||
import com.baseband.client.event.events.PacketEvent;
|
||||
import com.baseband.client.mixins.ISPacketPlayerPosLook;
|
||||
import com.baseband.client.module.Module;
|
||||
import com.baseband.client.setting.NumberSetting;
|
||||
import net.minecraft.network.play.client.CPacketConfirmTeleport;
|
||||
import net.minecraft.network.play.client.CPacketPlayer;
|
||||
import net.minecraft.network.play.server.SPacketPlayerPosLook;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class PacketFly extends Module {
|
||||
//Doogie13 made this, ported in with permission
|
||||
public PacketFly() {
|
||||
super("PacketFly");
|
||||
}
|
||||
|
||||
|
||||
// setting for Factor with bounds 0.1 to 5.0 and a precision of 0.1
|
||||
// for 2b2tpvp.net, default value of 1.3 is recommended when using this for flying
|
||||
// when phasing, you may wish to use something closer to 2 or 3
|
||||
final NumberSetting<Float> factor = register(new NumberSetting<>("Factor", 1.3f, 0.1f, 5f));
|
||||
|
||||
final NumberSetting<Integer> boundValue = register(new NumberSetting<>("Bounds", 512, -1024, 1024));
|
||||
|
||||
// current teleport ID
|
||||
int tpID = -1;
|
||||
|
||||
// set of packets we allow
|
||||
Set<CPacketPlayer> allowedCPacketPlayers = new HashSet<>();
|
||||
|
||||
|
||||
// map of IDs and positions where we can ignore server rubberbands
|
||||
HashMap<Integer, Vec3d> allowedPositionsAndIDs = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
// clear these so they don't take up memory
|
||||
allowedCPacketPlayers.clear();
|
||||
allowedPositionsAndIDs.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
// we will not have been tracking tpID so we must reset it
|
||||
tpID = -1;
|
||||
}
|
||||
|
||||
// this can be any event which will let us set player motion
|
||||
@Subscribe
|
||||
public void onMotion(MoveEvent event) {
|
||||
|
||||
// first we must get motion
|
||||
double motionX, motionY = 0, motionZ;
|
||||
|
||||
// store whether we are anti-kicking
|
||||
boolean antiKicking = false;
|
||||
|
||||
// Handle motion Y
|
||||
// check if we need to do anti-kick
|
||||
// we do not need to anti-kick when inside blocks
|
||||
if (mc.player.ticksExisted % 10 == 0 && !mc.world.collidesWithAnyBlock(mc.player.getEntityBoundingBox())) {
|
||||
// 0.04 is the distance we must fall before being kicked for flying
|
||||
// net.minecraft.network.NetHandlerPlayServer line 182
|
||||
motionY = -.04;
|
||||
antiKicking = true;
|
||||
} else {
|
||||
|
||||
// we MUST allow the player to prioritise going up as it allows us to manipulate our bounding box with sneaking
|
||||
// NCP will flag SurvivalFly for anything larger than 0.0625 so we use 0.0624 to be on the safe side
|
||||
// I believe this to be because the server doesn't process movement slower than 0.0625 in the same way but I can't find evidence for this
|
||||
if (mc.gameSettings.keyBindJump.isKeyDown())
|
||||
motionY = .0624;
|
||||
else if (mc.gameSettings.keyBindSneak.isKeyDown())
|
||||
motionY = -.0624;
|
||||
|
||||
}
|
||||
|
||||
// Handle Motion X, Z
|
||||
// we will handle them as one speed and split them into X and Z based on rotation and keys pressed
|
||||
double motionH;
|
||||
|
||||
// If we are inside blocks, we must use speed slower than 0.0625 so vanilla doesn't set us back
|
||||
// net.minecraft.network.NetHandlerPlayServer line 560
|
||||
|
||||
boolean walls = mc.world.collidesWithAnyBlock(mc.player.getEntityBoundingBox());
|
||||
|
||||
if (walls) {
|
||||
|
||||
motionH = .0624;
|
||||
|
||||
if (motionY != 0) {
|
||||
|
||||
// this means the hypotenuse of our position is always under .625;
|
||||
double multiply = 1 / Math.sqrt(2);
|
||||
|
||||
motionY *= multiply;
|
||||
motionH *= multiply;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// base air move speed
|
||||
motionH = .2873;
|
||||
|
||||
// we cannot move up if we are moving horizontally since NCP will notice
|
||||
boolean movingHorizontally = mc.player.moveForward != 0 || mc.player.moveStrafing != 0;
|
||||
|
||||
if (movingHorizontally)
|
||||
motionY = Math.min(0, motionY);
|
||||
|
||||
}
|
||||
|
||||
// we now split motionH into motionX and motionZ
|
||||
// this should really be in a util
|
||||
// we use dir because tradition
|
||||
double[] dir = new double[]{0,0};
|
||||
|
||||
// if we aren't moving we can just use 0 motion
|
||||
if (!(mc.player.moveForward == 0 && mc.player.moveStrafing == 0)) {
|
||||
|
||||
int strafing = 0;
|
||||
int forward = 0;
|
||||
|
||||
// make moveForward and moveStrafing rounded to the nearest 1
|
||||
if (mc.player.moveStrafing < 0)
|
||||
strafing = -1;
|
||||
else if (mc.player.moveStrafing > 0)
|
||||
strafing = 1;
|
||||
|
||||
if (mc.player.moveForward < 0)
|
||||
forward = -1;
|
||||
else if (mc.player.moveForward > 0)
|
||||
forward = 1;
|
||||
|
||||
float strafe = 90 * strafing;
|
||||
strafe *= (forward != 0F) ? forward * 0.5F : 1;
|
||||
|
||||
float yaw = mc.player.rotationYaw - strafe;
|
||||
yaw -= (mc.player.moveForward < 0F) ? 180 : 0;
|
||||
|
||||
// to radians
|
||||
yaw *= 1 / (180 / Math.PI);
|
||||
|
||||
// get X and Z split
|
||||
double x = (-Math.sin(yaw) * motionH);
|
||||
double z = (Math.cos(yaw) * motionH);
|
||||
|
||||
dir = new double[]{x, z};
|
||||
|
||||
}
|
||||
|
||||
motionX = dir[0];
|
||||
motionZ = dir[1];
|
||||
|
||||
// get the lowest possible factor
|
||||
int factorInt = (int) Math.floor(factor.getValue());
|
||||
|
||||
// check if we should send more packets
|
||||
// decimal place is how much we should factorise more
|
||||
if (mc.player.ticksExisted % 10 < 10 * (factor.getValue() - factorInt))
|
||||
factorInt++;
|
||||
|
||||
// send packets
|
||||
Vec3d motion = send(motionX, motionY, motionZ, antiKicking, factorInt);
|
||||
|
||||
event.x=(motion.x);
|
||||
event.y=(motion.y);
|
||||
event.z=(motion.z);
|
||||
|
||||
// allows us to phase
|
||||
mc.player.noClip = true;
|
||||
|
||||
}
|
||||
|
||||
// this can be repeated multiple times to move faster
|
||||
Vec3d send(double motionX, double motionY, double motionZ, boolean antiKick, int factor) {
|
||||
|
||||
for (int i = 1; i < factor + 1; i++) {
|
||||
|
||||
// only anti-kick once per loop as doing it multiple times is a waste of height
|
||||
if (antiKick && factor != 1)
|
||||
motionY = 0;
|
||||
|
||||
// get the absolute position
|
||||
Vec3d pos = mc.player.getPositionVector().add(motionX * i, motionY * i, motionZ * i);
|
||||
|
||||
// create a movement packet
|
||||
// we use onGround true to prevent fall damage on some servers
|
||||
CPacketPlayer.Position packet = new CPacketPlayer.Position(pos.x, pos.y, pos.z, true);
|
||||
|
||||
// create a "bounds" packet
|
||||
// this is just any packet over 100 blocks away from current position or 300 when elytra is open
|
||||
// net.minecraft.network.NetHandlerPlayServer line 529
|
||||
CPacketPlayer.Position bounds = new CPacketPlayer.Position(pos.x, pos.y + boundValue.getValue(), pos.z, true);
|
||||
|
||||
// allow normal packet and "bounds" packet to be sent (handled later)
|
||||
allowedCPacketPlayers.add(packet);
|
||||
allowedCPacketPlayers.add(bounds);
|
||||
|
||||
// send packets
|
||||
mc.player.connection.sendPacket(packet);
|
||||
mc.player.connection.sendPacket(bounds);
|
||||
|
||||
// we must have a correct teleport ID to save, we use the "bounds" packet to get one anyways if not
|
||||
if (tpID < 0)
|
||||
break;
|
||||
|
||||
// iterate tpID as bounds will have caused rubberband
|
||||
tpID++;
|
||||
|
||||
// send a tpID packet confirming the bounds packet
|
||||
mc.player.connection.sendPacket(new CPacketConfirmTeleport(tpID));
|
||||
|
||||
// add move vector and tpID to the map
|
||||
allowedPositionsAndIDs.put(tpID, pos);
|
||||
}
|
||||
|
||||
// return a vec of our motion
|
||||
return new Vec3d(motionX * factor, motionY * (antiKick ? 1 : factor), motionZ * factor);
|
||||
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPacketSend(PacketEvent.Write event) {
|
||||
|
||||
// we only cancel CPacketPlayers
|
||||
if (event.getPacket() instanceof CPacketPlayer)
|
||||
// check if we are allowing the packet through
|
||||
// cancel if not
|
||||
if (!allowedCPacketPlayers.contains((CPacketPlayer) event.getPacket()))
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPacketReceive(PacketEvent.Write event) {
|
||||
|
||||
// check if the packet is a player pos look
|
||||
if (event.getPacket() instanceof SPacketPlayerPosLook) {
|
||||
|
||||
SPacketPlayerPosLook packet = (SPacketPlayerPosLook) event.getPacket();
|
||||
int id = packet.getTeleportId();
|
||||
|
||||
// check if saved history contains the packet ID
|
||||
if (allowedPositionsAndIDs.containsKey(id)) {
|
||||
|
||||
// check if saved packet with that ID has the corresponding position
|
||||
// this would mean the packet lines up and we can ignore the packet
|
||||
if (allowedPositionsAndIDs.get(id).equals(new Vec3d(packet.getX(), packet.getY(), packet.getZ()))) {
|
||||
|
||||
// remove the entry
|
||||
allowedPositionsAndIDs.remove(id);
|
||||
|
||||
// confirm the packet
|
||||
mc.player.connection.sendPacket(new CPacketConfirmTeleport(id));
|
||||
|
||||
// cancel the event
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// update our teleport ID
|
||||
tpID = id;
|
||||
|
||||
// prevent jittery rotation
|
||||
((ISPacketPlayerPosLook) packet).setYaw(mc.player.rotationYaw);
|
||||
((ISPacketPlayerPosLook) packet).setPitch(mc.player.rotationPitch);
|
||||
|
||||
// we MUST confirm this packet
|
||||
mc.player.connection.sendPacket(new CPacketConfirmTeleport(id));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -4,12 +4,35 @@ import com.baseband.client.Utils;
|
|||
import com.baseband.client.event.Subscribe;
|
||||
import com.baseband.client.event.events.PacketEvent;
|
||||
import com.baseband.client.module.Module;
|
||||
import com.baseband.client.setting.EnumSetting;
|
||||
import com.baseband.client.setting.NumberSetting;
|
||||
import com.baseband.client.setting.Setting;
|
||||
import com.baseband.client.setting.StringSetting;
|
||||
|
||||
public class PacketTest extends Module {
|
||||
public PacketTest() {
|
||||
super("PacketTest");
|
||||
}
|
||||
|
||||
Setting<Integer> intSetting = register(new NumberSetting<>("IntSetting", 1,2,0));
|
||||
|
||||
Setting<Float> floatSetting = register(new NumberSetting<>("FloatSetting",1f,2f,0f));
|
||||
|
||||
Setting<Double> doubleSetting = register(new NumberSetting<>("DoubleSetting",1d,2d,0d));
|
||||
|
||||
Setting<String> stringSetting = register(new StringSetting("StringSetting","s"));
|
||||
|
||||
Setting<Level> levelSetting = register(new EnumSetting<>("Level", Level.HIGH));
|
||||
|
||||
enum Level {
|
||||
LOW,
|
||||
MEDIUM,
|
||||
HIGH
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void handleEventA(PacketEvent.Read event) {
|
||||
Utils.sendChatMessage(event.getPacket().getClass().getName());
|
||||
|
|
|
@ -0,0 +1,158 @@
|
|||
package com.baseband.client.module.modules;
|
||||
|
||||
import com.baseband.client.MotionUtil;
|
||||
import com.baseband.client.event.Subscribe;
|
||||
import com.baseband.client.event.events.MoveEvent;
|
||||
import com.baseband.client.event.events.PacketEvent;
|
||||
import com.baseband.client.event.events.SafeTickEvent;
|
||||
import com.baseband.client.module.Module;
|
||||
import com.baseband.client.setting.BooleanSetting;
|
||||
import com.baseband.client.setting.NumberSetting;
|
||||
import net.minecraft.network.play.server.SPacketEntityVelocity;
|
||||
import net.minecraft.network.play.server.SPacketExplosion;
|
||||
import net.minecraft.network.play.server.SPacketPlayerPosLook;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class Speed extends Module {
|
||||
public Speed() {
|
||||
super("Speed");
|
||||
}
|
||||
|
||||
|
||||
//final ModeSetting bunnyMode = register(new ModeSetting("NCP Mode", "Normal", Arrays.asList("Normal", "Updated")).setDescription("How to accelerate when jumping"));
|
||||
final BooleanSetting boost = register(new BooleanSetting("Boost", true));
|
||||
final NumberSetting<Float> boostReduction = register(new NumberSetting<>("Boost Reduction", 0f, 0f, 1f));
|
||||
|
||||
boolean slow = false;
|
||||
int jumps = 0;
|
||||
double bunnySpeed = .2873;
|
||||
int groundTick = 0;
|
||||
|
||||
double lastDist = 0;
|
||||
double dmgBoost = 0;
|
||||
boolean isDmgBoostAbsolute = false;
|
||||
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
bunnySpeed = lastDist = dmgBoost = jumps = 0;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public final void onUpdate(SafeTickEvent event) {
|
||||
//parent.setTickLength(50f / 1.088f);
|
||||
lastDist = Math.hypot(mc.player.posX - mc.player.prevPosX, mc.player.posZ - mc.player.prevPosZ);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPacketReceive(PacketEvent.Read event) {
|
||||
|
||||
if (event.getPacket() instanceof SPacketPlayerPosLook) {
|
||||
bunnySpeed = 0;
|
||||
}
|
||||
|
||||
if (mc.player.isInWater() || mc.player.isInLava())
|
||||
return;
|
||||
|
||||
if (!boost.getValue())
|
||||
return;
|
||||
|
||||
if (event.getPacket() instanceof SPacketExplosion) {
|
||||
|
||||
SPacketExplosion packet = (SPacketExplosion) event.getPacket();
|
||||
|
||||
dmgBoost = Math.hypot(packet.getMotionX(), packet.getMotionZ());
|
||||
|
||||
} else if (event.getPacket() instanceof SPacketEntityVelocity) {
|
||||
|
||||
SPacketEntityVelocity packet = (SPacketEntityVelocity) event.getPacket();
|
||||
|
||||
if (packet.getEntityID() == mc.player.getEntityId()) {
|
||||
dmgBoost = Math.hypot(packet.getMotionX() / 8000D, packet.getMotionZ() / 8000D);
|
||||
isDmgBoostAbsolute = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onMove(MoveEvent event) {
|
||||
|
||||
if (mc.player.isInWater() || mc.player.isInLava())
|
||||
return;
|
||||
|
||||
double xzSpeed;
|
||||
|
||||
double base = MotionUtil.applySpeed(.2873);
|
||||
|
||||
if (mc.player.moveForward == 0 && mc.player.moveStrafing == 0 || mc.player.collidedHorizontally)
|
||||
jumps = 0;
|
||||
|
||||
if (mc.player.onGround && (mc.player.moveForward != 0 || mc.player.moveStrafing != 0)) {
|
||||
|
||||
bunnySpeed = Math.max(
|
||||
// current speed multiplied by a condensed version of mc friction code
|
||||
bunnySpeed = .2 + bunnySpeed * (double) (mc.world.getBlockState(BlockPos.PooledMutableBlockPos.retain(mc.player.posX, mc.player.getEntityBoundingBox().minY - 1.0D, mc.player.posZ).setPos(mc.player.posX, mc.player.getEntityBoundingBox().minY - 1.0D, mc.player.posZ)).getBlock().getSlipperiness(mc.world.getBlockState(BlockPos.PooledMutableBlockPos.retain(mc.player.posX, mc.player.getEntityBoundingBox().minY - 1.0D, mc.player.posZ).setPos(mc.player.posX, mc.player.getEntityBoundingBox().minY - 1.0D, mc.player.posZ)), mc.world, BlockPos.PooledMutableBlockPos.retain(mc.player.posX, mc.player.getEntityBoundingBox().minY - 1.0D, mc.player.posZ), mc.player) * 0.91F),
|
||||
getBunnySpeed(MotionUtil.applySpeed(.2873))
|
||||
);
|
||||
|
||||
// jump
|
||||
event.y=(mc.player.motionY = MotionUtil.applyJumpBoost(.42F));
|
||||
|
||||
groundTick = 0;
|
||||
slow = true;
|
||||
|
||||
if (++jumps == 1)
|
||||
bunnySpeed *= .95;
|
||||
|
||||
} else if (slow || mc.player.collidedHorizontally) {
|
||||
|
||||
// https://github.com/NoCheatPlus/NoCheatPlus/blob/f7b2c017fd66838ed2542fba483d7268ff01c2cf/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/player/SurvivalFly.java#L1692
|
||||
bunnySpeed -= 0.66 * base;
|
||||
slow = false;
|
||||
|
||||
} else
|
||||
// https://github.com/NoCheatPlus/NoCheatPlus/blob/f7b2c017fd66838ed2542fba483d7268ff01c2cf/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/player/SurvivalFly.java#L1698
|
||||
// we use a little less so that we don't flag
|
||||
bunnySpeed = lastDist - lastDist / 159;
|
||||
|
||||
double oldSpeed = bunnySpeed;
|
||||
if (dmgBoost >= 0) {
|
||||
if (isDmgBoostAbsolute) {
|
||||
bunnySpeed = dmgBoost - ((dmgBoost - bunnySpeed) * (1 - boostReduction.getValue()));
|
||||
} else {
|
||||
bunnySpeed += dmgBoost * (1 - boostReduction.getValue());
|
||||
}
|
||||
dmgBoost = 0;
|
||||
}
|
||||
|
||||
bunnySpeed = Math.max(oldSpeed, bunnySpeed);
|
||||
|
||||
xzSpeed = bunnySpeed = Math.max(base, bunnySpeed);
|
||||
|
||||
// should never happen
|
||||
|
||||
//event.setMotion(true);
|
||||
|
||||
if (xzSpeed == Double.MIN_VALUE)
|
||||
return;
|
||||
|
||||
double[] dir = MotionUtil.getMotion(xzSpeed);
|
||||
event.x=(dir[0]);
|
||||
event.z=(dir[1]);
|
||||
|
||||
}
|
||||
|
||||
double getBunnySpeed(double base) {
|
||||
|
||||
// prevent too aggressive acceleration causing flags
|
||||
base = Math.min(1, base);
|
||||
|
||||
//if (bunnyMode.getValue().equals("Normal"))
|
||||
return base * 1.935;
|
||||
//else
|
||||
// return base * 1.87;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.baseband.client.setting;
|
||||
|
||||
public class BooleanSetting extends Setting<Boolean> {
|
||||
public BooleanSetting(String name, Boolean value) {
|
||||
super(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setByClass(String value) {
|
||||
this.setValue(Boolean.parseBoolean(value));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.baseband.client.setting;
|
||||
|
||||
public class EnumSetting <T extends Enum<?>> extends Setting<T> {
|
||||
public EnumSetting(String name, T value) {
|
||||
super(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setByClass(String value) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package com.baseband.client.setting;
|
||||
|
||||
public class NumberSetting<T extends Number> extends Setting<T> {
|
||||
|
||||
T max;
|
||||
T min;
|
||||
|
||||
|
||||
public NumberSetting(String name, T value, T max, T min) {
|
||||
super(name, value);
|
||||
this.max= max;
|
||||
this.min = min;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setByClass(String value) {
|
||||
try {
|
||||
T parsedValue = parseValue(value);
|
||||
this.setValue(parsedValue);
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.println("Invalid value format for " + this.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private T parseValue(String value) {
|
||||
if (getValue() instanceof Integer) {
|
||||
return (T) Integer.valueOf(value);
|
||||
} else if (getValue() instanceof Double) {
|
||||
return (T) Double.valueOf(value);
|
||||
} else if (getValue() instanceof Float) {
|
||||
return (T) Float.valueOf(value);
|
||||
} else if (getValue() instanceof Long) {
|
||||
return (T) Long.valueOf(value);
|
||||
} // Add additional checks for other Number subclasses as needed
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setValue(T value) {
|
||||
if (max != null && min != null) {
|
||||
Number maxNumber = max;
|
||||
Number minNumber = min;
|
||||
|
||||
double valueToMax = Math.abs(value.doubleValue() - maxNumber.doubleValue());
|
||||
double valueToMin = Math.abs(value.doubleValue() - minNumber.doubleValue());
|
||||
|
||||
if (valueToMax < valueToMin) {
|
||||
this.value = max;
|
||||
} else {
|
||||
this.value = min;
|
||||
}
|
||||
|
||||
} else {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public T getMin() {
|
||||
return min;
|
||||
}
|
||||
|
||||
public T getMax() {
|
||||
return max;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.baseband.client.setting;
|
||||
|
||||
public abstract class Setting <T> {
|
||||
String name;
|
||||
T value;
|
||||
|
||||
|
||||
public Setting(String name, T value) {
|
||||
this.name=name;
|
||||
this.value=value;
|
||||
}
|
||||
|
||||
public abstract void setByClass(String value);
|
||||
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(T value) {
|
||||
this.value=value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.baseband.client.setting;
|
||||
|
||||
public class StringSetting extends Setting<String> {
|
||||
public StringSetting(String name, String value) {
|
||||
super(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setByClass(String value) {
|
||||
this.setValue(value);
|
||||
}
|
||||
}
|
|
@ -5,8 +5,10 @@
|
|||
"minVersion": "0",
|
||||
"refmap": "mixins.baseband.refmap.json",
|
||||
"mixins": [
|
||||
"MixinMinecraft",
|
||||
"MixinForgeBus",
|
||||
"MixinNetworkManager"
|
||||
"MixinMinecraft",
|
||||
"MixinNetworkManager",
|
||||
"MixinEntityPlayerSP",
|
||||
"ISPacketPlayerPosLook"
|
||||
]
|
||||
}
|
|
@ -1,22 +1,10 @@
|
|||
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();
|
||||
}
|
||||
});
|
||||
public static void main(String[] args) {
|
||||
SwingUtilities.invokeLater(InstallerApp::new);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ public class InstallerApp {
|
|||
JOptionPane.showMessageDialog(loginFrame, "Your BaseBand account has been banned\nPlease contact support.", "BaseBand Installer", JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(0);
|
||||
}else if (responseInt == -6){
|
||||
JOptionPane.showMessageDialog(loginFrame, "Your Password has been Reset\nPlease re-run the installer.", "BaseBand Installer", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(loginFrame, "Your Password has been Reset\nPlease re-run the installer.", "BaseBand Installer", JOptionPane.INFORMATION_MESSAGE);
|
||||
System.exit(0);
|
||||
} else{
|
||||
JOptionPane.showMessageDialog(loginFrame, "Invalid username or password.", "BaseBand Installer", JOptionPane.ERROR_MESSAGE);
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
package org.baseband.installer.util.library;
|
||||
|
||||
import org.baseband.installer.util.minecraft.MinecraftFiles;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
|
||||
import static org.baseband.installer.Installer.jarPath;
|
||||
import static org.baseband.installer.Installer.jarUrl;
|
||||
|
||||
public class LibraryInstaller {
|
||||
|
||||
public static void download() throws Exception {
|
||||
File f = new File(MinecraftFiles.getLibraries() + jarPath);
|
||||
if (!f.exists()) {
|
||||
try {
|
||||
ReadableByteChannel rbc = Channels.newChannel(jarUrl.openStream());
|
||||
FileOutputStream fos = new FileOutputStream(MinecraftFiles.getLibraries() + jarPath);
|
||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||
System.out.println("Successfully Downloaded Loader Jar");
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("The URL Did Not Find A Valid Jar To Download, Skipping");
|
||||
}
|
||||
} else {
|
||||
System.out.println("The Loader Jar Has Already Been Downloaded");
|
||||
}
|
||||
}
|
||||
|
||||
public static URL toUrl(String s) {
|
||||
try {
|
||||
return new URL(s);
|
||||
} catch (MalformedURLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,25 +4,6 @@ import java.io.File;
|
|||
|
||||
public class MinecraftFiles {
|
||||
private static final String os = System.getProperty("os.name").toLowerCase();
|
||||
private static final String minecraft = getMinecraft();
|
||||
private static String libraries;
|
||||
private static String versions;
|
||||
|
||||
public static String getMinecraft() {
|
||||
String minecraft = null;
|
||||
|
||||
assert os != null;
|
||||
|
||||
if (os.contains("nux")) {
|
||||
minecraft = System.getProperty("user.home") + "/.minecraft/";
|
||||
} else if (os.contains("darwin") || os.contains("mac")) {
|
||||
minecraft = System.getProperty("user.home") + "/Library/Application Support/minecraft/";
|
||||
} else if (os.contains("win")) {
|
||||
minecraft = System.getenv("APPDATA") + File.separator + ".minecraft" + File.separator;
|
||||
}
|
||||
|
||||
return minecraft;
|
||||
}
|
||||
|
||||
public static String getMinecraftMods() {
|
||||
String minecraft = null;
|
||||
|
@ -39,20 +20,4 @@ public class MinecraftFiles {
|
|||
|
||||
return minecraft;
|
||||
}
|
||||
|
||||
public static String getVersions() {
|
||||
if (minecraft != null) {
|
||||
versions = minecraft + "versions" + File.separator;
|
||||
}
|
||||
return versions;
|
||||
}
|
||||
|
||||
public static String getLibraries() {
|
||||
getMinecraft();
|
||||
|
||||
if (minecraft != null) {
|
||||
libraries = minecraft + "libraries" + File.separator;
|
||||
}
|
||||
return libraries;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
package org.baseband.installer.util.version;
|
||||
|
||||
import org.baseband.installer.Installer;
|
||||
import org.baseband.installer.util.minecraft.MinecraftFiles;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Objects;
|
||||
|
||||
public class VersionInstaller {
|
||||
|
||||
public static JSONObject parseJSONFile(String filename) throws JSONException, IOException {
|
||||
String content = new String(Files.readAllBytes(Paths.get(filename)));
|
||||
return new JSONObject(content);
|
||||
}
|
||||
|
||||
public static void injectVersionJson() throws IOException {
|
||||
File file2 = new File(MinecraftFiles.getVersions());
|
||||
if (file2.isDirectory()) {
|
||||
for (File file1 : Objects.requireNonNull(file2.listFiles())) {
|
||||
if (!file1.isDirectory()) continue;
|
||||
for (File file : Objects.requireNonNull(file1.listFiles())) {
|
||||
if (!file.getName().contains(".json") || !file.getName().contains("1.12.2") || !file.getName().contains("forge"))
|
||||
continue;
|
||||
|
||||
String path = String.valueOf(Paths.get(file.getAbsolutePath()));
|
||||
|
||||
editVersionArgs(path);
|
||||
editVersionLibrarys(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void editVersionArgs(String path) throws IOException {
|
||||
JSONObject obj = parseJSONFile(path);
|
||||
|
||||
String args = (String) obj.get("minecraftArguments");
|
||||
if (!args.contains("--tweakClass " + Installer.mainClassPath)) {
|
||||
obj.remove("minecraftArguments");
|
||||
obj.put("minecraftArguments", args + " --tweakClass " + Installer.mainClassPath);
|
||||
|
||||
Files.write(Paths.get(path), new JSONObject(obj.toString()).toString(2).getBytes());
|
||||
}
|
||||
}
|
||||
|
||||
public static void editVersionLibrarys(String path) throws IOException {
|
||||
JSONObject obj = parseJSONFile(path);
|
||||
JSONArray arr = obj.getJSONArray("libraries");
|
||||
String args = String.valueOf(obj);
|
||||
|
||||
if (!args.contains(convertPath(Installer.jarPath))) {
|
||||
JSONObject injectorJson = new JSONObject();
|
||||
|
||||
injectorJson.put("name", Installer.jarPath);
|
||||
|
||||
JSONArray ModifiedArray = arr.put(injectorJson);
|
||||
JSONObject newJson = obj.put("libraries", ModifiedArray);
|
||||
|
||||
Files.write(Paths.get(path), new JSONObject(newJson.toString()).toString(4).getBytes());
|
||||
System.out.println("Successfully Added Args To The Forge JSON File");
|
||||
} else {
|
||||
System.out.println("The Version Json Has Already Been Injected, Skipping");
|
||||
}
|
||||
}
|
||||
|
||||
public static String convertPath(String path) {
|
||||
String[] split = path.split("/");
|
||||
return split[0] + "." + split[1] + ":" + split[2] + ":" + split[3];
|
||||
}
|
||||
}
|
|
@ -4,23 +4,18 @@ import net.minecraft.launchwrapper.Launch;
|
|||
import org.baseband.launcher.Tweaker;
|
||||
import org.baseband.launcher.util.CustomClassloader;
|
||||
import org.baseband.launcher.util.HWID;
|
||||
import org.baseband.launcher.util.Key;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.reflect.Reflection;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.SecretKeyFactory;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.PBEKeySpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.swing.*;
|
||||
import java.io.*;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.Socket;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.spec.KeySpec;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.*;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
@ -28,6 +23,9 @@ import java.util.zip.ZipInputStream;
|
|||
|
||||
public class Loader {
|
||||
|
||||
public static Key classKey;
|
||||
public static Key objectKey;
|
||||
|
||||
public static void initiate() {
|
||||
try {
|
||||
//Socket socket = new Socket("127.0.0.1", 31212);
|
||||
|
@ -64,16 +62,33 @@ public class Loader {
|
|||
"\nPlease contact support for more details.", JOptionPane.ERROR_MESSAGE, true);
|
||||
}
|
||||
|
||||
//Set Class and Object encryption instances
|
||||
Key communicationKey = new Key(ticket);
|
||||
classKey = new Key();
|
||||
objectKey = new Key();
|
||||
|
||||
|
||||
if (System.getProperty("com.bb.debugKey") != null) {
|
||||
if (System.getProperty("com.bb.debugKey").equalsIgnoreCase("true")) {
|
||||
Tweaker.log.info("Debug via Java Argument \"-Dcom.bb.debugKey=true\"");
|
||||
communicationKey.setDebug(true);
|
||||
classKey.setDebug(true);
|
||||
objectKey.setDebug(true);
|
||||
}
|
||||
}
|
||||
|
||||
outputF.writeUTF("loader");
|
||||
outputF.writeUTF(username);
|
||||
outputF.writeUTF(password);
|
||||
outputF.writeUTF(HWID.generate());
|
||||
outputF.writeUTF(communicationKey.encryptString(username));
|
||||
outputF.writeUTF(communicationKey.encryptString(password));
|
||||
outputF.writeUTF(communicationKey.encryptString(HWID.generate()));
|
||||
|
||||
boolean dump = dumpDetected();
|
||||
outputF.writeBoolean(dump);
|
||||
outputF.writeUTF("reason"); //TODO: make this return reason
|
||||
|
||||
|
||||
|
||||
|
||||
int responseCode = inputF.readInt();
|
||||
|
||||
switch (responseCode) {
|
||||
|
@ -84,7 +99,7 @@ public class Loader {
|
|||
}
|
||||
|
||||
case -2: {
|
||||
message("HWID Reset.","Your HWID has been reset.", JOptionPane.INFORMATION_MESSAGE, false);
|
||||
Tweaker.log.info("HWID Reset, Authenticated.");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -125,7 +140,24 @@ public class Loader {
|
|||
Map<String, byte[]> classCache = new HashMap<>();
|
||||
Map<String, byte[]> resources = new HashMap<>();
|
||||
|
||||
try (ZipInputStream zipStream = new ZipInputStream(inputF)) {
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
||||
int l = inputF.readInt();
|
||||
byte[] buf = new byte[1024];
|
||||
int amt;
|
||||
while (out.size() != l) {
|
||||
amt = socket.getInputStream().read(buf);
|
||||
out.write(buf, 0, amt);
|
||||
}
|
||||
|
||||
InputStream input = new ByteArrayInputStream(out.toByteArray());
|
||||
//Encryption!
|
||||
//Nope!
|
||||
|
||||
|
||||
|
||||
try (ZipInputStream zipStream = new ZipInputStream(input)) {
|
||||
ZipEntry zipEntry;
|
||||
while ((zipEntry = zipStream.getNextEntry()) != null) {
|
||||
byte[] buffer = new byte[1024];
|
||||
|
@ -139,7 +171,7 @@ public class Loader {
|
|||
|
||||
|
||||
if (zipEntry.getName().endsWith(".class")) {
|
||||
classCache.put(zipEntry.getName().replace(".class", "").replace('/', '.'), encrypt(bos.toByteArray()));
|
||||
classCache.put(zipEntry.getName().replace(".class", "").replace('/', '.'), classKey.encryptByte(bos.toByteArray()));
|
||||
} else {
|
||||
resources.put(zipEntry.getName(), bos.toByteArray());
|
||||
}
|
||||
|
@ -170,9 +202,11 @@ public class Loader {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
socket.close();
|
||||
Tweaker.log.info("Loaded classes.");
|
||||
Tweaker.latch.countDown();
|
||||
} catch (Exception ignored) {
|
||||
ignored.printStackTrace();
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
@ -224,7 +258,7 @@ public class Loader {
|
|||
return true;
|
||||
}
|
||||
|
||||
getUnsafe().defineClass("sun.instrument.InstrumentationImpl", EMPTY_CLASS_BYTES, 0, EMPTY_CLASS_BYTES.length, null, null);
|
||||
Objects.requireNonNull(getUnsafe()).defineClass("sun.instrument.InstrumentationImpl", EMPTY_CLASS_BYTES, 0, EMPTY_CLASS_BYTES.length, null, null);
|
||||
|
||||
// this is for testing purposes to make sure it's actually loaded
|
||||
try {
|
||||
|
@ -236,53 +270,10 @@ public class Loader {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static byte[] key = null;
|
||||
public static byte[] encrypt(byte[] bytes) {
|
||||
if(key==null) {
|
||||
SecureRandom rd = new SecureRandom();
|
||||
byte[] arr = new byte[127];
|
||||
rd.nextBytes(arr);
|
||||
key=arr;
|
||||
}
|
||||
|
||||
try {
|
||||
final IvParameterSpec ivspec = new IvParameterSpec(new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
|
||||
final SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");
|
||||
final KeySpec spec = new PBEKeySpec(Arrays.toString(key).toCharArray(), "ssshhhhhhhhhhh!!!!".getBytes(), 65536, 256);
|
||||
final SecretKey tmp = factory.generateSecret(spec);
|
||||
final SecretKeySpec secretKey = new SecretKeySpec(tmp.getEncoded(), "AES");
|
||||
|
||||
final Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey, ivspec);
|
||||
|
||||
return Base64.getEncoder().encode(cipher.doFinal(bytes));
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] decrypt(byte[] bytes) {
|
||||
Reflection.getCallerClass();
|
||||
try {
|
||||
final IvParameterSpec ivspec = new IvParameterSpec(new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
|
||||
final SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");
|
||||
final KeySpec spec = new PBEKeySpec(Arrays.toString(key).toCharArray(), "ssshhhhhhhhhhh!!!!".getBytes(), 65536, 256);
|
||||
final SecretKey tmp = factory.generateSecret(spec);
|
||||
final SecretKeySpec secretKey = new SecretKeySpec(tmp.getEncoded(), "AES");
|
||||
|
||||
final Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKey, ivspec);
|
||||
|
||||
return cipher.doFinal(Base64.getDecoder().decode(bytes));
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
//unfunny decryption key above
|
||||
//what no lmao it's
|
||||
//regenerated every launch
|
||||
}
|
||||
}
|
||||
|
||||
private static Unsafe getUnsafe() {
|
||||
try {
|
||||
|
@ -297,6 +288,30 @@ public class Loader {
|
|||
}
|
||||
}
|
||||
|
||||
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 void message(String title, String message, int b, boolean exit) {
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package org.baseband.launcher.util;
|
||||
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
|
||||
import org.baseband.launcher.launch.Loader;
|
||||
import org.spongepowered.asm.service.MixinService;
|
||||
import org.spongepowered.asm.service.mojang.MixinServiceLaunchWrapper;
|
||||
import sun.reflect.Reflection;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Field;
|
||||
|
@ -14,13 +14,9 @@ import java.util.Objects;
|
|||
|
||||
|
||||
public class CustomClassloader extends ClassLoader {
|
||||
public static CustomClassloader INSTANCE;
|
||||
|
||||
|
||||
private byte[] classes;
|
||||
|
||||
|
||||
public CustomClassloader INSTANCE;
|
||||
|
||||
private static byte[] cryptClasses;
|
||||
|
||||
|
||||
public CustomClassloader(Object obj) {
|
||||
|
@ -49,7 +45,9 @@ public class CustomClassloader extends ClassLoader {
|
|||
}
|
||||
|
||||
INSTANCE = new CustomClassloader();
|
||||
INSTANCE.classes=convertToBytes(classes);
|
||||
//CustomClassloader.classes = classes;
|
||||
|
||||
cryptClasses = Loader.objectKey.serializeObject(classes);
|
||||
|
||||
|
||||
try {
|
||||
|
@ -65,7 +63,8 @@ public class CustomClassloader extends ClassLoader {
|
|||
@Override
|
||||
protected Class<?> findClass(String name) throws ClassNotFoundException {
|
||||
if(name.startsWith("com.baseband")) {
|
||||
byte[] data = Loader.decrypt((byte[]) ((HashMap<?, ?>) Objects.requireNonNull(convertFromBytes(classes))).get(name));
|
||||
//byte[] data = Loader.decrypt(classes.get(name));
|
||||
byte[] data = Loader.classKey.decryptByte((byte[]) ((HashMap<?, ?>) Objects.requireNonNull(Loader.objectKey.deserializeObject(cryptClasses))).get(name));
|
||||
if (data == null) {
|
||||
return super.findClass(name);
|
||||
}
|
||||
|
@ -86,42 +85,28 @@ public class CustomClassloader extends ClassLoader {
|
|||
}
|
||||
|
||||
|
||||
private byte[] convertToBytes(Object object) {
|
||||
Reflection.getCallerClass();
|
||||
try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream out = new ObjectOutputStream(bos)) {
|
||||
out.writeObject(object);
|
||||
return Loader.encrypt(bos.toByteArray());
|
||||
}catch (IOException e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Object convertFromBytes(byte[] bytes) {
|
||||
try (ByteArrayInputStream bis = new ByteArrayInputStream(Objects.requireNonNull(Loader.decrypt(bytes)));
|
||||
ObjectInputStream in = new ObjectInputStream(bis)) {
|
||||
return in.readObject();
|
||||
}catch (IOException | ClassNotFoundException e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class CustomMixinServer extends MixinServiceLaunchWrapper {
|
||||
|
||||
private static class CustomMixinServer extends MixinServiceLaunchWrapper {
|
||||
@Override
|
||||
public byte[] getClassBytes(String name, String transformedName) throws IOException {
|
||||
byte[] bytes = Loader.decrypt((byte[]) ((HashMap<?, ?>) Objects.requireNonNull(convertFromBytes(classes))).get(name));
|
||||
if (bytes != null) {
|
||||
return bytes;
|
||||
if(name.startsWith("com.baseband")) {
|
||||
byte[] bytes = Loader.classKey.decryptByte((byte[]) ((HashMap<?, ?>) Objects.requireNonNull(Loader.objectKey.deserializeObject(cryptClasses))).get(name));
|
||||
if (bytes != null) {
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
return super.getClassBytes(name, transformedName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getClassBytes(String name, boolean runTransformers) throws ClassNotFoundException, IOException {
|
||||
byte[] bytes = Loader.decrypt((byte[]) ((HashMap<?, ?>) Objects.requireNonNull(convertFromBytes(classes))).get(name));
|
||||
if (bytes != null) {
|
||||
return bytes;
|
||||
if(name.startsWith("com.baseband")) {
|
||||
byte[] bytes = Loader.classKey.decryptByte((byte[]) ((HashMap<?, ?>) Objects.requireNonNull(Loader.objectKey.deserializeObject(cryptClasses))).get(name));
|
||||
if (bytes != null) {
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
return super.getClassBytes(name, runTransformers);
|
||||
}
|
||||
|
|
193
Loader/src/main/java/org/baseband/launcher/util/Key.java
Normal file
193
Loader/src/main/java/org/baseband/launcher/util/Key.java
Normal file
|
@ -0,0 +1,193 @@
|
|||
package org.baseband.launcher.util;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.SecretKeyFactory;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.PBEKeySpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.spec.KeySpec;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Key {
|
||||
//Daniella made the actual encryption,
|
||||
//Jess made the serialization/byte handling/randomTicket
|
||||
|
||||
protected final String string;
|
||||
|
||||
private boolean debug = false;
|
||||
/**
|
||||
* Generates a random Key
|
||||
*/
|
||||
public Key() {
|
||||
string = getRandomTicket();
|
||||
}
|
||||
|
||||
public Key(String key) {
|
||||
string = key;
|
||||
}
|
||||
|
||||
public void setDebug(boolean debug) {
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
private static String getRandomTicket() {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
for (int count = 0; count < 64; ++count) {
|
||||
buffer.append(UUID.randomUUID());
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
|
||||
public byte[] serializeObject(Object obj) {
|
||||
try {
|
||||
if(debug) {
|
||||
System.out.println(obj + " serialize + encrypt");
|
||||
}
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
ObjectOutputStream objectOut = new ObjectOutputStream(byteArrayOutputStream);
|
||||
objectOut.writeObject(obj);
|
||||
objectOut.close();
|
||||
return encryptByte(byteArrayOutputStream.toByteArray());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null; // Return null in case of an error
|
||||
}
|
||||
}
|
||||
|
||||
public Object deserializeObject(byte[] bytes) {
|
||||
try {
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(decryptByte(bytes));
|
||||
ObjectInputStream objectIn = new ObjectInputStream(byteArrayInputStream);
|
||||
Object obj = objectIn.readObject();
|
||||
objectIn.close();
|
||||
if(debug) {
|
||||
System.out.println(obj + " deserialize + decrypt");
|
||||
}
|
||||
return obj;
|
||||
} catch (IOException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return null; // Return null in case of an error
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] encryptByte(byte[] bytes) {
|
||||
if(bytes == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
//bytes = encrypt(bytes, string.toCharArray());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public byte[] decryptByte(byte[] bytes) {
|
||||
if(bytes == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
//bytes = decrypt(bytes, string.toCharArray());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public byte[] encrypt(byte[] data, char[] password) throws Exception {
|
||||
SecureRandom random = new SecureRandom();
|
||||
byte[] salt = new byte[16];
|
||||
random.nextBytes(salt);
|
||||
|
||||
KeySpec keySpec = new PBEKeySpec(password, salt, 65536, 256);
|
||||
SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
|
||||
byte[] keyBytes = factory.generateSecret(keySpec).getEncoded();
|
||||
SecretKey key = new SecretKeySpec(keyBytes, "AES");
|
||||
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
byte[] ivBytes = new byte[16];
|
||||
random.nextBytes(ivBytes);
|
||||
IvParameterSpec iv = new IvParameterSpec(ivBytes);
|
||||
|
||||
cipher.init(Cipher.ENCRYPT_MODE, key, iv);
|
||||
|
||||
byte[] encryptedData = cipher.doFinal(data);
|
||||
|
||||
// Prepend salt and IV to the encrypted data
|
||||
byte[] result = new byte[salt.length + ivBytes.length + encryptedData.length];
|
||||
System.arraycopy(salt, 0, result, 0, salt.length);
|
||||
System.arraycopy(ivBytes, 0, result, salt.length, ivBytes.length);
|
||||
System.arraycopy(encryptedData, 0, result, salt.length + ivBytes.length, encryptedData.length);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public byte[] decrypt(byte[] encryptedData, char[] password) throws Exception {
|
||||
byte[] salt = new byte[16];
|
||||
byte[] ivBytes = new byte[16];
|
||||
byte[] data = new byte[encryptedData.length - 32]; // Subtract salt and IV lengths
|
||||
|
||||
System.arraycopy(encryptedData, 0, salt, 0, 16);
|
||||
System.arraycopy(encryptedData, 16, ivBytes, 0, 16);
|
||||
System.arraycopy(encryptedData, 32, data, 0, data.length);
|
||||
|
||||
KeySpec keySpec = new PBEKeySpec(password, salt, 65536, 256);
|
||||
SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
|
||||
byte[] keyBytes = factory.generateSecret(keySpec).getEncoded();
|
||||
SecretKey key = new SecretKeySpec(keyBytes, "AES");
|
||||
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
IvParameterSpec iv = new IvParameterSpec(ivBytes);
|
||||
|
||||
cipher.init(Cipher.DECRYPT_MODE, key, iv);
|
||||
|
||||
return cipher.doFinal(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypts a string
|
||||
* @param s string to encrypt
|
||||
* @return encrypted string
|
||||
*/
|
||||
public String encryptString(String s) {
|
||||
byte[] bytes = s.getBytes(StandardCharsets.ISO_8859_1);
|
||||
byte[] eb = string.getBytes(StandardCharsets.ISO_8859_1);
|
||||
int len = bytes.length;
|
||||
int p = eb.length;
|
||||
for (int i = 0 ; i < len ; i+=p) {
|
||||
for (int j = 0 ; j < p && i + j < len ; j++) {
|
||||
int idx = i + j;
|
||||
bytes[idx] = (byte) ((int) bytes[idx] + (int) eb[j]);
|
||||
}
|
||||
}
|
||||
return new String(bytes, StandardCharsets.ISO_8859_1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypts a string
|
||||
* @param s string to decrypt
|
||||
* @return decrypted string
|
||||
*/
|
||||
public String decryptString(String s) {
|
||||
byte[] bytes = s.getBytes(StandardCharsets.ISO_8859_1);
|
||||
byte[] eb = string.getBytes(StandardCharsets.ISO_8859_1);
|
||||
int len = bytes.length;
|
||||
int p = eb.length;
|
||||
for (int i = 0 ; i < len ; i+=p) {
|
||||
for (int j = 0 ; j < p && i + j < len ; j++) {
|
||||
int idx = i + j;
|
||||
bytes[idx] = (byte) ((int) bytes[idx] - (int) eb[j]);
|
||||
}
|
||||
}
|
||||
return new String(bytes, StandardCharsets.ISO_8859_1);
|
||||
}
|
||||
}
|
|
@ -57,16 +57,15 @@ public class Bot extends ListenerAdapter {
|
|||
}else {
|
||||
event.getChannel().sendMessage("Cannot find User [**" + username + "**]").queue();
|
||||
}
|
||||
} else if (message[0].equalsIgnoreCase("-adduser") && message.length == 3) {
|
||||
} else if (message[0].equalsIgnoreCase("-adduser") && message.length == 2) {
|
||||
if (this.findRole(Objects.requireNonNull(event.getMember()), "Staff") == null) {
|
||||
event.getChannel().sendMessage("Invalid Perms (Requires Staff Role)").queue();
|
||||
return;
|
||||
}
|
||||
String username = message[1];
|
||||
String hashedPassword = message[2];
|
||||
|
||||
if(!UserManager.users.usernameExists(username)) {
|
||||
UserManager.users.put(username, hashedPassword, "hwid", "true", "false");
|
||||
UserManager.users.put(username, "reset", "hwid", "true", "false");
|
||||
event.getChannel().sendMessage("Created User [**" + username + "**]").queue();
|
||||
}else {
|
||||
event.getChannel().sendMessage("User [**" + username + "**] already exists.").queue();
|
||||
|
@ -78,7 +77,7 @@ public class Bot extends ListenerAdapter {
|
|||
}
|
||||
// Loop through the outer map
|
||||
for (Map.Entry<String, Map<String, String>> entry : UserManager.users.getMap().entrySet()) {
|
||||
StringBuilder stringBuilder = new StringBuilder("==============================");
|
||||
StringBuilder stringBuilder = new StringBuilder("==============================").append("\n");
|
||||
String outerKey = entry.getKey();
|
||||
Map<String, String> innerMap = entry.getValue();
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package dev.baseband.server.socket;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
@ -18,6 +15,7 @@ public class ClientHandler extends Thread {
|
|||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
client.setSoTimeout(5000);
|
||||
DataOutputStream dos = new DataOutputStream(client.getOutputStream());
|
||||
DataInputStream dis = new DataInputStream(client.getInputStream());
|
||||
|
||||
|
@ -25,11 +23,12 @@ public class ClientHandler extends Thread {
|
|||
//We are confirming that we are who we say we are
|
||||
String ticket = dis.readUTF();
|
||||
dos.writeUTF(ticket);
|
||||
Key key = new Key(ticket);
|
||||
|
||||
String type = dis.readUTF();
|
||||
String username = dis.readUTF();
|
||||
String hashedPassword = sha512hex(dis.readUTF());
|
||||
String hwid = dis.readUTF();
|
||||
String username = key.decryptString(dis.readUTF());
|
||||
String hashedPassword = sha512hex(key.decryptString(dis.readUTF()));
|
||||
String hwid = key.decryptString(dis.readUTF());
|
||||
boolean dump = dis.readBoolean();
|
||||
|
||||
|
||||
|
@ -51,7 +50,6 @@ public class ClientHandler extends Thread {
|
|||
System.out.println("(We are banning this user.)");
|
||||
UserManager.users.setIsBanned(username, "true");
|
||||
dos.writeInt(-5);
|
||||
client.close();
|
||||
System.out.println("========================================");
|
||||
return;
|
||||
}
|
||||
|
@ -81,13 +79,12 @@ public class ClientHandler extends Thread {
|
|||
dos.writeInt(result);
|
||||
} else if(result == -6){
|
||||
System.out.println("Password Reset.");
|
||||
UserManager.users.setPassword(username, hashedPassword);
|
||||
dos.writeInt(result);
|
||||
}else{
|
||||
System.out.println("Auth failed");
|
||||
dos.writeInt(result);
|
||||
}
|
||||
|
||||
client.close();
|
||||
System.out.println("========================================");
|
||||
return;
|
||||
}
|
||||
|
@ -95,30 +92,32 @@ public class ClientHandler extends Thread {
|
|||
|
||||
if (result == 0 || result == -2) {
|
||||
System.out.println("Client is valid");
|
||||
|
||||
dos.writeInt(result);
|
||||
|
||||
|
||||
|
||||
|
||||
byte[] bytes = new byte[(int) Socket.clientFile.length()];
|
||||
|
||||
FileInputStream fis = new FileInputStream(Socket.clientFile);
|
||||
BufferedInputStream bis = new BufferedInputStream(fis);
|
||||
|
||||
bis.read(bytes, 0, bytes.length);
|
||||
|
||||
dos.writeInt(bytes.length);
|
||||
|
||||
dos.write(bytes, 0, bytes.length);
|
||||
|
||||
dos.flush();
|
||||
|
||||
System.out.println("Sent File To Client");
|
||||
System.out.println("========================================");
|
||||
client.close();
|
||||
} else {
|
||||
System.out.println("Invalid, Error code "+result);
|
||||
System.out.println("========================================");
|
||||
dos.writeInt(result);
|
||||
client.close();
|
||||
System.out.println("========================================");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
this.interrupt();
|
||||
}
|
||||
}
|
||||
|
|
139
Server/src/main/java/dev/baseband/server/socket/Key.java
Normal file
139
Server/src/main/java/dev/baseband/server/socket/Key.java
Normal file
|
@ -0,0 +1,139 @@
|
|||
package dev.baseband.server.socket;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Key {
|
||||
//Daniella made the actual encryption,
|
||||
//Jess made the serialization/byte handling/randomTicket
|
||||
|
||||
protected final String string;
|
||||
|
||||
private boolean debug = false;
|
||||
/**
|
||||
* Generates a random Key
|
||||
*/
|
||||
public Key() {
|
||||
string = getRandomTicket();
|
||||
}
|
||||
|
||||
public Key(String key) {
|
||||
string = key;
|
||||
}
|
||||
|
||||
public void setDebug(boolean debug) {
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
private static String getRandomTicket() {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
for (int count = 0; count < 64; ++count) {
|
||||
buffer.append(UUID.randomUUID());
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
|
||||
public byte[] serializeObject(Object obj) {
|
||||
try {
|
||||
if(debug) {
|
||||
System.out.println(obj + " serialize + encrypt");
|
||||
}
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
ObjectOutputStream objectOut = new ObjectOutputStream(byteArrayOutputStream);
|
||||
objectOut.writeObject(obj);
|
||||
objectOut.close();
|
||||
return encryptByte(byteArrayOutputStream.toByteArray());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null; // Return null in case of an error
|
||||
}
|
||||
}
|
||||
|
||||
public Object deserializeObject(byte[] bytes) {
|
||||
try {
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(decryptByte(bytes));
|
||||
ObjectInputStream objectIn = new ObjectInputStream(byteArrayInputStream);
|
||||
Object obj = objectIn.readObject();
|
||||
objectIn.close();
|
||||
if(debug) {
|
||||
System.out.println(obj + " serialize + encrypt");
|
||||
}
|
||||
return obj;
|
||||
} catch (IOException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return null; // Return null in case of an error
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] encryptByte(byte[] bytes) {
|
||||
if(bytes == null) {
|
||||
return null;
|
||||
}
|
||||
byte[] eb = string.getBytes(StandardCharsets.ISO_8859_1);
|
||||
int len = bytes.length;
|
||||
int p = eb.length;
|
||||
for (int i = 0 ; i < len ; i+=p) {
|
||||
for (int j = 0 ; j < p && i + j < len ; j++) {
|
||||
int idx = i + j;
|
||||
bytes[idx] = (byte) ((int) bytes[idx] + (int) eb[j]);
|
||||
}
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public byte[] decryptByte(byte[] bytes) {
|
||||
if(bytes == null) {
|
||||
return null;
|
||||
}
|
||||
byte[] eb = string.getBytes(StandardCharsets.ISO_8859_1);
|
||||
int len = bytes.length;
|
||||
int p = eb.length;
|
||||
for (int i = 0 ; i < len ; i+=p) {
|
||||
for (int j = 0 ; j < p && i + j < len ; j++) {
|
||||
int idx = i + j;
|
||||
bytes[idx] = (byte) ((int) bytes[idx] - (int) eb[j]);
|
||||
}
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypts a string
|
||||
* @param s string to encrypt
|
||||
* @return encrypted string
|
||||
*/
|
||||
public String encryptString(String s) {
|
||||
byte[] bytes = s.getBytes(StandardCharsets.ISO_8859_1);
|
||||
byte[] eb = string.getBytes(StandardCharsets.ISO_8859_1);
|
||||
int len = bytes.length;
|
||||
int p = eb.length;
|
||||
for (int i = 0 ; i < len ; i+=p) {
|
||||
for (int j = 0 ; j < p && i + j < len ; j++) {
|
||||
int idx = i + j;
|
||||
bytes[idx] = (byte) ((int) bytes[idx] + (int) eb[j]);
|
||||
}
|
||||
}
|
||||
return new String(bytes, StandardCharsets.ISO_8859_1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypts a string
|
||||
* @param s string to decrypt
|
||||
* @return decrypted string
|
||||
*/
|
||||
public String decryptString(String s) {
|
||||
byte[] bytes = s.getBytes(StandardCharsets.ISO_8859_1);
|
||||
byte[] eb = string.getBytes(StandardCharsets.ISO_8859_1);
|
||||
int len = bytes.length;
|
||||
int p = eb.length;
|
||||
for (int i = 0 ; i < len ; i+=p) {
|
||||
for (int j = 0 ; j < p && i + j < len ; j++) {
|
||||
int idx = i + j;
|
||||
bytes[idx] = (byte) ((int) bytes[idx] - (int) eb[j]);
|
||||
}
|
||||
}
|
||||
return new String(bytes, StandardCharsets.ISO_8859_1);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue