Skip to content

Commit

Permalink
Fixed a bug in the adminbot by adding delays when clicks cause the vi…
Browse files Browse the repository at this point in the history
…ew to change in PwnedHub 2.0.
  • Loading branch information
lanmaster53 committed May 11, 2024
1 parent 8638f77 commit cdc9643
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions adminbot/bot.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from selenium import webdriver
from selenium.webdriver.firefox.options import Options as FirefoxOptions
from selenium.webdriver.firefox.service import Service as FirefoxService
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
import glob
import os.path
Expand Down Expand Up @@ -35,6 +36,8 @@ def __init__(self, driver, name):
def debug(self, s):
print(f"[{self.__class__.__name__}] [{self.name}] [{self.driver.current_url}] {s}")

def wait_until_url(self, url):
WebDriverWait(self.driver, 10).until(EC.url_to_be(url))

class HubBot(BaseBot):

Expand Down Expand Up @@ -103,14 +106,14 @@ def log_in(self, email):
self.debug('Logging in.')
login_button = self.driver.find_element('xpath', '//input[@type="button" and @value="Log me in please."]')
login_button.click()
self.wait_until_url('http://test.pwnedhub.com/#/login/passwordless')

self.debug('Fetching the Passwordless Authentication code.')
inbox_url = 'http://admin.pwnedhub.com/inbox/[email protected]'
import urllib.request
contents = urllib.request.urlopen(inbox_url).read().decode()
match = re.search(r'<br><br>(\d{6})<br><br>', contents)
code = match.group(1)
print(f"\n\n{code}\n\n")

self.debug('Setting the inputs.')
code_input = self.driver.find_element('name', 'code')
Expand All @@ -119,6 +122,7 @@ def log_in(self, email):
self.debug('Submitting the Passwordless Authentication code.')
code_button = self.driver.find_element('xpath', '//input[@type="button" and @value="Yes, it\'s really me."]')
code_button.click()
self.wait_until_url('http://test.pwnedhub.com/#/admin/users')

def send_private_message(self, room_id, message):
self.debug('Visiting the Messaging view.')
Expand Down

0 comments on commit cdc9643

Please sign in to comment.