def attack(attempts, pause, url): xpaths = { 'ldap_button': '/html/body/div[2]/div/div[2]/div/div/div[1]/div[3]/nav/ul/li[3]/a', 'username_field': '//*[@id="username"]', 'password_field': '//*[@id="password"]', 'signin_button': '//*[@id="auth-submit"]' } firefox_driver = webdriver.Firefox() firefox_driver.get(url) firefox_driver.maximize_window() firefox_driver.find_element_by_xpath(xpaths['ldap_button']).click() for attempt in range(1, attempts + 1): username = "******".format(fraise.generate(word_count=1), fraise.generate(word_count=1), fraise.generate(word_count=1)) password = fraise.generate() print("Attempt: {} - {} - {}".format(attempt, username, password)) firefox_driver.find_element_by_xpath(xpaths['username_field']).clear() firefox_driver.find_element_by_xpath( xpaths['username_field']).send_keys(username) firefox_driver.find_element_by_xpath(xpaths['password_field']).clear() firefox_driver.find_element_by_xpath( xpaths['password_field']).send_keys(password) firefox_driver.find_element_by_xpath(xpaths['signin_button']).click() time.sleep(float(pause / 1000)) firefox_driver.close()
def test_generate_with_capitalized_false(self): """When capitalized is false or ommitted, the first char of each word should be lower case""" uncapitalized_passphrase = fraise.generate(capitalized=False) print("Generated uncapitalized passphrase: {}".format( uncapitalized_passphrase)) default_passphrase = fraise.generate() print("Generated default passphrase: {}".format(default_passphrase)) for word in uncapitalized_passphrase.split(' '): assert word[0].islower() for word in default_passphrase.split(' '): assert word[0].islower()
def test_generate_with_capitalized_true(self): """When capitalized is true, the first char of each word should be upper case""" passphrase = fraise.generate(capitalized=True) print("Generated passphrase: {}".format(passphrase)) words_in_passphrase = passphrase.split(' ') for word in words_in_passphrase: assert word[0].isupper()
def test_generate_with_max_word_length(self): passphrase = fraise.generate(max_word_length=4) print("Generated passphrase: {}".format(passphrase)) words_in_passphrase = passphrase.split(' ') too_long_words = [ word for word in words_in_passphrase if len(word) > 4 ] assert not too_long_words
def test_generate_with_no_parameters(self): passphrase = fraise.generate() match = re.match(r'^([a-z]+\s){3}[a-z]+$', passphrase) print("Generated passphrase: {}".format(passphrase)) assert match
def test_generate_with_seperator(self): passphrase = fraise.generate(separator="-") match = re.match(r'^([a-z]+-){3}[a-z]+$', passphrase) print("Generated passphrase: {}".format(passphrase)) assert match
def test_generate_with_minimum_length(self): passphrase = fraise.generate(minimum_length=128) print("Generated passphrase: {}".format(passphrase)) assert len(passphrase) >= 128
def test_generate_with_word_count(self): passphrase = fraise.generate(word_count=8) match = re.match(r'^([a-z]+\s){7}[a-z]+$', passphrase) print("Generated passphrase: {}".format(passphrase)) assert match