diff --git a/examples/DumpNTLMInfo.py b/examples/DumpNTLMInfo.py index 0d8edce36..73633164c 100644 --- a/examples/DumpNTLMInfo.py +++ b/examples/DumpNTLMInfo.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -37,6 +38,7 @@ import os import sys import argparse +import argcomplete import logging import struct import socket @@ -644,6 +646,8 @@ def __convert_size(self, size_bytes): parser.add_argument('-protocol', choices=['SMB', 'RPC'], nargs='?', metavar="protocol", help='Protocol to use (SMB or RPC). Default is SMB, port 135 uses RPC normally.') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv) == 1: parser.print_help() sys.exit(1) diff --git a/examples/Get-GPPPassword.py b/examples/Get-GPPPassword.py index 23f3653d0..5ced02e3d 100755 --- a/examples/Get-GPPPassword.py +++ b/examples/Get-GPPPassword.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -20,6 +21,7 @@ # import argparse +import argcomplete import base64 import xml import charset_normalizer @@ -227,6 +229,8 @@ def parse_args(): group.add_argument("-target-ip", action="store", metavar="ip address", help="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 it") group.add_argument("-port", choices=["139", "445"], nargs="?", default="445", metavar="destination port", help="Destination port to connect to SMB Server") + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv) == 1: parser.print_help() sys.exit(1) diff --git a/examples/GetADComputers.py b/examples/GetADComputers.py index c1f96be55..0db79a550 100644 --- a/examples/GetADComputers.py +++ b/examples/GetADComputers.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -30,6 +31,7 @@ from __future__ import print_function from __future__ import unicode_literals import argparse +import argcomplete import logging import sys import dns.resolver @@ -209,8 +211,7 @@ def run(self): 'If ommited, the domain part (FQDN) ' 'specified in the account parameter will be used') - - + argcomplete.autocomplete(parser, always_complete_options=False) if len(sys.argv)==1: parser.print_help() diff --git a/examples/GetADUsers.py b/examples/GetADUsers.py index 22dde4833..a5ee0172c 100755 --- a/examples/GetADUsers.py +++ b/examples/GetADUsers.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -28,6 +29,7 @@ from __future__ import print_function from __future__ import unicode_literals import argparse +import argcomplete import logging import sys from datetime import datetime @@ -173,6 +175,8 @@ def run(self): 'If ommited, the domain part (FQDN) ' 'specified in the account parameter will be used') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/GetLAPSPassword.py b/examples/GetLAPSPassword.py index be5d4d9af..94dd91d49 100755 --- a/examples/GetLAPSPassword.py +++ b/examples/GetLAPSPassword.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -37,6 +38,7 @@ from pyasn1.codec.der import decoder from pyasn1_modules import rfc5652 import argparse +import argcomplete import json import logging import sys @@ -277,6 +279,8 @@ def run(self): 'Required when querying a Windows Server 2025' 'domain controller with LDAPS enforced.') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/GetNPUsers.py b/examples/GetNPUsers.py index 0f9c92aa1..27bfd2330 100755 --- a/examples/GetNPUsers.py +++ b/examples/GetNPUsers.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -29,6 +30,7 @@ from __future__ import division from __future__ import print_function import argparse +import argcomplete import datetime import logging import random @@ -369,6 +371,8 @@ def request_multiple_TGTs(self, usernames): 'If ommited, the domain part (FQDN) ' 'specified in the account parameter will be used') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() print("\nThere are a few modes for using this script") @@ -383,6 +387,7 @@ def request_multiple_TGTs(self, usernames): print("\n3. Request TGTs for all users") print("\n\tGetNPUsers.py contoso.com/emily:password -request or GetNPUsers.py contoso.com/emily") print("\n4. Request TGTs for users in a file") + print("\n\tGetNPUsers.py -no-pass -usersfile users.txt contoso.com/") print("\nFor this operation you don\'t need credentials.") sys.exit(1) diff --git a/examples/GetUserSPNs.py b/examples/GetUserSPNs.py index 56a37d4e7..bf589241f 100755 --- a/examples/GetUserSPNs.py +++ b/examples/GetUserSPNs.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -33,6 +34,7 @@ from __future__ import division from __future__ import print_function import argparse +import argcomplete import logging import sys from datetime import datetime @@ -497,6 +499,8 @@ def request_multiple_TGSs(self, usernames): 'If ommited, the domain part (FQDN) ' 'specified in the account parameter will be used') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv) == 1: parser.print_help() sys.exit(1) diff --git a/examples/addcomputer.py b/examples/addcomputer.py index 6a7a7db86..e36651351 100755 --- a/examples/addcomputer.py +++ b/examples/addcomputer.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -39,6 +40,7 @@ import ldap3 import argparse +import argcomplete import logging import sys import string @@ -416,6 +418,7 @@ def run(self): 'Useful if you can\'t translate the FQDN.' 'specified in the account parameter will be used') + argcomplete.autocomplete(parser, always_complete_options=False) if len(sys.argv)==1: parser.print_help() diff --git a/examples/atexec.py b/examples/atexec.py index c55618d4d..ace5b8fd9 100755 --- a/examples/atexec.py +++ b/examples/atexec.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -26,6 +27,7 @@ import string import sys import argparse +import argcomplete import time import random import logging @@ -271,6 +273,8 @@ def cmd_split(cmdline): 'If omitted it will use the domain part (FQDN) specified in the target parameter') group.add_argument('-keytab', action="store", help='Read keys for SPN from keytab file') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/attrib.py b/examples/attrib.py index 7a545dc9c..aee60937d 100644 --- a/examples/attrib.py +++ b/examples/attrib.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -21,6 +22,7 @@ from __future__ import annotations import sys import argparse +import argcomplete import logging import ntpath from dataclasses import dataclass @@ -246,6 +248,8 @@ def main(): set_parser.add_argument('-p', '--pinned', dest='pinned', action='store_true', help="This attribute indicates user intent that the file or directory should be kept fully present locally even when not being actively accessed. This attribute is for use with hierarchical storage management software.") set_parser.add_argument('-u', '--unpinned', dest='unpinned', action='store_true', help="This attribute indicates that the file or directory should not be kept fully present locally except when being actively accessed. This attribute is for use with hierarchical storage management software.") + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/badsuccessor.py b/examples/badsuccessor.py index 7feff0190..d83723fbb 100644 --- a/examples/badsuccessor.py +++ b/examples/badsuccessor.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -22,6 +23,7 @@ from __future__ import unicode_literals import argparse +import argcomplete import logging import random import string @@ -698,6 +700,8 @@ def modify_dmsa(self, ldapConnection): group.add_argument('-dc-host', action='store',metavar = "hostname", help='Hostname of the domain controller to use. If ommited, the domain part (FQDN) specified in the account parameter will be used') group.add_argument('-dc-ip', action='store',metavar = "ip", help='IP of the domain controller to use. Useful if you can\'t translate the FQDN.') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/changepasswd.py b/examples/changepasswd.py index 1c3c78397..ecda39c89 100755 --- a/examples/changepasswd.py +++ b/examples/changepasswd.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -119,6 +120,7 @@ # import argparse +import argcomplete import logging import sys @@ -819,6 +821,8 @@ def parse_args(): ), ) + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv) == 1: parser.print_help() sys.exit(1) diff --git a/examples/dacledit.py b/examples/dacledit.py index f5c729bda..542c4b2df 100755 --- a/examples/dacledit.py +++ b/examples/dacledit.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -19,6 +20,7 @@ # import argparse +import argcomplete import binascii import codecs import json @@ -747,6 +749,8 @@ def parse_args(): dacl_parser.add_argument('-inheritance', action="store_true", help='Enable the inheritance in the ACE flag with CONTAINER_INHERIT_ACE and OBJECT_INHERIT_ACE. Useful when target is a Container or an OU, ' 'ACE will be inherited by objects within the container/OU (except objects with adminCount=1)') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv) == 1: parser.print_help() sys.exit(1) diff --git a/examples/dcomexec.py b/examples/dcomexec.py index d16f8bc75..f6fdda916 100755 --- a/examples/dcomexec.py +++ b/examples/dcomexec.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -39,6 +40,7 @@ from __future__ import division from __future__ import print_function import argparse +import argcomplete import cmd import logging import ntpath @@ -590,6 +592,8 @@ def load_smbclient_auth_file(path): "See smbclient man page's -A option.") group.add_argument('-keytab', action="store", help='Read keys for SPN from keytab file') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/describeTicket.py b/examples/describeTicket.py index 4379a2e88..1cdd74e47 100755 --- a/examples/describeTicket.py +++ b/examples/describeTicket.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -21,6 +22,7 @@ import sys import traceback import argparse +import argcomplete import datetime import base64 from typing import Sequence @@ -751,6 +753,7 @@ def parse_args(): 'The information is encrypted using the AS reply key. Attack primitive known as UnPAC-the-Hash. (https://www.thehacker.recipes/ad/movement/kerberos/unpac-the-hash)' credential_info.add_argument('--asrep-key', action="store", metavar="HEXKEY", help='AS reply key for PAC Credentials decryption') + argcomplete.autocomplete(parser, always_complete_options=False) if len(sys.argv) == 1: parser.print_help() diff --git a/examples/dpapi.py b/examples/dpapi.py index bd0f102cc..4661c512a 100755 --- a/examples/dpapi.py +++ b/examples/dpapi.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -39,6 +40,7 @@ import struct import argparse +import argcomplete import logging import sys from six import b @@ -610,6 +612,8 @@ def run(self): credhist.add_argument('-password', action='store', help='User\'s password') credhist.add_argument('-entry', action='store', type=int, help='Entry index in CREDHIST') + argcomplete.autocomplete(parser, always_complete_options=False) + options = parser.parse_args() # Init the example's logger theme logger.init(options.ts, options.debug) diff --git a/examples/esentutl.py b/examples/esentutl.py index f898b92db..a143a045f 100755 --- a/examples/esentutl.py +++ b/examples/esentutl.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -24,6 +25,7 @@ import sys import logging import argparse +import argcomplete from impacket.examples import logger from impacket import version @@ -81,6 +83,8 @@ def main(): export_parser = subparsers.add_parser('export', help='dumps the catalog info for the DB') export_parser.add_argument('-table', action='store', required=True, help='table to dump') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/exchanger.py b/examples/exchanger.py index ad690d070..5ff8641e6 100755 --- a/examples/exchanger.py +++ b/examples/exchanger.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -30,6 +31,7 @@ import codecs import logging import argparse +import argcomplete import binascii import sys from six import PY3 @@ -975,6 +977,8 @@ def localized_arg(bytestring): help='Output format for binary objects') dnt_lookup.add_argument('-output-file', action='store', help='Output filename') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv) == 1: parser.print_help() sys.exit(1) diff --git a/examples/filetime.py b/examples/filetime.py index 6ee1d1500..ad429a161 100644 --- a/examples/filetime.py +++ b/examples/filetime.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -23,6 +24,7 @@ from __future__ import annotations import sys import argparse +import argcomplete import logging import ntpath from typing import Tuple @@ -166,6 +168,8 @@ def main(): touch_parser.add_argument('-v', '--validate', action='store_true', help='Query the file after touching to verify the changes.') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/findDelegation.py b/examples/findDelegation.py index ad77c3f82..e158b6381 100755 --- a/examples/findDelegation.py +++ b/examples/findDelegation.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -25,6 +26,7 @@ from __future__ import print_function import argparse +import argcomplete import logging import sys @@ -256,6 +258,8 @@ def run(self): 'If ommited, the domain part (FQDN) ' 'specified in the account parameter will be used') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/getArch.py b/examples/getArch.py index e82cb9d77..6c8578155 100755 --- a/examples/getArch.py +++ b/examples/getArch.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -28,6 +29,7 @@ from __future__ import division from __future__ import print_function import argparse +import argcomplete import logging import sys @@ -90,6 +92,8 @@ def run(self): parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON') parser.add_argument('-ts', action='store_true', help='Adds timestamp to every logging output') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/getPac.py b/examples/getPac.py index 080693da7..4d23ba0f5 100755 --- a/examples/getPac.py +++ b/examples/getPac.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -25,6 +26,7 @@ from __future__ import division from __future__ import print_function import argparse +import argcomplete import datetime import logging import random @@ -305,6 +307,9 @@ def dump(self): group = parser.add_argument_group('authentication') group.add_argument('-hashes', action="store", metavar = "LMHASH:NTHASH", help='NTLM hashes, format is LMHASH:NTHASH') + + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/getST.py b/examples/getST.py index 377a0f5b1..e4d64df31 100755 --- a/examples/getST.py +++ b/examples/getST.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -52,6 +53,7 @@ from __future__ import division from __future__ import print_function import argparse +import argcomplete import datetime import logging import os @@ -873,9 +875,12 @@ def run(self): group.add_argument('-dc-ip', action='store', metavar="ip address", help='IP Address of the domain controller. If ' 'omitted it use the domain part (FQDN) specified in the target parameter') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv) == 1: parser.print_help() print("\nExamples: ") + print("\t./getST.py -spn cifs/contoso-dc -hashes lm:nt contoso.com/user\n") print("\tit will use the lm:nt hashes for authentication. If you don't specify them, a password will be asked") sys.exit(1) diff --git a/examples/getTGT.py b/examples/getTGT.py index 4601adfe0..b558a3f52 100755 --- a/examples/getTGT.py +++ b/examples/getTGT.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -22,6 +23,7 @@ from __future__ import division from __future__ import print_function import argparse +import argcomplete import logging import sys from binascii import unhexlify @@ -91,12 +93,16 @@ def run(self): group.add_argument('-service', action='store', metavar="SPN", help='Request a Service Ticket directly through an AS-REQ') group.add_argument('-principalType', nargs="?", type=lambda value: constants.PrincipalNameType[value.upper()] if value.upper() in constants.PrincipalNameType.__members__ else None, action='store', default=constants.PrincipalNameType.NT_PRINCIPAL, help='PrincipalType of the token, can be one of NT_UNKNOWN, NT_PRINCIPAL, NT_SRV_INST, NT_SRV_HST, NT_SRV_XHST, NT_UID, NT_SMTP_NAME, NT_ENTERPRISE, NT_WELLKNOWN, NT_SRV_HST_DOMAIN, NT_MS_PRINCIPAL, NT_MS_PRINCIPAL_AND_ID, NT_ENT_PRINCIPAL_AND_ID; default is NT_PRINCIPAL, ') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() print("\nExamples: ") print("\t./getTGT.py -hashes lm:nt contoso.com/user\n") print("\tit will use the lm:nt hashes for authentication. If you don't specify them, a password will be asked") + sys.exit(1) + options = parser.parse_args() # Init the example's logger theme diff --git a/examples/goldenPac.py b/examples/goldenPac.py index 045d87c01..554f161d6 100755 --- a/examples/goldenPac.py +++ b/examples/goldenPac.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -1039,6 +1040,7 @@ def exploit(self): if __name__ == '__main__': import argparse + import argcomplete import sys try: import pyasn1 @@ -1092,6 +1094,9 @@ def exploit(self): group = parser.add_argument_group('authentication') group.add_argument('-hashes', action="store", metavar = "LMHASH:NTHASH", help='NTLM hashes, format is LMHASH:NTHASH') + + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() print("\nExamples: ") @@ -1101,6 +1106,7 @@ def exploit(self): print("\tif domain.net and/or domain-machine do not resolve, add them") print("\tto the hosts file or explicitly specify the domain IP (e.g. 1.1.1.1) and target IP:\n") print("\tpython goldenPac.py -dc-ip 1.1.1.1 -target-ip 2.2.2.2 domain.net/normaluser:mypwd@domain-host\n") + print("\tThis will upload the xxx.exe file and execute it as: xxx.exe param1 param2 paramn") print("\tpython goldenPac.py -c xxx.exe domain.net/normaluser:mypwd@domain-host param1 param2 paramn\n") sys.exit(1) diff --git a/examples/karmaSMB.py b/examples/karmaSMB.py index 9df8ebff4..049e4a435 100755 --- a/examples/karmaSMB.py +++ b/examples/karmaSMB.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -58,6 +59,7 @@ import sys import os import argparse +import argcomplete import logging import ntpath try: @@ -608,11 +610,13 @@ def setExtensionsConfig(self, filename): parser.add_argument('-ts', action='store_true', help='Adds timestamp to every logging output') parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON') + argcomplete.autocomplete(parser, always_complete_options=False) if len(sys.argv)==1: parser.print_help() sys.exit(1) + try: options = parser.parse_args() except Exception as e: diff --git a/examples/keylistattack.py b/examples/keylistattack.py index 150a182c0..68724dadf 100644 --- a/examples/keylistattack.py +++ b/examples/keylistattack.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -132,6 +133,7 @@ def getAllDomainUsers(self): if __name__ == '__main__': import argparse + import argcomplete import sys try: @@ -177,6 +179,8 @@ def getAllDomainUsers(self): help='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 it') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv) == 1: parser.print_help() sys.exit(1) @@ -265,4 +269,4 @@ def getAllDomainUsers(self): import traceback traceback.print_exc() - logging.error(e) \ No newline at end of file + logging.error(e) diff --git a/examples/kintercept.py b/examples/kintercept.py index 23575aaf6..8721f505a 100755 --- a/examples/kintercept.py +++ b/examples/kintercept.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -29,6 +30,7 @@ # Example: kintercept.py --request-handler s4u2else:administrator dc-ip-addr # import struct, socket, argparse, asyncore +import argcomplete from binascii import crc32 from pyasn1.codec.der import decoder, encoder from pyasn1.type.univ import noValue @@ -271,6 +273,9 @@ def parse_args(): parser.add_argument('--reply-handler', default='', metavar='HANDLER:ARG', help='Example: tgs-rep-user:user') parser.add_argument('-ts', action='store_true', help='Adds timestamp to every logging output') parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON') + + argcomplete.autocomplete(parser, always_complete_options=False) + return vars(parser.parse_args()) diff --git a/examples/lookupsid.py b/examples/lookupsid.py index 9708aa3d1..903635ec1 100755 --- a/examples/lookupsid.py +++ b/examples/lookupsid.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -24,6 +25,7 @@ import sys import logging import argparse +import argcomplete import codecs from impacket.examples import logger @@ -178,6 +180,9 @@ def __bruteForce(self, rpctransport, maxRid): '(KRB5CCNAME) based on target parameters. If valid credentials ' 'cannot be found, it will use the ones specified in the command ' 'line') + + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/machine_role.py b/examples/machine_role.py index 48f0a813f..6381e3331 100644 --- a/examples/machine_role.py +++ b/examples/machine_role.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -24,6 +25,7 @@ import sys import logging import argparse +import argcomplete from impacket.examples import logger from impacket.examples.utils import parse_target @@ -147,6 +149,8 @@ def __log_and_exit(self, error): group.add_argument('-aesKey', action='store', metavar='hex key', help='AES key to use for Kerberos Authentication ' '(128 or 256 bits)') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/mimikatz.py b/examples/mimikatz.py index d40643211..f6029bac4 100755 --- a/examples/mimikatz.py +++ b/examples/mimikatz.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -22,6 +23,7 @@ from __future__ import division from __future__ import print_function import argparse +import argcomplete import cmd import logging import os @@ -142,6 +144,8 @@ def main(): help='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 it') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/mqtt_check.py b/examples/mqtt_check.py index c4f57ea29..f98595696 100755 --- a/examples/mqtt_check.py +++ b/examples/mqtt_check.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -23,6 +24,7 @@ from __future__ import print_function import argparse +import argcomplete import logging import sys @@ -65,6 +67,8 @@ def run(self): parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON') parser.add_argument('-ts', action='store_true', help='Adds timestamp to every logging output') + argcomplete.autocomplete(parser, always_complete_options=False) + try: options = parser.parse_args() except Exception as e: diff --git a/examples/mssqlclient.py b/examples/mssqlclient.py index cca3e9b59..7fa26f644 100755 --- a/examples/mssqlclient.py +++ b/examples/mssqlclient.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -20,6 +21,7 @@ # import argparse +import argcomplete import sys import logging @@ -64,6 +66,8 @@ group.add_argument('-port', action='store', default='1433', help='target MSSQL port (default 1433)') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/mssqlinstance.py b/examples/mssqlinstance.py index 4f63e30b3..fe662e5fd 100755 --- a/examples/mssqlinstance.py +++ b/examples/mssqlinstance.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -22,6 +23,7 @@ from __future__ import division from __future__ import print_function import argparse +import argcomplete import sys import logging @@ -39,6 +41,8 @@ parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON') parser.add_argument('-ts', action='store_true', help='Adds timestamp to every logging output') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/net.py b/examples/net.py index 27f08c7f2..608d64ecb 100644 --- a/examples/net.py +++ b/examples/net.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -36,6 +37,7 @@ import sys import argparse +import argcomplete import logging from datetime import datetime @@ -542,6 +544,8 @@ def __is_option_present(self, options, option): group.add_argument('-port', choices=['139', '445'], nargs='?', default='445', metavar="destination port", help='Destination port to connect to SMB Server') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv) == 1: parser.print_help() sys.exit(1) diff --git a/examples/netview.py b/examples/netview.py index 4a092bdd3..458a5611f 100755 --- a/examples/netview.py +++ b/examples/netview.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -54,6 +55,7 @@ from __future__ import print_function import sys import argparse +import argcomplete import logging import socket from threading import Thread, Event @@ -472,6 +474,8 @@ def stop(self): group.add_argument('-dc-ip', action='store',metavar = "ip address", help='IP Address of the domain controller. If ' 'ommited it use the domain part (FQDN) specified in the target parameter') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/ntfs-read.py b/examples/ntfs-read.py index 9f0329f73..eec5e3787 100755 --- a/examples/ntfs-read.py +++ b/examples/ntfs-read.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -34,6 +35,7 @@ import logging import struct import argparse +import argcomplete import cmd import ntpath from six import PY2, text_type @@ -1180,9 +1182,12 @@ def main(): parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON') parser.add_argument('-ts', action='store_true', help='Adds timestamp to every logging output') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) + options = parser.parse_args() # Init the example's logger theme logger.init(options.ts, options.debug) diff --git a/examples/ntlmrelayx.py b/examples/ntlmrelayx.py index f1f8ce92c..2b88bb0b9 100644 --- a/examples/ntlmrelayx.py +++ b/examples/ntlmrelayx.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -38,6 +39,7 @@ # import argparse +import argcomplete import sys import logging import cmd @@ -431,6 +433,8 @@ def stop_servers(threads): sccmdpoptions.add_argument('--sccm-dp-extensions', action='store', required=False, help='A custom list of extensions to look for when downloading files from the SCCM Distribution Point. If not provided, defaults to .ps1,.bat,.xml,.txt,.pfx') sccmdpoptions.add_argument('--sccm-dp-files', action='store', required=False, help='The path to a file containing a list of specific URLs to download from the Distribution Point, instead of downloading by extensions. Providing this argument will skip file indexing') + argcomplete.autocomplete(parser, always_complete_options=False) + try: options = parser.parse_args() except Exception as e: diff --git a/examples/owneredit.py b/examples/owneredit.py index cb9c78a5c..ecabfc2ba 100644 --- a/examples/owneredit.py +++ b/examples/owneredit.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -16,6 +17,7 @@ # Charlie BROMBERG (@_nwodtuhs) import argparse +import argcomplete import logging import sys import traceback @@ -256,6 +258,8 @@ def parse_args(): dacl_parser = parser.add_argument_group("dacl editor") dacl_parser.add_argument('-action', choices=['read', 'write'], nargs='?', default='read', help='Action to operate on the owner attribute') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv) == 1: parser.print_help() sys.exit(1) diff --git a/examples/psexec.py b/examples/psexec.py index 542d72100..fd817c3a0 100755 --- a/examples/psexec.py +++ b/examples/psexec.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -26,6 +27,7 @@ import logging from threading import Thread, Lock import argparse +import argcomplete import random import string import time @@ -634,6 +636,8 @@ def run(self): group.add_argument('-remote-binary-name', action='store', metavar="remote_binary_name", default = None, help='This will ' 'be the name of the executable uploaded on the target') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/raiseChild.py b/examples/raiseChild.py index 13c2fd7f5..c7cbdcb95 100755 --- a/examples/raiseChild.py +++ b/examples/raiseChild.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -61,6 +62,7 @@ from __future__ import division from __future__ import print_function import argparse +import argcomplete import datetime import logging import random @@ -1273,6 +1275,8 @@ def exploit(self): group.add_argument('-aesKey', action="store", metavar = "hex key", help='AES key to use for Kerberos Authentication ' '(128 or 256 bits)') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() print("\nExamples: ") @@ -1286,6 +1290,7 @@ def exploit(self): print("\tpython raiseChild.py -target-exec targetHost childDomainn.net/adminuser\n") print("\tThis will perform the attack and then psexec against target-exec as User with RID 1101") print("\tpython raiseChild.py -target-exec targetHost -targetRID 1101 childDomainn.net/adminuser\n") + print("\tThis will save the final goldenTicket generated in the ccache target file") print("\tpython raiseChild.py -w ccache childDomain.net/adminuser\n") sys.exit(1) diff --git a/examples/rbcd.py b/examples/rbcd.py index 1e7e05903..12ad30767 100755 --- a/examples/rbcd.py +++ b/examples/rbcd.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -20,6 +21,7 @@ # [ ]: allow users to set a ((-delegate-from-sid or -delegate-from-dn) and -delegate-to-dn) in order to skip ldapdomaindump and explicitely set the SID/DN import argparse +import argcomplete import logging import sys import traceback @@ -295,6 +297,8 @@ def parse_args(): 'the identity parameter') group.add_argument('-dc-host', action='store', metavar="hostname", help='Hostname of the domain controller or KDC (Key Distribution Center) for Kerberos. If omitted, -dc-ip will be used') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv) == 1: parser.print_help() sys.exit(1) diff --git a/examples/rdp_check.py b/examples/rdp_check.py index d17d5abff..a602dfd60 100755 --- a/examples/rdp_check.py +++ b/examples/rdp_check.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -280,6 +281,7 @@ def getData(self): import socket import argparse + import argcomplete import sys import logging from binascii import a2b_hex @@ -558,6 +560,9 @@ def check_rdp(host, username, password, domain, hashes=None, ipv6=False): group = parser.add_argument_group('authentication') group.add_argument('-hashes', action="store", metavar = "LMHASH:NTHASH", help='NTLM hashes, format is LMHASH:NTHASH') + + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/reg.py b/examples/reg.py index 50f8be5a5..2a09c81ec 100755 --- a/examples/reg.py +++ b/examples/reg.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -31,6 +32,7 @@ from __future__ import division from __future__ import print_function import argparse +import argcomplete import codecs import logging import sys @@ -642,6 +644,8 @@ def __parse_lp_data(valueType, valueData): group.add_argument('-port', choices=['139', '445'], nargs='?', default='445', metavar="destination port", help='Destination port to connect to SMB Server') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv) == 1: parser.print_help() sys.exit(1) diff --git a/examples/registry-read.py b/examples/registry-read.py index 877803243..c43fc5191 100644 --- a/examples/registry-read.py +++ b/examples/registry-read.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -23,6 +24,7 @@ from __future__ import print_function import sys import argparse +import argcomplete import ntpath from binascii import unhexlify, hexlify @@ -148,6 +150,8 @@ def main(): walk_parser = subparsers.add_parser('walk', help='walks the registry from the name node down') walk_parser.add_argument('-name', action='store', required=True, help='registry class name to start walking down from') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/regsecrets.py b/examples/regsecrets.py index 5bab7b2f7..622ee1ae3 100755 --- a/examples/regsecrets.py +++ b/examples/regsecrets.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright (C) 2022 Fortra. All rights reserved. @@ -50,6 +51,7 @@ # import argparse +import argcomplete import codecs import logging import sys @@ -212,6 +214,8 @@ def cleanup(self): help='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 it') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/rpcdump.py b/examples/rpcdump.py index 1ca4663a7..93d70d248 100755 --- a/examples/rpcdump.py +++ b/examples/rpcdump.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -25,6 +26,7 @@ import sys import logging import argparse +import argcomplete from impacket.http import AUTH_NTLM from impacket.examples import logger @@ -185,6 +187,9 @@ def __fetchList(self, rpctransport): group = parser.add_argument_group('authentication') group.add_argument('-hashes', action="store", metavar = "LMHASH:NTHASH", help='NTLM hashes, format is LMHASH:NTHASH') + + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/rpcmap.py b/examples/rpcmap.py index 708725203..63ace0254 100755 --- a/examples/rpcmap.py +++ b/examples/rpcmap.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -36,6 +37,7 @@ import sys import logging import argparse +import argcomplete from impacket.http import AUTH_BASIC from impacket.examples import logger, rpcdatabase @@ -316,6 +318,8 @@ def _split_lines(self, text, width): group.add_argument('-hashes-transport', action="store", metavar = "LMHASH:NTHASH", help='NTLM hashes, format is LMHASH:NTHASH') group.add_argument('-no-pass', action="store_true", help='don\'t ask for passwords') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/sambaPipe.py b/examples/sambaPipe.py index f526d0279..de7ed647c 100755 --- a/examples/sambaPipe.py +++ b/examples/sambaPipe.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -32,6 +33,7 @@ # import argparse +import argcomplete import logging import sys from os import path @@ -232,6 +234,8 @@ def run(self): group.add_argument('-port', choices=['139', '445'], nargs='?', default='445', metavar="destination port", help='Destination port to connect to SMB Server') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv) == 1: parser.print_help() sys.exit(1) diff --git a/examples/samedit.py b/examples/samedit.py index 487fc2074..b8db1c9c1 100644 --- a/examples/samedit.py +++ b/examples/samedit.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright (C) 2024 Fortra. All rights reserved. @@ -26,6 +27,7 @@ import sys import codecs import argparse +import argcomplete import logging import binascii @@ -60,6 +62,7 @@ parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON') parser.add_argument('-ts', action='store_true', help='Adds timestamp to every logging output') + argcomplete.autocomplete(parser, always_complete_options=False) if len(sys.argv) < 4: parser.print_help() @@ -118,4 +121,4 @@ traceback.print_exc() logging.error(e) - hive.finish() \ No newline at end of file + hive.finish() diff --git a/examples/samrdump.py b/examples/samrdump.py index d08fd5bc6..c3a809a03 100755 --- a/examples/samrdump.py +++ b/examples/samrdump.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -25,6 +26,7 @@ import sys import logging import argparse +import argcomplete import codecs from datetime import datetime @@ -230,6 +232,8 @@ def __fetchList(self, rpctransport): group.add_argument('-aesKey', action="store", metavar = "hex key", help='AES key to use for Kerberos Authentication ' '(128 or 256 bits)') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/secretsdump.py b/examples/secretsdump.py index 168384eb1..2f15dcaff 100755 --- a/examples/secretsdump.py +++ b/examples/secretsdump.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -53,6 +54,7 @@ from __future__ import division from __future__ import print_function import argparse +import argcomplete import codecs import logging import os @@ -465,6 +467,8 @@ def cleanup(self): help='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 it') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv) == 1: parser.print_help() sys.exit(1) diff --git a/examples/services.py b/examples/services.py index 6d7877d5d..af5c2c883 100755 --- a/examples/services.py +++ b/examples/services.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -26,6 +27,7 @@ from __future__ import print_function import sys import argparse +import argcomplete import logging import codecs @@ -323,6 +325,8 @@ def doStuff(self, rpctransport): group.add_argument('-port', choices=['139', '445'], nargs='?', default='445', metavar="destination port", help='Destination port to connect to SMB Server') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/smbclient.py b/examples/smbclient.py index dc130541e..78722c9a8 100755 --- a/examples/smbclient.py +++ b/examples/smbclient.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -24,6 +25,7 @@ import sys import logging import argparse +import argcomplete from impacket.examples import logger from impacket.examples.utils import parse_target from impacket.examples.smbclient import MiniImpacketShell @@ -62,6 +64,8 @@ def main(): group.add_argument('-port', choices=['139', '445'], nargs='?', default='445', metavar="destination port", help='Destination port to connect to SMB Server') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/smbexec.py b/examples/smbexec.py index af0754b3a..ed6fb9045 100755 --- a/examples/smbexec.py +++ b/examples/smbexec.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -42,6 +43,7 @@ import string import cmd import argparse +import argcomplete try: import ConfigParser except ImportError: @@ -359,6 +361,7 @@ def send_data(self, data): '(128 or 256 bits)') group.add_argument('-keytab', action="store", help='Read keys for SPN from keytab file') + argcomplete.autocomplete(parser, always_complete_options=False) if len(sys.argv)==1: parser.print_help() diff --git a/examples/smbserver.py b/examples/smbserver.py index 4b62a97e3..0b0c6ce59 100755 --- a/examples/smbserver.py +++ b/examples/smbserver.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -18,6 +19,7 @@ import sys import argparse +import argcomplete import logging from impacket.examples import logger @@ -49,10 +51,13 @@ parser.add_argument('-smb2support', action='store_true', default=False, help='SMB2 Support (experimental!)') parser.add_argument('-outputfile', action='store', default=None, help='Output file to log smbserver output messages') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) + try: options = parser.parse_args() except Exception as e: diff --git a/examples/ticketConverter.py b/examples/ticketConverter.py index 5359cb3de..b41a368ed 100755 --- a/examples/ticketConverter.py +++ b/examples/ticketConverter.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -28,6 +29,7 @@ # import argparse +import argcomplete import struct from impacket import version @@ -38,6 +40,9 @@ def parse_args(): parser = argparse.ArgumentParser() parser.add_argument('input_file', help="File in kirbi (KRB-CRED) or ccache format") parser.add_argument('output_file', help="Output file") + + argcomplete.autocomplete(parser, always_complete_options=False) + return parser.parse_args() diff --git a/examples/ticketer.py b/examples/ticketer.py index 487bb592e..f1800baf7 100755 --- a/examples/ticketer.py +++ b/examples/ticketer.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -48,6 +49,7 @@ from __future__ import division from __future__ import print_function import argparse +import argcomplete import datetime import logging import random @@ -1143,6 +1145,8 @@ def run(self): ' for querying the ST and extracting the PAC, which will be' ' included in the new ticket') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() print("\nExamples: ") @@ -1155,6 +1159,7 @@ def run(self): " -request -user -password baduser\n") print("\twill first authenticate against the KDC (using -user/-password) and get a TGT that will be used") print("\tas template for customization. Whatever encryption algorithms used on that ticket will be honored,") + print("\thence you might need to specify both -nthash and -aesKey data. Ticket will be generated for 'baduser'") print("\tand saved as baduser.ccache") sys.exit(1) diff --git a/examples/tstool.py b/examples/tstool.py index e6d121454..db13c1b65 100755 --- a/examples/tstool.py +++ b/examples/tstool.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -30,6 +31,7 @@ # import argparse +import argcomplete import codecs import logging import sys @@ -616,6 +618,8 @@ def do_msg(self): group.add_argument('-port', choices=['139', '445'], nargs='?', default='445', metavar="destination port", help='Destination port to connect to SMB Server') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv) == 1: parser.print_help() sys.exit(1) diff --git a/examples/wmiexec.py b/examples/wmiexec.py index 815341f5e..e4d885aff 100755 --- a/examples/wmiexec.py +++ b/examples/wmiexec.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -30,6 +31,7 @@ import os import cmd import argparse +import argcomplete import time import logging import ntpath @@ -399,6 +401,8 @@ def load_smbclient_auth_file(path): "See smbclient man page's -A option.") group.add_argument('-keytab', action="store", help='Read keys for SPN from keytab file') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv) == 1: parser.print_help() sys.exit(1) diff --git a/examples/wmipersist.py b/examples/wmipersist.py index 78f6975be..99c774f2c 100755 --- a/examples/wmipersist.py +++ b/examples/wmipersist.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -53,6 +54,7 @@ from __future__ import print_function import sys import argparse +import argcomplete import logging from impacket.examples import logger @@ -203,7 +205,9 @@ def run(self, addr): '(128 or 256 bits)') group.add_argument('-dc-ip', action='store',metavar = "ip address", help='IP Address of the domain controller. If ' 'ommited it use the domain part (FQDN) specified in the target parameter') - + + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/examples/wmiquery.py b/examples/wmiquery.py index 85e893417..39f2ec682 100755 --- a/examples/wmiquery.py +++ b/examples/wmiquery.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK # Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies @@ -26,6 +27,7 @@ from __future__ import division from __future__ import print_function import argparse +import argcomplete import sys import os import logging @@ -155,6 +157,8 @@ def do_exit(self, line): '(RPC_C_AUTHN_LEVEL_PKT_PRIVACY). For example CIM path "root/MSCluster" would require ' 'privacy level by default)') + argcomplete.autocomplete(parser, always_complete_options=False) + if len(sys.argv)==1: parser.print_help() sys.exit(1) diff --git a/requirements.txt b/requirements.txt index 22f9d34e7..a61e737e3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,4 +8,5 @@ pyOpenSSL ldap3>=2.5,!=2.5.2,!=2.5.0,!=2.6 ldapdomaindump>=0.9.0 flask>=1.0 +argcomplete pyreadline3;sys_platform == 'win32' diff --git a/setup.py b/setup.py index 1ffca7328..e485dab3b 100644 --- a/setup.py +++ b/setup.py @@ -72,7 +72,7 @@ def read(fname): data_files=data_files, install_requires=['pyasn1>=0.2.3', 'pyasn1_modules', 'pycryptodomex', 'pyOpenSSL', 'six', 'ldap3>=2.5,!=2.5.2,!=2.5.0,!=2.6', - 'ldapdomaindump>=0.9.0', 'flask>=1.0', 'setuptools', 'charset_normalizer'], + 'ldapdomaindump>=0.9.0', 'flask>=1.0', 'setuptools', 'charset_normalizer', 'argcomplete'], extras_require={':sys_platform=="win32"': ['pyreadline3'], }, classifiers=[