o
    j                     @   s   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lm	Z	 d dl
mZ ddeded	ed
edef
ddZdd ZedkrCe  dS dS )    N)KerberosClientFactorykerberos_url_help_epilog)KerberosSPN)AIOKerberosClient)KirbiFkerberos_urlspn	kirbifile
ccachefilecross_domainc                    s   t |trt|}t| }| }td |	 I d H  |du r:td |
|jI d H \}}}}| }td ||I d H \}	}
}|d urZ|j| td|  t|	|
}tt| |d uro|| td d S )NzGetting TGTTz"Getting TGS for otherdomain krbtgtzGetting TGSzTGT stored in ccache file %szDone!)
isinstancestrr   from_spnr   from_url
get_clientloggingdebugget_TGTget_referral_ticketdomainget_TGSccacheto_fileprintr   from_ticketdatainfo)r   r   r	   r
   r   cuclient_new_factorytgsencpartkeykirbi r$   /root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/minikerberos/examples/getTGS.pygetTGS	   s*   






r&   c                  C   s   dd l } | jd| jtd}|jddddd |jdd	d
 |jddd
 |jdddd |jddd
 |jddd
 | }|jdkrKtjtj	d n|jdkrXtjtj
d ntjdd tt|j|j|j|j|j d S )Nr   zQPolls the kerberos service for a TGS for the sepcified user and specified service)descriptionformatter_classepilogz-vz	--verbosecount)actiondefaultz--ccachezQCCACHE file to store the TGT ticket in, otherwise kirbi will be printed to stdout)helpz--kirbizPkirbi file to store the TGT ticket in, otherwise kirbi will be printed to stdoutz--cross-domain
store_truezSPN is in another domain.)r+   r-   r   zthe kerberos target string. r   zLthe SPN to request the TGS for. Must be in the format of service/host@domain)level   )argparseArgumentParserRawDescriptionHelpFormatterr   add_argument
parse_argsverboser   basicConfigINFODEBUGasynciorunr&   r   r   r#   r   r   )r1   parserargsr$   r$   r%   main"   s   

$r>   __main__)NNF)osr   r:   minikerberos.common.factoryr   r   minikerberos.common.spnr   minikerberos.aioclientr   minikerberos.common.kirbir   r   boolr&   r>   __name__r$   r$   r$   r%   <module>   s     
