Advertisement
Guest User

Untitled

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