Update ldap.py for --dc-list flag
parent
1c0340a1e8
commit
63749ea29b
|
@ -827,30 +827,23 @@ class ldap(connection):
|
|||
search_filter = "(&(objectCategory=computer)(primaryGroupId=516))"
|
||||
attributes = ["dNSHostName"]
|
||||
resp = self.search(search_filter, attributes, 0)
|
||||
if resp:
|
||||
answers = []
|
||||
self.logger.debug(f"Total of records returned {len(resp):d}")
|
||||
for item in resp:
|
||||
if isinstance(item, ldapasn1_impacket.SearchResultEntry) is not True:
|
||||
continue
|
||||
name = ""
|
||||
try:
|
||||
|
||||
for attribute in item["attributes"]:
|
||||
if str(attribute["type"]) == "dNSHostName":
|
||||
name = str(attribute["vals"][0])
|
||||
try:
|
||||
ip_address = socket.gethostbyname(name.split(".")[0])
|
||||
if ip_address != True and name != "":
|
||||
self.logger.highlight(f"{name} =", ip_address)
|
||||
except socket.gaierror:
|
||||
self.logger.fail(f"{name} = Connection timeout")
|
||||
except Exception as e:
|
||||
self.logger.fail("Exception:", exc_info=True)
|
||||
self.logger.fail(f"Skipping item, cannot process due to error {e}")
|
||||
pass
|
||||
return
|
||||
|
||||
for item in resp:
|
||||
if isinstance(item, ldapasn1_impacket.SearchResultEntry) is not True:
|
||||
continue
|
||||
name = ""
|
||||
try:
|
||||
for attribute in item["attributes"]:
|
||||
if str(attribute["type"]) == "dNSHostName":
|
||||
name = str(attribute["vals"][0])
|
||||
try:
|
||||
ip_address = socket.gethostbyname(name.split(".")[0])
|
||||
if ip_address != True and name != "":
|
||||
self.logger.highlight(f"{name} =", ip_address)
|
||||
except socket.gaierror:
|
||||
self.logger.fail(f"{name} = Connection timeout")
|
||||
except Exception as e:
|
||||
self.logger.fail("Exception:", exc_info=True)
|
||||
self.logger.fail(f"Skipping item, cannot process due to error {e}")
|
||||
|
||||
def asreproast(self):
|
||||
if self.password == "" and self.nthash == "" and self.kerberos is False:
|
||||
|
|
Loading…
Reference in New Issue