o
    j                     @   s   d dl mZ d dl mZ d dlZd dlZd dlZd dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d	d
 ZedkrCe  dS dS )    )division)print_functionN)logger)parse_target)MiniImpacketShell)version)SMBConnectionc               
   C   sP  t tj tjddd} | jdddd | jdtd	d
d | jdddd | jdddd | jdddd | d}|jddddd |jdddd |jdddd |jddddd | d}|jd dd!d"d |jd#dd!d$d |jd%d&d'gd(d'd)d*d+ tt	j
d,kr|   t	d, |  }t|j|j t|j\}}}}|jd u r||_|d u rd-}|d-kr|d-kr|jd u r|jd.u r|jd u rd/d0lm} |d1}|jd urd|_|jd ur|jd2\}}	nd-}d-}	zt||jt|jd3}
|jdu r|
|||||	|j|j n	|
 |||||	 t!|
d |j"}|j"d ur>t#|j"d4}|$d5|j d6 d7 d6  |%  |j&d urut'(d8|j&j)  |j&* D ]}|d/ d9krjt d:| d;d< |+| qRt |d;d< qRW d S |,  W d S  t-y } zt'. j/t'j0krd/d l1}|2  t'3t4| W Y d }~d S d }~ww )=NTzSMB client implementation.)add_helpdescriptiontargetstorez6[[domain/]username[:password]@]<targetName or address>)actionhelpz
-inputfilerz5input file with commands to execute in the mini shell)typer   z-outputfilez'Output file to log smbclient actions inz-debug
store_truezTurn DEBUG output ONz-tsz&Adds timestamp to every logging outputauthenticationz-hasheszLMHASH:NTHASHz$NTLM hashes, format is LMHASH:NTHASH)r   metavarr   z-no-passz&don't ask for password (useful for -k)z-kzUse Kerberos authentication. Grabs credentials from ccache file (KRB5CCNAME) based on target parameters. If valid credentials cannot be found, it will use the ones specified in the command linez-aesKeyzhex keyz<AES key to use for Kerberos Authentication (128 or 256 bits)
connectionz-dc-ipz
ip addressztIP Address of the domain controller. If omitted it will use the domain part (FQDN) specified in the target parameterz
-target-ipzIP Address of the target machine. If omitted it will use whatever was specified as target. This is useful when target is the NetBIOS name and you cannot resolve itz-port139445?zdestination portz)Destination port to connect to SMB Server)choicesnargsdefaultr   r       Fr   )getpassz	Password::)	sess_portaz====================

z====================zExecuting commands from %s#z# %s )end)5printr   BANNERargparseArgumentParseradd_argumentFileTypeadd_argument_grouplensysargv
print_helpexit
parse_argsr   inittsdebugr   r   	target_iphashesno_passaesKeyr   ksplitr   intportkerberosLogindc_iploginr   
outputfileopenwriteclose	inputfilelogginginfoname	readlinesonecmdcmdloop	Exception	getLoggerlevelDEBUG	traceback	print_excerrorstr)parsergroupoptionsdomainusernamepasswordaddressr   lmhashnthash	smbClientshellflineerO    ra   /root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/../../../bin/smbclient.pymain!   s   






.

rc   __main__)
__future__r   r   r-   rE   r'   impacket.examplesr   impacket.examples.utilsr   impacket.examples.smbclientr   impacketr   impacket.smbconnectionr   rc   __name__ra   ra   ra   rb   <module>   s   \
