WEBVTT

00:00.000 --> 00:01.580
All right, welcome.

00:02.200 --> 00:05.060
I hope you're going to have to readjust this.

00:05.060 --> 00:06.540
You're a little taller than me.

00:06.840 --> 00:13.220
But we're welcoming up, I can't pronounce his name, but he assures me that that's common.

00:13.220 --> 00:16.180
So you can call him Scooby.

00:16.300 --> 00:18.720
That's what he goes by.

00:18.720 --> 00:31.340
And Scooby is a senior security architect, adversary detection team lead, and threat hunting team lead for Belk Canada, one of Canada's largest carriers.

00:31.540 --> 00:39.180
The talk that he's going to give is really cool because Bloodhound started out as a red teaming tool, right?

00:39.180 --> 00:50.660
But we've learned through using the tool that it's really, really useful for blue teamers to discover the attack paths in your active directory.

00:50.660 --> 01:00.060
So Scooby's going to give us some information on that and how you can use this tool on the blue side to understand your active directory and, and the attack paths better.

01:08.820 --> 01:10.100
Hello everybody.

01:10.100 --> 01:12.680
Welcome to this talk called Bloodhound from Red to Blue.

01:12.680 --> 01:15.920
I'm Scooby, you can find me on Twitter at ScoobyMTL.

01:16.340 --> 01:20.060
Um, I was mentioned I'm a senior security architect at Belk Canada.

01:20.680 --> 01:25.660
Adversary team lead detection and uh, threat hunting team lead as well.

01:25.660 --> 01:30.280
Um, this talk was first presented at B-Side Charm a few months ago.

01:30.280 --> 01:34.300
Uh, so if there's some parts that I need to skip, I will refer you to that talk.

01:34.300 --> 01:37.600
Uh, I might have to go a bit faster because I've added a few things.

01:38.040 --> 01:43.680
Um, at this point of the con- the talk, you might wonder is this guy mentally challenged or does he have an accent?

01:43.960 --> 01:47.720
Well, according to my doctors, because I'm French Canadian, that I speak like this.

01:47.720 --> 01:51.000
Uh, Canadian, we're usually nice people until Aki comes along.

01:51.000 --> 01:53.900
Then if you're not on our team, well, you best STFU.

01:54.020 --> 02:04.760
Um, because I'm French Canadian, you will probably notice I won't pronounce S's at the end of words, uh, or H's, or I might have them where they don't belong, but, uh, don't worry, just bear with me.

02:05.220 --> 02:08.260
With this talk, I have a few, uh, unlock achievements.

02:08.260 --> 02:10.820
First of all, uh, I'm giving a talk at DEF CON.

02:10.940 --> 02:13.140
Secondly, I'm giving a talk with a Mohawk.

02:13.260 --> 02:20.120
Um, as I mentioned, this is my second talk here at Hacker Summer Camp, so that makes me, uh, equal with, uh, Pyrotech.

02:20.120 --> 02:21.720
He gave also two talks.

02:21.720 --> 02:25.840
That's one more talk than Sub-T and that's two more talk than Matt Graber.

02:25.840 --> 02:29.620
Uh, Matt mentioned that I had to talk about quality over quantity.

02:29.620 --> 02:31.000
I don't know what he meant.

02:31.440 --> 02:37.300
Um, no security researcher, uh, ego was harmed in the making of this slide, so rest assured.

02:37.940 --> 02:39.880
So here's the agenda for today.

02:39.880 --> 02:49.680
We're going to talk about what Blowdown is, the basic usage of Blowdown, we're going to do an introduction to the Cypher language, and then we're going to set and des- to destroy PATS.

02:49.680 --> 02:52.460
And then I'm going to talk about report and automation.

02:52.980 --> 02:56.520
Uh, by show of hands, who here have used Blowdown before?

02:57.740 --> 03:01.280
Okay, and who have built their own Cypher queries?

03:02.640 --> 03:04.720
Uh, okay, awesome.

03:05.580 --> 03:11.280
Defenders thinking list, attackers thinking graphs, as long as this is true, attacker wins.

03:11.280 --> 03:18.380
You probably all heard this before, it's a very, uh, common saying from John Lambert and it comes with a whole blog.

03:18.760 --> 03:31.160
Um, what, what it really means is when an adversary, uh, land in your networks, it doesn't land in a list that you have, it lands in a graph which is a complex set of relationship between objects.

03:31.380 --> 03:38.860
Blowdown is one of the tools that will actually show you the relationship between those objects, um, and are they are actually linked together.

03:39.060 --> 03:48.620
So when we talk about a list, this is what we think, talk about, we think about a list of assets, a list of server names, a list of group, uh, a list of serial numbers.

03:49.180 --> 04:02.720
Then we go deeper and we have even more lists, a list of open port, a list of uninstalled software, compliancy box, but what all those lists won't tell you that a graph will is how are those things actually connected together.

04:03.240 --> 04:11.080
What is the relationship that exists that you know of and especially that you do not know of between all of those objects and all of your assets.

04:11.540 --> 04:19.820
So for those who are not familiar with graph, uh, it's not a security concept per se, um, so here's an example in real life.

04:20.020 --> 04:27.560
So you and Alexis are going to a restaurant, comes along Taylor and Jordan and you become infatuated with Jordan.

04:27.660 --> 04:30.740
So you're gonna leverage relationship in order to get what you want.

04:30.740 --> 04:42.180
So first of all, you're gonna leverage your family relation, relationship with Alexis, who is a co-worker of Taylor, who is a friend of Jordan and then you'll get Jordan's phone number.

04:42.180 --> 04:46.000
By the icon I choose for the phone, you might guess roughly how old I am.

04:46.240 --> 04:53.280
Um, so you can see here, uh, I've made a big effort to stay, uh, gender neutral in my names and my relation, I'm really proud of that.

