def write_cheater_id(id): try: if os.path.isfile("lists\\cheaters_ids.txt") == True: file = open("lists\\cheaters_ids.txt", "r").read() if file.find(id) != -1: print("[INFO] " + "User " + id + " is already in the cheaters list.") tools.log("[INFO] " + "User " + id + " is already in the cheaters list.") else: f = open("lists\\cheaters_ids.txt", "a+", encoding="utf-8") f.write(id + "\n") f.close() print("[INFO] " + "User " + id + " has been added to the cheaters list.") tools.log("[INFO] " + "User " + id + " has been added to the cheaters list.") else: f = open("lists\\cheaters_ids.txt", "w+", encoding="utf-8") f.write(id + "\n") f.close() print("[INFO] " + "User " + id + " has been added to the cheaters list.") tools.log("[INFO] " + "User " + id + " has been added to the cheaters list.") except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] An unknown error occured. Please check the Anti-Cheat.log and Anti-Cheat_traceback.log files to know more." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
def get_img(url, userid): try: filename = url.rsplit('/', 1)[1] r = requests.get(url, allow_redirects=True) open(filename, 'wb').write(r.content) global team team = getcolor.main_color(filename) global pokeid pokeid = ocr.getid(filename, userid) except KeyboardInterrupt: return except IndexError as i: print( Fore.RED + Style.BRIGHT + "[WARN] URL soumises incorrecte. Veuillez vérifier les fichiers Anti-Cheat.log et Anti-Cheat_traceback.log pour en savoir plus." + Style.RESET_ALL) tools.log("[ERRO] " + str(i)) tools.log_traceback(traceback.format_exc()) pokeid = "ERROR" except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] Une erreur inconnue est survenue. Veuillez vérifier les fichiers Anti-Cheat.log et Anti-Cheat_traceback.log pour en savoir plus." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
def write_cheater_id(id): try: if os.path.isfile("lists\\cheaters_ids.txt") == True: file = open("lists\\cheaters_ids.txt", "r").read() if file.find(id) != -1: print("[INFO] " + "L'utilisateur " + id + " est déjà dans la liste des tricheurs.") tools.log("[INFO] " + "L'utilisateur " + id + " est déjà dans la liste des tricheurs.") else: f = open("lists\\cheaters_ids.txt", "a+", encoding="utf-8") f.write(id + "\n") f.close() print("[INFO] " + "L'utilisateur " + id + " a été ajouté à la liste des tricheurs.") tools.log("[INFO] " + "L'utilisateur " + id + " a été ajouté à la liste des tricheurs.") else: f = open("lists\\cheaters_ids.txt", "w+", encoding="utf-8") f.write(id + "\n") f.close() print("[INFO] " + "L'utilisateur " + id + " a été ajouté à la liste des tricheurs.") tools.log("[INFO] " + "L'utilisateur " + id + " a été ajouté à la liste des tricheurs.") except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] Une erreur inconnue est survenue. Veuillez vérifier les fichiers Anti-Cheat.log et Anti-Cheat_traceback.log pour en savoir plus." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
def get_img(url, userid): try: filename = url.rsplit('/', 1)[1] r = requests.get(url, allow_redirects=True) open(filename, 'wb').write(r.content) global team team = getcolor.main_color(filename) global pokeid pokeid = ocr.getid(filename, userid) except KeyboardInterrupt: return except IndexError as i: print( Fore.RED + Style.BRIGHT + "[WARN] Incorrect URL submitted. Please check the Anti-Cheat.log and Anti-Cheat_traceback.log files to know more." + Style.RESET_ALL) tools.log("[ERRO] " + str(i)) tools.log_traceback(traceback.format_exc()) pokeid = "ERROR" except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] An unknown error occured. Please check the Anti-Cheat.log and Anti-Cheat_traceback.log files to know more." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
async def recheck(ctx, user: discord.Member): try: userid = str(user.id) username = str(user.name) print("[INFO] " + username + " has been asked for a new verification.") tools.log("[INFO] " + username + " has been asked for a new verification.") role = get(ctx.guild.roles, name="Verified") if role in user.roles: await user.remove_roles(role) role = get(ctx.guild.roles, name="instinct") if role in user.roles: await user.remove_roles(role) role = get(ctx.guild.roles, name="valor") if role in user.roles: await user.remove_roles(role) role = get(ctx.guild.roles, name="mystic") if role in user.roles: await user.remove_roles(role) os.remove("servers_lists\\" + userid + "_servers_list.txt") await user.send( "[Pokémon GO Marseille]\n:flag_us: You have been asked for a new verification, please follow the autorisation link and use ./verify to verify yourself.\n:flag_fr: Une nouvelle vérification de votre part est requise, veuillez suivre le lien d'autorisation et utilisez ./verify pour vous vérifier." ) except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] An unknown error occured. Please check the Anti-Cheat.log and Anti-Cheat_traceback.log files to know more." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
def text_process(text, userid): try: sep = "&" rest = text.split(sep, 1)[0] file = open("user_ids\\" + userid + ".txt", "w") file.write(rest) file.close() file = open("user_ids\\" + userid + ".txt", "r") lastl = list(file)[-1] file.close() file = open("user_ids\\" + userid + ".txt", "w") file.write(lastl) file.close() file = open("user_ids\\" + userid + ".txt", "r") lines = file.read().splitlines() file.close() last_line = lastl if "\n" in last_line: sep = "\n" last_line = last_line.split(sep, 1)[0] else: pass if " " in last_line: tools.log("[INFO] " + "Résultat de l'OCR : " + last_line) print( Fore.RED + Style.BRIGHT + "[WARN] Espace détecté dans le nom d'utilisateur. Des erreurs peuvent découler des procédures suivantes." + Style.RESET_ALL) tools.log( "[WARN] Espace détecté dans le nom d'utilisateur. Des erreurs peuvent découler des procédures suivantes." ) last_line = fallback(userid, 2) file = open("user_ids\\" + userid + ".txt", "w") file.write(last_line) file.close() else: print("[INFO] " + "Résultat de l'OCR : " + last_line) tools.log("[INFO] " + "Résultat de l'OCR : " + last_line) file = open("user_ids\\" + userid + ".txt", "w") file.write(last_line) file.close() return last_line except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] Une erreur inconnue est survenue. Veuillez vérifier les fichiers Anti-Cheat.log et Anti-Cheat_traceback.log pour en savoir plus." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc()) return "ERROR"
def text_process(text, userid): try: sep = "&" rest = text.split(sep, 1)[0] file = open("user_ids\\" + userid + ".txt", "w") file.write(rest) file.close() file = open("user_ids\\" + userid + ".txt", "r") lastl = list(file)[-1] file.close() file = open("user_ids\\" + userid + ".txt", "w") file.write(lastl) file.close() file = open("user_ids\\" + userid + ".txt", "r") lines = file.read().splitlines() file.close() last_line = lastl if "\n" in last_line: sep = "\n" last_line = last_line.split(sep, 1)[0] else: pass if " " in last_line: tools.log("[INFO] " + "OCR Result: " + last_line) print( Fore.RED + Style.BRIGHT + "[WARN] Found space in detected username. The following procedures could lead to errors." + Style.RESET_ALL) tools.log( "[WARN] Found space in detected username. The following procedures could lead to errors." ) last_line = fallback(userid, 2) file = open("user_ids\\" + userid + ".txt", "w") file.write(last_line) file.close() else: print("[INFO] " + "OCR Result: " + last_line) tools.log("[INFO] " + "OCR Result: " + last_line) file = open("user_ids\\" + userid + ".txt", "w") file.write(last_line) file.close() return last_line except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] An unknown error occured. Please check the Anti-Cheat.log and Anti-Cheat_traceback.log files to know more." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc()) return "ERROR"
def check_updates(command): try: name = "Anti-Cheat FR" version = "v1.4.0" date = "04/09/19" print("Vérification des mises à jour ...") tools.log("[INFO] Vérification des mises à jour ...") check = subprocess.Popen(args=[ "setup\\curl.exe", "-s", "-f", "-k", "--output", "updates.json", "https://sh4fs0c13ty.tk/updates/updates.json" ]) check.wait() with open("updates.json") as json_file: data = json.load(json_file) for p in data: if "Anti-Cheat FR" == p['App']: new_version = p['Version'] new_codename = p['Codename'] new_url = p['Link'] new_date = p['Release date'] global new_checksum new_checksum = p['Checksum'] if version < new_version: if date < new_date: if command == "update": update(new_url) elif command == "check": print( "Une nouvelle mise à jour est disponible : Anti-Cheat " + new_version + " (" + new_codename + ") publiée le " + new_date + ".") print( "Veuillez utiliser la commande \"update\" pour mettre à jour vers la nouvelle version." ) tools.log( "[INFO] Une nouvelle mise à jour est disponible : Anti-Cheat " + new_version + " (" + new_codename + ") publiée le " + new_date + ".") else: print("Vous avez déjà la dernière version d'Anti-Cheat !") tools.log("[INFO] Aucune nouvelle mise à jour trouvée.") else: print("Vous avez déjà la dernière version d'Anti-Cheat !") tools.log("[INFO] Aucune nouvelle mise à jour trouvée.") except KeyboardInterrupt: os.remove("updates.json") return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] Une erreur est survenue pendant la recherche de mises à jour. Veuillez vérifier les fichiers Anti-Cheat.log et Anti-Cheat_traceback.log pour en savoir plus." + Style.RESET_ALL) tools.log( "[WARN] Une erreur est survenue pendant la recherche de mises à jour." ) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc()) os.remove("updates.json")
def check_updates(command): try: name = "Anti-Cheat EN" version = "v1.4.0" date = "04/09/19" print("Checking for updates ...") tools.log("[INFO] Checking for updates ...") check = subprocess.Popen(args=[ "setup\\curl.exe", "-s", "-f", "-k", "--output", "updates.json", "https://sh4fs0c13ty.tk/updates/updates.json" ]) check.wait() with open("updates.json") as json_file: data = json.load(json_file) for p in data: if "Anti-Cheat EN" == p['App']: new_version = p['Version'] new_codename = p['Codename'] new_url = p['Link'] new_date = p['Release date'] global new_checksum new_checksum = p['Checksum'] if version < new_version: if date < new_date: if command == "update": update(new_url) elif command == "check": print("A new update is available: Anti-Cheat " + new_version + " (" + new_codename + ") released on " + new_date + ".") print( "Please use the \"update\" command to update to the new version." ) tools.log( "[INFO] A new update is available: Anti-Cheat " + new_version + " (" + new_codename + ") released on " + new_date + ".") else: print("You already have the latest version of Anti-Cheat!") tools.log("[INFO] No new version available.") else: print("You already have the latest version of Anti-Cheat!") tools.log("[INFO] No new version available.") except KeyboardInterrupt: os.remove("updates.json") return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] An error occured while checking for updates. Please check the Anti-Cheat.log and Anti-Cheat_traceback.log files to know more." + Style.RESET_ALL) tools.log("[WARN] An error occured while checking for updates.") tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc()) os.remove("updates.json")
def json_check(pokid, usrid): try: global blacklisted print("[INFO] " + "Vérification de la liste des tricheurs Pokémon GO ...") tools.log("[INFO] " + "Vérification de la liste des tricheurs Pokémon GO ...") if os.path.isfile("lists\\cheaters.json") == False: tools.excel2json() with open("lists\\cheaters.json") as json_file: data = json.load(json_file) for p in data: if pokeid == p["Pseudo*"]: print(Fore.RED + Style.BRIGHT + "[WARN] " + "Tricheur Pokémon GO connu détecté." + Style.RESET_ALL) tools.log("[WARN] " + "Tricheur Pokémon GO connu détecté.") if os.path.isfile("lists\\Associated_IDs.txt") == False: f = open("lists\\Associated_IDs.txt", "w") f.write("Pokémon_GO_ID:Discord_ID\n") f.close() associated_ids = str(pokid + ":" + usrid + "\n") file = open("lists\\Associated_IDs.txt", "r").read() if file.find(associated_ids) != -1: print("[INFO] " + "IDs déjà associés : " + pokid + ":" + usrid) tools.log("[INFO] " + "IDs déjà associés : " + pokid + ":" + usrid) else: f = open("lists\\Associated_IDs.txt", "a") f.write(pokid + ":" + usrid + "\n") f.close() blacklisted = 1 if blacklisted != 1: print("[INFO] " + pokeid + " n'est pas dans la liste des tricheurs.") tools.log("[INFO] " + pokeid + " n'est pas dans la liste des tricheurs.") except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] Une erreur inconnue est survenue. Veuillez vérifier les fichiers Anti-Cheat.log et Anti-Cheat_traceback.log pour en savoir plus." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
def bcheck(userid): try: global blacklisted global pokeid blacklisted = 0 blacklist = open("lists\\blacklist.txt", "r") if os.path.isfile("servers_lists\\" + userid + "_servers_list.txt") == True: print("[INFO] " + "Vérification des serveurs sur la liste noire ...") tools.log("[INFO] " + "Vérification des serveurs sur la liste noire ...") guilds = open("servers_lists\\" + userid + "_servers_list.txt", "r") bline = blacklist.readlines() gline = guilds.readlines() for x in bline: x = x.split("\n", 1)[0] for y in gline: y = y.split("\n", 1)[0] if x == y: print("[INFO] " + "Serveur sur la liste noire trouvé !") tools.log("[INFO] " + "Serveur sur la liste noire trouvé !") blacklisted = 1 blacklist.close() guilds.close() if blacklisted != 1: print( "[INFO] " + "Aucun serveur présent sur la liste noire n'a été trouvé.") tools.log( "[INFO] " + "Aucun serveur présent sur la liste noire n'a été trouvé.") json_check(pokeid, userid) else: blacklisted = 2 except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] Une erreur inconnue est survenue. Veuillez vérifier les fichiers Anti-Cheat.log et Anti-Cheat_traceback.log pour en savoir plus." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
async def kick(ctx, user: discord.Member): try: username = str(user.name) print("[INFO] " + "Utilisateur éjecté : " + username + ".") tools.log("[INFO] " + "Utilisateur éjecté : " + username + ".") await user.send( ":flag_us: You have been kicked from the server. Please verify yourself again to access the server.\n:flag_fr: Vous avez été kické du serveur. Veuillez vous soumettre à une nouvelle vérification afin d'accéder au serveur." ) await ctx.guild.kick(user) except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] Une erreur inconnue est survenue. Veuillez vérifier les fichiers Anti-Cheat.log et Anti-Cheat_traceback.log pour en savoir plus." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
async def on_ready(): try: bot_id = str(bot.user.id) print("Connecté avec succès.") print("Nom : " + bot.user.name) print("ID : " + bot_id) print("========================") tools.log("[INFO] Connecté en tant que " + bot.user.name + " avec l'ID " + bot_id + ".") except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] Une erreur inconnue est survenue. Veuillez vérifier le fichier Anti-Cheat.log pour en savoir plus." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
async def on_ready(): try: bot_id = str(bot.user.id) print("Logged in successfully.") print("Name: " + bot.user.name) print("ID: " + bot_id) print("========================") tools.log("[INFO] Logged in as " + bot.user.name + " with ID " + bot_id + ".") except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] An unknown error occured. Please check the Anti-Cheat.log file to know more." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
async def kick(ctx, user: discord.Member): try: username = str(user.name) print("[INFO] " + "User kicked: " + username + ".") tools.log("[INFO] " + "User kicked: " + username + ".") await user.send( ":flag_us: You have been kicked from the server. Please verify yourself again to access the server.\n:flag_fr: Vous avez été kické du serveur. Veuillez vous soumettre à une nouvelle vérification afin d'accéder au serveur." ) await ctx.guild.kick(user) except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] An unknown error occured. Please check the Anti-Cheat.log and Anti-Cheat_traceback.log files to know more." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
def json_check(pokid, usrid): try: global blacklisted print("[INFO] " + "Checking Pokémon GO cheaters list ...") tools.log("[INFO] " + "Checking Pokémon GO cheaters list ...") if os.path.isfile("lists\\cheaters.json") == False: tools.excel2json() with open("lists\\cheaters.json") as json_file: data = json.load(json_file) for p in data: if pokeid == p["Pseudo*"]: print(Fore.RED + Style.BRIGHT + "[WARN] " + "Known Pokémon GO cheater detected." + Style.RESET_ALL) tools.log("[WARN] " + "Known Pokémon GO cheater detected.") if os.path.isfile("lists\\Associated_IDs.txt") == False: f = open("lists\\Associated_IDs.txt", "w") f.write("Pokémon_GO_ID:Discord_ID\n") f.close() associated_ids = str(pokid + ":" + usrid + "\n") file = open("lists\\Associated_IDs.txt", "r").read() if file.find(associated_ids) != -1: print("[INFO] " + "IDs already associated: " + pokid + ":" + usrid) tools.log("[INFO] " + "IDs already associated: " + pokid + ":" + usrid) else: f = open("lists\\Associated_IDs.txt", "a") f.write(pokid + ":" + usrid + "\n") f.close() blacklisted = 1 if blacklisted != 1: print("[INFO] " + pokeid + " is not in the cheaters list.") tools.log("[INFO] " + pokeid + " is not in the cheaters list.") except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] An unknown error occured. Please check the Anti-Cheat.log and Anti-Cheat_traceback.log files to know more." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
async def recheck_all(ctx): try: print( "[INFO] Une nouvelle vérification a été demandée à tout le monde.") tools.log( "[INFO] Une nouvelle vérification a été demandée à tout le monde.") await ctx.send( "@everyone\n[Pokémon GO Marseille]\n:flag_us: Everyone must be verified again, please follow the autorisation link and use ./verify to verify yourself.\n:flag_fr: Tout le monde doit être vérifié une nouvelle fois, veuillez suivre le lien d'autorisation et utilisez ./verify pour vous vérifier." ) for member in ctx.message.guild.members: userid = member.id flag = False role = get(ctx.guild.roles, name="Admin") if role in member.roles: flag = True if userid == bot.user.id: flag = True if flag != True: role = get(ctx.guild.roles, name="Verified") if role in member.roles: await member.remove_roles(role) role = get(ctx.guild.roles, name="instinct") if role in member.roles: await member.remove_roles(role) role = get(ctx.guild.roles, name="valor") if role in member.roles: await member.remove_roles(role) role = get(ctx.guild.roles, name="mystic") if role in member.roles: await member.remove_roles(role) if os.path.isfile("servers_lists\\" + str(userid) + "_servers_list.txt") == True: os.remove("servers_lists\\" + str(userid) + "_servers_list.txt") except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] Une erreur inconnue est survenue. Veuillez vérifier les fichiers Anti-Cheat.log et Anti-Cheat_traceback.log pour en savoir plus." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
async def on_member_join(member): try: global blacklisted blacklisted = 0 userid = str(member.id) username = str(member.name) print("[INFO] " + username + " a rejoint le serveur.") tools.log("[INFO] " + username + " a rejoint le serveur.") try: file = open("lists\\cheaters_ids.txt").read() if file.find(userid) != -1: print(Fore.RED + Style.BRIGHT + "[WARN] " + "L'utilisateur " + userid + " est dans la liste des tricheurs." + Style.RESET_ALL) print("[INFO] " + "Éjection de " + username + ".") tools.log("[WARN] " + "L'utilisateur " + userid + " est dans la liste des tricheurs.") tools.log("[INFO] " + "Éjection de " + username + ".") user = usr(userid) await member.guild.kick(user) else: print("[INFO] " + username + " n'est pas dans la liste des tricheurs.") tools.log("[INFO] " + username + " n'est pas dans la liste des tricheurs.") except: print( Fore.RED + Style.BRIGHT + "[WARN] La liste des tricheurs est manquante. Impossible de vérifier " + username + "." + Style.RESET_ALL) tools.log( "[WARN] La liste des tricheurs est manquante. Impossible de vérifier " + username + ".") except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] Une erreur inconnue est survenue. Veuillez vérifier les fichiers Anti-Cheat.log et Anti-Cheat_traceback.log pour en savoir plus." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
def ocr_core(filename): try: print("[INFO] " + "Processing OCR ...") tools.log("[INFO] " + "Processing OCR ...") text = pytesseract.image_to_string( Image.open(filename), lang="ita", config= "-c tessedit_char_whitelist=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789&" ) return text except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] An unknown error occured. Please check the Anti-Cheat.log and Anti-Cheat_traceback.log files to know more." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
def ocr_core(filename): try: print("[INFO] " + "OCR en cours ...") tools.log("[INFO] " + "OCR en cours ...") text = pytesseract.image_to_string( Image.open(filename), lang="ita", config= "-c tessedit_char_whitelist=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789&" ) return text except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] Une erreur inconnue est survenue. Veuillez vérifier les fichiers Anti-Cheat.log et Anti-Cheat_traceback.log pour en savoir plus." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
def bcheck(userid): try: global blacklisted global pokeid blacklisted = 0 blacklist = open("lists\\blacklist.txt", "r") if os.path.isfile("servers_lists\\" + userid + "_servers_list.txt") == True: print("[INFO] " + "Checking for blacklisted servers ...") tools.log("[INFO] " + "Checking for blacklisted servers ...") guilds = open("servers_lists\\" + userid + "_servers_list.txt", "r") bline = blacklist.readlines() gline = guilds.readlines() for x in bline: x = x.split("\n", 1)[0] for y in gline: y = y.split("\n", 1)[0] if x == y: print("[INFO] " + "Blacklisted server found!") tools.log("[INFO] " + "Blacklisted server found!") blacklisted = 1 blacklist.close() guilds.close() if blacklisted != 1: print("[INFO] " + "No blacklisted server found.") tools.log("[INFO] " + "No blacklisted server found.") json_check(pokeid, userid) else: blacklisted = 2 except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] An unknown error occured. Please check the Anti-Cheat.log and Anti-Cheat_traceback.log files to know more." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
async def on_member_join(member): try: global blacklisted blacklisted = 0 userid = str(member.id) username = str(member.name) print("[INFO] " + username + " joined the server.") tools.log("[INFO] " + username + " joined the server.") try: file = open("lists\\cheaters_ids.txt").read() if file.find(userid) != -1: print(Fore.RED + Style.BRIGHT + "[WARN] " + "User " + userid + " is in the cheaters list." + Style.RESET_ALL) print("[INFO] " + "Kicking " + username + ".") tools.log("[WARN] " + "User " + userid + " is in the cheaters list.") tools.log("[INFO] " + "Kicking " + username + ".") user = usr(userid) await member.guild.kick(user) else: print("[INFO] " + username + " is not in the cheaters list.") tools.log("[INFO] " + username + " is not in the cheaters list.") except: print(Fore.RED + Style.BRIGHT + "[WARN] Cheaters list is missing. Cannot verify " + username + "." + Style.RESET_ALL) tools.log("[WARN] Cheaters list is missing. Cannot verify " + username + ".") except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] An unknown error occured. Please check the Anti-Cheat.log and Anti-Cheat_traceback.log files to know more." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
def getid(file, userid): try: global filename filename = file ocr_result = ocr_core(file) if ocr_result.find("&") != -1: pokeid = text_process(ocr_result, userid) elif ocr_result.find("PROGRESDELASEMAINE") != -1: pokeid = text_processfr(ocr_result, userid, 1) elif ocr_result.find("PROGRSDELASEMAINE") != -1: pokeid = text_processfr(ocr_result, userid, 2) else: pokeid = "ERROR" os.remove(file) return pokeid except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] Une erreur inconnue est survenue. Veuillez vérifier les fichiers Anti-Cheat.log et Anti-Cheat_traceback.log pour en savoir plus." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
def getid(file, userid): try: global filename filename = file ocr_result = ocr_core(file) if ocr_result.find("&") != -1: pokeid = text_process(ocr_result, userid) elif ocr_result.find("PROGRESDELASEMAINE") != -1: pokeid = text_processfr(ocr_result, userid, 1) elif ocr_result.find("PROGRSDELASEMAINE") != -1: pokeid = text_processfr(ocr_result, userid, 2) else: pokeid = "ERROR" os.remove(file) return pokeid except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] An unknown error occured. Please check the Anti-Cheat.log and Anti-Cheat_traceback.log files to know more." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
def update(url): try: global done global new_checksum done = False t = threading.Thread(target=updating) t.start() tools.log("[INFO] Downloading new Anti-Cheat version at " + url) dl = subprocess.Popen(args=[ "setup\\curl.exe", "-s", "-f", "-k", "--output", "Anti-Cheat_EN.zip", url ]) dl.wait() if sha256sum("Anti-Cheat_EN.zip").lower() == new_checksum.lower(): tools.log("[INFO] Checksum verified for Anti-Cheat_EN.zip: " + new_checksum) tools.log("[INFO] Extracting Anti-Cheat_EN.zip archive ...") extract = subprocess.Popen( args=["setup\\7z.exe", "x", "Anti-Cheat_EN.zip", "-bb3", "-r"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) extract.wait() dir = os.getcwd() tools.log("[INFO] Removing new default config.json file.") os.remove(dir + "\\Anti-Cheat_Discord_Bot-master\\scripts\\config.json") tools.log( "[INFO] Copying new folder: Anti-Cheat_Discord_Bot-master/licenses." ) for root, dirs, files in os.walk( dir + "\\Anti-Cheat_Discord_Bot-master\\licenses"): for file in files: path_file = os.path.join(root, file) shutil.copy2(path_file, dir + "\\licenses") shutil.rmtree(dir + "\\Anti-Cheat_Discord_Bot-master\\licenses") tools.log( "[INFO] Removed new folder: Anti-Cheat_Discord_Bot-master/licenses." ) shutil.rmtree(dir + "\\Anti-Cheat_Discord_Bot-master\\lists") tools.log( "[INFO] Removed new folder: Anti-Cheat_Discord_Bot-master/lists." ) tools.log( "[INFO] Copying new folder: Anti-Cheat_Discord_Bot-master/scripts." ) for root, dirs, files in os.walk( dir + "\\Anti-Cheat_Discord_Bot-master\\scripts"): for file in files: path_file = os.path.join(root, file) shutil.copy2(path_file, dir + "\\scripts") shutil.rmtree(dir + "\\Anti-Cheat_Discord_Bot-master\\scripts") tools.log( "[INFO] Removed new folder: Anti-Cheat_Discord_Bot-master/scripts." ) shutil.rmtree(dir + "\\Anti-Cheat_Discord_Bot-master\\servers_lists") tools.log( "[INFO] Removed new folder: Anti-Cheat_Discord_Bot-master/servers_lists." ) tools.log( "[INFO] Copying new folder: Anti-Cheat_Discord_Bot-master/setup." ) for root, dirs, files in os.walk( dir + "\\Anti-Cheat_Discord_Bot-master\\setup"): for file in files: path_file = os.path.join(root, file) shutil.copy2(path_file, dir + "\\setup") shutil.rmtree(dir + "\\Anti-Cheat_Discord_Bot-master\\setup") tools.log( "[INFO] Removed new folder: Anti-Cheat_Discord_Bot-master/setup." ) shutil.rmtree(dir + "\\Anti-Cheat_Discord_Bot-master\\user_ids") tools.log( "[INFO] Removed new folder: Anti-Cheat_Discord_Bot-master/user_ids." ) tools.log( "[INFO] Copying new folder: Anti-Cheat_Discord_Bot-master/") for root, dirs, files in os.walk( dir + "\\Anti-Cheat_Discord_Bot-master"): for file in files: path_file = os.path.join(root, file) shutil.copy2(path_file, dir) shutil.rmtree(dir + "\\Anti-Cheat_Discord_Bot-master") tools.log( "[INFO] Removed new folder: Anti-Cheat_Discord_Bot-master/") tools.log("[INFO] Installing new Python requirements ...") pysetup = subprocess.Popen( args=["python", "-m", "pip", "-r", "setup\\requirements.txt"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) pysetup.wait() tools.log("[INFO] Anti-Cheat has been updated.") print( "[INFO] Anti-Cheat has been updated.\n\nPlease close this window without using the exit command and restart the Anti-Cheat main console." ) while True: time.sleep(1) else: done = True time.sleep(0.5) print( Fore.RED + Style.BRIGHT + "[WARN] Incorrect checksum. File may me corrupted or altered." + Style.RESET_ALL) print("[INFO] Aborting update.") tools.log( "[WARN] Incorrect checksum. File may me corrupted or altered.") tools.log("[INFO] Aborting update.") os.remove("Anti-Cheat_EN.zip") time.sleep(1) done = True except KeyboardInterrupt: done = True os.remove("updates.json") return except Exception as e: done = True time.sleep(0.5) print( Fore.RED + Style.BRIGHT + "[WARN] An error occured while updating. Please check the Anti-Cheat.log and Anti-Cheat_traceback.log files to know more." + Style.RESET_ALL) tools.log("[WARN] An error occured while updating.") tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
def update(url): try: global done global new_checksum done = False t = threading.Thread(target=updating) t.start() tools.log( "[INFO] Téléchargement de la nouvelle version d'Anti-Cheat version depuis " + url) dl = subprocess.Popen(args=[ "setup\\curl.exe", "-s", "-f", "-k", "--output", "Anti-Cheat_FR.zip", url ]) dl.wait() if sha256sum("Anti-Cheat_FR.zip").lower() == new_checksum.lower(): tools.log("[INFO] Somme vérifiée pour Anti-Cheat_FR.zip: " + new_checksum) tools.log("[INFO] Extraction de l'archive Anti-Cheat_FR.zip ...") extract = subprocess.Popen( args=["setup\\7z.exe", "x", "Anti-Cheat_FR.zip", "-bb3", "-r"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) extract.wait() dir = os.getcwd() tools.log( "[INFO] Suppression du nouveau fichier config.json par défaut." ) os.remove(dir + "\\Anti-Cheat_Discord_Bot-master\\scripts\\config.json") tools.log( "[INFO] Copie du nouveau dossier : Anti-Cheat_Discord_Bot-master/licenses." ) for root, dirs, files in os.walk( dir + "\\Anti-Cheat_Discord_Bot-master\\licenses"): for file in files: path_file = os.path.join(root, file) shutil.copy2(path_file, dir + "\\licenses") shutil.rmtree(dir + "\\Anti-Cheat_Discord_Bot-master\\licenses") tools.log( "[INFO] Suppression du nouveau dossier : Anti-Cheat_Discord_Bot-master/licenses." ) shutil.rmtree(dir + "\\Anti-Cheat_Discord_Bot-master\\lists") tools.log( "[INFO] Suppression du nouveau dossier : Anti-Cheat_Discord_Bot-master/lists." ) tools.log( "[INFO] Copie du nouveau dossier : Anti-Cheat_Discord_Bot-master/scripts." ) for root, dirs, files in os.walk( dir + "\\Anti-Cheat_Discord_Bot-master\\scripts"): for file in files: path_file = os.path.join(root, file) shutil.copy2(path_file, dir + "\\scripts") shutil.rmtree(dir + "\\Anti-Cheat_Discord_Bot-master\\scripts") tools.log( "[INFO] Suppression du nouveau dossier : Anti-Cheat_Discord_Bot-master/scripts." ) shutil.rmtree(dir + "\\Anti-Cheat_Discord_Bot-master\\servers_lists") tools.log( "[INFO] Suppression du nouveau dossier : Anti-Cheat_Discord_Bot-master/servers_lists." ) tools.log( "[INFO] Copie du nouveau dossier : Anti-Cheat_Discord_Bot-master/setup." ) for root, dirs, files in os.walk( dir + "\\Anti-Cheat_Discord_Bot-master\\setup"): for file in files: path_file = os.path.join(root, file) shutil.copy2(path_file, dir + "\\setup") shutil.rmtree(dir + "\\Anti-Cheat_Discord_Bot-master\\setup") tools.log( "[INFO] Suppression du nouveau dossier : Anti-Cheat_Discord_Bot-master/setup." ) shutil.rmtree(dir + "\\Anti-Cheat_Discord_Bot-master\\user_ids") tools.log( "[INFO] Suppression du nouveau dossier : Anti-Cheat_Discord_Bot-master/user_ids." ) tools.log( "[INFO] Copie du nouveau dossier : Anti-Cheat_Discord_Bot-master/" ) for root, dirs, files in os.walk( dir + "\\Anti-Cheat_Discord_Bot-master"): for file in files: path_file = os.path.join(root, file) shutil.copy2(path_file, dir) shutil.rmtree(dir + "\\Anti-Cheat_Discord_Bot-master") tools.log( "[INFO] Suppression du nouveau dossier : Anti-Cheat_Discord_Bot-master/" ) tools.log( "[INFO] Installation des nouvelles dépendances Python ...") pysetup = subprocess.Popen( args=["python", "-m", "pip", "-r", "setup\\requirements.txt"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) pysetup.wait() tools.log("[INFO] Anti-Cheat a été mis à jour.") print( "[INFO] Anti-Cheat a été mis à jour.\n\nVeuillez fermer cette fenêtre sans utiliser la commande exit et redémarrer la console principale d'Anti-Cheat." ) while True: time.sleep(1) else: done = True time.sleep(0.5) print( Fore.RED + Style.BRIGHT + "[WARN] Somme incorrecte. Le fichier peut être corrompu ou altéré." + Style.RESET_ALL) print("[INFO] Abandon de la mise à jour.") tools.log( "[WARN] Somme incorrecte. Le fichier peut être corrompu ou altéré." ) tools.log("[INFO] Abandon de la mise à jour.") os.remove("Anti-Cheat_FR.zip") time.sleep(1) done = True except KeyboardInterrupt: done = True os.remove("updates.json") return except Exception as e: done = True time.sleep(0.5) print( Fore.RED + Style.BRIGHT + "[WARN] Une erreur est survenue lors de la mise à jour. Veuillez vérifier les fichiers Anti-Cheat.log et Anti-Cheat_traceback.log pour en savoir plus." + Style.RESET_ALL) tools.log("[WARN] Une erreur est survenue lors de la mise à jour.") tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
def text_processfr(text, userid, idsep): try: if idsep == 1: sep = "PROGRESDELASEMAINE" if idsep == 2: sep = "PROGRSDELASEMAINE" rest = text.split(sep, 1)[0] file = open("user_ids\\" + userid + ".txt", "w") file.write(rest) file.close() file = open("user_ids\\" + userid + ".txt", "r") lines = file.read().splitlines() last_line = lines[-1] file.close() while last_line.find("et") == -1: lines = lines[:-1] last_line = lines[-1] lines = lines[:-1] last_line = lines[-1] if last_line != "": pass else: lines = lines[:-1] last_line = lines[-1] if " " in last_line: tools.log("[INFO] " + "OCR Result: " + last_line) print( Fore.RED + Style.BRIGHT + "[WARN] Found space in detected username. The following procedures could lead to errors." + Style.RESET_ALL) tools.log( "[WARN] Found space in detected username. The following procedures could lead to errors." ) last_line = fallback(userid, 1) file = open("user_ids\\" + userid + ".txt", "w") file.write(last_line) file.close() else: print("[INFO] " + "OCR Result: " + last_line) tools.log("[INFO] " + "OCR Result: " + last_line) file = open("user_ids\\" + userid + ".txt", "w") file.write(rest) file.close() return last_line except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] An unknown error occured. Please check the Anti-Cheat.log and Anti-Cheat_traceback.log files to know more." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc()) return "ERROR"
def fallback(userid, method): try: global filename print("[INFO] Using fallback function to detect username.") tools.log("[INFO] Using fallback function to detect username.") text = os.popen("tesseract -l ita " + filename + " stdout quiet").read() if method == 1: sep = "PROGRÈS DE LA SEMAINE" rest = text.split(sep, 1)[0] file = open("user_ids\\" + userid + ".txt", "w") file.write(rest) file.close() file = open("user_ids\\" + userid + ".txt", "r") lines = file.read().splitlines() last_line = lines[-1] while last_line.find("et") == -1: lines = lines[:-1] last_line = lines[-1] lines = lines[:-1] last_line = lines[-1] if last_line != "": pass else: lines = lines[:-1] last_line = lines[-1] if " " in last_line: sep = " " rest = last_line.split(sep, 1)[0] print("[INFO] " + "Fallback OCR Result: " + rest) tools.log("[INFO] " + "Fallback OCR Result: " + rest) return rest elif method == 2: sep = "&" rest = text.split(sep, 1)[0] file = open("user_ids\\" + userid + ".txt", "w") file.write(rest) file.close() file = open("user_ids\\" + userid + ".txt", "r") lastl = list(file)[-1] file.close() file = open("user_ids\\" + userid + ".txt", "w") file.write(lastl) file.close() file = open("user_ids\\" + userid + ".txt", "r") lines = file.read().splitlines() file.close() last_line = lastl if "\n" in last_line: sep = "\n" last_line = last_line.split(sep, 1)[0] else: pass if " " in last_line: sep = " " rest = last_line.split(sep, 1)[0] file = open("user_ids\\" + userid + ".txt", "w") file.write(rest) file.close() print("[INFO] " + "Fallback OCR Result: " + rest) tools.log("[INFO] " + "Fallback OCR Result: " + rest) return rest else: print(Fore.RED + Style.BRIGHT + "[WARN] Wrong fallback method. Aborting." + Style.RESET_ALL) tools.log("[WARN] Wrong fallback method. Aborting.") return "ERROR" except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] An unknown error occured. Please check the Anti-Cheat.log and Anti-Cheat_traceback.log files to know more." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc()) return "ERROR"
async def verify(ctx, url=None): try: global pokeid global blacklisted blacklisted = 0 userid = str(ctx.author.id) username = str(ctx.author.name) role = get(ctx.guild.roles, name="Verified") if role in ctx.author.roles: print(Fore.RED + Style.BRIGHT + "[WARN] " + username + " tried to use ./verify but is already verified." + Style.RESET_ALL) tools.log("[WARN] " + username + " tried to use ./verify but is already verified.") await ctx.message.delete() else: if url is None: try: url = str(ctx.message.attachments[0].url) except: print(Fore.RED + Style.BRIGHT + "[WARN] " + username + " used ./verify without any arguments." + Style.RESET_ALL) tools.log("[WARN] " + username + " used ./verify without any arguments.") await ctx.channel.purge(limit=None, check=lambda msg: not msg.pinned) print("[INFO] Channel cleared.") tools.log("[INFO] Channel cleared.") return 0 print("[INFO] " + username + " is being verified.") tools.log("[INFO] " + username + " is being verified.") get_img(url, userid) if pokeid == "ERROR": print( Fore.RED + Style.BRIGHT + "[WARN] Wrong Pokémon GO page submitted. Cannot verify " + username + "." + Style.RESET_ALL) tools.log( "[WARN] Wrong Pokémon GO page submitted. Cannot verify " + username + ".") await ctx.author.send( "[Pokémon GO Marseille]\n:flag_us: The image you submitted for verification is wrong!\n:flag_fr: L'image que vous avez soumis pour la vérification est incorrecte !" ) await ctx.channel.purge(limit=None, check=lambda msg: not msg.pinned) return 0 bcheck(userid) if blacklisted == 0: print("[INFO] " + "New verified user: "******".") tools.log("[INFO] " + "New verified user: "******".") await ctx.author.send( "[Pokémon GO Marseille]\n:flag_us: Welcome to the server Pokémon GO Marseille!\n:flag_fr: Bienvenue dans le serveur Pokémon GO Marseille !" ) role = get(ctx.guild.roles, name="Verified") await ctx.author.add_roles(role) print("[INFO] " + "Verified role applied to " + username + ".") tools.log("[INFO] " + "Verified role applied to " + username + ".") global team teamrole = get(ctx.guild.roles, name=team) await ctx.author.add_roles(teamrole) print("[INFO] " + team + " role applied to " + username + ".") tools.log("[INFO] " + team + " role applied to " + username + ".") await ctx.author.edit(nick=pokeid) print("[INFO] " + username + " nickname changed to " + pokeid + ".") tools.log("[INFO] " + username + " nickname changed to " + pokeid + ".") blacklisted = 0 if blacklisted == 1: print(Fore.RED + Style.BRIGHT + "[WARN] " + "Cheater detected!\n[WRAN] Kicking " + username + "." + Style.RESET_ALL) tools.log("[WARN] " + "Cheater detected!\n[WARN] Kicking " + username + ".") await ctx.author.send( "[Pokémon GO Marseille]\n https://cdn.discordapp.com/attachments/451360093607297054/599226877277634561/IMG_20190511_111313.jpg \n:flag_us: You have been detected as a cheater, please contact an administrator and prove that you are not a cheater to access the server.\n:flag_fr: Vous êtes soupçonné d'être un tricheur, veuillez contacter un administrateur et lui prouver que vous n'êtes pas un tricheur afin d'accéder au serveur." ) write_cheater_id(userid) user = usr(userid) await ctx.guild.kick(user) blacklisted = 0 if blacklisted == 2: print( Fore.RED + Style.BRIGHT + "[WARN] " + username + " did not authorize the bot to access his informations." + Style.RESET_ALL) tools.log( "[WARN] " + username + " did not authorize the bot to access his informations.") await ctx.author.send( ":flag_us: You must authorize the bot to access your informations before verifying yourself!\n:flag_fr: Vous devez autoriser le bot à accéder à vos informations avant de vous vérifier !" ) blacklisted = 0 await ctx.channel.purge(limit=None, check=lambda msg: not msg.pinned) print("[INFO] Channel cleared.") tools.log("[INFO] Channel cleared.") except KeyboardInterrupt: return except Exception as e: print( Fore.RED + Style.BRIGHT + "[WARN] An unknown error occured. Please check the Anti-Cheat.log and Anti-Cheat_traceback.log files to know more." + Style.RESET_ALL) tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc())
], creationflags=NEW_CONSOLE, startupinfo=info).pid print("Anti-Cheat OAauth2 module started with PID " + str(pid) + ".") tools.log("[INFO] Anti-Cheat OAauth2 module started with PID " + str(pid) + ".") f = open("scripts\\oauth_pid.txt", "w") f.write(str(pid)) f.close() pid2 = subprocess.Popen(args=["python", "scripts\\check.py", TOKEN], creationflags=NEW_CONSOLE, startupinfo=info2).pid print("Anti-Cheat Checker module started with PID " + str(pid2) + ".") tools.log("[INFO] Anti-Cheat Checker module started with PID " + str(pid2) + ".") f = open("scripts\\check_pid.txt", "w") f.write(str(pid2)) f.close() except KeyboardInterrupt: exit except Exception as e: tools.log("[ERRO] " + str(e)) tools.log_traceback(traceback.format_exc()) print( Fore.RED + Style.BRIGHT + "[WARN] An unknown error occured. Please check the Anti-Cheat.log and Anti-Cheat_traceback.log files to know more." + Style.RESET_ALL)