관리-도구
편집 파일: wordpress.cpython-311.pyc
� ���Z�.�I���������������������� ����d�Z�ddlZddlZddlZddlmZ�ddlmZmZ�ddl m Z �ddlmZ�ddlm Z mZmZ�ddlmZ�dd lmZmZ�dd lmZ�esddlmZ�ndZddlmZ�dd lmZ�ddlmZ��ej��������e ������������Z!�G�d��de e������������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)� HookEvent)�choose_value_from_config�SystemConfig)�MessageType)�ANTIVIRUS_MODE)�MessageSink� MessageSource�expect)�HostingPanel)� load_state� save_state)�Scope)�plugin)� Wordpress)� MalwareHit��WPSitec������������������������e�Zd�Zej��������Zd��Zd��Zd��Zd��Z dd�Z d��Zd��Z�e ej��������������������d ����������������Z�e ej��������������������d ����������������Z�e ej��������������������d����������������Z�e ej��������������������d����������������Zd S�)�ImunifySecurityPluginc������������������������d�|�_���������d�|�_��������t����������d���������������������������������d������������|�_��������t����������d���������������������������������d������������pt ����������j��������|�_��������d�|�_��������d�|�_ ��������d�S�)Nr���� installed�enabled) �_loop�_sinkr����get�installation_completedr����SECURITY_PLUGIN_ENABLED�last_config_value�installation_task� deleting_task)�selfs��� �K/opt/imunify360/venv/lib/python3.11/site-packages/imav/plugins/wordpress.py�__init__zImunifySecurityPlugin.__init__<���s{�������� ��� �&0�1H�&I�&I�&M�&M��' ��' ��#�� �.�/�/�3�3�I�>�>�� 1��0�� ���7;���26���������c������������������� ���K����d�S��N��)r!����loops��� r"����create_sinkz!ImunifySecurityPlugin.create_sinkI���s�����������r$���c�������������������&���K����||�_���������||�_��������d�S�r&���)r���r���)r!���r(����sinks��� r"���� create_sourcez#ImunifySecurityPlugin.create_sourceL���s������������ ��� � � r$���c������������������������t����������|�|������������st�������������������������������d|�������������t����������|�|������������}|d�uo)|������������������������������������o|������������������������������������S�)NzUnknown task '%s')�hasattr�logger�error�getattr�done� cancelled)r!����task_attr_name�tasks��� r"����_task_in_progressz'ImunifySecurityPlugin._task_in_progressP���sd�������t�^�,�,�� >��L�L�,�n�=�=�=��t�^�,�,���4��L�� � ���O�L�D�N�N�<L�<L�8L�Lr$���Fc���������������������K����|�����������������������d������������r*|rd�S�|�j��������������������������������������������|�j����������d�{V����|�����������������������d������������rt�������������������������������d�������������d�S�t����������j��������|������������|�_��������d�S�)Nr ���r���zInstallation is already running)r6���r ����cancelr/����warning�asyncio�create_taskr���)r!����coro� for_new_sitess��� r"����process_installationz*ImunifySecurityPlugin.process_installationW���s������������!�!�/�2�2�� %��� �����%�%�'�'�'��$�$�$�$�$�$�$�$��!�!�"5�6�6�� ��N�N�<�=�=�=��F�!(�!4�T�!:�!:����r$���c���������������������K����|�����������������������d������������r&|�j��������������������������������������������|�j����������d�{V����|�����������������������d������������rt�������������������������������d�������������d�S�t����������j��������|������������|�_��������d�S�)Nr���r ���zDeleting is already running)r6���r���r8���r/���r9���r:���r;���r ���)r!���r<���s��� r"����process_deletingz&ImunifySecurityPlugin.process_deletinge���s������������!�!�"5�6�6�� )��"�)�)�+�+�+��(�(�(�(�(�(�(�(��!�!�/�2�2�� ��N�N�8�9�9�9��F�$�0��6�6����r$���c���������������������K����t�������������������������������������������������������������d�{V���}t������������������������}t������������������������}|D�]H}t����������dd|�������������\��}}|dk����r|���������������������|��������������3|���������������������|��������������I|r7t �������������������������������d�������������t �������������������������������d|���������������|S�)N�MALWARE_SCANNING�default_action)�username�cleanupz�WordPress plugin installation is currently available only with the following config settings: {"MALWARE_SCANNING": {"default_action": "cleanup"}. Additional options will be supported later.z(Skipping installation for invalid_users=)r���� get_users�setr����addr/����info)r!����users�valid_users� invalid_users�userrC����_s��� r"����get_valid_usersz%ImunifySecurityPlugin.get_valid_usersp���s�����������"�n�n�.�.�0�0�0�0�0�0�0�0���e�e����� ��� (�� (�D� 8�"� ��!��!��!��N�A����*�*�����%�%�%�%��!�!�$�'�'�'�'��� G��K�K�$� �� �� �� �K�K�E�]�E�E�F�F�F��r$���c���������������������K����t��������������������������������d|j��������|j���������������������|j��������dk����r[|�j��������sd�S�|��������������������������������������d�{V���}|����������������������t����������j��������||�j ���������������������d���������������d�{V����d�S�|j��������dk����rht����������j ��������|�j �����������������������d�{V����t����������j��������s>|�� ��������������������t����������j��������|�j �����������������������������������d�{V����d|�_��������d�S�d�S�d�S�) Nz<ImunifySecurityPlugin received message action: %s method: %s�install_on_new_sites�rJ���r+���T)r=����tidy_up�r+���F)r/���rI����action�methodr���rO���r>���r����install_for_usersr����tidy_up_manually_deletedr���r���r@����remove_all_installed)r!����messagerK���s��� r"����manage_plugin_actionz*ImunifySecurityPlugin.manage_plugin_action����sv������������J��N��N� �� �� ���>�3�3�3��.�� ��� $� 4� 4� 6� 6�6�6�6�6�6�6�K��+�+��(�{���L�L�L�"��,������ �� �� �� �� �� �� �� �� ���^�y� (� (��1�t�z�B�B�B�B�B�B�B�B�B�B��4�� 4��+�+��/�T�Z�@�@�@�������������������/4��+�+�+��)� (� 4�� 4r$���c���������������������K����t����������|d���������t����������������������sd�S�t����������j��������}||�j��������k����rd�S�||�_��������|r]|�j��������sV|��������������������������������������d�{V���}|����������������������t����������j ��������||�j �����������������������������������d�{V����d|�_��������nC|sA|�j��������r:|����������������������t����������j��������|�j �����������������������������������d�{V����d|�_��������t����������d|�j��������|d��������������d�S�)N�confrR���TrT���Fr���)r���r���)� isinstancer���r���r���r���r���rO���r>���r���rW���r���r@���rY���r ���)r!���rZ����current_config_valuerK���s��� r"����manage_plugin_installationz0ImunifySecurityPlugin.manage_plugin_installation����sk����������'�&�/�<�8�8�� ��F�(�@���4�#9�9�9��F��"6����� 0��(C�� 0� $� 4� 4� 6� 6�6�6�6�6�6�6�K��+�+��(�{���L�L�L����� �� �� �� �� �� �� ��+/�D�'�'�%�� 0�$�*E�� 0��'�'��+���<�<�<����� �� �� �� �� �� �� ��+0�D�'��#�!�8�/� �� � �� �� �� �� r$���c���������������������K����|�j���������sdS�|���������������������d������������dk����s|���������������������d������������sdS�t����������j��������|d���������������������}t ������������������������}|D�]�}|j��������dk����r~ �t ����������j��������|j��������������������}|j ��������}t����������j��������|������������}|D�]5}|j��������� ��������������������|������������r|���������������������||f��������������n�6�{#�t����������$�r�Y���w�xY�w��|st �������������������������������d�������������dS�t �������������������������������dt'����������|�������������������������d��|D���������������} t����������j��������|�j��������| ��������������d{V����t �������������������������������d t'����������| �������������������������dS�) a��� INFO [2025-02-24 12:00:20,384] imav.plugins.wordpress: Malware cleanup finished: HookEvent.MalwareCleanupFinished( { 'cleanup_id': 'fa4fe7e48dbf45588f53b24366cd8893', 'started': 1740398411.786418, 'error': None, 'total_files': 3, 'total_cleaned': 3, 'status': 'ok' } ) N�status�ok�started�filez3Cleanup finished => no sites found for cleaned hitsz1Cleanup finished => %s site(s) need to be updatedc������������������8�����g�|�]\��}}t����������|d�|���������������S�)��)�docroot�domain�uidr���)�.0� site_pathrj���s��� r"���� <listcomp>zIImunifySecurityPlugin.handle_malware_cleanup_finished.<locals>.<listcomp>��s;������� �� �� �� �3�� �9�R�S�9�9�9� �� �� r$���z"%s site(s) updated after a cleanup)r���r���r���� cleaned_sincerG���� resource_type�pwd�getpwnamrM����pw_uidr����get_sites_for_user� orig_file� startswithrH����KeyErrorr/����debugrI����len�update_data_on_sitesr���) r!���rZ����hits� site_paths�hit� user_inforj���� user_sitesrl����wordpress_sitess ��� r"����handle_malware_cleanup_finishedz5ImunifySecurityPlugin.handle_malware_cleanup_finished����s���������� ��%�� ��F���;�;�x� � �D�(�(����I�0F�0F�(��F���'�� �(:�;�;���U�U� ���� �� �C�� �F�*�*�� #��S�X� 6� 6�I�#�*�C�!'�!:�3�!?�!?�J�%/��"��"� ��=�3�3�I�>�>��"�&�N�N�I�s�+;�<�<�<�!�E�"���� ��������D������+���� ��L�L�N�O�O�O��F����?�� �O�O� �� �� � �� �",� �� �� �� ��)�$�*�o�F�F�F�F�F�F�F�F�F����8�#�o�:N�:N�O�O�O�O�Os����4A,C!�! C.�-C.c���������������������K����|�j���������sdS�|���������������������d������������dk����s*|���������������������d������������r|���������������������d������������sdS�|d���������}t����������j��������|������������}|st�������������������������������d|�������������dS�t�������������������������������dt����������|�������������������������t����������j��������|�j ��������|��������������d{V����t�������������������������������dt����������|�������������������������dS�) a��� INFO [2025-02-24 11:57:17,968] imav.plugins.wordpress: Malware scan finished: HookEvent.MalwareScanningFinished( { 'scan_id': 'b9bd136aff0a4d87a248c859cfe41c47', 'scan_type': 'user', 'path': '/home/user1' } ) INFO [2025-02-24 12:00:10,740] imav.plugins.wordpress: Malware scan finished: HookEvent.MalwareScanningFinished( { 'scan_id': 'a74271d2cdd04e0c9bd49ef6de23e0d8', 'scan_type': 'user', 'path': '/home/user4', 'started': 1740398383, 'total_files': 39229, 'total_malicious': 3, 'error': None, 'status': 'ok', 'scan_params': {'intensity_cpu': 2, 'intensity_io': 2, 'intensity_ram': 2048, 'initiator': None, 'file_patterns': None, 'exclude_patterns': None, 'follow_symlinks': False, 'detect_elf': True}, 'stats': {'scan_time': 27, 'mem_peak': 28217344, 'smart_time_hs': 0.004, 'scan_time_hs': 1.1751, 'smart_time_preg': 0, 'scan_time_preg': 2.7391, 'finder_time': 13.5896, 'cas_time': 0.7562, 'deobfuscate_time': 0.8998, 'total_files': 39229} } ) Nrb���rc����path�statsz+Scan finished => no sites found for path=%sz.Scan finished => %s site(s) need to be updatedz%s site(s) updated after a scan) r���r���r����get_sites_by_pathr/���rw���rI���rx���ry���r���)r!���rZ���r�����sitess��� r"����handle_malware_scan_finishedz2ImunifySecurityPlugin.handle_malware_scan_finished��s ���������8��%�� ��F�� �K�K��!�!�T�)�)��;�;�v�&�&�� *��;�;�w�'�'�� *�� �F���v����(��.�.���� ��L�L�F��M�M�M��F�� ���<�c�%�j�j� �� �� ���)�$�*�e�<�<�<�<�<�<�<�<�<����5�s�5�z�z�B�B�B�B�Br$���N)F)�__name__� __module__�__qualname__r����IM360�SCOPEr#���r)���r,���r6���r>���r@���rO���r ���r����WordpressPluginActionr[����ConfigUpdater`���r����MalwareCleanupFinishedr�����MalwareScanningFinishedr����r'���r$���r"���r���r���9���s:��������������K�E�7��7��7� �� �� ������M��M��M�;��;��;��;� 7�� 7�� 7������6��V�K�-�.�.�4��4��/�.�4�8��V�K�$�%�%� �� ��&�%� �D��V�I�,�-�-�=P��=P��.�-�=P�~��V�I�-�.�.�4C��4C��/�.�4C��4C��4Cr$���r���)#�__doc__�loggingrp���r:����%defence360agent.contracts.hook_eventsr���� defence360agent.contracts.configr���r����"defence360agent.contracts.messagesr���r����!defence360agent.contracts.pluginsr���r ���r ����+defence360agent.subsys.panels.hosting_panelr����'defence360agent.subsys.persistent_stater���r ����defence360agent.utilsr����imav.wordpressr����imav.contracts.configr����imav.malwarelib.modelr����imav.model.wordpressr���� getLoggerr����r/���r���r'���r$���r"����<module>r�������s��������*������ � � � �������;��;��;��;��;��;�����������������;��:��:��:��:��:��;��;��;��;��;��;�������������������� �E��D��D��D��D��D��J��J��J��J��J��J��J��J��'��'��'��'��'��'���� �&�%�%�%�%�%�%� �F��+��+��+��+��+��+��,��,��,��,��,��,��'��'��'��'��'��'� �� �8� $� $��GC��GC��GC��GC��GC�K���GC��GC��GC��GC��GCr$���