1 00:00:00,000 --> 00:00:06,000 . Thank you, everybody. Excuse the 2 00:00:06,000 --> 00:00:12,070 profanities in advance. And let's get started. So the title of my talk is spooky 3 00:00:14,380 --> 00:00:20,980 authentication at a distance, a.k.a. why I don't care about your passwords. So let's start 4 00:00:21,880 --> 00:00:28,600 about me. I have a day job and a night job. I'm working in two shifts. Day job is at 5 00:00:28,600 --> 00:00:39,740 a company. We are mostly prevalent in Europe and Asia. Not much here in the States. And I am 6 00:00:39,740 --> 00:00:46,780 from the Swiss division. So I'm working at Switzerland. My night job, I run under the alias 7 00:00:47,160 --> 00:00:54,820 of ScalSec. I am an open source developer. I have a lot of open source tools created over 8 00:00:54,820 --> 00:00:58,580 the years and published mostly under MIT license. And I have a lot of open source tools 9 00:00:58,600 --> 00:01:03,280 here. And I'm a member or a proud member of Porchetta industries or Porchetta industries 10 00:01:03,280 --> 00:01:11,040 for some of the audiences. And we have an awesome logo over there. So biggest project maybe 11 00:01:11,040 --> 00:01:17,640 that you might have heard of is PyPyCats. Anybody has heard of PyPyCats? Anybody is using 12 00:01:17,640 --> 00:01:28,400 it? Nice. Nice. Thank you. And also I have a tendency of rewriting libraries for my own 13 00:01:28,400 --> 00:01:37,660 abusement. So AIOSMB is basically in packet rewritten from scratch. MSLDAP is like my own 14 00:01:37,660 --> 00:01:45,060 LDAP library. And I have like Kerberos, NTLM, SSH, whatever. I'm a big fan of networking 15 00:01:45,060 --> 00:01:53,620 protocols if one can tell. And yeah, all of these are open source except for OctoPwn. OctoPwn 16 00:01:53,620 --> 00:01:58,380 is a special project. And actually, while developing OctoPwn, I have been working on 17 00:01:58,400 --> 00:02:06,500 I started looking a bit into like nested things that one can do with Windows integrated 18 00:02:06,500 --> 00:02:15,420 authentication. And hence this talk was born. Yeah. Also I like to just go and ramble about 19 00:02:15,420 --> 00:02:23,100 everything. So I have a promise for you today or this afternoon. In this presentation, you 20 00:02:23,100 --> 00:02:28,380 will see a novel technique that will allow you to basically take a little bit of your 21 00:02:28,400 --> 00:02:34,140 code and run it in the context of machine A. If you manage to execute code in a user context of 22 00:02:34,140 --> 00:02:40,620 machine A, then from machine B, which is like your machine, the attacker machine, you will be 23 00:02:40,620 --> 00:02:50,880 able to perform authentication in the context of user A, but from your own target machine. This 24 00:02:50,880 --> 00:02:57,300 means that it will basically the code, like the attacking code itself is going to be executed on 25 00:02:57,300 --> 00:03:02,960 your machine and hopefully you haven't installed XDR or AV or whatever on your machine because 26 00:03:02,960 --> 00:03:11,800 why would you? This will allow you to, if you manage to sufficiently hide the proxy binary, and 27 00:03:11,800 --> 00:03:19,300 I will give you some hints on how you can do that. It's a really small proxy binary. Then you're 28 00:03:20,020 --> 00:03:27,160 basically golden because you usually don't really necessarily care about the initial point of 29 00:03:27,300 --> 00:03:33,440 compromise. So like you don't really care about like what is on the HR machine or the HR lady who 30 00:03:33,440 --> 00:03:38,480 double clicked on the spam that you crafted. You are mostly caring about like what is on the 31 00:03:39,060 --> 00:03:47,120 servers and like over SMB or LDAP that you can reach using the HR person's authentication 32 00:03:47,120 --> 00:03:56,680 context, right? So in summary, I'm going to talk about first like just a brief overview, like a 33 00:03:57,300 --> 00:04:02,860 gentle overview of Windows authentication protocol. This is going to be in the test tomorrow, so I 34 00:04:02,860 --> 00:04:10,480 hope that you are going to take notes. General description, we are going to use LDAP as an example 35 00:04:10,480 --> 00:04:18,020 and I'm going to like take your hand and walk you through on how NTLM, Kerberos plays together 36 00:04:18,020 --> 00:04:24,660 with SBNego, but we are just going to skim over and I have two demos for you, not live demos 37 00:04:24,660 --> 00:04:27,280 because I'm not going to go through all of them, but I'm going to give you a little bit of a 38 00:04:27,300 --> 00:04:28,020 Point, they don't actually allow the plug on so remember to plug in. They told me I'm 39 00:04:28,020 --> 00:04:34,580 not allowed to plug in random USB sticks on this machine. We are going to talk 40 00:04:34,580 --> 00:04:40,700 about SSPI and basically the how to authenticate locally but remotely but also locally part. 41 00:04:41,100 --> 00:04:49,960 So, Windows authentication protocols, in a nutshell, before this first slide about authentication 42 00:04:49,960 --> 00:04:57,180 protocol, one thing that I want to mention, is most of the people that I talk about, they're 43 00:04:57,300 --> 00:04:58,940 that I talk with about authentication protocol. 44 00:04:59,720 --> 00:05:01,780 They have this weird notion 45 00:05:01,780 --> 00:05:04,220 that like the authentication protocol 46 00:05:04,220 --> 00:05:05,960 basically stops being useful 47 00:05:05,960 --> 00:05:08,360 after you perform the authentication itself. 48 00:05:08,740 --> 00:05:11,860 And basically it's either a yes or no decision 49 00:05:11,860 --> 00:05:13,640 whether you get access to the resource 50 00:05:13,640 --> 00:05:14,620 or not from the server. 51 00:05:15,140 --> 00:05:16,920 However, I would like to point out 52 00:05:16,920 --> 00:05:18,520 and I'm going to point it out multiple times 53 00:05:18,520 --> 00:05:19,900 that it is not the case 54 00:05:19,900 --> 00:05:21,960 because usually modern authentication protocols 55 00:05:21,960 --> 00:05:23,080 also do key exchange 56 00:05:23,080 --> 00:05:24,620 and you will have to do something 57 00:05:24,620 --> 00:05:27,740 with the encryption and decryption key context. 58 00:05:29,120 --> 00:05:32,400 So yeah, as I said, there is going to be a lot of letters. 59 00:05:33,240 --> 00:05:35,740 No worries if you don't, if you cannot read it. 60 00:05:35,820 --> 00:05:37,320 Oh, it's actually quite readable. 61 00:05:37,520 --> 00:05:38,740 I was really afraid of this one. 62 00:05:40,620 --> 00:05:43,840 So basically we take like a random network protocol, 63 00:05:44,120 --> 00:05:44,980 generic overview, 64 00:05:45,880 --> 00:05:48,000 client would like to log into the server. 65 00:05:48,200 --> 00:05:49,240 How to do this? 66 00:05:49,440 --> 00:05:51,700 Like if you would be willing 67 00:05:51,700 --> 00:05:53,220 or if you wish to implement 68 00:05:53,220 --> 00:05:54,600 your own custom protocol, 69 00:05:54,600 --> 00:05:56,920 and you would like to have some authentication on it, 70 00:05:57,000 --> 00:06:00,120 then basically like this is the generic rundown 71 00:06:00,120 --> 00:06:00,920 how it should look like. 72 00:06:01,060 --> 00:06:04,480 So you would obviously want to have some version negotiation 73 00:06:04,960 --> 00:06:06,120 between the client and the server 74 00:06:06,120 --> 00:06:08,240 because probably your protocol 75 00:06:08,240 --> 00:06:11,360 is not going to come out right at the first time. 76 00:06:11,480 --> 00:06:13,760 So you will need to have some versioning 77 00:06:13,760 --> 00:06:14,840 and the client and the server 78 00:06:14,840 --> 00:06:16,240 should be using like the same version 79 00:06:16,240 --> 00:06:17,940 of the or the dialect of the protocol. 80 00:06:18,260 --> 00:06:20,280 Oops, we already at SMB, whatever. 81 00:06:21,440 --> 00:06:24,580 Yeah, so after the version has been negotiated, 82 00:06:24,600 --> 00:06:29,020 then you will see the authentication protocol negotiation. 83 00:06:29,420 --> 00:06:31,620 This can be in the version negotiation as well. 84 00:06:32,160 --> 00:06:35,020 And then both the client and the server 85 00:06:35,020 --> 00:06:36,120 agreed on authentication, 86 00:06:36,600 --> 00:06:39,840 then I put it in a separate logical container, 87 00:06:40,080 --> 00:06:42,240 the authentication client and the authentication server 88 00:06:42,490 --> 00:06:43,760 are going to initialize. 89 00:06:43,880 --> 00:06:48,680 And usually everything that these two generic 90 00:06:48,680 --> 00:06:52,440 like authentication concepts are willing to communicate 91 00:06:52,440 --> 00:06:54,580 with each other are just going to go through the same process. 92 00:06:54,600 --> 00:06:56,800 They will be interposed on the actual network protocol. 93 00:06:57,200 --> 00:07:00,780 We are going to see it in like in great detail later on. 94 00:07:00,900 --> 00:07:03,720 And this back and forth of the out messages 95 00:07:03,720 --> 00:07:07,980 are going to go until the authentication 96 00:07:07,980 --> 00:07:09,780 either succeeds or not. 97 00:07:10,580 --> 00:07:12,600 Obviously, like currently we are not touching 98 00:07:12,600 --> 00:07:17,760 the authorization part because we don't have like a day 99 00:07:17,760 --> 00:07:22,940 of explaining every single bit of information here. 100 00:07:23,460 --> 00:07:23,800 So. 101 00:07:24,600 --> 00:07:26,700 After the authentication is finished, 102 00:07:26,980 --> 00:07:30,920 then usually both the client or the authentication client 103 00:07:30,920 --> 00:07:33,540 and the authentication server are going to end up 104 00:07:33,540 --> 00:07:34,640 with a shared secret. 105 00:07:34,940 --> 00:07:38,560 And this shared secret issue is used or not used 106 00:07:38,560 --> 00:07:41,200 depending on what the protocol would like to, 107 00:07:41,260 --> 00:07:44,560 like the actual network protocol would like to do 108 00:07:44,560 --> 00:07:45,260 in the future. 109 00:07:46,420 --> 00:07:49,180 They have the option to use the shared secret 110 00:07:49,180 --> 00:07:52,000 to basically encrypt or protect the integrity 111 00:07:52,000 --> 00:07:52,920 of the protocol. 112 00:07:52,920 --> 00:07:55,060 So, moving on. 113 00:07:55,180 --> 00:07:59,260 This is a continuation of the slides before. 114 00:07:59,580 --> 00:08:01,220 So, authentication protocols. 115 00:08:02,680 --> 00:08:04,560 So, encryption and decryption. 116 00:08:05,100 --> 00:08:08,220 User would like to list the shares, for example. 117 00:08:08,860 --> 00:08:11,800 It double clicks on or like it types like slash slash 118 00:08:12,120 --> 00:08:14,620 IP address because we are still in the NTLM times 119 00:08:14,620 --> 00:08:16,560 and we don't want to use Kerberos anyhow. 120 00:08:17,600 --> 00:08:20,520 This is going to be translated inside of the client 121 00:08:20,520 --> 00:08:22,220 to like a series of messages. 122 00:08:22,220 --> 00:08:24,440 And these are plain text messages. 123 00:08:24,640 --> 00:08:27,020 So, basically the client can request 124 00:08:27,020 --> 00:08:29,180 the authentication protocol to encrypt the message. 125 00:08:29,400 --> 00:08:32,020 Then the encrypted message is going to be dispatched 126 00:08:32,020 --> 00:08:32,540 to the server. 127 00:08:32,660 --> 00:08:34,060 Server is going to dispatch it 128 00:08:34,060 --> 00:08:35,040 to the authentication protocol, 129 00:08:35,300 --> 00:08:37,680 which does the decryption and or the integrity verification 130 00:08:38,500 --> 00:08:41,620 and going to be like turtles all the way down from here. 131 00:08:42,360 --> 00:08:46,880 These encrypted and decrypted calls are going to go on 132 00:08:46,880 --> 00:08:48,180 till the protocol terminates 133 00:08:48,180 --> 00:08:50,020 or like the network connection terminates. 134 00:08:50,020 --> 00:08:54,080 So, here as I was explaining, 135 00:08:54,320 --> 00:08:57,200 we are going to use LDAP as like a case study 136 00:08:57,980 --> 00:09:02,840 because it supports like all the authentication protocols 137 00:09:02,840 --> 00:09:09,740 and more than that shows like the generational weaknesses 138 00:09:10,060 --> 00:09:16,520 in, I would say like in any single place. 139 00:09:16,740 --> 00:09:19,840 But whatever, we are going to, the alcohol, 140 00:09:20,020 --> 00:09:24,940 we are going to see like what LDAP supports 141 00:09:24,940 --> 00:09:26,000 as authentication methods 142 00:09:26,000 --> 00:09:28,600 and how we can maybe proxify some of these. 143 00:09:30,920 --> 00:09:31,540 Moving on. 144 00:09:31,720 --> 00:09:35,000 Yes, so LDAP has a Sicily authentication. 145 00:09:35,420 --> 00:09:36,920 How many of you are familiar 146 00:09:36,920 --> 00:09:39,500 with the Sicily authentication in LDAP? 147 00:09:39,920 --> 00:09:43,420 Yeah, I'm not really seeing many hands around here. 148 00:09:43,660 --> 00:09:47,000 So, Sicily authentication is actually raw NTLM authentication 149 00:09:47,300 --> 00:09:50,000 that has been like forced inside of the LDAP. 150 00:09:50,000 --> 00:09:50,140 I think there's a couple of people 151 00:09:50,140 --> 00:09:50,500 who are familiar with the LDAP protocol 152 00:09:50,500 --> 00:09:52,200 thanks to Microsoft because they, 153 00:09:52,800 --> 00:09:55,400 when they came up with this whole NTLM stuff, 154 00:09:55,580 --> 00:09:58,100 they wanted to like stuff it like literally everywhere. 155 00:09:58,440 --> 00:10:00,580 And this is one of the main reasons 156 00:10:00,580 --> 00:10:02,140 why we cannot really get rid of it. 157 00:10:03,480 --> 00:10:06,120 So, basically what is happening here is that like, 158 00:10:06,220 --> 00:10:08,720 you can have like a root query before authentication 159 00:10:09,320 --> 00:10:11,020 that basically explain like, 160 00:10:11,100 --> 00:10:13,220 it's kind of like the version negotiation part. 161 00:10:13,500 --> 00:10:17,220 Then you have the bin request where you specify Sicily. 162 00:10:17,400 --> 00:10:19,160 And if you want to check it in Wireshark, 163 00:10:19,160 --> 00:10:20,240 this is the place where it, 164 00:10:20,340 --> 00:10:22,180 where Wireshark fails, basically. 165 00:10:22,320 --> 00:10:24,580 The sector just fails because, 166 00:10:25,540 --> 00:10:26,920 not because of security issues, 167 00:10:27,100 --> 00:10:28,880 but because like, it's just like, 168 00:10:29,980 --> 00:10:32,600 simply put a badly made protocols. 169 00:10:33,020 --> 00:10:40,100 Nobody's really using it except for nefarious reasons. 170 00:10:40,220 --> 00:10:42,840 One might want to use it. 171 00:10:43,380 --> 00:10:46,540 Anyhow, so, bin request, bin response, 172 00:10:46,840 --> 00:10:48,640 NTLM client is going to, 173 00:10:49,160 --> 00:10:50,900 kick in, NTLM client, 174 00:10:51,300 --> 00:10:53,840 like the LDAP client is going to ask the NTLM client, 175 00:10:54,140 --> 00:10:57,000 hey, like, what is the first structure 176 00:10:57,000 --> 00:10:59,420 that I need to send to the server 177 00:10:59,420 --> 00:11:00,860 so authentication can proceed? 178 00:11:01,220 --> 00:11:03,720 And NTLM is going to say this like, 179 00:11:03,820 --> 00:11:07,000 okay, like, oh, it's negotiate. 180 00:11:07,840 --> 00:11:09,680 No, that might be an issue there. 181 00:11:09,820 --> 00:11:12,360 But point is that NTLM has like, 182 00:11:12,380 --> 00:11:13,940 basically three data structures, 183 00:11:14,000 --> 00:11:18,540 the authenticate, the challenge, and the negotiate. 184 00:11:19,160 --> 00:11:21,240 Yes, okay, then it's negotiate, sorry about that. 185 00:11:21,620 --> 00:11:25,320 So basically like NTLM messages are being interposed 186 00:11:25,320 --> 00:11:26,640 on top of the LDAP protocol, 187 00:11:27,040 --> 00:11:28,380 passing them back and forth 188 00:11:28,380 --> 00:11:29,580 till the authentication finished. 189 00:11:29,860 --> 00:11:33,220 And then you have a shared secret available. 190 00:11:33,640 --> 00:11:36,380 And if, for example, like LDAP integrity is, 191 00:11:36,400 --> 00:11:37,780 integrity protection is enabled, 192 00:11:37,960 --> 00:11:41,420 then this is the shared secret that is going to be used 193 00:11:41,420 --> 00:11:44,140 for either encrypt and or integrity protect 194 00:11:44,140 --> 00:11:45,840 your LDAP messages in the future. 195 00:11:47,060 --> 00:11:47,620 Okay. 196 00:11:47,620 --> 00:11:47,680 Okay. 197 00:11:47,760 --> 00:11:50,020 So quick word about Espinego. 198 00:11:50,740 --> 00:11:52,140 Espinego is basically 199 00:11:52,140 --> 00:11:55,760 an authentication protocol selector protocol. 200 00:11:56,480 --> 00:11:59,240 That's a tongue twister. 201 00:11:59,840 --> 00:12:03,620 That supports LDAP, Kerberos, the other type of Kerberos, 202 00:12:03,740 --> 00:12:04,960 and potentially it could support 203 00:12:04,960 --> 00:12:07,980 other authentication protocols as sub protocols, 204 00:12:08,300 --> 00:12:09,700 but mostly like these are the, 205 00:12:09,760 --> 00:12:11,840 like NTLM and Kerberos are the two main ones 206 00:12:11,840 --> 00:12:14,920 that are being used in a normal day-to-day life. 207 00:12:15,900 --> 00:12:17,440 So Espinego, it's a, 208 00:12:17,620 --> 00:12:20,260 does not provide authentication. 209 00:12:20,700 --> 00:12:23,580 It is just a way for the client and the server 210 00:12:23,580 --> 00:12:25,760 to agree on an authentication protocol 211 00:12:25,760 --> 00:12:27,080 to be used in the future. 212 00:12:27,500 --> 00:12:30,580 And one of the tidbits is that Espinego 213 00:12:31,000 --> 00:12:37,180 has an added integrity protection in itself. 214 00:12:37,480 --> 00:12:41,080 So basically it is to protect against downgrade attack, 215 00:12:41,180 --> 00:12:42,720 like not downgrade attacks, 216 00:12:43,080 --> 00:12:46,360 depending on if you think like NTLM is more secure 217 00:12:46,360 --> 00:12:47,600 or less secure than Kerberos, 218 00:12:47,600 --> 00:12:52,320 but this integrity integrity protection requires 219 00:12:52,720 --> 00:12:54,700 after the NTLM authentication finished 220 00:12:54,700 --> 00:12:56,260 as the sub authentication module 221 00:12:56,760 --> 00:13:04,980 to use the secret key to sign the Espinego packet 222 00:13:04,980 --> 00:13:08,940 that has been sent by the client from the server. 223 00:13:09,100 --> 00:13:11,620 So it verifies that the client in fact, 224 00:13:12,080 --> 00:13:15,120 receive like requested only NTLM authentication 225 00:13:15,720 --> 00:13:17,580 and not somebody who was doing it. 226 00:13:17,580 --> 00:13:17,680 So it's like, 227 00:13:17,680 --> 00:13:20,200 I'm in the middle and removing the Kerberos part 228 00:13:20,200 --> 00:13:21,900 from the request. 229 00:13:23,780 --> 00:13:26,020 Yeah, so LDAP. 230 00:13:26,500 --> 00:13:28,020 LDAP supports like these, 231 00:13:28,120 --> 00:13:31,520 the following three main authentication protocol classes. 232 00:13:31,760 --> 00:13:33,260 One is called Simple. 233 00:13:33,500 --> 00:13:35,380 The Simple can have plain, 234 00:13:35,580 --> 00:13:37,060 which is like user and password. 235 00:13:37,540 --> 00:13:39,400 Obviously there is no integrity protection 236 00:13:39,400 --> 00:13:41,920 and no like secret key exchange after that, 237 00:13:42,020 --> 00:13:43,860 because you are literally sending the username 238 00:13:43,860 --> 00:13:44,800 and plain text password. 239 00:13:44,800 --> 00:13:46,700 There is also none, 240 00:13:46,880 --> 00:13:48,580 which is we call anonymous bind. 241 00:13:48,860 --> 00:13:49,840 There is Sicily, 242 00:13:50,020 --> 00:13:52,180 which is like, it still bugs me 243 00:13:52,180 --> 00:13:55,020 that it's still enabled everywhere. 244 00:13:55,380 --> 00:13:59,280 And we have the SASL and inside of the SASL, 245 00:13:59,340 --> 00:14:01,840 you can find Espinego and GSS API. 246 00:14:02,320 --> 00:14:08,160 And yeah, the external one is really, really interesting 247 00:14:08,160 --> 00:14:12,920 because it's basically the external one presumes 248 00:14:12,920 --> 00:14:14,200 that you have created, 249 00:14:14,800 --> 00:14:17,420 like an MTLS connection already to the LDAP server. 250 00:14:17,760 --> 00:14:20,400 And the external does not provide any other information. 251 00:14:20,620 --> 00:14:21,820 Just, it just says, that's like, 252 00:14:21,920 --> 00:14:24,360 hey, I already authenticated to you, 253 00:14:24,420 --> 00:14:27,760 but over TLS or SSL. 254 00:14:27,860 --> 00:14:29,920 So please like verify that one. 255 00:14:30,160 --> 00:14:32,360 And since I'm verified, then just let me in. 256 00:14:32,580 --> 00:14:34,680 And this is really, really useful 257 00:14:34,680 --> 00:14:39,820 if you are doing like ADCS attacks, for example, depending. 258 00:14:40,060 --> 00:14:44,720 So just a quick rundown on how the LDAP, 259 00:14:44,800 --> 00:14:47,340 SASL, Espinego, NTLM authentication works. 260 00:14:47,720 --> 00:14:48,880 And I believe like, 261 00:14:49,020 --> 00:14:51,200 this is going to be the most complex one. 262 00:14:51,340 --> 00:14:54,460 I don't want to torture you further. 263 00:14:55,360 --> 00:14:58,960 So basically LDAP client kicks in, 264 00:14:59,060 --> 00:15:02,080 connects to the server via TCP, hopefully. 265 00:15:02,860 --> 00:15:06,900 Then there is some version negotiation with root query. 266 00:15:07,800 --> 00:15:09,280 Espinego client kicks in. 267 00:15:09,520 --> 00:15:12,620 Espinego client is going to like instruct the LDAP client 268 00:15:12,620 --> 00:15:13,840 to send basically the, 269 00:15:14,980 --> 00:15:17,760 supported authentication protocols to the LDAP server. 270 00:15:18,020 --> 00:15:20,460 LDAP server is going to kick in the Espinego server 271 00:15:21,060 --> 00:15:22,580 saying that, hey, I got a new client. 272 00:15:22,700 --> 00:15:23,700 This is what they support. 273 00:15:24,120 --> 00:15:25,000 What should I reply? 274 00:15:25,440 --> 00:15:28,020 It should, like the reply of the Espinego server 275 00:15:28,020 --> 00:15:30,140 is then interposed onto the LDAP client 276 00:15:30,140 --> 00:15:32,740 and LDAP client relays it to the Espinego client. 277 00:15:32,980 --> 00:15:35,660 And you know, you get the gist. 278 00:15:35,760 --> 00:15:37,700 Like you don't need to read it through, 279 00:15:38,420 --> 00:15:40,500 maybe at home because there's going to be a test tomorrow. 280 00:15:41,720 --> 00:15:44,060 So how Kerberos authentication works. 281 00:15:44,800 --> 00:15:46,260 Kerberos, if we are not talking 282 00:15:46,260 --> 00:15:50,580 about mutual authentication for Kerberos, 283 00:15:50,720 --> 00:15:52,640 then it's going to be really simple. 284 00:15:52,900 --> 00:15:56,320 The reason why it is so simple is because like the actual 285 00:15:56,320 --> 00:15:59,040 Kerberos communication is not being shown on this slide 286 00:15:59,400 --> 00:16:02,180 because like the complexity is done on the other side, 287 00:16:02,240 --> 00:16:03,160 on the other end. 288 00:16:03,300 --> 00:16:07,180 So basically then LDAP is just basically using Espinego 289 00:16:07,180 --> 00:16:10,080 to instruct the Kerberos client to request a ticket. 290 00:16:10,220 --> 00:16:12,000 And then they just send this ticket 291 00:16:12,360 --> 00:16:13,580 and this ticket is already, 292 00:16:14,800 --> 00:16:17,560 this ticket already contains the shared secret. 293 00:16:18,510 --> 00:16:23,380 So let's talk about SMB, encryption, decryption, 294 00:16:24,290 --> 00:16:29,540 because it is a bit different than like Kerberos 295 00:16:29,540 --> 00:16:30,540 and normal NTLM. 296 00:16:30,640 --> 00:16:35,980 So Kerberos and NTLM themselves provide encryption 297 00:16:35,980 --> 00:16:38,340 and decryption algorithms to be used, 298 00:16:38,380 --> 00:16:39,780 which are specified by RFC. 299 00:16:39,980 --> 00:16:44,500 And NTLM encryption, decryption, RFC, the errata, 300 00:16:44,800 --> 00:16:46,580 is larger than the actual RFC. 301 00:16:47,460 --> 00:16:48,840 That should tell you something. 302 00:16:50,040 --> 00:16:53,360 But mostly, like besides LDAP, 303 00:16:53,420 --> 00:16:56,220 like not many other protocols are actually taking advantage 304 00:16:56,220 --> 00:16:58,400 of NTLM encryption, decryption, 305 00:16:59,200 --> 00:17:01,280 probably because it's based on RC4, 306 00:17:01,500 --> 00:17:03,280 but I don't know that part. 307 00:17:04,660 --> 00:17:07,520 Yeah, so how SMB does it, however, 308 00:17:07,640 --> 00:17:11,420 is that SMB says this like, oh, like it's really nice 309 00:17:11,420 --> 00:17:14,480 and cute that you are like defining your own RFC and your 310 00:17:14,480 --> 00:17:16,440 own encryption and decryption methods, 311 00:17:16,720 --> 00:17:20,740 but actually I am Microsoft, I don't really care about it. 312 00:17:21,160 --> 00:17:23,980 So how about just give me the secret key 313 00:17:24,320 --> 00:17:26,780 and I'll deal with the rest. 314 00:17:27,180 --> 00:17:29,760 And this is like, this is going to be like super important 315 00:17:29,760 --> 00:17:32,900 later for us when we are actually trying to rebuild 316 00:17:32,900 --> 00:17:35,100 some authentication context on our own machines. 317 00:17:37,080 --> 00:17:40,200 So yeah, Microsoft has this SSPI. 318 00:17:40,940 --> 00:17:43,020 SSPI is a set of APIs that 319 00:17:44,480 --> 00:17:45,800 are like that you can, 320 00:17:45,880 --> 00:17:48,300 that allows you to interface with Alsace 321 00:17:49,020 --> 00:17:50,480 in a programmatical way. 322 00:17:50,740 --> 00:17:54,380 And SSPI is basically created because, 323 00:17:55,140 --> 00:17:59,520 as some of you might know, Alsace caches some credentials. 324 00:18:00,840 --> 00:18:03,260 I don't know if it's a big secret or not, 325 00:18:03,420 --> 00:18:06,100 but yeah, it caches some credentials, 326 00:18:06,340 --> 00:18:07,980 some like sometimes plain text, 327 00:18:08,060 --> 00:18:09,700 sometimes not really plain text credentials, 328 00:18:09,880 --> 00:18:10,600 but they are there. 329 00:18:10,760 --> 00:18:14,040 The reason why they are there is because you have like millions 330 00:18:14,040 --> 00:18:16,800 of, like a million processes running on your computer 331 00:18:17,120 --> 00:18:18,540 in a Windows domain environment, 332 00:18:18,820 --> 00:18:21,940 and these processes ad hoc want to connect to the DC 333 00:18:21,940 --> 00:18:23,380 or to some other servers. 334 00:18:23,640 --> 00:18:28,400 And yeah, it's not really nice if we ping the user 335 00:18:28,400 --> 00:18:31,260 every time of a random background process 336 00:18:31,260 --> 00:18:32,760 which is to authenticate to the DC 337 00:18:32,760 --> 00:18:36,760 just to get the credentials every single time. 338 00:18:37,420 --> 00:18:42,280 So SSPI is the way that like a user land application 339 00:18:42,280 --> 00:18:45,620 or a user land process would perform 340 00:18:45,620 --> 00:18:49,600 like an authentication either with or without 341 00:18:49,600 --> 00:18:52,940 the user consent or yeah, 342 00:18:53,040 --> 00:18:55,580 they don't really care about consent in this part, 343 00:18:55,740 --> 00:18:58,760 but like there is a way to set it up 344 00:18:58,760 --> 00:18:59,800 that it prompts the user, 345 00:18:59,960 --> 00:19:02,720 but like why would you use that 346 00:19:03,280 --> 00:19:05,720 if you are on the attacker side, of course. 347 00:19:08,280 --> 00:19:11,860 So SSPI defines a kind of handful 348 00:19:11,860 --> 00:19:13,320 of API calls, 349 00:19:13,560 --> 00:19:15,280 but for the sake of this discussion, 350 00:19:16,090 --> 00:19:20,280 we only need to take five into account. 351 00:19:21,100 --> 00:19:24,180 Acquire credential handle, initialize security context, 352 00:19:24,480 --> 00:19:27,760 query context attributes, encrypt and decrypt message. 353 00:19:28,060 --> 00:19:29,360 This is how we roll. 354 00:19:29,500 --> 00:19:33,740 Like if you have like a legit or an illegit process, 355 00:19:35,080 --> 00:19:40,200 then this is only the five that you would need to implement 356 00:19:40,200 --> 00:19:44,060 to get the authentication action rolling. 357 00:19:45,460 --> 00:19:48,940 So again, generalization, how it looks like. 358 00:19:49,360 --> 00:19:53,000 So basically client would like to connect to the, 359 00:19:53,040 --> 00:19:54,760 would like to authenticate to the server. 360 00:19:54,940 --> 00:19:57,980 So client on its own end is going to first invoke 361 00:19:57,980 --> 00:20:01,040 acquire credential handle that is going to create 362 00:20:01,040 --> 00:20:02,920 like an authentication context, 363 00:20:03,120 --> 00:20:05,080 like on the Alsace level, 364 00:20:05,920 --> 00:20:09,840 then for every single like authentication message that, 365 00:20:10,200 --> 00:20:13,260 that needs to be passed between the client and the server, 366 00:20:13,400 --> 00:20:15,880 the client is going to constantly invoke 367 00:20:15,880 --> 00:20:17,860 the initialized security context part, 368 00:20:19,180 --> 00:20:23,020 up till to the point where the initialized security context 369 00:20:23,020 --> 00:20:25,860 actually from the client part comes back 370 00:20:25,860 --> 00:20:28,020 to the network client and says this like, 371 00:20:28,120 --> 00:20:29,420 okay, we are finished. 372 00:20:29,620 --> 00:20:32,860 And like, I believe that we have like a good go 373 00:20:32,860 --> 00:20:34,600 at this authentication part. 374 00:20:35,080 --> 00:20:37,140 So if the result is okay, 375 00:20:37,300 --> 00:20:39,800 then there is going to be a shared secret. 376 00:20:39,800 --> 00:20:42,080 Like the shared secret that we were explaining 377 00:20:42,080 --> 00:20:43,440 in the general overview. 378 00:20:43,700 --> 00:20:45,020 This shared secret, however, 379 00:20:45,140 --> 00:20:50,460 is going to be kept in the Alsace process or something like, 380 00:20:51,160 --> 00:20:52,660 no, it's probably it's in that, 381 00:20:52,700 --> 00:20:54,280 like it is in the Alsace processor. 382 00:20:55,020 --> 00:20:58,840 And then there is a problem. 383 00:20:59,000 --> 00:21:01,640 So like, so far so good, because like you are not, 384 00:21:02,060 --> 00:21:06,940 you're not an administrator or some high integrity process. 385 00:21:07,120 --> 00:21:09,480 So you cannot get out these keys. 386 00:21:09,800 --> 00:21:13,160 However, there is actually an API call, 387 00:21:13,840 --> 00:21:17,580 because what happens if, for example, in SMB's case, 388 00:21:17,780 --> 00:21:20,720 SMB decides to implement their own encryption 389 00:21:20,720 --> 00:21:22,220 and decryption algorithms, 390 00:21:22,460 --> 00:21:24,700 and they would need to have the key for that, 391 00:21:24,840 --> 00:21:26,180 like the shared key, right? 392 00:21:26,320 --> 00:21:28,960 What happens if like some, 393 00:21:29,160 --> 00:21:32,280 like my process would like to have that as well? 394 00:21:32,740 --> 00:21:39,600 So therefore we have the query context attributes API 395 00:21:39,800 --> 00:21:42,740 call, which you can invoke after the authentication 396 00:21:42,740 --> 00:21:44,300 has finished successfully. 397 00:21:44,860 --> 00:21:48,200 And the query context attribute, like this API, 398 00:21:48,440 --> 00:21:49,400 I'm not going to say it again, 399 00:21:50,320 --> 00:21:54,940 is actually there to query like a lot of different aspects 400 00:21:54,940 --> 00:21:56,600 of the current authentication context. 401 00:21:56,820 --> 00:21:59,340 And one of these aspects is to actually give you back 402 00:21:59,340 --> 00:22:02,760 the secret key, like the shared key that has been generated 403 00:22:02,760 --> 00:22:05,220 based on like either Kerberos or anti-LMR, 404 00:22:05,400 --> 00:22:06,660 Credit SSP, whatever. 405 00:22:07,400 --> 00:22:09,520 And this is super useful for us. 406 00:22:09,800 --> 00:22:15,300 Actually, because, yeah, almost, almost. 407 00:22:15,480 --> 00:22:17,020 So this is super useful for us, 408 00:22:17,080 --> 00:22:21,640 because what we can do here is that now like we can, 409 00:22:21,860 --> 00:22:25,140 like from our machine can instruct Alsace 410 00:22:25,140 --> 00:22:27,000 to perform authentication for us. 411 00:22:27,120 --> 00:22:28,360 So authentication is done. 412 00:22:28,540 --> 00:22:31,280 What we need is the secret key, 413 00:22:31,400 --> 00:22:35,040 and we can now request Alsace to give us the secret key. 414 00:22:35,300 --> 00:22:39,740 Well, what happens if like, can we do it remotely? 415 00:22:39,800 --> 00:22:42,520 I mean, like it's just like four API calls. 416 00:22:42,760 --> 00:22:44,960 So like if you build like an RPC 417 00:22:44,960 --> 00:22:47,700 that is wrapping these four or five API calls, 418 00:22:47,900 --> 00:22:50,240 then you should be golden, right? 419 00:22:50,420 --> 00:22:52,940 Now there is, there is kind of a problem 420 00:22:52,940 --> 00:22:57,540 because there is a special case 421 00:22:58,180 --> 00:23:00,780 that like Kerberos Mutual Authentication. 422 00:23:01,160 --> 00:23:02,800 In Kerberos Mutual Authentication, 423 00:23:03,720 --> 00:23:07,300 you will need to have like, in any way, sorry. 424 00:23:07,780 --> 00:23:09,780 You will need to have, not just the, the IP address. 425 00:23:09,780 --> 00:23:14,540 secret key but also the IV. But how are you going to get the IV? The query 426 00:23:14,540 --> 00:23:22,140 contest attributes API does not tell you the IV at all and in normal 427 00:23:23,060 --> 00:23:28,940 situations like in NTLM you don't need the IV because it's RC4 so why would 428 00:23:28,940 --> 00:23:34,420 you need an IV? For Kerberos case the IV if it's not mutual then you can read it 429 00:23:34,420 --> 00:23:38,780 out from the ticket itself. But if it's a mutual authentication that means that 430 00:23:38,780 --> 00:23:42,820 like the the actual client and the server are going to do like another 431 00:23:42,820 --> 00:23:49,200 round trip of exchanging tickets then the the session key like the 432 00:23:49,200 --> 00:23:54,920 ticket that finally you end up with in the client is going to contain the IV 433 00:23:54,920 --> 00:23:59,240 but you cannot decrypt that that part of the ticket that contains the IV and 434 00:23:59,240 --> 00:24:05,500 Alsace doesn't give you that. So this this gave me a bit of a like a hard time 435 00:24:05,500 --> 00:24:08,660 to figure out but then it clicked on me 436 00:24:08,660 --> 00:24:13,420 basically if we have the anchor like the encrypt message and decrypt message so 437 00:24:13,420 --> 00:24:18,280 taking the encrypt message is going to wrap our data whatever data that we are 438 00:24:18,280 --> 00:24:23,180 encrypting in a token and that token must have the current initialization 439 00:24:24,260 --> 00:24:28,300 vector otherwise like the other side would not be able to decrypt it right so 440 00:24:28,300 --> 00:24:33,800 this was the missing piece of the puzzle now we have basically we can out like we 441 00:24:33,800 --> 00:24:40,420 can make else's authenticate if we can have the initialization vector and we 442 00:24:40,420 --> 00:24:48,260 can have the secret key as well so your else's but on my machine the goal is 443 00:24:48,260 --> 00:24:55,040 basically to create wrappers for these four API calls no sorry five API calls 444 00:24:55,040 --> 00:25:02,120 and that is the easy part the hard part is that now you have two choices now you 445 00:25:02,120 --> 00:25:03,300 either need to 446 00:25:04,620 --> 00:25:10,300 modify your own attacking machines else's process to to interface with this 447 00:25:10,300 --> 00:25:17,280 to be leveraging this new newly created like RPC or you would rewrite each and 448 00:25:17,280 --> 00:25:21,180 every single like authentication protocol that you want to deal with and 449 00:25:21,180 --> 00:25:29,960 since I love authentication protocols guess what where I ended up so it took I 450 00:25:29,960 --> 00:25:32,200 would say like roughly two years 451 00:25:34,320 --> 00:25:38,440 but yeah so I came up with an authentication library that look for 452 00:25:38,440 --> 00:25:44,240 Python that is like that is used by all of my like network implementations that 453 00:25:44,240 --> 00:25:53,000 leverages these type of like RPC calls how does it look like so again you don't 454 00:25:53,000 --> 00:25:53,560 have to read it 455 00:25:53,560 --> 00:25:59,100 oh it's actually okay I like kind of like how it turned out basically what 456 00:25:59,100 --> 00:26:02,320 you're seeing here is that you can 457 00:26:03,800 --> 00:26:10,240 you can perform these these RPC calls I'm not going to go over each and every 458 00:26:10,240 --> 00:26:13,440 step because I don't want to make this presentation one and a half hours long 459 00:26:13,440 --> 00:26:25,960 the final part of of this is sorry yes yes so basically what we were discussing 460 00:26:25,960 --> 00:26:29,420 before is that there are like two ways that you can do the encryption 461 00:26:29,420 --> 00:26:33,680 decryption part because my first instinct since I could not get the IV 462 00:26:33,800 --> 00:26:38,280 out any like I could not figure out how to get the IV what I did is that's like 463 00:26:38,280 --> 00:26:43,180 for each and every encrypt and decrypt message call I was performing at yet 464 00:26:43,180 --> 00:26:49,320 another set of RPC calls to inject back the encrypted data from my machine back 465 00:26:49,320 --> 00:26:53,540 to the victims machine and make the else's decrypt this and send back the 466 00:26:53,540 --> 00:27:00,580 the raw data now this is not really the the let's say it's not really a useful 467 00:27:00,580 --> 00:27:03,680 solution because it just hogs the the bandwidth 468 00:27:03,800 --> 00:27:12,060 of it however here what you have is that with this for with the previously 469 00:27:12,060 --> 00:27:16,940 explained get session key and then encrypt message with some random message 470 00:27:16,940 --> 00:27:21,420 and unwrapping the the response token you can basically have the entire 471 00:27:21,420 --> 00:27:26,920 encryption and decryption context back in your home machine from from the 472 00:27:26,920 --> 00:27:33,640 target from the victim's target machine so I'm I would like to 473 00:27:33,640 --> 00:27:33,780 show you a little bit of an example of how you can do this and I'm going to show you 474 00:27:33,780 --> 00:27:38,840 two use cases for it actually multiple use cases but like two which I have a 475 00:27:38,840 --> 00:27:48,580 demo for one is how does it get how did it get here sorry one is just basically 476 00:27:48,580 --> 00:27:53,020 the proof of concept code is going to be executed in the victims machine and then 477 00:27:53,020 --> 00:27:57,340 from another machine we are going to perform an authentication to the domain 478 00:27:57,340 --> 00:27:57,740 controller 479 00:28:04,280 --> 00:28:13,200 let's hope that the codec works this time I see the video here just 480 00:28:13,200 --> 00:28:25,860 oh that's nice because now I have to look over here 481 00:28:31,120 --> 00:28:37,560 okay so the attacker machine is on top it's a Ubuntu machine and the victim 482 00:28:37,560 --> 00:28:45,740 machine knows is on the bottom so at first we are just going we are just 483 00:28:45,740 --> 00:28:49,360 going to show that's like we are not administrators we are not like in a 484 00:28:49,360 --> 00:28:55,340 highly privileged users group and then if everything finished and we are going 485 00:28:55,340 --> 00:28:57,180 to execute this proxy binary 486 00:28:57,740 --> 00:29:02,940 and this proxy binary let's stop here this proxy binary currently is just like 487 00:29:02,940 --> 00:29:06,120 listening on the port on the victim machine obviously this is not the way 488 00:29:06,120 --> 00:29:09,360 that you would do it in a real-life scenario this is just for proof of 489 00:29:09,360 --> 00:29:15,180 proof of concept sake and yeah on the target machine what you see here is that 490 00:29:15,180 --> 00:29:27,100 basically V told the library the some be library to yeah so with all the SMB 491 00:29:27,100 --> 00:29:27,720 library to 492 00:29:27,720 --> 00:29:33,100 to like not to use any like actual credentials but to use the username 493 00:29:33,100 --> 00:29:40,120 sorry the the IP like the RPC server on the IP address and port that of the 494 00:29:40,120 --> 00:29:45,320 victim machine and as soon as basically I executed the like I gave the 495 00:29:45,320 --> 00:29:54,440 instruction let's just go back to the URL quickly if we can oh sorry here so 496 00:29:54,440 --> 00:29:57,700 on top basically that is the only information that 497 00:29:57,720 --> 00:30:03,960 the a SMB client is is using so we have the IP address of the target machine two 498 00:30:03,960 --> 00:30:12,120 times basically because not just one times three and the port is by by 499 00:30:12,120 --> 00:30:16,580 default it's set to something doesn't really matter so the point is SMB 500 00:30:16,580 --> 00:30:24,500 connection is going to basically work immediately and we can yeah so we can 501 00:30:24,500 --> 00:30:26,520 perform on authentication here 502 00:30:29,260 --> 00:30:30,500 thank you 503 00:30:34,700 --> 00:30:40,040 so yeah it's just a guy deliberately printed out all the debug data so we 504 00:30:40,700 --> 00:30:47,520 can we can see what is happening there and for the other protocol is basic ups 505 00:30:47,520 --> 00:30:55,260 sorry going back there so just just to show that it actually works so like it 506 00:30:55,260 --> 00:30:57,640 lists the shares and I can like we can 507 00:30:57,720 --> 00:31:03,560 actually download the file from the from the destination yes so that was for SMB 508 00:31:03,560 --> 00:31:15,780 and we have one for one for LDAP as well and that should be coming soon yeah 509 00:31:17,040 --> 00:31:21,780 basically the the command is exactly the same and yeah we logged in to the DC 510 00:31:21,780 --> 00:31:27,620 via LDAP and here we are listing the the SPM 511 00:31:27,720 --> 00:31:34,080 and like the Kerberos to be users for the time being ok sorry I just need to 512 00:31:34,080 --> 00:31:38,020 speed it up because times is of the essence 513 00:31:44,000 --> 00:31:47,280 we have it here 514 00:31:47,840 --> 00:31:55,020 yeah that was the first demo so this was one use case the second use case is that 515 00:31:55,020 --> 00:31:57,700 basically you can use this technology 516 00:31:57,720 --> 00:32:05,260 by grabbing a Raspberry Pi, like a single one, you can make it a USB dongle, you can 517 00:32:05,260 --> 00:32:10,960 add some clever techniques to make it act as a keyboard, like a rubber ducky 518 00:32:10,960 --> 00:32:17,320 for example, and also to act as a USB Ethernet device. If you set up DHCP 519 00:32:17,320 --> 00:32:22,000 server, Wi-Fi access point, whatever, then you can create a really really neat 520 00:32:22,000 --> 00:32:27,980 attack tool with it, because as we have seen in the previous slides, this 521 00:32:27,980 --> 00:32:33,720 technique does not require the attacker to know anything prior about the target 522 00:32:33,720 --> 00:32:39,540 domain. If there is a user account that is actually active and the 523 00:32:39,540 --> 00:32:45,900 user has executed this proxy library, then everything else can happen, like 524 00:32:45,900 --> 00:32:49,800 all the authentication and all the attacks are happening from another 525 00:32:49,800 --> 00:32:50,300 machine, 526 00:32:50,300 --> 00:32:55,180 machine. And the basic domain information can be pulled, for 527 00:32:55,180 --> 00:33:01,400 example, like the logon server. And since all users can pull 528 00:33:01,400 --> 00:33:04,820 information from the LDAP, then it just basically trickles down 529 00:33:05,280 --> 00:33:10,480 and you don't need to add any, you don't need to, like if you 530 00:33:10,480 --> 00:33:13,260 have an embedded system, you don't need to add any specific 531 00:33:13,260 --> 00:33:16,760 like target specific code. This means that like if you put 532 00:33:16,760 --> 00:33:21,040 everything together in a small Raspberry Pi, which is kind of 533 00:33:21,040 --> 00:33:24,540 like on the desk, for example, then what you are going to end 534 00:33:24,540 --> 00:33:30,120 up with is like a pawn everything toolkit. Because if 535 00:33:30,400 --> 00:33:36,000 the proxy is going to, is successfully executed, and the 536 00:33:36,000 --> 00:33:40,220 way that it's being executed is that if you plug it in, I'm just 537 00:33:40,220 --> 00:33:46,200 going to go on a ramble, sorry. So if you plug this device in, 538 00:33:46,300 --> 00:33:46,740 then it's going to, it's going to, it's going to, it's going 539 00:33:46,740 --> 00:33:49,440 to show itself to the target machine, an unlocked target 540 00:33:49,440 --> 00:33:53,080 machine. What is going to show itself as a keyboard, like an 541 00:33:53,080 --> 00:33:58,200 HID keyboard, and USB Ethernet device, right? With the HID 542 00:33:58,200 --> 00:34:01,920 keyboard, your attacker code, like just like with the rubber 543 00:34:01,920 --> 00:34:05,040 docky, you control the key code, you can instruct the 544 00:34:05,040 --> 00:34:09,180 machine to execute the binary, like the proxy binary, and the 545 00:34:09,180 --> 00:34:11,900 proxy binary is not going to go out to the Internet because you 546 00:34:11,900 --> 00:34:14,080 don't know if there is an Internet or not on the target 547 00:34:14,080 --> 00:34:16,720 machine. But what you know is that if there is an Internet on 548 00:34:16,720 --> 00:34:18,640 the target machine, it has access to at least one network 549 00:34:18,640 --> 00:34:21,500 because you provided this network to it via the Raspberry 550 00:34:21,500 --> 00:34:25,200 Pi. And then this proxy machine can connect back to the Raspberry 551 00:34:25,200 --> 00:34:28,900 Pi, and then whatever application is running inside 552 00:34:28,900 --> 00:34:32,820 of this Raspberry Pi can immediately leverage the user 553 00:34:32,820 --> 00:34:37,400 authentication context of the, of the target machine. So 554 00:34:37,400 --> 00:34:41,700 basically, like with some clever engineering, with this 555 00:34:41,700 --> 00:34:46,700 technique, you can do, like, a pawn all Raspberry Pi, and then 556 00:34:46,700 --> 00:34:51,020 that works on ad gap networks as well. Like, the target doesn't 557 00:34:51,020 --> 00:34:55,860 need to have any type of access to the Internet. So, demo. 558 00:35:07,780 --> 00:35:16,520 Uh-huh. Any minute now? Okay. Stop, stop, stop, stop, stop. 559 00:35:24,400 --> 00:35:27,920 Okay. This is the victim's machine. The victim's machine is 560 00:35:27,920 --> 00:35:32,260 currently just like a, okay, thank you. The victim's machine 561 00:35:32,260 --> 00:35:37,200 is basically just a standard Windows 10 machine, and I have 562 00:35:37,200 --> 00:35:40,680 plugged in this device. Like, you will have to believe me, I 563 00:35:40,680 --> 00:35:44,000 wanted to do it on the stage, but they told me that it's, it's 564 00:35:44,000 --> 00:35:46,680 probably better to have video of everything. So, I'm going to 565 00:35:46,700 --> 00:35:51,400 do it on the stage. So, what are we going to see now is that we 566 00:35:51,400 --> 00:35:54,660 have to wait until it boots, and then virtual keyboard 567 00:35:54,660 --> 00:35:58,560 immediately starts executing the code. The actual, like, 568 00:35:58,580 --> 00:36:04,780 reverse proxy binary is served via HTTP from the HTTP server of 569 00:36:04,780 --> 00:36:10,000 the Raspberry device as well. And, yes, at this point, what 570 00:36:10,000 --> 00:36:13,660 you would see is that the proxy is executed, and you will see 571 00:36:13,660 --> 00:36:16,680 two host names and port addresses. Those are the 572 00:36:16,700 --> 00:36:20,940 two host names are the Active Directory server and over the 573 00:36:20,940 --> 00:36:27,560 LDAP port. Yeah, it's too small. I'd be able to make it bigger, 574 00:36:27,700 --> 00:36:35,580 but, oops, no. Yeah. But this is not the point. The point 575 00:36:35,580 --> 00:36:40,520 comes afterwards. So, what we can do is a bit of clever 576 00:36:40,520 --> 00:36:44,400 engineering. We can open the browser. Now, usually, this is 577 00:36:44,400 --> 00:36:46,560 not what you would do on the target machine. This 578 00:36:46,700 --> 00:36:49,080 is what you would do somewhere else. Where is the somewhere 579 00:36:49,080 --> 00:36:53,400 else? Since I explained that the Raspberry Pi has a Wi-Fi, like an 580 00:36:53,400 --> 00:36:59,580 access point, this service that I'm going to open, oops. What 581 00:36:59,580 --> 00:37:06,000 happened? Oh, yeah. So, this service is actually my OctoPwn 582 00:37:06,000 --> 00:37:10,540 project. I was explaining OctoPwn on area 41, like DEFCON 583 00:37:10,540 --> 00:37:16,340 Switzerland a year ago. And this OctoPwn integrates this 584 00:37:16,700 --> 00:37:22,500 tech technique into itself. So, what we are seeing here is that 585 00:37:22,500 --> 00:37:27,960 basically we already have a lot of information available to us 586 00:37:27,960 --> 00:37:33,320 via the tool because, like, between the time that the proxy 587 00:37:33,320 --> 00:37:36,840 connected back to OctoPwn's, like, handler server and the 588 00:37:36,840 --> 00:37:40,740 time that I opened this, the automation immediately started 589 00:37:42,280 --> 00:37:46,680 enumerating the domain. So, what we are seeing here is that 590 00:37:46,680 --> 00:37:50,880 there is, like, there is some SMB browser as well. So, like, the 591 00:37:50,880 --> 00:37:54,820 SMB connection is working. There is no, and there was, there has 592 00:37:54,820 --> 00:37:59,860 been absolutely no prior, like, user secret configured on this 593 00:37:59,860 --> 00:38:06,320 device. And we are going to perform Kerberos thing soon. So, 594 00:38:06,480 --> 00:38:12,940 we have, this is the, this part is the handler of the agent, 595 00:38:13,040 --> 00:38:16,660 like, the reverse proxy agent. And, you know, this is the 596 00:38:16,680 --> 00:38:21,120 currently, like, Kerberos thing is set as a separate entity. So, 597 00:38:21,240 --> 00:38:25,300 if I, I'm going to basically instruct the Kerberos logic to 598 00:38:25,300 --> 00:38:29,120 use the, or the, you already created LDAP session that has 599 00:38:29,120 --> 00:38:32,840 been created by the proxy authentication to the target 600 00:38:33,280 --> 00:38:39,660 domain via the proxy library. It will basically allow me to 601 00:38:39,660 --> 00:38:44,520 perform Kerberos thing on the target machine. And then, 602 00:38:44,560 --> 00:38:46,660 basically, like, we have all the, all the, you know, all the 603 00:38:46,680 --> 00:38:53,720 Kerberos tickets that we can send to Hashcat to crack. And, 604 00:38:55,940 --> 00:39:03,540 okay. Tickets. Speed up a little. Who made this video? Okay. Yeah. 605 00:39:03,620 --> 00:39:06,500 And what, what, what is happening here on this session 606 00:39:06,500 --> 00:39:11,480 while we were Kerberos thing, it also started the domain 607 00:39:11,480 --> 00:39:16,660 enumeration over LDAP and SMB, which is basically, you know, 608 00:39:16,680 --> 00:39:19,720 not Bloodhound, but Bloodhound. So, like, I basically, I 609 00:39:19,720 --> 00:39:23,740 rewrote Bloodhound in Python from scratch just for this. So, 610 00:39:23,800 --> 00:39:28,740 what we are going to see here is that there's going to be a cut. 611 00:39:28,860 --> 00:39:32,900 And after, after the enumeration has finished, we 612 00:39:32,900 --> 00:39:35,740 just, like, I'm listing here just, like, all the IP 613 00:39:35,740 --> 00:39:40,060 addresses and ports that the, the, the tool is being, that the 614 00:39:40,060 --> 00:39:44,200 tool is connecting to right now. And, yeah, we did the SMB 615 00:39:44,200 --> 00:39:45,980 enumeration since it's a virtual domain. 616 00:39:46,680 --> 00:39:50,580 There is not many, there aren't many SMB hosts. And this is 617 00:39:50,580 --> 00:39:56,260 actually, this is the representation layer of the tool, 618 00:39:56,320 --> 00:39:58,580 like, my Bloodhound implementation. It's called 619 00:39:58,580 --> 00:40:02,700 Jackdaw. And we can see that it's already, like, loading in 620 00:40:02,700 --> 00:40:06,140 the database that was generated from the other session. And 621 00:40:06,140 --> 00:40:10,000 soon, if it's loaded, what we are going to end up with is a 622 00:40:10,000 --> 00:40:16,660 canvas. Hopefully. Any second now. Yes. So, we're going to 623 00:40:16,680 --> 00:40:20,720 go to this canvas and then here are all the paths to the domain 624 00:40:20,720 --> 00:40:26,780 administrator. After, yes. Here you go. And this is fully 625 00:40:26,780 --> 00:40:27,220 automated. 626 00:40:37,960 --> 00:40:42,760 Thank you. And, yeah, I have some other slides as well, but 627 00:40:42,760 --> 00:40:46,660 this is basically the gist of it. And I hope you have, you 628 00:40:46,680 --> 00:40:50,840 know, I'm sorry. I hope you have some questions. So, I think 629 00:40:51,560 --> 00:40:57,120 we can, oh, no, sorry. Really quickly, I would like to do some 630 00:40:57,120 --> 00:41:00,040 shout outs. Hopefully the persons are inside of this room. 631 00:41:00,200 --> 00:41:03,460 So, there is a few, there is future research to be done with 632 00:41:03,460 --> 00:41:06,560 this one. Because I don't want you, I don't want you people to 633 00:41:06,560 --> 00:41:10,260 be forced using my tools. Everything, by the way, except 634 00:41:10,260 --> 00:41:13,520 for the OctoPom part, everything is going to be open source. It 635 00:41:13,520 --> 00:41:16,660 is actually already open sourced. I published it in the 636 00:41:16,680 --> 00:41:22,360 guest today. No, today afternoon. And the future of 637 00:41:22,360 --> 00:41:29,160 this research would be the, to have basically like all 638 00:41:29,160 --> 00:41:33,440 Windows-based tools leveraging this type of technique, which 639 00:41:33,440 --> 00:41:37,200 can be done. And there was a gentleman, hopefully he's here, 640 00:41:37,740 --> 00:41:42,320 called Ethical Chaos. And a few years ago he created a tool. 641 00:41:43,040 --> 00:41:46,660 And this tool is basically, I don't know if you've heard of 642 00:41:46,680 --> 00:41:50,440 it. It allows, like, it hooks every single, like, processes on 643 00:41:50,440 --> 00:41:56,160 your, like, attacker machine and overtakes the SSPI calls. Or, 644 00:41:56,240 --> 00:41:58,760 like, not just the SSPI calls, but, like, it could use to be 645 00:41:58,760 --> 00:42:01,380 overtaking the SSPI calls as well. This is some modification 646 00:42:01,380 --> 00:42:05,440 needed. And it could be integrated, like, it could be 647 00:42:05,880 --> 00:42:08,900 used with this technique that would allow basically, like, 648 00:42:09,020 --> 00:42:13,040 every already existing Windows process on your target, on your 649 00:42:13,040 --> 00:42:16,540 attacker Windows machines, your PowerShell scripts, your C 650 00:42:16,680 --> 00:42:20,660 call, browser, whatever, to leverage this technique so you 651 00:42:20,660 --> 00:42:24,280 don't have to deploy these scripts on the remote end. And 652 00:42:24,280 --> 00:42:27,940 it would be really nice to do. However, I have my own 653 00:42:27,940 --> 00:42:31,780 platform. So thank you very much. I already put, like, a 654 00:42:31,780 --> 00:42:36,820 lot of time into this one. But if somebody would like to do it, 655 00:42:36,840 --> 00:42:42,620 then, yes, go for it. Just hit me up. I can help if you need. 656 00:42:42,820 --> 00:42:46,660 The other shout out is that the other future research that I'm 657 00:42:46,680 --> 00:42:51,000 going to be doing is that there are a handful of other API calls 658 00:42:51,000 --> 00:42:55,880 that can be added here to support PKEynit and other, like, 659 00:42:55,940 --> 00:42:58,740 Windows Hello, like, certificate-based services to 660 00:42:59,400 --> 00:43:04,600 basically use the exact same type of, like, authentication 661 00:43:04,600 --> 00:43:09,860 proxying, which might be interesting. I am going to work 662 00:43:09,860 --> 00:43:14,960 on this part definitely because I know at least one person who 663 00:43:14,960 --> 00:43:16,500 might be really interested. 664 00:43:17,240 --> 00:43:22,580 And, yes, so thank you for everybody who is on these slides. 665 00:43:22,880 --> 00:43:28,060 Your research has helped me tremendously. And also here are 666 00:43:28,060 --> 00:43:31,940 the links with all the, like, open source tools that you have 667 00:43:31,940 --> 00:43:39,060 seen here on this talk. The WSnet-dotnet is the actual, like, 668 00:43:39,060 --> 00:43:45,640 proxy that has been used here. And QA time. If you have time. 669 00:43:52,080 --> 00:43:54,800 Thank you. 670 00:43:55,680 --> 00:43:57,040 . 671 00:44:00,480 --> 00:44:01,840 . 672 00:44:01,840 --> 00:44:02,960 . 673 00:44:02,960 --> 00:44:04,060 . 674 00:44:04,060 --> 00:44:04,120 . 675 00:44:04,120 --> 00:44:04,260 . 676 00:44:04,260 --> 00:44:04,520 . 677 00:44:04,520 --> 00:44:04,540 . 678 00:44:04,540 --> 00:44:04,660 . 679 00:44:04,660 --> 00:44:04,680 . 680 00:44:10,440 --> 00:44:11,800 . 681 00:44:11,800 --> 00:44:11,820 . 682 00:44:16,680 --> 00:44:16,980 . 683 00:44:33,340 --> 00:44:34,540 . . 684 00:44:35,560 --> 00:44:36,460 . . 685 00:44:36,460 --> 00:44:36,620 . . 686 00:44:36,620 --> 00:44:37,140 . . . 687 00:44:37,140 --> 00:44:42,140 Maybe in two hours it will be detected, I wouldn't know. 688 00:44:44,700 --> 00:44:49,720 But I already implemented it in Rust and Nim, but I'm not going to provide that part. 689 00:44:53,600 --> 00:44:55,020 Any other questions? 690 00:44:55,960 --> 00:44:56,480 No? 691 00:44:56,660 --> 00:44:57,640 Thank you very much.