1 00:00:00,000 --> 00:00:01,680 running the password village. 2 00:00:01,680 --> 00:00:08,720 We wanted to start off getting you up and running with Hashcat on an NVIDIA GPU and then cover some basic attacks. 3 00:00:08,720 --> 00:00:15,660 The goal here is to start building a foundation that other talks throughout the village and DEF CON will expand on. 4 00:00:16,120 --> 00:00:21,700 So ideally you're going to have a GTX model NVIDIA card and be running Linux. 5 00:00:21,700 --> 00:00:34,440 The box we're on here is an AWS instance running the stock Ubuntu 20.04 AMI, and it has a Tesla T4, which isn't the greatest card for cracking, but it's going to work for our purposes. 6 00:00:35,360 --> 00:00:38,220 So Hashcat supports two modes of operation. 7 00:00:38,220 --> 00:00:47,640 You have OpenCL, which is a standard language, meaning that it's going to run on any card or CPU that supports OpenCL. 8 00:00:47,740 --> 00:00:54,820 That can be Intel, that can be AMD, that can be NVIDIA, and that can be AMD video cards. 9 00:00:56,580 --> 00:01:07,200 And then there's CUDA, which is specific to NVIDIA, which will allow us to eek just a bit more performance out of the card and get us some faster crack rates. 10 00:01:07,200 --> 00:01:12,400 Since we have an NVIDIA card on this box, we're going to go with the CUDA driver. 11 00:01:12,560 --> 00:01:14,860 Now we don't want to use the repo drivers. 12 00:01:15,120 --> 00:01:37,620 We don't want to use the repo drivers because the Ubuntu maintainers will include patches to those drivers that may fix a bug for a desktop environment, for instance, but it breaks the compatibility with the CUDA runtime and therefore breaks Hashcat. 13 00:01:37,620 --> 00:01:39,560 And we don't want that to happen. 14 00:01:39,560 --> 00:01:47,940 So we're going to use the driver that's supplied by NVIDIA, and we're going to use the CUDA toolkit version. 15 00:01:47,980 --> 00:01:55,340 So we are on Linux, we're on x86-64, so 64-bit processor or 64-bit system. 16 00:01:55,340 --> 00:01:56,840 We're running Ubuntu. 17 00:01:56,840 --> 00:01:59,360 We're running version 20.04. 18 00:01:59,380 --> 00:02:01,000 And then we have a couple of options here. 19 00:02:01,000 --> 00:02:13,280 So we have a run file, which is a local install, a local Debian install, which will create a Debian archive on your, or sorry, a Debian repo on your local box, and then you have the network install. 20 00:02:13,640 --> 00:02:28,820 Because we want to maintain compatibility between the CUDA version and the Hashcat release, we don't want to upgrade CUDA as part of a system upgrade on accident and break it. 21 00:02:28,820 --> 00:02:31,400 So we're going to go with the local run file. 22 00:02:31,940 --> 00:02:40,590 So we're going to copy this wget line here, paste that in. 23 00:02:47,680 --> 00:02:52,400 And then we're going to go ahead and grab our Hashcat binaries. 24 00:03:01,010 --> 00:03:07,730 And we're also want the PGP signature so that we can verify that it's legit. 25 00:03:13,580 --> 00:03:17,140 And then we're going to want to grab the Hashcat key. 26 00:03:17,140 --> 00:03:19,980 So we see here, we've got the fingerprint. 27 00:03:20,280 --> 00:03:22,260 Scroll over here a bit. 28 00:03:22,380 --> 00:03:27,480 So we've got the fingerprint here, and it says that it is on the PGP key servers. 29 00:03:27,480 --> 00:03:33,180 So we can use GPG to go ahead and import that key. 30 00:03:38,310 --> 00:03:40,450 Okay, we've got our key. 31 00:03:41,210 --> 00:03:48,750 And then let's verify that our download is actually signed and correct. 32 00:03:51,840 --> 00:03:55,700 Okay, so there we go, we've got a good signature. 33 00:03:57,880 --> 00:03:59,540 So we are good there. 34 00:04:00,340 --> 00:04:03,400 So we're also going to grab a word list. 35 00:04:04,020 --> 00:04:06,480 And we're going to grab that from Skull Security. 36 00:04:06,620 --> 00:04:13,640 And we're going to be using Rocky, which is kind of an old list, but it's also still really good. 37 00:04:15,720 --> 00:04:17,860 So let's grab that guy. 38 00:04:25,800 --> 00:04:28,300 Let's grab it incredibly slowly. 39 00:04:36,390 --> 00:04:40,330 So the next part, we'll go ahead and install the CUDA SDK. 40 00:04:40,330 --> 00:04:53,690 And it's going to fail the first time we run it, because we're on a brand new box that has no dependencies installed at all. 41 00:04:53,810 --> 00:05:06,350 So there are some things that the SDK is going to do, like build the NVIDIA driver, and it's going to need to have things like GCC and other libraries that it requires in order to do that. 42 00:05:06,430 --> 00:05:13,310 So what we're actually going to do is kind of walk through the steps on how we can make sure that we get all of those. 43 00:05:15,090 --> 00:05:21,090 Now that that's done, so we're going to do a search for an Aptcache search for the NVIDIA driver. 44 00:05:21,770 --> 00:05:24,430 And we can see that there are a bunch of them. 45 00:05:25,050 --> 00:05:28,970 So let's just say this guy right here. 46 00:05:29,310 --> 00:05:33,870 And it's the latest release that seems that Ubuntu has. 47 00:05:33,870 --> 00:05:43,030 And then we are going to apt-get build-dep NVIDIA driver 440. 48 00:05:43,030 --> 00:05:48,370 So we want to get all the dependencies that NVIDIA driver 440 requires. 49 00:05:50,090 --> 00:05:59,170 So we don't have any source listings for non-binary polls in our apt-config. 50 00:05:59,170 --> 00:06:02,950 So let's go ahead and make that happen. 51 00:06:10,520 --> 00:06:13,280 Make sure we get the editor in there as well. 52 00:06:16,500 --> 00:06:22,100 So we're going to uncomment this, and we're going to uncomment this and that's all we need. 53 00:06:25,480 --> 00:06:29,440 Do a quick update. 54 00:06:40,670 --> 00:06:42,370 And let's try that again. 55 00:06:44,170 --> 00:06:45,050 Okay. 56 00:06:46,270 --> 00:06:48,150 So we're going to go ahead and let all that install. 57 00:06:48,150 --> 00:06:51,530 So this will allow us to build our driver. 58 00:06:53,970 --> 00:07:00,270 We also need to grab one more thing because hashcat is packaged in the 7-zip format, we'll need to grab p7-zip. 59 00:07:17,610 --> 00:07:19,590 Any day now. 60 00:07:35,780 --> 00:07:36,840 AWS? 61 00:07:41,020 --> 00:07:42,500 Thank you. 62 00:07:49,940 --> 00:07:52,560 So we'll grab p7-zip as well. 63 00:07:56,400 --> 00:07:58,500 Hopefully that didn't take as long. 64 00:08:00,000 --> 00:08:05,240 And we're going to bypass some of this. 65 00:08:05,500 --> 00:08:12,940 So if you run the CUDA SDK installer, it has a kind of menu-driven interface. 66 00:08:12,940 --> 00:08:14,240 We don't want that. 67 00:08:14,420 --> 00:08:19,380 So we're going to run it in silent mode, and we want to install the driver and the toolkit. 68 00:08:23,720 --> 00:08:25,440 And this is going to take a minute. 69 00:08:26,700 --> 00:08:27,340 Okay. 70 00:08:27,680 --> 00:08:37,200 Now there's one other step that if we had used the menu-driven method, it would tell us that we need to add some stuff to our path. 71 00:08:37,720 --> 00:08:40,240 So if we look at 72 00:08:43,340 --> 00:08:52,620 ldsoconf.conf.d, so it already wrote our CUDA library path, so that's good. 73 00:08:52,980 --> 00:08:58,740 But it did not write the path update for our profile. 74 00:08:59,360 --> 00:09:02,120 So we need to go ahead and add that in. 75 00:09:02,280 --> 00:09:12,760 So we'll do a sudo vi slash etc profile.d, and we'll call this cuda.sh. 76 00:09:14,920 --> 00:09:24,700 And then in here, we're basically just adding the path to the CUDA binaries to our system path. 77 00:09:24,700 --> 00:09:29,320 And then this is going to load every time a new instance is spawned. 78 00:09:29,320 --> 00:09:34,760 So we'll go ahead and source accept profile so we get the update. 79 00:09:39,400 --> 00:09:40,280 Okay. 80 00:09:40,280 --> 00:09:46,880 And then we also need to run ldconfig so that it updates the library path. 81 00:09:49,110 --> 00:09:50,550 Okay. 82 00:09:50,670 --> 00:09:57,770 And then let's check NVIDIA SMI and make sure that it sees our card. 83 00:09:58,050 --> 00:09:59,270 And it does. 84 00:09:59,270 --> 00:10:08,850 So we've got our Tesla T4, and it is running on the driver version that was supplied with the CUDA SDK, which is 450.51.05. 85 00:10:08,850 --> 00:10:11,250 It's right here. 86 00:10:11,530 --> 00:10:14,210 And we can see we're on CUDA version 11. 87 00:10:14,310 --> 00:10:15,970 So that's good. 88 00:10:16,570 --> 00:10:20,630 So next, let's unpack Hashcat. 89 00:10:20,630 --> 00:10:25,590 So we're going to 7zip extract hashcat.7zip. 90 00:10:26,850 --> 00:10:33,110 And while we're at it, let's go ahead and bunzip to rocky.txt. 91 00:10:39,220 --> 00:10:40,980 All right. 92 00:10:41,980 --> 00:10:45,800 So let's make sure that Hashcat sees our video card now. 93 00:10:49,160 --> 00:10:50,420 And it does. 94 00:10:50,420 --> 00:10:54,400 And it sees that it can run in either CUDA or OpenCL mode. 95 00:10:55,120 --> 00:10:58,240 It's going to default to the CUDA version here. 96 00:10:58,240 --> 00:11:03,220 So we don't need to worry about the OpenCL info below us. 97 00:11:03,480 --> 00:11:11,220 And then let's just do a quick benchmark to make sure that we actually get running. 98 00:11:12,700 --> 00:11:15,540 Okay, so we can see that it selected our device. 99 00:11:15,740 --> 00:11:21,280 It skipped the OpenCL part of that because it has the CUDA API. 100 00:11:21,500 --> 00:11:23,320 And there we go. 101 00:11:27,340 --> 00:11:33,180 So let's move into doing some simple attacks with Hashcat. 102 00:11:36,910 --> 00:11:41,430 So we're going to go back to the Password Village site, which is at passwordvillage.org. 103 00:11:42,010 --> 00:11:45,990 And we are going to grab some NT hashes. 104 00:11:47,750 --> 00:11:50,570 So we've got our Hashcat examples here. 105 00:11:52,210 --> 00:11:58,310 You can copy and paste these off the site and follow along if you are set up to do so. 106 00:11:59,830 --> 00:12:01,950 Let's get rid of this. 107 00:12:04,030 --> 00:12:06,610 We'll call this NT.hash. 108 00:12:08,910 --> 00:12:13,870 We'll paste those guys in using whatever editor you desire. 109 00:12:15,950 --> 00:12:24,050 And then we used Hashmode 1000 here because I know that 1000 is NTLM. 110 00:12:25,670 --> 00:12:32,290 But if you needed to find it, you could do a Hashcat help and then grep. 111 00:12:32,690 --> 00:12:39,090 We'll do a dash I so we do a case insensitive search and look for NTLM. 112 00:12:39,870 --> 00:12:43,450 And we can see right here NTLM is Mode 1000. 113 00:12:43,570 --> 00:12:47,670 Net NTLM V1 and V2 are different hash types. 114 00:12:47,670 --> 00:12:59,330 Typically, you see those coming out of Responder, which I believe EvilMog is going to do a talk on later in the day that will quickly cover those. 115 00:12:59,390 --> 00:13:05,290 So we want Hashcat TACM 1000 for Mode. 116 00:13:05,630 --> 00:13:08,190 We want our NT.hash file. 117 00:13:08,190 --> 00:13:10,730 And then we want to run this against RockYou. 118 00:13:16,800 --> 00:13:19,200 So it's going to initialize the device there. 119 00:13:19,200 --> 00:13:20,700 It's going to load the dictionary. 120 00:13:20,800 --> 00:13:23,920 And then it cracked all our hashes. 121 00:13:23,920 --> 00:13:28,320 It cracked all our hashes because these hashes were generated from RockYou. 122 00:13:28,340 --> 00:13:32,080 So you would expect to get all of those. 123 00:13:32,080 --> 00:13:48,480 If you were pulling hashes from the wild, you know, RockYou may crack one of them, it may crack none of them, or it may crack all of them, depending on how good the password policy of the company or the site that was compromised and the hashes were leaked from. 124 00:13:49,240 --> 00:13:52,760 So to kind of walk through this a little bit, there's a lot going on on the screen here. 125 00:13:52,760 --> 00:13:57,160 So we have our hashes up here and we have the associated plain text on the opposite side. 126 00:13:57,160 --> 00:14:06,120 So you've got, this is a hash, we've got a separator, and then we have the plain text of this hash. 127 00:14:06,620 --> 00:14:08,640 And then we've got 10 of those. 128 00:14:09,020 --> 00:14:11,040 So we had a session name of hashcat. 129 00:14:11,120 --> 00:14:20,740 If we were doing some session stuff where maybe we wanted to stop this and resume it later, this name is important. 130 00:14:20,740 --> 00:14:22,500 We're not going to cover that here. 131 00:14:22,680 --> 00:14:30,520 The status would normally be running, but since we only had a small sample and we knew the plain text for all of those, it cracked them all pretty quick. 132 00:14:30,900 --> 00:14:34,780 We were running against NTLMs. 133 00:14:35,580 --> 00:14:40,320 Our hash target was the hash file that we supplied called nt.hash. 134 00:14:40,760 --> 00:14:48,740 The guest base, meaning the candidate words that we were selecting from, came from a file called rockyou.txt. 135 00:14:49,240 --> 00:15:01,240 The speed of our device, which is actually pretty slow compared to what we saw up here in the benchmark, because it never got fully up to speed. 136 00:15:01,240 --> 00:15:02,460 Where are we at here? 137 00:15:07,860 --> 00:15:09,180 Right here. 138 00:15:11,440 --> 00:15:20,220 So we can see here we were going at about 35.7 billion. 139 00:15:21,280 --> 00:15:22,820 It's pretty quick. 140 00:15:23,060 --> 00:15:27,820 But down here we were only going at about 7.7 million. 141 00:15:27,820 --> 00:15:42,460 So that's mainly because we didn't have enough work to supply the GPU, but also because we cracked all the hashes so quickly that it never got a chance to get up to full speed. 142 00:15:42,840 --> 00:15:46,100 So we recovered all 10 of our hashes, so we had 10 digests. 143 00:15:46,100 --> 00:15:48,760 A hash is also called a digest. 144 00:15:49,100 --> 00:15:58,980 It ran through the entire list of words, so we had 14.3 million possible candidates, and we exhausted that entire space. 145 00:15:58,980 --> 00:16:05,180 It rejected none of them, and a rejection can come from a word that's too long. 146 00:16:05,180 --> 00:16:09,700 We had a restore point, which we didn't use because we're not doing a restore . 147 00:16:10,040 --> 00:16:12,260 And then we had the candidates down here. 148 00:16:12,260 --> 00:16:14,690 Now in a long run, this is going to show 149 00:16:17,930 --> 00:16:24,450 a sample of what words are currently being tried against the hashes. 150 00:16:24,450 --> 00:16:38,430 And here we have some hex representation, and this is probably because we have a colon, which is a separator that HashCat uses internally. 151 00:16:38,430 --> 00:16:46,490 So it's going to put that into a hex representation so that it doesn't accidentally cut your hash or your plain text in the wrong spot. 152 00:16:46,490 --> 00:16:51,370 And then we have our hardware monitor, which was telling us some statistics about the card. 153 00:16:51,370 --> 00:17:02,350 So it was running at 59 degrees Celsius, it was at 75% utilization, and then our core speed, the memory speed, and the bus workload. 154 00:17:04,010 --> 00:17:08,090 So that's a very simple dictionary attack. 155 00:17:09,050 --> 00:17:10,330 So let's try 156 00:17:17,020 --> 00:17:20,060 let's try doing a combinator attack. 157 00:17:20,060 --> 00:17:34,080 Now a combinator attack is when you take two word lists, and HashCat is going to take one word from one word list and one word from the other word list and smash them together and try that as a candidate. 158 00:17:34,080 --> 00:17:36,320 And it's going to do that for each one. 159 00:17:36,600 --> 00:17:46,720 So in very large runs, this is not really the best attack to do because it can take years to complete. 160 00:17:46,720 --> 00:17:58,880 So if we were to use Rocky with Rocky, for instance, we're doing 14.3 million to the 14.3 million, which ends up being some ridiculous number that we're probably never going to exhaust. 161 00:18:00,360 --> 00:18:08,480 The example dictionaries here are actually reasonably small and it's a really good baseline for showing how the attack works. 162 00:18:08,480 --> 00:18:12,320 So we can copy this. 163 00:18:15,160 --> 00:18:20,080 So we're going to use A1, which is the attack mode for combinator. 164 00:18:20,400 --> 00:18:23,820 These hashes are MD5, so we're going to say M0. 165 00:18:23,820 --> 00:18:27,560 M0 is the mode identifier for MD5. 166 00:18:28,020 --> 00:18:30,620 HashCat provides an example list of hashes. 167 00:18:30,620 --> 00:18:39,300 So this is going to be the list of MD5 hashes and then the two example dictionaries, which are actually the same dictionary, so we're just going to specify it twice. 168 00:18:39,300 --> 00:18:42,020 You could do this with two different dictionaries. 169 00:18:42,080 --> 00:18:50,620 So if you had example.dict and then example1.dict that has some different word set in it, that will work and you could even reverse some. 170 00:18:52,620 --> 00:18:54,920 So let's go ahead and run this. 171 00:18:56,500 --> 00:18:59,380 Go ahead and run this with the right name. 172 00:19:06,930 --> 00:19:09,330 And yeah, that's a lot. 173 00:19:09,530 --> 00:19:16,650 So we had, if we go back to our status output here, we know all this. 174 00:19:16,650 --> 00:19:22,770 We had a file which was example.dict on the left side and a file which was example.dict on the right side. 175 00:19:22,770 --> 00:19:33,330 So if you think about it this way, you have example.dict and then example.dict. 176 00:19:33,890 --> 00:19:49,370 So this is going to be the left side, this is going to be the right side, and then again, Hashcat just combined left and right, made a single word out of it, hashed it, and then checked it against the list of hashes. 177 00:19:50,070 --> 00:19:53,630 So we can see here that we went quite a bit faster this time. 178 00:19:53,630 --> 00:19:59,370 So we went at 5.8 billion candidates per second. 179 00:19:59,730 --> 00:20:13,810 We recovered 2,906 of 6,494 digests, so just under 45 percent, and we have 3,588 hashes remaining. 180 00:20:16,310 --> 00:20:17,970 So the next one we'll do 181 00:20:24,030 --> 00:20:25,990 is a brute force. 182 00:20:25,990 --> 00:20:34,170 Now, this is going to be a very simple example of a mask attack, we'll talk about mask attacks later. 183 00:20:34,970 --> 00:20:38,310 Brute forcing is when we take 184 00:20:42,230 --> 00:20:49,810 a string and then increment it by either a number or a letter to exhaust a full key space. 185 00:20:49,810 --> 00:21:08,530 So in this case, we're doing 1, 2, 3, let's see, 1, 2, 3, 4, 5, 6 spaces of all characters, so that's numbers, letters, lowercase and uppercase, and then specials. 186 00:21:09,050 --> 00:21:12,790 This is again going to be MD5. 187 00:21:12,870 --> 00:21:16,890 We're going to use the same example hash set that we used before. 188 00:21:17,370 --> 00:21:26,010 A3 is to specify a mask attack or a brute force attack, and then get this right the first time, 189 00:21:30,350 --> 00:21:33,070 and then we let it run. 190 00:21:33,330 --> 00:21:42,630 So you'll see here that we're only going to crack six-character passwords because we only specified for HashCat to crack six-character passwords. 191 00:21:43,250 --> 00:21:56,590 We can see we've got some lowercase, we had some numbers, now we've got an uppercase here, there's an uppercase there, some stuff starting with numbers, so lowercase. 192 00:21:58,230 --> 00:21:58,930 Okay. 193 00:22:00,630 --> 00:22:06,530 So what HashCat was doing in that mode was, so we had this mask specified. 194 00:22:07,370 --> 00:22:15,470 We said we want to try all possible combinations of all printable ASCII characters on a standard keyboard. 195 00:22:15,470 --> 00:22:17,510 So we have 95 of those. 196 00:22:17,550 --> 00:22:22,630 So for each one of these positions, it's going to try all 95 possibilities. 197 00:22:23,150 --> 00:22:50,270 So if we look at it this way, let's say it starts at 1, 2, 3, 4, 5, 6 As, and then it tries 1, 2, 3, 4, 5, 6 with a B, and then it tries 1, 2, 3, 4, 5 with a C, and it continues to increment until C gets to Z, and then it shifts by 1. 198 00:22:51,070 --> 00:23:01,770 So then we have 1, 2, 3, 4, B, A, 1, 2, 3, 4, B, B, and so on and so forth. 199 00:23:01,770 --> 00:23:11,270 But since we're going so fast, the incrementing of the characters goes ridiculously fast. 200 00:23:12,830 --> 00:23:21,590 So that is your basic rundown of the three very basic attack modes that HashCat does. 201 00:23:22,090 --> 00:23:39,710 You can go back and take a look at the standard attacks that are specified on the Password Village website if you need help understanding what was going on, and also some examples of how to use the commands for a given attack mode. 202 00:23:41,670 --> 00:23:46,710 So that's all we've got for now, and hope you join us for the next talk!