Skip to content

Commit 09cc03f

Browse files
committed
Add argcomplete functionality
1 parent 62e2a9a commit 09cc03f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+264
-6
lines changed

examples/DumpNTLMInfo.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
# PYTHON_ARGCOMPLETE_OK
23
# Impacket - Collection of Python classes for working with network protocols.
34
#
45
# Copyright Fortra, LLC and its affiliated companies
@@ -37,6 +38,7 @@
3738
import os
3839
import sys
3940
import argparse
41+
import argcomplete
4042
import logging
4143
import struct
4244
import socket
@@ -644,6 +646,8 @@ def __convert_size(self, size_bytes):
644646
parser.add_argument('-protocol', choices=['SMB', 'RPC'], nargs='?', metavar="protocol",
645647
help='Protocol to use (SMB or RPC). Default is SMB, port 135 uses RPC normally.')
646648

649+
argcomplete.autocomplete(parser, always_complete_options=False)
650+
647651
if len(sys.argv) == 1:
648652
parser.print_help()
649653
sys.exit(1)

examples/Get-GPPPassword.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python3
2+
# PYTHON_ARGCOMPLETE_OK
23
# Impacket - Collection of Python classes for working with network protocols.
34
#
45
# Copyright Fortra, LLC and its affiliated companies
@@ -20,6 +21,7 @@
2021
#
2122

2223
import argparse
24+
import argcomplete
2325
import base64
2426
import xml
2527
import charset_normalizer
@@ -227,6 +229,8 @@ def parse_args():
227229
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")
228230
group.add_argument("-port", choices=["139", "445"], nargs="?", default="445", metavar="destination port", help="Destination port to connect to SMB Server")
229231

232+
argcomplete.autocomplete(parser, always_complete_options=False)
233+
230234
if len(sys.argv) == 1:
231235
parser.print_help()
232236
sys.exit(1)

examples/GetADComputers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
# PYTHON_ARGCOMPLETE_OK
23
# Impacket - Collection of Python classes for working with network protocols.
34
#
45
# Copyright Fortra, LLC and its affiliated companies
@@ -30,6 +31,7 @@
3031
from __future__ import print_function
3132
from __future__ import unicode_literals
3233
import argparse
34+
import argcomplete
3335
import logging
3436
import sys
3537
import dns.resolver
@@ -209,8 +211,7 @@ def run(self):
209211
'If ommited, the domain part (FQDN) '
210212
'specified in the account parameter will be used')
211213

212-
213-
214+
argcomplete.autocomplete(parser, always_complete_options=False)
214215

215216
if len(sys.argv)==1:
216217
parser.print_help()

examples/GetADUsers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
# PYTHON_ARGCOMPLETE_OK
23
# Impacket - Collection of Python classes for working with network protocols.
34
#
45
# Copyright Fortra, LLC and its affiliated companies
@@ -28,6 +29,7 @@
2829
from __future__ import print_function
2930
from __future__ import unicode_literals
3031
import argparse
32+
import argcomplete
3133
import logging
3234
import sys
3335
from datetime import datetime
@@ -173,6 +175,8 @@ def run(self):
173175
'If ommited, the domain part (FQDN) '
174176
'specified in the account parameter will be used')
175177

178+
argcomplete.autocomplete(parser, always_complete_options=False)
179+
176180
if len(sys.argv)==1:
177181
parser.print_help()
178182
sys.exit(1)

examples/GetLAPSPassword.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
# PYTHON_ARGCOMPLETE_OK
23
# Impacket - Collection of Python classes for working with network protocols.
34
#
45
# Copyright Fortra, LLC and its affiliated companies
@@ -37,6 +38,7 @@
3738
from pyasn1.codec.der import decoder
3839
from pyasn1_modules import rfc5652
3940
import argparse
41+
import argcomplete
4042
import json
4143
import logging
4244
import sys
@@ -277,6 +279,8 @@ def run(self):
277279
'Required when querying a Windows Server 2025'
278280
'domain controller with LDAPS enforced.')
279281

282+
argcomplete.autocomplete(parser, always_complete_options=False)
283+
280284
if len(sys.argv)==1:
281285
parser.print_help()
282286
sys.exit(1)

