o
    àý°j  ã                
   @   sÈ  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
mZ edk�râee
jƒ e jddd	�Zejd
ddd� ejdddd� ejddddd� ejdddd� ejdddd� ejdddd� ejddddd� ejd e  d!¡d"d#� ejd$dd%d&d� ejd'dd%d(d� e d)¡Zejd*dd+d,d-� ejd.dd/d� ejd0dd1d� ejd2dd3d4d-� e d5¡Zejd6dd7d8d-� ejd9dd7d:d-� ejd;dd<d=d� eejƒd>kråe ¡  e d>¡ e ¡ Ze ejej¡ eejƒ\ZZ Z!Z"edu �rd%Ze!d%k�r'e d%k�r'ej#du �r'ej$du �r'ej%du �r'd d?l&m&Z& e&d@ƒZ!ej'du �r0e"e_'ej%du�r9de_(ej)ej'e*ej+ƒe"ej,ej-dA�Z.e. /¡  z*ej(du �ree.j0ej1e e!eej#ej%ej2dB�Z3ne. 4ej1e e!eej#ej5¡Z3e. 6¡  W n# e7�yš Z8 zejdCddD� e 9e:e8ƒ¡ dZ3W Y dZ8[8ndZ8[8ww e3du �rÜee.ej;ƒZ<ej=�rÁej= >¡ D ]Z?edEe? dFdG� e< @e?¡ �q¯nejA�rØejAD ]ZBedEeB ƒ e< @eB¡ �qÈne< C¡  e. D¡  dS dS )Hé    N)Úlogger)ÚSQLSHELL)Úparse_target)ÚversionÚtdsÚ__main__Tz*TDS client implementation (SSL supported).)Úadd_helpÚdescriptionÚtargetÚstorez6[[domain/]username[:password]@]<targetName or address>)ÚactionÚhelpz-dbz&MSSQL database instance (default None)z-windows-authÚ
store_trueFz<whether or not to use Windows Authentication (default False))r   Údefaultr   z-debugzTurn DEBUG output ONz-tsz&Adds timestamp to every logging outputz-showzshow the queriesz-commandÚextendÚ*zFCommands to execute in the SQL shell. Multiple commands can be passed.)r   Únargsr   z-fileÚrz4input file with commands to execute in the SQL shell)Útyper   z--host-nameÚ z;HostName property to use when connecting to the MSSQLServerz
--app-namez:AppName property to use when connecting to the MSSQLServerÚ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 addresszoIP Address of the domain controller. If ommited it 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Ú1433z target MSSQL port (default 1433)é   )Úgetpassz	Password:)Úworkstation_idÚapplication_name)ÚkdcHostz
Exception:)Úexc_infozSQL> %sú )Úend)EÚargparseÚsysÚloggingÚimpacket.examplesr   Úimpacket.examples.mssqlshellr   Úimpacket.examples.utilsr   Úimpacketr   r   Ú__name__ÚprintÚBANNERÚArgumentParserÚparserÚadd_argumentÚFileTypeÚadd_argument_groupÚgroupÚlenÚargvÚ
print_helpÚexitÚ
parse_argsÚoptionsÚinitÚtsÚdebugr
   ÚdomainÚusernameÚpasswordÚ
remoteNameÚhashesÚno_passÚaesKeyr   Ú	target_ipÚkÚMSSQLÚintÚportÚ	host_nameÚapp_nameÚms_sqlÚconnectÚkerberosLoginÚdbÚdc_ipÚresÚloginÚwindows_authÚprintRepliesÚ	ExceptionÚeÚerrorÚstrÚshowÚshellÚfileÚ	readlinesÚlineÚonecmdÚcommandÚcÚcmdloopÚ
disconnect© r`   r`   ú‹/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/../../../bin/mssqlclient.pyÚ<module>   s˜   




ÿ

8 ÿ€ý
þ
þª