hdZddlZddlZddlZddlZddlmZmZmZm Z m Z m Z ddl m Z ejeZGdde ZdZdZd Zd Ze ed d ZdZdZdZdZdZdS)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)atomic_rewriteis_systemd_bootcheck_exit_code check_runretry_onrun)KWConfigceZdZdZdZdZdS)PureFTPBaseConfigz^\s*?{}\s+(.*?)\s*?$z{} {}z/etc/pure-ftpd.confN)__name__ __module__ __qualname__SEARCH_PATTERN WRITE_PATTERNDEFAULT_FILENAMEU/opt/imunify360/venv/lib/python3.11/site-packages/imav/malwarelib/subsys/pure_ftpd.pyr r )s ,NM,rr cKtsMtddgtjtjtjd{Vt ddddSt gdd{Vt gd d{VdS) Nstartimunify360-purestdinstdoutstderr"/etc/init/imunify360-pure.overrideFbackup) systemctlenabler)r rrrr subprocessDEVNULLrrrrruploadscript_enabler%/s    C ' ($%%           ;RNNNNNNBBBCCCCCCCCCAAABBBBBBBBBBBrcKtsMtddgtjtjtjd{Vt ddddSt gdd{Vt gd d{VdS) Nstoprrrzstart on manual Fr)r r'r)r disablerr"rrruploadscript_disabler)>s   E & '$%%            0       @@@AAAAAAAAACCCDDDDDDDDDDDrcKts1tddgd{V\}}}d|vStgdd{V\}}}|dkS)Nstatusrz start/running)r r+rr)rrdecode)_outrcs ruploadscript_statusr0Qs   x):;<<<<<<<< 3#**,,..GGGHHHHHHHHAqQwrc<Ktstddgd{VdS tgdd{VdS#t$rM}|jr:|jddkr)t dt|nYd}~dSd}~wwxYw)Nz/etc/init.d/pure-ftpdrestart)r r2z pure-ftpdrz-%s Service pure-ftpd is probably deactivated.)rrr Exceptionargsloggerwarningrepr)errs rr2r2[s    6 BCCCCCCCCCCC AAABB B B B B B B B B B   x CHQK1,,Dd3ii  sA BABB ) max_triescngd}tjddg} t|jddkr;t fd|Dr djdSn9#t $rYn.t$r!}t d |d}~wwxYwdS) N)z7/opt/alt/python35/share/imunify360/scripts/pure_scan.shz=/opt/alt/python35/share/imunify360/scripts/pureftpd-on-uploadz0/usr/share/imunify360/scripts/pureftpd-on-uploadexecmdline)attrsTz/usr/sbin/pure-uploadscriptc3PK|] }jdo|jdvV!dS)r>N)info).0scriptprocs r z*thirdparty_uploadscript..|sWII )$Kty7K)KIIIIIIr z&File not found during process iter: %s) psutil process_iternextrAalljoin StopIterationFileNotFoundErrorr6r7)imunify_scriptsiterDs @rthirdparty_uploadscriptrQksO  E9#5 6 6 6B 6 688Dy#@@@SIIII-IIIFF@xx ) 4555    E     NNCQ G G G   6 4sA;; B1 B1B,,B1c~tjdotjdtjS)Nz/usr/sbin/pure-ftpd)ospathisfileaccessX_OKrrrdetectrXs3 7>>/ 0 0 RYrw66rctg}|r!|j||j|S)N)r is_installedpure_ftp_conf_clsappend) hosting_panelconfigss rget_pureftpd_configsr_sA !G""$$8  + 7}6777 NrcKt|}|D]S} |dd"#t$r%}td|Yd}~Ld}~wwxYwt d{VdS)NCallUploadScriptyes'Error when accessing pureftp config: %s)r_setOSErrorr6r7r2r]r^clsrPs renable_scan_in_configrhs"=11GII I C" # # ' ' . . . . I I I NNDa H H H H H H H H I ))OOOOOOOOOs6 A%A  A%c t|}|D]q} |d}||dkrdS>#t$r'}td|Yd}~dSd}~wwxYwdS)NranoFrcT)r_getstriprer6r7)r]r^rgvaluerPs rscan_in_config_enabledrns"=11G C*++//11E}  5 5uu!6    NNDa H H H555555  4s7A BA<<Bc@Ktyt|}|D]S} |dd"#t$r%}td|Yd}~Ld}~wwxYwt d{Vtd{VdS)Nrarjrc)rQr_rdrer6r7r2r)rfs rdisable_purescanrps  (&}55 M MC M&''++D1111 M M MH!LLLLLLLL Mii           sA A3A..A3)__doc__loggingrSr#rGdefence360agent.utilsrrrrrrdefence360agent.utils.kwconfigr getLoggerr r6r r%r)r0r2rMrQrXr_rhrnrprrrrvs*  433333  8 $ $-------- C C CEEE&      r***+*0     ! ! ! ! !r