o
    �õ±j´	  ã                   @   sR   d dl Z d dlZd dlZd dlmZmZ d dlmZ dd„ Ze	dkr'eƒ  dS dS )é    N)ÚCCACHEÚ
Credential)Úprint_tablec                  C   s„  dd l } | jdd�}|jdd�}d|_d|_|jdd	d�}|jd
dddd� |jdddd� |jddd�}|jddd�}|jdddd� |jddtdddd� |jddd� | ¡ }t	j
t	jd� t	 d|j ¡ t |j¡}|jdkr¡g }| d gt ¡  ¡ d}	|jD ]}
| t|	ƒg|
 ¡  ¡ |	d!7 }	q…tƒ  t|ƒ d S |jdkræ|jrÖt|jd"ƒ�}|j|jd#�D ]}| | ¡ d$ ¡ q·W d   ƒ n
1 sÍw   Y  d S d S |j|jd#�D ]}t|ƒ qÝd S |jdk�r@tj  !tj  "tj  #|j¡¡d%t$ %|j¡ ¡}|j&}tƒ }|j'|_'|j(|_(|j)|_)d}	|jD ]}
|	|v �r&|	d!7 }	�q|j |
¡ |	d!7 }	�qt	 *d&| ¡ | +|¡ d S d S )'Nr   zTool to manipulate CCACHE files)ÚdescriptionÚcommands)ÚhelpTÚcommandÚroastz,Lists all tickets in hashcat-friendly formatz-az	--allhashÚ
store_truez*Process all tickets, regardless of enctype)Úactionr   z-oz	--outfilezOutput hash file nameÚlistzList all tickets in the fileÚdelzpDelete ticket(s) from file, store the new ccache file in a specified filename, or an automatically generated onezOutput ccache file namez-iz--idÚappendzTicket ID to delete)Útyper   r   ÚrequiredÚ
ccachefilezinput CCACHE file)ÚlevelzOpening file %sÚidé   Úwb)Ú
all_hashess   
z%s.edited.ccachezWriting edited file to %s),ÚargparseÚArgumentParserÚadd_subparsersr   ÚdestÚ
add_parserÚadd_argumentÚintÚ
parse_argsÚloggingÚbasicConfigÚINFOÚdebugr   r   Ú	from_filer   r   r   Úsummary_headerÚcredentialsÚstrÚsummaryÚprintr   ÚoutfileÚopenÚ
get_hashesÚallhashÚwriteÚencodeÚosÚpathÚjoinÚdirnameÚabspathÚntpathÚbasenamer   Úfile_format_versionÚheadersÚprimary_principalÚinfoÚto_file)r   ÚparserÚ
subparsersÚroast_groupÚ
list_groupÚdelete_groupÚargsÚccÚtableÚiÚcredÚfÚhÚoutput_filenamer   Útemp_cc© rI   ú–/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/minikerberos/examples/ccache_editor.pyÚmain   sj   



ÿ$ÿ
ÿ,

ïrK   Ú__main__)
r/   r   r4   Úminikerberos.common.ccacher   r   Úminikerberos.common.utilsr   rK   Ú__name__rI   rI   rI   rJ   Ú<module>   s    ?
ÿ