Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

潜在的なバグと脆弱性の修正と可読性の向上 #181

Merged
merged 4 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ dependencies {
exclude module: "authlib"
}

include ('com.github.TheAltening:TheAltening4j:-SNAPSHOT') {
include('com.github.TheAltening:TheAltening4j:-SNAPSHOT') {
exclude module: "gson"
}
include 'com.github.TheAltening:TheAlteningAuth4j:-SNAPSHOT'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ viarewind_version=3.0.7-24w09a-SNAPSHOT
vialoader_version=2.2.13-SNAPSHOT

snake_yml_version=2.2
slf4j_version=2.0.9
slf4j_version=2.0.9
9 changes: 8 additions & 1 deletion src/main/java/net/aspw/client/Launch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ import net.aspw.client.features.module.impl.visual.MoreParticles
import net.aspw.client.features.module.impl.visual.Trajectories
import net.aspw.client.protocol.ProtocolBase
import net.aspw.client.protocol.ProtocolMod
import net.aspw.client.utils.*
import net.aspw.client.utils.Access
import net.aspw.client.utils.ClassUtils.hasForge
import net.aspw.client.utils.ClientUtils
import net.aspw.client.utils.InventoryHelper
import net.aspw.client.utils.InventoryUtils
import net.aspw.client.utils.MinecraftInstance
import net.aspw.client.utils.PacketUtils
import net.aspw.client.utils.RotationUtils
import net.aspw.client.utils.SessionUtils
import net.aspw.client.utils.misc.sound.TipSoundManager
import net.aspw.client.visual.client.clickgui.dropdown.ClickGui
import net.aspw.client.visual.font.semi.Fonts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.google.gson.JsonObject
import net.aspw.client.auth.compat.Session
import net.aspw.client.auth.utils.set
import net.aspw.client.auth.utils.string
import java.util.*
import java.util.UUID

class CrackedAccount : MinecraftAccount("Cracked") {
override var name = "Player"
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/net/aspw/client/config/configs/AccountsConfig.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
package net.aspw.client.config.configs;

import com.google.gson.*;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import net.aspw.client.auth.account.CrackedAccount;
import net.aspw.client.auth.account.MinecraftAccount;
import net.aspw.client.auth.manage.AccountSerializer;
import net.aspw.client.config.FileConfig;
import net.aspw.client.config.FileManager;

import java.io.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

Expand Down
24 changes: 17 additions & 7 deletions src/main/java/net/aspw/client/config/configs/FriendsConfig.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
package net.aspw.client.config.configs;

import com.google.gson.*;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import net.aspw.client.config.FileConfig;
import net.aspw.client.config.FileManager;
import net.aspw.client.utils.ClientUtils;

import java.io.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -35,11 +45,11 @@ protected void loadConfig() throws IOException {
return;

for (final JsonElement friendElement : jsonElement.getAsJsonArray()) {
JsonObject friendObject = friendElement.getAsJsonObject();
final JsonObject friendObject = friendElement.getAsJsonObject();
addFriend(friendObject.get("playerName").getAsString(), friendObject.get("alias").getAsString());
}

} catch (JsonSyntaxException | IllegalStateException ex) {
} catch (final JsonSyntaxException | IllegalStateException ex) {
//When the JSON Parse fail, the client try to load and update the old config
ClientUtils.getLogger().info("[FileManager] Try to load old Friends config...");

Expand All @@ -51,7 +61,7 @@ protected void loadConfig() throws IOException {
line = line.replace(" ", "").replace("\"", "").replace(",", "");

if (line.contains(":")) {
String[] data = line.split(":");
final String[] data = line.split(":");
addFriend(data[0], data[1]);
} else
addFriend(line);
Expand All @@ -71,7 +81,7 @@ protected void saveConfig() throws IOException {
final JsonArray jsonArray = new JsonArray();

for (final Friend friend : getFriends()) {
JsonObject friendObject = new JsonObject();
final JsonObject friendObject = new JsonObject();
friendObject.addProperty("playerName", friend.getPlayerName());
friendObject.addProperty("alias", friend.getAlias());
jsonArray.add(friendObject);
Expand Down Expand Up @@ -153,7 +163,7 @@ public List<Friend> getFriends() {
/**
* The type Friend.
*/
public class Friend {
public static class Friend {

private final String playerName;
private final String alias;
Expand Down
18 changes: 12 additions & 6 deletions src/main/java/net/aspw/client/config/configs/ModulesConfig.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package net.aspw.client.config.configs;

import com.google.gson.*;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import net.aspw.client.Launch;
import net.aspw.client.config.FileConfig;
import net.aspw.client.config.FileManager;
import net.aspw.client.features.module.Module;

import java.io.*;
import java.util.Iterator;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

/**
Expand All @@ -31,9 +39,7 @@ protected void loadConfig() throws IOException {
if (jsonElement instanceof JsonNull)
return;

final Iterator<Map.Entry<String, JsonElement>> entryIterator = jsonElement.getAsJsonObject().entrySet().iterator();
while (entryIterator.hasNext()) {
final Map.Entry<String, JsonElement> entry = entryIterator.next();
for (final Map.Entry<String, JsonElement> entry : jsonElement.getAsJsonObject().entrySet()) {
final Module module = Launch.moduleManager.getModule(entry.getKey());

if (module != null) {
Expand Down
31 changes: 18 additions & 13 deletions src/main/java/net/aspw/client/config/configs/ValuesConfig.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package net.aspw.client.config.configs;

import com.google.gson.*;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import net.aspw.client.Launch;
import net.aspw.client.config.FileConfig;
import net.aspw.client.config.FileManager;
Expand All @@ -9,8 +13,12 @@
import net.aspw.client.value.Value;
import net.aspw.client.visual.client.altmanager.menus.GuiTheAltening;

import java.io.*;
import java.util.Iterator;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

/**
Expand All @@ -36,22 +44,19 @@ protected void loadConfig() throws IOException {

final JsonObject jsonObject = (JsonObject) jsonElement;

final Iterator<Map.Entry<String, JsonElement>> iterator = jsonObject.entrySet().iterator();
while (iterator.hasNext()) {
final Map.Entry<String, JsonElement> entry = iterator.next();

for (final Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
if (entry.getKey().equalsIgnoreCase("macros")) {
JsonArray jsonValue = entry.getValue().getAsJsonArray();
final JsonArray jsonValue = entry.getValue().getAsJsonArray();
for (final JsonElement macroElement : jsonValue) {
JsonObject macroObject = macroElement.getAsJsonObject();
JsonElement keyValue = macroObject.get("key");
JsonElement commandValue = macroObject.get("command");
final JsonObject macroObject = macroElement.getAsJsonObject();
final JsonElement keyValue = macroObject.get("key");
final JsonElement commandValue = macroObject.get("command");

MacroManager.INSTANCE.addMacro(keyValue.getAsInt(), commandValue.getAsString());
}
} else if (entry.getKey().equalsIgnoreCase("features")) {
} else if (entry.getKey().equalsIgnoreCase("thealtening")) {
JsonObject jsonValue = (JsonObject) entry.getValue();
final JsonObject jsonValue = (JsonObject) entry.getValue();

if (jsonValue.has("API-Key"))
GuiTheAltening.Companion.setApiKey(jsonValue.get("API-Key").getAsString());
Expand All @@ -62,7 +67,7 @@ protected void loadConfig() throws IOException {
if (module != null) {
final JsonObject jsonModule = (JsonObject) entry.getValue();

for (final Value moduleValue : module.getValues()) {
for (final Value<?> moduleValue : module.getValues()) {
final JsonElement element = jsonModule.get(moduleValue.getName());

if (element != null) moduleValue.fromJson(element);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/aspw/client/features/api/ColorElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ColorElement extends IntegerValue {
* @param counter the counter
* @param m the m
*/
public ColorElement(int counter, Material m) {
public ColorElement(final int counter, final Material m) {
super("Color" + counter + "-" + m.getColorName(), 255, 0, 255);
}

Expand All @@ -24,7 +24,7 @@ protected void onChanged(final Integer oldValue, final Integer newValue) {
/**
* The enum Material.
*/
enum Material {
public enum Material {
/**
* Red material.
*/
Expand All @@ -40,7 +40,7 @@ enum Material {

private final String colName;

Material(String name) {
Material(final String name) {
this.colName = name;
}

Expand Down
7 changes: 6 additions & 1 deletion src/main/java/net/aspw/client/features/api/CombatManager.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package net.aspw.client.features.api

import net.aspw.client.Launch
import net.aspw.client.event.*
import net.aspw.client.event.AttackEvent
import net.aspw.client.event.EntityKilledEvent
import net.aspw.client.event.EventTarget
import net.aspw.client.event.Listenable
import net.aspw.client.event.UpdateEvent
import net.aspw.client.event.WorldEvent
import net.aspw.client.utils.EntityUtils
import net.aspw.client.utils.MinecraftInstance
import net.aspw.client.utils.MovementUtilsFix
Expand Down
50 changes: 33 additions & 17 deletions src/main/java/net/aspw/client/features/api/PacketManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.aspw.client.Launch;
import net.aspw.client.event.*;
import net.aspw.client.event.EventState;
import net.aspw.client.event.EventTarget;
import net.aspw.client.event.Listenable;
import net.aspw.client.event.MotionEvent;
import net.aspw.client.event.PacketEvent;
import net.aspw.client.event.TeleportEvent;
import net.aspw.client.event.UpdateEvent;
import net.aspw.client.event.WorldEvent;
import net.aspw.client.features.module.impl.combat.KillAura;
import net.aspw.client.features.module.impl.combat.KillAuraRecode;
import net.aspw.client.features.module.impl.combat.TPAura;
Expand All @@ -11,10 +18,19 @@
import net.aspw.client.features.module.impl.visual.BetterView;
import net.aspw.client.features.module.impl.visual.Interface;
import net.aspw.client.protocol.ProtocolBase;
import net.aspw.client.utils.*;
import net.aspw.client.utils.ClientUtils;
import net.aspw.client.utils.EntityUtils;
import net.aspw.client.utils.MinecraftInstance;
import net.aspw.client.utils.MovementUtils;
import net.aspw.client.utils.PacketUtils;
import net.aspw.client.utils.RotationUtils;
import net.aspw.client.utils.timer.MSTimer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.*;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.entity.item.EntityBoat;
import net.minecraft.entity.item.EntityItemFrame;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.item.EntityTNTPrimed;
import net.minecraft.network.Packet;
import net.minecraft.network.play.client.C03PacketPlayer;
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement;
Expand All @@ -23,17 +39,28 @@

public class PacketManager extends MinecraftInstance implements Listenable {

private static final MSTimer packetCountTimer = new MSTimer();
public static int swing;
public static boolean isVisualBlocking = false;
private static boolean flagged = false;
public static int flagTicks;
public static float eyeHeight;
public static float lastEyeHeight;
public static int sendPacketCounts;
public static int receivePacketCounts;
private static boolean flagged = false;
private int preSend = 0;
private int preReceive = 0;
private static final MSTimer packetCountTimer = new MSTimer();

public static boolean shouldStopRender(Entity entity) {
return (EntityUtils.isMob(entity) ||
EntityUtils.isAnimal(entity) ||
entity instanceof EntityBoat ||
entity instanceof EntityMinecart ||
entity instanceof EntityItemFrame ||
entity instanceof EntityTNTPrimed ||
entity instanceof EntityArmorStand) &&
entity != mc.thePlayer && mc.thePlayer.getDistanceToEntity(entity) > 45.0f;
}

@EventTarget
public void onWorld(WorldEvent event) {
Expand Down Expand Up @@ -70,7 +97,7 @@ public void onMotion(MotionEvent event) {
eyeHeight = END_HEIGHT;
} else if (eyeHeight < START_HEIGHT) {
float delta = START_HEIGHT - eyeHeight;
delta *= 0.4;
delta *= 0.4F;
eyeHeight = START_HEIGHT - delta;
}

Expand Down Expand Up @@ -165,17 +192,6 @@ public void onPacket(PacketEvent event) {
}
}

public static boolean shouldStopRender(Entity entity) {
return (EntityUtils.isMob(entity) ||
EntityUtils.isAnimal(entity) ||
entity instanceof EntityBoat ||
entity instanceof EntityMinecart ||
entity instanceof EntityItemFrame ||
entity instanceof EntityTNTPrimed ||
entity instanceof EntityArmorStand) &&
entity != mc.thePlayer && mc.thePlayer.getDistanceToEntity(entity) > 45.0f;
}

@Override
public boolean handleEvents() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package net.aspw.client.features.command.impl
import net.aspw.client.Launch
import net.aspw.client.features.command.Command
import org.lwjgl.input.Keyboard
import java.util.*
import java.util.Locale

class BindCommand : Command("bind", emptyArray()) {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.apache.http.util.EntityUtils
import java.awt.Desktop
import java.io.File
import java.io.IOException
import java.util.*
import java.util.Locale

class ConfigCommand : Command("config", arrayOf("c")) {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package net.aspw.client.features.command.impl

import net.aspw.client.features.command.Command
import net.minecraft.enchantment.Enchantment
import java.util.*
import java.util.Locale

class EnchantCommand : Command("enchant", emptyArray()) {
/**
Expand Down
Loading
Loading