-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmscheck.py
158 lines (136 loc) · 5.62 KB
/
cmscheck.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
#!/usr/bin/python
import os, os.path, sys, argparse, re
parser = argparse.ArgumentParser()
parser.add_argument("-a", "--account", dest="account", help="All CMS on specified cPanel account")
parser.add_argument("-w", "--wordpress", "--wp", dest="wordpress", help="Targets Wordpress installations", action='store_true')
parser.add_argument("-j", "--joomla", dest="joomla", help="Targets Joomla installations", action='store_true')
parser.add_argument("-d", "--drupal", dest="drupal", help="Targets Drupal installations", action='store_true')
parser.add_argument("-e", "--exhaustive", dest="exhaustive", help="All supported CMS on All Accounts", action='store_true')
args = parser.parse_args()
acctPath = "/home/{0}/public_html".format(args.account)
#Joomla - CMS Script style output
def jooVphp():
fileList = []
for root, folders, files in os.walk(acctPath):
for file in files:
if file == 'version.php':
fileList.append(os.path.join(root,file))
for path in fileList:
with open(path) as f:
for line in f:
if "public $RELEASE = '" in line:
version_number = line[20:25]
inst_path = re.sub('libraries/cms/version/version.php', '', path)
version_number = re.sub('\';', '', version_number)
# print "Joomla installation(s) and version(s):"
print inst_path + " = " + version_number + " Joomla"
#Wordpress - CMS Script style output
def wpVphp():
fileList = []
for root, folders, files in os.walk(acctPath):
for file in files:
if file == 'version.php':
fileList.append(os.path.join(root,file))
for path in fileList:
with open(path) as f:
for line in f:
if line.startswith("$wp_version ="):
version_number = line[15:20]
inst_path = re.sub('wp-includes/version.php', '', path)
version_number = re.sub('\';', '', version_number)
# print "Wordpress installation(s) and version(s):"
print inst_path + " = " + version_number + " Wordpress"
#Drupal - CMS Script style output
def druVphp():
fileList = []
for root, folders, files in os.walk(acctPath):
for file in files:
if file == 'bootstrap.inc':
fileList.append(os.path.join(root,file))
for path in fileList:
with open(path) as f:
for line in f:
if "define('VERSION', '" in line:
version_number = line[19:26]
inst_path = re.sub('includes/bootstrap.inc', '', path)
version_number = re.sub('\'\);', '', version_number)
# print "Drupal installation(s) and version(s):"
print inst_path + " = " + version_number + " Drupal"
#Exhaustive - CMS Script style output
fullList = []
#Exhaustive - CMS Script style output
def exhaustive():
cpdir = "/var/cpanel/users"
druList = []
wpList = []
jooList = []
for root, folders, files in os.walk(cpdir):
for file in files:
newpath = "/home/" + os.path.join(file) + "/public_html/"
if "public_html" in newpath:
###Wordpress
for root, folders, files in os.walk(newpath):
for file in files:
if file == 'version.php':
wpList.append(os.path.join(root,file))
for path in wpList:
with open(path) as f:
for line in f:
if line.startswith("$wp_version ="):
version_number = line[15:20]
inst_path = re.sub('wp-includes/version.php', '', path)
version_number = re.sub('\';', '', version_number)
# print inst_path + " = " + version_number + " Wordpress"
# return inst_path + " = " + version_number + " Wordpress"
fullList.append(inst_path + " = " + version_number + " Wordpress")
###Joomla
for root, folders, files in os.walk(newpath):
for file in files:
if file == 'version.php':
jooList.append(os.path.join(root,file))
for path in jooList:
with open(path) as f:
for line in f:
if "public $RELEASE = '" in line:
version_number = line[20:25]
inst_path = re.sub('libraries/cms/version/version.php', '', path)
version_number = re.sub('\';', '', version_number)
# print inst_path + " = " + version_number + " Joomla"
# return inst_path + " = " + version_number + " Joomla"
fullList.append(inst_path + " = " + version_number + " Joomla")
###Drupal
for root, folders, files in os.walk(newpath):
for file in files:
if file == 'bootstrap.inc':
druList.append(os.path.join(root,file))
for path in druList:
with open(path) as f:
for line in f:
if "define('VERSION', '" in line:
version_number = line[19:26]
inst_path = re.sub('includes/bootstrap.inc', '', path)
version_number = re.sub('\'\);', '', version_number)
# print inst_path + " = " + version_number + " Drupal"
# return inst_path + " = " + version_number + " Drupal"
fullList.append(inst_path + " = " + version_number + " Drupal")
###Uniqify
output = []
for each in fullList:
if each not in output:
output.append(each)
print ("\n".join(output))
#Actions
if args.wordpress:
print "Wordpress installation(s) and version(s):"
wpVphp()
elif args.joomla:
print "Joomla installation(s) and version(s):"
jooVphp()
elif args.drupal:
print "Drupal installation(s) and version(s):"
druVphp()
elif args.exhaustive:
print "Exhaustive installation(s) and versions(s):"
exhaustive()
else:
print "Too bad, so sad."