1
00:00:00,020 --> 00:00:00,930
In this lesson,

2
00:00:00,930 --> 00:00:04,110
we're going to cover the Basics of Increasing Hash Security.

3
00:00:04,110 --> 00:00:06,600
Now, before we talk about how to increase hash security,

4
00:00:06,600 --> 00:00:08,880
we probably should focus first on two common types

5
00:00:08,880 --> 00:00:11,310
of hashing attacks that are used by threat actors.

6
00:00:11,310 --> 00:00:14,370
These are the Pass-the-Hash-Attack and the birthday attack.

7
00:00:14,370 --> 00:00:16,890
Now, first we have the Pass-the-Hash-Attack.

8
00:00:16,890 --> 00:00:19,560
Hashing is a commonly used method of storing passwords

9
00:00:19,560 --> 00:00:22,410
inside of our systems, and therefore, if the hash digest

10
00:00:22,410 --> 00:00:24,480
or hash value of that password can be obtained

11
00:00:24,480 --> 00:00:25,410
by an attacker,

12
00:00:25,410 --> 00:00:26,790
they can try to break into your network

13
00:00:26,790 --> 00:00:28,740
using those hash credentials.

14
00:00:28,740 --> 00:00:31,350
Now, the Pass-the-Hash-Attack is a hacking technique

15
00:00:31,350 --> 00:00:33,750
that allows you an attacker to authenticate to remote server

16
00:00:33,750 --> 00:00:35,970
or service by using the underlying hash

17
00:00:35,970 --> 00:00:37,080
of a user's password

18
00:00:37,080 --> 00:00:39,600
instead of actually associating the plain text password

19
00:00:39,600 --> 00:00:41,640
that you normally have to log in with.

20
00:00:41,640 --> 00:00:43,620
Now, if an attacker is able to sniff that hash

21
00:00:43,620 --> 00:00:44,880
or steal it some other way,

22
00:00:44,880 --> 00:00:46,710
they don't actually need to brute force the hash

23
00:00:46,710 --> 00:00:48,600
to try and get that clear text password

24
00:00:48,600 --> 00:00:50,310
of your giving user account.

25
00:00:50,310 --> 00:00:52,770
Instead, the attacker can simply reuse the hash

26
00:00:52,770 --> 00:00:54,330
of that arbitrary user account

27
00:00:54,330 --> 00:00:56,820
as they go and authenticate against the remote system

28
00:00:56,820 --> 00:00:59,400
and they can then impersonate the user that way.

29
00:00:59,400 --> 00:01:01,650
In other words, from an attacker's perspective,

30
00:01:01,650 --> 00:01:04,140
hashes are functioning equivalent to the original password

31
00:01:04,140 --> 00:01:05,099
that they generated,

32
00:01:05,099 --> 00:01:05,933
and this means they don't

33
00:01:05,933 --> 00:01:07,620
actually need to get the actual password

34
00:01:07,620 --> 00:01:10,320
for your account to log in as if they were you.

35
00:01:10,320 --> 00:01:12,900
The pass the hash attack is really difficult to defend

36
00:01:12,900 --> 00:01:15,030
against because there are so many possible exploits

37
00:01:15,030 --> 00:01:16,890
inside of the Windows operating system

38
00:01:16,890 --> 00:01:19,440
as well as the applications that run on top of it.

39
00:01:19,440 --> 00:01:20,340
Any of these can be used

40
00:01:20,340 --> 00:01:22,200
by an attacker to elevate their permissions

41
00:01:22,200 --> 00:01:24,240
and then be able to pull off the credential harvesting

42
00:01:24,240 --> 00:01:26,460
or hash harvesting that they can then use

43
00:01:26,460 --> 00:01:29,700
in a further attack using pass the hash technique.

44
00:01:29,700 --> 00:01:31,260
Also, only one machine

45
00:01:31,260 --> 00:01:33,240
in a Windows domain needs to be misconfigured

46
00:01:33,240 --> 00:01:34,890
or missing a critical security patch

47
00:01:34,890 --> 00:01:36,870
for that hacker to be able to find their way in

48
00:01:36,870 --> 00:01:39,870
and be able to execute this pass the hash technique.

49
00:01:39,870 --> 00:01:41,760
Now, there are many penetration tools out there

50
00:01:41,760 --> 00:01:43,800
like Mimikatz that will give you the ability

51
00:01:43,800 --> 00:01:46,410
to automate this process of harvesting the hashes

52
00:01:46,410 --> 00:01:48,660
and conducting the patch the pass the hash technique.

53
00:01:48,660 --> 00:01:50,430
To prevent the Pass-the-Hash-Attack,

54
00:01:50,430 --> 00:01:51,784
you should ensure

55
00:01:51,784 --> 00:01:52,890
that only trusted operating systems are allowed

56
00:01:52,890 --> 00:01:54,120
to connect to your servers

57
00:01:54,120 --> 00:01:56,640
that your Windows domains have their trust set up properly

58
00:01:56,640 --> 00:01:59,520
and that workstations are all going to be patched and updated

59
00:01:59,520 --> 00:02:01,590
as well as making sure your multifactor authentication

60
00:02:01,590 --> 00:02:03,060
is being used properly in your network

61
00:02:03,060 --> 00:02:05,190
and that all user accounts have been set up

62
00:02:05,190 --> 00:02:07,560
to use the concept of lease privilege.

63
00:02:07,560 --> 00:02:09,509
Now, the second type of attack I want to cover

64
00:02:09,509 --> 00:02:11,430
is what's known as a birthday attack.

65
00:02:11,430 --> 00:02:12,660
And the birthday attack occurs

66
00:02:12,660 --> 00:02:15,000
when the attacker's able to send two different messages

67
00:02:15,000 --> 00:02:16,320
through a hash algorithm

68
00:02:16,320 --> 00:02:19,110
and then get the same identical hash digest.

69
00:02:19,110 --> 00:02:20,970
This is what we call a collision.

70
00:02:20,970 --> 00:02:22,530
And in the case of a birthday attack,

71
00:02:22,530 --> 00:02:24,900
we actually are trying to create collisions.

72
00:02:24,900 --> 00:02:26,910
Now, this attack gets its name from something known

73
00:02:26,910 --> 00:02:28,350
as the Birthday paradox,

74
00:02:28,350 --> 00:02:30,630
which says that if you have a random group of people,

75
00:02:30,630 --> 00:02:32,760
the chances that you're going to have two people in that group

76
00:02:32,760 --> 00:02:35,520
with the same birthday is pretty high.

77
00:02:35,520 --> 00:02:37,760
Now, when I teach this course in person to a group

78
00:02:37,760 --> 00:02:40,380
of 30 people, most of the time two people

79
00:02:40,380 --> 00:02:42,570
in the class are going to have the same birthday

80
00:02:42,570 --> 00:02:44,280
based on the same month and day

81
00:02:44,280 --> 00:02:47,070
because there are only 365 days in a year.

82
00:02:47,070 --> 00:02:49,200
So if you actually do the math on this,

83
00:02:49,200 --> 00:02:53,100
you only need 57 people in a room to get a 99% chance

84
00:02:53,100 --> 00:02:55,230
of having two identical birthdays.

85
00:02:55,230 --> 00:02:56,910
Now, with 23 people in the room,

86
00:02:56,910 --> 00:02:58,800
your odds are about 50/50,

87
00:02:58,800 --> 00:03:00,900
and that's why in a class with about 30 students,

88
00:03:00,900 --> 00:03:03,630
more often than not we have identical birthdays

89
00:03:03,630 --> 00:03:07,020
because that puts us somewhere in the 70 to 80% range

90
00:03:07,020 --> 00:03:08,880
based on the underlying math.

91
00:03:08,880 --> 00:03:10,230
Now, in the world of hashes

92
00:03:10,230 --> 00:03:12,960
two identical hash digests are called a collision

93
00:03:12,960 --> 00:03:15,180
and if an attacker can find two identical messages

94
00:03:15,180 --> 00:03:16,380
with the same hash,

95
00:03:16,380 --> 00:03:18,960
they can use this as an attack against your system.

96
00:03:18,960 --> 00:03:21,150
For example, let's say that I found a match

97
00:03:21,150 --> 00:03:22,560
to your password's hash,

98
00:03:22,560 --> 00:03:23,520
that I can then use that

99
00:03:23,520 --> 00:03:25,380
to bypass your authentication system,

100
00:03:25,380 --> 00:03:27,390
even if I'm entering in the wrong password

101
00:03:27,390 --> 00:03:30,390
as long as that password has the same hash value.

102
00:03:30,390 --> 00:03:32,790
For this reason, we want to make sure we're using hashes

103
00:03:32,790 --> 00:03:35,310
with long output digest, so we start using things

104
00:03:35,310 --> 00:03:37,830
like SHA-256 over MD5

105
00:03:37,830 --> 00:03:39,180
because this will significantly reduce

106
00:03:39,180 --> 00:03:40,050
the amount of collisions

107
00:03:40,050 --> 00:03:42,810
and the effectiveness of a birthday attack.

108
00:03:42,810 --> 00:03:45,480
So how else can we increase the strength of our hashes,

109
00:03:45,480 --> 00:03:48,150
especially when using them as part of our password security?

110
00:03:48,150 --> 00:03:49,860
Well, one of the first things we can do

111
00:03:49,860 --> 00:03:52,140
is use something known as key stretching.

112
00:03:52,140 --> 00:03:53,610
Now, key stretching is a technique

113
00:03:53,610 --> 00:03:55,380
that's used to mitigate a weaker key

114
00:03:55,380 --> 00:03:56,700
by increasing its effectiveness

115
00:03:56,700 --> 00:03:59,730
and thereby increasing the time needed to crack that key.

116
00:03:59,730 --> 00:04:01,950
When you stretch a weaker key, the weaker key is run

117
00:04:01,950 --> 00:04:02,790
through an algorithm

118
00:04:02,790 --> 00:04:04,770
to create a longer more secure key,

119
00:04:04,770 --> 00:04:06,480
than what would normally be used.

120
00:04:06,480 --> 00:04:08,520
Many systems are going to utilize key stretching

121
00:04:08,520 --> 00:04:10,200
to increase the security they provide,

122
00:04:10,200 --> 00:04:12,630
including systems like Wifi Protected Access,

123
00:04:12,630 --> 00:04:15,600
Wifi Protected Access 2, Pretty Good Privacy

124
00:04:15,600 --> 00:04:18,180
Decrypt and others, which all use key stretching

125
00:04:18,180 --> 00:04:21,000
to mitigate a shorter keys inherent weakness.

126
00:04:21,000 --> 00:04:22,770
Second, we have salting.

127
00:04:22,770 --> 00:04:25,050
Now, salting involves the addition of random data,

128
00:04:25,050 --> 00:04:27,030
which we call a salt to the password

129
00:04:27,030 --> 00:04:30,390
before it undergoes a one-way cryptographic hash function.

130
00:04:30,390 --> 00:04:31,650
This process ensures that

131
00:04:31,650 --> 00:04:34,050
even if two users have the same password,

132
00:04:34,050 --> 00:04:36,210
their hashed outputs will be different

133
00:04:36,210 --> 00:04:38,100
because they're using different salts.

134
00:04:38,100 --> 00:04:41,310
Now, by doing so, salting amplifies password security

135
00:04:41,310 --> 00:04:43,290
and thwarts various password cracking strategies

136
00:04:43,290 --> 00:04:46,140
and techniques like dictionary attacks, brute force attacks

137
00:04:46,140 --> 00:04:47,910
and rainbow table attacks.

138
00:04:47,910 --> 00:04:50,670
Dictionary attacks happen when an attacker tries every word

139
00:04:50,670 --> 00:04:51,960
from a predefined list

140
00:04:51,960 --> 00:04:53,520
and this becomes much more challenging

141
00:04:53,520 --> 00:04:55,740
because the salt is going to alter the hash outcome

142
00:04:55,740 --> 00:04:57,930
for those commonly used passwords.

143
00:04:57,930 --> 00:05:00,480
Similarly, brute force attacks where every possible

144
00:05:00,480 --> 00:05:02,233
password combination is tested becomes

145
00:05:02,233 --> 00:05:04,290
a much more time consuming process

146
00:05:04,290 --> 00:05:06,180
because of the salting process.

147
00:05:06,180 --> 00:05:08,130
And finally, we have rainbow tables

148
00:05:08,130 --> 00:05:09,300
which are pre-computer tables

149
00:05:09,300 --> 00:05:11,370
for reversing cryptographic hash functions

150
00:05:11,370 --> 00:05:14,220
and these are rendered ineffective against salted hashes

151
00:05:14,220 --> 00:05:16,410
because the added salt forces the attackers

152
00:05:16,410 --> 00:05:17,970
to compute a new table

153
00:05:17,970 --> 00:05:20,520
for each and every salt value making this type

154
00:05:20,520 --> 00:05:22,800
of attack much more impractical.

155
00:05:22,800 --> 00:05:25,890
The third thing we have to use is what's known as nonce.

156
00:05:25,890 --> 00:05:27,960
Now, utilizing a nonce is a strategic way

157
00:05:27,960 --> 00:05:30,990
to enhance the security of potentially vulnerable passwords.

158
00:05:30,990 --> 00:05:33,450
Nonce, which stands for number used once,

159
00:05:33,450 --> 00:05:35,310
is a unique often random number

160
00:05:35,310 --> 00:05:36,143
that's going to be added

161
00:05:36,143 --> 00:05:38,340
to the password based authentication process.

162
00:05:38,340 --> 00:05:40,140
The primary function of a nonce is to ensure

163
00:05:40,140 --> 00:05:42,420
that even if the attacker is able to get your password

164
00:05:42,420 --> 00:05:44,490
or its corresponding authentication data,

165
00:05:44,490 --> 00:05:47,430
they simply can't reuse it for unauthorized access.

166
00:05:47,430 --> 00:05:48,690
By adding this transient number

167
00:05:48,690 --> 00:05:50,310
to the authentication sequence,

168
00:05:50,310 --> 00:05:52,440
your resulted hash data is going to change

169
00:05:52,440 --> 00:05:54,600
every single time and make it significantly

170
00:05:54,600 --> 00:05:58,140
harder for a cyber adversary to exploit stolen credentials.

171
00:05:58,140 --> 00:05:59,730
This ephemeral approach is going to

172
00:05:59,730 --> 00:06:01,350
add an additional layer of security,

173
00:06:01,350 --> 00:06:02,790
especially in systems that are vulnerable

174
00:06:02,790 --> 00:06:04,770
to replay attacks where the attacker attempts

175
00:06:04,770 --> 00:06:07,800
to resubmit capture data for unauthorized access.

176
00:06:07,800 --> 00:06:09,840
Finally, your systems need to be configured

177
00:06:09,840 --> 00:06:11,910
to limit the number of failed login attempts

178
00:06:11,910 --> 00:06:13,530
allowed for a giving user.

179
00:06:13,530 --> 00:06:15,480
This will help to prevent password cracking attacks

180
00:06:15,480 --> 00:06:16,950
against your accounts.

181
00:06:16,950 --> 00:06:18,150
Normally, you want the number

182
00:06:18,150 --> 00:06:19,320
of incorrect passwords entered

183
00:06:19,320 --> 00:06:20,610
before locking out the account

184
00:06:20,610 --> 00:06:23,610
to be set somewhere pretty low like three, that way,

185
00:06:23,610 --> 00:06:26,220
if somebody enters the password incorrectly three times,

186
00:06:26,220 --> 00:06:28,320
that account will automatically be locked.

187
00:06:28,320 --> 00:06:30,630
Yes, this can become painful for your users

188
00:06:30,630 --> 00:06:33,270
if they accidentally enter the wrong password to many times,

189
00:06:33,270 --> 00:06:35,324
but it does increase the security drastically

190
00:06:35,324 --> 00:06:37,740
and it does help to slow down an attacker

191
00:06:37,740 --> 00:06:39,270
who's trying to guess the user's password

192
00:06:39,270 --> 00:06:40,950
and break into your systems.

193
00:06:40,950 --> 00:06:42,840
So remember, hashing can be attacked

194
00:06:42,840 --> 00:06:44,610
through the use of pass the hash techniques

195
00:06:44,610 --> 00:06:47,220
to reuse a password without cracking its hash first

196
00:06:47,220 --> 00:06:48,930
or by using the birthday paradox

197
00:06:48,930 --> 00:06:51,750
or birthday attack to create known collisions.

198
00:06:51,750 --> 00:06:53,640
To prevent these types of hashing attacks

199
00:06:53,640 --> 00:06:54,960
you should increase your security

200
00:06:54,960 --> 00:06:57,870
of your hashing system by using key stretching, nonce

201
00:06:57,870 --> 00:07:00,330
and limiting the number of incorrect login attempts.

202
00:07:00,330 --> 00:07:02,010
Key stretching is a technique that's used

203
00:07:02,010 --> 00:07:03,870
to enhance the security of stored passwords

204
00:07:03,870 --> 00:07:06,000
by applying a hash function multiple times

205
00:07:06,000 --> 00:07:08,160
and therefore making brute force attacks

206
00:07:08,160 --> 00:07:09,420
much more time consuming

207
00:07:09,420 --> 00:07:12,180
and computationally expensive for an attacker.

208
00:07:12,180 --> 00:07:14,850
Nonces are unique values, often random numbers.

209
00:07:14,850 --> 00:07:16,290
They're going to be used once inside

210
00:07:16,290 --> 00:07:18,990
of a cryptographic operation to prevent replay attacks

211
00:07:18,990 --> 00:07:20,550
by ensuring the repeated transactions

212
00:07:20,550 --> 00:07:22,170
produce different outputs.

213
00:07:22,170 --> 00:07:23,880
And limiting the failed login attempts

214
00:07:23,880 --> 00:07:25,680
is a security measure that restricts the number

215
00:07:25,680 --> 00:07:27,000
of incorrect login attempts

216
00:07:27,000 --> 00:07:29,070
that a user can make within a given timeframe

217
00:07:29,070 --> 00:07:31,020
and the goal here is to deter attackers

218
00:07:31,020 --> 00:07:33,570
from continually guessing a user's credentials.

219
00:07:33,570 --> 00:07:35,970
By implementing these techniques, our hash digest

220
00:07:35,970 --> 00:07:38,220
and their associated data can be better protected

221
00:07:38,220 --> 00:07:39,053
from threat actors

222
00:07:39,053 --> 00:07:41,300
who may be targeting your enterprise networks.

