df .dZdgZdZdZdZddlZddlmZmZm Z m Z m Z m Z m Z ddlmZmZmZmZmZdd lmZdd lmZGd d e ZGd de ZGdde Ze eeeeeeeeeZGdde ZdZdZdZdZdZeedZ eedZ!e j"Z"ee"_#eege"_$e%e!dre!j&Z&ee&_#eege&_$e!j'Z'ee'_#eeeeeege'_$e!j(Z(ee(_#eege(_$e!j)Z)ee)_#eege)_$e!j*Z*ee*_#eege*_$GddZ+dZ,e-dkr|ddl.Z.ddl/Z/dZ0e+Z+e0de/j1Z2e+,e2e/j/e3d4e+j5e+j6dSdS) z PAM module for python Provides an authenticate function that will allow the caller to authenticate a user against the Pluggable Authentication Modules (PAM) on the system. Implemented using ctypes, so no compilation is necessary. pamz1.8.4z David Ford z 2018 June 15N)CDLLPOINTER Structure CFUNCTYPEcastbyrefsizeof)c_void_pc_size_tc_char_pc_charc_int)memmove) find_libraryc"eZdZdZdefgZdZdS) PamHandlez&wrapper class for pam_handle_t pointerhandlec<tj|d|_dS)Nr)r__init__rselfs c/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pam.pyrzPamHandle.__init__'s4    N)__name__ __module__ __qualname____doc__r _fields_rrrrr#s600H%'Hrrc(eZdZdZdefdefgZdZdS) PamMessagez'wrapper class for pam_message structure msg_stylemsgc$d|j|jfzS)Nz)r#r$rs r__repr__zPamMessage.__repr__/s%(BBBrN)rrrrrr rr&r rrr"r"+sB11u%x'8:HCCCCCrr"c(eZdZdZdefdefgZdZdS) PamResponsez(wrapper class for pam_response structureresp resp_retcodec$d|j|jfzS)Nz)r*r)rs rr&zPamResponse.__repr__6s&$*;TY)GGGrN)rrrrr rrr&r rrr(r(2sB22(#ne%<>HHHHHHrr(c"eZdZdZdefdefgZdS)PamConvz$wrapper class for pam_conv structureconv appdata_ptrN)rrrr conv_funcr rr rrr-r-;s(..)$}h&?AHHHrr-cpam_endc$eZdZdZdZdZddZdS) rrNcdSNr rs rrz pam.__init__gs rloginutf-8Tc t fd}tjdkrt|tr||}ttr|t|tr||}n~t|t r||}tt r|t|t r||}d|vsdvsd|vrd|_d|_dSt t}t|d}t||t|t|} | dkr| |_d|_dSt|d} | dk} | r|rt|t } | |_t#|| |_tjdkr|j||_t't(d rt+|| | S) ausername and password authentication for the given service. Returns True for success, or False for failure. self.code (integer) and self.reason (string) are always stored and may be referenced for the reason why authentication failed. 0/'Success' will be stored for success. Python3 expects bytes() for ctypes inputs. This function will make necessary conversions using the supplied encoding. Inputs: username: username to authenticate password: password in plain text service: PAM service to authenticate against, defaults to 'login' Returns: success: True failure: False ct|tt}t|t t}||d<t |D]}||jjtkrjtt dztt}t|t |||_ d||_ dS)zxSimple conversation function that responds to any prompt where the echo is off with the supplied passwordrr1)callocr r(rrrangecontentsr#PAM_PROMPT_ECHO_OFFlenrrr)r*) n_messagesmessages p_responseapp_dataaddrresponseidst cpasswordpasswords rmy_convz!pam.authenticate..my_convs *f[&9&9::DD'+"6"677H$JqM:&& 1 1A;'15HHH Xq&..AACCCMM:::'*HQK$/0HQK,1rr3r4zstrings may not contain NULFrzpam_start() failedr7)r0sys version_info isinstancestrencodeunicodecodereasonr rr- pam_startr pam_authenticate pam_setcredPAM_REINITIALIZE_CRED pam_strerrordecodehasattrlibpamr7) rusernamerMserviceencoding resetcredsrNrr.retval auth_successrLs ` @r authenticatezpam.authenticatejs<,          t # #(C(( NX__X5N5N((C(( NX__X5N5N('3'' MW^^H5M5M'(G,, 5#??844(G,, 5#??844'7++ 4">>(33 h  'X"5"5G9K9KDI7DK5X&& !$$7HeDkk5==II Q;; DI.DK5!&!,,{  AJ A )>??F "6622  t # #+,,X66DK 69 % % $ FF # # #r)r;r<T)rrrrWrXrrgr rrrrcsG D F   UUUUUUrc4tj|i|S)zB Compatibility function for older versions of python-pam. )rrg)vargsdargss rrgrgs  355 u . . ..r__main__cfd}tj|tjdkrt |}nt |}tj|S)NcVtjtjdSr:)readline insert_text redisplay)textsrhookz input_with_prefill..hooks)   & & &   rrO)rnset_pre_input_hookrQrRinput raw_input)promptrqrrresults ` rinput_with_prefillrxsk ! ! ! ! ! #D)))  t # #6]]FFv&&F#%%% rz Username: z{} {})7r__all__ __version__ __author__ __released__rQctypesrrrrrr r r r r rrr ctypes.utilrrr"r(r0r-rBPAM_PROMPT_ECHO_ON PAM_ERROR_MSG PAM_TEXT_INFOr\libcr`r?restypeargtypesr_r7rYr[r]rZrrgrrngetpassrxgetuserraprintformatrWrXr rrrsw 1  KKKKKKKKKKKKKKKKKK>>>>>>>>>>>>>>$$$$$$ CCCCCCCCHHHHH)HHH IeUGGGGJ,?,?$@$@''''R]J^J^B_B_ai j j BBBBBiBBB    Dc!2!233 De!4!455 K$%x0 7693 &G %GO!*E 2G", ! %x1A1A779CUCUV ". ! &. "/ $ &. "3!&.\\\\\\\\~/// z    #%%C!!,0A0ABBHXw00111 E'..3: . .//////r