U vfQ@sdZddlZddlZddlZddlZddlmZddlm Z ddl Z ddl m Z dZdZd Zd d Zd d ZeddkrejZnejZGdddejZddZGdddZdS)zP Functions for communicating with Pageant, the basic windows ssh agent program. N) zero_byte)b)_winapilPi JcCstjjddS)NsPageant)ctypeswindlluser32Z FindWindowAr r E/opt/alt/python38/lib/python3.8/site-packages/paramiko/win_pageant.py_get_pageant_window_object+sr cCs ttS)z Check to see if there is a "Pageant" agent we can talk to. This checks both if we have the required libraries (win32all or ctypes) and if there is a Pageant currently running. )boolr r r r r can_talk_to_agent/sr64bitc@s,eZdZdZdefdejjfdejfgZ dS)COPYDATASTRUCTzy ctypes implementation of http://msdn.microsoft.com/en-us/library/windows/desktop/ms649010%28v=vs.85%29.aspx Znum_data data_sizeZdata_locN) __name__ __module__ __qualname____doc__ ULONG_PTRrZwintypesZDWORDZc_void_pZ_fields_r r r r r?s  rc Cst}|sdSdtd}t|tt}|||tdt |t }| \}}t t ||}tjj|tt|t|}|dkr|d|d} td| d} | || W5QRSW5QRdSQRXdS)za Communication with the Pageant process is done through a shared memory-mapped file. NZPageantRequest08xrrz>I)r thread get_identrZ MemoryMap_AGENT_MAX_MSGLENZ get_security_attributes_for_userwritearrayrr buffer_infor_AGENT_COPYDATA_IDrrr Z SendMessageAwin32con_WM_COPYDATAZsizeofZbyrefseekreadstructunpack) msgZhwndZmap_nameZpymapZ char_bufferZchar_buffer_addressZchar_buffer_sizeZcdsresponseZdatalenZretlenr r r _query_pageantLs<    r'c@s0eZdZdZddZddZddZdd Zd S) PageantConnectiona Mock "connection" to an agent which roughly approximates the behavior of a unix local-domain socket (as used by Agent). Requests are sent to the pageant daemon via special Windows magick, and responses are buffered back for subsequent reads. cCs d|_dSN _responseselfr r r __init__zszPageantConnection.__init__cCst||_dSr))r'r+)r-datar r r send}szPageantConnection.sendcCs@|jdkrdS|jd|}|j|d|_|jdkrs&     &