Advertisement
InnovAnon-Inc

paypal-account-o_creat-wip

Aug 6th, 2024
923
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 11.05 KB | Source Code | 0 0
  1. #! /usr/bin/env python
  2.  
  3.     @app.get("/paypal2")
  4.     async def _paypal2(email            :str,
  5.                     password         :Optional[str]  =None,
  6.                     limit            :Optional[int]  =None,
  7.                     mean_arrival_rate:Optional[float]=None,
  8.     )->Response:#Union[Response,FileResponse]:
  9.         """
  10.        Sign me up! (PayPal)
  11.        Use Case: shekeler heckler
  12.        """
  13.         await logger.adebug('_paypal2 %s %s %s %s', email, password, limit, mean_arrival_rate)
  14.         _url:str = 'https://www.paypal.com/us/webapps/mpp/account-selection'
  15.         return await _login_helper(_paypal2_helper, _url, email, password, limit, mean_arrival_rate)
  16.  
  17.     def _paypal_security_challenge(driver:WebDriver)->None: # FIXME captchas are hard
  18.         nonlocal timeout
  19.         try:
  20.             logger.debug('looking for the get captcha')
  21.             #by     = By.XPATH
  22.             #cond   = "//div[@aria-labelledby='ally-label']"
  23.             by     = By.ID
  24.             cond   = "checkbox"
  25.             _captcha = WebDriverWait(driver, timeout).until( EC.presence_of_element_located  ((by, cond)))
  26.             logger.debug('scrolling the captcha')
  27.             #driver.execute_script('arguments[0].scrollIntoView();', _captcha)
  28.             try:
  29.                 logger.debug('waiting for captcha to become visible')
  30.                 _captcha = WebDriverWait(driver, timeout).until( EC.visibility_of_element_located((by, cond)))
  31.             except TimeoutException as e:
  32.                 logger.exception(e)
  33.             try:
  34.                 logger.debug('waiting for captcha to become clickable')
  35.                 _captcha = WebDriverWait(driver, timeout).until( EC.element_to_be_clickable      ((by, cond)))
  36.             except TimeoutException as e:
  37.                 logger.exception(e)
  38.             logger.debug('found the captcha')
  39.             driver.execute_script("arguments[0].click();", _captcha)
  40.             ActionChains(driver).move_to_element(_captcha) .click(_captcha) .perform()
  41.             logger.debug('pressed enter')
  42.         except TimeoutException as e:
  43.             logger.exception(e)
  44.  
  45.     def _paypal2_helper(driver:WebDriver, email:str, passwd:str, mean_arrival_rate:Optional[float])->Optional[str]:
  46.         """ demonstrate the paypal signup sequence """
  47.         logger.debug('_paypal2_helper %s %s', email, passwd)
  48.         assert isinstance(passwd,str)
  49.         nonlocal timeout
  50.  
  51.         #logger.debug('looking for the get account')
  52.         #by     = By.XPATH
  53.         #cond   = "//input[@value='Personal']"
  54.         #_account = WebDriverWait(driver, timeout).until( EC.presence_of_element_located  ((by, cond)))
  55.         #logger.debug('scrolling the account')
  56.         ##driver.execute_script('arguments[0].scrollIntoView();', _account)
  57.         #try:
  58.         #    logger.debug('waiting for account to become visible')
  59.         #    _account = WebDriverWait(driver, timeout).until( EC.visibility_of_element_located((by, cond)))
  60.         #except TimeoutException as e:
  61.         #    logger.exception(e)
  62.         #try:
  63.         #    logger.debug('waiting for account to become clickable')
  64.         #    _account = WebDriverWait(driver, timeout).until( EC.element_to_be_clickable      ((by, cond)))
  65.         #except TimeoutException as e:
  66.         #    logger.exception(e)
  67.         #logger.debug('found the account')
  68.         #driver.execute_script("arguments[0].click();", _account)
  69.         #
  70.         #ActionChains(driver).move_to_element(_account) .click(_account)                   .perform()
  71.         #logger.debug('pressed enter')
  72.  
  73.         #
  74.  
  75.         logger.debug('looking for the start')
  76.         by     = By.XPATH
  77.         cond   = "//a[text()='Get Started']"
  78.         _start = WebDriverWait(driver, timeout).until( EC.presence_of_element_located  ((by, cond)))
  79.         logger.debug('scrolling the start')
  80.         #driver.execute_script('arguments[0].scrollIntoView();', _start)
  81.         try:
  82.             logger.debug('waiting for start to become visible')
  83.             _start = WebDriverWait(driver, timeout).until( EC.visibility_of_element_located((by, cond)))
  84.         except TimeoutException as e:
  85.             logger.exception(e)
  86.         try:
  87.             logger.debug('waiting for start to become clickable')
  88.             _start = WebDriverWait(driver, timeout).until( EC.element_to_be_clickable      ((by, cond)))
  89.         except TimeoutException as e:
  90.             logger.exception(e)
  91.         logger.debug('found the start')
  92.         driver.execute_script("arguments[0].click();", _start)
  93.        
  94.         ActionChains(driver).move_to_element(_start) .click(_start)                   .perform()
  95.         logger.debug('pressed enter')
  96.  
  97.         #
  98.         _paypal_security_challenge(driver)
  99.         #
  100.  
  101.         logger.debug('looking for the get email')
  102.         by     = By.XPATH
  103.         cond   = "//input[@aria-labelledby='paypalAccountData_email-label']"
  104.         _email = WebDriverWait(driver, timeout).until( EC.presence_of_element_located  ((by, cond)))
  105.         logger.debug('scrolling the email')
  106.         #driver.execute_script('arguments[0].scrollIntoView();', _email)
  107.         try:
  108.             logger.debug('waiting for email to become visible')
  109.             _email = WebDriverWait(driver, timeout).until( EC.visibility_of_element_located((by, cond)))
  110.         except TimeoutException as e:
  111.             logger.exception(e)
  112.         try:
  113.             logger.debug('waiting for email to become clickable')
  114.             _email = WebDriverWait(driver, timeout).until( EC.element_to_be_clickable      ((by, cond)))
  115.         except TimeoutException as e:
  116.             logger.exception(e)
  117.         logger.debug('found the email')
  118.         driver.execute_script("arguments[0].click();", _email)
  119.         ActionChains(driver).move_to_element(_email) .click(_email).send_keys(email).send_keys(Keys.ENTER) .perform()
  120.         logger.debug('pressed enter')
  121.  
  122.         #
  123.         _paypal_security_challenge(driver)
  124.         #
  125.  
  126.         #logger.debug('looking for the get next')
  127.         #by     = By.XPATH
  128.         #cond   = "//button[text()='Next']"
  129.         #_next = WebDriverWait(driver, timeout).until( EC.presence_of_element_located  ((by, cond)))
  130.         #logger.debug('scrolling the next')
  131.         ##driver.execute_script('arguments[0].scrollIntoView();', _next)
  132.         #try:
  133.         #    logger.debug('waiting for next to become visible')
  134.         #    _next = WebDriverWait(driver, timeout).until( EC.visibility_of_element_located((by, cond)))
  135.         #except TimeoutException as e:
  136.         #    logger.exception(e)
  137.         #try:
  138.         #    logger.debug('waiting for next to become clickable')
  139.         #    _next = WebDriverWait(driver, timeout).until( EC.element_to_be_clickable      ((by, cond)))
  140.         #except TimeoutException as e:
  141.         #    logger.exception(e)
  142.         #logger.debug('found the next')
  143.         #driver.execute_script("arguments[0].click();", _next)
  144.         #ActionChains(driver).move_to_element(_next) .click(_next)                                       .perform()
  145.         #logger.debug('pressed enter')
  146.  
  147.         #
  148.        
  149.         logger.debug('looking for the get phone')
  150.         by     = By.XPATH
  151.         cond   = "//input[@aria-describedby='message_paypalAccountData_phone']"
  152.         _phone = WebDriverWait(driver, timeout).until( EC.presence_of_element_located  ((by, cond)))
  153.         logger.debug('scrolling the phone')
  154.         #driver.execute_script('arguments[0].scrollIntoView();', _phone)
  155.         try:
  156.             logger.debug('waiting for phone to become visible')
  157.             _phone = WebDriverWait(driver, timeout).until( EC.visibility_of_element_located((by, cond)))
  158.         except TimeoutException as e:
  159.             logger.exception(e)
  160.         try:
  161.             logger.debug('waiting for phone to become clickable')
  162.             _phone = WebDriverWait(driver, timeout).until( EC.element_to_be_clickable      ((by, cond)))
  163.         except TimeoutException as e:
  164.             logger.exception(e)
  165.         logger.debug('found the phone')
  166.         driver.execute_script("arguments[0].click();", _phone)
  167.         phone = ''.join([randrange(0,9) for _ in range(10)])
  168.         ActionChains(driver).move_to_element(_phone) .click(_phone).send_keys(phone).send_keys(Keys.ENTER) .perform()
  169.         logger.debug('pressed enter')
  170.  
  171.         #
  172.  
  173.         #logger.debug('looking for the get next')
  174.         #by     = By.XPATH
  175.         #cond   = "//button[text()='Next']"
  176.         #_next = WebDriverWait(driver, timeout).until( EC.presence_of_element_located  ((by, cond)))
  177.         #logger.debug('scrolling the next')
  178.         ##driver.execute_script('arguments[0].scrollIntoView();', _next)
  179.         #try:
  180.         #    logger.debug('waiting for next to become visible')
  181.         #    _next = WebDriverWait(driver, timeout).until( EC.visibility_of_element_located((by, cond)))
  182.         #except TimeoutException as e:
  183.         #    logger.exception(e)
  184.         #try:
  185.         #    logger.debug('waiting for next to become clickable')
  186.         #    _next = WebDriverWait(driver, timeout).until( EC.element_to_be_clickable      ((by, cond)))
  187.         #except TimeoutException as e:
  188.         #    logger.exception(e)
  189.         #logger.debug('found the next')
  190.         #driver.execute_script("arguments[0].click();", _next)
  191.         #ActionChains(driver).move_to_element(_next) .click(_next)                                       .perform()
  192.         #logger.debug('pressed enter')
  193.  
  194.         # FIXME phones are hard
  195.  
  196.         for k in range(1, 6+1):
  197.             assert (1 <= k and k <= 6)
  198.             logger.debug('looking for the get security')
  199.             by     = By.XPATH
  200.             cond   = str(f"//input[@aria-label='Security code digit {k}']")
  201.             _security = WebDriverWait(driver, timeout).until( EC.presence_of_element_located  ((by, cond)))
  202.             logger.debug('scrolling the security')
  203.             #driver.execute_script('arguments[0].scrollIntoView();', _security)
  204.             try:
  205.                 logger.debug('waiting for security to become visible')
  206.                 _security = WebDriverWait(driver, timeout).until( EC.visibility_of_element_located((by, cond)))
  207.             except TimeoutException as e:
  208.                 logger.exception(e)
  209.             try:
  210.                 logger.debug('waiting for security to become clickable')
  211.                 _security = WebDriverWait(driver, timeout).until( EC.element_to_be_clickable      ((by, cond)))
  212.             except TimeoutException as e:
  213.                 logger.exception(e)
  214.             logger.debug('found the security')
  215.             driver.execute_script("arguments[0].click();", _security)
  216.             security = randrange(1, 9)
  217.             ActionChains(driver).move_to_element(_security) .click(_security).send_keys(security).send_keys(Keys.ENTER) .perform()
  218.             logger.debug('pressed enter')
  219.  
  220.         #
  221.  
  222.         # TODO
  223.  
  224.         try:
  225.             logger.debug('looking for logout')
  226.             raise NotImplementedError()
  227.             logger.debug('found the logout')
  228.             return passwd
  229.         except NoSuchElementException as e:
  230.             logger.error('could not find logout: %s', e)
  231.         return None
  232.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement