1- import ctypes
2- import os
3- import shutil
4- import socket
5- import ssl
6- import sys
7- import time
1+ import socket as dsocket
82from contextlib import suppress
3+ from ctypes import windll
94from dataclasses import dataclass
105from json import load
11- from random import randint , choice , randrange
6+ from os import getcwd , listdir , chdir , remove , mkdir , path , name
7+ from random import choice , randrange
8+ from random import randint
9+ from shutil import copytree , rmtree , copyfile
10+ from ssl import create_default_context
11+ from sys import exit
12+ from time import sleep , time
1213from typing import Any
1314from urllib .parse import urlparse
1415from zipfile import ZipFile
1516
16- import requests
1717from colorama import Fore
18+ from requests import get
1819from selenium import webdriver
1920from selenium .webdriver .chrome .webdriver import WebDriver
2021from selenium .webdriver .common .by import By
2122from selenium .webdriver .support .select import Select
2223from tqdm import tqdm
2324from twocaptcha import TwoCaptcha
2425
25- import anycaptcha
2626from Utils import Utils , Timer
27+ from anycaptcha import AnycaptchaClient , FunCaptchaProxylessTask
2728
2829# Some Value
2930eGenerated = 0
3031solvedCaptcha = 0
3132
33+
3234class AutoUpdater :
3335 def __init__ (self , version ):
3436 self .version = version
3537 self .latest = self .get_latest ()
36- self .this = os . getcwd ()
37- self .file = os . getenv ( "TEMP" ) + "\ latest.zip"
38- self .folder = os . getenv ( "TEMP" ) + f"\ latest_{ randrange (1_000_000 , 999_999_999 )} "
38+ self .this = getcwd ()
39+ self .file = "temp/ latest.zip"
40+ self .folder = f"temp/ latest_{ randrange (1_000_000 , 999_999_999 )} "
3941
4042 @dataclass
4143 class latest_data :
4244 version : str
4345 zip_url : str
4446
4547 def get_latest (self ):
46- rjson = requests . get ("https://api.github.com/repos/MatrixTM/OutlookGen/tags" ).json ()
47- return self .latest_data (version = rjson [0 ]["name" ], zip_url = requests . get (rjson [0 ]["zipball_url" ]).url )
48+ rjson = get ("https://api.github.com/repos/MatrixTM/OutlookGen/tags" ).json ()
49+ return self .latest_data (version = rjson [0 ]["name" ], zip_url = get (rjson [0 ]["zipball_url" ]).url )
4850
4951 @staticmethod
50- def download (host , path , filename ):
51- with socket .socket (socket .AF_INET , socket .SOCK_STREAM ) as sock :
52- context = ssl . create_default_context ()
52+ def download (host , dPath , filename ):
53+ with dsocket .socket (dsocket .AF_INET , dsocket .SOCK_STREAM ) as sock :
54+ context = create_default_context ()
5355 with context .wrap_socket (sock , server_hostname = "api.github.com" ) as wrapped_socket :
54- wrapped_socket .connect ((socket .gethostbyname (host ), 443 ))
56+ wrapped_socket .connect ((dsocket .gethostbyname (host ), 443 ))
5557 wrapped_socket .send (
56- f"GET { path } HTTP/1.1\r \n Host:{ host } \r \n Accept: text/html,application/xhtml+xml,application/xml;q=0.9,file/avif,file/webp,file/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9\r \n \r \n " .encode ())
58+ f"GET { dPath } HTTP/1.1\r \n Host:{ host } \r \n Accept: text/html,application/xhtml+xml,application/xml;q=0.9,file/avif,file/webp,file/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9\r \n \r \n " .encode ())
5759
5860 resp = b""
5961 while resp [- 4 :- 1 ] != b"\r \n \r " :
@@ -75,30 +77,33 @@ def download(host, path, filename):
7577
7678 def update (self ):
7779 if not self .version == self .latest .version :
80+ rmtree ("temp" ) if path .exists ("temp" ) else ""
81+ mkdir ("temp" )
7882 print ("Updating Script..." )
7983 parsed = urlparse (self .latest .zip_url )
8084 self .download (parsed .hostname , parsed .path , self .file )
8185 ZipFile (self .file ).extractall (self .folder )
82- os .chdir ("{}\\ {}" .format (self .folder , os .listdir (self .folder )[0 ]))
83- for files in os .listdir ():
84- if os .path .isdir (files ):
86+ print (path .exists (self .folder ))
87+ print (path .exists (listdir (self .folder )[0 ]))
88+ chdir ("{}/{}" .format (self .folder , listdir (self .folder )[0 ]))
89+ for files in listdir ():
90+ if path .isdir (files ):
8591 with suppress (FileNotFoundError ):
86- shutil . rmtree ("{}\\ {}" .format (self .this , files ))
87- shutil . copytree (files , "{}\\ {}" .format (self .this , files ))
92+ rmtree ("{}/ {}" .format (self .this , files ))
93+ copytree (files , "{}/ {}" .format (self .this , files ))
8894 else :
8995 with suppress (FileNotFoundError ):
90- os .remove ("{}\\ {}" .format (self .this , files ))
91- shutil .copyfile (files , "{}\\ {}" .format (self .this , files ))
96+ remove ("{}/{}" .format (self .this , files ))
97+ copyfile (files , "{}/{}" .format (self .this , files ))
98+ rmtree ("../../../temp" )
9299 exit ("Run Script Again!" )
93100 return
94101 print ("Script is up to date!" )
95102
96103
97-
98-
99104class eGen :
100105 def __init__ (self ):
101- self .version = "v1.2.1 "
106+ self .version = "v1.2.2 "
102107 AutoUpdater (self .version ).update ()
103108 self .Utils = Utils () # Utils Module
104109 self .config : Any = load (open ('config.json' )) # Config File
@@ -123,7 +128,7 @@ def __init__(self):
123128 for arg in tqdm (self .config ["DriverArguments" ], desc = 'Loading Arguments' ,
124129 bar_format = '{desc} | {l_bar}{bar:15} | {percentage:3.0f}%' ): # Get Driver Arguments
125130 self .options .add_argument (arg ) # Add Argument to option
126- time . sleep (0.2 )
131+ sleep (0.2 )
127132
128133 # More Options
129134 self .options .add_experimental_option ("excludeSwitches" , ["enable-automation" ])
@@ -142,8 +147,8 @@ def solver(self, site_url, browser):
142147
143148 # AnyCaptcha
144149 elif self .providers == 'anycaptcha' :
145- client = anycaptcha . AnycaptchaClient (self .api_key )
146- task = anycaptcha . FunCaptchaProxylessTask (site_url , self .site_key )
150+ client = AnycaptchaClient (self .api_key )
151+ task = FunCaptchaProxylessTask (site_url , self .site_key )
147152 job = client .createTask (task , typecaptcha = "funcaptcha" )
148153 self .print ("Solving funcaptcha" )
149154 job .join ()
@@ -157,7 +162,7 @@ def solver(self, site_url, browser):
157162
158163 def check_proxy (self , proxy ):
159164 with suppress (Exception ):
160- requests . get ("https://outlook.live.com" , proxies = {
165+ get ("https://outlook.live.com" , proxies = {
161166 "http" : "http://{}" .format (proxy ),
162167 "https" : "http://{}" .format (proxy )
163168 }, timeout = self .config ["ProxyCheckTimeout" ])
@@ -168,11 +173,10 @@ def fElement(self, driver: WebDriver, by: By = By.ID, value=None, delay: float =
168173 # Custom find Element Function
169174 count = 0
170175 while count <= 100 :
171- try :
176+ with suppress ( Exception ) :
172177 return driver .find_element (by , value )
173- except :
174- time .sleep (delay )
175- count += 1
178+ sleep (delay )
179+ count += 1
176180 self .print (f'tried 100 time to find element...' )
177181 driver .quit ()
178182 return
@@ -182,14 +186,14 @@ def get_balance(self):
182186 if self .providers == 'twocaptcha' :
183187 return TwoCaptcha (self .api_key ).balance ()
184188 elif self .providers == 'anycaptcha' :
185- return anycaptcha . AnycaptchaClient (self .api_key ).getBalance ()
189+ return AnycaptchaClient (self .api_key ).getBalance ()
186190
187191 def update (self ):
188192 # Update Title Function
189193 global eGenerated , solvedCaptcha
190194 title = f'Email Generated: { eGenerated } | Solved Captcha: { solvedCaptcha } | Balance: { self .get_balance ()} '
191- ctypes . windll .kernel32 .SetConsoleTitleW (title ) if os . name == 'nt' else print (f'\33 ]0;{ title } \a ' , end = '' ,
192- flush = True )
195+ windll .kernel32 .SetConsoleTitleW (title ) if name == 'nt' else print (f'\33 ]0;{ title } \a ' , end = '' ,
196+ flush = True )
193197
194198 def generate_info (self ):
195199 # Generate Information Function
@@ -204,7 +208,7 @@ def checkConfig(self):
204208 if captcha_sec ['api_key' ] == "" or captcha_sec ['providers' ] == "anycaptcha/twocaptcha" or \
205209 self .config ['EmailInfo' ]['Domain' ] == "@hotmail.com/@outlook.com" :
206210 self .print ('Please Fix Config!' )
207- sys . exit ()
211+ exit ()
208212
209213 def print (self , text : object , end : str = "\n " ):
210214 # Print With Prefix Function
@@ -232,12 +236,12 @@ def CreateEmail(self, driver: WebDriver):
232236 global eGenerated , solvedCaptcha
233237 self .update ()
234238 driver .set_page_load_timeout (5 )
235- self .Timer .start (time . time ()) if self .config ["Common" ]['Timer' ] else ''
239+ self .Timer .start (time ()) if self .config ["Common" ]['Timer' ] else ''
236240 driver .get ("https://outlook.live.com/owa/?nlp=1&signup=1" )
237241 assert 'Create' in driver .title
238242 if self .config ['EmailInfo' ]['Domain' ] == "@hotmail.com" :
239243 domain = self .fElement (driver , By .ID , 'LiveDomainBoxList' )
240- time . sleep (0.1 )
244+ sleep (0.1 )
241245 domainObject = Select (domain )
242246 domainObject .select_by_value ('hotmail.com' )
243247 emailInput = self .fElement (driver , By .ID , 'MemberName' )
@@ -272,13 +276,13 @@ def CreateEmail(self, driver: WebDriver):
272276 self .fElement (driver , By .ID , 'iSignupAction' ).click ()
273277 driver .switch_to .frame (self .fElement (driver , By .ID , 'enforcementFrame' ))
274278 token = self .solver (driver .current_url , self .driver )
275- time . sleep (0.5 )
279+ sleep (0.5 )
276280 driver .execute_script (
277281 'parent.postMessage(JSON.stringify({eventId:"challenge-complete",payload:{sessionToken:"' + token + '"}}),"*")' )
278282 self .print ("&aCaptcha Solved" )
279283 self .update ()
280284 self .fElement (driver , By .ID , 'idBtn_Back' ).click ()
281- self .print (f'Email Created in { str (self .Timer .timer (time . time ())).split ("." )[0 ]} s' ) if \
285+ self .print (f'Email Created in { str (self .Timer .timer (time ())).split ("." )[0 ]} s' ) if \
282286 self .config ["Common" ]['Timer' ] else self .print ('Email Created' )
283287 eGenerated += 1
284288 self .Utils .logger (self .email + self .config ['EmailInfo' ]['Domain' ], self .password )
@@ -287,7 +291,7 @@ def CreateEmail(self, driver: WebDriver):
287291 except Exception as e :
288292 if e == KeyboardInterrupt :
289293 driver .quit ()
290- sys . exit (0 )
294+ exit (0 )
291295 self .print ("&4Something is wrong | %s" % str (e ).split ("\n " )[0 ].strip ())
292296 finally :
293297 driver .quit ()
0 commit comments