Skip to content

Commit eb7707a

Browse files
refactor(args): update remaining protos to use new default formatter for printing arg defaults
1 parent 913c760 commit eb7707a

7 files changed

Lines changed: 51 additions & 37 deletions

File tree

nxc/protocols/ftp/proto_args.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
from nxc.helpers.args import DisplayDefaultsNotNone
2+
3+
14
def proto_args(parser, parents):
2-
ftp_parser = parser.add_parser("ftp", help="own stuff using FTP", parents=parents)
3-
ftp_parser.add_argument("--port", type=int, default=21, help="FTP port (default: 21)")
5+
ftp_parser = parser.add_parser("ftp", help="own stuff using FTP", parents=parents, formatter_class=DisplayDefaultsNotNone)
6+
ftp_parser.add_argument("--port", type=int, default=21, help="FTP port")
47

5-
cgroup = ftp_parser.add_argument_group("FTP Access", "Options for enumerating your access")
6-
cgroup.add_argument("--ls", metavar="DIRECTORY", nargs="?", const=".", help="List files in the directory, ex: --ls or --ls Directory")
7-
cgroup.add_argument("--get", metavar="FILE", help="Download a file, ex: --get fileName.txt")
8-
cgroup.add_argument("--put", metavar=("LOCAL_FILE", "REMOTE_FILE"), nargs=2, help="Upload a file, ex: --put inputFileName.txt outputFileName.txt")
8+
cgroup = ftp_parser.add_argument_group("File Operations", "Options for enumerating and interacting with files on the target")
9+
cgroup.add_argument("--ls", metavar="DIRECTORY", nargs="?", const=".", help="List files in the directory")
10+
cgroup.add_argument("--get", metavar="FILE", help="Download a file")
11+
cgroup.add_argument("--put", metavar=("LOCAL_FILE", "REMOTE_FILE"), nargs=2, help="Upload a file")
912
return parser

nxc/protocols/ldap/proto_args.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
from nxc.helpers.args import DisplayDefaultsNotNone
2+
3+
14
def proto_args(parser, parents):
2-
ldap_parser = parser.add_parser("ldap", help="own stuff using LDAP", parents=parents)
5+
ldap_parser = parser.add_parser("ldap", help="own stuff using LDAP", parents=parents, formatter_class=DisplayDefaultsNotNone)
36
ldap_parser.add_argument("-H", "--hash", metavar="HASH", dest="hash", nargs="+", default=[], help="NTLM hash(es) or file(s) containing NTLM hashes")
4-
ldap_parser.add_argument("--port", type=int, choices={389, 636}, default=389, help="LDAP port (default: 389)")
7+
ldap_parser.add_argument("--port", type=int, choices={389, 636}, default=389, help="LDAP port")
58
ldap_parser.add_argument("--no-smb", action="store_true", help="No smb connection")
69

710
dgroup = ldap_parser.add_mutually_exclusive_group()
@@ -30,7 +33,7 @@ def proto_args(parser, parents):
3033
bgroup = ldap_parser.add_argument_group("Bloodhound Scan", "Options to play with Bloodhoud")
3134
bgroup.add_argument("--bloodhound", action="store_true", help="Perform a Bloodhound scan")
3235
bgroup.add_argument("-ns", "--nameserver", help="Custom DNS IP")
33-
bgroup.add_argument("-c", "--collection", help="Which information to collect. Supported: Group, LocalAdmin, Session, Trusts, Default, DCOnly, DCOM, RDP, PSRemote, LoggedOn, Container, ObjectProps, ACL, All. You can specify more than one by separating them with a comma. (default: Default)'")
36+
bgroup.add_argument("-c", "--collection", default="Collection", help="Which information to collect. Supported: Group, LocalAdmin, Session, Trusts, Default, DCOnly, DCOM, RDP, PSRemote, LoggedOn, Container, ObjectProps, ACL, All. You can specify more than one by separating them with a comma")
3437

3538
return parser
3639

nxc/protocols/mssql/proto_args.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
from nxc.helpers.args import DisplayDefaultsNotNone
2+
3+
14
def proto_args(parser, parents):
2-
mssql_parser = parser.add_parser("mssql", help="own stuff using MSSQL", parents=parents)
5+
mssql_parser = parser.add_parser("mssql", help="own stuff using MSSQL", parents=parents, formatter_class=DisplayDefaultsNotNone)
36
mssql_parser.add_argument("-H", "--hash", metavar="HASH", dest="hash", nargs="+", default=[], help="NTLM hash(es) or file(s) containing NTLM hashes")
4-
mssql_parser.add_argument("--port", default=1433, type=int, metavar="PORT", help="MSSQL port (default: 1433)")
5-
mssql_parser.add_argument("--mssql-timeout", help="SQL server connection timeout, default is %(default)s seconds", type=int, default=5)
7+
mssql_parser.add_argument("--port", default=1433, type=int, metavar="PORT", help="MSSQL port")
8+
mssql_parser.add_argument("--mssql-timeout", help="SQL server connection timeout", type=int, default=5)
69
mssql_parser.add_argument("-q", "--query", dest="mssql_query", metavar="QUERY", type=str, help="execute the specified query against the MSSQL DB")
710

