-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathjoomlascan.py
308 lines (220 loc) · 12.4 KB
/
joomlascan.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
296
297
298
299
300
301
302
303
304
305
306
307
308
#!/usr/bin/python
import sys
import httplib
import requests
import argparse
from bs4 import BeautifulSoup
import threading
import time
dbarray = []
url = ""
useragentdesktop = {"User-Agent": "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)",
"Accept-Language": "it"}
timeoutconnection = 5
pool = None
swversion = "0.5beta"
def hello():
print "-------------------------------------------"
print " Joomla Scan "
print " Usage: python joomlascan.py <target> "
print " Version " + swversion + " - Database Entries " + str(len(dbarray))
print " created by Andrea Draghetti "
print "-------------------------------------------"
def load_component():
with open("comptotestdb.txt", "r") as f:
for line in f:
dbarray.append(line[:-1]) if line[-1] == "\n" else dbarray.append(line)
def check_url(url, path="/"):
fullurl = url + path
try:
conn = requests.get(fullurl, headers=useragentdesktop, timeout=timeoutconnection)
if conn.headers["content-length"] != "0":
return conn.status_code
else:
return 404
except StandardError:
return None
def check_url_head_content_length(url, path="/"):
fullurl = url + path
try:
conn = requests.head(fullurl, headers=useragentdesktop, timeout=timeoutconnection)
return conn.headers["content-length"]
except StandardError:
return None
def check_readme(url, component):
if check_url(url, "/components/" + component + "/README.txt") == 200:
print "\t README file found \t > " + url + "/components/" + component + "/README.txt"
if check_url(url, "/components/" + component + "/readme.txt") == 200:
print "\t README file found \t > " + url + "/components/" + component + "/readme.txt"
if check_url(url, "/components/" + component + "/README.md") == 200:
print "\t README file found \t > " + url + "/components/" + component + "/README.md"
if check_url(url, "/components/" + component + "/readme.md") == 200:
print "\t README file found \t > " + url + "/components/" + component + "/readme.md"
if check_url(url, "/administrator/components/" + component + "/README.txt") == 200:
print "\t README file found \t > " + url + "/administrator/components/" + component + "/README.txt"
if check_url(url, "/administrator/components/" + component + "/readme.txt") == 200:
print "\t README file found \t > " + url + "/administrator/components/" + component + "/readme.txt"
if check_url(url, "/administrator/components/" + component + "/README.md") == 200:
print "\t README file found \t > " + url + "/administrator/components/" + component + "/README.md"
if check_url(url, "/administrator/components/" + component + "/readme.md") == 200:
print "\t README file found \t > " + url + "/administrator/components/" + component + "/readme.md"
def check_license(url, component):
if check_url(url, "/components/" + component + "/LICENSE.txt") == 200:
print "\t LICENSE file found \t > " + url + "/components/" + component + "/LICENSE.txt"
if check_url(url, "/components/" + component + "/license.txt") == 200:
print "\t LICENSE file found \t > " + url + "/components/" + component + "/license.txt"
if check_url(url, "/administrator/components/" + component + "/LICENSE.txt") == 200:
print "\t LICENSE file found \t > " + url + "/administrator/components/" + component + "/LICENSE.txt"
if check_url(url, "/administrator/components/" + component + "/license.txt") == 200:
print "\t LICENSE file found \t > " + url + "/administrator/components/" + component + "/license.txt"
if check_url(url, "/components/" + component + "/" + component[4:] + ".xml") == 200:
print "\t LICENSE file found \t > " + url + "/components/" + component + "/" + component[4:] + ".xml"
if check_url(url, "/administrator/components/" + component + "/" + component[4:] + ".xml") == 200:
print "\t LICENSE file found \t > " + url + "/administrator/components/" + component + "/" + component[
4:] + ".xml"
def check_changelog(url, component):
if check_url(url, "/components/" + component + "/CHANGELOG.txt") == 200:
print "\t CHANGELOG file found \t > " + url + "/components/" + component + "/CHANGELOG.txt"
if check_url(url, "/components/" + component + "/changelog.txt") == 200:
print "\t CHANGELOG file found \t > " + url + "/components/" + component + "/changelog.txt"
if check_url(url, "/administrator/components/" + component + "/CHANGELOG.txt") == 200:
print "\t CHANGELOG file found \t > " + url + "/administrator/components/" + component + "/CHANGELOG.txt"
if check_url(url, "/administrator/components/" + component + "/changelog.txt") == 200:
print "\t CHANGELOG file found \t > " + url + "/administrator/components/" + component + "/changelog.txt"
def check_mainfest(url, component):
if check_url(url, "/components/" + component + "/MANIFEST.xml") == 200:
print "\t MANIFEST file found \t > " + url + "/components/" + component + "/MANIFEST.xml"
if check_url(url, "/components/" + component + "/manifest.xml") == 200:
print "\t MANIFEST file found \t > " + url + "/components/" + component + "/manifest.xml"
if check_url(url, "/administrator/components/" + component + "/MANIFEST.xml") == 200:
print "\t MANIFEST file found \t > " + url + "/administrator/components/" + component + "/MANIFEST.xml"
if check_url(url, "/administrator/components/" + component + "/manifest.xml") == 200:
print "\t MANIFEST file found \t > " + url + "/administrator/components/" + component + "/manifest.xml"
def check_index(url, component):
if check_url_head_content_length(url, "/components/" + component + "/index.htm") == 200 and check_url_head(url,
"/components/" + component + "/index.htm") > 1000:
print "\t INDEX file descriptive found \t > " + url + "/components/" + component + "/index.htm"
if check_url_head_content_length(url, "/components/" + component + "/index.html") == 200 and check_url_head(url,
"/components/" + component + "/index.html") > 1000:
print "\t INDEX file descriptive found \t > " + url + "/components/" + component + "/index.html"
if check_url_head_content_length(url,
"/administrator/components/" + component + "/INDEX.htm") == 200 and check_url_head(
url, "/administrator/components/" + component + "/INDEX.htm") > 1000:
print "\t INDEX file descriptive found \t > " + url + "/administrator/components/" + component + "/INDEX.htm"
if check_url_head_content_length(url,
"/administrator/components/" + component + "/INDEX.html") == 200 and check_url_head(
url, "/administrator/components/" + component + "/INDEX.html") > 1000:
print "\t INDEX file descriptive found \t > " + url + "/administrator/components/" + component + "/INDEX.html"
def index_of(url, path="/"):
fullurl = url + path
try:
page = requests.get(fullurl, headers=useragentdesktop, timeout=timeoutconnection)
soup = BeautifulSoup(page.text, "html.parser")
if soup.title:
titlepage = soup.title.string
if (titlepage and "Index of /" in titlepage):
return True
else:
return False
else:
return False
except:
return False
def scanner(url, component):
if check_url(url, "/index.php?option=" + component) == 200:
print "Component found: " + component + "\t > " + url + "/index.php?option=" + component
check_readme(url, component)
check_license(url, component)
check_changelog(url, component)
check_mainfest(url, component)
check_index(url, component)
if index_of(url, "/components/" + component + "/"):
print "\t Explorable Directory \t > " + url + "/components/" + component + "/"
if index_of(url, "/administrator/components/" + component + "/"):
print "\t Explorable Directory \t > " + url + "/administrator/components/" + component + "/"
elif check_url(url, "/components/" + component + "/") == 200:
print "Component found: " + component + "\t > " + url + "/index.php?option=" + component
print "\t But possibly it is not active or protected"
check_readme(url, component)
check_license(url, component)
check_changelog(url, component)
check_mainfest(url, component)
check_index(url, component)
if index_of(url, "/components/" + component + "/"):
print "\t Explorable Directory \t > " + url + "/components/" + component + "/"
if index_of(url, "/administrator/components/" + component + "/"):
print "\t Explorable Directory \t > " + url + "/administrator/components/" + component + "/"
elif check_url(url, "/administrator/components/" + component + "/") == 200:
print "Component found: " + component + "\t > " + url + "/index.php?option=" + component
print "\t On the administrator components"
check_readme(url, component)
check_license(url, component)
check_changelog(url, component)
check_mainfest(url, component)
check_index(url, component)
if index_of(url, "/administrator/components/" + component + "/"):
print "\t Explorable Directory \t > " + url + "/components/" + component + "/"
if index_of(url, "/administrator/components/" + component + "/"):
print "\t Explorable Directory \t > " + url + "/administrator/components/" + component + "/"
pool.release()
def main(argv):
# Carico il database di tutti i compomenti di Joomla
load_component()
# Visualizzo il banner di benvenuto
hello()
# Analizzo gli argomenti passati sul terminale
try:
parser = argparse.ArgumentParser()
parser.add_argument("-u", "--url", action="store", dest="url", help="The Joomla URL/domain to scan.")
parser.add_argument("-t", "--threads", action="store", dest="threads",
help="The number of threads to use when multi-threading requests (default: 10).")
parser.add_argument("-v", "--version", action="version", version="%(prog)s " + swversion)
arguments = parser.parse_args()
except:
sys.exit(1)
if arguments.url:
url = arguments.url
if url[:8] != "https://" and url[:7] != "http://":
print("You must insert http:// or https:// procotol\n")
sys.exit(1)
# Rimuovo un eventuale barra alla fine del url
if url[-1:] is "/":
url = url[:-1]
else:
print("")
parser.parse_args(["-h"])
sys.exit(1)
concurrentthreads = 10
global pool
# Imposto il numero di thread concorrenti
if arguments.threads and arguments.threads is int:
# Limit the number of threads.
concurrentthreads = arguments.threads
pool = threading.BoundedSemaphore(concurrentthreads)
else:
# Default value for limit the number of threads.
pool = threading.BoundedSemaphore(concurrentthreads)
# Analizzo la disponibilita del sito indicato
if check_url(url) != 404:
if check_url(url, "/robots.txt") == 200:
print "Robots file found: \t \t > " + url + "/robots.txt"
else:
print "No Robots file found"
if check_url(url, "/error_log") == 200:
print "Error log found: \t \t > " + url + "/error_log"
else:
print "No Error Log found"
# Inizio la scansione dei componenti
print "\nStart scan...with %d concurrent threads!" % concurrentthreads
for component in dbarray:
# Thread Pool
pool.acquire(blocking=True)
t = threading.Thread(target=scanner, args=(url, component,))
t.start()
while (threading.active_count() > 1):
time.sleep(0.1)
print "End Scanner"
else:
print "Site Down, check url please..."
if __name__ == "__main__":
main(sys.argv[1:])