04:53.320 --> 04:57.220
Um, in active directory it will look a little bit more like this.

04:57.220 --> 05:08.260
So an attacker will land somewhere in the network by compromising an account via phishing or password spraying because my password is always summer 2019 and there he is.

05:08.260 --> 05:15.280
And then he's gonna leverage, um, uh, the fact that this, uh, user is admin to his workstation.

05:15.280 --> 05:19.100
A bad InfoSec practice, but it does happen way more than we want.

05:19.300 --> 05:31.980
And then that machine can RDP to a terminal server, for example, in your environment and depending how much, uh, employee you have, this might be between 1,000 or 100 to 1,000 people.

05:32.080 --> 05:39.540
Then on that machine, there's a user who has a session and he has a little crown because he's a member of a high value group.

05:39.540 --> 05:47.920
I see people with phones, um, last slide of the deck will contain the link where you can download the whole slide so you don't need to take pictures of every slides.

05:49.220 --> 05:51.380
Now let's go over an overview of Bloodhound.

05:51.380 --> 05:56.840
I'll try to go quickly as more than half of the people, uh, seems to have used the tool before.

05:56.840 --> 05:58.720
But first of all, what is Bloodhound?

05:59.100 --> 06:02.460
Rest assured there's lots of word, but it's the only slide with so many words.

06:02.460 --> 06:09.420
So Bloodhound uses graph theory to reveal the hidden and often unintended relationship within an active directory environment.

06:09.420 --> 06:12.940
Both attackers and defenders can use those paths.

06:12.940 --> 06:19.380
Uh, red teamer to exploit them and of course, blue teamer to destroy them before they are being exploited.

06:19.440 --> 06:21.760
Here's a very quick history of Bloodhound.

06:21.760 --> 06:27.800
It was, it was released at Bloodhound 24 in a talk called Six Degrees of, uh, Domain Admin.

06:27.800 --> 06:33.840
If you go to that link, you'll see Rowan actually unlocking his password manager and making the repo live.

06:33.980 --> 06:44.460
I was personally, um, introduced to Bloodhound a year after that at Black Hat 2007 in a talk called Industrial Revolution of Lateral Movement from Tal Mahar and Tal Barry.

06:44.460 --> 06:55.260
And it's an excellent talk where they explain how they can use a path generated by Bloodhound and, um, uh, through PowerShell, they just exploit and get the credential automatically.

06:55.520 --> 07:07.180
And then last year at Bloodhound, uh, at Black Hat, sorry, 2018, the team released Bloodhound 2.0 and Bloodhound is developed by Waldo, Captain Jesus, and Armjoy, three people I'm sure you're familiar with.

07:07.580 --> 07:09.740
So what does Bloodhound do exactly?

07:09.900 --> 07:11.580
Well, there's three simple things.

07:11.580 --> 07:19.080
It queries Active Directory, it imports the data in the Neo4j database, and then it shows the relationship between the objects.

07:20.080 --> 07:22.020
So why should you use Bloodhound?

07:22.020 --> 07:29.880
Well, for red teamers, you can use the UI to bu- to build complex attack path offline and this reduce the noise on the network a lot.

07:29.880 --> 07:41.380
So every time you jump on a machine, you already know which credentials you need to steal and which attack path you need to follow to get to the next, you don't need to re-scan the network every time you land in a new machine.

07:41.500 --> 07:45.540
For blue teamer, we can use query to find the busiest attack path.

07:45.840 --> 07:53.600
Um, we can test the relationship of deleting or removing, uh, relationship or remediating would be the right term, um, on your graph.

07:53.840 --> 07:57.080
And then you can destroy the path before they are being exploited.

07:59.300 --> 08:03.600
So it's now time to talk about the basic, or what I like to call the first steps.

08:04.440 --> 08:06.680
So first of all, you need an ingester.

08:06.960 --> 08:20.320
There's three ingesters, there's SharpHound, which is a C-sharp tool, there's InvokeBloodhound, which is a PowerShell that loads, uh, SharpHound reflectively, and then there's BloodhoundPython that was built by, uh, Dirkjen from Foxit.

08:20.320 --> 08:24.760
So if you land in a Linux machine, you can still leverage the goodness of Bloodhound.

08:25.380 --> 08:27.280
Uh, on the right, I've put some comment.

08:27.280 --> 08:28.960
I'm gonna go very quickly through them.

08:28.960 --> 08:43.320
Uh, just want to mention that, uh, collection method all does not include logged on anymore, because starting in Windows 10, 10th anniversary, uh, and, um, Windows Server 2016, you need to be local admin in order to list the session.

08:43.320 --> 08:46.480
So now you need to add that if you want to have everything.

08:46.480 --> 08:55.600
DC only is something that is, um, less quiet, makes a lot less noise on the network, but you, as a defender, you should still run that in order to make sure that you can detect it.

08:56.060 --> 08:58.460
Uh, max loop time goes with session loop.

08:58.460 --> 09:02.900
By default, uh, Bloodhound will loop for session for 2 hours.

09:03.140 --> 09:08.620
Um, as we're defender, we don't really care about being detected, so we should run that as long as possible.

09:08.660 --> 09:18.040
Uh, the reason being that if you run it during the day, you'll get all your user session, whereas if you run it at night, you might get some administrative tasks that are happening only at night.

09:18.120 --> 09:23.480
Um, and you should also shift the days that you're running it because some activities might happen only a day a week.

09:24.720 --> 09:31.160
Um, search forest, uh, yeah, whatever, if you have more than one forest, sharpound-h for help, uh, could be useful.

09:32.340 --> 09:37.920
Uh, this is a screenshot of the GUI, but there's nothing like a live demo, so let's jump into the UI.

09:37.920 --> 09:40.160
This is the screen that you're gonna see when you get here.

