shell bypass 403

Cubjrnet7 Shell

: /usr/share/lve/modlscapi/user/__pycache__/ [ drwxr-xr-x ]

name : mod_lsapi_stat.cpython-39.pyc
a

ABMf�:�@s�ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddlm
Z
ddlmZddlm
Z
mZmZmZmZddlmZmZmZmZmZmZmZddlZGdd	�d	e�Zddd�Zddd�Zddd�Zddd�Zdd�Z dd�Z!dd�Z"dS)�N)�get_cp)�criu_settings_malfunctions)�lsapi_settings_malfunctions)�liblsapi_malfunctions)�
cpanel_whmapi�plesk_bin_php_handler�dump_loaded_modules�
dump_lsapi�
query_strings)�get_da_domains�get_da_php_options�read_da_config�
liblsapi_path�pretty_version_keys�
count_domains�StatUtilsExceptionc@seZdZdS)�ModLsapiStatExceptionN)�__name__�
__module__�__qualname__�rr�//usr/share/lve/modlscapi/user/mod_lsapi_stat.pyrsrFc
Csd}i}t�}zd|jdkr8tj�d�r2t�|d<qpd}n8|jdkrNt�|d<n"|jdkrdt�|d<nd�|j�}Wn,t	y�}zt
|�}WYd}~n
d}~00|dur�t�|d<||d	<t
|�|d
<|�t
��|�t��|�dt|d���i�t|�|�rtj|dd
�S|SdS)a�
    Return statistics data
    :param as_json: return json string if True, dict otherwise
    :return: statistics data dict(
                `controlPanel`: EA3/EA4/Plesk/DirectAdmin/Unknown CP,
                `criu`: dict(
                        `status`: running/stopped,
                        `version`: version
                    ),
                `domainStat`: dict(
                        `version`: `domains_num`,
                        ...
                    ) or dict(`error`: description) if some error occurred,
                `lsapiConf`: dict(
                        lsapi_with_connection_pool: on/off,
                        lsapi_criu: on/off
                    )
            ) or its json-packed version
    N�cPanelz/etc/cpanel/ea4/is_ea4Z
domainStatz7mod_lsapi domains stat is currently unsupported for EA3�Plesk�DirectAdminz7mod_lsapi domains stat is currently unsupported for {0}ZdomainStatErrorZcontrolPanelZtotalDomainT)Z	sort_keys)r�name�os�path�exists�get_cpanel_ea4_stat�get_plesk_stat�get_da_stat�formatr�str�dict�update�get_lsapi_conf�
get_crui_stat�sum�values�analyze_malfunctions�json�dumps)�as_json�errorZstatsZ
control_panel�errr�get"s4



r0Tc
CsPt�}t�}t�}z�td��d�}|D]8}|�|�d�t���|�d��|�d�||�d�<q&td��d�}tdd	�|D��}t|���}	|��D]*\}
}|�|t���	|
|�|
t��i�q�|r�t
�|||�}|}|��D].\}
}|�	t�t|	��
t|����t���q�Wn2tttf�yBtd
�t���d����Yn0t||	|�S)aY
    Collect mod_lsapi statistics for cPanel EA4 through WHM API
    :param lsapi_only: return only lsapi domains statistics if True, or full statistics if False
    :param with_selector: take into account the statistics of php selector
    :return: if lsapi_only return lsapi domains per version
                stat dict(
                    `version`: `domains_num`,
                    ...
                )
            else return full statistics per handler
                stat dict(
                    `handler`: {`version`: `domains_num`, ... }
                    ...
                )
    Zphp_get_vhost_versionsZversions�version�vhostZaccountZphp_get_handlers�version_handlerscSs g|]}|�d�|�d�f�qS)r1Zcurrent_handler�r0��.0�hrrr�
<listcomp>t�z'get_cpanel_ea4_stat.<locals>.<listcomp>��
)r$rr0�
setdefault�set�add�list�keys�itemsr%�selector_usage_libZea4_selector_check�fromkeys�
difference�KeyError�	TypeErrorrr�join�	traceback�
format_exc�splitr)�
lsapi_only�
with_selectorZdomains_per_versionZ
handlers_statZdomain_usersZvhosts_datar2Z
handlers_datar3Zall_versionsZver�handlerZs_checked_version_handlersr7�vrrrrYs* $,rc
Csd}d}t�}z�td�}dd�|D�}|D]t}|�d�}d�|�d��d	�d
d��}	tdd�td
|d�D��}
d|vr�d}|j|	d�}n|j|	d�}|
||<q*|r�t�||�}Wn6t	t
tttj
fy�td�t���d����Yn0ddd�|��D�i}|�r|dS|S)a
    Collect mod_lsapi statistics for Plesk
    Collects lsapi domains ONLY
    :param lsapi_only: return only lsapi domains statistics if True, or full statistics if False
    :param with_selector: take into account the statistics of php selector
    :return: if lsapi_only return lsapi domains per version dict(
                    `version`: `domains_num`
                    ...
                )
            else return stats with handler dict(
                    `lsapi`: {`version`: `domains_num`, ... }
                )
    z
