gdZddlmZddlmZddlmZddlmZddl m Z ddl m Z ddl mZejejejejejfZ d d ZGd d e Zd S)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 . Copyright © 2019 Cloud Linux Software Inc. This software is also available under ImunifyAV commercial license, see ) HookEvent) MessageType)expect) execute_hooks)EventHookExecutor)MalwareHitStatus) MalwareHitNc Ktj|d\}}|r9tj||||||||} || d{VdSdS)NT) by_scan_idignore_cleaned)scan_id scan_typeerrorstartedpath total_filestotal_maliciousDUMP)r malicious_listrMalwareDetectedCriticalprocess_message) sinkr rrrtotalrrhitsmalware_detecteds U/opt/imunify360/venv/lib/python3.11/site-packages/imav/plugins/event_hook_executor.py detected_hookr)s'54OT 5$<+    ""#344444444444 5 5ceZdZeedZeejdZeej dZ eej dZ dS)ImavEventHookExecutorcXK|jt|dSN)_loop create_taskr)selfevents r receive_eventz#ImavEventHookExecutor.receive_event>s* }U3344444rc (K|d}|rdnd}|d}d|D}d|D}tj|d|d|t|t||| }|j|d{VdS) Nrfailedokrc8g|]}|jtjv|S)statusr RESTORABLE).0hs r zAImavEventHookExecutor.process_malware_cleanup..Hs(NNNah2B2M&M&M1&M&M&Mrc6g|]}|Sr,)as_dict)r/hits rr1zAImavEventHookExecutor.process_malware_cleanup..Is ...# ...r cleanup_idr)r5rrr total_cleanedr-r)rMalwareCleanupFinishedlen_sinkr)r%messagerr-rcleaneddumpmalware_cleanups rprocess_malware_cleanupz-ImavEventHookExecutor.process_malware_cleanupBs ",vNNdNNN.....#:|,I&D g,,   j((99999999999rc K|d}|dsdSt|j|d|d|d|d|d|dd{VdS)Nsummaryrscanidtyperrr)getrr9)r%r:r@s rprocess_malware_scanz*ImavEventHookExecutor.process_malware_scanVs)$ {{6""  F J H  FO I  FO M " G            rc Kt|j|j|j|j|j|j|jd{VdSr")rr9r rBrrtotal_resourcesr)r%r:s rprocess_malware_db_scanz-ImavEventHookExecutor.process_malware_db_scanjsd J O L O L  # M           rN) __name__ __module__ __qualname__rEVENTSr'rMalwareCleanupr> MalwareScanrDMalwareDatabaseScanrGr,rrr r =s VV_55_5 VK &''::(':& VK #$$  %$ & VK +,,   -,    rr r")__doc__%defence360agent.contracts.hook_eventsr"defence360agent.contracts.messagesr!defence360agent.contracts.pluginsrdefence360agent.hooks.executer+defence360agent.plugins.event_hook_executorrimav.malwarelib.configrimav.malwarelib.modelr MalwareScanningStartedMalwareScanningFinishedMalwareCleanupStartedr7rrKrr r,rrrZs*<;;;;;::::::877777IIIIII333333,,,,,,$ % # $ %  ;?5555(7 7 7 7 7 -7 7 7 7 7 r