qwiklabs: create qwiklabs account

still need to accept the confirmation email
master
EmaMaker 2021-08-25 18:16:54 +02:00
parent 022b5c967b
commit d475eede24
2 changed files with 121 additions and 60 deletions

View File

@ -1,87 +1,131 @@
from utils import browser_manager
from selenium.webdriver.common.by import By
import time
from selenium.webdriver.common.alert import Alert
from selenium.webdriver.common.alert import Command
from selenium.webdriver.common.alert import Alert, Command
from selenium.webdriver.common.keys import Keys
import requests
class QL_DeleteAccount:
def __init__(self, proxy, account):
import os
import urllib
# recaptcha libraries
import pydub
import speech_recognition as sr
from bs4 import BeautifulSoup
class QL_CreateACcount:
def __init__(self, proxy=False):
self.proxy = proxy
self.account = account
def create_account(self):
self.info = RandomNameGenerator(self.proxy).get_person_info()
self.driver = browser_manager.start_browser(self.proxy)
self.temp_mail = TempMail(self.driver).get_new_temp_mail()
self.name = RandomNameGenerator(self.proxy).get_person_info()
self.temp_mail = TempMail(self.proxy)
self.temp_mail_address = self.temp_mail.get_new_temp_mail()
self.sign_up()
self.delete()
print("Account created!".format(self.info, self.temp_mail_address))
def sign_up(self):
print("[+] Signing in using account [{}:{}]".format(self.account[0], self.account[1]))
print("[+] Creating a new account for with mail [{}:{}]".format(self.info, self.temp_mail_address))
self.driver.get("https://www.qwiklabs.com/users/sign_in")
self.driver.get("https://www.qwiklabs.com/users/sign_up")
time.sleep(1.5)
#accept goddamn cookies
browser_manager.clickButton(self.driver, By.XPATH, '/html/body/div[2]/div/button')
time.sleep(2)
browser_manager.inputText(self.driver, By.CSS_SELECTOR, "#user_email", self.account[0])
time.sleep(1.5)
browser_manager.inputText(self.driver, By.CSS_SELECTOR, "#user_password", self.account[1])
time.sleep(1.5)
browser_manager.clickButton(self.driver, By.CSS_SELECTOR, "#new_user > div.form-actions > button")
browser_manager.inputText(self.driver, By.CSS_SELECTOR, "#user_first_name", self.info[0], after_delay=1.5)
browser_manager.inputText(self.driver, By.CSS_SELECTOR, "#user_last_name", self.info[1], after_delay=1.5)
browser_manager.inputText(self.driver, By.CSS_SELECTOR, "#user_email", self.temp_mail_address, after_delay=1.5)
browser_manager.inputText(self.driver, By.CSS_SELECTOR, "#user_company_name", self.info[2], after_delay=1.5)
browser_manager.inputText(self.driver, By.CSS_SELECTOR, "#user_password", "hellogoodbye", after_delay=1.5)
browser_manager.inputText(self.driver, By.CSS_SELECTOR, "#user_password_confirmation", "hellogoodbye", after_delay=1.5)
time.sleep(5)
def delete(self):
# Click on profile icon, it's under a shadow-dom element
root1 = self.driver.find_element_by_css_selector("#my_account")
shadow = browser_manager.expand_shadow_element(self.driver, root1)
profile = shadow.find_element_by_css_selector('.ql-icon-button')
profile.click()
time.sleep(2)
# head over to settings
settings = self.driver.find_element_by_css_selector('#settings')
settings.click()
time.sleep(2)
#accept goddamn cookies
browser_manager.clickButton(self.driver, By.XPATH, '/html/body/div[2]/div/button')
time.sleep(2)
# select 'security' tab
root1 = browser_manager.waitForElement(self.driver, By.XPATH, '/html/body/ql-drawer-container/ql-drawer/ql-sidenav/ql-sidenav-item[4]')
shadow = browser_manager.expand_shadow_element(self.driver, root1)
root1.click()
time.sleep(2)
# button = shadow.find_element_by_css_selector('.sidenav-item')
# button.click()
browser_manager.clickButton(self.driver, By.XPATH, '/html/body/ql-drawer-container/ql-drawer-content/main/div[3]/div[2]/div/a')
self.resolve_captcha()
time.sleep(5)
self.driver.find_element_by_xpath('/html/body/div[1]/div[1]/div[2]/form[2]/div[9]/button').click()
#delete history
browser_manager.clickButton(self.driver, By.CSS_SELECTOR, '#delete_account_history_are_you_sure > div > div > div > a:nth-child(2)')
time.sleep(8)
def resolve_captcha(self):
# switch to recaptcha frame
# frames = self.driver.find_elements_by_tag_name("iframe")
# self.driver.switch_to.frame(frames[0])
self.driver.switch_to.frame(self.driver.find_element_by_xpath('/html/body/div[1]/div[1]/div[2]/form[2]/div[8]/div/div/iframe'))
browser_manager.delay(self.driver)
# click on checkbox to activate recaptcha
self.driver.find_element_by_class_name("recaptcha-checkbox").click()
# switch to recaptcha audio control frame
self.driver.switch_to.default_content()
frames = self.driver.find_element_by_xpath("/html/body/div[4]/div[4]").find_elements_by_tag_name("iframe")
self.driver.switch_to.frame(frames[0])
browser_manager.delay(self.driver)
# click on audio challenge
self.driver.find_element_by_id("recaptcha-audio-button").click()
# switch to recaptcha audio challenge frame
self.driver.switch_to.default_content()
frames = self.driver.find_elements_by_tag_name("iframe")
self.driver.switch_to.frame(frames[-1])
browser_manager.delay(self.driver)
# get the mp3 audio file
src = self.driver.find_element_by_id("audio-source").get_attribute("src")
print("[INFO] Audio src: %s" % src)
# download the mp3 audio file from the source
urllib.request.urlretrieve(src, os.path.normpath(os.getcwd() + "\\sample.mp3"))
browser_manager.delay(self.driver)
# load downloaded mp3 audio file as .wav
try:
sound = pydub.AudioSegment.from_mp3(os.path.normpath(os.getcwd() + "\\sample.mp3"))
sound.export(os.path.normpath(os.getcwd() + "\\sample.wav"), format="wav")
sample_audio = sr.AudioFile(os.path.normpath(os.getcwd() + "\\sample.wav"))
except Exception:
print("[ERR] Please run program as administrator or download ffmpeg manually, "
"http://blog.gregzaal.com/how-to-install-ffmpeg-on-windows/")
# translate audio to text with google voice recognition
r = sr.Recognizer()
with sample_audio as source:
audio = r.record(source)
key = r.recognize_google(audio)
print("[INFO] Recaptcha Passcode: %s" % key)
# key in results and submit
self.driver.find_element_by_id("audio-response").send_keys(key.lower())
self.driver.find_element_by_id("audio-response").send_keys(Keys.ENTER)
self.driver.switch_to.default_content()
browser_manager.delay(self.driver)
# self.driver.find_element_by_id("recaptcha-verify-button").click()
# browser_manager.delay(self.driver)
# finally accept the deletition of the account
al = self.driver.switch_to.alert
al.accept()
def accept_eula(self):
self.driver.get(self.temp_mail.get_confirmation_link())
#insert password
browser_manager.inputText(self.driver, By.CSS_SELECTOR, "#user_password", "hellogoodbye + \n", after_delay=1.5)
print("Account {} deleted!".format(self.account))
class RandomNameGenerator():
def __init__(self, proxy):
def __init__(self, proxy=False):
self.proxy = proxy
self.proxyDict = {
"socks" : proxy,
"socksVersion" : 5
}
}
def get_person_info(self):
if self.proxy:
@ -95,16 +139,33 @@ class RandomNameGenerator():
company = r.json()['results'][0]['location']['city']
return (firstname, lastname, company)
# get a temp mail from https://www.1secmail.com/api/ and handle it using requests
class TempMail:
def __init__(self, browser):
self.browser = browser
def __init__(self, proxy=False):
self.proxy = proxy
self.proxyDict = {
"socks" : proxy,
"socksVersion" : 5
}
# Open a new tab, head over to temp-mail.org, click the delete button and get a new temp mail
def get_new_temp_mail(self):
# open new tab and switch to it
self.browser.execute_script("window.open('https://temp-mail.org', 'tmp-mail');")
self.browser.switch_to.window('tmp-mail')
self.email = requests.get('https://www.1secmail.com/api/v1/?action=genRandomMailbox', proxies=self.proxyDict).json()[0]
return self.email
# Wait for qwiklabs confirmation email to arrive, click it
def accept_email(self):
pass
def accept_eula(self):
fetched_msg = requests.get('https://www.1secmail.com/api/v1/?action=getMessages&login=' + self.email.split('@')[0] + '&domain='+self.email.split('@')[1], proxies=self.proxyDict)
msg_id = requests[0]['id']
email = requests.get('https://www.1secmail.com/api/v1/?action=readMessage&login=' + self.email.split('@')[0] + '&domain='+self.email.split('@')[1] + '&id=' + str(id_msg))
body = email.json()['body']
soup = BeautifulSoup(body, 'html.parser')
soup = soup.prettify()
a = ""
for link in soup.find_all('a'):
if 'confirmation' in link.get('href'):
a = link.get('href')
return a