alt-php{v}z	alt-php56r?cSsg|]}d|�d�vr|�qS)Zlsphp�idr4r5rrrr8�r9z"get_plesk_stat.<locals>.<listcomp>rOr:ZfullVersion�.N���cSsg|]}|�d��qS)�domainr4)r6�drrrr8�r9z	get-usage)rOZcustom)rNr;ZlsapicSsi|]\}}|t|��qSr)�len)r6�krNrrr�
<dictcomp>�r9z"get_plesk_stat.<locals>.<dictcomp>)r$rr0rGrJr=r"rBZplesk_selector_checkrErF�AttributeErrorrZSelectorStatExceptionrrHrIrA)
rKrLZhandler_tmplZcustom_versionZdomain_version_statZall_handlersZlsphp_handlersrMZ
handler_idZphp_version�domainsZ
version_idZresult_statrrrr �s,

�r csd}t�}�z�t�}|dd}|dd}|dd}|dd}t|�}	t|�}
t�}t���fdd�|��D�|dkr�|	�i}|	�i||<�n|dkr�|
�i}|
�i||<n�|	t�|
t�i}|��D]�\}
}|D]v}|j|
|d	�}z<t|�\}}|�	|d
�}t||d�}|�
|��|�Wq�tj
�yL|�
|	��|�Yq�0q�q�||k�rv|	||	|
||
i||<n,|	||	|
t�i||<|
||
|	t�i||<|�r�t�|�
|	�||	�}|�
|��|�Wn4ttttf�ytd�t���d����Yn0t||	|
g|�S)
aN
    Collect lsapi domains statistics fro DirectAdmin
    :param lsapi_only: return only lsapi domains statistics if True, or full statistics if False
    :param with_selector: take into account the statistics of php selector
    :return: if lsapi_only return lsapi domains per version
                stat dict(
                    `version`: `domains_num`,
                    ...
                )
            else return full statistics per handler
                stat dict(
                    `handler`: {`version`: `domains_num`, ... }
                    ...
                )
    z>/usr/local/directadmin/data/users/{user}/domains/{domain}.conf�r1�rMcsg|]}��|��qSr)r%)r6rN�Zjoinedrrr8�r9zget_da_stat.<locals>.<listcomp>Zno)�userrRZphp1_selectr:r;)r$rrrr=r)rAr"r
Zgetintr0r>�configparserZ
NoOptionErrorrBZda_selector_checkr%rErFrWrrrGrHrIrJr)rKrLZdomain_conf_pathZhandler_statZphp_optionsZphp1_verZphp2_verZphp1_handlerZphp2_handlerZ
php1_labelZ
php2_labelZuser_domainsZversion_statr\rXrRZconfig_pathZconf_parserZglobal_sectionZphp_settingr1Zselector_updatedrr[rr!�s\
�
��r!cCsjd�t�d��}z tjgd�tjtjd�d}WntjyHd}Yn0d||r`|�d�d	nd
d�iS)z�
    Get criu service info
    :return: dict(
                `criu`: dict(
                    `status`: running/stopped,
                    `version`: version
                )
            )
    r:z/usr/sbin/criu -V)z
/sbin/service�criu�status)�stdout�stderrZrunning�stoppedr^� rYz
not installed)r_r1)rG�exec_command�
subprocessZ
check_callZDEVNULLZCalledProcessErrorrJ)Zcriu_versionZcriu_service_statusrrrr's

��r'cCsTt�}t�}|�dd�}|�dd�|�dd�d�|�dd�tt�d�|sLd	nd
d�S)al
    Retrieve lsapi configuration:
    - crui
    - connection pool
    and versions of module and library
    :return: dict(
                lsapiConf: dict(
                    lsapi_with_connection_pool: on/off,
                    lsapi_criu: on/off
                ),
                modVersion: version,
                libVersion: version
            )
    Zlsapi_moduleN�
lsapi_criuZoff�lsapi_with_connection_pool)rfrgr1Zliblsapi_versionZdisabledZenabled)�	lsapiConfZ
modVersion�
libVersion�	modStatus)r	rr0r
r)Zapache_confZapache_modulesZ
mod_statusrrrr&s

�


�r&cstt���fdd�}dj|dd|ddd�}|d	}|t|d
�|t|�|t|��sbdS|�d�i�dS)
z�
    Detect configuration malfunctions and update resulting statistics dict accordingly
    For now only criu malfunctions are presented
    See malfunctions in dashboard_malfunctions.py module
    :param stats_dict: resulting statistics dict
    cs*z��||�Wnty$Yn0dS)N)�appendrE)Zmalfunc_dict�key��malfunctionsrr�add_malfunctionHsz-analyze_malfunctions.<locals>.add_malfunctionz{opt}_{serv}rhrfr^r_)�optZservrjriNrn)r?r"rrrr%)Z
stats_dictroZ
criu_settingsZlsapi_settingsrrmrr*?s
�

r*)F)TT)TT)TT)#rr+rHrer]rd�lve_diagnosticrZdashboard_malfunctionsrrr�
stat_utilsrrrr	r
rrr
rrrrrB�	Exceptionrr0rr r!r'r&r*rrrr�<module>s($
7
1
,
O 

© 2025 Cubjrnet7