09:40.360 --> 09:46.160
Um, because I'm a bit short on time, I'm gonna make it, okay, as quick as possible.

09:46.160 --> 09:48.700
I'm just gonna turn like this.

09:49.680 --> 10:07.060
Um, so the thing I wanted to show you guys is, um, gonna skip a few things, but query, most people when they land here, they will use the, uh, fine administrative, fine shortest path to domain admin, um, and the domain, so I'm gonna let the little doggy do,

10:07.060 --> 10:11.340
the doggy do his thing while I just show you here the filtering option.

10:11.340 --> 10:14.220
So these are all the edges that you have available for you.

10:14.680 --> 10:21.580
Um, this is not the latest version, they're quite, there's a few more now, but it was working for the presentation and I didn't dare to try the new version.

10:21.900 --> 10:26.620
Um, so you can remove any of those edge and re, recreate the graph and it's just gonna be gone.

10:27.240 --> 10:47.780
Um, so from here, what I wanted to show, but now I, I can't really not read, but if you don't know how to, um, yeah, anyway, I cannot see the, the thing, but you can right click on any edge and get help, um, and information about how you can abuse that type of relationship.

10:47.780 --> 10:50.480
So this is really useful and it's not really well documented.

10:50.480 --> 10:57.360
Uh, you have some, uh, OPSEC, uh, consideration and of course, uh, lots of reference as well for any type of link.

10:57.680 --> 11:08.340
Um, another interesting thing is that if you right click on any of the nodes, you have a few little menu here and you have edit nodes.

11:08.340 --> 11:15.340
So if you go there, you can see all the property of that node and you can also add properties using the little add button right here.

11:16.140 --> 11:21.360
Um, there's a few undocumented shortcut as well that I want to, um, point out today.

11:21.440 --> 11:25.460
So first of all, there's the space bar that will bring you spotlight.

11:25.460 --> 11:28.500
Here you'll have all the elements of your, uh, graph.

11:28.500 --> 11:35.500
So you can click on anything and it's gonna, uh, zoom in on your element and put it in the, um, directory here.

11:35.760 --> 11:48.240
So here you have, uh, if you, if you wanna, if you have a, a user that is called Matt, you can click on him and if you wanna know if he has a path to domain admin, you just use a little road here and you type domain admin.

11:49.880 --> 11:54.120
And just like Google Map, it will show you if the user has a path to domain admin.

11:54.260 --> 11:55.960
So here's the path for that user.

11:56.840 --> 12:04.840
Um, beside that, a few other maybe keywords, uh, you can use shift command and I to bring a console.

12:04.840 --> 12:09.180
So if there's any error message, uh, that you want to read, they will be here.

12:09.960 --> 12:16.300
Um, lastly here in the settings, there's two, uh, uh, yeah, two interesting thing.

12:16.300 --> 12:20.140
First of all, the debug query mode that goes with the raw query here.

12:20.280 --> 12:27.440
So when you activate that, every time you click somewhere, you will actually have, um , the query in Cypher at the bottom in the raw query bar.

12:27.440 --> 12:29.960
And this is really helpful if you wanna learn Cypher.

12:31.580 --> 12:37.400
And, uh, last but not least, there is the dark mode, which is probably the most important part of Bloodhound.

12:38.540 --> 12:40.700
So let's get back to the presentation.

12:40.860 --> 12:46.800
And by the way, every time I say, uh, dark team in this presentation, there's a fairy that is born.

12:46.800 --> 12:47.840
So here it is.

12:47.840 --> 12:48.960
Uh, why fairies?

12:48.960 --> 12:51.080
Because I have two daughters and they love fairies.

12:51.280 --> 12:54.580
Um, here are the undocumented feature that I talked about.

12:54.580 --> 12:58.940
So using, uh, the right click on an edge to show contextual help.

12:58.940 --> 13:01.880
Using control to toggle on or off the labels.

13:01.920 --> 13:04.160
Control shift I for the console space bar.

13:04.160 --> 13:09.320
And you can also search for GPO or OU, uh, right in the bar and also domain.

13:09.320 --> 13:12.960
So if you wanna know what's, have been enumerated, you can use those keywords.

13:14.120 --> 13:19.520
So graph database, as I mentioned, you, you load, uh, the data in Neo4j.

13:19.520 --> 13:23.140
Uh, this is where you can download the community edition, which is free.

13:23.140 --> 13:27.680
And then you start it like you would start any other Linux services just by using the start.

13:28.140 --> 13:35.220
Um, once it's installed, you can go to a, uh, web console on port 7474.

13:35.300 --> 13:39.640
So some people might ask why use the web console when Bloodhound comes with a UI.

13:39.760 --> 13:44.320
Well, there's a few reason for that, uh, especially when you start writing your own query.

13:44.320 --> 13:53.600
If you make a mistake in your query in the console, um, you'll quickly know that your query is wrong and it will point you what is wrong in your query.

13:53.800 --> 13:57.440
So right here you'll see that equal is not the right, uh, symbol.

13:57.440 --> 13:59.200
You need to put a semi-colon.

13:59.200 --> 14:04.200
So when you fix that, you get the result of your, um, of your query.

14:04.220 --> 14:14.560
Also, you can see that if you're not returning a path but you're returning a property, it will actually list, uh, in a table, which doesn't happen in the GUI, but we're gonna come back to that.

14:14.560 --> 14:20.560
A last reason to use, uh, the web GUI, the web console, sorry, it's because it also has a dark theme.

14:20.560 --> 14:21.780
Hey, another fairy.

14:22.820 --> 14:28.080
Uh, let's go through an introduction of Cypher or what I like, I like to call learning to run.

14:29.240 --> 14:35.380
So a basic Cypher query will have a few objects, a few, a few elements with a, a match statement.

14:35.600 --> 14:38.560
Then you have to declare some objects or variables.

