Skip to content

Commit 5eb00ba

Browse files
authored
SPNEGO.from_cli_arguments: don't ask for password when unrequired (#4839)
1 parent befe516 commit 5eb00ba

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

scapy/layers/spnego.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,7 @@ def from_cli_arguments(
669669
if not valid_ip(target):
670670
hostname = target
671671
target = str(Net(target))
672+
672673
# Check UPN
673674
try:
674675
_, realm = _parse_upn(UPN)
@@ -678,12 +679,23 @@ def from_cli_arguments(
678679
except ValueError:
679680
# not a UPN: NTLM only
680681
kerberos = False
682+
681683
# Do we need to ask the password?
682-
if HashNt is None and password is None and ST is None:
684+
if all(
685+
x is None
686+
for x in [
687+
ST,
688+
password,
689+
HashNt,
690+
HashAes256Sha96,
691+
HashAes128Sha96,
692+
]
693+
):
683694
# yes.
684695
from prompt_toolkit import prompt
685696

686697
password = prompt("Password: ", is_password=True)
698+
687699
ssps = []
688700
# Kerberos
689701
if kerberos and hostname:
@@ -731,11 +743,13 @@ def from_cli_arguments(
731743
"Kerberos required but domain not specified in the UPN, "
732744
"or target isn't a hostname !"
733745
)
746+
734747
# NTLM
735748
if not kerberos_required:
736749
if HashNt is None and password is not None:
737750
HashNt = MD4le(password)
738751
ssps.append(NTLMSSP(UPN=UPN, HASHNT=HashNt))
752+
739753
# Build the SSP
740754
return cls(ssps)
741755

0 commit comments

Comments
 (0)