examples/GetNPUsers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
# PYTHON_ARGCOMPLETE_OK
23
# Impacket - Collection of Python classes for working with network protocols.
34
#
45
# Copyright Fortra, LLC and its affiliated companies
@@ -29,6 +30,7 @@
2930
from __future__ import division
3031
from __future__ import print_function
3132
import argparse
33+
import argcomplete
3234
import datetime
3335
import logging
3436
import random
@@ -369,6 +371,8 @@ def request_multiple_TGTs(self, usernames):
369371
'If ommited, the domain part (FQDN) '
370372
'specified in the account parameter will be used')
371373

374+
argcomplete.autocomplete(parser, always_complete_options=False)
375+
372376
if len(sys.argv)==1:
373377
parser.print_help()
374378
print("\nThere are a few modes for using this script")
@@ -383,6 +387,7 @@ def request_multiple_TGTs(self, usernames):
383387
print("\n3. Request TGTs for all users")
384388
print("\n\tGetNPUsers.py contoso.com/emily:password -request or GetNPUsers.py contoso.com/emily")
385389
print("\n4. Request TGTs for users in a file")
390+
386391
print("\n\tGetNPUsers.py -no-pass -usersfile users.txt contoso.com/")
387392
print("\nFor this operation you don\'t need credentials.")
388393
sys.exit(1)

examples/GetUserSPNs.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
# PYTHON_ARGCOMPLETE_OK
23
# Impacket - Collection of Python classes for working with network protocols.
34
#
45
# Copyright Fortra, LLC and its affiliated companies
@@ -33,6 +34,7 @@
3334
from __future__ import division
3435
from __future__ import print_function
3536
import argparse
37+
import argcomplete
3638
import logging
3739
import sys
3840
from datetime import datetime
@@ -497,6 +499,8 @@ def request_multiple_TGSs(self, usernames):
497499
'If ommited, the domain part (FQDN) '
498500
'specified in the account parameter will be used')
499501

502+
argcomplete.autocomplete(parser, always_complete_options=False)
503+
500504
if len(sys.argv) == 1:
501505
parser.print_help()
502506
sys.exit(1)

examples/addcomputer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
# PYTHON_ARGCOMPLETE_OK
23
# Impacket - Collection of Python classes for working with network protocols.
34
#
45
# Copyright Fortra, LLC and its affiliated companies
@@ -39,6 +40,7 @@
3940

4041
import ldap3
4142
import argparse
43+
import argcomplete
4244
import logging
4345
import sys
4446
import string
@@ -416,6 +418,7 @@ def run(self):
416418
'Useful if you can\'t translate the FQDN.'
417419
'specified in the account parameter will be used')
418420

421+
argcomplete.autocomplete(parser, always_complete_options=False)
419422

420423
if len(sys.argv)==1:
421424
parser.print_help()

examples/atexec.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
# PYTHON_ARGCOMPLETE_OK
23
# Impacket - Collection of Python classes for working with network protocols.
34
#
45
# Copyright Fortra, LLC and its affiliated companies
@@ -26,6 +27,7 @@
2627
import string
2728
import sys
2829
import argparse
30+
import argcomplete
2931
import time
3032
import random
3133
import logging
@@ -271,6 +273,8 @@ def cmd_split(cmdline):
271273
'If omitted it will use the domain part (FQDN) specified in the target parameter')
272274
group.add_argument('-keytab', action="store", help='Read keys for SPN from keytab file')
273275

276+
argcomplete.autocomplete(parser, always_complete_options=False)
277+
274278
if len(sys.argv)==1:
275279
parser.print_help()
276280
sys.exit(1)

examples/attrib.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
# PYTHON_ARGCOMPLETE_OK
23
# Impacket - Collection of Python classes for working with network protocols.
34
#
45
# Copyright Fortra, LLC and its affiliated companies
@@ -21,6 +22,7 @@
2122
from __future__ import annotations
2223
import sys
2324
import argparse
25+
import argcomplete
2426
import logging
2527
import ntpath
2628
from dataclasses import dataclass
@@ -246,6 +248,8 @@ def main():
246248
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.")
247249
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.")
248250

251+
argcomplete.autocomplete(parser, always_complete_options=False)
252+
249253
if len(sys.argv)==1:
250254
parser.print_help()
251255
sys.exit(1)

0 commit comments

Comments
 (0)