-
Notifications
You must be signed in to change notification settings - Fork 0
/
skim_cms_filter.py
executable file
·116 lines (108 loc) · 3.87 KB
/
skim_cms_filter.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
#!/usr/bin/env python3
import skim_writer_io
from time import perf_counter as pc
class SkimCmsFilter:
'''
Filters HTTP headers and content to identify what CMS is used if any.
Is called from Requester, which can display them for profiling.
'''
def __init__(self):
'''
Constructor initialises vars to store results from performance timers
Requester Class calls and can display them for profiling.
'''
self.perf_is_it_drupal: str = "n/a"
self.perf_is_it_wordpress: str = "n/a"
self.perf_is_it_sharepoint: str = "n/a"
self.perf_is_it_joomla: str = "n/a"
def is_it_drupal(self, url, headers: str, content: str) -> bool:
'''
Parse http response data for Drupal CMS
'''
try:
p1 = pc()
writer = skim_writer_io.Skim_writer_io().writer
check = str(headers) + str(content)
if ("drupal" in check) or ("Drupal" in check):
writer(url, "drupal")
p2 = pc()
timer = str(p2 - p1)
timer = timer[:8]
self.perf_is_it_drupal = str(timer)
return True
else:
p2 = pc()
timer = str(p2 - p1)
timer = timer[:8]
self.perf_is_it_drupal = str(timer)
return False
except Exception as e:
print("Error! in drupal: " + str(e))
def is_it_wordpress(self, url: str, headers: str) -> bool:
'''
Parse http response data for Wordpress CMS
'''
try:
p1 = pc()
writer = skim_writer_io.Skim_writer_io().writer
headers = str(headers)
if ("wp" in headers) or ("xmlrpc.php" in headers):
writer(url, "wordpress")
p2 = pc()
timer = str(p2 - p1)
timer = timer[:8]
self.perf_is_it_wordpress = str(timer)
return True
else:
p2 = pc()
timer = str(p2 - p1)
timer = timer[:8]
self.perf_is_it_wordpress = str(timer)
return False
except Exception as e:
print("Error! in is_it_wordpress " + str(e))
def is_it_sharepoint(self, url: str, headers: str) -> bool:
'''
Parse http response data for Sharepoint
'''
try:
p1 = pc()
writer = skim_writer_io.Skim_writer_io().writer
if any("SharePoint" in x for x in headers):
writer(url, "sharepoint")
p2 = pc()
timer = str(p2 - p1)
timer = timer[:8]
self.perf_is_it_sharepoint = str(timer)
return True
else:
p2 = pc()
timer = str(p2 - p1)
timer = timer[:8]
self.perf_is_it_sharepoint = str(timer)
return False
except Exception as e:
print("Error! in is_it_sharepoint: " + str(e))
def is_it_joomla(self, url: str, headers: str, content: str) -> bool:
'''
Parse http response data for Joomla CMS
'''
try:
p1 = pc()
writer = skim_writer_io.Skim_writer_io().writer
search_space = str("".join(headers)) + str(content)
if "joomla" in search_space:
writer(url, "joomla")
p2 = pc()
timer = str(p2 - p1)
timer = timer[:8]
self.perf_is_it_joomla = str(timer)
return True
else:
p2 = pc()
timer = str(p2 - p1)
timer = timer[:8]
self.perf_is_it_joomla = str(timer)
return False
except Exception as e:
print("Error! in is_it_joomla: " + str(e))