h= dZddlZddlZddlZddlmZddlZddlmZddl m Z ddl m Z ddl mZddlmZmZdd lmZdd lmZejeZGd d eZdS) 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 N)Path) ExitStack)utils)Core) MessageType) MessageSinkexpect)Scope)malware_responsecXeZdZejZdZdZee j dZ dS)ServerPullFileSenderNcK||_dS)N)loop)selfrs M/opt/imunify360/venv/lib/python3.11/site-packages/imav/plugins/server_pull.py create_sinkz ServerPullFileSender.create_sink+s c nK|d}|dD]} t5}tj|r|t jtj}| tj dd|gd{V| dtj|j|}t!jt%|j}t*d|j|tj||d{Vdddn #1swxYwYc#t0$r2}t*t5|Yd}~d}~wwxYwdS) Nreasonfiles)dirlsz-alrz)Uploading temporary file %s with hash: %s) upload_reason)rospathisdir enter_contexttempfileNamedTemporaryFilerTMPDIRwriter check_runseekr MalwareHitPathnamehashlibsha256r read_bytes hexdigestloggerinfo upload_file Exceptionwarningstr)rmessagerfilestacktfhash_es r upload_filesz!ServerPullFileSender.upload_files.s"G$ ' 'D '[[Ew}}T**"00$7DKHHHueT7J'K'K!K!K!K!K!K!KLLL />rwMM ' MM4466!!#)++ GG! +6F#( ' ' 's1vv&&&&&&&& '- ' 's;E6D8E) E6)E- -E60E- 1E66 F2'F--F2) __name__ __module__ __qualname__r IM360SCOPErrr rMalwareSendFilesr6rrr r 'sX KE D VK ())''*)'''rr )__doc__r&loggingrpathlibrr contextlibrdefence360agentr defence360agent.contracts.configr"defence360agent.contracts.messagesr!defence360agent.contracts.pluginsrr defence360agent.utilsr imav.malwarelib.utilsr getLoggerr7r*r r=rrrIs*  !!!!!!111111::::::AAAAAAAA''''''222222  8 $ $!'!'!'!'!';!'!'!'!'!'r