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 rµd-}|d-krÖ|d-krÖ|jd u rÖ|jd.u rÖ|jd u rÖd/d0lm} |d1ƒ}|jd urÞd|_|jd urì|j d2¡\}}	nd-}d-}	z‹t||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�r•d/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-kzÁUse 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-ipz£IP 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   \
ÿ