Skip to content

Commit 753e277

Browse files
committed
Release 3.2
1 parent a2b5786 commit 753e277

File tree

1 file changed

+51
-45
lines changed

1 file changed

+51
-45
lines changed

FindUncommonShares.py

Lines changed: 51 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ def parseArgs():
439439
group_targets_source.add_argument("-ai", "--auth-dc-ip", default=None, type=str, help="IP of the domain controller.")
440440
group_targets_source.add_argument("-au", "--auth-user", default=None, type=str, help="Username of the domain account.")
441441
group_targets_source.add_argument("--ldaps", default=False, action="store_true", help="Use LDAPS (default: False)")
442+
group_targets_source.add_argument("--no-ldap", default=False, action="store_true", help="Do not perform LDAP queries.")
442443
group_targets_source.add_argument("--subnets", default=False, action="store_true", help="Get all subnets from the domain and use them as targets (default: False)")
443444
group_targets_source.add_argument("-tl", "--target-ldap-query", dest="target_ldap_query", type=str, default=None, required=False, help="LDAP query to use to extract computers from the domain.")
444445

@@ -476,9 +477,9 @@ def parseArgs():
476477
print("[+] No password of hashes provided and --no-pass is '%s'" % options.no_pass)
477478
from getpass import getpass
478479
if options.auth_domain is not None:
479-
options.auth_password = getpass(" | Provide a password for '%s\\%s':" % (options.auth_domain, options.auth_username))
480+
options.auth_password = getpass(" | Provide a password for '%s\\%s':" % (options.auth_domain, options.auth_user))
480481
else:
481-
options.auth_password = getpass(" | Provide a password for '%s':" % options.auth_username)
482+
options.auth_password = getpass(" | Provide a password for '%s':" % options.auth_user)
482483

483484
if options.readable == True or options.writable == True:
484485
options.check_user_access = True
@@ -636,7 +637,7 @@ def get_machine_name(options, domain):
636637
s.login('', '')
637638
except Exception:
638639
if s.getServerName() == '':
639-
raise Exception('Error while anonymous logging into %s' % domain)
640+
raise Exception("Error while anonymous logging into %s" % domain)
640641
else:
641642
s.logoff()
642643
return s.getServerName()
@@ -758,7 +759,8 @@ def worker(options, target, domain, username, password, lmhash, nthash, results,
758759
except Exception as err:
759760
if options.debug:
760761
lock.acquire()
761-
print(err)
762+
if options.debug:
763+
traceback.print_exc()
762764
lock.release()
763765
else:
764766
if options.debug:
@@ -778,51 +780,54 @@ def load_targets(options):
778780
targets = []
779781

780782
# Loading targets from domain computers
781-
if options.auth_dc_ip is not None and options.auth_user is not None and (options.auth_password is not None or options.auth_hashes is not None) and options.target_ldap_query is None:
782-
if options.debug:
783-
print("[debug] Loading targets from computers in the domain '%s'" % options.auth_domain)
784-
targets += get_computers_from_domain(
785-
auth_domain=options.auth_domain,
786-
auth_dc_ip=options.auth_dc_ip,
787-
auth_username=options.auth_user,
788-
auth_password=options.auth_password,
789-
auth_hashes=options.auth_hashes,
790-
auth_key=None,
791-
use_ldaps=options.ldaps,
792-
__print=False
793-
)
783+
if not options.no_ldap:
784+
if options.auth_dc_ip is not None and options.auth_user is not None and (options.auth_password is not None or options.auth_hashes is not None) and options.target_ldap_query is None:
785+
if options.debug:
786+
print("[debug] Loading targets from computers in the domain '%s'" % options.auth_domain)
787+
targets += get_computers_from_domain(
788+
auth_domain=options.auth_domain,
789+
auth_dc_ip=options.auth_dc_ip,
790+
auth_username=options.auth_user,
791+
auth_password=options.auth_password,
792+
auth_hashes=options.auth_hashes,
793+
auth_key=None,
794+
use_ldaps=options.ldaps,
795+
__print=False
796+
)
794797

795798
# Loading targets from domain computers
796-
if options.auth_dc_ip is not None and options.auth_user is not None and (options.auth_password is not None or options.auth_hashes is not None) and options.target_ldap_query is not None:
797-
if options.debug:
798-
print("[debug] Loading targets from specfic LDAP query '%s'" % options.target_ldap_query)
799-
computers = raw_ldap_query(
800-
auth_domain=options.auth_domain,
801-
auth_dc_ip=options.auth_dc_ip,
802-
auth_username=options.auth_username,
803-
auth_password=options.auth_password,
804-
auth_hashes=options.auth_hashes,
805-
query=options.target_ldap_query,
806-
use_ldaps=options.use_ldaps,
807-
attributes=["dNSHostName"]
808-
)
809-
for _, computer in computers:
810-
targets.append(computer["dNSHostName"])
799+
if not options.no_ldap:
800+
if options.auth_dc_ip is not None and options.auth_user is not None and (options.auth_password is not None or options.auth_hashes is not None) and options.target_ldap_query is not None:
801+
if options.debug:
802+
print("[debug] Loading targets from specfic LDAP query '%s'" % options.target_ldap_query)
803+
computers = raw_ldap_query(
804+
auth_domain=options.auth_domain,
805+
auth_dc_ip=options.auth_dc_ip,
806+
auth_username=options.auth_username,
807+
auth_password=options.auth_password,
808+
auth_hashes=options.auth_hashes,
809+
query=options.target_ldap_query,
810+
use_ldaps=options.use_ldaps,
811+
attributes=["dNSHostName"]
812+
)
813+
for _, computer in computers:
814+
targets.append(computer["dNSHostName"])
811815

812816
# Loading targets from subnetworks of the domain
813-
if options.subnets and options.auth_dc_ip is not None and options.auth_user is not None and (options.auth_password is not None or options.auth_hashes is not None):
814-
if options.debug:
815-
print("[debug] Loading targets from subnetworks of the domain '%s'" % options.auth_domain)
816-
targets += get_subnets(
817-
auth_domain=options.auth_domain,
818-
auth_dc_ip=options.auth_dc_ip,
819-
auth_username=options.auth_user,
820-
auth_password=options.auth_password,
821-
auth_hashes=options.auth_hashes,
822-
auth_key=None,
823-
use_ldaps=options.ldaps,
824-
__print=True
825-
)
817+
if not options.no_ldap:
818+
if options.subnets and options.auth_dc_ip is not None and options.auth_user is not None and (options.auth_password is not None or options.auth_hashes is not None):
819+
if options.debug:
820+
print("[debug] Loading targets from subnetworks of the domain '%s'" % options.auth_domain)
821+
targets += get_subnets(
822+
auth_domain=options.auth_domain,
823+
auth_dc_ip=options.auth_dc_ip,
824+
auth_username=options.auth_user,
825+
auth_password=options.auth_password,
826+
auth_hashes=options.auth_hashes,
827+
auth_key=None,
828+
use_ldaps=options.ldaps,
829+
__print=True
830+
)
826831

827832
# Loading targets line by line from a targets file
828833
if options.targets_file is not None:
@@ -884,6 +889,7 @@ def load_targets(options):
884889
print("[debug] Target '%s' was not added." % target)
885890

886891
final_targets = sorted(list(set(final_targets)))
892+
887893
return final_targets
888894

889895

0 commit comments

Comments
 (0)