14:38.640 --> 14:43.040
So here you can see that we are declaring a variable U of the type user.

14:43.040 --> 14:48.720
And if you want to, uh, access the attributes, you need to put a dot with the attributes name.

14:49.000 --> 14:58.200
Then you'll likely want to find some relation, so that says two dash and an arrow pointing in the direction that you want, and in brackets, you can put the relation type.

14:58.780 --> 15:07.400
After that, you'll probably want to find paths, so you have shortest path or all shortest paths from one variable towards another one.

15:07.400 --> 15:10.160
And then you have where if you want to make some filtering.

15:10.360 --> 15:13.700
And then you need to, a return function to say exactly what you want to return.

15:16.640 --> 15:18.840
So there's two methods for doing the filtering.

15:18.840 --> 15:21.580
There's the explicit methods and there's the where clause.

15:21.580 --> 15:23.720
So I'll show you the difference between the two.

15:23.740 --> 15:25.640
Here is with an explicit function.

15:25.640 --> 15:29.500
So you can see that I'm declaring a variable called N and it's type of a group .

15:29.500 --> 15:34.200
And the name must be equal to, uh, domain user at test lab dot local.

15:34.200 --> 15:40.660
Then I'm defining another variable M, which is a group, uh, and this one is domain admin at test lab dot local .

15:40.660 --> 15:47.540
And then I'm looking for a shortest path between those two groups and I don't care how many ops there is and I want to return the path.

15:48.680 --> 15:51.440
With the where clause it will look a little bit more like this.

15:51.440 --> 15:58.380
So we have the match shortest path N towards M group and then we say what we want for those domain, uh, those variable.

15:58.440 --> 16:04.400
So the first one is we want it to start with domain user, whereas the other one we want it to contain something.

16:04.480 --> 16:06.720
There's also end widths that exist.

16:06.720 --> 16:08.300
And then we return the path.

16:08.460 --> 16:10.380
Here are the two queries side by side.

16:10.380 --> 16:13.940
When you run them, not surprisingly, you get the exact same result.

16:13.980 --> 16:16.140
So why use one instead of the other?

16:16.460 --> 16:17.680
First of all, the time.

16:17.680 --> 16:21.780
It is way faster to use explicit when you can versus a where clause.

16:21.900 --> 16:32.720
On the other end, if you're, um, a consultant or if you have multiple domains and you, you use specific, you'll have to make your query for all the domains that you go to, you'll have to change your, your query all the time.

16:32.720 --> 16:36.420
So depending on the situation, one might be more suited than the other.

16:36.920 --> 16:40.420
Also when you're using the web UI, it will help you improve your query.

16:40.420 --> 16:50.740
So when your query works but is not optimal, you'll get those little, um, exclamation mark and when you click on them, uh, the UI will tell you how you can actually improve them.

16:51.600 --> 16:54.660
So here's the query that we have improved.

16:54.660 --> 17:09.320
So if we put them side by side, you can see that in the first one, we declared a variable and then we do the shortest path, whereas in the second one, we do the shortest path and we declare our variable right inside the function, which is now the preferred way to do it in Cypher.

17:13.650 --> 17:16.010
This is pro tip number one of the talk.

17:16.010 --> 17:23.050
So using appending explain or profile in front of your query will help you understand what's actually happening under the hood.

17:23.050 --> 17:34.690
So explain will, will do the execution plan but will not run the statement, whereas the run, uh, the profile will run the statement and you'll see exactly which operator is taking more, uh, doing most of the work.

17:34.910 --> 17:36.290
So here is how it works.

17:36.290 --> 17:41.910
So here's a complex query that returns pretty much all the object in the graph, um, and you do match.

17:41.910 --> 17:46.190
So when you do explain match, just put explain and, and before, you'll get this.

17:46.190 --> 17:47.890
So you know, this is explain.

17:47.890 --> 17:52.510
So you can see here we have, uh, since, uh, 1600 hits estimated.

17:52.690 --> 17:56.450
When we run it with profile, we see that it's actually 16,000.

17:56.450 --> 18:00.770
So you can see that, uh, profile is way more precise than the other one.

18:01.590 --> 18:06.010
Here are some, uh, useful query and I'll just put also my GitHub link here.

18:06.010 --> 18:10.890
So if you want to download it, all the custom queries that I did not show you in the UI, they are there.

18:11.590 --> 18:16.390
Um , so domain user, those are the first thing that I like to do when I start an engagement or go on a new domain.

18:16.630 --> 18:26.470
Uh, looking where domain user, our local admins, if they have a shortest path to high value target, if there are any places that they can RDP to, and then all the other bad rights that they might have.

18:26.770 --> 18:28.850
Then I like to look into Kerberos thing.

18:28.850 --> 18:39.290
If you have no idea what Kerberos thing is, in a nutshell, it's, um, it's an attack where you request a weak password, a weak cipher of a password in RC4 and then you crack it offline.

18:39.290 --> 18:45.050
If you want more information, ADSecurity.org, the site by Sean McAlf.

18:45.050 --> 18:53.810
And then I also brought back the, back the top 10, uh, that were removed from version 1 to 10 because I believe as a blue teamer, it's a good place to start exploring your graph.

18:53.810 --> 18:55.350
So I just put them back.

18:56.570 --> 19:02.470
Here's, uh, an example of some advanced query that were shared in the Blowdown Cipher Query Slack channel.

19:02.550 --> 19:06.350
Uh, I believe those, the both of them were built by Waldo.

19:06.510 --> 19:14.550
Um, just to show you that, uh, you can start doing optional match, you can start collecting variables, you can add them together, you can unwind, uh, you can count stuff.

19:14.550 --> 19:26.390
And if you look at the second one, you can extract, uh, labels, you can extract variable, you can filter things, um, you can do, um, average length and lots of mathematical things also, uh, in there.

19:27.110 --> 19:31.930
If you want to learn more about cipher, there's a good cheat sheet from Neo4j and this is the link.

19:32.110 --> 19:36.670
Now that we know a little bit how to build cipher queries, it's time to destroy paths.

19:41.440 --> 19:43.760
So what are we trying to do when we're destroying paths?

19:43.760 --> 19:51.340
Well, we're trying to find the busiest path and then we're trying to find, to test the effect of the proposed remediation.

19:51.540 --> 20:04.000
So when you have the old path, sometimes you, it might seem obvious that if you remove a link, you'll destroy the path and domain user won't have access, uh, won't have a path anymore to domain admin, but we'll see that this is not always the case.

20:04.780 --> 20:11.760
Um, and then when we know exactly which path should be removed, then we can inform our domain admins and have them make the change.

20:11.900 --> 20:14.100
Let's try this in a control environment.

20:14.300 --> 20:16.300
First of all, we're gonna create a problem.

20:16.320 --> 20:23.000
So I'm gonna merge the domain user and I'm gonna give them admin rights to the computer 673.

20:23.160 --> 20:27.420
When I run that in a console, I get that one relation was created and I'm very happy.

20:28.280 --> 20:36.040
After that, we're gonna test our relationship, so we're gonna ask for a path between domain user and the computer 673 and we're gonna ask to return the path.

20:36.480 --> 20:38.860
Not surprisingly, our path is there.

20:39.740 --> 20:41.900
Now we have two options that we can use.

20:41.900 --> 20:43.820
We can filter out the relationship.

20:44.200 --> 20:49.320
This is, this is to be used when there's only one relationship type, uh, in that path.

20:49.640 --> 20:53.320
Or you can delete the relationship if there's more than one relation.

20:53.700 --> 20:55.260
I'll show you how to do both.

20:55.260 --> 20:57.660
So first of all, filtering out the relationship.

20:57.760 --> 20:59.420
So here's the same beginning of the query.

20:59.420 --> 21:10.140
We're looking for a path between domain user and computer 673 and we want to filter a relationship where the type of relationship is not admin 2 and we want to return the path.

21:10.800 --> 21:13.360
If we do it with a delete, it will look like this.

21:13.360 --> 21:17.340
So pretty much the same query again, but then we just delete the relation.

21:18.960 --> 21:22.420
And then you need to print it, so same thing, but you return the path.

21:22.860 --> 21:25.100
And those are the three queries side by side.

21:25.100 --> 21:29.060
When you run them, again, not surprisingly, you have no data.

21:30.400 --> 21:33.460
The thing is, everything I just said was wrong.

21:35.180 --> 21:37.940
So you're like, okay, everything was wrong, so why are we here?

21:37.940 --> 21:39.780
Is, are we losing our time?

21:40.200 --> 21:48.840
Um, I'll take you to what happened in my head in the last 36 hours and remember that I've presented this at B-Side Charm and, uh, this part was not in B-Side Charm.

21:49.200 --> 21:51.780
So let's do it against real data.

21:51.960 --> 22:01.000
So we're going to do the same thing, we're going to find, uh, our target, so we're going to do the shortest path between domain user and domain admin and we're going to get a path that looks like this.

22:01.320 --> 22:09.740
Uh, the top here is execute decom and it's the only execute decom in the path, so this should be a prime target for a filter out.

22:10.960 --> 22:21.080
So here how you would do that, you would say shortest path between domain admin to domain, uh, between domain user to domain admin, where the path is not execute decom.

22:21.080 --> 22:29.260
And if the fix is right, and if this is the fix that we want to send to our, uh, sysadmin, we should not have a path to domain admin anymore.

22:29.760 --> 22:31.340
Now we have a problem.

22:31.340 --> 22:34.180
We still have a path, but it's much longer.

22:34.680 --> 22:39.620
So this is, the execute decom is not the right thing that we want to execute, we want to exclude.

22:40.820 --> 22:42.880
But why filtering is wrong?

22:42.980 --> 22:44.540
I'll show you right here.

22:44.640 --> 22:50.760
So this is instead of shortest path to domain admin, this is all shortest paths to domain admin.

22:50.760 --> 22:55.120
So as you can see there's two paths with the same length that lends to domain admin.

22:55.200 --> 23:04.760
This is the first one that we excluded with the execute decom, but right here there's another execute decom and that link was also removed from our view.

23:04.800 --> 23:15.700
So not only did we still have, um, a path to domain admin when we excluded execute decom, but we removed every, uh, execute decom everywhere in every path of the graph.

23:15.700 --> 23:18.680
So that's why filtering out is actually a bad idea.

23:19.380 --> 23:24.480
Now it's like, okay, but at least I can delete relationship, right?

23:24.680 --> 23:38.220
So here's the same shortest path, but then I print the label and you can see that in between, uh, computer, uh, sorry, group 4574 and computer 65, uh, 652, there's our execute decom.

23:38.260 --> 23:49.460
So we're going to target that link and we're going to say, we're going to take the path, uh, I want a path between, sorry, the, and then, yeah, assign it a variable R and then we're going to delete the relationship.

23:49.460 --> 23:52.040
And then this happened.

23:52.420 --> 24:00.320
And then I was like, well, shit, now I've deleted two relationship when I wanted to only delete execute decom.

24:00.320 --> 24:02.640
And I was like, okay, now what do I do?

24:02.640 --> 24:10.080
My talk is in 36 hours and none of my techniques actually work and I'm going to look like, uh, anyway.

24:10.560 --> 24:13.620
But, uh, the solution was quite easy.

24:13.620 --> 24:19.680
I googled how to target a single link and the first, uh, result was actually there.

24:19.680 --> 24:21.160
So it's very easy.

24:21.160 --> 24:31.380
The same query, but you can see that here I have actually tell it exactly which relation I wanted to target and I, oops, and, uh, delete only one relationship.

24:31.380 --> 24:34.260
And then I was partying like Dave Vader was not there.

24:34.260 --> 24:37.120
Uh, that's pretty much what I looked like in my room, uh, yesterday.

24:38.400 --> 24:47.040
So now we get something that looks like this when you're using the filter out to this path, which is actually the path that we saw on the top in our execute decom is right there.

24:48.480 --> 24:50.340
So that brings me to this part.

24:50.340 --> 24:59.220
So when you do the same query in the web UI, you get the picture on the left, which has all, you can see all the, um, all the links.

24:59.260 --> 25:02.240
When you do it in Bloodown, you only have one link.

25:02.360 --> 25:14.740
So I looked a little bit, I asked, uh, the guys from Bloodown and the reason is when you do a query to Neo4j, it returns only one, uh, link, but then the GUI somehow add them back when the query is done.

25:14.740 --> 25:19.280
So that's why, uh, on the Bloodown GUI, they only get the one link that is returned by the query.

25:19.340 --> 25:22.320
And it's by alphabetical order.

25:24.440 --> 25:27.860
So let's, let's talk about what, what exactly happened here.

25:28.020 --> 25:29.940
So a graph is like a map.

25:29.940 --> 25:35.000
So imagine that you want to find all the routes between Chicago and New York City, for example.

25:35.120 --> 25:43.380
You'll, maybe you'll be shown one or two routes on the map, but that's by, by not, it's not all the paths that exist by any stretch of the imagination.

25:43.380 --> 25:45.600
You can turn left on the street, right, whatever.

25:45.620 --> 25:47.920
So that's exactly what's happening here.

25:48.660 --> 25:53.780
Bloodown, well, Bloodown will only show you one relationship, so you might think that there's only one when there's many.

25:53.860 --> 26:00.920
And it is possible to delete a very specific relationship using this command, so assigning the name of the relationship that you want to delete before.

26:02.200 --> 26:05.540
Now, let's get back to our regular scheduled programming.

26:06.160 --> 26:08.800
This is the pro tip number two of the talk.

26:09.380 --> 26:14.780
Um, by default, there's five groups that are high value in Bloodown.

26:15.200 --> 26:17.580
But in your environment, it's probably not the case.

26:17.580 --> 26:20.460
You probably have way more groups that are very important.

26:20.460 --> 26:29.040
So this is a query that will help you find all the group that contains admin and that their high value, uh, attributes is not set to true.

26:29.040 --> 26:35.220
You're going to return those name and your environment, we have Asia admins, Europe admin, and North America admins.

26:35.740 --> 26:42.320
Now, what we're going to do is that we're going to run the same query, but we're going to set those group high value property to true.

26:42.640 --> 26:46.920
So we go from the five original ones to eight groups that are high value.

26:47.460 --> 26:51.220
Pro tip number three, what about the user inside of those groups?

26:51.340 --> 27:01.480
So here's a query that's going to help you find all the high value groups that you have and all the user that belongs to those group and then you're going to set the high value property of those user to true.

27:01.480 --> 27:10.140
If you have a good eye, you might have noticed that this relationship is in the other direction and just is, this is just to show you how flexible Cypher can be.

27:10.320 --> 27:20.520
So what it's going to do, it's going to change something like this where you have domain admins with a diamond meaning that it's a high value, a group, and, uh, user are not high value to this.

27:21.700 --> 27:28.400
Now, it will also change your shortest, all shortest path to this, from this to this.

27:28.400 --> 27:33.460
So you see that in reality, you have a lot more path than you actually thought at the beginning.

27:35.020 --> 27:39.740
Pro tip number four, I know, I know, it's not Christmas and I keep on giving.

27:40.460 --> 27:48.120
So here is, uh, in the, uh, in the shell, uh, CLI where you can, uh, you can use Cypher shell and I'm going to talk about that a little bit later.

27:48.700 --> 27:55.440
Um, but basically here, we see that the first one is longer to execute than the second one and the reason is very simple.

27:55.440 --> 28:02.260
In the first one, we are returning a path, where on the second one, we are returning a, uh, attribute.

28:02.260 --> 28:06.400
So it's a lot faster to return attributes if you don't have to, uh, send a path.

28:07.860 --> 28:16.180
Uh, pro tip number five, another way to accelerate your query or make them faster is to remove the relationship variable if you don't need them.

28:16.180 --> 28:21.040
Here the difference seems very small, but bear in mind that my database is very short.

28:21.540 --> 28:29.360
If you want to learn more things about how you can use Bloodown as a defender, you can watch operationalizing Bloodown attack graph for defenders.

28:29.400 --> 28:32.880
There's also SAT processor who did quite, uh, a lot of research.

28:32.880 --> 28:39.900
Uh, you also present another methodology where you actually whitelist or whi- blacklist the nodes themselves by adding a properties.

28:39.900 --> 28:48.980
And then of course, there's a Bloodown Slack, the Cypher query channel where there's lots of people there, including myself, that will try to help you with your Cypher query if you have any problems.

28:49.740 --> 28:57.460
Now we're gonna talk about reporting because attackers thinks in graph, management thinks in metrics, and as long as this is true, ops will suffer.

29:03.100 --> 29:07.700
So here's an example of very, very simple, uh, report that we can have.

29:07.700 --> 29:13.320
At the top you can put, uh, say, in January 100 percent of our user had a path to domain admin.

29:13.320 --> 29:19.680
Now in February 7, it's 57, and then in March 12, and we're trying to get to as low as possible, of course.

29:19.680 --> 29:24.380
If this is not visual enough for your management, you can always use gauges.

29:24.380 --> 29:32.580
Those one were built in, uh, Google Doc, for example, very easily, and if they don't understand this, well, honestly, at this point, I cannot help you anymore.

29:34.760 --> 29:41.500
Here's a query about how, uh, you can find a percentage of user with a dom- uh, path to domain admin.

29:41.640 --> 29:49.980
So what you're doing here is you're looking for a shortest path between domain user and, um, sorry, shortest path to DA.

29:49.980 --> 30:01.800
So here you're looking, yeah, you're looking for a path from user to domain admin, and then you're going to count the number of user you have in your path, and then how many user have a path, uh, and then you're going to do some maths writing the return function.

30:01.800 --> 30:09.740
So user that has a path divided by the total of user multiplied by 100 , this will give you your percent, and when you run this, you get 100 percent in this case.

30:10.280 --> 30:22.040
Now when you're done with the low-hanging fruit, you can start looking at things that are a bit mo- more, a bit more funky, like, do I have any domain admins that have session to non-DC machines?

30:22.040 --> 30:23.700
This is a bad practice.

30:23.700 --> 30:27.820
Your domain admin should only log in into the domain controller.

30:27.820 --> 30:39.760
So what we're doing here is that we're looking for, uh, comp- computers that are not part of the domain controller group, and we assign them a variable called non-DC.

30:39.760 --> 30:47.980
Then we're looking for non-DC that has a session to a user, and the user must be, uh, a member of domain admin.

30:48.460 --> 30:52.920
And then we return the name, the username, and we count the connection.

30:53.540 --> 30:56.600
Again, here, there's something special about this query.

30:56.620 --> 30:58.740
We have a double relationship.

30:58.740 --> 31:03.760
It's also to show you how powerful, uh, Cypher can be, and I'm very proud of this.

31:03.760 --> 31:05.840
Uh, I, I worked, uh, really hard on this one.

31:05.840 --> 31:13.860
I got another version from Waldo, uh, on the Slack channel, but he was using SID, and it was not working with SID in the test database.

31:14.460 --> 31:20.580
So this will give you something like this, so you see all of your admins and how many connection they have to non-DC machine.

31:21.280 --> 31:32.700
If these names are too cryptic in your environment, you can do a little modification right here, and in brackets, you can put all the fields that you actually want to display, and it's gonna look like this.

31:32.700 --> 31:39.460
So here you have the username and also the display name, so it might be easier for you to find who this account belongs to.

31:40.200 --> 31:44.460
So here's another way of representing the same graph, uh, the same Excel fight.

31:44.460 --> 31:49.600
Here's log- log- logarithmic, and you're aiming for your data to go down, down, down, down, down.

31:49.800 --> 31:57.260
Um, it's probably not the best way to show it, but, uh, at least there's a dark team, and that gives me my third fairy for the talk.

31:58.840 --> 32:01.320
So now let's talk about automation.

32:02.860 --> 32:11.940
So as I mentioned earlier, there's a CLI, um, command, sorry, uh, in the bin directory of Neo4j.

32:11.940 --> 32:19.400
So you can go there, you export your username, you export your password, and then using Cypher shell, you can paste your query directly there.

32:19.400 --> 32:22.440
You just need to, uh, enclose them with single quotes.

32:22.560 --> 32:29.040
Um, so another pro tip would be every time you build a custom query in, um, Cypher, always use double quotes.

32:29.080 --> 32:32.200
And when you go in your, uh, shell, you can use a single quote.

32:32.420 --> 32:36.560
Uh, if you do mix and match, it's gonna be very difficult to automate things.

32:36.660 --> 32:49.600
So this query, um, is, we're looking for the Kerberos table, high value accounts that are Kerberos table, so that's why we have as SPN attributes to true, and high value group set to true.

32:49.600 --> 32:56.680
When you run that, you'll get this in the shell, but you can also pipe it in a CSV file, and it's gonna look like this.

32:56.680 --> 33:00.200
Uh, Q8 is only because that was my eighth query in the graph.

33:01.140 --> 33:09.640
CSV is very easy to open, I mean you can send that to your manager or your sysadmins, they will be able to open it in their favorite spreadsheet.

33:10.620 --> 33:12.120
Now, alerting.

33:13.120 --> 33:23.540
So you, when you have your query, you can start comparing, uh, the current munch result with the last munch result, and you just send an alert if the number increase.

33:23.760 --> 33:26.740
And I went very fast cause we're already at the conclusion.

33:28.380 --> 33:31.060
Here are the key takeaways for today.

33:31.180 --> 33:35.780
Defender can think in graph too, using tool like Bloodown.

33:36.040 --> 33:41.780
Cypher is a very flexible language, and you can do a lot of thing if you put the effort in it.

33:41.780 --> 33:53.520
It's also important to test the real impact of a remediation before you send it to your sysadmin, otherwise they'll lose faith in Bloodown, they'll lose faith in your process, and they'll probably lose faith in you.

33:53.880 --> 33:56.580
Um, but it's easy to do as I demonstrated.

33:56.880 --> 33:59.540
Not all query are worth automating.

34:00.480 --> 34:11.480
What I mean by that is that, yes you can see all the domain, all the user that are in domain admin, for example, and you probably want to be alerted if there's new user in that group.

34:11.480 --> 34:16.220
But you'll run Bloodown maybe once a quarter, once a month, if you're lucky maybe once a week.

34:16.220 --> 34:19.680
Uh, that's not fast enough to be alerted if there's a new domain admin.

34:19.680 --> 34:26.600
So you're way better off looking for event ID 4728 in your logs to be alerted in near real time.

34:28.020 --> 34:31.900
Finally, I want to give a big thank you to the Blue Team Village for having me today.

34:31.900 --> 34:35.160
I want to thank Pyrotek, Talberry, and Grifter.

