From 9dc4c4d44832bde2012c23bf39cb150085bc5d48 Mon Sep 17 00:00:00 2001 From: Gabriele Date: Wed, 1 May 2024 18:01:26 +0200 Subject: [PATCH] first 2fa test implementation --- noip-renew.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/noip-renew.py b/noip-renew.py index 7f98edf..8035aac 100755 --- a/noip-renew.py +++ b/noip-renew.py @@ -21,6 +21,7 @@ from selenium.webdriver.support import expected_conditions as EC from datetime import date from datetime import timedelta +from pyotp import * import time import sys import os @@ -28,6 +29,8 @@ import base64 import subprocess +OTP_SECRET = "" + class Logger: def __init__(self, level): self.level = 0 if level is None else level @@ -89,6 +92,21 @@ def login(self): ele_pwd.send_keys(base64.b64decode(self.password).decode('utf-8')) ele_pwd.send_keys(Keys.ENTER) + try: + elem = WebDriverWait(self.browser, 10).until( EC.presence_of_element_located((By.ID, "verificationCode"))) + except: + raise Exception("2FA verify page could not load") + + if self.debug > 1: + self.browser.save_screenshot("debug-otp.png") + + self.logger.log("Sending OTP...") + + ele_challenge = elem.find_element(By.NAME, "challenge_code") + + ele_challenge.send_keys(TOTP(OTP_SECRET).now()) + ele_challenge.send_keys(Keys.ENTER) + # After Loggin browser loads my.noip.com page - give him some time to load # 'noip-cart' element is near the end of html, so html have been loaded try: