Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.lordethan.cryton.utils;
- public class SessionStealer extends GuiScreen {
- public GuiScreen parentScreen;
- public GuiTextField passwordBox2;
- public GuiTextField sessionBox;
- public SessionStealer(GuiScreen paramScreen)
- {
- this.parentScreen = paramScreen;
- }
- public void initGui()
- {
- Keyboard.enableRepeatEvents(true);
- this.buttonList.add(new GuiButton(444, this.width / 2 - 100, this.height / 4 + 96 + 50, "Session ID Login"));
- this.buttonList.add(new GuiButton(2, this.width / 2 - 100, this.height / 4 + 96 + 106, "Back"));
- this.passwordBox2 = new GuiTextField(66, mc.fontRendererObj, this.width / 2 - 100, 161, 200, 20);
- passwordBox2.setMaxStringLength(65);
- }
- public void onGuiClosed()
- {
- Keyboard.enableRepeatEvents(false);
- }
- public void updateScreen()
- {
- this.passwordBox2.updateCursorCounter();
- }
- public void mouseClicked(int x, int y, int b)
- {
- this.passwordBox2.mouseClicked(x, y, b);
- try {
- super.mouseClicked(x, y, b);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public static boolean premium = true;
- public void keyTyped(char ch, int key)
- {
- if (key == 1) {
- Minecraft.getMinecraft().displayGuiScreen(this.parentScreen);
- }
- this.passwordBox2.textboxKeyTyped(ch, key);
- if (key == 28) {
- actionPerformed((GuiButton)this.buttonList.get(0));
- }
- if (key == 13) {
- actionPerformed((GuiButton)this.buttonList.get(0));
- }
- }
- public static String lastusername = "";
- public static String lastpassword = "";
- protected void actionPerformed(GuiButton par1GuiButton)
- {
- if (par1GuiButton.id == 444)
- {
- // validate input
- String input = passwordBox2.getText();
- if(input.length() != 65 || !input.substring(32, 33).equals(":")
- || input.split(":").length != 2)
- {
- System.out.print("NO SESSION TOKE");
- return;
- }
- String uuid = input.split(":")[1];
- if(uuid.contains("-"))
- {
- System.out.print("NO SESSION TOKE2");
- return;
- }
- // fetch name history
- JsonElement rawJson;
- try
- {
- rawJson =
- new JsonParser().parse(new InputStreamReader(new URL(
- "https://api.mojang.com/user/profiles/" + uuid
- + "/names").openConnection().getInputStream()));
- }catch(Exception e)
- {
- System.out.print("Server down? TOKE");
- return;
- }
- // validate UUID
- if(!rawJson.isJsonArray())
- {
- System.out.print("INVALID UUID");
- return;
- }
- // get latest name
- JsonArray json = rawJson.getAsJsonArray();
- String name =
- json.get(json.size() - 1).getAsJsonObject().get("name")
- .getAsString();
- // validate session
- try
- {
- Proxy proxy =
- MinecraftServer.getServer() == null ? null
- : MinecraftServer.getServer().getServerProxy();
- if(proxy == null)
- proxy = Proxy.NO_PROXY;
- HttpURLConnection connection =
- (HttpURLConnection)new URL(
- "https://authserver.mojang.com/validate")
- .openConnection(proxy);
- connection.setRequestMethod("POST");
- connection.setRequestProperty("Content-Type",
- "application/json");
- String content =
- "{\"accessToken\":\"" + input.split(":")[0] + "\"}";
- connection.setRequestProperty("Content-Length", ""
- + content.getBytes().length);
- connection.setRequestProperty("Content-Language", "en-US");
- connection.setUseCaches(false);
- connection.setDoInput(true);
- connection.setDoOutput(true);
- DataOutputStream output =
- new DataOutputStream(connection.getOutputStream());
- output.writeBytes(content);
- output.flush();
- output.close();
- if(connection.getResponseCode() != 204)
- throw new IOException();
- }catch(IOException e)
- {
- System.out.print("Invalid Session");
- return;
- }
- // use session
- mc.session = new Session(name, uuid, input.split(":")[0], "mojang");
- }
- }
- public void drawScreen(int x, int y, float f)
- {
- this.drawDefaultBackground();
- //Display.setResizable(false);
- ScaledResolution scaledRes = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight);
- Gui.drawScaledCustomSizeModalRect(0,
- 0,
- 0.0F,
- 0.0F,
- scaledRes.getScaledWidth(),
- scaledRes.getScaledHeight(),
- scaledRes.getScaledWidth(),
- scaledRes.getScaledHeight(),
- scaledRes.getScaledWidth(),
- scaledRes.getScaledHeight());
- drawString(mc.fontRendererObj, "§fSessionID", this.width / 2 - 100, 150, 10526880);
- mc.fontRendererObj.drawString("Username: §a" + this.mc.session.getUsername(), 3, 3, 16777215);
- try
- {
- this.passwordBox2.drawTextBox();
- }
- catch (Exception err)
- {
- err.printStackTrace();
- }
- super.drawScreen(x, y, f);
- }
- public static String getProcessorID()
- {
- try
- {
- Process process = Runtime.getRuntime().exec(new String[] { "wmic", "cpu", "get", "ProcessorID" });
- process.getOutputStream().close();
- Scanner sc = new Scanner(process.getInputStream());
- String property = sc.next();
- return sc.next();
- }
- catch (IOException localIOException) {}
- return "0-0";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement