WEBVTT

00:00.000 --> 00:06.600
All right, welcome everyone to turning Microsoft's login page into our phishing infrastructure.

00:06.720 --> 00:12.240
And most importantly, welcome to our special guests from Microsoft, right?

00:12.240 --> 00:16.380
Welcome people from Microsoft, because you guys really have to be my biggest fans.

00:16.380 --> 00:27.340
See, when my talk title and description got published by DEF CON, I finally quickly received an email from Microsoft Security Response Center asking me for a preview of my slides.

00:27.340 --> 00:37.240
However, the thing is, before I actually published this presentation to DEF CON, I already made the decision that I would not be sharing anything with Microsoft.

00:37.240 --> 00:40.720
And you'd be thinking, okay, but what about responsible disclosure then?

00:40.720 --> 01:01.220
And I agree actually, but the thing is, if I would have reported this to Microsoft without this talk being a thing, I know for certain that they would just have returned there or provide me their classic response saying there's not a vulnerability, it does not meet the bar to do immediate servicing,

01:01.220 --> 01:01.760
right?

01:01.760 --> 01:19.800
So to save some time for the both of us, I responded to them and said, look, everything I will be sharing in my talk will not meet any bar for immediate servicing, so let's save some time for both of us and you don't need to worry about it.

01:19.800 --> 01:21.560
But they weren't really happy with that.

01:21.560 --> 01:30.640
They still encouraged me to submit my findings to the MSRC for review, even if they don't meet servicing requirements and bounty eligibility, right?

01:30.640 --> 01:34.260
And when that didn't work, they were very persistent.

01:34.260 --> 01:43.620
They sent me an invitation for a conversation with some free food and drinks, hoping that maybe that would get me to share my talk.

01:43.620 --> 01:47.000
But once again, I said, okay, thank you for the invitation.

01:47.000 --> 01:48.480
I have something else to do.

01:48.480 --> 01:53.360
So I thought that would have been the end of that, but they were actually really, really persistent.

01:53.380 --> 02:06.560
They upped their level a little bit and they invited me to the MSRC party with the Skyfall Panoramic Bar, which has this amazing view over Las Vegas with some great food, some swag as well.

02:07.500 --> 02:16.540
So, yeah, this was a little bit too nice to turn down, so I went there, freeloading a little bit without sharing any of my talk.

02:17.940 --> 02:29.020
I am very happy that I will now be able to share my slides with Microsoft and with the rest of DEF CON also watching, but I suppose you guys will do nothing malicious with that, right?

02:29.100 --> 02:32.800
So before we start, let's do a quick introduction about myself.

02:32.800 --> 02:36.120
I am Keanu Ness, also known as RedbyteOnline.

02:36.120 --> 02:40.360
I lead a small offensive security team at a Belgian company called Spotted.

02:40.360 --> 02:51.580
I'm also the author of Graspi, an offensive security toolkit used for initial access and post-compromise enumeration of EnterID and Microsoft 365 applications.

02:51.580 --> 02:57.620
And I'm also the instructor for several Azure Red teaming trainings at Alta Security.

02:57.680 --> 02:58.820
But enough about me.

02:58.820 --> 03:03.660
Let's actually get into different stuff because I have a lot of new techniques I want to share with you guys.

03:04.900 --> 03:07.140
I'll go over a quick introduction.

03:07.140 --> 03:13.800
I'll keep this very brief because I want to use the majority of my time to actually go over the new techniques I want to share with you guys.

03:13.900 --> 03:28.220
So if you have done any type of assessments requiring you to send out realistic phishing emails without any whitelisting in place, you'll probably relate to some of these challenges that you could encounter, right?

03:28.220 --> 03:35.000
You have email security solutions that could block your suspicious links in there.

03:35.000 --> 03:43.020
There is user awareness where they focus quite a lot on hoovering over the link and seeing if the domain name is legitimate, right?

03:43.020 --> 03:48.860
Nothing we can't really get past to with a good pretext, of course.

03:48.860 --> 03:51.440
But still something we need to take into consideration.

03:52.100 --> 03:56.640
It takes quite a lot of time to get a benign domain categorization, of course.

03:56.700 --> 04:02.040
And constantly recycling your domains when they are burned can be a little bit tedious, right?

04:02.040 --> 04:05.540
So what alternatives do we actually have for that?

04:05.580 --> 04:24.240
So we have, if we don't want to use a malicious domain name, we can, for example, use consent grant attacks where we will be using the legitimate Microsoft domain and be phishing a user for consent to their permissions over their emails, their files, whatever we want without phishing their passwords,

04:24.240 --> 04:24.680
right?

04:24.680 --> 04:30.600
However, most of the interesting permissions require admin approval, especially in hardened tenants.

04:30.600 --> 04:33.640
You would see that admin approval would be required for everything.

04:33.640 --> 04:41.100
There's also verified publish restrictions, which is not that big deal to get around to, but still it's there.

04:41.100 --> 04:43.260
Device code phishing is still very useful.

04:43.260 --> 04:52.960
We still use this very effectively quite a lot during our assessments, but it could be blocked in hardened tenants as well, with conditional access policies.

04:52.960 --> 04:58.500
And then adversary in the middle is obviously very useful to make your website look very convincing.

04:58.500 --> 05:03.560
You are basically interacting with a real website, but on a malicious domain name.

05:03.560 --> 05:05.900
So that's also a drawback on that.

05:05.900 --> 05:08.720
You're basically in the same situation as previously.

05:08.900 --> 05:14.160
If your domain gets burned, you will need to rotate that and so forth, right?

05:14.160 --> 05:17.380
So I was interested in this instead.

05:17.380 --> 05:25.860
Can we use the TrustedLogin.MicrosoftOnline.com, so the login domain for use for all kinds of authentication purposes by Microsoft?

05:25.860 --> 05:28.340
Can we use this domain for phishing purposes?

05:28.420 --> 05:39.540
And I was looking into this, and I found that this was actually a little bit too easy, so I quickly changed that into, in how many ways can we abuse this Microsoft login page for phishing purposes, right?

05:39.540 --> 05:49.620
And I will show you a couple of them, starting with some basic examples where you will still have some ways to actually see that something phishy is going on if you are a little bit tech-savvy.

05:49.620 --> 05:54.620
At the end, we will be showing some very advanced techniques that completely destroy the login page.

05:54.620 --> 06:02.320
We will be extracting clear text credentials and bypassing multi-factor authentication, all while staying on this legitimate login domain, right?

06:02.320 --> 06:05.080
So without losing too much time, let's get into that.

06:05.460 --> 06:14.020
Before we do that, let me give you some honorable mentions of things that I also found, but I didn't really have too much time to talk about that.

06:14.300 --> 06:17.420
In general, these are some open redirects.

06:17.420 --> 06:18.580
I will share a couple of them.

06:18.580 --> 06:23.120
These are still working, as all of the other things that are still working, right?

06:23.160 --> 06:26.380
First, you can use Federation as an open redirect.

06:26.380 --> 06:43.180
So what you can do is you can configure a domain in your attacker tenant, set the sign-in URL for Federation to your phishing page, and then you can craft a URL that looks something like this, login.microsoftonline.com, and then with some parameters with the login hints of the domain that you set up for Federation.

06:43.240 --> 06:57.040
And if you would forward that link to your victim, it would instantly redirect to that phishing domain where you can host something like E-Village and XO, whatever you want, to craft your credentials, right?

06:57.040 --> 07:03.680
So basic open redirects, which is basically known of how Federation works.

07:03.680 --> 07:06.340
So this is probably something that they can't really patch.

07:06.340 --> 07:26.100
Additionally, another thing that you can do is you can create an app registration in your Enter ID tenant with a redirect URL to your phishing page, and then create a URL with the prompt equals non-parameter, and that would basically bypass the consent prompt being shown or any type of prompt being shown,

07:26.100 --> 07:31.080
so no login page or whatever, and it would instantly redirect to your redirect URL, right?

07:31.140 --> 07:37.460
Even if with the most restrictive consent settings, it would still instantly redirect.

07:37.580 --> 07:45.200
And then a slight alternative to that, what you can do is create, once again, an app registration with your redirect URL to your phishing page.

07:45.380 --> 08:00.000
However, here we will craft a URL with an invalid scope parameter, and what happens over here is the user will be redirected, but only after legitimate authentication, so they will still see a little bit of the login page.

08:00.000 --> 08:09.540
They will stay there, sign in with their legitimate credentials, whatever they would need, and after they sign in, usually the consent prompt would be shown.

08:09.540 --> 08:15.060
However, because we are using an invalid scope that Microsoft doesn't understand, it will throw an error.

08:15.060 --> 08:19.200
It will not show an error, but it will instantly redirect to the redirect URL, right?

08:19.220 --> 08:21.960
Even with the most restrictive user consent settings.

08:21.960 --> 08:25.740
So a couple of open redirects, which I shared.

08:25.740 --> 08:29.360
These three I shared with Microsoft to give them something.

08:29.360 --> 08:34.860
I have not received a response about that, but I'm fairly certain that this is something they can fix.

08:35.380 --> 08:38.100
I will show you a quick demo of the last one.

08:38.840 --> 08:42.360
So at the left, you have the attacker point of view.

08:42.360 --> 08:44.840
At the right, you have the user point of view.

08:44.840 --> 08:49.780
So this is the URL we would send to the user, for example, that we want to phish.

08:49.840 --> 08:51.020
So it's an invalid scope.

08:51.020 --> 08:52.560
That's the most important one.

08:52.600 --> 08:55.880
So we copy that one, paste that into the browser.

08:59.600 --> 09:03.200
All right, and you would see the other ones would instantly redirect to your phishing page.

09:03.200 --> 09:06.620
This one will stay on the Microsoft login website for a bit.

09:06.620 --> 09:11.340
It would ask you to enter your password, whatever, do multi-factor authentication if that is required.

09:11.340 --> 09:26.320
And as soon as that happens, you would see it would redirect to our malicious website, where we can, for example, say, okay, because you're accessing sensitive information, you are required to sign in once again, or you can say your password expired or whatever.

09:26.800 --> 09:31.340
But something like this would be very useful for certain pretexts, right?

09:35.260 --> 09:45.220
All right, and at the left, you can see we have Evo-GNX running, which is capturing the credentials, bypassing multi-factor authentication, and extracting the session cookies of the user.

09:45.300 --> 09:49.140
All right, so this is how that would look like.

09:50.380 --> 09:58.960
All right, so open redirects are nice, but I didn't want to talk too much about them, because, to be honest, they are not that impressive, of course.

09:58.960 --> 10:01.940
Can be useful in certain use cases if you want to use that, right?

10:01.940 --> 10:04.040
But let's look at some other approaches.

10:04.540 --> 10:08.660
And for the first one, I will be using self-service sign-up.

10:08.660 --> 10:11.000
So what is self-service sign-up?

10:11.000 --> 10:19.960
So self-service sign-up basically allows external users to sign in to applications in your tenant with their own credentials.

10:19.960 --> 10:30.320
So they will basically, when you set that up, be allowed to register a guest account in your Entra ID tenant without being invited already or anything, right?

10:30.320 --> 10:32.560
This can be useful in certain use cases.

10:32.560 --> 10:38.280
Obviously, by default, that is disabled, but you can enable that if you want that in your Entra ID tenants.

10:39.480 --> 10:46.200
And the interesting thing about this is that you can collect custom attributes during the sign-up flow, right?

10:46.200 --> 10:53.620
And you can collect certain types of default attributes, such as a job title, display name, anything you want.

10:53.620 --> 11:03.260
However, nothing stops you of creating a custom attribute called password, for example, and an additional integer, for example, called MFA code, right?

11:03.260 --> 11:14.200
So these attributes would be collected by Microsoft during the sign-in page, and the user would be requested to fill in whatever they want for these values, right?

11:14.820 --> 11:21.480
So, and then you'll probably think, okay, but how do we validate whether the password is actually correct or not, right?

11:21.480 --> 11:24.360
Because a user can fill in anything over there.

11:24.360 --> 11:26.940
So with an API connector, we can actually do that.

11:26.940 --> 11:35.540
What the API connector will allow us to do is it will allow us to do input validation of all of the inputs that is provided in these custom attributes, right?

11:35.540 --> 11:40.480
So with this, we will be able to validate the password, return an error message if it's incorrect.

11:40.480 --> 11:42.520
So let's look at how the attack would work.

11:42.520 --> 11:44.040
We send a link to the user.

11:44.040 --> 11:45.180
They would click on that.

11:45.180 --> 11:51.940
They would go to the login.microsoftonline.com domain, obviously, as all of the examples that I will be showing.

11:52.520 --> 11:57.460
And after that, they will need to sign in with their account of their home tenant, right?

11:57.460 --> 11:59.400
They will need to accept a tenant invite.

11:59.400 --> 12:06.060
And after that, they will be asked to fill in the attributes that we want, so the password and whatever, right?

12:06.360 --> 12:10.160
They will fill that in on enter ID, which will forward that to our API connector.

12:10.160 --> 12:12.660
The user does not directly interact with our domain, right?

12:12.660 --> 12:14.740
So everything goes to enter ID.

12:15.060 --> 12:16.460
So the attributes are collected.

12:16.460 --> 12:19.280
They are forwarded in cleartext to us, right?

12:19.280 --> 12:24.540
And at that point in time, we can actually validate that against enter ID if it's correct or not.

12:24.540 --> 12:28.500
If it's incorrect, we can tell the user that they need to use a different password.

12:28.500 --> 12:32.360
Otherwise, we have the credentials of the user and we compromise their account, right?

12:32.360 --> 12:36.540
We basically continue this until they provide valid credentials.

12:37.080 --> 12:39.980
All right, so this is what the URL would actually look like.

12:39.980 --> 12:49.140
So login.microsoftonline.com, client ID of the application that we set up in our attacker tenant for self-service sign-up, and then a login hint of the...

12:49.140 --> 12:51.460
This is our victim user, right?

12:51.460 --> 12:55.860
So an email address of the victim user that would allow it to be pre-populated on the sign-in page.

12:55.860 --> 12:58.980
So an additional step that the user does not need to do themselves.

12:59.080 --> 13:04.180
And we use prompt create to force the registration page to show up.

13:04.180 --> 13:05.780
Otherwise, they would need to click on something.

13:05.780 --> 13:09.440
So the more things we can automate for the user, the better, right?

13:09.440 --> 13:15.020
So prompt create plus the login hints will force the sign-in page with the pre-filled email address to be showing up.

13:15.400 --> 13:18.320
User signs in with their credentials, accept the tenant invite.

13:18.660 --> 13:25.200
This is not a consent prompt, so even if the most restrictive consent settings are configured, it would not really help there.

13:25.200 --> 13:32.980
And at that point in time, the custom attributes collection page would be shown where we capture the credentials and validate that with our API connector, right?

13:32.980 --> 13:35.920
So let's look at that with a demo.

13:36.220 --> 13:38.320
So you know how it looks like.

13:38.320 --> 13:40.560
At left, you have the attacker point of view.

13:40.560 --> 13:44.440
At the right, you have the victim user point of view.

13:44.460 --> 13:46.940
So we paste that URL that I shared previously.

13:47.320 --> 13:49.320
This is what they would end up on.

13:49.320 --> 13:52.060
So they sign in with their valid credentials.

13:54.020 --> 13:56.460
They accept the tenant invite.

13:58.180 --> 14:02.840
And then this is what the attribute collection flow would be looking like.

14:02.840 --> 14:07.760
But the interesting thing is, this is all on the legitimate login.microsoft.com online domain, right?

14:07.760 --> 14:10.700
So it has some trustworthiness to it.

14:10.700 --> 14:18.660
You can see over here, if we enter an incorrect password, we can return custom error messages saying that the password is incorrect because we can validate that.

14:18.660 --> 14:25.420
So provide a correct password with invalid MFA codes, we can return a different error message.

14:25.940 --> 14:35.640
And if the user provides a correct MFA code and a correct password, you will see that we can return a custom error message.

14:35.840 --> 14:41.540
So we can also redirect to users anywhere we want at this point in time, if we wanted to.

14:41.540 --> 14:43.700
But we have everything we need right now.

14:43.700 --> 14:47.100
We have access tokens, refresh tokens, session cookies.

14:47.100 --> 14:50.180
The complete account of the user is now compromised.

14:50.520 --> 14:52.680
All right.

14:56.000 --> 14:59.480
If you find that impressive already, wait for the next ones.

14:59.480 --> 15:01.740
So I have some backup slides.

15:02.440 --> 15:08.360
So the next one, I will be looking at abusing custom company branding, right?

15:08.360 --> 15:15.500
So custom company branding, this basically allows us to customize the look and feel of the Microsoft Entra ID sign-in page, right?

15:15.500 --> 15:17.260
So what could go wrong?

15:17.260 --> 15:18.680
Quite a lot we will see.

15:18.680 --> 15:26.900
This is from the documentation from Microsoft, all of the things that, or a couple of the things that we would be able to customize.

15:26.900 --> 15:35.120
This is used quite a lot by organizations, mostly to load a custom background for their sign-in page, for their organization.

15:35.200 --> 15:41.800
However, I've noticed that you can actually customize quite a lot more than what the documentation describes.

15:42.020 --> 15:42.360
All right.

15:42.360 --> 15:49.940
And one of the interesting things that you can do with custom company branding is inserting a custom CSS file, right?

15:49.940 --> 15:54.560
You cannot customize, luckily, any HTML or JavaScript, right?

15:54.560 --> 15:55.800
That would be really bad.

15:55.800 --> 16:03.460
However, you can customize a little bit what the page or what it would look like with CSS, right?

16:04.060 --> 16:09.400
However, not all CSS is obviously allowed because the nasty CSS is filtered out.

16:09.400 --> 16:13.660
I was looking into, okay, how does it define what is allowed and what isn't?

16:13.660 --> 16:27.620
And basically, what happens is, when I was looking into that, it will always, if you load the login page, it will always return the completely unfiltered CSS file to the browser, and then it will filter the CSS with client-side JavaScript.

16:27.620 --> 16:32.920
That basically means that we can actually see in the source code everything that it is filtering for.

16:32.920 --> 16:44.220
So for future reference, if you wanted to know, these are all the properties, CSS, add rules, functions, whatever that you are not allowed to utilize.

16:44.260 --> 16:47.860
So this was very useful to look into what we could do.

16:47.920 --> 16:51.980
So I was playing with this, looking with this, okay, what can I do with that?

16:51.980 --> 16:55.440
I found that you could target the sign-in buttons, for example.

16:55.540 --> 16:56.940
So what did we do?

16:56.940 --> 17:00.780
I first hide the sign-in buttons, and they are gone right now.

17:00.780 --> 17:02.680
So you're thinking, okay, what can we do with that?

17:02.680 --> 17:12.660
Well, if we look at some of the other options in the custom company branding, we are basically also allowed to customize the self-service password reset, right?

17:12.660 --> 17:24.580
And what this would allow us to do is we can basically show a custom link that would be redirecting to whatever domain that we want with any value that we want.

17:24.580 --> 17:26.360
So we can do something like this.

17:26.360 --> 17:30.960
The next button that we previously just hit, we can replace that with something like that.

17:30.960 --> 17:33.460
Obviously, right now, no one would click on that.

17:33.460 --> 17:35.940
No one would be too stupid to click on that.

17:35.940 --> 17:43.500
However, if we customize that a little bit more with a little bit CSS, we can make that link look something like that.

17:43.860 --> 17:47.460
So now it looks quite a little like this next button, right?

17:47.460 --> 17:55.980
And even if you hover over it, it has some animation that it changes the background a little bit, but you say, okay, now it looks great, but it's at the wrong location, right?

17:55.980 --> 18:06.340
And you're correct, but we can move that a little bit with some relative positioning, and now it's exactly to the pixel correct where the real next button would be, right?

18:06.340 --> 18:13.120
So we can do this for the next button on the account fill-in page or on the next page to collect the password as well.

18:13.120 --> 18:16.560
We can basically hijack these buttons, right?

18:16.700 --> 18:21.340
So how would we abuse this, or what URL would we be using for that?

18:21.340 --> 18:30.920
Once again, login.max.online.com, and we will just add our tenant ID in there, and that is basically enough to load our custom CSS from our tenant, right?

18:30.920 --> 18:41.720
And these tenant IDs, these are GUIDs, so users would never actually know whether that's someone else's tenant, maybe if you're really tech-savvy, but no one is going to be looking at that, right?

18:41.900 --> 18:43.540
And then what else do we have?

18:43.540 --> 18:44.280
Prompt login.

18:44.280 --> 18:52.100
This is basically to force Microsoft to show the sign-on page, even if you're already signed in with some cookies in your browser, right?

18:52.100 --> 18:54.960
So prompt login forces to show the sign-on page.

18:55.320 --> 19:05.080
User enters their email address on the domain, clicks on the next button, and then they are redirected to our malicious domain where we can capture their credentials, for example, with others in the middle, right?

19:06.560 --> 19:10.100
All right, so what does this look like for the user?

19:10.100 --> 19:12.680
So they are on login.microsoftonline.com.

19:12.680 --> 19:15.000
For example, we are phishing the CEO of Microsoft.

19:15.000 --> 19:16.300
They provide their email address.

19:16.300 --> 19:20.080
They click on the next button, and they see the password fill-in page, right?

19:20.080 --> 19:22.640
But this is on a different domain, but it's so seamless.

19:22.640 --> 19:23.540
The user doesn't see it.

19:23.540 --> 19:29.700
They click on the button, and they see the next page that they are expecting, but on a different domain, right?

19:29.700 --> 19:31.400
So it's very, very powerful.

19:31.400 --> 19:33.520
So let's look at an example of that.

19:34.040 --> 19:36.580
So we go to that domain.

19:39.080 --> 19:42.300
User fills in their email address, clicks.

19:42.300 --> 19:46.000
You can see, if you hover over the button, there is this nice animation.

19:46.000 --> 19:46.920
We click on that.

19:46.920 --> 19:50.860
At the left, you can see EvilGNX loading already, loading the login page.

19:50.860 --> 19:52.840
We will pre-fill the email address of the user.

19:52.840 --> 19:56.440
We can load custom tenant branding of the user, whatever we want.

19:56.440 --> 20:02.340
User enters their password, and if they sign in, they would get an MFA prompt or whatever.

20:02.340 --> 20:08.400
Obviously, we don't know the password of the CEO of Microsoft, of course, but you can see where this is going, right?

20:08.400 --> 20:10.020
This is just for a demonstration.

20:11.940 --> 20:12.900
All right.

20:13.800 --> 20:18.360
Let's look at something else we can do with password authentication.

20:18.980 --> 20:30.640
So password authentication is one of the methods that you can use to allow your users to sign in with their on-premise credentials to any Entra.ID integrated application, right?

20:30.640 --> 20:48.300
So the way that this works in the background is Entra.ID will literally forward the password in clear text to your on-prem PTA agents, which will decrypt the credentials and validate them against a domain controller, right?

20:48.300 --> 20:52.540
So this is fairly abused quite a lot already.

20:52.540 --> 21:02.960
It's a well-known post-compromise persistence attack technique where you backdoor the PTA agents and you basically wait for authentication attempts and you extract clear text credentials from that, right?

21:02.960 --> 21:05.560
So this is usually done after full domain compromise.

21:05.560 --> 21:10.740
You compromise someone's on-prem environment and then you install this backdoor, right?

21:10.740 --> 21:13.360
Which requires quite a lot of high privileges.

21:13.660 --> 21:16.040
So how does the authentication flow work?

21:16.040 --> 21:18.660
So user goes through any application.

21:18.660 --> 21:21.160
It will be redirected to Entra.ID, right?

21:21.160 --> 21:23.500
Entra.ID will ask for the credentials.

21:23.500 --> 21:32.100
So the credentials are added on Entra.ID's login page, which will then be forwarded to your on-prem PTA agent for validation.

21:32.120 --> 21:39.140
At this point in time, your passwords are in clear text on this agent and they will validate that against the on-premise domain controller.

21:39.300 --> 21:47.100
And what is also important to know, the PTA agent here is in charge of whether they want to accept or decline the authentication or not, right?

21:47.380 --> 21:49.720
So that is how it works.

21:49.720 --> 21:54.660
So as I said, it's a known technique to use this for persistent purposes.

21:54.660 --> 21:57.920
However, what my idea was, can we use that for initial access?

21:57.920 --> 22:03.080
Can we use password authentication set up in our attacker tenant, right?

22:04.000 --> 22:07.560
And still clear text credentials of users and other tenants, right?

22:07.560 --> 22:09.180
So this was my plan.

22:09.180 --> 22:12.000
I set up password authentication in our tenant that I control.

22:12.000 --> 22:13.140
So I can do that.

22:13.140 --> 22:17.340
I backed over the PTA agents on-premise, which is running on a server that I control.

22:17.340 --> 22:18.320
So I can do that as well.

22:18.320 --> 22:20.280
So this is all fairly straightforward.

22:20.280 --> 22:30.460
But then the tricky part becomes, we need to trick users from other tenants to sign into our domain, to our Entra ID tenant, right?

22:30.460 --> 22:33.340
Otherwise, we wouldn't be able to get their credentials.

22:33.460 --> 22:37.340
So this is one is easier said than done, but let's look at that in a little bit.

22:37.680 --> 22:39.260
So let's first look at the first step.

22:39.260 --> 22:40.700
I will go over this briefly.

22:40.700 --> 22:44.200
It's very boring, but it's all documents from Microsoft, how we can set that up.

22:44.200 --> 22:46.660
So we set up an Entra ID domain.

22:46.660 --> 22:49.500
We set up Entra Connect Sync.

22:49.500 --> 22:53.400
We set up password authentication over there, go through all the steps that are needed.

22:53.400 --> 22:57.200
And eventually we see password authentication is enabled for our tenants, right?

22:57.200 --> 23:01.080
Then second thing we need to do is we need to backdoor that password authentication agent.

23:01.080 --> 23:05.580
Right here, we will be using PTA spy from AAD internals by Dr.

23:05.580 --> 23:06.080
Azure AD.

23:06.080 --> 23:09.280
But there are a lot of tools that do the same thing, basically.

23:10.460 --> 23:12.540
But PTA spy is very easy to install.

23:12.540 --> 23:17.300
We just use install AAD int PTA spy on our PTA agents.

23:17.300 --> 23:25.760
And then after that, when we test that by signing into some accounts from our tenants, we will be able to see the clear text credentials, right?

23:26.100 --> 23:29.200
So now let's look at the other part.

23:29.200 --> 23:33.140
How can we force users from other tenants to sign into our tenants?

23:33.140 --> 23:42.000
There are a couple of constraints to that of whether we are restricted to make it still collect the credentials with PTA, right?

23:42.000 --> 23:45.120
So we can only target users in our own tenants.

23:45.120 --> 23:52.860
Otherwise they wouldn't be able to sign into our tenant and then definitely it would not be able to use PTA from our tenant, right?

23:53.160 --> 23:56.820
Password authentication also only works with hybrid users.

23:56.820 --> 23:58.600
So cloud-only users will not work.

23:58.600 --> 24:01.480
For example, guest accounts are cloud-only users.

24:01.480 --> 24:04.000
So these can't be synced to on-prem.

24:04.000 --> 24:07.000
So something like that would not be possible, right?

24:07.000 --> 24:08.740
So what other options do we have?

24:09.880 --> 24:19.740
I was looking into this setting, email as alternate login ID, because it is a very underestimated feature that can be fairly useful in some cases.

24:19.740 --> 24:31.880
Basically what this allows you to do, if you enable that in your tenant, you can basically allow users in your tenant to sign in with any email address that is defined in their proxy address attributes.

24:32.000 --> 24:40.340
And this proxy address attributes can, in certain cases, have email addresses from unverified domains that you do not own.

24:40.340 --> 24:44.420
So I was looking into that for a cloud-only user just to test this really quickly.

24:44.500 --> 24:50.440
If you set, you cannot control the proxy address directly, but you can, for example, update the email attributes.

24:50.440 --> 24:54.840
And for cloud-only users, this gets propagated automatically to the proxy address fields.

24:54.840 --> 24:57.920
So you can see over here, we set that to non-synced at microsoft.com.

24:57.920 --> 25:01.060
We don't own the microsoft.com domain, but you can still do that.

25:01.060 --> 25:09.760
And after that, with your previous setting, we can actually sign in with that account into our tenant and it will be linked to that specific user, right?

25:09.760 --> 25:19.540
So this, you could think, that probably is something you can actually trick a user of a different tenant into signing in with our tenant, right?

25:19.540 --> 25:23.680
Because their email address could be displayed on our login page, right?

25:23.820 --> 25:32.440
When I looked into that for synced users, then we saw that this email property is not propagated.

25:32.440 --> 25:43.440
I tried a lot of things to try to influence that, but even setting the proxy address fields on-prem, for example, it does not automatically propagate to the proxy address field in Enter ID.

25:43.440 --> 25:50.140
So there was no way for synced users to influence that, to get unverified domain names in there.

25:50.140 --> 25:52.560
This is documented by Microsoft as well, right?

25:52.560 --> 25:54.520
So I needed to find something else.

25:54.520 --> 26:00.760
And that's why, when I started looking into the custom CSS that I showed previously, right?

26:00.760 --> 26:08.320
So I was thinking, okay, can we maybe modify how the email property is shown on the login page with custom CSS?

26:08.320 --> 26:20.340
And I was looking at all the attributes that we can customize or the custom selectors that we have in CSS, but none of them allowed us to directly select the email address that is shown on the page.

26:20.340 --> 26:26.680
However, the closest one that we do have is something like the sign-in box, or we can set CSS to the complete body.

26:26.680 --> 26:36.280
That is still possible, but things like Ent child or anything similar that would allow us to only select that email address are all disallowed, so we can't do that.

26:36.280 --> 26:47.400
What we would need to find is some way to set something on a parent element on the page that would only affect the email address property without modifying the rest of the page.

26:47.460 --> 26:50.600
So I was looking in the other things that are allowed, and then I saw font-face.

26:50.600 --> 26:56.900
And font-face allows you to basically select or define a custom font that would be used for your page.

26:57.500 --> 27:02.720
And we can apply that to the complete body or to the sign-in container, doesn't really matter.

27:02.720 --> 27:10.600
And then I was actually looking into, okay, how can I create a custom font?

27:10.760 --> 27:14.340
So I found this neat application that would allow me to do that.

27:14.340 --> 27:17.560
And as you can see over here, this looks quite a lot like an S.

27:17.560 --> 27:23.180
However, if you look a little bit closer, this is actually a hyphen, right?

27:23.180 --> 27:27.320
As a human, you would think that this is an S, but the computer will think that this is a hyphen.

27:27.320 --> 27:29.720
This is a dash character, basically, right?

27:29.720 --> 27:33.160
A really swirly dash character, but it's a dash character.

27:33.160 --> 27:46.100
So what we can do is now purchase a domain, micro-auth.com, and the computer, your browser, will think that micro-auth.com will be there, but it will render it as microsoft.com, right?

27:46.100 --> 27:57.860
So now we can, since we've verified that domain, we own that domain, we can create any users with that email address, like admin at micro-auth.com, for example.

27:57.860 --> 28:05.580
We can set up some conditional access policies if we don't want the user to gain access to our tenants after we phish them, for example.

28:06.040 --> 28:10.880
And then we set up this custom CSS to implement our custom font, right?

28:10.880 --> 28:15.440
We load our custom font from a specific location, doesn't really matter.

28:16.280 --> 28:22.460
And we set that font to only take place on when the hyphen character is loaded, right?

28:22.460 --> 28:28.500
So only use that font for the hyphen character, which is 2D in hexadecimal, right?

28:28.500 --> 28:34.480
And then all the other fonts are basically the normal fonts that Microsoft would otherwise use, right?

28:34.480 --> 28:36.940
And this is what it would look like for the user.

28:36.940 --> 28:44.380
So the user sees admin at microsoft.com, but if you look at the source code, it is admin at micro-auth.com, right?

28:44.380 --> 28:46.420
So very convenient.

28:46.420 --> 28:58.480
And our phishing URL can be as short as this, login.microsoft.online.com, and then a login hint with our email address we want of the user we want to phish with a slight modification at that.

28:58.480 --> 29:03.020
Obviously, the user might see that, so you can use a little bit of obfuscation or encoding of that.

29:03.020 --> 29:05.380
You can use some URL encoding over there.

29:05.380 --> 29:07.900
You can encode whatever you want, a small part.

29:08.080 --> 29:15.580
The complete email address, you can add any parameters in there to make the URL look more legitimate, right?

29:15.580 --> 29:21.260
At the end, it will be very hard for the user to see that this small modification is in there, right?

29:21.260 --> 29:23.400
So let's look at a demonstration of that.

29:23.400 --> 29:28.740
So this is our attacker server where our PTA agent is running and PTA spy is running.

29:28.740 --> 29:32.940
So right now you can see it is installed, but there are no credentials just yet.

29:33.400 --> 29:35.700
So this is the victim point of view.

29:35.700 --> 29:38.300
They go to our phishing domain.

29:39.160 --> 29:41.600
Okay, they go to login.microsoft.online.com.

29:41.640 --> 29:52.500
You will see it looks like admin.microsoft.com, and you can also see it will show up the credentials from their password manager as well, because they are on the legitimate Microsoft domain.

29:52.500 --> 29:56.340
After they sign in, we get their credentials in clear text, basically.

29:57.420 --> 29:58.080
Yes.

29:59.180 --> 30:00.440
All right.

30:03.960 --> 30:05.180
Thank you.

30:05.240 --> 30:08.620
But there are still a little bit of limitations to that, right?

30:08.620 --> 30:12.960
If you look at the previous demo, you might have seen that.

30:12.960 --> 30:21.760
Obviously, a wrong password can be provided by the user because PTA spy will always return a successful authentication without validating the password, right?

30:21.760 --> 30:23.920
So we need to take care of that.

30:23.920 --> 30:29.660
And the second thing is clear text passwords are nice, but they are useless if multi-factor authentication is enforced, right?

30:29.660 --> 30:33.540
So let's see what we can do to work with that, right?

30:33.540 --> 30:44.940
So we will use the same CSS as previously, but we will add a little bit of extra CSS to that, basically to modify the title that will be shown on the sign-in page.

30:44.940 --> 30:45.740
And what is the title?

30:45.740 --> 30:51.260
This is basically the area between the email address and the password field, right?

30:51.260 --> 31:00.460
So we will hide that title and we will actually load a custom image from a location that we control from our attacker web server, right?

31:00.660 --> 31:02.600
So what will we be doing with that?

31:02.600 --> 31:07.580
The first time that it loads, we will, and it will request that image, we will return this image.

31:07.580 --> 31:14.040
Enter password, so just regularly as usual, this would be what would be shown the first time.

31:14.060 --> 31:21.600
After we validate the password of the user, we will redirect them to the login page a second time, and then we will load this image.

31:21.700 --> 31:22.800
Enter code.

31:22.800 --> 31:25.900
And now the login page would look like this, right?

31:26.040 --> 31:38.360
And yeah, since we are using password authentication, we will be actually capturing that OTP code once again with our vector over password authentication agent, right?

31:38.560 --> 31:51.680
Then we also need to modify how the PTA spy works a little bit, because as we said, it will always return a valid authentication attempt that will not validate the credentials of the user.

31:51.680 --> 32:01.680
So how PTA spy works is basically on the PTA agent, it will hook the login user API call from the Microsoft API, the Windows API, right?

32:01.680 --> 32:08.460
What we will do is we will modify that hook a little bit, and we will actually implement a new function that will validate the credentials.

32:08.460 --> 32:10.120
It's too big to actually show here.

32:10.120 --> 32:17.600
I might share that on GitHub in a while, but for now, I will just show you a little bit of snippets from this.

32:17.760 --> 32:21.800
And if the authentication is successful, we will return successful authentication.

32:21.800 --> 32:27.300
Otherwise, we'll return an error, and Microsoft will show that error, and the user will enter a new password, right?

32:27.300 --> 32:31.100
So how will this go in the background?

32:31.460 --> 32:36.940
We send a link to the user, to our sign-in page of Android ID, right?

32:36.940 --> 32:41.340
They will click on that, and obviously when the sign-in page loads, it will request that image.

32:41.340 --> 32:45.180
So the first time it loads that image from our web server, we return this image.

32:45.180 --> 32:54.660
The user will enter their password, because it is instructed to do that, which will be forwarded to Android ID, and Android ID will forward that to our password authentication agent, right?

32:54.660 --> 32:58.620
At this point, we validate that password against Android ID, right?

32:58.620 --> 33:02.320
And if the authentication is successful, we return that.

33:02.320 --> 33:05.900
If it's unsuccessful, we return an error message, and they can try again, right?

33:05.900 --> 33:07.240
Let's assume it is successful.

33:07.240 --> 33:18.940
What we will do is we'll let our web server that's hosting our image know that the authentication was successful, so it knows next time if we need to load an image in the next couple of minutes, we know that it needs to return the other image, right?

33:18.940 --> 33:30.000
At this point in time, we also redirect the user to the login page once again, and they will receive the image once again to be requesting their OTP code, right?

33:30.000 --> 33:35.900
They will provide the OTP code in the password field, right, which will be forwarded to our PTA agent.

33:35.900 --> 33:38.240
We can validate that once again to Android ID.

33:38.240 --> 33:40.980
If it's unsuccessful, we can return an error once again.

33:40.980 --> 33:43.140
If it's successful, we compromise the user account.

33:43.140 --> 33:44.860
So this is the ID behind it.

33:44.860 --> 33:47.040
What would our sign-in URL look like?

33:47.040 --> 33:49.740
It's a little bit bigger, as you can see over here.

33:49.740 --> 34:06.920
So once again, login.mysoftonline.com, and the client ID of our application that we have set up with the custom redirect URL, the prompt login to force the login page to be shown, even if the user has already signed in, which is required because we will need to sign in the user two times,

34:06.920 --> 34:07.140
right?

34:07.140 --> 34:09.660
And then the e-mail address of the user we want to target.

34:09.660 --> 34:14.560
And then the redirect URL will redirect the user after successful authentication once again to the login page.

34:14.560 --> 34:16.800
And you can see it's a little bit nested over there.

34:16.820 --> 34:24.300
But then the third time, or the second time they successfully sign in, they will be redirected to wherever you want to go, Google, in this specific case.

34:24.880 --> 34:32.180
One small note for the demo is that usually we would rewrite something like micro-auth.com authentication attempts.

34:32.180 --> 34:36.540
For that, we would rewrite that to Microsoft.com and validate if the credentials are valid.

34:36.540 --> 34:37.840
For that, I can't, right?

34:37.840 --> 34:45.100
Obviously, since I don't have access to a Microsoft.com domain, and I asked them, but they said no.

34:45.160 --> 34:49.800
I even told them, you can see my slides if you give me the account for the demo, and they said no.

34:50.120 --> 35:01.120
So , because we do not have access to that Microsoft.com domain, what I will be doing is I will show you the demo where we capture the credentials for the user at Microsoft.com.

35:01.120 --> 35:10.580
But instead of validating the credentials against a Microsoft account, you will validate them against an account that I have control over, that I know the password of, so I can fish myself, basically.

35:10.640 --> 35:14.140
So, let's look into that.

35:15.460 --> 35:20.440
So, over here, we have the victim point of view in the bottom left corner.

35:20.640 --> 35:25.580
Everything will happen on the legitimate Microsoft login page so they will be asked to enter their password.

35:25.580 --> 35:31.200
If they enter an invalid password, they will receive an error message, just to show that we are actually checking for that.

35:31.200 --> 35:34.300
We still have the password, of course, but we know that it's invalid.

35:34.820 --> 35:44.820
If the user provides the correct password, for example, the one that's saved in their password manager, then it will seamlessly load the enter code image.

35:46.080 --> 35:54.580
And if they provide the correct MFA code over there, we can redirect them wherever we want, and we basically compromise the user.

35:54.580 --> 35:58.140
Once again, we have their access token, session cookies, anything we need.

36:03.180 --> 36:04.400
All right.

36:05.740 --> 36:11.260
So, this is nice, once again, but there's still a couple of limitations to that.

36:11.680 --> 36:21.280
First, we are capturing a MFA code in a password field, which is a little bit suspicious because usually the OTP code is in clear text, right?

36:21.520 --> 36:28.660
Additionally, authenticator app notifications are a little bit more convenient in company environments, right?

36:28.660 --> 36:31.680
They are used quite a lot more, and they are more convenient for the user.

36:31.680 --> 36:35.960
So, I was looking at, okay, can we actually do something with that instead, right?

36:35.960 --> 36:38.740
And for that, we will actually need two Enter ID tenants.

36:38.740 --> 36:41.540
The first one will have the same CSS as we saw previously.

36:41.540 --> 36:45.120
It will only replace the hyphen with an S character, right?

36:45.120 --> 36:48.020
The other CSS that you saw previously, we don't use that.

36:48.200 --> 36:52.440
And, yeah, it's basically the main sign-in page that you saw previously, right?

36:52.480 --> 36:58.840
Then the second tenant, which we will redirect the user to after authentication, will have this CSS.

36:58.900 --> 37:04.420
And basically, what this will be doing is it will replace the complete sign-in box with an image.

37:04.420 --> 37:05.980
And you're thinking, okay, what image?

37:05.980 --> 37:08.120
An image looking something like this, right?

37:08.260 --> 37:14.400
Showing the two-digit code that they would need to sign in on their authenticator app, right?

37:14.400 --> 37:19.720
And you're thinking, okay, but how do we know in advance which specific two-digit code that the user needs to enter?

37:19.720 --> 37:20.740
Well, we don't know.

37:20.740 --> 37:25.100
So, we just generate an image for all of them, right?

37:25.100 --> 37:26.980
So, this took quite a while.

37:26.980 --> 37:30.780
So, I have 100 images ready over here.

37:30.780 --> 37:35.880
And basically, it doesn't matter what image or which code that Microsoft provides us.

37:35.880 --> 37:36.960
We can return that.

37:37.280 --> 37:38.820
And this is how the attack flow would go.

37:38.820 --> 37:47.620
So, we send a link to the user to sign into the first tenant, right, which will...

37:47.620 --> 37:54.520
There's not much modifications on that one, just replacing the hyphen with an S character in this specific case.

37:54.520 --> 37:59.400
So, you would provide their credentials, which we will capture on our PTA server.

37:59.400 --> 38:00.840
We can validate them.

38:00.840 --> 38:02.680
If there is an error, we can return that.

38:02.680 --> 38:05.040
If not, we return a successful authentication.

38:05.140 --> 38:11.240
At this point in time, we will also receive a two-digit MFA code from EnterID if MFA is set up.

38:11.240 --> 38:14.300
And we forward that to our web server, right?

38:14.300 --> 38:16.140
So, for example, 42.

38:16.140 --> 38:21.120
We redirect the user to now tenant two, where our different CSS is loaded.

38:21.120 --> 38:29.720
And there, it will actually load the image, right, because we're replacing the complete sign-in prompt with an image and whatever code that is needed, right?

38:29.720 --> 38:36.420
In the meantime, our attacker server is constantly polling, checking if the authentication already succeeded with MFA.

38:36.480 --> 38:38.700
The user will see the two-digit code.

38:38.700 --> 38:44.860
They will also look down, because they just received a notification on their phone to ask for the two-digit code.

38:44.860 --> 38:47.720
So, they provide that, which will be forwarded to EnterID.

38:47.720 --> 38:50.860
And at that point in time, we compromise the user's account.

38:50.920 --> 38:54.880
So, let's look at our final demo over here.

38:55.680 --> 39:01.960
Once again, login.microsoftonline.com with some custom properties, which you can see over there.

39:02.680 --> 39:07.180
And the redirect URL will just redirect them once again to the login page of the second tenant.

39:07.180 --> 39:09.420
So, you can see that in action over here.

39:09.420 --> 39:11.640
First time we enter the password.

39:13.940 --> 39:16.940
So, it's going to be an invalid password first time.

39:16.940 --> 39:20.200
So, you can see no redirection if the user enters an invalid password.

39:20.200 --> 39:23.140
If we take the correct password from our

39:28.180 --> 39:35.520
Authenticator extension or whatever, the user will be redirected to the second tenant, where this image would be shown.

39:35.520 --> 39:41.120
And as you can see over here, the user has entered their multi-factor authentication on their app.

39:41.120 --> 39:44.300
We get their access token, refresh token, and their session cookies.

39:44.300 --> 39:46.640
You will see they will not be redirected over here.

39:46.640 --> 39:49.860
So, this could be something that they will note.

39:49.860 --> 39:54.440
However, they are still on a legitimate Microsoft login page.

39:54.440 --> 39:57.040
So, it is not that suspicious, right?

39:57.820 --> 39:58.840
All right.

39:59.540 --> 40:02.260
So, for that, we would actually need two tenants.

40:02.260 --> 40:10.460
You can actually do something where you only use one tenant if you really want that, but then you would need to use this.

40:10.460 --> 40:12.400
Browser language customization.

40:12.400 --> 40:19.460
And what this allows you to do is specify custom tenant branding for a specific language, right?

40:19.460 --> 40:25.760
So, for each language, you could load a custom CSS file, which would allow us to, for example, do something like this.

40:26.120 --> 40:29.640
By default, in any language, it would return the normal login page.

40:29.640 --> 40:33.880
If the language is set to French, for example, we return the MFA prompt.

40:33.880 --> 40:40.260
And we can actually modify which language is used with this parameter, this LC parameter.

40:40.260 --> 40:44.880
We provide an ID over there for French, for example, and then it would load the login page, right?

40:44.880 --> 40:48.600
So, this would allow you to do this exact same attack with only one EnterID tenant.

40:48.600 --> 40:51.620
However, you will note one slight difference.

40:51.680 --> 40:55.840
If you change the language, it would also change the language and the page title.

40:56.300 --> 41:06.420
So, this could be something that could be seen, but probably not too suspicious for the user, and they will probably not notice it because they just received a notification in their Authenticator app, right?

41:07.000 --> 41:10.560
So, to summarize, I showed about eight techniques.

41:10.560 --> 41:13.620
The OpenRedirect ones, I went over them fairly quickly.

41:13.620 --> 41:21.420
If you are interested in that, the slides for that are at the back of my presentation as well because I first created some slides for that.

41:21.980 --> 41:23.900
So, you will be able to see that still.

41:23.900 --> 41:33.420
Four of these techniques, we can actually be using or staying completely within the legitimate login.microsoftonline.com domain, right?

41:33.420 --> 41:38.820
Without going anywhere else, and a couple of them will also bypass multi-factor authentication, right?

41:38.820 --> 41:45.340
So, to summarize, login.microsoftonline.com is a free redirector for phishing pages.

41:45.340 --> 41:48.620
It can serve any image as it is imaged, right?

41:48.620 --> 41:53.900
So, if you want to host cat memes on Microsoft's login page, you can do that if you want, right?

41:53.900 --> 42:01.760
It is the most trusted credential harvester by far and is basically the perfect all-in-one phishing platform, phishing as a service platform, right?

42:02.100 --> 42:06.240
Some references over here from, obviously, Dr.

42:06.240 --> 42:17.880
Azure AD for his awesome work with AD internals and PTA Spy, which we use quite a lot over here, which is based on the research of Adam Chester, actually.

42:18.220 --> 42:26.920
And also, a quick shout-out to Kuba, the creator of EvilGeneX, which allowed me to use the EvilGeneX Pro version for some of these demos over here.

42:27.280 --> 42:30.800
If you have any questions, feel free to come ask me after the session.

42:30.800 --> 42:32.660
I will reach out to me on my socials.

42:32.660 --> 42:33.980
You can see that over here.

42:33.980 --> 42:43.040
I just want to end over here with a picture that I took at the Microsoft party two days ago, which basically summarizes this entire talk.

42:43.040 --> 42:50.140
I'm not sure if you can see it, but they had this small sign over there saying game over, and they allowed me to take some pictures over there.

42:50.200 --> 42:52.280
So, yeah, thank you so much.

