403Webshell
Server IP : 216.106.184.20  /  Your IP : 216.73.216.234
Web Server : LiteSpeed
System : Linux asmodeus.in-hell.com 5.14.0-570.58.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 29 06:24:11 EDT 2025 x86_64
User : sekoaid1 ( 1891)
PHP Version : 7.3.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/imunify360/venv/lib/python3.11/site-packages/im360/simple_rpc/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/imunify360/venv/lib/python3.11/site-packages/im360/simple_rpc/uninstall_cleanup.py
import logging
import os

from pathlib import Path

from defence360agent.contracts.config import AcronisBackup
from defence360agent.rpc_tools.lookup import RootEndpoints, bind
from defence360agent.utils import Scope, atomic_rewrite
from im360.plugins.lfd import LFD
from im360.subsys import csf
from im360.utils.net import OUT, TCP

logger = logging.getLogger(__name__)


class UninstallCleanupEndpoints(RootEndpoints):
    SCOPE = Scope.IM360

    @bind("remove-csf-ports")
    async def remove_csf_ports(self):
        if not os.path.isfile(csf.CSF_CONFIG):
            logging.info("Nothing to do, there is no csf config file")
            return
        try:
            ports = AcronisBackup.PORTS
            ranges = AcronisBackup.RANGE
            csf.remove_ports(TCP, OUT, *ports, ranges=ranges)
            await csf.restart_all()
            logging.info("Successfully removed Acronis ports from csf config")

        except Exception:
            logger.exception("Failed to remove Arconis ports from csf config")

    @bind("remove-csf-post-hook")
    async def remove_csf_post_hook(self):
        for script_path in [
            csf.CSF_POST_HOOK_SCRIPT_USR_LOCAL,
            csf.CSF_POST_HOOK_SCRIPT_ETC,
        ]:
            path = Path(script_path)
            if not path.is_file():
                continue

            try:
                content = path.read_bytes()
                new_content = content
                for script_line in (
                    csf.IPSET_RESTORE_SCRIPT,
                    csf.IPSET_RESTORE_SCRIPT_LEGACY,
                ):
                    if script_line in new_content:
                        new_content = new_content.replace(script_line, b"")
                if new_content != content:
                    logger.info(
                        "Removing ipset restore script from %s",
                        script_path,
                    )
                    atomic_rewrite(script_path, new_content)
            except Exception:
                logger.exception(
                    "Failed to remove ipset restore script from %s",
                    script_path,
                )

    @bind("remove-block-report-script")
    async def restore_block_report_script(self):
        await LFD().shutdown()

    @bind("restore-configs")
    async def pre_uninstall(self):
        await self.remove_csf_ports()
        await self.remove_csf_post_hook()
        await self.restore_block_report_script()

Youez - 2016 - github.com/yon3zu
LinuXploit