Skip to content

Commit

Permalink
Add option to use getpass to provide password preventing leakage to c…
Browse files Browse the repository at this point in the history
…onsole (#10)

LGTM
  • Loading branch information
stephenbradshaw authored Jul 30, 2024
1 parent 6fb4e3b commit 6f95ce0
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions polenum.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import argparse
import sys
import re
import getpass


def d2b(a):
Expand Down Expand Up @@ -84,21 +85,27 @@ class SAMRDump:
}

def __init__(self, protocols=None,
username='', password=''):
username='', password='', hidepwd=False):
if not protocols:
protocols = list(SAMRDump.KNOWN_PROTOCOLS.keys())

self.__username = username
self.__password = password
self.__protocols = protocols
self.__hidepwd = hidepwd

def dump(self, addr):
"""Dumps the list of users and shares registered present at
addr. Addr is a valid host name or IP address.
"""

print('\n')
if (self.__username and self.__password):
if (self.__username and self.__password and self.__hidepwd):
print('[+] Attaching to {0} using {1}:{2}'.format(addr,
self.__username,
len(self.__password) * '*'))

elif (self.__username and self.__password and not self.__hidepwd):
print('[+] Attaching to {0} using {1}:{2}'.format(addr,
self.__username,
self.__password))
Expand Down Expand Up @@ -262,6 +269,7 @@ def main():
user = args.username
passw = args.password
target = args.domain
hidepwd = False

if args.enum4linux:
enum4linux_regex = re.compile('(?:([^@:]*)(?::([^@]*))?@)?(.*)')
Expand All @@ -270,10 +278,14 @@ def main():
passw = passw + '@' + target.rpartition('@')[0]
target = target.rpartition('@')[2]

if not passw:
hidepwd = True
passw = getpass.getpass()

if args.protocols:
dumper = SAMRDump(args.protocols, user, passw)
dumper = SAMRDump(args.protocols, user, passw, hidepwd=hidepwd)
else:
dumper = SAMRDump(username=user, password=passw)
dumper = SAMRDump(username=user, password=passw, hidepwd=hidepwd)

try:
dumper.dump(target)
Expand Down

0 comments on commit 6f95ce0

Please sign in to comment.