3 L] @sdZddlZddlZddlZddlZddlmZddlm Z y ddl Z Wne k rdddl Z YnXddl mZdZdZd Zd d Zd d ZejddkrejZnejZGdddejZddZGdddeZdS)zP Functions for communicating with Pageant, the basic windows ssh agent program. N) zero_byte)b)_winapilPi JcCstjjjddS)NsPageant)ctypeswindlluser32Z FindWindowAr r :/tmp/pip-install-wfra5znf/paramiko/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_agent2sr64bitc@s,eZdZdZdefdejjfdejfgZ dS)COPYDATASTRUCTzy ctypes implementation of http://msdn.microsoft.com/en-us/library/windows/desktop/ms649010%28v=vs.85%29.aspx Znum_dataZ data_sizeZdata_locN) __name__ __module__ __qualname____doc__ ULONG_PTRrZwintypesZDWORDc_void_p_fields_r r r r rBs rc Cst}|sdSdtj}tj|ttj}||j|tjdt |t }|j \}}t t ||}tjjj|ttj|tj|}|dkr|jd|jd} tjd| d} | |j| SdSQRXdS)za Communication with the Pageant process is done through a shared memory-mapped file. NzPageantRequest%08xrrz>I)r thread get_identrZ MemoryMap_AGENT_MAX_MSGLENZ get_security_attributes_for_userwritearrayrr buffer_infor_AGENT_COPYDATA_IDrrr Z SendMessageAwin32con_WM_COPYDATAsizeofbyrefseekreadstructunpack) msgZhwndZmap_nameZpymapZ char_bufferZchar_buffer_addressZchar_buffer_sizeZcdsresponseZdatalenZretlenr r r _query_pageantOs(      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|_dS)N) _response)selfr r r __init__}szPageantConnection.__init__cCst||_dS)N)r)r+)r,datar r r sendszPageantConnection.sendcCs@|jdkrdS|jd|}|j|d|_|jdkrs,      &