File tree 1 file changed +87
-0
lines changed
1 file changed +87
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ <documentation>
3
+ <summary>Find weak passwords in sys.sql_logins</summary>
4
+ <returns>1 data set: select query.</returns>
5
+ <issues>No</issues>
6
+ <author>Mitch Wheat</author>
7
+ <created>2019-07-21</created>
8
+ <modified>2019-08-16 by Konstantin Taranov</modified>
9
+ <version>1.1</version>
10
+ <sourceLink>https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Find_Weak_Passwords.sql</sourceLink>
11
+ <originalLink>https://mitchwheat.com/2019/07/21/sql-server-security-find-users-with-weak-passwords/</originalLink>
12
+ </documentation>
13
+ */
14
+
15
+ SET NOCOUNT ON ;
16
+
17
+ IF OBJECT_ID(' tempdb..#CommonPasswords' ) IS NOT NULL
18
+ DROP TABLE # CommonPasswords;
19
+
20
+ CREATE TABLE # CommonPasswords(Password varchar(30) not null primary key);
21
+
22
+ INSERT INTO # CommonPasswords(Password) VALUES
23
+ (' ' ),
24
+ (' 123' ),
25
+ (' 1234' ),
26
+ (' 12345' ),
27
+ (' 123456' ),
28
+ (' 1234567' ),
29
+ (' 12345678' ),
30
+ (' 123456789' ),
31
+ (' 1234567890' ),
32
+ (' qwerty' ),
33
+ (' qwerty123' ),
34
+ (' password' ),
35
+ (' password1' ),
36
+ (' password123' ),
37
+ (' 111111' ),
38
+ (' 1111111' ),
39
+ (' abc123' ),
40
+ (' 666666' ),
41
+ (' 7777777' ),
42
+ (' 654321' ),
43
+ (' 123123' ),
44
+ (' 123321' ),
45
+ (' iloveyou' ),
46
+ (' admin' ),
47
+ (' nimda' ),
48
+ (' welcome' ),
49
+ (' !@#$%^&*' ),
50
+ (' aa123456' ),
51
+ (' sunshine' ),
52
+ (' princess' ),
53
+ (' football' ),
54
+ (' monkey' ),
55
+ (' charlie' ),
56
+ (' donald' ),
57
+ (' dragon' ),
58
+ (' passw0rd' ),
59
+ (' trustno1' ),
60
+ (' letmein' ),
61
+ (' whatever' ),
62
+ (' hello' ),
63
+ (' freedom' ),
64
+ (' master' ),
65
+ (' starwars' ),
66
+ (' qwertyuiop' ),
67
+ (' qazwsx' ),
68
+ (' login' );
69
+
70
+ SELECT
71
+ name,
72
+ create_date,
73
+ is_disabled
74
+ FROM
75
+ sys .sql_logins sl (nolock)
76
+ cross apply # CommonPasswords cp
77
+ WHERE
78
+ PWDCOMPARE(cp .Password , sl .password_hash ) = 1
79
+ UNION ALL
80
+ SELECT
81
+ name,
82
+ create_date,
83
+ is_disabled
84
+ FROM
85
+ sys .sql_logins sl (nolock)
86
+ WHERE
87
+ PWDCOMPARE(sl .name , sl .password_hash ) = 1 ; -- password same as username
You can’t perform that action at this time.
0 commit comments