811
dgroup = mssql_parser.add_mutually_exclusive_group()
@@ -21,7 +24,7 @@ def proto_args(parser, parents):
2124
psgroup.add_argument("--clear-obfscripts", action="store_true", help="Clear all cached obfuscated PowerShell scripts")
2225

2326
tgroup = mssql_parser.add_argument_group("Files", "Options for put and get remote files")
24-
tgroup.add_argument("--put-file", nargs=2, metavar=("SRC_FILE", "DEST_FILE"), help="Put a local file into remote target, ex: whoami.txt C:\\Windows\\Temp\\whoami.txt")
25-
tgroup.add_argument("--get-file", nargs=2, metavar=("SRC_FILE", "DEST_FILE"), help="Get a remote file, ex: C:\\Windows\\Temp\\whoami.txt whoami.txt")
27+
tgroup.add_argument("--put-file", nargs=2, metavar=("SRC_FILE", "DEST_FILE"), help="Put a local file into remote target, ex: whoami.txt C:\\\\Windows\\\\Temp\\\\whoami.txt")
28+
tgroup.add_argument("--get-file", nargs=2, metavar=("SRC_FILE", "DEST_FILE"), help="Get a remote file, ex: C:\\\\Windows\\\\Temp\\\\whoami.txt whoami.txt")
2629

2730
return parser

nxc/protocols/rdp/proto_args.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
from nxc.helpers.args import DisplayDefaultsNotNone
2+
3+
14
def proto_args(parser, parents):
2-
rdp_parser = parser.add_parser("rdp", help="own stuff using RDP", parents=parents)
5+
rdp_parser = parser.add_parser("rdp", help="own stuff using RDP", parents=parents, formatter_class=DisplayDefaultsNotNone)
36
rdp_parser.add_argument("-H", "--hash", metavar="HASH", dest="hash", nargs="+", default=[], help="NTLM hash(es) or file(s) containing NTLM hashes")
4-
rdp_parser.add_argument("--port", type=int, default=3389, help="Custom RDP port")
5-
rdp_parser.add_argument("--rdp-timeout", type=int, default=5, help="RDP timeout on socket connection, defalut is %(default)ss")
7+
rdp_parser.add_argument("--port", type=int, default=3389, help="RDP port")
8+
rdp_parser.add_argument("--rdp-timeout", type=int, default=5, help="RDP timeout on socket connection")
69
rdp_parser.add_argument("--nla-screenshot", action="store_true", help="Screenshot RDP login prompt if NLA is disabled")
710

811
dgroup = rdp_parser.add_mutually_exclusive_group()
@@ -11,7 +14,7 @@ def proto_args(parser, parents):
1114

1215
egroup = rdp_parser.add_argument_group("Screenshot", "Remote Desktop Screenshot")
1316
egroup.add_argument("--screenshot", action="store_true", help="Screenshot RDP if connection success")
14-
egroup.add_argument("--screentime", type=int, default=10, help="Time to wait for desktop image, default is %(default)ss")
15-
egroup.add_argument("--res", default="1024x768", help='Resolution in "WIDTHxHEIGHT" format. Default: "1024x768"')
17+
egroup.add_argument("--screentime", type=int, default=10, help="Time to wait for desktop image")
18+
egroup.add_argument("--res", default="1024x768", help="Resolution in WIDTHxHEIGHT format")
1619

1720
return parser

nxc/protocols/ssh/proto_args.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
from argparse import _StoreAction
2+
from nxc.helpers.args import DisplayDefaultsNotNone
3+
24

35
def proto_args(parser, parents):
4-
ssh_parser = parser.add_parser("ssh", help="own stuff using SSH", parents=parents)
6+
ssh_parser = parser.add_parser("ssh", help="own stuff using SSH", parents=parents, formatter_class=DisplayDefaultsNotNone)
57
ssh_parser.add_argument("--key-file", type=str, help="Authenticate using the specified private key. Treats the password parameter as the key's passphrase.")
6-
ssh_parser.add_argument("--port", type=int, default=22, help="SSH port (default: 22)")
7-
ssh_parser.add_argument("--ssh-timeout", help="SSH connection timeout, default is %(default)s secondes", type=int, default=15)
8+
ssh_parser.add_argument("--port", type=int, default=22, help="SSH port")
9+
ssh_parser.add_argument("--ssh-timeout", help="SSH connection timeout", type=int, default=15)
810
sudo_check_arg = ssh_parser.add_argument("--sudo-check", action="store_true", help="Check user privilege with sudo")
9-
sudo_check_method_arg = ssh_parser.add_argument("--sudo-check-method", action=get_conditional_action(_StoreAction), make_required=[], choices={"sudo-stdin", "mkfifo"}, default="sudo-stdin", help="method to do with sudo check, default is '%(default)s (mkfifo is non-stable, probably you need to execute once again if it failed)'")
10-
ssh_parser.add_argument("--get-output-tries", help="Number of times with sudo command tries to get results, default is %(default)s", type=int, default=5)
11+
sudo_check_method_arg = ssh_parser.add_argument("--sudo-check-method", action=get_conditional_action(_StoreAction), make_required=[], choices={"sudo-stdin", "mkfifo"}, default="sudo-stdin", help="method to do with sudo check (mkfifo is non-stable, probably you need to execute once again if it failed)'")
12+
ssh_parser.add_argument("--get-output-tries", type=int, default=5, help="Number of times with sudo command tries to get results")
1113
sudo_check_method_arg.make_required.append(sudo_check_arg)
1214

