fix loader wtf
This commit is contained in:
parent
7f19262325
commit
47a343a1b3
3 changed files with 43 additions and 61 deletions
|
@ -34,11 +34,11 @@ import java.util.function.Consumer;
|
|||
|
||||
public class BaseBand {
|
||||
public static int majorVersion = 1;
|
||||
public static int buildNumber = 468;
|
||||
public static String hash = "2714cbd106927da2";
|
||||
public static int buildNumber = 485;
|
||||
public static String hash = "d8be0a150e9890d3";
|
||||
|
||||
public static String name = "BaseBand";
|
||||
public long timeOfCompile = 1696830524662L;
|
||||
public long timeOfCompile = 1700145647026L;
|
||||
public CommandManager commandRegistry;
|
||||
public EventBus eventBus;
|
||||
public ArrayList<Module> modules = new ArrayList<>();
|
||||
|
|
|
@ -278,37 +278,16 @@ public class Loader {
|
|||
int amountOfData = inputF.readInt();
|
||||
|
||||
for (int i = 0; i < amountOfData; i++) {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
Tweaker.log(i + "datapart");
|
||||
|
||||
int l = inputF.readInt();
|
||||
byte[] buf = new byte[1024];
|
||||
int amt;
|
||||
while (out.size() != l) {
|
||||
amt = inputF.read(buf);
|
||||
out.write(buf, 0, amt);
|
||||
}
|
||||
String name = new String(aesD.doFinal(communicationKey.decryptByteKey(out.toByteArray())));
|
||||
String name = new String(aesD.doFinal(communicationKey.decryptByteKey(Base64.getDecoder().decode(inputF.readUTF()))));
|
||||
Tweaker.log("1");
|
||||
|
||||
out = new ByteArrayOutputStream();
|
||||
byte[] data = communicationKey.decryptByteKey(Base64.getDecoder().decode(inputF.readUTF()));
|
||||
Tweaker.log("2");
|
||||
|
||||
l = inputF.readInt();
|
||||
buf = new byte[1024];
|
||||
while (out.size() != l) {
|
||||
amt = inputF.read(buf);
|
||||
out.write(buf, 0, amt);
|
||||
}
|
||||
byte[] data = aesD.doFinal(communicationKey.decryptByteKey(out.toByteArray()));
|
||||
|
||||
out = new ByteArrayOutputStream();
|
||||
|
||||
l = inputF.readInt();
|
||||
buf = new byte[1024];
|
||||
while (out.size() != l) {
|
||||
amt = inputF.read(buf);
|
||||
out.write(buf, 0, amt);
|
||||
}
|
||||
|
||||
byte[] dataKey = aesD.doFinal(communicationKey.decryptByteKey(out.toByteArray()));
|
||||
byte[] dataKey = aesD.doFinal(communicationKey.decryptByteKey(Base64.getDecoder().decode(inputF.readUTF())));
|
||||
Tweaker.log("3");
|
||||
|
||||
if (name.endsWith(".class")) {
|
||||
classKey.access(x -> classCache.put(name.replace(".class", "").replace('/', '.'), x.getValue().encryptByte(new Key(dataKey).decryptByte(data))));
|
||||
|
@ -317,6 +296,8 @@ public class Loader {
|
|||
}
|
||||
}
|
||||
|
||||
Tweaker.log("loaded classes?");
|
||||
|
||||
|
||||
CustomClassloader customCL = new CustomClassloader(
|
||||
(Supplier<Object>) (() -> new DataKeeper<>(CustomClassloader.getTransferPermissionManager(), defaultStrictness, classCache).forgetIn(2000)),
|
||||
|
@ -382,7 +363,6 @@ public class Loader {
|
|||
try {
|
||||
Objects.requireNonNull(getUnsafe()).defineClass("sun.instrument.InstrumentationImpl", EMPTY_CLASS_BYTES, 0, EMPTY_CLASS_BYTES.length, null, null);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
return "JavaAgent?";
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ import java.security.SecureRandom;
|
|||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.jar.JarInputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
public class ClientHandler extends Thread {
|
||||
final Socket client;
|
||||
|
@ -165,6 +165,7 @@ public class ClientHandler extends Thread {
|
|||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
if(!SocketHandler.currentJarHash.equals(jarHash) && !SocketHandler.pastJarHashes.contains(jarHash) && result >= 0) {
|
||||
dos.writeInt(-8);
|
||||
System.out.println("JAR HASH MISMATCH, banning.");
|
||||
|
@ -174,6 +175,8 @@ public class ClientHandler extends Thread {
|
|||
return;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
if(!SocketHandler.currentJarHash.equals(jarHash) && SocketHandler.pastJarHashes.contains(jarHash) && result >= 0) {
|
||||
dos.writeInt(-9);
|
||||
System.out.println("JAR HASH MISMATCH, denying.");
|
||||
|
@ -190,47 +193,36 @@ public class ClientHandler extends Thread {
|
|||
dos.writeInt(result);
|
||||
Map<Map<String, byte[]>, byte[]> data = new HashMap<>();
|
||||
|
||||
try (ZipInputStream zipStream = new ZipInputStream(new ByteArrayInputStream(SocketHandler.clientFileData))) {
|
||||
ZipEntry zipEntry;
|
||||
while ((zipEntry = zipStream.getNextEntry()) != null) {
|
||||
byte[] buffer = new byte[1024];
|
||||
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
int len;
|
||||
while ((len = zipStream.read(buffer)) > 0) {
|
||||
bos.write(buffer, 0, len);
|
||||
}
|
||||
bos.close();
|
||||
|
||||
JarInputStream jar = new JarInputStream(new ByteArrayInputStream(SocketHandler.clientFileData));
|
||||
ZipEntry zentry;
|
||||
|
||||
while ((zentry = jar.getNextEntry()) != null) {
|
||||
Map<String, byte[]> dataLocal = new HashMap<>();
|
||||
byte[] keyData = SecureRandom.getSeed(256);
|
||||
dataLocal.put(zipEntry.getName(), new Key(keyData).encryptByte(bos.toByteArray()));
|
||||
byte[] keyData = SecureRandom.getSeed(1024);
|
||||
dataLocal.put(zentry.getName(), new Key(keyData).encryptByte(getBytes(jar)));
|
||||
data.put(dataLocal, keyData);
|
||||
}
|
||||
}
|
||||
|
||||
dos.writeInt(data.size());
|
||||
|
||||
for (Map.Entry<Map<String, byte[]>, byte[]> mapEntry : data.entrySet()) {
|
||||
//For the love of all that is holy YOU DO NOT TOUCH THIS CODE TUD
|
||||
|
||||
Map.Entry<String, byte[]> entry = mapEntry.getKey().entrySet().iterator().next();
|
||||
|
||||
String className = entry.getKey(); //Name
|
||||
byte[] classData = entry.getValue(); //Data
|
||||
byte[] cryptKey = mapEntry.getValue(); //Key
|
||||
|
||||
byte[] encryptedBytes = key.encryptByte(aesE.doFinal(className.getBytes()));
|
||||
dos.writeInt(encryptedBytes.length);
|
||||
dos.write(encryptedBytes, 0, encryptedBytes.length);
|
||||
dos.flush();
|
||||
byte[] encryptedBytes1 = key.encryptByte(aesE.doFinal(className.getBytes()));
|
||||
dos.writeUTF(Base64.getEncoder().encodeToString(encryptedBytes1));
|
||||
|
||||
encryptedBytes = key.encryptByte(aesE.doFinal(classData));
|
||||
dos.writeInt(encryptedBytes.length);
|
||||
dos.write(encryptedBytes, 0, encryptedBytes.length);
|
||||
dos.flush();
|
||||
byte[] encryptedBytes2 = key.encryptByte(classData);
|
||||
dos.writeUTF(Base64.getEncoder().encodeToString(encryptedBytes2));
|
||||
|
||||
encryptedBytes = key.encryptByte(aesE.doFinal(cryptKey));
|
||||
dos.writeInt(encryptedBytes.length);
|
||||
dos.write(encryptedBytes, 0, encryptedBytes.length);
|
||||
dos.flush();
|
||||
byte[] encryptedBytes3 = key.encryptByte(aesE.doFinal(cryptKey));
|
||||
dos.writeUTF(Base64.getEncoder().encodeToString(encryptedBytes3));
|
||||
}
|
||||
|
||||
|
||||
|
@ -246,4 +238,14 @@ public class ClientHandler extends Thread {
|
|||
//this.interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] getBytes(final InputStream inputStream) throws IOException {
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
final byte[] buffer = new byte[256];
|
||||
int bytesRead;
|
||||
while ((bytesRead = inputStream.read(buffer)) >= 0) {
|
||||
out.write(buffer, 0, bytesRead);
|
||||
}
|
||||
return out.toByteArray();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue