o
    j
                     @   s6   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 )
SspCredentialc                 C   s(   d| _ d | _d | _d | _d| _d | _d S )Nssp    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/alsadecryptor/packages/ssp/decryptor.py__init__   s   
zSspCredential.__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SspCredential.to_dictc                 C   s   t |  S )N)jsondumpsr   r   r   r   r   to_json   s   zSspCredential.to_jsonc                 C   sJ   d| j  }|d| j 7 }|d| j 7 }|d| j 7 }|d| j  7 }|S )Nz	== SSP [%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SspCredential.__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 )	SspDecryptorc                    s"   t  d||| || _g | _d S )NSsp)superr   decryptor_templatecredentials)r   readerr    lsa_decryptorsysinfo	__class__r   r   r   *   s   
zSspDecryptor.__init__c                    sL   |  d| jjI d H }| j|| jj I d H }| j|I d H }||fS )Nz
msv1_0.dll)find_signaturer    	signaturer"   get_ptr_with_offsetfirst_entry_offsetget_ptr)r   positionptr_entry_loc	ptr_entryr   r   r   find_first_entry/   s
   zSspDecryptor.find_first_entryc                    s  t  }|j|_|jj| jI d H |_|jj| jI d H |_	|jj
jdkrp|jddu s7|j	ddu rZ|jj
| jI d H }| j|ddd\|_|_|jd urY|j |_n|jj
| jI d H }| j|dd\|_|_|jdkr|j	dkr|jd u rd S | j| d S )Nr   $T   )bytes_expectedsegment_size)r3    )r   LogonIdr   r!   Domaineread_stringr"   r   UserNamer	   PasswordLengthendswithread_maxdatadecrypt_passwordr
   r   r   append)r   	ssp_entrycenc_datar   r   r   	add_entry5   s"    
zSspDecryptor.add_entryc              
      s   z|   I d H \}}W n ty& } z| d|  W Y d }~d S d }~ww | j|I d H  | jj| jI d H }| || j	I d H  d S )Nz"Failed to find structs! Reason: %s)
r/   	Exceptionlogr"   mover    
list_entryload	walk_listrB   )r   entry_ptr_valueentry_ptr_loce	entry_ptrr   r   r   startI   s   zSspDecryptor.start)r   r   r   r   r/   rB   rM   __classcell__r   r   r%   r   r   )   s
    r   )r   &pypykatz.alsadecryptor.package_commonsr   r   r   r   r   r   r   <module>   s   