Skip to content

Commit

Permalink
first 2fa test implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
neothematrix committed May 1, 2024
1 parent 3d8440d commit 9dc4c4d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions noip-renew.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
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
import re
import base64
import subprocess

OTP_SECRET = ""

class Logger:
def __init__(self, level):
self.level = 0 if level is None else level
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 9dc4c4d

Please sign in to comment.