start	end	text
0	6540	All right, welcome. I hope you're going to have to readjust this. You're a little taller than me.
6840	13400	But we're welcoming up, I can't pronounce his name, but he assures me that that's common. So
14120	22660	you can call him Scooby. That's what he goes by. And Scooby is a senior security architect,
22660	29760	adversary detection team lead, and threat hunting team lead for Belk Canada, one of Canada's
29760	36400	largest carriers. The talk that he's going to give is really cool because Bloodhound started
36400	43400	out as a red teaming tool, right? But we've learned through using the tool that it's really,
43400	50880	really useful for blue teamers to discover the attack paths in your active directory. So
50880	55760	Scooby's going to give us some information on that and how you can use this tool on the blue
55760	70100	side to understand your active directory and, and the attack paths better. Hello everybody.
70100	74340	Welcome to this talk called Bloodhound from Red to Blue. I'm Scooby, you can find me on Twitter
74340	81440	at ScoobyMTL. Um, I was mentioned I'm a senior security architect at Belk Canada. Adversary team
81440	88140	lead detection and uh, threat hunting team lead as well. Um, this talk was first presented at
88140	93400	B-Side Charm a few months ago. Uh, so if there's some parts that I need to skip, I will refer you
93400	98840	to that talk. Uh, I might have to go a bit faster because I've added a few things. Um, at this
98840	103020	point of the con- the talk, you might wonder is this guy mentally challenged or does he have an
103020	107720	accent? Well, according to my doctors, because I'm French Canadian, that I speak like this.
107720	112220	Uh, Canadian, we're usually nice people until Aki comes along. Then if you're not on our team,
112220	116780	well, you best STFU. Um, because I'm French Canadian, you will probably notice I won't
116780	122620	pronounce S's at the end of words, uh, or H's, or I might have them where they don't belong,
122620	127580	but, uh, don't worry, just bear with me. With this talk, I have a few, uh, unlock
127580	132140	achievements. First of all, uh, I'm giving a talk at DEF CON. Secondly, I'm giving a talk with
132260	138020	a Mohawk. Um, as I mentioned, this is my second talk here at Hacker Summer Camp, so that makes
138020	143840	me, uh, equal with, uh, Pyrotech. He gave also two talks. That's one more talk than Sub-T and
143840	148380	that's two more talk than Matt Graber. Uh, Matt mentioned that I had to talk about quality
148380	154940	over quantity. I don't know what he meant. Um, no security researcher, uh, ego was harmed in
154940	160440	the making of this slide, so rest assured. So here's the agenda for today. We're going to talk
160440	165400	about what Blowdown is, the basic usage of Blowdown, we're going to do an introduction to
165400	170280	the Cypher language, and then we're going to set and des- to destroy PATS. And then I'm going
170280	175680	to talk about report and automation. Uh, by show of hands, who here have used Blowdown
175680	186140	before? Okay, and who have built their own Cypher queries? Uh, okay, awesome. Defenders
186140	191440	thinking list, attackers thinking graphs, as long as this is true, attacker wins. You
191440	197240	probably all heard this before, it's a very, uh, common saying from John Lambert and it comes
197240	203600	with a whole blog. Um, what, what it really means is when an adversary, uh, land in your
203600	208500	networks, it doesn't land in a list that you have, it lands in a graph which is a complex
208500	213500	set of relationship between objects. Blowdown is one of the tools that will actually show you
213500	219380	the relationship between those objects, um, and are they are actually linked together. So
219380	223340	when we talk about a list, this is what we think, talk about, we think about a list of
223340	229880	assets, a list of server names, a list of group, uh, a list of serial numbers. Then we go
229880	234460	deeper and we have even more lists, a list of open port, a list of uninstalled software,
234460	240100	compliancy box, but what all those lists won't tell you that a graph will is how are those
240100	246000	things actually connected together. What is the relationship that exists that you know of
246000	251660	and especially that you do not know of between all of those objects and all of your assets. So
251660	257860	for those who are not familiar with graph, uh, it's not a security concept per se, um, so
257860	264000	here's an example in real life. So you and Alexis are going to a restaurant, comes along
264000	268760	Taylor and Jordan and you become infatuated with Jordan. So you're gonna leverage
268760	272120	relationship in order to get what you want. So first of all, you're gonna leverage your
272120	278780	family relation, relationship with Alexis, who is a co-worker of Taylor, who is a friend of
278780	284020	Jordan and then you'll get Jordan's phone number. By the icon I choose for the phone, you
284020	289140	might guess roughly how old I am. Um, so you can see here, uh, I've made a big effort to
289140	294100	stay, uh, gender neutral in my names and my relation, I'm really proud of that. Um, in
294100	298880	active directory it will look a little bit more like this. So an attacker will land somewhere
298880	304340	in the network by compromising an account via phishing or password spraying because my
304340	311340	password is always summer 2019 and there he is. And then he's gonna leverage, um, uh, the
311340	317180	fact that this, uh, user is admin to his workstation. A bad InfoSec practice, but it does
317180	323240	happen way more than we want. And then that machine can RDP to a terminal server, for
323240	328520	example, in your environment and depending how much, uh, employee you have, this might be
328520	335240	between 1,000 or 100 to 1,000 people. Then on that machine, there's a user who has a
335240	340200	session and he has a little crown because he's a member of a high value group. I see people
340200	344660	with phones, um, last slide of the deck will contain the link where you can download the whole
344660	350860	slide so you don't need to take pictures of every slides. Now let's go over an overview of
350860	355980	Bloodhound. I'll try to go quickly as more than half of the people, uh, seems to have used the
355980	360540	tool before. But first of all, what is Bloodhound? Rest assured there's lots of word, but
360540	365080	it's the only slide with so many words. So Bloodhound uses graph theory to reveal the hidden
365080	370800	and often unintended relationship within an active directory environment. Both attackers and
370800	376740	defenders can use those paths. Uh, red teamer to exploit them and of course, blue teamer to
376740	381840	destroy them before they are being exploited. Here's a very quick history of Bloodhound. It
381840	388240	was, it was released at Bloodhound 24 in a talk called Six Degrees of, uh, Domain Admin. If
388240	392700	you go to that link, you'll see Rowan actually unlocking his password manager and making the
392700	398560	repo live. I was personally, um, introduced to Bloodhound a year after that at Black Hat 2007
398560	404720	in a talk called Industrial Revolution of Lateral Movement from Tal Mahar and Tal Barry. And
404720	409760	it's an excellent talk where they explain how they can use a path generated by Bloodhound and,
409760	415900	um, uh, through PowerShell, they just exploit and get the credential automatically. And then
415900	421880	last year at Bloodhound, uh, at Black Hat, sorry, 2018, the team released Bloodhound 2.0 and
421880	426020	Bloodhound is developed by Waldo, Captain Jesus, and Armjoy, three people I'm sure you're
426020	431740	familiar with. So what does Bloodhound do exactly? Well, there's three simple things. It
431740	437060	queries Active Directory, it imports the data in the Neo4j database, and then it shows the
437060	443300	relationship between the objects. So why should you use Bloodhound? Well, for red teamers, you
443300	448480	can use the UI to bu- to build complex attack path offline and this reduce the noise on the
448480	453160	network a lot. So every time you jump on a machine, you already know which credentials you
453160	458440	need to steal and which attack path you need to follow to get to the next, you don't need to
458440	463580	re-scan the network every time you land in a new machine. For blue teamer, we can use query to
463580	469800	find the busiest attack path. Um, we can test the relationship of deleting or removing, uh,
469800	474700	relationship or remediating would be the right term, um, on your graph. And then you can
474700	481500	destroy the path before they are being exploited. So it's now time to talk about the basic, or
481500	487500	what I like to call the first steps. So first of all, you need an ingester. There's three
487500	492260	ingesters, there's SharpHound, which is a C-sharp tool, there's InvokeBloodhound, which
492260	497320	is a PowerShell that loads, uh, SharpHound reflectively, and then there's BloodhoundPython
497320	502600	that was built by, uh, Dirkjen from Foxit. So if you land in a Linux machine, you can still
502600	507640	leverage the goodness of Bloodhound. Uh, on the right, I've put some comment. I'm gonna go
507640	512780	very quickly through them. Uh, just want to mention that, uh, collection method all does not
512780	518860	include logged on anymore, because starting in Windows 10, 10th anniversary, uh, and, um,
518860	524300	Windows Server 2016, you need to be local admin in order to list the session. So now you need
524300	529200	to add that if you want to have everything. DC only is something that is, um, less quiet,
529200	533300	makes a lot less noise on the network, but you, as a defender, you should still run that in
533300	538580	order to make sure that you can detect it. Uh, max loop time goes with session loop. By
539020	544700	default, uh, Bloodhound will loop for session for 2 hours. Um, as we're defender, we don't
544700	549460	really care about being detected, so we should run that as long as possible. Uh, the reason
549460	553860	being that if you run it during the day, you'll get all your user session, whereas if you run
553860	558500	it at night, you might get some administrative tasks that are happening only at night. Um, and
558500	561980	you should also shift the days that you're running it because some activities might happen
561980	568100	only a day a week. Um, search forest, uh, yeah, whatever, if you have more than one forest,
568100	574720	sharpound-h for help, uh, could be useful. Uh, this is a screenshot of the GUI, but there's
574720	579240	nothing like a live demo, so let's jump into the UI. This is the screen that you're gonna see
579240	585280	when you get here. Um, because I'm a bit short on time, I'm gonna make it, okay, as quick as
585280	594640	possible. I'm just gonna turn like this. Um, so the thing I wanted to show you guys is, um,
594640	599860	gonna skip a few things, but query, most people when they land here, they will use the, uh,
599860	605940	fine administrative, fine shortest path to domain admin, um, and the domain, so I'm gonna let
605940	611440	the little doggy do, the doggy do his thing while I just show you here the filtering option. So
611440	616040	these are all the edges that you have available for you. Um, this is not the latest version,
616040	620220	they're quite, there's a few more now, but it was working for the presentation and I didn't
620220	625380	dare to try the new version. Um, so you can remove any of those edge and re, recreate the graph
625380	632140	and it's just gonna be gone. Um, so from here, what I wanted to show, but now I, I can't really
632140	639880	not read, but if you don't know how to, um, yeah, anyway, I cannot see the, the thing, but you
639880	646900	can right click on any edge and get help, um, and information about how you can abuse that type
646900	651140	of relationship. So this is really useful and it's not really well documented. Uh, you have
651140	656400	some, uh, OPSEC, uh, consideration and of course, uh, lots of reference as well for any type
656400	666060	of link. Um, another interesting thing is that if you right click on any of the nodes, you have
666060	670200	a few little menu here and you have edit nodes. So if you go there, you can see all the property
670200	677200	of that node and you can also add properties using the little add button right here. Um, there's a
677200	682920	few undocumented shortcut as well that I want to, um, point out today. So first of all, there's
682920	688760	the space bar that will bring you spotlight. Here you'll have all the elements of your, uh, graph.
688760	694620	So you can click on anything and it's gonna, uh, zoom in on your element and put it in the, um,
694620	700500	directory here. So here you have, uh, if you, if you wanna, if you have a, a user that is called
700500	705720	Matt, you can click on him and if you wanna know if he has a path to domain admin, you just use a
705720	712360	little road here and you type domain admin. And just like Google Map, it will show you if the
712360	719040	user has a path to domain admin. So here's the path for that user. Um, beside that, a few other
719040	725640	maybe keywords, uh, you can use shift command and I to bring a console. So if there's any error
725640	733600	message, uh, that you want to read, they will be here. Um, lastly here in the settings, there's
733600	739040	two, uh, uh, yeah, two interesting thing. First of all, the debug query mode that goes with the
739040	744440	raw query here. So when you activate that, every time you click somewhere, you will actually have,
744440	748660	um, the query in Cypher at the bottom in the raw query bar. And this is really helpful if you
748660	755560	wanna learn Cypher. And, uh, last but not least, there is the dark mode, which is probably the
755560	761520	most important part of Bloodhound. So let's get back to the presentation. And by the way, every
761520	768180	time I say, uh, dark team in this presentation, there's a fairy that is born. So here it is. Uh,
768180	772600	why fairies? Because I have two daughters and they love fairies. Um, here are the
772600	778000	undocumented feature that I talked about. So using, uh, the right click on an edge to show
778000	783220	contextual help. Using control to toggle on or off the labels. Control shift I for the console
783220	789620	space bar. And you can also search for GPO or OU, uh, right in the bar and also domain. So if you
789620	795440	wanna know what's, have been enumerated, you can use those keywords. So graph database, as I
795440	801200	mentioned, you, you load, uh, the data in Neo4j. Uh, this is where you can download the
801200	805440	community edition, which is free. And then you start it like you would start any other Linux
805440	813420	services just by using the start. Um, once it's installed, you can go to a, uh, web console on
813420	819640	port 7474. So some people might ask why use the web console when Bloodhound comes with a UI.
819760	824640	Well, there's a few reason for that, uh, especially when you start writing your own query. If
824640	830760	you make a mistake in your query in the console, um, you'll quickly know that your query is
830760	835640	wrong and it will point you what is wrong in your query. So right here you'll see that equal is
835640	841100	not the right, uh, symbol. You need to put a semi-colon. So when you fix that, you get the
841100	846780	result of your, um, of your query. Also, you can see that if you're not returning a path but
846780	851260	you're returning a property, it will actually list, uh, in a table, which doesn't happen in
851260	857640	the GUI, but we're gonna come back to that. A last reason to use, uh, the web GUI, the web
857640	863440	console, sorry, it's because it also has a dark theme. Hey, another fairy. Uh, let's go
863440	870160	through an introduction of Cypher or what I like, I like to call learning to run. So a basic
870160	876040	Cypher query will have a few objects, a few, a few elements with a, a match statement. Then
876040	881160	you have to declare some objects or variables. So here you can see that we are declaring a
881160	886400	variable U of the type user. And if you want to, uh, access the attributes, you need to put a
886400	892760	dot with the attributes name. Then you'll likely want to find some relation, so that says two
892760	896960	dash and an arrow pointing in the direction that you want, and in brackets, you can put the
896960	903060	relation type. After that, you'll probably want to find paths, so you have shortest path or all
903060	908840	shortest paths from one variable towards another one. And then you have where if you want to
908840	913040	make some filtering. And then you need to, a return function to say exactly what you want to
913040	920520	return. So there's two methods for doing the filtering. There's the explicit methods and
920520	924560	there's the where clause. So I'll show you the difference between the two. Here is with an
924560	929240	explicit function. So you can see that I'm declaring a variable called N and it's type of a
929240	934980	group. And the name must be equal to, uh, domain user at test lab dot local. Then I'm
934980	940420	defining another variable M, which is a group, uh, and this one is domain admin at test lab dot
940420	944720	local. And then I'm looking for a shortest path between those two groups and I don't care how
944720	950380	many ops there is and I want to return the path. With the where clause it will look a little bit
950380	956120	more like this. So we have the match shortest path N towards M group and then we say what we
956120	960660	want for those domain, uh, those variable. So the first one is we want it to start with domain
960660	966020	user, whereas the other one we want it to contain something. There's also end widths that
966020	971280	exist. And then we return the path. Here are the two queries side by side. When you run them,
971280	976980	not surprisingly, you get the exact same result. So why use one instead of the other? First of
976980	982360	all, the time. It is way faster to use explicit when you can versus a where clause. On the other
982360	987560	end, if you're, um, a consultant or if you have multiple domains and you, you use specific,
987560	991120	you'll have to make your query for all the domains that you go to, you'll have to change your,
991120	995820	your query all the time. So depending on the situation, one might be more suited than the
995820	1000920	other. Also when you're using the web UI, it will help you improve your query. So when your
1000920	1006300	query works but is not optimal, you'll get those little, um, exclamation mark and when you
1006300	1012800	click on them, uh, the UI will tell you how you can actually improve them. So here's the query
1012800	1017680	that we have improved. So if we put them side by side, you can see that in the first one, we
1017680	1022680	declared a variable and then we do the shortest path, whereas in the second one, we do the
1022680	1026680	shortest path and we declare our variable right inside the function, which is now the preferred
1026680	1037950	way to do it in Cypher. This is pro tip number one of the talk. So using appending explain or
1037950	1042530	profile in front of your query will help you understand what's actually happening under the
1042530	1047630	hood. So explain will, will do the execution plan but will not run the statement, whereas the
1047630	1052410	run, uh, the profile will run the statement and you'll see exactly which operator is taking
1052410	1057690	more, uh, doing most of the work. So here is how it works. So here's a complex query that
1057690	1063070	returns pretty much all the object in the graph, um, and you do match. So when you do explain
1063070	1068190	match, just put explain and, and before, you'll get this. So you know, this is explain. So you
1068190	1074590	can see here we have, uh, since, uh, 1600 hits estimated. When we run it with profile, we see
1074590	1080110	that it's actually 16,000. So you can see that, uh, profile is way more precise than the other
1080110	1086390	one. Here are some, uh, useful query and I'll just put also my GitHub link here. So if you
1086390	1090890	want to download it, all the custom queries that I did not show you in the UI, they are there.
1091590	1095530	Um, so domain user, those are the first thing that I like to do when I start an engagement or go
1095530	1100230	on a new domain. Uh, looking where domain user, our local admins, if they have a shortest path
1100230	1105090	to high value target, if there are any places that they can RDP to, and then all the other bad
1105090	1109810	rights that they might have. Then I like to look into Kerberos thing. If you have no idea what
1109810	1115650	Kerberos thing is, in a nutshell, it's, um, it's an attack where you request a weak password, a
1115650	1120830	weak cipher of a password in RC4 and then you crack it offline. If you want more information,
1120830	1128410	ADSecurity.org, the site by Sean McAlf. And then I also brought back the, back the top 10, uh,
1128410	1132530	that were removed from version 1 to 10 because I believe as a blue teamer, it's a good place to
1132530	1138530	start exploring your graph. So I just put them back. Here's, uh, an example of some advanced
1138530	1143810	query that were shared in the Blowdown Cipher Query Slack channel. Uh, I believe those, the
1143810	1149190	both of them were built by Waldo. Um, just to show you that, uh, you can start doing optional
1149190	1153590	match, you can start collecting variables, you can add them together, you can unwind, uh, you
1153590	1158070	can count stuff. And if you look at the second one, you can extract, uh, labels, you can extract
1158070	1164010	variable, you can filter things, um, you can do, um, average length and lots of mathematical
1164010	1169950	things also, uh, in there. If you want to learn more about cipher, there's a good cheat sheet
1169950	1175150	from Neo4j and this is the link. Now that we know a little bit how to build cipher queries, it's
1175150	1184100	time to destroy paths. So what are we trying to do when we're destroying paths? Well, we're
1184100	1189900	trying to find the busiest path and then we're trying to find, to test the effect of the
1189900	1194740	proposed remediation. So when you have the old path, sometimes you, it might seem obvious
1194740	1199600	that if you remove a link, you'll destroy the path and domain user won't have access, uh, won't
1199600	1205380	have a path anymore to domain admin, but we'll see that this is not always the case. Um, and
1205380	1209620	then when we know exactly which path should be removed, then we can inform our domain admins
1209620	1215000	and have them make the change. Let's try this in a control environment. First of all, we're
1215000	1220200	gonna create a problem. So I'm gonna merge the domain user and I'm gonna give them admin
1220200	1225780	rights to the computer 673. When I run that in a console, I get that one relation was
1225780	1230820	created and I'm very happy. After that, we're gonna test our relationship, so we're gonna ask
1230820	1236800	for a path between domain user and the computer 673 and we're gonna ask to return the path. Not
1236800	1242780	surprisingly, our path is there. Now we have two options that we can use. We can filter out
1242780	1248320	the relationship. This is, this is to be used when there's only one relationship type, uh, in
1248320	1254100	that path. Or you can delete the relationship if there's more than one relation. I'll show
1254100	1258500	you how to do both. So first of all, filtering out the relationship. So here's the same
1258500	1263540	beginning of the query. We're looking for a path between domain user and computer 673 and we
1263540	1269060	want to filter a relationship where the type of relationship is not admin 2 and we want to
1269060	1274160	return the path. If we do it with a delete, it will look like this. So pretty much the same
1274160	1280840	query again, but then we just delete the relation. And then you need to print it, so same
1280840	1285540	thing, but you return the path. And those are the three queries side by side. When you run
1285540	1292680	them, again, not surprisingly, you have no data. The thing is, everything I just said was
1292680	1299100	wrong. So you're like, okay, everything was wrong, so why are we here? Is, are we losing our
1299100	1304980	time? Um, I'll take you to what happened in my head in the last 36 hours and remember that I've
1304980	1310120	presented this at B-Side Charm and, uh, this part was not in B-Side Charm. So let's do it
1310120	1314860	against real data. So we're going to do the same thing, we're going to find, uh, our target, so
1314860	1319020	we're going to do the shortest path between domain user and domain admin and we're going to
1319020	1324840	get a path that looks like this. Uh, the top here is execute decom and it's the only execute
1324840	1331980	decom in the path, so this should be a prime target for a filter out. So here how you would
1331980	1337260	do that, you would say shortest path between domain admin to domain, uh, between domain user
1337260	1343600	to domain admin, where the path is not execute decom. And if the fix is right, and if this is
1343600	1348480	the fix that we want to send to our, uh, sysadmin, we should not have a path to domain admin
1348480	1355700	anymore. Now we have a problem. We still have a path, but it's much longer. So this is, the
1355700	1361460	execute decom is not the right thing that we want to execute, we want to exclude. But why
1361460	1367500	filtering is wrong? I'll show you right here. So this is instead of shortest path to domain
1367500	1372440	admin, this is all shortest paths to domain admin. So as you can see there's two paths with
1372440	1377400	the same length that lends to domain admin. This is the first one that we excluded with the
1377400	1383460	execute decom, but right here there's another execute decom and that link was also removed
1383460	1388880	from our view. So not only did we still have, um, a path to domain admin when we excluded
1388880	1395760	execute decom, but we removed every, uh, execute decom everywhere in every path of the graph. So
1395760	1402440	that's why filtering out is actually a bad idea. Now it's like, okay, but at least I can
1402440	1408000	delete relationship, right? So here's the same shortest path, but then I print the label and
1408000	1416320	you can see that in between, uh, computer, uh, sorry, group 4574 and computer 65, uh, 652,
1416320	1421460	there's our execute decom. So we're going to target that link and we're going to say, we're
1421460	1427320	going to take the path, uh, I want a path between, sorry, the, and then, yeah, assign it a
1427320	1433440	variable R and then we're going to delete the relationship. And then this happened. And then I
1433440	1439520	was like, well, shit, now I've deleted two relationship when I wanted to only delete
1439520	1445120	execute decom. And I was like, okay, now what do I do? My talk is in 36 hours and none of my
1445120	1452740	techniques actually work and I'm going to look like, uh, anyway. But, uh, the solution was
1452740	1459200	quite easy. I googled how to target a single link and the first, uh, result was actually
1459200	1464840	there. So it's very easy. The same query, but you can see that here I have actually tell it
1464840	1471380	exactly which relation I wanted to target and I, oops, and, uh, delete only one relationship.
1471380	1475360	And then I was partying like Dave Vader was not there. Uh, that's pretty much what I looked
1475360	1480700	like in my room, uh, yesterday. So now we get something that looks like this when you're
1480700	1485020	using the filter out to this path, which is actually the path that we saw on the top in our
1485020	1492400	execute decom is right there. So that brings me to this part. So when you do the same query in
1492400	1498740	the web UI, you get the picture on the left, which has all, you can see all the, um, all the
1498740	1503860	links. When you do it in Bloodown, you only have one link. So I looked a little bit, I asked,
1503860	1508840	uh, the guys from Bloodown and the reason is when you do a query to Neo4j, it returns only
1508840	1515780	one, uh, link, but then the GUI somehow add them back when the query is done. So that's why, uh,
1515780	1520420	on the Bloodown GUI, they only get the one link that is returned by the query. And it's by
1521140	1528600	alphabetical order. So let's, let's talk about what, what exactly happened here. So a
1528600	1533580	graph is like a map. So imagine that you want to find all the routes between Chicago and New
1533580	1538100	York City, for example. You'll, maybe you'll be shown one or two routes on the map, but
1538100	1543580	that's by, by not, it's not all the paths that exist by any stretch of the imagination. You can
1543580	1549240	turn left on the street, right, whatever. So that's exactly what's happening here. Bloodown,
1549240	1552480	well, Bloodown will only show you one relationship, so you might think that there's only one
1552480	1556960	when there's many. And it is possible to delete a very specific relationship using this
1556960	1562740	command, so assigning the name of the relationship that you want to delete before. Now,
1562740	1568060	let's get back to our regular scheduled programming. This is the pro tip number two of the
1568060	1575940	talk. Um, by default, there's five groups that are high value in Bloodown. But in your
1575940	1579800	environment, it's probably not the case. You probably have way more groups that are very
1579800	1584940	important. So this is a query that will help you find all the group that contains admin and
1584940	1590340	that their high value, uh, attributes is not set to true. You're going to return those name
1590340	1596300	and your environment, we have Asia admins, Europe admin, and North America admins. Now,
1596300	1599700	what we're going to do is that we're going to run the same query, but we're going to set those
1599700	1605800	group high value property to true. So we go from the five original ones to eight groups that
1605800	1612160	are high value. Pro tip number three, what about the user inside of those groups? So here's a
1612160	1616360	query that's going to help you find all the high value groups that you have and all the user
1616360	1620780	that belongs to those group and then you're going to set the high value property of those user to
1620780	1625300	true. If you have a good eye, you might have noticed that this relationship is in the other
1625300	1630880	direction and just is, this is just to show you how flexible Cypher can be. So what it's going
1630880	1634500	to do, it's going to change something like this where you have domain admins with a diamond
1634500	1642140	meaning that it's a high value, a group, and, uh, user are not high value to this. Now,
1642160	1649320	it will also change your shortest, all shortest path to this, from this to this. So you see that
1649320	1655620	in reality, you have a lot more path than you actually thought at the beginning. Pro tip
1655620	1661800	number four, I know, I know, it's not Christmas and I keep on giving. So here is, uh, in the,
1661800	1666500	uh, in the shell, uh, CLI where you can, uh, you can use Cypher shell and I'm going to talk
1666500	1672360	about that a little bit later. Um, but basically here, we see that the first one is longer to
1672360	1676700	execute than the second one and the reason is very simple. In the first one, we are returning
1676940	1683180	a path, where on the second one, we are returning a, uh, attribute. So it's a lot faster to
1683180	1689600	return attributes if you don't have to, uh, send a path. Uh, pro tip number five, another way
1689600	1695100	to accelerate your query or make them faster is to remove the relationship variable if you
1695100	1700200	don't need them. Here the difference seems very small, but bear in mind that my database is very
1700200	1705940	short. If you want to learn more things about how you can use Bloodown as a defender, you can
1705940	1710980	watch operationalizing Bloodown attack graph for defenders. There's also SAT processor who did
1710980	1715680	quite, uh, a lot of research. Uh, you also present another methodology where you actually
1715680	1720820	whitelist or whi- blacklist the nodes themselves by adding a properties. And then of course,
1720820	1724380	there's a Bloodown Slack, the Cypher query channel where there's lots of people there,
1724380	1730180	including myself, that will try to help you with your Cypher query if you have any problems. Now
1730180	1734180	we're gonna talk about reporting because attackers thinks in graph, management thinks in
1734180	1744880	metrics, and as long as this is true, ops will suffer. So here's an example of very, very
1744880	1751480	simple, uh, report that we can have. At the top you can put, uh, say, in January 100 percent of
1751480	1756620	our user had a path to domain admin. Now in February 7, it's 57, and then in March 12, and
1756620	1761820	we're trying to get to as low as possible, of course. If this is not visual enough for your
1761820	1767400	management, you can always use gauges. Those one were built in, uh, Google Doc, for example,
1767400	1771840	very easily, and if they don't understand this, well, honestly, at this point, I cannot help you
1771840	1780540	anymore. Here's a query about how, uh, you can find a percentage of user with a dom- uh, path
1780540	1784660	to domain admin. So what you're doing here is you're looking for a shortest path between
1784660	1791780	domain user and, um, sorry, shortest path to DA. So here you're looking, yeah, you're looking for a
1791780	1796200	path from user to domain admin, and then you're going to count the number of user you have in
1796200	1800840	your path, and then how many user have a path, uh, and then you're going to do some maths
1800840	1805260	writing the return function. So user that has a path divided by the total of user multiplied by
1805260	1810640	100, this will give you your percent, and when you run this, you get 100 percent in this case.
1810640	1813840	Now when you're done with the low-hanging fruit, you can start looking at things that are a
1813840	1821020	bit mo- more, a bit more funky, like, do I have any domain admins that have session to non-DC
1821020	1826520	machines? This is a bad practice. Your domain admin should only log in into the domain
1826520	1833500	controller. So what we're doing here is that we're looking for, uh, comp- computers that are
1833500	1839980	not part of the domain controller group, and we assign them a variable called non-DC. Then
1839980	1846700	we're looking for non-DC that has a session to a user, and the user must be, uh, a member of
1846700	1854180	domain admin. And then we return the name, the username, and we count the connection. Again,
1854180	1859380	here, there's something special about this query. We have a double relationship. It's also to
1859380	1864780	show you how powerful, uh, Cypher can be, and I'm very proud of this. Uh, I, I worked, uh,
1864780	1868940	really hard on this one. I got another version from Waldo, uh, on the Slack channel, but he
1868940	1875440	was using SID, and it was not working with SID in the test database. So this will give you
1875440	1879280	something like this, so you see all of your admins and how many connection they have to
1879280	1885180	non-DC machine. If these names are too cryptic in your environment, you can do a little
1885180	1890020	modification right here, and in brackets, you can put all the fields that you actually want
1890020	1895200	to display, and it's gonna look like this. So here you have the username and also the display
1895200	1901560	name, so it might be easier for you to find who this account belongs to. So here's another way
1901560	1906180	of representing the same graph, uh, the same Excel fight. Here's log- log- logarithmic, and
1906180	1911580	you're aiming for your data to go down, down, down, down, down. Um, it's probably not the
1911580	1916160	best way to show it, but, uh, at least there's a dark team, and that gives me my third fairy
1916160	1925180	for the talk. So now let's talk about automation. So as I mentioned earlier, there's a CLI,
1925200	1933400	um, command, sorry, uh, in the bin directory of Neo4j. So you can go there, you export your
1933400	1938460	username, you export your password, and then using Cypher shell, you can paste your query
1938460	1944140	directly there. You just need to, uh, enclose them with single quotes. Um, so another pro tip
1944140	1949520	would be every time you build a custom query in, um, Cypher, always use double quotes. And
1949520	1954080	when you go in your, uh, shell, you can use a single quote. Uh, if you do mix and match, it's
1954080	1960220	gonna be very difficult to automate things. So this query, um, is, we're looking for the
1960220	1965200	Kerberos table, high value accounts that are Kerberos table, so that's why we have as SPN
1965780	1972080	attributes to true, and high value group set to true. When you run that, you'll get this in the
1972080	1977600	shell, but you can also pipe it in a CSV file, and it's gonna look like this. Uh, Q8 is only
1977600	1983540	because that was my eighth query in the graph. CSV is very easy to open, I mean you can send
1983540	1987780	that to your manager or your sysadmins, they will be able to open it in their favorite
1988680	1996800	spreadsheet. Now, alerting. So you, when you have your query, you can start comparing, uh, the
1996800	2002420	current munch result with the last munch result, and you just send an alert if the number
2002420	2009500	increase. And I went very fast cause we're already at the conclusion. Here are the key
2009500	2016960	takeaways for today. Defender can think in graph too, using tool like Bloodown. Cypher is a
2016960	2022840	very flexible language, and you can do a lot of thing if you put the effort in it. It's also
2022840	2027880	important to test the real impact of a remediation before you send it to your sysadmin,
2027880	2032000	otherwise they'll lose faith in Bloodown, they'll lose faith in your process, and they'll
2032000	2038180	probably lose faith in you. Um, but it's easy to do as I demonstrated. Not all query are
2038180	2045720	worth automating. What I mean by that is that, yes you can see all the domain, all the user
2045720	2049480	that are in domain admin, for example, and you probably want to be alerted if there's new
2050000	2054720	user in that group. But you'll run Bloodown maybe once a quarter, once a month, if you're
2054720	2059080	lucky maybe once a week. Uh, that's not fast enough to be alerted if there's a new domain
2059080	2065180	admin. So you're way better off looking for event ID 4728 in your logs to be alerted in
2065180	2071340	near real time. Finally, I want to give a big thank you to the Blue Team Village for having me
2071340	2077480	today. I want to thank Pyrotek, Talberry, and Grifter. Um, I'm, I'm here because of these
2077480	2081800	people and especially Grifter last year, uh, in Toronto said that, uh, if you have something
2081800	2087360	that you want to share with the community, don't be shy, do it, do CFPs, and, uh, you might
2087360	2092200	get accepted. And that's what happened to me, so I'm very happy. Um, and you learn a lot
2092200	2097240	more about what you want to talk about or what you, about your subject when you make a talk
2097240	2101160	because it's the second talk and as you saw, uh, lots of things have changed since the first
2101160	2106500	version. Finally, I want to thank Waldo and Captain Jesus, uh, who created the tool and who
2106500	2111340	are helping everybody in the Slack channel when they have questions. So as promised, here's
2111340	2116680	the link to the, the, the whole deck. And, uh, the second link is the talk for, uh, the same
2116680	2121760	talk, but, uh, that I gave at B-Side Charm where I gave a more in-depth tour of, uh, the GUI
2121760	2127720	and, uh, I go a little bit, well, less fast, let's say, slower. So if you have any questions, I
2127720	2143630	have a few minutes. So the question is, is there a training or environment you can practice
2143630	2149510	on? Yes, there is, um, an open database. I don't have the link with me, but if you go to the
2149510	2155230	Bloodhound Slack, um, or if you, if you send me, uh, a text or something, I will give it to
2155230	2161570	you. It exists. Uh, the Specter Ops team has built, uh, and put online a database. And you can
2161570	2166630	also generate your own. There's a DB generator that comes with Bloodhound that you can run and
2166630	2171330	you just specify how many, uh, you com- user and computer you want and it's going to build
2171330	2182580	everything. That's what I use for this presentation. So this is all fake data. Yes. So is
2182580	2187960	iValue a Bloodhound term? Yes, it is. It's an attribute that, uh, that it, uh, that is
2187960	2193540	collected and that is, uh, you can activate it in the GUI or manually using Cypher. So it's
2193540	2205510	one of the properties. Well, everything is open source, so you can probably change, uh, the
2205890	2210050	default iValue group in the code if you want. Uh, but I don't know how to do that, but I'm
2210050	2229120	pretty sure you can. Any other questions? Yes? So the question was if you run Bloodhound a
2229120	2233400	multiple time, uh, can you just import data over it or should you kind of clean your
2233400	2238740	database? Uh, the best way usually is you save your old database and you create, then you, you
2238740	2244100	save it, then you clear it and you re-import. So you can see, yeah, it's better. Because
2244100	2248580	otherwise if, if your admins have made changes, they will still be there in your environment
2248580	2253440	and they will still, when you do your query, it's not going to be a, uh, a real representation
2254040	2272980	of your environment if you don't clean it. Yes, sir? Is there, uh, the, the question was is
2272980	2280340	there a reason why I did the deleting the relationship between looking for, for, for the
2280340	2285400	percentage? Uh, because I believe it's, it's easier to find, to, to break the, the most path
2285400	2290500	at the beginning, um, but you can do it the other way around also. But if you have something
2290500	2294420	from domain user that goes to domain admin, that's probably the first thing you want to
2294420	2300420	remove and that will give you, um, a high win rate or a, a big drop in your percentage. If
2300420	2305680	you have a path from, from domain user to DA, that means 100 percent of your user have a
2305680	2323600	path and it's going to be hard to find which one to, if you're not doing the query. Yes, sir?
2323600	2329940	Okay, uh, is there a difference between the 3 and Jester? The sharp, the sharp, um, uh, the
2329940	2336020	PowerShell one and then the, uh, Python. So Python should be mostly used if you land in a
2336020	2341180	Linux environment or if you don't have any credentials. And then you go to the first
2341180	2347180	machine and you rerun SharPound from there. So SharPound is really the preferred methods to
2347180	2352200	run it. Uh, you'll see that now since a few months, a lot of antivirus has started
2352200	2358820	categorizing it as a virus, which is a bit sad, but you can kind of understand maybe why. Um,
2358820	2366460	so PowerShell is a way to actually load, uh, uh, SharPound reflectively. So if you have
2366460	2371920	application whitelisting, for example, you might be able to run a script or, yeah. But the
2371920	2376920	preferred methods, especially for a blue teamer, would be to allow SharPound to be executed in
2376920	2383540	one machine, in one directory, and then you, you do it this way. As a, as a red teamer, I'll
2383540	2387780	let other people answer, but as a blue teamer, you should just whitelist in for a very
2387780	2406330	specific place. Any other questions? Yes? Okay, so the question was, is there any tools in
2406330	2412470	Neo4j to, uh, see the difference between different graph? I don't know of any, but, uh, my
2412470	2416330	friend is sitting right there. Give me a good idea and I'm gonna work on that, uh, for next
2416330	2428680	year. The question was, did I test it in any Azure environment or any other cloud? No, I did
2428680	2437940	not. Any other questions? Thank you very much, everybody.
