o
    Žõ±j¶
  ã                   @   s>   d dl Z d dlZd dlmZ G dd„ dƒZG dd„ deƒZdS )é    N)ÚPackageDecryptorc                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚLiveSspCredentialc                 C   s(   d| _ d | _d | _d | _d| _d | _d S )NÚlivesspó    ©ÚcredtypeÚusernameÚ
domainnameÚpasswordÚpassword_rawÚluid©Úself© r   ú£/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pypykatz/lsadecryptor/packages/livessp/decryptor.pyÚ__init__   s   
zLiveSspCredential.__init__c                 C   sD   i }| j |d< | j|d< | j|d< | j|d< | j|d< | j|d< |S )Nr   r   r	   r
   r   r   r   ©r   Útr   r   r   Úto_dict   s   





zLiveSspCredential.to_dictc                 C   s   t  |  ¡ ¡S )N)ÚjsonÚdumpsr   r   r   r   r   Úto_json   s   zLiveSspCredential.to_jsonc                 C   sJ   d| j  }|d| j 7 }|d| j 7 }|d| j 7 }|d| j ¡  7 }|S )Nz	== LiveSsp [%x]==
z	username %s
z	domainname %s
z	password %s
z		password (hex)%s
)r   r   r	   r
   r   Úhexr   r   r   r   Ú__str__   s   
zLiveSspCredential.__str__N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   r   r   
   s
    	r   c                       s4   e Zd Z‡ fdd„Zdd„ Zdd„ Zdd„ Z‡  ZS )	ÚLiveSspDecryptorc                    s"   t ƒ  d|||¡ || _g | _d S )NÚLiveSsp)Úsuperr   Údecryptor_templateÚcredentials)r   Úreaderr    Úlsa_decryptorÚsysinfo©Ú	__class__r   r   r   (   s   
zLiveSspDecryptor.__init__c                 C   sˆ   |   d| jj¡}|  dt|ƒ ¡ |  dt|| jj ƒ ¡ | j || jj ¡}|  dt|ƒ ¡ | j |¡}|  dt|ƒ ¡ ||fS )Nz
msv1_0.dllzSignature @ %szSignature (corrected) @ %szFirst entry ptr @ %szFirst entry -> %s)	Úfind_signaturer    Ú	signatureÚlogr   Úfirst_entry_offsetr"   Úget_ptr_with_offsetÚget_ptr)r   ÚpositionÚptr_entry_locÚ	ptr_entryr   r   r   Úfind_first_entry-   s   z!LiveSspDecryptor.find_first_entryc                 C   s¾   t ƒ }|j|_|j | j¡}|jj | j¡|_	|jj
 | j¡|_|jjjdkrW|jj | j¡}|j	 d¡du rN| j|dd�\|_|_|jd urM|j ¡ |_n	|  |¡\|_|_| j |¡ d S )Nr   ú$T)Úbytes_expected)r   ÚLocallyUniqueIdentifierr   Ú	suppCredsÚreadr"   r!   ÚUserNameÚread_stringr   ÚDomainer	   ÚPasswordÚLengthÚread_maxdataÚendswithÚdecrypt_passwordr
   r   r   Úappend)r   Ú	ssp_entryÚcr4   Úenc_datar   r   r   Ú	add_entry7   s   
€zLiveSspDecryptor.add_entryc              
   C   sr   z|   ¡ \}}W n ty" } z|  d| ¡ W Y d }~d S d }~ww | j |¡ | j | j¡}|  || j¡ d S )Nz"Failed to find structs! Reason: %s)	r0   Ú	Exceptionr)   r"   Úmover    Ú
list_entryÚ	walk_listrB   )r   Úentry_ptr_valueÚentry_ptr_locÚeÚ	entry_ptrr   r   r   ÚstartJ   s   €þzLiveSspDecryptor.start)r   r   r   r   r0   rB   rK   Ú__classcell__r   r   r%   r   r   '   s
    
r   )Úior   Ú%pypykatz.lsadecryptor.package_commonsr   r   r   r   r   r   r   Ú<module>   s
   