HEX
Server: Apache/2.4.65 (Unix) OpenSSL/1.1.1k
System: Linux vps109042.inmotionhosting.com 4.18.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64
User: cisa (1010)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //opt/dedrads/__pycache__/cmspass.cpython-313.pyc
�

"��i��	��SrSSKrSSKrSSKrSSKJr SSKJr SSKrSSK	r	SSK
Jr SSKJ
r
Jr \R"S5r\R"S5rS	\	R$4S
jrS\R(S\S	\\S-\S-44S
jrS\	R$S\S\S\4SjrS	\4SjrS\S	\\4SjrS\4SjrSr\S:Xa\"5 gg)z�Scans a cPanel account for WordPress and Joomla! configuration files, then
uses whmapi1 to reset database passwords to match what was found in them.
This script logs to /var/log/messages�N)�ArgumentParser)�Path)�
SysLogHandler)�whmapi1�
CpAPIErrorz"DB_(USER|PASSWORD).*['\"](.+)['\"]z\b(user|password) = '(.+)'�returnc��[R"S5nUR[R5 [R"SS9n[R"SS9n[R
"[RS9nURU5 UR[R5 URU5 [SS9nURU5 UR[R5 URU5 U$)Nz
cmspass.pyz%(levelname)s: %(message)s)�fmtz&cmspass.py: %(levelname)s: %(message)s)�streamz/dev/log)�address)�logging�	getLogger�setLevel�DEBUG�	Formatter�
StreamHandler�sys�stdout�setFormatter�
addHandlerr�WARNING)�logger�out_fmt�log_fmtr�syslogs     �/opt/dedrads/cmspass.py�
setup_loggingrs���
�
�
�|�
,�F�
�O�O�G�M�M�"����$@�A�G����$L�M�G�
�
"�
"�#�*�*�
5�F�
���� �
�O�O�G�M�M�"�
���f��
�:�
.�F�
���� �
�O�O�G�O�O�$�
���f���M��regex�pathc�&�Sup#[USS9nUH_nURU5=n(dMUR5upxUR5S:XaUnMGUR5S:XdM]UnMa SSS5 X#4$!,(df   X#4$=f)zWill parse db conf variables�NN�utf-8��encoding�user�passwordN)�open�search�groups�lower)	rr �db_user�db_pass�file�line�match�key�vals	         r�
conf_parser3$s���!��G�	
�d�W�	%���D����T�*�*�u�*� �<�<�>����9�9�;�&�(�!�G��Y�Y�[�J�.�!�G��
&����
&�	%����s�B�<B�/B�
Br�cpuserr,r-c��UbUcg[SXUS.SS9 URSU5 g![anURSX$5 SnAgSnAff=f)z/Will pass the reset variables to the cPanel APIN�set_mysql_password)r4r&r'T)�args�checkzReset password for %sz#Failed to reset password for %s: %s)r�warningr�error)rr4r,r-�excs     r�set_passr<4s`����'�/��	9�� �"��I��	
�	���.��8���J����:�G�I�I��J�s�*�
A�A�Ac���[[S9nURSSSSS9 UR5Rn[
R"U5(d[R"US35 U$)z4Will parse input for user and ensure the user exists)�descriptionz-uz--userTzcPanel username)�required�helpz  does not exist or is restricted)	r�__doc__�add_argument�
parse_argsr&�rads�cpuser_safer�exit)�parserr&s  rrCrCDsb��
��
0�F�
����h��<M��N�����#�#�D����D�!�!����D�6�9�:�;��Kr�homedirc��SUSSSUS3SSSSS	S
SSSSS
S/n[R"U[RSSS9nURR	S5Vs/sHo3(dM[U5PM sn$s snf)zFind all config files�findz-not�(z-pathz/mailz-prune�)z-name�
wp-config.phpz-o�configuration.phpz-type�fz-print0r#F)rr%r8�)�
subprocess�run�PIPEr�splitr)rH�cmd�ret�xs    r�
find_filesrXNs���	����g�'��%�/@�(�C��W�o�t�W�6I�3���i��C��.�.��J�O�O�g�U��C�!�Z�Z�-�-�d�3�9�3��q�G�D��G�3�9�9��9s�
A:�(A:c��URS:wag[USS9nUHnSU;dM SSS5 g SSS5 g!,(df   g=f)NrNFr#r$z
class JConfigT)�namer()r �confr/s   r�conf_is_joomlar\]sQ���y�y�'�'��	
�d�W�	%���D��$�&��
&�	%��
&��	
&�	%��s�
?�?�?�
A
c��[5n[5n[R"U5n[W5H�nSupVURS:Xa%URSU5 [[U5upVO4[U5(a$URSU5 [[U5upVU(dMyU(dM�[XXV5 M� g![Ra n[
R"U5 SnAN�SnAff=f)Nr"rMzScanning %s)rCrrD�get_homedir�CpuserErrorrrFrXrZ�debugr3�WP_CONFr\�JM_CONFr<)r&rrHr;r r,r-s       r�mainrcgs����<�D�
�_�F���"�"�4�(���7�#��%����9�9��'��L�L���-�)�'�4�8��G�W�
�D�
!�
!��L�L���-�)�'�4�8��G��7�w�w��V�7�4�$����������
�
���s�C
�
C>�C9�9C>�__main__)rArQ�rer�argparser�pathlibrrDr
�logging.handlersr�cpapisrr�compilerarb�Loggerr�Pattern�tuple�strr3r<rC�listrXr\rc�__name__�rr�<module>rrs���)��	�
�#����*�&�
�*�*�:�
;��
�*�*�2�
3��
�w�~�~�
� 
�b�j�j�
��
��s�T�z�3��:�7M�1N�
� 
9�W�^�^�
9�S�
9�3�
9��
9� �C��:��:��T�
�:����5�&�z���F�r