[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: webshield_captcha_keys.py
File is not writable. Editing disabled.
import asyncio import logging import random from defence360agent.contracts.config import SystemConfig from defence360agent.contracts.messages import ConfigUpdate from defence360agent.contracts.plugins import MessageSink, expect from defence360agent.utils import atomic_rewrite from im360.contracts.config import Webshield from im360.subsys import webshield logger = logging.getLogger(__name__) _NGINX_CONFIG = '/etc/imunify360-webshield/' \ 'webshield-http.conf.d/captchakeys.conf' _NGINX_CONFIG_TPL = """ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # DO NOT EDIT. AUTOMATICALLY GENERATED. # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # # Direct modifications to this file WILL be lost upon subsequent # regeneration of this configuration file. # # To have your modifications retained, you should use # update settings in UI. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # captcha_site_key {site_key}; captcha_secret_key {secret_key}; """ PREDEFINED_KEYS = [{ 'site_key': '6LfsZ_wUAAAAAHoeRpleA1IY4j62iofQtA_0jJhB', 'secret_key': '6LfsZ_wUAAAAADruSY3HSNxy31QQsH17CKNRPAAK', }, { 'site_key': '6LcLaPwUAAAAAOLoPlKRFZnQW2QNKjKN2v1ReY2S', 'secret_key': '6LcLaPwUAAAAAE3JSA-AEzkQ5_N7vr8Pg8k1UDqa', }, { 'site_key': '6LcZaPwUAAAAAKQ8DW178c0eBeIXAr0c_oEQnHMZ', 'secret_key': '6LcZaPwUAAAAAORZW2nuA593V2t8IIL6MIHLDl9m', }, { 'site_key': '6LfwghwUAAAAAAYrFATHtss0Xe_bC7I6OWE_ayK4', 'secret_key': '6LfwghwUAAAAALdx_xobqogq6hpa4pR8usRovQl8' }] class WebshieldCaptchaKeys(MessageSink): def __init__(self): self._cached = {} self._loop = None async def create_sink(self, loop) -> None: self._loop = loop @expect(ConfigUpdate) async def on_config_update(self, message: ConfigUpdate): # also executed on agent startup try: if isinstance(message["conf"], SystemConfig): if not Webshield.ENABLE: return keys = { 'site_key': Webshield.CAPTCHA_SITE_KEY, 'secret_key': Webshield.CAPTCHA_SECRET_KEY, } if self._cached == keys: return template_params = keys \ if (Webshield.CAPTCHA_SITE_KEY and Webshield.CAPTCHA_SECRET_KEY) \ else random.choice(PREDEFINED_KEYS) atomic_rewrite( _NGINX_CONFIG, _NGINX_CONFIG_TPL.format(**template_params), backup=False, ) logger.info("Reloading Webshield service.") await webshield.service_reload() self._cached = keys except asyncio.CancelledError: raise except Exception as e: # webshield directory is absent in integration tests, causing # 'config update' failure logger.error( 'Something went wrong during updating captcha keys: %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.2 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