Skip to content

Commit c699c6d

Browse files
authored
Merge pull request Pennyw0rth#291 from Pennyw0rth/neff-jitter
Change jitter option to throttle authentications
2 parents 0cf9d72 + f0b2d39 commit c699c6d

4 files changed

Lines changed: 22 additions & 14 deletions

File tree

nxc/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def gen_cli_args():
4646

4747
parser.add_argument("-t", type=int, dest="threads", default=256, help="set how many concurrent threads to use (default: 256)")
4848
parser.add_argument("--timeout", default=None, type=int, help="max timeout in seconds of each thread (default: None)")
49-
parser.add_argument("--jitter", metavar="INTERVAL", type=str, help="sets a random delay between each connection (default: None)")
49+
parser.add_argument("--jitter", metavar="INTERVAL", type=str, help="sets a random delay between each authentication (default: None)")
5050
parser.add_argument("--no-progress", action="store_true", help="Not displaying progress bar during scan")
5151
parser.add_argument("--verbose", action="store_true", help="enable verbose output")
5252
parser.add_argument("--debug", action="store_true", help="enable debug level information")

nxc/connection.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,6 @@ def __init__(self, args, db, host):
108108
self.logger.info(f"Error resolving hostname {self.hostname}: {e}")
109109
return
110110

111-
if args.jitter:
112-
jitter = args.jitter
113-
if "-" in jitter:
114-
start, end = jitter.split("-")
115-
jitter = (int(start), int(end))
116-
else:
117-
jitter = (0, int(jitter))
118-
119-
value = random.choice(range(jitter[0], jitter[1]))
120-
self.logger.debug(f"Doin' the jitterbug for {value} second(s)")
121-
sleep(value)
122-
123111
try:
124112
self.proto_flow()
125113
except Exception as e:
@@ -388,7 +376,9 @@ def parse_credentials(self):
388376
return domain, username, owned, secret, cred_type, [None] * len(secret)
389377

390378
def try_credentials(self, domain, username, owned, secret, cred_type, data=None):
391-
"""Try to login using the specified credentials and protocol.
379+
"""
380+
Try to login using the specified credentials and protocol.
381+
With --jitter an authentication throttle can be applied.
392382
393383
Possible login methods are:
394384
- plaintext (/kerberos)
@@ -401,6 +391,18 @@ def try_credentials(self, domain, username, owned, secret, cred_type, data=None)
401391
return False
402392
if hasattr(self.args, "delegate") and self.args.delegate:
403393
self.args.kerberos = True
394+
395+
if self.args.jitter:
396+
jitter = self.args.jitter
397+
if "-" in jitter:
398+
start, end = jitter.split("-")
399+
jitter = (int(start), int(end))
400+
else:
401+
jitter = (0, int(jitter))
402+
value = jitter[0] if jitter[0] == jitter[1] else random.choice(range(jitter[0], jitter[1]))
403+
self.logger.debug(f"Throttle authentications: sleeping {value} second(s)")
404+
sleep(value)
405+
404406
with sem:
405407
if cred_type == "plaintext":
406408
if self.args.kerberos:

nxc/netexec.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ def main():
214214
if ans.lower() not in ["y", "yes", ""]:
215215
exit(1)
216216

217+
if args.jitter and len(targets) > 1:
218+
nxc_logger.highlight(highlight("[!] Jitter is only throttling authentications per target!", "red"))
219+
217220
try:
218221
asyncio.run(start_run(protocol_object, args, db, targets))
219222
except KeyboardInterrupt:

tests/e2e_commands.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -x whoami
2323
netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -X whoami
2424
netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -X whoami --obfs
2525
netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS --wmi "select Name from win32_computersystem"
26+
netexec --jitter 2 smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS
27+
netexec --jitter 1-3 smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS
28+
netexec --jitter 2-2 smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS
2629
##### SMB Modules
2730
netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -L
2831
netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M add-computer --options

0 commit comments

Comments
 (0)