From 6da074e73b33719817edf5406d8a4e56ee09bf71 Mon Sep 17 00:00:00 2001 From: Marshall Hallenbeck Date: Sat, 22 Apr 2023 13:48:07 -0400 Subject: [PATCH] update f-strings --- cme/protocols/ldap.py | 12 ++++++------ cme/protocols/smb.py | 10 +++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cme/protocols/ldap.py b/cme/protocols/ldap.py index fd746c2f..0efae0d5 100644 --- a/cme/protocols/ldap.py +++ b/cme/protocols/ldap.py @@ -326,7 +326,7 @@ class ldap(connection): self.logger.extra["protocol"] = "SMB" if not self.no_ntlm else "LDAP" self.logger.extra["port"] = "445" if not self.no_ntlm else "389" self.logger.display( - f"{self.server_os}{' x{}'.format(self.os_arch) if self.os_arch else ''} (name:{self.hostname}) (domain:{self.domain}) (signing:{self.signing}) (SMBv1:{self.smbv1})" + f"{self.server_os}{f' x{self.os_arch}' if self.os_arch else ''} (name:{self.hostname}) (domain:{self.domain}) (signing:{self.signing}) (SMBv1:{self.smbv1})" ) self.logger.extra["protocol"] = "LDAP" # self.logger.display(self.endpoint) @@ -449,7 +449,7 @@ class ldap(connection): self.check_if_admin() # Prepare success credential text - out = f"{domain}\\{self.username} {highlight('({})'.format(self.config.get('CME', 'pwn3d_label')) if self.admin_privs else '')}" + out = f"{domain}\\{self.username} {highlight(f'({self.config.get("CME", "pwn3d_label")})' if self.admin_privs else '')}" self.logger.extra["protocol"] = "LDAPS" self.logger.extra["port"] = "636" @@ -504,7 +504,7 @@ class ldap(connection): self.check_if_admin() # Prepare success credential text - out = f"{domain}\\{self.username}:{self.password if not self.config.get('CME', 'audit_mode') else self.config.get('CME', 'audit_mode') * 8} {highlight('({})'.format(self.config.get('CME', 'pwn3d_label')) if self.admin_privs else '')}" + out = f"{domain}\\{self.username}:{self.password if not self.config.get('CME', 'audit_mode') else self.config.get('CME', 'audit_mode') * 8} {highlight(f'({self.config.get("CME", "pwn3d_label")})' if self.admin_privs else '')}" self.logger.extra["protocol"] = "LDAP" self.logger.extra["port"] = "636" if (self.args.gmsa or self.args.port == 636) else "389" @@ -526,7 +526,7 @@ class ldap(connection): self.check_if_admin() # Prepare success credential text - out = f"{domain}\\{self.username}:{self.password if not self.config.get('CME', 'audit_mode') else self.config.get('CME', 'audit_mode') * 8} {highlight('({})'.format(self.config.get('CME', 'pwn3d_label')) if self.admin_privs else '')}" + out = f"{domain}\\{self.username}:{self.password if not self.config.get('CME', 'audit_mode') else self.config.get('CME', 'audit_mode') * 8} {highlight(f'({self.config.get("CME", "pwn3d_label")})' if self.admin_privs else '')}" self.logger.extra["protocol"] = "LDAPS" self.logger.extra["port"] = "636" self.logger.success(out) @@ -593,7 +593,7 @@ class ldap(connection): self.check_if_admin() # Prepare success credential text - out = f"{domain}\\{self.username}:{self.nthash if not self.config.get('CME', 'audit_mode') else self.config.get('CME', 'audit_mode') * 8} {highlight('({})'.format(self.config.get('CME', 'pwn3d_label')) if self.admin_privs else '')}" + out = f"{domain}\\{self.username}:{self.nthash if not self.config.get('CME', 'audit_mode') else self.config.get('CME', 'audit_mode') * 8} {highlight(f'({self.config.get("CME", "pwn3d_label")})' if self.admin_privs else '')}" self.logger.extra["protocol"] = "LDAP" self.logger.extra["port"] = "636" if (self.args.gmsa or self.args.port == 636) else "389" self.logger.success(out) @@ -613,7 +613,7 @@ class ldap(connection): self.check_if_admin() # Prepare success credential text - out = f"{domain}\\{self.username}:{self.nthash if not self.config.get('CME', 'audit_mode') else self.config.get('CME', 'audit_mode') * 8} {highlight('({})'.format(self.config.get('CME', 'pwn3d_label')) if self.admin_privs else '')}" + out = f"{domain}\\{self.username}:{self.nthash if not self.config.get('CME', 'audit_mode') else self.config.get('CME', 'audit_mode') * 8} {highlight(f'({self.config.get("CME", "pwn3d_label")})' if self.admin_privs else '')}" self.logger.extra["protocol"] = "LDAPS" self.logger.extra["port"] = "636" self.logger.success(out) diff --git a/cme/protocols/smb.py b/cme/protocols/smb.py index 251ede28..46b6c742 100755 --- a/cme/protocols/smb.py +++ b/cme/protocols/smb.py @@ -403,9 +403,11 @@ class smb(connection): msMCSAdmPwd = values['ms-mcs-admpwd'] else: self.logger.fail("No result found with attribute ms-MCS-AdmPwd or msLAPS-Password") - logging.debug("Host: {:<20} Password: {} {}".format(sAMAccountName, msMCSAdmPwd, self.hostname)) + logging.debug(f"Host: {sAMAccountName:<20} Password: {msMCSAdmPwd} {self.hostname}") else: - self.logger.fail('msMCSAdmPwd or msLAPS-Password is empty or account cannot read LAPS property for {}'.format(self.hostname)) + self.logger.fail( + f'msMCSAdmPwd or msLAPS-Password is empty or account cannot read LAPS property for {self.hostname}' + ) return False @@ -413,7 +415,9 @@ class smb(connection): self.password = msMCSAdmPwd if msMCSAdmPwd == '': - self.logger.fail('msMCSAdmPwd or msLAPS-Password is empty or account cannot read LAPS property for {}'.format(self.hostname)) + self.logger.fail( + f'msMCSAdmPwd or msLAPS-Password is empty or account cannot read LAPS property for {self.hostname}' + ) return False if ntlm_hash: