From 263b0ac92494247b2b3aab19671bb1a78a45acce Mon Sep 17 00:00:00 2001 From: Lucas Vater Date: Thu, 5 May 2022 13:53:27 +0200 Subject: [PATCH 1/2] Handle unknown NTSTATUS in SessionError --- impacket/smb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/impacket/smb.py b/impacket/smb.py index fd3b1b1a2d..c13c173343 100644 --- a/impacket/smb.py +++ b/impacket/smb.py @@ -578,7 +578,7 @@ def __str__( self ): error_code_str = '%s(%s)' % error_code if self.nt_status: - return 'SMB SessionError: %s(%s)' % nt_errors.ERROR_MESSAGES[self.error_code] + return 'SMB SessionError: %s(%s)' % nt_errors.ERROR_MESSAGES.get(self.error_code, ("UNKNOWN_NTSTATUS", self.error_code)) else: # Fall back to the old format return 'SMB SessionError: class: %s, code: %s' % (error_class_str, error_code_str) From 493077fc9b89aa9f2ac5c72e29a3f349c9467d50 Mon Sep 17 00:00:00 2001 From: Lucas Vater Date: Wed, 11 Oct 2023 16:42:02 +0200 Subject: [PATCH 2/2] Handle unknown NTSTATUS in other places --- impacket/krb5/kerberosv5.py | 10 ++++++++-- impacket/smb.py | 8 +++++++- impacket/smbconnection.py | 11 +++++++---- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/impacket/krb5/kerberosv5.py b/impacket/krb5/kerberosv5.py index 7c66a93d87..5308b4b28a 100644 --- a/impacket/krb5/kerberosv5.py +++ b/impacket/krb5/kerberosv5.py @@ -699,7 +699,7 @@ def getErrorPacket( self ): return self.packet def getErrorString( self ): - return constants.ERROR_MESSAGES[self.error] + return str(self) def __str__( self ): retString = 'Kerberos SessionError: %s(%s)' % (constants.ERROR_MESSAGES[self.error]) @@ -708,7 +708,13 @@ def __str__( self ): if self.error == constants.ErrorCodes.KRB_ERR_GENERIC.value: eData = decoder.decode(self.packet['e-data'], asn1Spec = KERB_ERROR_DATA())[0] nt_error = struct.unpack('