11#!/usr/bin/env python3
22# -*- coding: utf-8 -*-
3+ # PYTHON_ARGCOMPLETE_OK
34# File name : __main__.py
45# Author : Podalirius (@podalirius_)
56# Date created : 17 Sep 2022
910import os
1011import sys
1112import threading
13+ import argcomplete
1214from sectools .network .domains import is_fqdn
1315from sectools .network .ip import is_ipv4_cidr , is_ipv4_addr , is_ipv6_addr , expand_cidr , expand_port_range
1416
@@ -46,7 +48,7 @@ def parseArgs():
4648 mode_scan_advanced_config .add_argument ("--smb-port" , default = 445 , type = int , help = "SMB port (default: 445)" )
4749 mode_scan_advanced_config .add_argument ("--dce-port" , default = 135 , type = int , help = "DCERPC port (default: 135)" )
4850 mode_scan_advanced_config .add_argument ("--dce-ports" , default = [], nargs = '+' , type = int , help = "DCERPC ports" )
49- mode_scan_advanced_config .add_argument ("--auth-type" , default = None , type = str , help = "Desired authentication type ('smb' or 'http')." )
51+ mode_scan_advanced_config .add_argument ("--auth-type" , default = None , type = str , choices = ('smb' , 'http' ), help = "Desired authentication type ." )
5052 mode_scan_advanced_config .add_argument ("--stop-on-ntlm-auth" , default = False , action = "store_true" , help = "Move on to next target on successful NTLM authentication." )
5153 # Filters
5254 mode_scan_filters = mode_scan .add_argument_group ("Filtering" )
@@ -93,7 +95,7 @@ def parseArgs():
9395 mode_fuzz_advanced_config .add_argument ("--smb-port" , default = 445 , type = int , help = "SMB port (default: 445)" )
9496 mode_fuzz_advanced_config .add_argument ("--dce-port" , default = 135 , type = int , help = "DCERPC port (default: 135)" )
9597 mode_fuzz_advanced_config .add_argument ("--dce-ports" , default = [], nargs = '+' , type = int , help = "DCERPC ports" )
96- mode_fuzz_advanced_config .add_argument ("--auth-type" , default = None , type = str , help = "Desired authentication type ('smb' or 'http')." )
98+ mode_fuzz_advanced_config .add_argument ("--auth-type" , default = None , type = str , choices = ('smb' , 'http' ), help = "Desired authentication type ." )
9799 # Filters
98100 mode_fuzz_filters = mode_fuzz .add_argument_group ("Filtering" )
99101 mode_fuzz_filters .add_argument ("--filter-method-name" , default = [], action = 'append' , type = str , help = "Filter by method name" )
@@ -122,7 +124,7 @@ def parseArgs():
122124 mode_fuzz_logging = mode_fuzz .add_argument_group ("Logging" )
123125 mode_fuzz_logging .add_argument ("--minimum-log-level" , default = 0 , help = "Minimum logging level (integer)." )
124126 mode_fuzz_logging .add_argument ("--log-file" , default = None , help = "Path for the file to log to (enables logging)." )
125-
127+
126128 # Creating the "coerce" subparser ==============================================================================================================
127129 mode_coerce = argparse .ArgumentParser (add_help = False )
128130 mode_coerce .add_argument ("-v" , "--verbose" , default = False , action = "store_true" , help = "Verbose mode (default: False)" )
@@ -136,7 +138,7 @@ def parseArgs():
136138 mode_coerce_advanced_config .add_argument ("--dce-port" , default = 135 , type = int , help = "DCERPC port (default: 135)" )
137139 mode_coerce_advanced_config .add_argument ("--dce-ports" , default = [], nargs = '+' , type = int , help = "DCERPC ports" )
138140 mode_coerce_advanced_config .add_argument ("--always-continue" , default = False , action = "store_true" , help = "Always continue to coerce" )
139- mode_coerce_advanced_config .add_argument ("--auth-type" , default = None , type = str , help = "Desired authentication type ('smb' or 'http')." )
141+ mode_coerce_advanced_config .add_argument ("--auth-type" , default = None , type = str , choices = ('smb' , 'http' ), help = "Desired authentication type ." )
140142 # Filters
141143 mode_coerce_filters = mode_coerce .add_argument_group ("Filtering" )
142144 mode_coerce_filters .add_argument ("--filter-method-name" , default = [], action = 'append' , type = str , help = "Filter by method name" )
@@ -165,13 +167,14 @@ def parseArgs():
165167 mode_coerce_logging = mode_coerce .add_argument_group ("Logging" )
166168 mode_coerce_logging .add_argument ("--minimum-log-level" , default = 0 , help = "Minimum logging level (integer)." )
167169 mode_coerce_logging .add_argument ("--log-file" , default = None , help = "Path for the file to log to (enables logging)." )
168-
170+
169171 # Adding the subparsers to the base parser
170172 subparsers = parser .add_subparsers (help = "Mode" , dest = "mode" , required = True )
171173 mode_scan_parser = subparsers .add_parser ("scan" , parents = [mode_scan ], help = "Tests known methods with known working paths on all methods, and report when an authentication is received." )
172- mode_coerce_parser = subparsers .add_parser ("coerce" , parents = [mode_coerce ], help = "Trigger authentications through all known methods with known working paths" )
174+ mode_coerce_parser = subparsers .add_parser ("coerce" , parents = [mode_coerce ], help = "Trigger authentications through all known methods with known working paths. " )
173175 mode_fuzz_parser = subparsers .add_parser ("fuzz" , parents = [mode_fuzz ], help = "Tests every method with a list of exploit paths, and report when an authentication is received." )
174176
177+ argcomplete .autocomplete (parser , always_complete_options = False )
175178 options = parser .parse_args ()
176179
177180 # Parsing hashes
@@ -245,15 +248,15 @@ def main():
245248 final_targets .append (target )
246249 else :
247250 reporter .print_warn ("Target '%s' was not added." % target , debug = True )
248-
249- # Sort
251+
252+ # Sort
250253 targets = sorted (list (set (final_targets )))
251254
252255 credentials = Credentials (
253- username = options .username ,
254- password = options .password ,
255- domain = options .domain ,
256- lmhash = lmhash ,
256+ username = options .username ,
257+ password = options .password ,
258+ domain = options .domain ,
259+ lmhash = lmhash ,
257260 nthash = nthash
258261 )
259262
0 commit comments