Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.16 KB | None | 0 0
  1. package me.lordethan.cryton.utils;
  2.  
  3. import net.minecraft.client.gui.GuiScreen;
  4.  
  5. import java.io.DataOutputStream;
  6. import java.io.IOException;
  7. import java.io.InputStreamReader;
  8. import java.net.HttpURLConnection;
  9. import java.net.Proxy;
  10. import java.net.URL;
  11. import java.util.Scanner;
  12.  
  13. import org.lwjgl.input.Keyboard;
  14.  
  15. import com.google.gson.JsonArray;
  16. import com.google.gson.JsonElement;
  17. import com.google.gson.JsonParser;
  18. import net.minecraft.client.Minecraft;
  19. import net.minecraft.client.gui.Gui;
  20. import net.minecraft.client.gui.GuiButton;
  21. import net.minecraft.client.gui.GuiScreen;
  22. import net.minecraft.client.gui.GuiTextField;
  23. import net.minecraft.client.gui.ScaledResolution;
  24. import net.minecraft.server.MinecraftServer;
  25. import net.minecraft.util.ResourceLocation;
  26. import net.minecraft.util.Session;
  27.  
  28. public class SessionStealer extends GuiScreen {
  29.  
  30.  
  31. public GuiScreen parentScreen;
  32.  
  33.  
  34. public GuiTextField passwordBox2;
  35.  
  36. public GuiTextField sessionBox;
  37.  
  38. public SessionStealer(GuiScreen paramScreen)
  39. {
  40. this.parentScreen = paramScreen;
  41. }
  42.  
  43. public void initGui()
  44. {
  45.  
  46. Keyboard.enableRepeatEvents(true);
  47. this.buttonList.add(new GuiButton(444, this.width / 2 - 100, this.height / 4 + 96 + 50, "Session ID Login"));
  48. this.buttonList.add(new GuiButton(2, this.width / 2 - 100, this.height / 4 + 96 + 106, "Back"));
  49. this.passwordBox2 = new GuiTextField(66, mc.fontRendererObj, this.width / 2 - 100, 161, 200, 20);
  50. passwordBox2.setMaxStringLength(65);
  51.  
  52. }
  53.  
  54. public void onGuiClosed()
  55. {
  56. Keyboard.enableRepeatEvents(false);
  57. }
  58.  
  59. public void updateScreen()
  60. {
  61.  
  62. this.passwordBox2.updateCursorCounter();
  63. }
  64.  
  65. public void mouseClicked(int x, int y, int b)
  66. {
  67. this.passwordBox2.mouseClicked(x, y, b);
  68. try {
  69. super.mouseClicked(x, y, b);
  70. } catch (IOException e) {
  71. e.printStackTrace();
  72. }
  73. }
  74.  
  75. public static boolean premium = true;
  76. public void keyTyped(char ch, int key)
  77. {
  78. if (key == 1) {
  79. Minecraft.getMinecraft().displayGuiScreen(this.parentScreen);
  80. }
  81.  
  82.  
  83. this.passwordBox2.textboxKeyTyped(ch, key);
  84.  
  85.  
  86. if (key == 28) {
  87. actionPerformed((GuiButton)this.buttonList.get(0));
  88. }
  89. if (key == 13) {
  90. actionPerformed((GuiButton)this.buttonList.get(0));
  91. }
  92.  
  93. }
  94. public static String lastusername = "";
  95. public static String lastpassword = "";
  96.  
  97. protected void actionPerformed(GuiButton par1GuiButton)
  98. {
  99.  
  100. if (par1GuiButton.id == 444)
  101. {
  102. // validate input
  103. String input = passwordBox2.getText();
  104.  
  105. if(input.length() != 65 || !input.substring(32, 33).equals(":")
  106. || input.split(":").length != 2)
  107. {
  108. System.out.print("NO SESSION TOKE");
  109. return;
  110. }
  111. String uuid = input.split(":")[1];
  112. if(uuid.contains("-"))
  113. {
  114. System.out.print("NO SESSION TOKE2");
  115. return;
  116. }
  117.  
  118. // fetch name history
  119. JsonElement rawJson;
  120. try
  121. {
  122. rawJson =
  123. new JsonParser().parse(new InputStreamReader(new URL(
  124. "https://api.mojang.com/user/profiles/" + uuid
  125. + "/names").openConnection().getInputStream()));
  126. }catch(Exception e)
  127. {
  128. System.out.print("Server down? TOKE");
  129. return;
  130. }
  131.  
  132. // validate UUID
  133. if(!rawJson.isJsonArray())
  134. {
  135. System.out.print("INVALID UUID");
  136. return;
  137. }
  138.  
  139. // get latest name
  140. JsonArray json = rawJson.getAsJsonArray();
  141. String name =
  142. json.get(json.size() - 1).getAsJsonObject().get("name")
  143. .getAsString();
  144.  
  145. // validate session
  146. try
  147. {
  148. Proxy proxy =
  149. MinecraftServer.getServer() == null ? null
  150. : MinecraftServer.getServer().getServerProxy();
  151. if(proxy == null)
  152. proxy = Proxy.NO_PROXY;
  153.  
  154. HttpURLConnection connection =
  155. (HttpURLConnection)new URL(
  156. "https://authserver.mojang.com/validate")
  157. .openConnection(proxy);
  158.  
  159. connection.setRequestMethod("POST");
  160. connection.setRequestProperty("Content-Type",
  161. "application/json");
  162.  
  163. String content =
  164. "{\"accessToken\":\"" + input.split(":")[0] + "\"}";
  165.  
  166. connection.setRequestProperty("Content-Length", ""
  167. + content.getBytes().length);
  168. connection.setRequestProperty("Content-Language", "en-US");
  169. connection.setUseCaches(false);
  170. connection.setDoInput(true);
  171. connection.setDoOutput(true);
  172.  
  173. DataOutputStream output =
  174. new DataOutputStream(connection.getOutputStream());
  175. output.writeBytes(content);
  176. output.flush();
  177. output.close();
  178.  
  179. if(connection.getResponseCode() != 204)
  180. throw new IOException();
  181. }catch(IOException e)
  182. {
  183. System.out.print("Invalid Session");
  184. return;
  185. }
  186.  
  187. // use session
  188. mc.session = new Session(name, uuid, input.split(":")[0], "mojang");
  189.  
  190.  
  191.  
  192.  
  193. }
  194.  
  195. }
  196.  
  197.  
  198. public void drawScreen(int x, int y, float f)
  199. {
  200. this.drawDefaultBackground();
  201. //Display.setResizable(false);
  202.  
  203. ScaledResolution scaledRes = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight);
  204. Gui.drawScaledCustomSizeModalRect(0,
  205. 0,
  206. 0.0F,
  207. 0.0F,
  208. scaledRes.getScaledWidth(),
  209. scaledRes.getScaledHeight(),
  210. scaledRes.getScaledWidth(),
  211. scaledRes.getScaledHeight(),
  212. scaledRes.getScaledWidth(),
  213. scaledRes.getScaledHeight());
  214.  
  215. drawString(mc.fontRendererObj, "§fSessionID", this.width / 2 - 100, 150, 10526880);
  216.  
  217. mc.fontRendererObj.drawString("Username: §a" + this.mc.session.getUsername(), 3, 3, 16777215);
  218.  
  219.  
  220. try
  221. {
  222.  
  223.  
  224.  
  225.  
  226.  
  227. this.passwordBox2.drawTextBox();
  228.  
  229.  
  230.  
  231. }
  232. catch (Exception err)
  233. {
  234. err.printStackTrace();
  235. }
  236. super.drawScreen(x, y, f);
  237. }
  238. public static String getProcessorID()
  239. {
  240. try
  241. {
  242. Process process = Runtime.getRuntime().exec(new String[] { "wmic", "cpu", "get", "ProcessorID" });
  243. process.getOutputStream().close();
  244. Scanner sc = new Scanner(process.getInputStream());
  245. String property = sc.next();
  246. return sc.next();
  247. }
  248. catch (IOException localIOException) {}
  249. return "0-0";
  250. }
  251.  
  252.  
  253.  
  254. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement