403Webshell
Server IP : 162.0.217.223  /  Your IP : 216.73.216.168
Web Server : LiteSpeed
System : Linux premium269.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : mypckeys ( 1539)
PHP Version : 8.1.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/imunify360/venv/lib64/python3.11/site-packages/imav/wordpress/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/imunify360/venv/lib64/python3.11/site-packages/imav/wordpress/__pycache__/cli.cpython-311.pyc
�

�l�h�*��|�dZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
mZddlm
Z
mZddlmZmZmZddlmZdd	lmZeje��Zd
edefd�Zd
edefd�Zdedefd�Zdefd�Zdefd�Z defd�Z!defd�Z"defd�Z#defd�Z$defd�Z%defd�Z&ed���defd���Z'd�Z(defd�Z)dS)u

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.


This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
See the GNU General Public License for more details.


You should have received a copy of the GNU General Public License
 along with this program.  If not, see <https://www.gnu.org/licenses/>.

Copyright © 2019 Cloud Linux Software Inc.

This software is also available under ImunifyAV commercial license,
see <https://www.imunify360.com/legal/eula>
�N)�Path)�
StrictVersion)�	check_run�
CheckRunError�async_lru_cache)�PLUGIN_PATH�PLUGIN_SLUG)�build_command_for_user�get_php_binary_path�
wp_wrapper)�log_message)�WPSite�version_str�returnc��t|t��sdS|���}|sdS	t|��dS#t$rYdSwxYw)z1Validate if a string is a valid semantic version.FT)�
isinstance�str�stripr�
ValueError)r�trimmed_strs  �G/opt/imunify360/venv/lib/python3.11/site-packages/imav/wordpress/cli.py�_validate_semverr-su���k�3�'�'���u��#�#�%�%�K����u���k�"�"�"��t�������u�u����s�A�
A�A�outputc�`�|sdS|���}|sdSt|��dkr+|d���}t|��r|St|��dkr+|d���}t|��r|St	dd|idd�	��dS)
z�
    Extract version from WP CLI output, trying both first and last parts.

    Args:
        output: The raw output from WP CLI

    Returns:
        The extracted version string or None if no valid version found
    Nr����zMFailed to extract valid semver version from WP CLI output. Output: '{output}'r�warningz#wp-plugin-version-extraction-failed)�format_args�level�fingerprint)�split�lenrrr
)r�parts�
first_part�	last_parts    r�_extract_version_from_outputr&?s������t�
�L�L�N�N�E����t��5�z�z�A�~�~��1�X�^�^�%�%�
��J�'�'�	����5�z�z�A�~�~��"�I�O�O�%�%�	��I�&�&�	����	��v�&��9������4��sitec��K�t|���d{V��}|dzdzdz}|���sdStjd��}	t	|��5}|D][}|�|��}|rB|�d��}t|��r|ccddd��Sddd��dS�\	ddd��n#1swxYwYn4#t$r'}t�
d||��Yd}~dSd}~wwxYwdS)z�
    Parse the version of imunify-security plugin by reading the main plugin file.

    Args:
        site: WordPress site object containing docroot path

    Returns:
        str: Plugin version or None if not found or invalid
    N�plugins�imunify-securityzimunify-security.phpz\* Version:\s*([0-9.]+)rz=Failed to read plugin file to determine version number %s: %s)�get_content_dir�exists�re�compile�open�search�groupr�	Exception�logger�error)	r(�content_dir�plugin_file�version_pattern�f�line�match�version�es	         r�_parse_version_from_plugin_filer>js�����(��-�-�-�-�-�-�-�-�K��i��"4�4�7M�M���������t��j�!;�<�<�O��
�+�
�
�	$�!��
$�
$��'�.�.�t�4�4���$�#�k�k�!�n�n�G�'��0�0�$�&���
	$�	$�	$�	$�	$�	$�	$�	$� $�	$�	$�	$�	$�	$�	$�	$�	$�$�
$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$����������K��
�	
�	
�	
�
�t�t�t�t�t�����
�����4sU�C�AC	� C�-C	�.C�;C	�=C�	C
�
C�C
�C�
D�D�Dc��\K�tj|j��j}t	||���d{V��}gt||j���d�d�tt���d�d�}t||��}t�d|����t|���d{V��dS)zFInstall the Imunify Security WordPress plugin on given WordPress site.N�plugin�install�
--activate�--forcezInstalling wp plugin �
�pwd�getpwuid�uid�pw_namerr�docrootrrr
r4�infor�r(�username�php_path�args�commands     r�plugin_installrP�s������|�D�H�%�%�-�H�(��x�8�8�8�8�8�8�8�8�H��	�H�d�l�	+�	+����	��	�K���	�
	��	�
�D�%�X�t�4�4�G�
�K�K�1��1�1�2�2�2�
�G�
�
���������r'c��\K�tj|j��j}t	||���d{V��}gt||j���d�d�tt���d�d�}t||��}t�d|����t|���d{V��dS)z�
    Update the Imunify Security WordPress plugin on given WordPress site.

    Currently, this is the same as install, but in the future it may differ.
    Nr@rArBrCzUpdating wp plugin rDrKs     r�
plugin_updaterR�s������|�D�H�%�%�-�H�(��x�8�8�8�8�8�8�8�8�H��	�H�d�l�	+�	+����	��	�K���	�
	��	�
�D�%�X�t�4�4�G�
�K�K�/�g�/�/�0�0�0�
�G�
�
���������r'c��>K�tj|j��j}t	||���d{V��}gt||j���d�d�t�d�}t||��}t�
d|����t|���d{V��dS)z<Uninstall the imunify-security wp plugin from given wp site.Nr@�	uninstallz--deactivatezUninstalling wp plugin )rErFrGrHrrrIr	r
r4rJrrKs     r�plugin_uninstallrU�s������|�D�H�%�%�-�H�(��x�8�8�8�8�8�8�8�8�H��	�H�d�l�	+�	+����	��	�	�
	��D�%�X�t�4�4�G�
�K�K�3�'�3�3�4�4�4�
�G�
�
���������r'c��tK�tj|j��j}t	||���d{V��}gt||j���d�d�t�d�}t||��}t�
d|����	t|���d{V��}|�d���
��}t|��S#t$r+}t�d|j��Yd}~dSd}~wt$$r&}t�d|��Yd}~dSd}~wwxYw)	z�
    Get the version of the imunify-security wp plugin installed on given WordPress site.

    Uses WP CLI to get the version.
    Nr@�getz--field=versionzGetting wp plugin version �utf-8z0Failed to get wp plugin version. Return code: %sz-Failed to decode wp plugin version output: %s)rErFrGrHrrrIr	r
r4rJr�decoderr&rr5�
returncode�UnicodeDecodeError)r(rLrMrNrO�resultrr=s        r�_get_plugin_versionr]�s}�����|�D�H�%�%�-�H�(��x�8�8�8�8�8�8�8�8�H��	�H�d�l�	+�	+����	��	�	�
	��D�%�X�t�4�4�G�
�K�K�6�W�6�6�7�7�7�� ��)�)�)�)�)�)�)�)�����w�'�'�-�-�/�/��+�F�3�3�3���������>�
�L�	
�	
�	
��t�t�t�t�t������������D�a�H�H�H��t�t�t�t�t��������s%�	A
C�
D7� D�
D7�D2�2D7c��K�	t|���d{V��}|r|Sn2#t$r%}t�d|��Yd}~nd}~wwxYwt�d��t|���d{V��S)z�
    Get the version of the imunify-security wp plugin installed on given WordPress site.

    First tries to parse the version from the plugin file, then falls back to WP CLI.
    Nz,Failed to parse version from plugin file: %sz/Plugin version not found in file, trying WP CLI)r>r3r4rrJr])r(r<r=s   r�get_plugin_versionr_�s�����J�7��=�=�=�=�=�=�=�=���	��N�	���J�J�J����E�q�I�I�I�I�I�I�I�I�����J�����K�K�A�B�B�B�$�T�*�*�*�*�*�*�*�*�*s��
A
�A�A
c��`K�tj|j��j}t	||���d{V��}gt||j���d�d�t�}t||��}t�
d|����	t|���d{V��n#t$rYdSwxYwdS)zMCheck if the imunify-security wp plugin is installed on given WordPress site.Nr@�is-installedz#Checking if wp plugin is installed FT)
rErFrGrHrrrIr	r
r4rJrrrKs     r�is_plugin_installedrb
s������|�D�H�%�%�-�H�(��x�8�8�8�8�8�8�8�8�H��	�H�d�l�	+�	+����	��	�	�D�%�X�t�4�4�G�
�K�K�?�g�?�?�@�@�@���� � � � � � � � � � �������u�u�����
�4s�B�
B+�*B+c��RK�tj|j��j}t	||���d{V��}gt||j���d�d�}t||��}t�	d|����	t|���d{V��n#t$rYdSwxYwdS)zJCheck if WordPress is installed and given site is accessible using WP CLI.N�coreraz#Checking if WordPress is installed FT)rErFrGrHrrrIr
r4rJrrrKs     r�is_wordpress_installedre"s������|�D�H�%�%�-�H�(��x�8�8�8�8�8�8�8�8�H��	�H�d�l�	+�	+����	��D�
%�X�t�4�4�G�
�K�K�?�g�?�?�@�@�@���� � � � � � � � � � �������u�u������4s�B�
B$�#B$c��DK�tj|j��j}t	||���d{V��}gt||j���d�d�}t||��}t�	d|����	t|���d{V��}|�d�����S#t$r+}t�d|j��Yd}~dSd}~wt $r&}t�d|��Yd}~dSd}~wwxYw)z�
    Get the content directory of the WordPress site using WP CLI.

    This should only be used if the default wp-content directory does not exist.
    N�evalzecho WP_CONTENT_DIR;zGetting content directory rXz0Failed to get content directory. Return code: %sz-Failed to decode content directory output: %s)rErFrGrHrrrIr
r4rJrrYrrr5rZr[)r(rLrMrNrOr\r=s       r�_get_content_directoryrh9s\�����|�D�H�%�%�-�H�(��x�8�8�8�8�8�8�8�8�H��	�H�d�l�	+�	+����	��D�
%�X�t�4�4�G�
�K�K�6�W�6�6�7�7�7�� ��)�)�)�)�)�)�)�)���}�}�W�%�%�+�+�-�-�-���������>�
�L�	
�	
�	
��t�t�t�t�t������������D�a�H�H�H��t�t�t�t�t��������s$�;B<�<
D� C,�,
D�9D�D�d)�maxsizec���K�t|j��dz}|���r|���s&t	|���d{V��}|rt|��}|S)a�
    Get the WordPress content directory for the given WordPress site.

    This function first checks if the default wp-content directory exists at the site's docroot.
    If the default path doesn't exist or isn't a directory, it attempts to get the actual
    content directory using WordPress CLI's WP_CONTENT_DIR constant.

    Returns:
        Path: The WordPress content directory path
    �
wp-contentN)rrIr-�is_dirrh)r(r6�wp_content_dirs   rr,r,Xs�����t�|�$�$�|�3�K������/�{�'9�'9�';�';�/�5�d�;�;�;�;�;�;�;�;���	/��~�.�.�K��r'c�8�t���dS)z.Clear the async LRU cache for get_content_dir.N)r,�cache_clear�r'r�clear_get_content_dir_cacherrps�����!�!�!�!�!r'c��K�t|���d{V��}|st|j��dz}t|��dzS)zO
    Get the Imunify Security data directory for the given WordPress site.
    Nrlr+)r,rrI)r(r6s  r�get_data_dirrtusW����(��-�-�-�-�-�-�-�-�K��8��4�<�(�(�<�7������1�1�1r')*�__doc__�loggingrEr.�pathlibr�distutils.versionr�defence360agent.utilsrrr�imav.wordpressrr	�imav.wordpress.utilsr
rr�defence360agent.sentryr
�imav.model.wordpressr�	getLogger�__name__r4r�boolrr&r>rPrRrUr]r_rbrerhr,rrrtrqr'r�<module>r�s�����*����
�
�
�
�	�	�	�	�������+�+�+�+�+�+�����������
4�3�3�3�3�3�3�3�����������
/�.�.�.�.�.�'�'�'�'�'�'�	��	�8�	$�	$���#��$�����$(��(��(�(�(�(�V&��&�3�&�&�&�&�R�v�����*�f�����2������(�F�����D+�6�+�+�+�+�&�F�����0�v�����.�v�����>��������������."�"�"�
2�V�2�2�2�2�2�2r'

Youez - 2016 - github.com/yon3zu
LinuXploit