Skip to content

Commit

Permalink
Added only bungeespoofable, fixed bungeespoof not working
Browse files Browse the repository at this point in the history
  • Loading branch information
DAMcraft committed Dec 31, 2023
1 parent 78b8cd3 commit c63b14e
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 62 deletions.
6 changes: 3 additions & 3 deletions src/main/java/de/damcraft/serverseeker/ServerSeeker.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import de.damcraft.serverseeker.country.Countries;
import de.damcraft.serverseeker.country.Country;
import de.damcraft.serverseeker.country.CountrySetting;
import de.damcraft.serverseeker.modules.BungeeSpoof;
import de.damcraft.serverseeker.modules.BungeeSpoofModule;
import it.unimi.dsi.fastutil.objects.Object2ReferenceOpenHashMap;
import meteordevelopment.meteorclient.addons.GithubRepo;
import meteordevelopment.meteorclient.addons.MeteorAddon;
Expand Down Expand Up @@ -33,15 +33,15 @@ public class ServerSeeker extends MeteorAddon {
public static final Map<String, Country> COUNTRY_MAP = new Object2ReferenceOpenHashMap<>();

public static final Gson gson = new Gson();

@Override
public void onInitialize() {
LOG.info("Loaded the ServerSeeker addon!");

// Load countries
Countries.init();

Modules.get().add( new BungeeSpoof() );
Modules.get().add( new BungeeSpoofModule() );
SettingsWidgetFactory.registerCustomFactory(CountrySetting.class, (theme) -> (table, setting) -> {
CountrySetting.countrySettingW(table, (CountrySetting) setting, theme);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ public enum GeoSearchType {
.build()
);

private final Setting<Boolean> onlyBungeeSpoofable = sg.add(new BoolSetting.Builder()
.name("only-bungee-spoofable")
.description("Will only give you servers where you can use BungeeSpoof")
.defaultValue(false)
.build()
);

private final Setting<GeoSearchType> geoSearchTypeSetting = sg.add(new EnumSetting.Builder<GeoSearchType>()
.name("geo-search-type")
.description("Whether to search by ASN or country code")
Expand Down Expand Up @@ -330,6 +337,7 @@ public void initWidgets() {

if (!onlineOnlySetting.get()) request.setOnlineAfter(0);
if (ignoreModded.get()) request.setIgnoreModded(true);
if (onlyBungeeSpoofable.get()) request.setOnlyBungeeSpoofable(true);


this.locked = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package de.damcraft.serverseeker.mixin;

import com.google.gson.JsonObject;
import de.damcraft.serverseeker.ServerSeeker;
import de.damcraft.serverseeker.modules.BungeeSpoofModule;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.utils.network.Http;
import net.minecraft.network.NetworkState;
import net.minecraft.network.packet.c2s.handshake.ConnectionIntent;
import net.minecraft.network.packet.c2s.handshake.HandshakeC2SPacket;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import static de.damcraft.serverseeker.ServerSeeker.gson;
import static meteordevelopment.meteorclient.MeteorClient.mc;

@Mixin(HandshakeC2SPacket.class)
public abstract class HandshakeC2SMixin {
@Shadow
public abstract NetworkState getNewNetworkState();

@Mutable
@Shadow
@Final
private String address;

@Inject(method = "<init>(ILjava/lang/String;ILnet/minecraft/network/packet/c2s/handshake/ConnectionIntent;)V", at = @At("RETURN"))
private void onHandshakeC2SPacket(int i, String string, int j, ConnectionIntent connectionIntent, CallbackInfo ci) {
BungeeSpoofModule bungeeSpoofModule = Modules.get().get(BungeeSpoofModule.class);
if (!bungeeSpoofModule.isActive()) return;
if (this.getNewNetworkState() != NetworkState.LOGIN) return;
ServerSeeker.LOG.info("Spoofing bungeecord handshake packet");
String spoofedUUID = mc.getSession().getUuidOrNull().toString();

String URL = "https://api.mojang.com/users/profiles/minecraft/" + mc.getSession().getUsername();

Http.Request request = Http.get(URL);
String response = request.sendString();
if (response != null) {
JsonObject jsonObject = gson.fromJson(response, JsonObject.class);

if (jsonObject != null && jsonObject.has("id")) {
spoofedUUID = jsonObject.get("id").getAsString();
}
}

this.address += "\u0000" + bungeeSpoofModule.spoofedAddress.get() + "\u0000" + spoofedUUID;
}
}
58 changes: 0 additions & 58 deletions src/main/java/de/damcraft/serverseeker/modules/BungeeSpoof.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package de.damcraft.serverseeker.modules;

import de.damcraft.serverseeker.ServerSeeker;
import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.settings.SettingGroup;
import meteordevelopment.meteorclient.settings.StringSetting;
import meteordevelopment.meteorclient.systems.modules.Module;

public class BungeeSpoofModule extends Module {
SettingGroup sgGeneral = settings.getDefaultGroup();

public Setting<String> spoofedAddress = sgGeneral.add(new StringSetting.Builder()
.name("spoofed-address")
.description("The spoofed IP address that will be sent to the server.")
.defaultValue("127.0.0.1")
.filter((text, c) -> (text + c).matches("^[0-9a-f\\\\.:]{0,45}$"))
.build()
);

public BungeeSpoofModule() {
super(ServerSeeker.CATEGORY, "BungeeSpoof", "Allows you to join servers with an exposed bungeecord backend. ONLY ENABLE THIS IF YOU ACTUALLY WANT TO JOIN A BUNGEESPOOFABLE SERVER!");
this.runInMainMenu = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class ServersRequest {
private JsonArray online_players;
private Integer protocol;
private Boolean ignore_modded;
private Boolean only_bungeespoofable;

public enum Software {
Any,
Expand Down Expand Up @@ -92,6 +93,10 @@ public void setIgnoreModded(Boolean ignore) {
this.ignore_modded = ignore;
}

public void setOnlyBungeeSpoofable(Boolean only) {
this.only_bungeespoofable = only;
}

public String json() {
return gson.toJson(this);
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/serverseeker.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"defaultRequire": 1
},
"mixins": [
"HandshakeC2SAccessor"
"HandshakeC2SAccessor",
"HandshakeC2SMixin"
]
}

0 comments on commit c63b14e

Please sign in to comment.