@@ -439,6 +439,7 @@ def parseArgs():
439
439
group_targets_source .add_argument ("-ai" , "--auth-dc-ip" , default = None , type = str , help = "IP of the domain controller." )
440
440
group_targets_source .add_argument ("-au" , "--auth-user" , default = None , type = str , help = "Username of the domain account." )
441
441
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." )
442
443
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)" )
443
444
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." )
444
445
@@ -476,9 +477,9 @@ def parseArgs():
476
477
print ("[+] No password of hashes provided and --no-pass is '%s'" % options .no_pass )
477
478
from getpass import getpass
478
479
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 ))
480
481
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 )
482
483
483
484
if options .readable == True or options .writable == True :
484
485
options .check_user_access = True
@@ -636,7 +637,7 @@ def get_machine_name(options, domain):
636
637
s .login ('' , '' )
637
638
except Exception :
638
639
if s .getServerName () == '' :
639
- raise Exception (' Error while anonymous logging into %s' % domain )
640
+ raise Exception (" Error while anonymous logging into %s" % domain )
640
641
else :
641
642
s .logoff ()
642
643
return s .getServerName ()
@@ -758,7 +759,8 @@ def worker(options, target, domain, username, password, lmhash, nthash, results,
758
759
except Exception as err :
759
760
if options .debug :
760
761
lock .acquire ()
761
- print (err )
762
+ if options .debug :
763
+ traceback .print_exc ()
762
764
lock .release ()
763
765
else :
764
766
if options .debug :
@@ -778,51 +780,54 @@ def load_targets(options):
778
780
targets = []
779
781
780
782
# 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
+ )
794
797
795
798
# 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" ])
811
815
812
816
# 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
+ )
826
831
827
832
# Loading targets line by line from a targets file
828
833
if options .targets_file is not None :
@@ -884,6 +889,7 @@ def load_targets(options):
884
889
print ("[debug] Target '%s' was not added." % target )
885
890
886
891
final_targets = sorted (list (set (final_targets )))
892
+
887
893
return final_targets
888
894
889
895
0 commit comments