From 352d1db8b5ed356b0ce9e3d21e71f042507e6e82 Mon Sep 17 00:00:00 2001
From: Jordan Borean <jborean93@gmail.com>
Date: Thu, 25 Mar 2021 15:14:32 +1000
Subject: [PATCH] Added WrongPassword exception (#84)

---
 CHANGELOG.md              | 1 +
 smbprotocol/exceptions.py | 5 +++++
 smbprotocol/header.py     | 1 +
 3 files changed, 7 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9e89b85..36d3d97 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,7 @@
 ## 1.5.0 - TBD
 
 * Added `smbprotocol.exceptions.SMBConnectionClosed` that is raised when trying to send or receive data on a connection that has been closed
+* Added `smbprotocol.exceptions.WrongPassword` that is raised when some servers indicate the password is not correct or the account is locked out
 * Do not attempt to reuse any cached connections that have been closed in `smbclient`
 * Added a lock when writing to the socket, only 1 thread can write a message at a single point in time
 * Revamped the SMB receiver code to simplify the logic and make it more durable
diff --git a/smbprotocol/exceptions.py b/smbprotocol/exceptions.py
index 1bac3aa..752d06d 100644
--- a/smbprotocol/exceptions.py
+++ b/smbprotocol/exceptions.py
@@ -438,6 +438,11 @@ class PrivilegeNotHeld(SMBResponseException):
     _STATUS_CODE = NtStatus.STATUS_PRIVILEGE_NOT_HELD
 
 
+class WrongPassword(SMBResponseException):
+    _BASE_MESSAGE = "The specified password is not correct or the user is locked out."
+    _STATUS_CODE = NtStatus.STATUS_WRONG_PASSWORD
+
+
 class LogonFailure(SMBResponseException):
     _BASE_MESSAGE = "The attempted logon is invalid. This is either due to a bad username or authentication " \
                     "information."
diff --git a/smbprotocol/header.py b/smbprotocol/header.py
index bbae26d..5950a44 100644
--- a/smbprotocol/header.py
+++ b/smbprotocol/header.py
@@ -87,6 +87,7 @@ class NtStatus(object):
     STATUS_NO_EAS_ON_FILE = 0xC0000052
     STATUS_EA_CORRUPT_ERROR = 0xC0000053
     STATUS_PRIVILEGE_NOT_HELD = 0xC0000061
+    STATUS_WRONG_PASSWORD = 0xC000006A
     STATUS_LOGON_FAILURE = 0xC000006D
     STATUS_PASSWORD_EXPIRED = 0xC0000071
     STATUS_INSUFFICIENT_RESOURCES = 0xC000009A
-- 
GitLab