Analyzing apache

This commit is contained in:
gbucchino
2023-09-15 11:43:43 +02:00
parent 20d15fa8ec
commit 725fe43786
2 changed files with 40 additions and 5 deletions
+23 -5
View File
@@ -3,12 +3,14 @@
import re
from os import listdir
from os.path import isdir
from audit.system.plugins.apache import apache_protocols
from audit.system.plugins.apache import apache_protocols, apache_signature, apache_indexes
class Apache:
def __init__(self, arguments):
self._ssl_versions = apache_protocols()
self._signature = apache_signature()
self._indexes = apache_indexes()
self._reports = dict()
self._apache_directory = arguments["apache_directory"]
@@ -20,7 +22,16 @@ class Apache:
def runAudit(self):
print("Running test for Apache")
self._analyzingSslVersion()
# Check if the directory exist
path = f"{self._apache_directory}"
if isdir(path):
self._analyzingSslVersion()
else:
self._reports['audit'] = False
self._reports["msg"] = "No directory found"
print(self._reports)
def getReports(self) -> dict:
return self._reports
@@ -30,14 +41,19 @@ class Apache:
path = f"{self._apache_directory}/sites-available"
if isdir(path):
self._reports['audit'] = True
count = 0
for site in listdir(path):
with open(f"{path}/{site}", 'rb') as f:
self._parseFile(f)
count += 1
if count == 0:
self._reports['audit'] = False
self._reports['msg'] = \
f'No virtual host found in the directory {path}'
else:
self._reports['audit'] = False
self._reports["msg"] = "No directory found"
print(self._reports)
self._reports["msg"] = f"No directory {path} found"
def _parseFile(self, fdata):
data = fdata.read()
@@ -102,3 +118,5 @@ class Apache:
- level: high, medium or low
"""
self._reports['ssl'] = dict()
self._reports['signature'] = dict()
self._reports['indexes'] = dict()