Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- - Copyright 2021 Ruri Gokou (Kuroneko-yousenpai)
- - Email: Kuronekoyousenpai@gmail.com
- - Telegram: https://t.me/Kuroneko_yousenpai
- - VK: https://vk.com/id466386210
- """
- import os
- import re
- import socket
- import sys
- from datetime import date, datetime
- from pathlib import Path
- import requests
- from bs4 import BeautifulSoup
- from pip._vendor.distlib.compat import raw_input
- from sty import fg, Style, RgbFg
- date_today : date = date.today()
- time_now : datetime = datetime.now()
- MAX_FILENAME_LENGTH = 259
- version : str = "1.0.5"
- input_file_path : str = "./"
- input_file_name : str = ""
- input_file : str
- output_file_path : str = './'
- output_file_name : str = "log" + "_" + "auths" + "_" + date_today.strftime("%d-%m-%y") + "_" + time_now.strftime("%H%M%S")
- output_file : str
- output_vk_ids_path : str = './'
- output_vk_ids_name : str = "log" + "_" + "vk_ids" + "_" + date_today.strftime("%d-%m-%y") + "_" + time_now.strftime("%H%M%S")
- output_vk_ids_file : str
- restrictions_for_path : str = r"^[a-zA-Zа-яА-Я0-9:/\\\\.\- ]*$"
- restrictions_for_filename : str = r"^[a-zA-Zа-яА-Я0-9._\- ]*$"
- ids_seen : set = set()
- vk_ids : list = []
- vk_ids_count : int = 0
- mail_ids : list = []
- mail_ids_count : int = 0
- okru_ids : list = []
- okru_ids_count : int = 0
- ampfinder : str = r"(?<=&)(amp;)"
- ampremover = re.compile(ampfinder)
- vk_url : str = "https://vk.com/id"
- vkontakte : str = "vkontakte"
- mail_ru : str = "mail_ru"
- okru : str = "odnoklassniki"
- viewer_id_regexp : str = r"(?<=&viewer_id=)(\d*)(?=&)"
- user_id_regexp : str = r"(?<=&user_id=)(\d*)(?=&)"
- vid_regexp : str = r"(?<=vid=)(\d*)(?=&)"
- oid_regexp : str = r"(?<=oid=)(\d*)(?=&)"
- okru_id_regexp : str = r"(?<=logged_user_id=)(\d*)(?=&)"
- sort_buffer : str = ""
- secondary_auths : list = []
- auth_vk_url : str = "https://markus.rmart.ru/engine/preloader/preloader.html"
- auth_mail_url : str = "https://markus.rmart.ru/wormix_mm/preloader/preloader.html"
- auth_okru_url : str = "https://markus.rmart.ru/wormix_ok/preloader/preloader.html"
- fg.red = Style(RgbFg(255, 0, 0))
- fg.lightgreen = Style(RgbFg(0, 255, 95))
- fg.lightblue = Style(RgbFg(217, 199, 255)) #For 256 colors terminal
- fg.lightblue2 = Style(RgbFg(135, 135, 255))
- #Yes/no
- def query_yes_no(question, default="yes"):
- """Ask a yes/no question via raw_input() and return their answer.
- "question" is a string that is presented to the user.
- "default" is the presumed answer if the user just hits <Enter>.
- It must be "yes" (the default), "no" or None (meaning
- an answer is required of the user).
- The "answer" return value is True for "yes" or False for "no".
- """
- valid = {"yes": True, "y": True, "yea": True,
- "no": False, "n": False, "nope": False}
- if default is None:
- prompt = " [y/n] "
- elif default == "yes":
- prompt = " [Y/n] "
- elif default == "no":
- prompt = " [y/N] "
- else:
- raise ValueError("invalid default answer: '%s'" % default)
- while True:
- sys.stdout.write(question + prompt)
- choice = raw_input().lower()
- if default is not None and choice == '':
- return valid[default]
- elif choice in valid:
- return valid[choice]
- else:
- sys.stdout.write("Please respond with 'yes' or 'no' ""(or 'y'/'n').\n")
- #Sort by social identifiers
- def SocialIdentifierSorter (uid, social):
- global vkontakte
- global mail_ru
- global okru
- global sort_buffer
- global ids_seen
- global vk_ids
- global mail_ids
- global okru_ids
- if uid and social == vkontakte:
- ids_seen.add(uid)
- vk_ids += [uid]
- print("VK ID: " + uid)
- sort_buffer = sort_buffer + auth_vk_url + line.rstrip('\n') + " " + "//VK ID: " + uid + ((" " + "|" + " " + "VK: " + GetSocialName(uid)) if (GetSocialName(uid)) else "") + " " + "|" + " " + "Url:" + " " + "https://vk.com/id" + uid + "\n"
- elif uid and social == mail_ru:
- ids_seen.add(uid)
- mail_ids += [uid]
- print("MAIL ID: " + uid)
- sort_buffer = sort_buffer + auth_mail_url + line.rstrip('\n') + " " + "//MM ID: " + uid + "\n"
- elif uid and social == okru:
- ids_seen.add(uid)
- okru_ids += [uid]
- print("OK.RU ID: " + uid)
- sort_buffer = sort_buffer + auth_okru_url + line.rstrip('\n') + " " + "//OK.RU ID: " + uid + "\n"
- #Check internet connection
- def internet_check(host="8.8.8.8", port=53, timeout=3):
- """
- Host: 8.8.8.8 (google-public-dns-a.google.com)
- OpenPort: 53/tcp
- Service: domain (DNS/TCP)
- """
- try:
- socket.setdefaulttimeout(timeout)
- socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))
- return True
- except socket.error as ex:
- print(ex)
- return False
- #Get social name by id
- def GetSocialName (social_id):
- if internet_check():
- url = vk_url + social_id
- # Making requests instance
- reqs = requests.get(url)
- # Using the BeaitifulSoup module
- soup = BeautifulSoup(reqs.text, 'html.parser')
- # Get title and return name
- for title in soup.find_all('title'):
- if title:
- page_title = title.get_text()
- splitted_title = page_title.split()
- if len(splitted_title) >= 4:
- name_from_title = splitted_title[0] + " " + splitted_title[1]
- return name_from_title
- else:
- return False
- else:
- return False
- #Сортировка ауткеев по группам: ауткеи вк, майла и одноклассников
- def SocialSorter(line_x):
- social_folders = {'engine': 1, 'wormix_mm': 2, 'wormix_ok': 3}
- line_fields = line_x.strip().split("/")
- if len(line_fields) >= 3:
- social = line_fields[3]
- return social_folders[social]
- else:
- return -1
- #Logs types (split by spaces count)
- def logs_type_first():
- return 3
- def logs_type_second():
- return 2
- def logs_type_third():
- return 1
- def logs_type_five():
- return int(input("Введите количество отступов до основной части ауткея: "))
- def logs_type_zero():
- return 0
- switch_logs_types = {
- 1: logs_type_first,
- 2: logs_type_second,
- 3: logs_type_third,
- 4: logs_type_zero,
- 5: logs_type_five
- }
- def switch_logs_type(logs_type):
- return switch_logs_types.get(logs_type, logs_type_zero)()
- print(f"{fg.red}Wormix Auths Sorter{fg.rs}" + "\n" + f"{fg.lightgreen}Version: {version}{fg.rs}" + "\n\n" + f"{fg.lightblue2}- Copyright 2021 Ruri Gokou (Kuroneko-yousenpai)" + "\n" + "- Email: Kuronekoyousenpai@gmail.com" + "\n" + "- Telegram: https://t.me/Kuroneko_yousenpai" + "\n" + "- VK: https://vk.com/id466386210" + f"{fg.rs}", end="\n\n")
- while True:
- try:
- while True:
- try:
- input_file_name = str(input("Укажите имя входного файла: "))
- if not re.match(restrictions_for_filename, input_file_name) or len(input_file_name) >= MAX_FILENAME_LENGTH:
- raise ("Restricted characters or too long file name!")
- question_filename = bool(query_yes_no("Всё правильно?"))
- print()
- if question_filename == True:
- input_file: str = input_file_path + input_file_name + '.txt'
- break
- except:
- print("Error: Invalid file name", end="\n\n")
- print("Файл лога должен находиться в одной папке с программой")
- question_filename_main = bool(query_yes_no("Или желаете указать полный путь до лога?"))
- print()
- if question_filename_main == True:
- while True:
- try:
- print("Пример: D:/Documents/Consollite/", end="\n\n")
- input_file_path = str(input("Укажите полный путь к файлу: "))
- if input_file_path[-1:] != "/":
- input_file_path = input_file_path + "/"
- if not (re.match(restrictions_for_path, input_file_path)):
- raise ("Restricted characters!")
- question_path = bool(query_yes_no("Всё правильно?"))
- print()
- if question_path == True:
- if os.path.exists(input_file_path):
- input_file: str = input_file_path + input_file_name + '.txt'
- break
- else:
- raise FileNotFoundError("Path are not existed!")
- except FileNotFoundError:
- print("Error: Path not found", end="\n\n")
- except ValueError:
- print("Error: File not found", end="\n\n")
- except:
- print("Error: Invalid path", end="\n\n")
- if os.path.isfile(input_file):
- break
- else:
- raise ValueError("File is not exist")
- except ValueError:
- print("Error: File not found", end="\n\n")
- except:
- print("Error: Something went wrong", end="\n\n")
- output_file = output_file_path + output_file_name + '.txt'
- print("Выходной файл сохраняется в той же директории, в которой находится программа")
- question_output_path_main = bool(query_yes_no("Желаете указать полный путь к выходному файлу?"))
- print()
- if question_output_path_main == True:
- while True:
- try:
- print("Пример: D:/Documents/Consollite/", end="\n\n")
- output_file_path = str(input("Укажите полный путь к файлу: "))
- if output_file_path[-1:] != "/":
- output_file_path = output_file_path + "/"
- if not (re.match(restrictions_for_path, output_file_path)):
- raise ("Restricted characters!")
- question_output_path = bool(query_yes_no("Всё правильно?"))
- print()
- if question_output_path == True:
- if os.path.exists(output_file_path):
- break
- else:
- print("Такой директории не существует!")
- question_dirnotexist = bool(query_yes_no("Хотите создать?"))
- print()
- if question_dirnotexist == True:
- try:
- Path(output_file_path).mkdir(parents=True, exist_ok=True)
- break
- except:
- raise ("Maybe program lack access...")
- else:
- raise ValueError("Path are not existed!")
- except ValueError:
- print("Error: Path not found", end="\n\n")
- except:
- print("Error: Invalid path", end="\n\n")
- question_output_filename_main = bool(query_yes_no("Желаете указать имя выходного файла?"))
- print()
- if question_output_filename_main == True:
- while True:
- try:
- output_file_name = str(input("Укажите желаемое имя выходного файла: "))
- print()
- if not re.match(restrictions_for_filename, output_file_name) or len(output_file_name) >= MAX_FILENAME_LENGTH:
- raise ValueError("Restricted characters or file name is too long!")
- output_file = output_file_path + output_file_name + '.txt'
- question_output_filename = bool(query_yes_no("Всё правильно?"))
- print()
- if question_output_filename == True:
- break
- except ValueError:
- print("Error: Invalid file name", end="\n\n")
- except:
- print("Error: Something went wrong", end="\n\n")
- question_urls = bool(query_yes_no("Хотите изменить ссылки для подставления?"))
- if question_urls == True:
- while True:
- question_vk_url = bool(query_yes_no("Изменить ссылку для ауткеев из вк?"))
- print()
- if question_vk_url == True:
- auth_vk_url = str(input("Укажите ссылку для ауткеев из вк: "))
- print()
- question_mail_url = bool(query_yes_no("Изменить ссылку для ауткеев из майла?"))
- print()
- if question_mail_url == True:
- auth_mail_url = str(input("Укажите ссылку для ауткеев из майла: "))
- print()
- question_okru_url = bool(query_yes_no("Изменить ссылку для ауткеев из одноклассников?"))
- print()
- if question_okru_url == True:
- auth_okru_url = str(input("Укажите ссылку для ауткеев из одноклассников: "))
- print()
- question_urls_confirmation = bool(query_yes_no("Всё правильно?"))
- print()
- if question_urls_confirmation == True:
- break
- while True:
- try:
- print()
- split_num_choice = int(input("Выберите формат логов: " + "\n" + "1 — [date] [time] [ip] auth" + "\n" + "2 — [date] [ip] auth" + "\n" + "3 — [ip] auth" + "\n" + "4 — auth" + "\n" + "5 — Свой вариант" + "\n\n" + "Если не знаете — ставьте 4" "\n\n" + "Enter number of choice: "))
- split_num = switch_logs_type(split_num_choice)
- question_splitnum = bool(query_yes_no("Всё правильно?"))
- print()
- if question_splitnum == True:
- break
- except:
- print("Error: Unknown logs format")
- #Sorting Hell
- # При проверке на дубликаты "viewer_id", "viewer_id" приоритетнее, чем "user_id"
- # Аналогично с "vid" и "oid", "vid" приоритетнее
- with open(input_file, 'r', errors='ignore') as logs_file, open(output_file, 'w+', errors='ignore') as logs_sorted_file:
- for line in logs_file.readlines():
- try:
- # Splitted by spaces
- splitted_line = line.split()
- if len(splitted_line) >= split_num:
- if re.search(viewer_id_regexp, splitted_line[split_num]) or re.search(user_id_regexp, splitted_line[split_num]) or re.search(vid_regexp, splitted_line[split_num]) or re.search(oid_regexp, splitted_line[split_num]) or re.search(okru_id_regexp, splitted_line[split_num]):
- line = splitted_line[split_num]
- # Удаляет всё до "?" вместе с вопросительным знаком и заменяет на вопросительный знак
- if re.search(r'^.*?\?', line):
- line = re.sub(r'^.*?\?', '?', line)
- # If at least one "amp;" are exists in line
- if re.search(ampfinder, line):
- line = ampremover.sub("", line)
- # Если нашлись ауткеи в ауткеях (два ауткея и более в одной строке)
- if len(line.split("?")) >= 3:
- split_by_qmark = line.split("?")
- split_by_qmark = list(filter(None, split_by_qmark))
- for i, auth in enumerate(split_by_qmark):
- additional_line = "?" + split_by_qmark[i] + "\n"
- secondary_auths += [additional_line]
- for line_secondaries in secondary_auths:
- if re.search(viewer_id_regexp, line_secondaries) or re.search(user_id_regexp, line_secondaries):
- if re.search(viewer_id_regexp, line_secondaries):
- viewer_id = re.search(viewer_id_regexp, line_secondaries).group()
- if re.search(user_id_regexp, line_secondaries):
- user_id = re.search(user_id_regexp, line_secondaries).group()
- if viewer_id and viewer_id != '0' and user_id and user_id != '0':
- if viewer_id not in ids_seen:
- SocialIdentifierSorter(viewer_id, vkontakte)
- elif user_id != viewer_id:
- if user_id not in ids_seen:
- SocialIdentifierSorter(user_id, vkontakte)
- elif viewer_id and viewer_id != '0' or user_id and user_id != '0':
- if viewer_id and viewer_id != '0':
- if viewer_id not in ids_seen:
- SocialIdentifierSorter(viewer_id, vkontakte)
- elif user_id and user_id != viewer_id and user_id != '0':
- if user_id not in ids_seen:
- SocialIdentifierSorter(user_id, vkontakte)
- elif re.search(vid_regexp, line_secondaries) or re.search(oid_regexp, line_secondaries):
- if re.search(vid_regexp, line_secondaries):
- mm_vid = re.search(vid_regexp, line_secondaries).group()
- if re.search(oid_regexp, line_secondaries):
- mm_oid = re.search(oid_regexp, line_secondaries).group()
- if mm_vid and mm_vid != '0' or mm_oid and mm_oid != '0':
- if mm_vid and mm_vid != '0':
- if mm_vid not in ids_seen:
- SocialIdentifierSorter(mm_vid, mail_ru)
- elif mm_oid and mm_oid != '0':
- if mm_oid not in ids_seen:
- SocialIdentifierSorter(mm_oid, mail_ru)
- elif re.search(okru_id_regexp, line_secondaries):
- okru_uid = re.search(okru_id_regexp, line_secondaries).group()
- if okru_uid and okru_uid != '0':
- if okru_uid not in ids_seen:
- SocialIdentifierSorter(okru_uid, okru)
- else:
- if re.search(viewer_id_regexp, line) or re.search(user_id_regexp, line):
- if re.search(viewer_id_regexp, line):
- viewer_id = re.search(viewer_id_regexp, line).group()
- if re.search(user_id_regexp, line):
- user_id = re.search(user_id_regexp, line).group()
- if viewer_id and viewer_id != '0' and user_id and user_id != '0':
- if viewer_id not in ids_seen:
- SocialIdentifierSorter(viewer_id, vkontakte)
- elif user_id != viewer_id:
- if user_id not in ids_seen:
- SocialIdentifierSorter(user_id, vkontakte)
- elif viewer_id and viewer_id != '0' or user_id and user_id != '0':
- if viewer_id and viewer_id != '0':
- if viewer_id not in ids_seen:
- SocialIdentifierSorter(viewer_id, vkontakte)
- elif user_id and user_id != viewer_id and user_id != '0':
- if user_id not in ids_seen:
- SocialIdentifierSorter(user_id, vkontakte)
- elif re.search(vid_regexp, line) or re.search(oid_regexp, line):
- if re.search(vid_regexp, line):
- mm_vid = re.search(vid_regexp, line).group()
- if re.search(oid_regexp, line):
- mm_oid = re.search(oid_regexp, line).group()
- if mm_vid and mm_vid != '0' or mm_oid and mm_oid != '0':
- if mm_vid and mm_vid != '0':
- if mm_vid not in ids_seen:
- SocialIdentifierSorter(mm_vid, mail_ru)
- elif mm_oid and mm_oid != '0':
- if mm_oid not in ids_seen:
- SocialIdentifierSorter(mm_oid, mail_ru)
- elif re.search(okru_id_regexp, line):
- okru_uid = re.search(okru_id_regexp, line).group()
- if okru_uid and okru_uid != '0':
- if okru_uid not in ids_seen:
- SocialIdentifierSorter(okru_uid, okru)
- except:
- ValueError("Probably, user set too high number for \"split_num\" variable")
- sort_buffer = sort_buffer.rstrip()
- for line in sort_buffer:
- logs_sorted_file.write(line)
- # Переставляем наконечник на начало файла, чтобы прочитать файл с самого начала и до конца
- logs_sorted_file.seek(0)
- auth_groups = 'VK auths', 'Mail.ru auths', 'Ok.ru auths'
- folds = ['engine', 'wormix_mm', 'wormix_ok']
- contents = logs_sorted_file.readlines()
- if contents:
- with open(output_file, 'w', errors='ignore') as logs_sorted_file:
- contents[-1] = f'{contents[-1]}\n'
- contents.sort(key=SocialSorter)
- for k, fold in enumerate(auth_groups):
- # Put enter before every category, except the first one
- if k != 0:
- logs_sorted_file.write(f'\n')
- # Conditional to test that category exists
- if any(line.strip().split("/")[3] == folds[k] for line in contents):
- # Put the label of each category
- logs_sorted_file.write(f'{auth_groups[k]}:\n')
- for i, line in enumerate(contents):
- # Put the right label in each category
- try:
- if line.strip().split("/")[3] == folds[k]:
- logs_sorted_file.write(f'{line}')
- except:
- pass
- if vk_ids != 0 or mail_ids != 0 or okru_ids != 0:
- if vk_ids != 0:
- for vk_id in vk_ids:
- vk_ids_count += vk_ids.count(vk_id)
- if mail_ids != 0:
- for mail_id in mail_ids:
- mail_ids_count += mail_ids.count(mail_id)
- if okru_ids != 0:
- for okru_uid in okru_ids:
- okru_ids_count += okru_ids.count(okru_uid)
- print()
- print(f"{fg.red}Total{fg.rs}:" + " " + str(vk_ids_count + mail_ids_count + okru_ids_count) + (" " + "|" + " " + "VK:" + " " + str(vk_ids_count) if (vk_ids_count != 0) else "") + (" " + "|" + " " + "Mail: " + str(mail_ids_count) if (mail_ids_count != 0) else "") + (" " + "|" + " " + "Ok.ru: " + str(okru_ids_count) if (okru_ids_count != 0) else ""))
- logs_sorted_file.write("\n" + "Total:" + " " + str(vk_ids_count + mail_ids_count + okru_ids_count) + (" " + "|" + " " + "VK:" + " " + str(vk_ids_count) if (vk_ids_count != 0) else "") + (" " + "|" + " " + "Mail: " + str(mail_ids_count) if (mail_ids_count != 0) else "") + (" " + "|" + " " + "Ok.ru: " + str(okru_ids_count) if (okru_ids_count != 0) else ""))
- if vk_ids and vk_ids != 0:
- print()
- question_vk_ids_main = bool(query_yes_no("Хотите создать файл с ссылками на всех вк пользователей ауткеев?"))
- print()
- if question_vk_ids_main == True:
- output_vk_ids_file = output_vk_ids_path + output_vk_ids_name + '.txt'
- print("Файл с ссылками на вк пользователей сохраняется в той же директории, в которой находится программа", end="\n\n")
- question_vk_ids_path = bool(query_yes_no("Желаете указать полный путь к файлу с ссылками на вк пользователей?"))
- print()
- if question_vk_ids_path == True:
- while True:
- try:
- print("Пример: D:/Documents/Consollite/", end="\n\n")
- output_vk_ids_path = str(input("Укажите полный путь к файлу: "))
- if (output_vk_ids_path[-1:] != "/"):
- output_vk_ids_path = output_file_path + "/"
- if not (re.match(restrictions_for_path, output_vk_ids_path)):
- raise ("Restricted characters!")
- question_output_vk_ids_path = bool(query_yes_no("Всё правильно?"))
- print()
- if question_output_vk_ids_path == True:
- if os.path.exists(output_vk_ids_path):
- break
- else:
- print("Такой директории не существует!")
- question_vk_ids_dirnotexist = bool(query_yes_no("Хотите создать?"))
- print()
- if question_vk_ids_dirnotexist == True:
- try:
- Path(output_vk_ids_path).mkdir(parents=True, exist_ok=True)
- break
- except:
- raise ValueError("Maybe program lack access...")
- else:
- raise ValueError("Path are not existed!")
- except ValueError:
- print("Error: Path not found", end="\n\n")
- except:
- print("Error: Invalid path")
- question_output_vk_ids_main = bool(query_yes_no("Желаете указать имя файла с ссылками на пользователей вк?"))
- if question_output_vk_ids_main == True:
- while True:
- try:
- output_vk_ids_name = str(input("Укажите желаемое имя выходного файла: "))
- if not re.match(restrictions_for_filename, output_vk_ids_name) or len(output_vk_ids_name) >= MAX_FILENAME_LENGTH:
- raise ValueError("Restricted characters or file name is too long!")
- output_vk_ids_file = output_vk_ids_path + output_vk_ids_name + '.txt'
- question_output_vk_ids_filename = bool(query_yes_no("Всё правильно?"))
- print()
- if question_output_vk_ids_filename == True:
- break
- except ValueError:
- print("Error: Invalid file name", end="\n\n")
- except:
- print("Error: Something went wrong")
- with open(output_vk_ids_file, 'w') as logs_vk_ids_file:
- for line in vk_ids:
- line = vk_url + line + "\n"
- logs_vk_ids_file.write(line)
- logs_vk_ids_file.write("\n" + "Total vk users: " + str(vk_ids_count))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement