-
Notifications
You must be signed in to change notification settings - Fork 8
/
find_admin.py
89 lines (76 loc) · 2.2 KB
/
find_admin.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
# The purpose of this script is to find admin modules
# Usage
# -----
# find_admin.py [target]
#
# find_admin.py
# find_admin.py http://example.com
#
# Parameters
# ----------
# [target] parameter is a valid url of the target.
#
# Tips
# ----
# run the script after midnight and come back in one hour.
import sys
import requests
from urllib.parse import urlparse
from collections import OrderedDict
from includes.functions import url_exists, sanitize_list
# all the urls combined by this script will be added to this list
urls = []
targets = [
{
'url' : 'http://example.com/',
},
]
if len(sys.argv) == 2:
target = sys.argv[1]
targets = [
{
'url' : target,
},
]
with open('wordlists/wordlist_admin.txt') as admin_file:
admin = admin_file.read().splitlines()
print('\nPlease wait while we build the url list...\n')
for target in targets:
uri = urlparse(target['url'])
base_url = uri.scheme + '://' + uri.netloc
result = url_exists(base_url)
if result[0] == False:
print('The target url \'' + base_url + '\' does not exist')
else:
for folder in admin:
folder_url = base_url + '/' + folder + '/'
url = folder_url
urls.append(url)
# print all urls
#for url in urls:
#print(url)
# log file to register the http code of each url
log_file = open('logs/find_admin.log', 'w+')
exclusion_list = []
for url in urls:
uri = urlparse(url)
if uri.netloc in exclusion_list:
continue
result = url_exists(url)
status_code = result[1]
content_type = result[2]
if result[0] == True:
print('Retrieving url:', url, '(' + str(status_code) + ')')
log_file.write(url + ' (' + str(status_code) + ')\n')
else:
print('Retrieving url:', url, '(' + str(status_code) + ')')
log_file.write(url + ' (' + str(status_code) + ')\n')
if status_code == -1:
exclusion_list.append(uri.netloc)
if status_code != 404 and status_code != -1:
# found file
print('\nFOUND:', url, '\n')
found_file = open('logs/found.log', 'a+')
found_file.write(url + ' (' + str(status_code) + ')\n')
found_file.close()
print('\nFinished\n')