1315
cgroup = ssh_parser.add_argument_group("Command Execution", "Options for executing commands")
14-
cgroup.add_argument("--codec", default="utf-8",
15-
help="Set encoding used (codec) from the target's output (default "
16-
"'utf-8'). If errors are detected, run chcp.com at the target, "
17-
"map the result with "
18-
"https://docs.python.org/3/library/codecs.html#standard-encodings and then execute "
19-
"again with --codec and the corresponding codec")
16+
cgroup.add_argument("--codec", default="utf-8", help="Set encoding used (codec) from the target's output. If errors are detected, run chcp.com at the target, map the result with https://docs.python.org/3/library/codecs.html#standard-encodings and then execute again with --codec and the corresponding codec")
2017
cgroup.add_argument("--no-output", action="store_true", help="do not retrieve command output")
2118
cgroup.add_argument("-x", metavar="COMMAND", dest="execute", help="execute the specified command")
2219

nxc/protocols/vnc/proto_args.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
from nxc.helpers.args import DisplayDefaultsNotNone
2+
3+
14
def proto_args(parser, parents):
2-
vnc_parser = parser.add_parser("vnc", help="own stuff using VNC", parents=parents)
3-
vnc_parser.add_argument("--port", type=int, default=5900, help="Custom VNC port")
5+
vnc_parser = parser.add_parser("vnc", help="own stuff using VNC", parents=parents, formatter_class=DisplayDefaultsNotNone)
6+
vnc_parser.add_argument("--port", type=int, default=5900, help="VNC port")
47
vnc_parser.add_argument("--vnc-sleep", type=int, default=5, help="VNC Sleep on socket connection to avoid rate limit")
58

69
egroup = vnc_parser.add_argument_group("Screenshot", "VNC Server")

nxc/protocols/winrm/proto_args.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
from nxc.helpers.args import DisplayDefaultsNotNone
2+
3+
14
def proto_args(parser, parents):
2-
winrm_parser = parser.add_parser("winrm", help="own stuff using WINRM", parents=parents)
5+
winrm_parser = parser.add_parser("winrm", help="own stuff using WINRM", parents=parents, formatter_class=DisplayDefaultsNotNone)
36
winrm_parser.add_argument("-H", "--hash", metavar="HASH", dest="hash", nargs="+", default=[], help="NTLM hash(es) or file(s) containing NTLM hashes")
4-
winrm_parser.add_argument("--port", nargs="+", default=["5985", "5986"], help="Custom WinRM port, default is %(default)s, format: 'http-port https-port'(with space separated) or 'single-port'"
5-
"(http & https will use same port when given single port)")
6-
winrm_parser.add_argument("--check-proto", nargs="+", default=["http", "https"], help="Choose what prorocol you want to check, default is %(default)s, format: 'http https'(with space separated) or 'single-protocol'")
7+
winrm_parser.add_argument("--port", nargs="+", default=["5985", "5986"], help="WinRM port - format: 'http-port https-port'(with space separated) or 'single-port' (http & https will use same port when given single port)")
8+
winrm_parser.add_argument("--check-proto", nargs="+", default=["http", "https"], help="Choose what prorocol you want to check - format: 'http https'(with space separated) or 'single-protocol'")
79
winrm_parser.add_argument("--laps", dest="laps", metavar="LAPS", type=str, help="LAPS authentification", nargs="?", const="administrator")
810
winrm_parser.add_argument("--http-timeout", dest="http_timeout", type=int, default=10, help="HTTP timeout for WinRM connections")
911

@@ -17,7 +19,7 @@ def proto_args(parser, parents):
1719
cgroup.add_argument("--lsa", action="store_true", help="dump LSA secrets from target systems")
1820

1921
cgroup = winrm_parser.add_argument_group("Command Execution", "Options for executing commands")
20-
cgroup.add_argument("--codec", default="utf-8", help="Set encoding used (codec) from the target's output (default: utf-8). If errors are detected, run chcp.com at the target & map the result with https://docs.python.org/3/library/codecs.html#standard-encodings and then execute again with --codec and the corresponding codec")
22+
cgroup.add_argument("--codec", default="utf-8", help="Set encoding used (codec) from the target's output. If errors are detected, run chcp.com at the target & map the result with https://docs.python.org/3/library/codecs.html#standard-encodings and then execute again with --codec and the corresponding codec")
2123
cgroup.add_argument("--no-output", action="store_true", help="do not retrieve command output")
2224
cgroup.add_argument("-x", metavar="COMMAND", dest="execute", help="execute the specified command")
2325
cgroup.add_argument("-X", metavar="PS_COMMAND", dest="ps_execute", help="execute the specified PowerShell command")

0 commit comments

Comments
 (0)