Skip to content

Commit

Permalink
Address issue #8
Browse files Browse the repository at this point in the history
  • Loading branch information
FBroy committed Aug 17, 2021
1 parent 69157ae commit e391522
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 87 deletions.
94 changes: 48 additions & 46 deletions bin/accountCreator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
import logging
import re
import time

Expand All @@ -12,6 +13,8 @@
from selenium.webdriver.support.ui import WebDriverWait


logging.basicConfig(format='%(asctime)s %(name)s %(levelname)s:%(message)s', level=logging.INFO, datefmt='%I:%M:%S')

# Parse the arguments
parser = argparse.ArgumentParser()
parser.add_argument("password", help="the password you want to use")
Expand All @@ -20,34 +23,34 @@

# Generate a random email address
email = generate_email_address(size=10, storeInFile='credentials.txt', mode='w')
open('credentials.txt', 'a').write('\n{}'.format(args.password))
with open('credentials.txt', 'a') as f:
f.write(f'\n{args.password}')
username = email.split('@')[0]

options = Options()
options.headless = True

f = open("instances.txt", 'r')
instances = f.readlines()
f.close()
with open("instances.txt", 'r') as f:
instances = f.readlines()
if args.verbose:
print("Starting account creation...\n")
logging.info("Starting account creation...\n")
browser = webdriver.Firefox(options=options)
browser.set_page_load_timeout(10)

# Looping through the instances in 'instances.txt'
for instance in instances:
if args.verbose:
print(instance.replace('\n', ''))
logging.info(instance.replace('\n', ''))
unreachable = False

# Request the page
try:
browser.get('https://'+instance)
browser.get(f'https://{instance}')
# If the page is not loaded within 10 seconds, skip it
except TimeoutException:
unreachable = True
if args.verbose:
print("Unreachable!\n")
logging.error("Unreachable!\n")
continue
if unreachable:
continue
Expand Down Expand Up @@ -86,68 +89,67 @@
finally:
if approval:
if args.verbose:
print("Approval required, skipping...\n")
logging.error("Approval required, skipping...\n")
continue
time.sleep(2)
browser.find_elements_by_name('button')[0].click()
time.sleep(5)
if args.verbose:
print("Registered successfully!\n")
logging.info("Registered successfully!\n")
continue

except:
if args.verbose:
print("This instance is either private, doesn't accept new registrations, has a custom login page or none at all, or something else went wrong.\n")
logging.error("This instance is either private, doesn't accept new registrations, has a custom login page or none at all, or something else went wrong.\n")
continue

if args.verbose:
print("Account creation done!\n")
logging.info("Account creation done!\n")
time.sleep(5)

# Fetch the emails from the server
login_id = email[:email.find('@')]
login_domain = email[email.find('@')+1:]
http_get_url = "https://www.1secmail.com/api/v1/?action=getMessages&login="+login_id+"&domain="+login_domain
http_get_url = f"https://www.1secmail.com/api/v1/?action=getMessages&login={login_id}&domain={login_domain}"
response = requests.get(http_get_url)
if not response.status_code == 200:
print("Invalid server response code ", response.status_code)
logging.error("Invalid server response code ", response.status_code)
response = response.json()

if args.verbose:
print("Starting email verification...\n")
f = open('readyInstances.txt', 'w')

# Loop through the emails and verify the address to finish the account creation
for nm in range(len(response)):
failed = False
# Get the emails
http_get_url_single = "https://www.1secmail.com/api/v1/?action=readMessage&login="+login_id+"&domain="+login_domain+"&id="+str(response[nm]['id'])
response2 = requests.get(http_get_url_single)
response2 = response2.json()
try:
# Search for the email verification code
confirmationLink = re.findall('https://.*/auth/.*'.format(instance), response2['textBody'])[0]
if args.verbose:
print(confirmationLink)
# Open the email verification link to verify the email
logging.info("Starting email verification...\n")

with open('readyInstances.txt', 'w') as f:
# Loop through the emails and verify the address to finish the account creation
for nm in range(len(response)):
failed = False
# Get the emails
http_get_url_single = f"https://www.1secmail.com/api/v1/?action=readMessage&login={login_id}&domain={login_domain}&id={str(response[nm]['id'])}"
response2 = requests.get(http_get_url_single)
response2 = response2.json()
try:
browser.get(confirmationLink)
except TimeoutException:
failed = True
continue
if failed:
# Search for the email verification code
confirmationLink = re.findall('https://.*/auth/.*', response2['textBody'])[0]
if args.verbose:
logging.info(confirmationLink)
# Open the email verification link to verify the email
try:
browser.get(confirmationLink)
except TimeoutException:
failed = True
continue
if failed:
continue
time.sleep(2)

# Extract the link and add it to the instances which are ready to be used
url = confirmationLink.split('/auth')[0].replace('https://', '')
if args.verbose:
logging.info(f'{url}\n')
f.write(f'{url}\n')
except:
continue
time.sleep(2)

# Extract the link and add it to the instances which are ready to be used
url = confirmationLink.split('/auth')[0].replace('https://', '')
if args.verbose:
print(url+'\n')
f.write(url+'\n')
except:
continue

browser.close()
f.close()
if args.verbose:
print("Email verification done!\n")
logging.info("Email verification done!\n")
Loading

0 comments on commit e391522

Please sign in to comment.