Skip to content

Commit

Permalink
Add hash-based authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
clubby789 committed Jul 15, 2021
1 parent 17bccbe commit bafa6fe
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion wsshuttle/cmdline.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import getpass
import re

from .listener import WsshuttleListener

Expand All @@ -15,7 +16,23 @@ def main() -> int:
parser.add_argument("-m", "--mask", required=True)
args = parser.parse_args()

if args.password is None and args.hash is None:
if args.hash and args.password:
print("Only one of --hash and --password may be specified")
return -1

if args.hash is not None:
ntlm = args.hash.lower()
if re.match("[a-z0-9]{32}"):
args.password = "0" * 32 + ":" + ntlm
elif re.match(":[a-z0-9]{32}"):
args.password = "0" * 32 + ntlm
elif re.match("[a-z0-9]{32}:[a-z0-9]{32}"):
args.password = ntlm
else:
print("Invalid hash format")
return -1

if args.password is None:
args.password = getpass.getpass()

listener = WsshuttleListener(username=args.username, password=args.password,
Expand Down

0 comments on commit bafa6fe

Please sign in to comment.