aboutsummaryrefslogtreecommitdiff
path: root/db_passwords/sql/get_data.sql
diff options
context:
space:
mode:
authorChristian Cleberg <156287552+ccleberg@users.noreply.github.com>2024-10-25 16:56:51 +0000
committerGitHub <noreply@github.com>2024-10-25 16:57:36 +0000
commitb871e5a3197c8176e3bfe416368b1ff70192cc99 (patch)
tree5beadfcb0f8c69524aa6527dd941d2aaeba6a6d6 /db_passwords/sql/get_data.sql
parent50e5f6fd4c8200fe3cc54f01d80a35b8f023f09e (diff)
downloadaudit-tools-b871e5a3197c8176e3bfe416368b1ff70192cc99.tar.gz
audit-tools-b871e5a3197c8176e3bfe416368b1ff70192cc99.tar.bz2
audit-tools-b871e5a3197c8176e3bfe416368b1ff70192cc99.zip
add SQL database password test
Diffstat (limited to 'db_passwords/sql/get_data.sql')
-rw-r--r--db_passwords/sql/get_data.sql30
1 files changed, 30 insertions, 0 deletions
diff --git a/db_passwords/sql/get_data.sql b/db_passwords/sql/get_data.sql
new file mode 100644
index 0000000..b5bef36
--- /dev/null
+++ b/db_passwords/sql/get_data.sql
@@ -0,0 +1,30 @@
+/*
+References:
+1. https://learn.microsoft.com/en-us/sql/relational-databases/security/password-policy
+2. https://learn.microsoft.com/en-us/sql/t-sql/functions/loginproperty-transact-sql
+*/
+
+SELECT
+ name,
+ principal_id,
+ sid,
+ type,
+ type_desc,
+ is_disabled,
+ create_date,
+ modify_date,
+ default_database_name,
+ default_language_name,
+ credential_id,
+ is_policy_checked,
+ is_expiration_checked,
+ password_hash,
+ LOGINPROPERTY(name, 'IsMustChange') AS IsMustChange,
+ LOGINPROPERTY(name, 'IsLocked') AS IsLocked,
+ LOGINPROPERTY(name, 'LockoutTime') AS LockoutTime,
+ LOGINPROPERTY(name, 'PasswordLastSetTime') AS PasswordLastSetTime,
+ LOGINPROPERTY(name, 'IsExpired') AS IsExpired,
+ LOGINPROPERTY(name, 'BadPasswordCount') AS BadPasswordCount,
+ LOGINPROPERTY(name, 'BadPasswordTime') AS BadPasswordTime,
+ LOGINPROPERTY(name, 'HistoryLength') AS HistoryLength
+FROM sys.sql_logins;