qwiklabs: delete accounts using selenium

master
EmaMaker 2021-08-24 21:31:49 +02:00
parent d644e704f8
commit ecf5a061bb
6 changed files with 99 additions and 16 deletions

View File

@ -1,13 +1,21 @@
from ngrok import ngrok
from colab import colab
import time
from qwiklabs import delete_account
c = colab.ColabGist('https://colab.research.google.com/gist/EmaMaker/4e1478c9913a2df58fc1b8ff422fa161/proxy.ipynb', ('giangillo.rossi@gmail.com', 'emamaker02'), minutes=3)
c.run()
def start_proxy_get_ip():
c = colab.ColabGist('https://colab.research.google.com/gist/EmaMaker/4e1478c9913a2df58fc1b8ff422fa161/proxy.ipynb', ('giangillo.rossi@gmail.com', 'emamaker02'), minutes=3)
c.run()
time.sleep(120)
time.sleep(120)
n = ngrok.Ngrok()
n.start_browser()
n.access_ngrok()
print(n.get_proxy_ip())
n = ngrok.Ngrok()
n.start_browser()
n.access_ngrok()
print(n.get_proxy_ip())
def delete_qwiklabs_account():
d = delete_account.QL_DeleteAccount(False, ("cicekaj673@fada55.com", "hellogoodbye"))
d.delete_account()
delete_qwiklabs_account()

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,73 @@
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
class QL_DeleteAccount:
def __init__(self, proxy, account):
self.proxy = proxy
self.account = account
def delete_account(self):
self.driver = browser_manager.start_browser(self.proxy)
self.sign_in()
self.delete()
def sign_in(self):
print("[+] Signing in using account [{}:{}]".format(self.account[0], self.account[1]))
self.driver.get("https://www.qwiklabs.com/users/sign_in")
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")
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')
time.sleep(5)
#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)
# finally accept the deletition of the account
al = self.driver.switch_to.alert
al.accept()
print("Account {} deleted!".format(self.account))

View File

@ -14,10 +14,12 @@ import time
import random
import requests
def waitForElement(browser, by, selector, timeout=5):
return WebDriverWait(browser, timeout).until(EC.element_to_be_clickable((by, selector)))
def clickButton(browser, by, selector, timeout=5):
WebDriverWait(browser, timeout).until(EC.element_to_be_clickable((by, selector))).click()
time.sleep(1)
WebDriverWait(browser, timeout).until(EC.element_to_be_clickable((by, selector))).click()
time.sleep(1)
def inputText(browser, by, selector, text, timeout=5, interval=0.2):
element = WebDriverWait(browser, timeout).until(EC.element_to_be_clickable((by, selector)))
@ -32,15 +34,15 @@ def select_shadow_element_by_css_selector(browser, selector):
return element
# Another lifesaver: https://stackoverflow.com/questions/37384458/how-to-handle-elements-inside-shadow-dom-from-selenium
# def expand_shadow_element(driver, element):
# shadow_root = driver.execute_script('return arguments[0].shadowRoot', element)
# return shadow_root
def expand_shadow_element(driver, element):
shadow_root = driver.execute_script('return arguments[0].shadowRoot', element)
return shadow_root
# This variant works on firefox https://stackoverflow.com/questions/67133483/accessing-shadowroot-via-selenium-in-firefox-returns-javascriptexception-cyclic
def expand_shadow_element(driver, element):
# return a list of elements
shadowRoot = driver.execute_script('return arguments[0].shadowRoot.children', element)
return shadowRoot
# def expand_shadow_element(driver, element):
# # return a list of elements
# shadowRoot = driver.execute_script('return arguments[0].shadowRoot.children', element)
# return shadowRoot
def start_browser(headless=False, proxy=False):
# # change mac