Advertisement
Guest User

Untitled

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