aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gq
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gq')
-rw-r--r--src/main/java/gq/malwarefight/nosession/tweaks/initial/InitialTweaker.java6
-rw-r--r--src/main/java/gq/malwarefight/nosession/utils/Utils.java8
-rw-r--r--src/main/java/gq/malwarefight/tokenapp/Main.java15
3 files changed, 17 insertions, 12 deletions
diff --git a/src/main/java/gq/malwarefight/nosession/tweaks/initial/InitialTweaker.java b/src/main/java/gq/malwarefight/nosession/tweaks/initial/InitialTweaker.java
index 21b2646..aae8bb6 100644
--- a/src/main/java/gq/malwarefight/nosession/tweaks/initial/InitialTweaker.java
+++ b/src/main/java/gq/malwarefight/nosession/tweaks/initial/InitialTweaker.java
@@ -49,14 +49,14 @@ public class InitialTweaker implements ITweaker {
}
}
if (isRelaunch) {
- String finalUuid = uuid;
- if (finalUuid == null) {
+ String finalUUID = uuid;
+ if (finalUUID == null) {
return; // if we don't have a uuid, quit
}
Runtime.getRuntime().addShutdownHook(
new Thread(() -> {
try {
- Socket socket = Utils.getProperSocket(UUID.fromString(finalUuid));
+ Socket socket = Utils.getProperSocket(UUID.fromString(Utils.normalizeUUID(finalUUID)));
socket.getOutputStream().write("fullquit\n".getBytes(StandardCharsets.UTF_8));
socket.close();
} catch (Exception e) {
diff --git a/src/main/java/gq/malwarefight/nosession/utils/Utils.java b/src/main/java/gq/malwarefight/nosession/utils/Utils.java
index 7d3c4dd..b34c0aa 100644
--- a/src/main/java/gq/malwarefight/nosession/utils/Utils.java
+++ b/src/main/java/gq/malwarefight/nosession/utils/Utils.java
@@ -91,6 +91,12 @@ public class Utils {
}
}
+ public static String normalizeUUID(String uuid) {
+ return uuid.replaceFirst(
+ "(\\p{XDigit}{8})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}+)", "$1-$2-$3-$4-$5"
+ );
+ }
+
public static void setStaticValue(Class<?> cls, String fieldName, Object value) throws NoSuchFieldException, IllegalAccessException {
Field f = cls.getDeclaredField(fieldName);
f.setAccessible(true);
@@ -169,8 +175,6 @@ public class Utils {
public static void setToken(String token) throws IOException, InvocationTargetException, NoSuchMethodException, IllegalAccessException, URISyntaxException {
Properties p = getJavaProperties();
- String cp = getClasspath(p);
- System.out.println(cp);
ProcessBuilder processBuilder = new ProcessBuilder(
getJavaExe(p), "-cp", getClasspath(p), Main.class.getName()
);
diff --git a/src/main/java/gq/malwarefight/tokenapp/Main.java b/src/main/java/gq/malwarefight/tokenapp/Main.java
index ecea1f3..96b9cb3 100644
--- a/src/main/java/gq/malwarefight/tokenapp/Main.java
+++ b/src/main/java/gq/malwarefight/tokenapp/Main.java
@@ -14,6 +14,7 @@ import java.net.*;
import java.util.UUID;
public class Main {
+
public static final int BASE_PORT = 47777;
public static YggdrasilMinecraftSessionService sessionService = null;
public static YggdrasilAuthenticationService authenticationService = null;
@@ -21,18 +22,17 @@ public class Main {
public static void setup() throws IOException {
String token = Utils.readString(System.in, '\n');
- System.out.println(token);
- YggdrasilAuthenticationService yas = new YggdrasilAuthenticationService(Proxy.NO_PROXY, token);
+ YggdrasilAuthenticationService yas = new YggdrasilAuthenticationService(Proxy.NO_PROXY,
+ token);
authenticationService = yas;
sessionService = (YggdrasilMinecraftSessionService) yas.createMinecraftSessionService();
- HttpsURLConnection httpsURLConnection = (HttpsURLConnection) (new URL("https://api.minecraftservices.com/minecraft/profile").openConnection());
+ HttpsURLConnection httpsURLConnection = (HttpsURLConnection) (new URL(
+ "https://api.minecraftservices.com/minecraft/profile").openConnection());
httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token);
String response = Utils.readString(httpsURLConnection.getInputStream(), null);
JsonObject jsonObject = new JsonParser().parse(response).getAsJsonObject();
UUID id = UUID.fromString(
- jsonObject.get("id").getAsString().replaceFirst(
- "(\\p{XDigit}{8})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}+)", "$1-$2-$3-$4-$5"
- )
+ Utils.normalizeUUID(jsonObject.get("id").getAsString())
);
String name = jsonObject.get("name").getAsString();
gameProfile = new GameProfile(id, name);
@@ -52,7 +52,8 @@ public class Main {
//noinspection resource
sock = new ServerSocket(i, 50, InetAddress.getLoopbackAddress());
break;
- } catch (Exception ignored) {}
+ } catch (Exception ignored) {
+ }
}
if (sock == null) {
System.err.println("Could not bind to any valid port");