34:35.400 --> 34:48.200
Um, I'm, I'm here because of these people and especially Grifter last year, uh, in Toronto said that, uh, if you have something that you want to share with the community, don't be shy, do it, do CFPs, and, uh, you might get accepted.

34:48.200 --> 34:50.440
And that's what happened to me, so I'm very happy.

34:50.600 --> 35:01.920
Um, and you learn a lot more about what you want to talk about or what you, about your subject when you make a talk because it's the second talk and as you saw, uh, lots of things have changed since the first version.

35:02.060 --> 35:09.680
Finally, I want to thank Waldo and Captain Jesus, uh, who created the tool and who are helping everybody in the Slack channel when they have questions.

35:10.100 --> 35:13.580
So as promised, here's the link to the, the, the whole deck.

35:13.600 --> 35:26.280
And, uh, the second link is the talk for, uh, the same talk, but, uh, that I gave at B-Side Charm where I gave a more in-depth tour of, uh, the GUI and, uh, I go a little bit, well, less fast, let's say, slower.

35:26.280 --> 35:28.840
So if you have any questions, I have a few minutes.

35:40.150 --> 35:44.370
So the question is, is there a training or environment you can practice on?

35:44.470 --> 35:47.110
Yes, there is, um, an open database.

35:47.110 --> 35:55.430
I don't have the link with me, but if you go to the Bloodhound Slack, um, or if you, if you send me, uh, a text or something, I will give it to you.

35:55.430 --> 35:56.390
It exists.

35:56.790 --> 36:01.270
Uh, the Specter Ops team has built, uh, and put online a database.

36:01.310 --> 36:02.790
And you can also generate your own.

36:02.790 --> 36:11.810
There's a DB generator that comes with Bloodhound that you can run and you just specify how many, uh, you com- user and computer you want and it's going to build everything.

36:11.810 --> 36:13.610
That's what I use for this presentation.

36:13.610 --> 36:15.150
So this is all fake data.

36:16.350 --> 36:17.030
Yes.

36:22.100 --> 36:24.060
So is iValue a Bloodhound term?

36:24.060 --> 36:24.980
Yes, it is.

36:24.980 --> 36:33.200
It's an attribute that, uh, that it, uh, that is collected and that is, uh, you can activate it in the GUI or manually using Cypher.

36:33.300 --> 36:34.780
So it's one of the properties.

36:41.690 --> 36:47.990
Well, everything is open source, so you can probably change, uh, the default iValue group in the code if you want.

36:48.190 --> 36:51.170
Uh, but I don't know how to do that, but I'm pretty sure you can.

36:52.190 --> 36:53.170
Any other questions?

36:53.170 --> 36:53.850
Yes?

37:06.580 --> 37:14.160
So the question was if you run Bloodhound a multiple time, uh, can you just import data over it or should you kind of clean your database?

37:14.400 --> 37:21.120
Uh, the best way usually is you save your old database and you create, then you, you save it, then you clear it and you re-import.

37:21.780 --> 37:23.920
So you can see, yeah, it's better.

37:23.920 --> 37:37.180
Because otherwise if, if your admins have made changes, they will still be there in your environment and they will still, when you do your query, it's not going to be a, uh, a real representation of your environment if you don't clean it.

37:37.260 --> 37:38.140
Yes, sir?

37:51.020 --> 38:01.040
Is there, uh, the, the question was is there a reason why I did the deleting the relationship between looking for, for, for the percentage?

38:01.040 --> 38:09.560
Uh, because I believe it's, it's easier to find, to, to break the, the most path at the beginning, um, but you can do it the other way around also.

38:09.560 --> 38:20.140
But if you have something from domain user that goes to domain admin, that's probably the first thing you want to remove and that will give you, um, a high win rate or a, a big drop in your percentage.

38:20.140 --> 38:29.880
If you have a path from, from domain user to DA, that means 100 percent of your user have a path and it's going to be hard to find which one to, if you're not doing the query.

38:31.640 --> 38:32.720
Yes, sir?

38:43.160 --> 38:46.000
Okay , uh, is there a difference between the 3 and Jester?

38:46.000 --> 38:53.080
The sharp, the sharp, um, uh, the PowerShell one and then the, uh, Python.

38:53.080 --> 38:59.580
So Python should be mostly used if you land in a Linux environment or if you don't have any credentials.

39:00.060 --> 39:04.060
And then you go to the first machine and you rerun SharPound from there.

39:04.060 --> 39:08.060
So SharPound is really the preferred methods to run it.

39:08.160 --> 39:17.860
Uh, you'll see that now since a few months, a lot of antivirus has started categorizing it as a virus, which is a bit sad, but you can kind of understand maybe why.

39:18.500 --> 39:25.420
Um, so PowerShell is a way to actually load, uh, uh, SharPound reflectively.

39:25.700 --> 39:30.980
So if you have application whitelisting, for example, you might be able to run a script or, yeah.

39:31.320 --> 39:41.640
But the preferred methods, especially for a blue teamer, would be to allow SharPound to be executed in one machine, in one directory, and then you, you do it this way.

39:42.000 --> 39:48.900
As a, as a red teamer, I'll let other people answer, but as a blue teamer, you should just whitelist in for a very specific place.

39:49.340 --> 39:50.760
Any other questions?

39:54.170 --> 39:54.950
Yes?

40:04.190 --> 40:10.190
Okay, so the question was, is there any tools in Neo4j to, uh, see the difference between different graph?

40:10.190 --> 40:13.590
I don't know of any, but, uh, my friend is sitting right there.

40:13.590 --> 40:16.930
Give me a good idea and I'm gonna work on that, uh, for next year.

40:24.080 --> 40:28.100
The question was, did I test it in any Azure environment or any other cloud?

40:28.100 --> 40:29.520
No, I did not.

40:32.720 --> 40:34.460
Any other questions?

40:36.160 --> 40:37.940
Thank you very much, everybody.

