o
    j$                     @   s:   d dl Z d dlmZmZ d dlmZmZ G dd dZdS )    N)IteratorList)CryptoAPIKeyFileCryptoAPIKeyPropertiesc                   @   sb   e Zd Zdd Zdee fddZeddee	j
B defd	d
Zeddee	j
B defddZdS )CryptoKeysFinderc                 C   s   g d| _ g | _d S )N)ServiceProfilesLocalServiceAppDataRoaming	MicrosoftCryptoKeys)startdirentriesself r   /root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pypykatz/dpapi/finders/cryptokeys.py__init__   s   

zCryptoKeysFinder.__init__returnc                 C   s
   t | jS )N)iterr   r   r   r   r   __iter__   s   
zCryptoKeysFinder.__iter__Twin_dirraise_errorc                 C   sr   t | trt|  } |  s|rt|  dt S | }t jD ]}|| }| s3t| dq"t	|S )N is not a directoryz does not exist)

isinstancestrpathlibPathabsoluteis_dir
ValueErrorr   r   from_dir)r   r   cryptokeys_dir	directoryr   r   r   from_windir   s   

zCryptoKeysFinder.from_windirr#   c                 C   st   t | trt|  } |  s|rt|  dt S t }|  D ]}| r*q#t	
| }|j| q#|S )Nr   )r   r   r   r   r   r    r!   r   iterdirr   
from_bytes
read_bytesr   append)r#   r   finderfilepathkeyr   r   r   r"       s   
zCryptoKeysFinder.from_dirN)T)__name__
__module____qualname__r   r   r   r   staticmethodr   r   r   boolr%   r"   r   r   r   r   r      s     r   )r   typingr   r   winacl.dtyp.wcee.cryptoapikeyr   r   r   r   r   r   r   <module>   s    