-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappManager.py
More file actions
executable file
·120 lines (95 loc) · 3.97 KB
/
Copy pathappManager.py
File metadata and controls
executable file
·120 lines (95 loc) · 3.97 KB
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
import os
import requests
from modules.module_cmsWordPress import cmsWordPress
from modules.module_cmsDrupal import cmsDrupal
from modules.module_cmsJoomla import cmsJoomla
from modules.module_savingData import savingData
#########################################################################
class mainManager:
# ***************************************************************
def __init__(self, params):
self.params = params
self.status = self.main(self.params)
# ***************************************************************
def main(self, userSelect):
pathToFile = userSelect["pathToFile"]
pathToSave = userSelect["pathToSave"]
extension = userSelect["extension"]
genLogs = userSelect["genLogs"]
fullPath = ""
if genLogs:
fileName = "Logs.txt"
fullPath = os.path.join(pathToSave, fileName)
file_listLogs = open(fullPath, "w")
file_listLogs.close()
finalData = {}
file_listSites = open(pathToFile, "r")
for url in file_listSites:
url = url.strip()
if url[-1] == "/":
url = url[:-1]
print(url)
secretInfo = self.gettingInfo(url)
if fullPath != "":
message = "* " + url + " :\n"
if "Error connection" not in secretInfo:
message += ">>> Identification of Server : "
message += "success\n" if "not available"\
not in secretInfo["Server"] else "error\n"
message += ">>> Identification of CMS : "
message += "success\n" if "not defined"\
not in secretInfo["CMS"] else "error\n"
else:
message += "error connection\n"
file_listLogs = open(fullPath, "a")
file_listLogs.write(message + "#"*50 + "\n")
file_listLogs.close()
print(secretInfo)
print("#" * 50)
finalData.update({url: secretInfo})
file_listSites.close()
############################################################
magic = savingData(finalData, pathToSave, extension).status
############################################################
return magic
# ***************************************************************
def gettingInfo(self, urlAddress):
if "http" not in urlAddress:
urlAddress = "http://" + urlAddress
result = {}
try:
data = requests.get(urlAddress)
except:
return "Error connection to '{}'".format(urlAddress)
primaryInfo = data.headers
if "server" in primaryInfo.keys() and primaryInfo["server"]!="":
serverInfo = primaryInfo["server"]
else:
serverInfo = "Server info is not available"
result.update({ "Server": serverInfo })
cmsInfo = ""
if cmsWordPress(urlAddress).status == True:
cmsInfo += "WordPress"
elif cmsDrupal(urlAddress).status == True:
cmsInfo += "Drupal"
elif cmsJoomla(urlAddress).status == True:
cmsInfo += "Joomla"
else:
cmsInfo += "CMS is not defined"
result.update({ "CMS": cmsInfo })
return result
#########################################################################
if __name__ == "__main__":
testParams = {
'pathToFile': 'D:\\test_siteList.txt',
'pathToSave': 'D:\\test_saveDir',
'extension': 'txt',
'genLogs': True
}
status = mainManager(testParams).status
print("#"*50)
if status == True:
print("Information about sites is stored")
else:
print("Error when saving data")
#========================================================================