Untitled
unknown
java
4 years ago
2.9 kB
14
Indexable
package dev.unzor.ShopBot.Utils;
import dev.unzor.ShopBot.Discord.Constants;
import dev.unzor.ShopBot.Main;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.Arrays;
import static dev.unzor.ShopBot.Utils.HWIDGenerator.getHWID;
public class HWIDUtil {
public static void init() throws Exception {
String[] HWIDs;
String userHWID = getHWID();
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hashedHWID = digest.digest(userHWID.getBytes(StandardCharsets.UTF_8));
if (Constants.debug) {
System.out.println("[DEBUG] Auth is: " + Arrays.toString(hashedHWID));
}
System.out.println("[+] Hashing HWID...");
Thread.sleep(2000);
if (Constants.debug)
System.out.println("[DEBUG] User's HWID is: " + userHWID);
System.out.println("[+] User's HWID has been hashed successfully");
System.out.println("[+] Connecting to the server...");
Thread.sleep(2000);
try {
String page = "http://62.83.4.21:443/api/shopbot/hwid.txt";
//Connecting to the web page
Connection conn = Jsoup.connect(page);
//executing the get request
Document doc = conn.get();
//Retrieving the contents (body) of the web page
String result = doc.body().text();
//Printing the result to an array of valid HWIDs
HWIDs = result.split("\n");
if (Constants.debug)
System.out.println("[DEBUG] List of valid HWIDs:" + Arrays.toString(HWIDs));
} catch (Exception e) {
if (e.getMessage().contains("Status=404")) {
System.out.println("[-] The server couldn't find the HWIDs database, please contact the developer.");
} else if (e.getMessage().contains("Connection refused")) {
System.out.println("[-] The server is offline, please try again later.");
}
return;
}
System.out.println("[+] Connected to the server successfully");
System.out.println("[+] Checking if HWID is valid...");
for (int i= 0; i < HWIDs.length; i++) {
if (HWIDs[i].contains(Arrays.toString(hashedHWID))) {
System.out.println("[+] Your HWID is valid!");
System.out.println("[+] User is authenticated!");
Thread.sleep(2000);
System.out.println("[+] Starting ShopBot...");
Main.startBot();
} else {
System.out.println("[-] Your HWID is invalid!");
System.out.println("[-] Please contact the developer!");
}
}
}
}
Editor is loading...