start	end	text
0	5380	Both of these folks have a pretty extensive background, so I'm just going to cover some of it,
5380	11960	introduce them. But before I do that, quick show of hands, how many people are doing threat
11960	20100	hunting in memory, looking for hostile actors in memory, right? So it's a difficult problem. And
20100	28200	so I'm really, really excited to personally to hear this talk. This is an area that needs a
28200	34720	whole lot of work to be done in it. And it's, you know, folks like Carlos and Marcos that are,
34720	43660	you know, on the edge of providing this kind of content for us. So Marcos is a software architect
43660	50600	at McAfee. He's leading the development of exploit prevention technology components, which are
50600	57580	part of the company McAfee's next generation flagship product called Endpoint Security.
57580	63960	Marco also led the organization of the first ever B-Sides conference in Cordoba, Argentina.
65220	71220	Carlos is an experienced InfoSec analyst who drives strategic initiatives and provides thought
71220	77360	leadership and insight regarding the ever-changing global landscape at Claro America Mobile
77360	85860	Offices in South America. He organized the One Hack Para Los Chicos local security conference,
85860	92080	and is now working on organizing the first ever B-Sides conference in Cordoba, Argentina.
92220	99240	So great, great to have these folks come and share their research with us. Give them a round of
99240	100120	applause.
100620	101800	Thank you.
106120	112780	Okay. Thank you all for being here, and thank you for attending this call, this talk, and thank
112780	119760	you Blue Team Villas for having us here. This talk is going to be about this project that we
119760	127960	started like a year ago called Memhunter. For us it was really a way to learn and new and
127960	133780	past code injection techniques and process manipulation in general. And also it was a way for
133780	138500	us to explore and how to cope up with a problem that we were having on the field, which was
138500	144980	around doing this threat hunting process in memory at scale. So we will talk about that during
144980	149720	the slide, and we'll talk about the problem that we are trying to solve. So this is the agenda for
149720	158480	today. So probably we will skip the first slide, and then introduction part. Then we will jump
158480	166060	into the why, the how, and the what part of this issue. So on the why, we will dive into why
166060	172680	hunting in memory is important. At least from our perspective, I will leave some, some, some
172680	181620	hints on that. Then on the how part of things, we will discuss on the how someone can go and
181620	189060	hunt for this stuff in memory by looking at specific properties of the processes. And then on
189060	194360	the what part of the agenda, we will discuss the tools. And this tool that we have created
194360	199100	called Memhunter, we will discuss on the characteristics of the tool. And we will also
199100	204840	talk about the, on the, the current state of the tool and then the future. Uh, and we will wrap
204840	212180	up everything with a, with a demo. Uh, with two demos actually. Okay, uh, about us. So, okay.
212180	219300	Do you want to? Yeah. Uh, hello. Thank you for coming. Uh, I'm Carlos. He's Marcos. Uh, he's
219740	227960	a Infosec lover. Uh, he, he working in McAfee. Uh, he's a software architect. Sorry for my
227960	238060	English. Uh, we, okay. Uh, we, we are a B-site Cordova organizations. Okay. And I work in, in
238060	244760	Arsec. It's a startup of Infosecurity. Okay. Okay. Yeah. Thank you. Thank you, Carlos. So
244760	251500	why, why hunting in memory? So, uh, couple of things here. So memory, why hunting in memory
252000	257320	these days? Uh, it's, it's a, I mean, hunting in memory is an important thing because of, uh,
257320	261860	the shift that we haven't seen on the threat landscape. So the threat landscape, uh, uh, has
261860	266980	evolved over the last few years. Mainly the, the attackers have really started to, to adopt
266980	272120	new techniques, to, to, to adopt new things, to evade the, the current detections. So they
272120	278480	shifted their, their, their, their attacker, attacker threat graph from, uh, a, a purely
278480	286420	fail-based, uh, uh, approach to a file-less, uh, base approach. Um, so one, one trend or, or
286420	292680	one aspect of, uh, this, uh, evolution is what we call the different, uh, vectors that
292680	296840	attacker, that they are using for that. So one of these vector is, uh, what I call the
296840	301900	process manipulation. Uh, so as part of, uh, the process manipulation, there are several
301900	307720	things that attackers do in order to evade the current defenses. Um, one of those
307720	313300	manipulations, uh, are what, what is called the, the call injection, right? There, there is
313300	318020	another type of process manipulation called, uh, defense evasion. So we'll touch on that
318020	321820	during, during the, the presentation. What I wanted to mention here is that mainly because
321820	328180	of this trend is what, uh, uh, people working on the blue side of the house have to, uh, uh,
328180	333720	come up with a new, new way to, to detect this, uh, this stuff. And another thing that, which
333720	338460	is actually quite important is the fact that, uh, in the past, uh, these, uh, techniques,
338460	343180	this, especially the call injection techniques, they used to be, uh, uh, something that was
343180	348680	only available for, you know, these big, uh, sponsor, uh, APT groups, mostly national
348680	355460	state groups. Uh, and they, they know, uh, how to take advantage of this just to avoid, you
355460	360820	know, being detected and being spot, uh, spotted, uh, on, uh, you know, on their, uh, on
360820	365980	their, uh, uh, intrusions. Um, but nowadays that, that is not actually the case. Nowadays
365980	371240	it's, uh, call injection techniques especially are, are, are a commodity. I mean, uh, anyone
371240	376100	can go to GitHub, for example, and grab, you know, the latest and, and greatest, uh, call
376100	381760	injection and include it on their code. So accessing to these, uh, these techniques, uh,
381760	387720	are, are, are available to anyone, uh, right now. Uh, so that's why we, we need to, uh, start
387720	393240	thinking on including, uh, ways to, to detect this stuff, uh, on memory. So going, going
393240	400600	back to the file list, uh, uh, uh, state that I, that I just mentioned. So there are, uh, I, I, I
400600	406300	really like this, uh, diagram that was taken from, uh, uh, uh, a sans, uh, uh, uh, white
406300	410940	paper. So the idea here is that, uh, from the diagram you can see where call injection
410940	416580	came into the, into play, uh, on the file list, uh, attack, uh, scenario. So you see that
416580	422080	call injection is used, uh, as part of, uh, uh, I mean it's mostly used, uh, uh, this, this
422080	427820	series of techniques are mostly used as stages on, uh, stages of attack. So, uh, for example
427820	433660	in the, this, uh, scenario where we got a remote code execution, uh, attack where, uh,
433660	440520	someone is executing, uh, executing, uh, execution on our, on our, uh, uh, endpoint. An
440520	444700	example of this is, uh, the, the WannaCry example, for example, where, where we have, uh,
444700	450600	the SMB vulnerable driver, driver, and then, uh, uh, by exploiting, uh, that vulnerability
450600	455240	someone can get, uh, code to execute an, an, an endpoint. And then they, they will most
455240	460840	likely use, uh, uh, they, they will mostly, uh, uh, trigger the second stage of that attack
460840	469340	by, um, by injecting, uh, their malicious payload into the memory, the user's main memory
469340	474020	of, uh, running process, the system process, most likely. So in the case of WannaCry, for
474020	480900	example, they use a technique, uh, called QueueUserAPC, which allows them to, uh, um, um,
480900	487760	to, uh, execute code, to inject code into the context of, uh, Elsa's, uh, from, uh, kernel
487760	493920	space. So, uh, so in that case, uh, code injection was used as a, as a second stage of an
493920	498640	attack. And, uh, and the most, uh, common attacks that we are seeing nowadays, which are
498640	504700	mostly driven by download, download, we see that code injection is used as a second stage
504700	510740	of the attack. So, uh, the attacker, uh, uh, gain, uh, code execution through a Word document,
510740	516020	for example, just by having, uh, the user to open a, a, a, a document with a macro. Then
516020	521280	the, the macro will exercise some Win, Win32 APIs and then the, the injection will happen
521280	526340	and the attacker will be able to, uh, run code in the context of a different process. So
526340	532780	that's where code injection is, uh, actually, uh, a thing nowadays. So, uh, yeah, so we, we
532780	537960	know what, what, uh, these techniques are. We know how to catch them, actually. Uh, but
537960	543720	why, why is that difficult to, to hunt for this stuff, uh, at scale? So the, the, the, the,
543720	549020	the problem came, uh, on the, uh, tools and tech, uh, yeah, on the tools and frameworks
549020	555320	that we have to hunt for, for this stuff. So, uh, currently the, the, I mean, you, you
555320	560340	have, I mean, if you want to hunt for this stuff, you only have, uh, two ways, uh, from
560340	566200	what I, from my point of view. You either go and buy, uh, uh, uh, an expensive EDR product
566200	571340	that supports these, uh, techniques. There are several EDR products out there that, uh,
571340	575720	either does, uh, uh, memory inspection, which is the, the same, the, the same thing that
575720	579920	I'm doing with this tool, or, uh, memory scanner and they, they do, uh, you know,
579920	584460	dump, uh, pattern matching on the memory of, uh, the, the different processes to look for
584460	589580	IOCs and see if, uh, there is an injection going on. So you either have to go and do
589580	595060	that or you get, uh, volatility and you get a full memory dump of the machine that you
595060	600760	want to analyze and take that full memory dump, uh, uh, uh, into the volatility framework,
600760	605340	uh, uh, and, and, and run the different, uh, uh, scanners that volatility have in order
605340	609520	to detect for this stuff on the, on that, on that dump. The problem with that approach
609520	613140	is that it, it doesn't scale. I mean, if you want, if you, if you have to do that, you
613140	619560	have to go to the machine that you, uh, think, uh, might contain some, some, some of, uh,
619560	625260	of, uh, of, uh, something living in memory. You have to dump, uh, you have to get a full
625260	630780	memory dump of that machine. You have to grab that memory dump into a forensic environment
630780	636880	and then analyze the stuff in there. The problem with that, uh, is that, um, you cannot do
636880	641100	that scale. You cannot do that, uh, every day on, on your organization, on any machine
641100	645760	on your organization. So mainly because of that, uh, we, we created this tool called,
645760	651880	uh, Memhunter. So what Memhunter will do, so I'm just giving a, a, a brief spoiler because
651880	656620	we are seeing that in, in detail in a moment. But, uh, what Memhunter will do is that it
656620	662120	will perform what is called a memory inspection on every processes on the, uh, every process
662120	667820	on the endpoint. And it will apply the same type of heuristics, uh, and, and, and an extra
667820	672800	couple of more, uh, that, uh, that detects for this stuff in memory and it will report
672800	679500	that back to you. Um, so through that you can, uh, run this, uh, periodically either as a
679500	685620	service or on demand and get the results of, uh, your entire organization, uh, at scale. So,
685620	691640	okay, so we just talked about the why. So now we will talk a bit, uh, about the how, uh, we
691640	699280	can hunt for this stuff, uh, in memory. So on the how part, we will, uh, mention, uh, uh, a
699280	705660	bit, uh, we will, we will, uh, sorry, we will, we will do a quick overview on the, on the, on
705660	710920	what the process manipulation is, what the properties of a process are affected by a process
711300	716040	manipulation and a code injection techniques. And then we will also describe, uh, uh, we will
716040	722820	also give, uh, a few, uh, give you a few details on, uh, how a process is created, uh, on the,
722820	727780	when, uh, on the, on the Windows, uh, environment. So talking about, uh, process
727780	735480	manipulation. So process manipulation is, uh, is, uh, for me is, uh, uh, uh, an umbrella term
735480	741420	that can be used for any type of, uh, technique used to compromise a legitimate, uh, process
741420	747040	and have it to execute malicious code. So you can do that, uh, either by, uh, performing a
747040	752280	code injection through memory location or memory writing. You can do that by, uh, getting,
752280	757840	forcing the process to execute something. Or you can do that through, uh, mechanism that are
757840	763180	available, uh, in the Windows environment to force a DLL to, to be loaded, uh, during the
763180	771400	process start. Uh, so going into the Win32, uh, process internals, uh, the thing that I want
771420	776880	to, that I want you to take from here, I mean we can spend hours talking about this, but, uh, the
776880	782420	most important things for, for this talk is the fact that, uh, the Windows kernel is, is the
782420	788260	one in charge of, uh, allocating the, I mean when a process is started, uh, uh, the, the
788260	793500	Windows kernel is the one in charge of, uh, creating, uh, what is called a, a, a process,
793500	799700	uh, uh, a process object that will take care of, uh, the different, uh, uh, areas that that
799700	805440	process container will have. Uh, along, among those areas, uh, there will be, uh, memories, uh,
805440	811340	areas, uh, designated for the different threads that will run within that process. So every
811340	815960	thread, uh, which are, by the way, the ones that will be running code, I mean the process
815960	820260	itself, uh, is not running any code, just the thread, the ones that are running the code. So
820260	825080	the, the, there will be a, a, a call stack, uh, uh, designated for every thread. There will be
825080	830560	also a, a, a, an area within the process internal called PEV, which is a process environment
830560	836040	block that will contain information on the common line used for the process, the, some, uh,
836040	840880	information about the, the, the, the properties of the image file, um, yeah, and a couple of
840880	845620	other things that we'll mention in a second. Then there will be areas around, uh, that, that
845620	852500	will, that will hold information, um, uh, regarding the, the, the dynamic, uh, uh, uh,
852500	857260	libraries that will, that the process will load. Uh, and within those, uh, dynamic
857260	863840	libraries, uh, I wanted to mention that every library loaded, uh, within, uh, uh, uh,
863840	869380	Windows process will have, uh, will follow what is called a PE format, which is a format
869380	875060	described by Microsoft to, uh, load stuff in memory. Uh, so that, that is going to be
875060	880600	important for one of the, the, the things that we'll be discussing in a second. So, uh,
880600	884820	just to wrap up a couple of things that I just mentioned. So the process properties, uh,
884820	889340	the thread properties, and the memory properties are the things that define, you know,
889340	896700	the normal or standard behavior of a, of a process. Uh, so, okay, so why, why I am
896700	901080	mentioning this and why I put in so emphasis on, on this? It's because of the fact that
901080	907080	we will use that as a way to, uh, detect, uh, anomalies, uh, in the, in either the
907080	913020	process properties, the thread properties, or the memory properties to, to, uh, and we
913020	918920	will use that, that to, to hunt, uh, for stuff in memory. So I'm giving three examples
918920	925160	here as a bit of a spoiler. Uh, we will discuss this in, in a bit more detail in a second,
925160	930020	but, uh, the idea is that, that, for example, uh, as I mentioned, every, uh, piece of code
930020	936060	that you run in a process, uh, have to run in a thread. So you can, you, you will, you
936060	940340	will run in a normal scenario that that thread will have to run from code that is actually
940340	946020	backed by a file on disk. So usually what, what is happening is that, uh, you, you have
946020	950820	your process, you load your process, uh, and the, uh, you create threads, uh, and that
950820	956560	thread, those threads have to run from code that they will be, uh, uh, that will be part
956560	961380	of the main module, the main executable, or they will be part of, uh, DLL, uh, within
961380	967100	the, uh, that, that was loaded by the process, right? So, uh, uh, there might be scenarios, uh,
967100	972500	where the process, uh, is not running, uh, sorry, that the thread is not running from, uh,
972500	977840	code that is backed on disk. And those scenarios are mostly, uh, no, not 100 percent of the
977840	983960	cases, but are mostly caused by, uh, these, uh, by the side effects, uh, uh, on the, on the
983960	989660	artifacts left by these, uh, code injection techniques. So whenever we found a thread
989660	995100	whose start address is not, is running from memory that is not backed by disk, we might say,
995100	1000500	okay, you know, this heuristic, because we call that heuristic, the heuristic might, might,
1000500	1004140	might be telling us that there might be something suspicious on that thread that might
1004140	1009060	require further attention, and that's what the tool will actually report. So the tool will
1009060	1015540	basically, uh, flag those processes with anomalies for ThreadHunter to go and look, uh, in
1015540	1022000	detail. Uh, another, uh, potentially, uh, another, uh, anomaly that we might end up using
1022000	1028020	is the memory permissions for the base address of, uh, the threads. So, uh, the threads
1028020	1034840	are supposed to be from, uh, memory regions that are marked as, uh, read, uh, um, execute,
1034840	1039480	but there might, there are code injections that left those memory regions marked as, uh,
1039480	1044800	read, write, execute. So that goes, uh, uh, the, the, uh, that will cause, uh, one of our
1044800	1050760	heuristics to, to, to fire, basically. Then, uh, in terms of, uh, memory properties, uh, we can
1050760	1056080	also look for, uh, uh, as I mentioned, uh, memory regions, uh, with, uh, read, write, uh,
1056080	1061360	execute permissions. We can also look for all allocations, so whenever you allocate a, a
1061360	1066440	piece of, uh, uh, allocate and commit, uh, um, a piece of, um, virtual memory within the
1066440	1071360	context of a process, there will be two, uh, meta, meta data fields within that memory
1071360	1078220	regions that will indicate the, the state of, uh, those, uh, um, of, uh, of, uh, the, the, the,
1078220	1083040	sorry, the, the protections, the, yeah, the, the, the state of, uh, that memory region, I
1083040	1088200	mean, is that memory region is, uh, read, write, execute region or, or something else. Uh, so
1088200	1093780	there, there are cases, uh, that, uh, techniques, uh, initially allocates, uh, the memory
1093780	1099620	region with, uh, read, write, execute and then, uh, uh, call, uh, uh, a Win32 API called
1099620	1104760	virtual protect to move those memory regions back to read, execute so it can look, uh, legit.
1105000	1111100	Uh, but there, uh, there is a flag within those, uh, memory regions meta data that will still
1111100	1116820	contain the initial allocation, uh, uh, value. So by looking into the, uh, mismatch between
1116820	1121780	those values is, uh, is a way to, to, to determine if there have been a, a potential
1122280	1127860	injection in place. Uh, then, uh, in terms of memory content, uh, there are a couple of
1127860	1132780	things that we can do here. Uh, I mean, one thing is just go and do, you know, the regular
1133260	1139240	DOM, uh, IOC match, which is, uh, effective, but it's, but it's very costly in terms of, uh,
1139240	1144880	performance. So there, there are EDR vendors that, uh, you know, have, uh, modules that are
1144880	1150660	specialized on doing this. They are mostly running, uh, drivers, uh, that scan the memory of
1150660	1155900	the process and looking for specific patterns and, and flag, you know, uh, uh, a threat event
1155900	1161780	whenever something, uh, malicious is found. In our case, uh, we, we were not able to do that.
1161780	1167220	Again, mainly because of performance reason, Memhunter is just a user space application. So
1167220	1171920	we, uh, we cannot afford, you know, just going and scanning, uh, the memory of the entire
1171920	1176800	memory base of a, of a process. So, uh, mainly because of that, what we are doing is
1176800	1183120	something called, uh, the virtual query walk. So what basically, uh, what we're doing is that we
1183120	1188960	are walking the different memory regions of every process. And then in some cases we are
1188960	1194780	looking for, you know, just a few, uh, f-f-fierce, uh, uh, bytes within those memory regions,
1194780	1200420	uh, looking for, uh, you know, signs of, uh, uh, P file within that, that, that region. Like,
1200420	1205920	uh, looking for the MC header, uh, within the, those, those f-f-fierce, uh, few bytes. Or we
1205920	1212580	look for, uh, you know, uh, uh, associated, uh, strings, uh, left by a Tagger thread graph. Uh,
1212580	1218800	but again, uh, this is, uh, uh, optimized just to look for a specific stuff and not for
1218800	1227000	entire content of, uh, the memory region. Okay, so, uh, having said that, uh, we will jump
1227000	1234380	into, uh, two examples of, uh, both code injection, uh, and, and, uh, uh, and, and
1234380	1240620	defensivation, uh, approaches. Uh, the, these examples are actually not quite new. They have
1240620	1246360	been in the, in the field for quite some time now. Uh, the, the first one is, uh, reflective
1246360	1253100	DLL injection. So reflective, uh, DLL injection, uh, is, uh, is a technique that got, uh,
1253100	1258120	popularized, uh, a few, a couple of years back. It was, uh, created and released by a guy
1258120	1263420	from Germany called Stephen Feuer. Uh, what this technique, uh, was to, uh, I mean the, the
1263420	1270160	purpose of the, this technique was to, um, allow the, the, the, the, the, yeah, mostly the, the,
1270160	1276340	the people interested on this kind of approach to unload code, uh, uh, in the context of a
1276340	1281420	remote process just by using a DLL. So the idea is that you get the, the reflective DLL
1281420	1286960	framework, you create the DLL, you include a part of that framework within your code, uh,
1286960	1291120	compile your DLL, and then, uh, the, the result of that compilation is something that you
1291120	1297900	can embed into the, uh, the, your, your attacking process or, uh, something that you can read, read
1297900	1302100	from, from the file system in, in, if that, that is what you, you wanted to do. But the idea is
1302100	1306540	that once you get that, that, that load of, load of data into the context of, uh, the
1306540	1313440	attacking process, you will write, you will write that, uh, that up into the victim process.
1313640	1317700	Uh, actually, sorry, uh, you, you will allocate first, you know, the, uh, read, write, execute,
1317700	1322840	uh, uh, big chunk of memory in the context of, uh, remote process. Then you will write that down
1322840	1327240	into the context of, uh, remote process and then you will spawn a thread, a new thread, uh, that
1327240	1337000	will run out of, uh, that, uh, that floating read, write, execute, uh, code. Uh, one of the biggest,
1337000	1343340	uh, biggest or then most well-known, uh, consumers of, uh, these techniques was, uh, Metasploit
1343340	1349420	on, with this, uh, Meta interpreter, uh, payload. So initially they, they used this to move, uh,
1349420	1353620	their, their, their payload around, you know, processes using this technique to go in a pure
1353620	1358820	file-less way. Uh, nowadays, uh, I think that they are using it as a kind of a fallback. They,
1358820	1363220	they, I think that they start with a different technique, the Q-user APC one, and then use this
1363220	1370520	as a fallback in case the previous one fails. Um, but, uh, yeah, but, uh, yeah, but, but the
1370520	1375300	thing, uh, the important thing here is that the anomalies that this technique will introduce, uh,
1375300	1380280	within the context of the process is that, that after the technique is executed, you will run, uh,
1380440	1386140	a new thread running from, uh, floating code, right? So there will be a big, uh, a new thread
1386140	1391640	that was not there before and the base address of that thread will be, uh, uh, uh, uh, uh, code,
1391640	1397080	uh, memory region marked as read, write, execute, which, which is not, uh, backed, uh, by a
1397080	1401660	model on disk. Then if you look into the code stack of that thread, there will be a stock
1401660	1407980	frames that will, again, will be not, um, uh, backed by a symbol, uh, uh, uh, by, uh, on, uh,
1407980	1414160	one of the models on disk. And that basically means that, uh, uh, I mean for this particular
1414160	1419800	technique, that basically means that, that thread, uh, uh, was created out of, uh, shellcode
1420360	1424840	that, uh, in, in the case of, uh, this technique was used to bootstrap the, the malicious
1424840	1430260	payload that you are, you are using. So basically the techniques, uh, simplifies that, uh,
1430260	1435860	bootstrapping, uh, for you so you are putting your regular DLL code, uh, uh, and the
1435860	1440820	bootstrapping code, shellcode will take care of, uh, uh, mapping sections, resolving
1440820	1445720	import, uh, fixing up relocations, uh, yeah, couple of extra things. But the idea is that
1445720	1452740	after, after the execution, uh, happens, uh, these three anomalies, uh, can be, will, can
1452740	1457400	be seen, uh, will, I mean we will be able to see these three anomalies in the process.
1457840	1464880	Okay, so, now, uh, jumping into, uh, defense, uh, evasion example, the process following
1464880	1471640	one. So the idea here is that, uh, uh, you want to run, uh, you want to evade, uh, you
1471640	1476720	know, the, the, the, the available, uh, endpoint protection stack. So you want to evade
1476720	1482140	the, the AVs and the EDR, uh, most likely on the, on the endpoint. You want to, your, your
1482140	1489760	malicious, uh, process to look as legit for, uh, these solutions. Uh, and, uh, yeah, and you
1489760	1495160	want to use, uh, uh, uh, a legit process as a container for your malicious code. Uh, and
1495160	1503360	this technique works by, uh, by again using, uh, legal, uh, Win32 APIs. So the idea is that
1503360	1509280	you create a process in suspended state. Uh, then you get the, I mean, when, when a
1509280	1514440	process is created in suspended state, uh, the, that process will not be assigned with, uh,
1514440	1519920	any, you know, uh, time, uh, in the, uh, scaling time in the kernel. It will be just, uh, you
1519920	1526820	know, freeze, uh, will, uh, with, uh, just, uh, uh, one, uh, single thread that will be
1526820	1532240	also freeze. So nothing, uh, will, will happen. Then, uh, once you, the process is created
1532240	1538500	in suspended state, you can get the, the, the execution context of that thread. Uh, from the
1538500	1544060	execution context and by also wa- and, and by also working, you know, the memory of, uh, uh,
1544060	1549480	of, uh, that, that process. Uh, you can, uh, with those two inputs, you can determine which
1549480	1555860	is the main module of, uh, of, uh, for that thread. Uh, and then you can, uh, call this API
1555860	1561980	called NT unmap view of section, which will end up, uh, unmapping, you know, the, the main
1561980	1567020	module from, uh, from the, from the process. Uh, and then you, the, there are a couple of
1567020	1572600	things, uh, that you can do, uh, that, at that point in time. Um, um, there are more basic
1572600	1578480	ways of, uh, uh, uh, or, or writing the, the, your malicious payload into that process. In
1578480	1583860	this case, and just for simplification, uh, I, I just, uh, mentioned that, uh, uh, one of
1583860	1590040	the, uh, uh, one of the, uh, possibilities that the attacker can do, can follow, is that they
1590040	1595860	can call virtual lock. Again, allocating a big chunk of, uh, read write execute memory. They
1595860	1601000	can, they can, uh, write, uh, you know, the payload into that memory. And then they can, uh,
1601000	1609160	redirect, uh, the, the, uh, the, the execution context of, uh, the, uh, the, the thread that
1609160	1615340	is posed to this new, uh, memory region. And then they can resume, uh, the thread. So that
1615340	1621540	will force the, your, uh, uh, the, the, the malicious, uh, the host, the host process to run
1621540	1627000	your code. But at the same time as, uh, no other thing has been modified in the process, just
1627000	1633600	the, uh, the, we, we just forced the, the, the victim process to run a different, uh, uh,
1633600	1639440	module. Uh, the process will, for, for a basic system, um, for AR solutions, uh, they will,
1639440	1647020	process will look like, uh, will look as, will look as legit. So the, the P, the PB, uh, uh,
1647020	1652440	yeah, most of the, the stuff on the process will not be touched. Uh, yeah, so we will see
1652440	1658240	that, uh, in a moment too. Uh, uh, so in, in terms of anomalies and, uh, and in terms of, uh,
1658240	1664800	ways to detect this, uh, this stuff. So the, the most likely, the most, uh, uh, the, the, the
1664800	1672920	best heuristic to detect, uh, something like this will be to, uh, uh, check, uh, uh, for the, uh,
1672920	1678520	P header fields of the main module on memory versus the P header fields of the counterpart on
1678520	1686280	disk. So by, by checking that, you can detect if, uh, uh, there is a mismatch with, uh, which, uh,
1686280	1690620	should never happen. And if there is a mismatch, we can, uh, report that as something, uh,
1690620	1697160	suspicious. So, yeah. Okay, so we just talk about those two examples. We will, we will just
1697160	1702640	talk about the process properties and how we can detect stuff. We will now jump into the what
1702640	1710740	part of, uh, the talk, which is around, uh, how to perform this as, uh, uh, at scale, uh, as
1710740	1717440	part of our threat hunting process. Uh, and this is where we are introducing Memhunter. So, um,
1717440	1723660	so this is a tool, uh, that we, I probably mentioned this already, but anyways, uh, uh, this is a
1723660	1728640	tool that we, we, we started some, some time ago. And again, it was a, a, a way for us to, to
1728640	1734180	explore on these, uh, techniques and ways, and ways to, uh, ways to explore these, uh, uh,
1734180	1739340	capabilities. So, uh, so Memhunter. Memhunter is a tool that, uh, deploys itself as a
1739340	1745700	standalone binary. Uh, it will, once, uh, the tool is running, it will, uh, perform a series of
1745700	1751840	inspection heuristics, which are the anomalies thing that I was just mentioning. So, uh, and
1751840	1757300	then whenever there is a find, finding, the tool will report that to the, to the user. So the
1757300	1761160	idea is that you have all these, uh, this is the architecture of the tool. The idea is that you
1761160	1766760	have, uh, uh, all these different heuristics in, in, uh, in the, in the, abstracted in this
1766760	1772160	concept, uh, called, uh, Hunter Modules. So every hunter is specialized in one of, uh, one
1772160	1778240	specific heuristics. And then, uh, there is, uh, uh, along with the, the hunters, there is a, a
1778240	1782580	part of a company in the tool in charge of, uh, doing the, the process context enumeration.
1782580	1786260	There is a part of the tool, uh, doing, in charge of doing the, the orchestration of the
1786260	1791360	hunters. And there is a part of the tool in charge of getting the, the forensic data. Uh,
1791360	1796260	something that I didn't quite mention is the fact that the tool can run, uh, either as, uh, as,
1796260	1803600	uh, a standalone service, uh, which, uh, is mainly a way for, to, for the tool to get the, uh,
1803600	1809580	the, the, the hunters to be driven by events. So we are using ETW to determine when the
1809580	1815260	hunters will be triggered. So, for example, we are listening for, uh, uh, kernel providers, uh,
1815260	1820380	from, uh, ETW kernel providers to, to determine if there is a process, uh, if a process got
1820380	1825980	created, if a thread got created, if an image was load. So those, those kind of things will
1825980	1831480	draw, will draw, uh, you know, some hunters to run on the context of a process. So that's,
1831480	1836080	uh, the real time eventing way. And then you also have the point in time or standalone
1836080	1840600	execution, execution analysis, which is the thing that we are going to demo. So the idea
1840600	1845920	here is that you get the tool, uh, you, you get the binary of the tool, uh, uh, you run it
1845920	1851040	without being privileged and the tool will perform the process enumeration and it will, uh,
1851040	1857060	perform, uh, it will apply the heuristics over every, uh, process, uh, on the endpoint.
1857640	1864360	Uh, okay. So, uh, currently, uh, the tool support nine hunter heuristics. So we will see
1864360	1869800	that, uh, uh, in the next slide. Along with the tool, uh, I have also created as a way to
1869800	1876340	exercise, uh, uh, the different hunter heuristics. I created, uh, this tool, uh, separate
1876340	1880760	tool called M Injector, which is basically a test tool, which, uh, 15 code injection
1880760	1887280	techniques. Uh, I'm probably going to include, uh, um, I need the new injection framework
1887280	1891800	to add a couple of, uh, extra techniques. So there was a great talk yesterday on code
1891800	1898800	injection, uh, in general, uh, which, uh, uh, they, they released a framework, um, which I
1898800	1903900	cannot remember the name to be honest, sorry. But, uh, yeah, but, uh, anyways, uh, that
1903900	1908260	framework is, is great. Uh, I will, I will, uh, I will start to use it. And then the, the tool
1908260	1913680	will also, um, generate some even logs, uh, and it also support the, the, some, uh,
1913680	1918780	baseline, uh, some exclusion. Because, uh, uh, as I mentioned that the tool will not give
1918780	1925540	you data on which malware, which, uh, attacker, tradecraft is running on the endpoint. It
1925540	1930500	will just give you a hint that there is something, uh, suspicious on the endpoint. So you
1930500	1934520	have to go and, and, and find yourself, you know, what, what is going on. And that, uh, also
1934520	1939320	means that the tool might end up reporting fault positives. So for both, for, for, sorry, for
1939320	1943740	the fault positive scenario, you have to have a way to exclude some processes. Uh, the
1943740	1948580	processes that most likely are going to cause fault positives are the, the process that, uh,
1948580	1953580	use techniques, use these techniques for legit, uh, purposes. Example of that is, uh, the,
1953580	1958480	the .NET processes, the managed processes, what, which use, uh, which compile things, uh,
1958480	1964340	on the fly, uh, and have, uh, JIT compilers. There are also products, uh, uh, for, from
1964340	1969260	security vendors that use code injection as a way to hook into stuff, uh, to monitor
1969260	1973580	behavior and so on. So there might be some positives, fault positives. You have, uh, an
1973580	1977620	exclusion, a way to baseline your, your environment. Okay, talking about the, the
1977620	1983920	hunters, uh, as we have, uh, nine, uh, hunters, so we are running out of time for
1983920	1987620	demo, so I will go really quick on, on this one. So the, the first one is a suspicious
1987620	1992080	threat. It will look for the base, uh, uh, star address and it will check for read write
1992080	1997140	execution flag. Suspicious call stack will look for, uh, symbols that are not backed.
1997140	2002000	Suspicious memory regions, it will check for the first few bytes, uh, to, to look for, uh,
2002000	2008420	you know, signs of, uh, uh, uh, uh, P models, uh, that was loaded or that currently been
2008420	2012840	loaded and used. Uh, sufficient base address is something that indicates that the main
2012840	2018080	model is running from private commit, uh, markup, uh, read write execute memory regions.
2018080	2023280	Suspicious pair is, uh, the thing that I just mentioned. Uh, suspicious models, uh, models,
2023280	2027620	uh, associated with, uh, read write execute memory regions. Suspicious hollow mo- hollow
2027620	2032940	models is, uh, the, this, uh, cross check between the, the P header, uh, field from the
2032940	2038340	memory versus the counterpart on disk. Uh, register persistent is just to, to look for, uh,
2038340	2044760	stuff like, uh, this, uh, uh, functionality from Windows to force, uh, DLL to load into, uh,
2044760	2050180	into remote process. Uh, and the last one, suspicious shellcode, uh, is, uh, mainly to look
2050180	2057020	for, uh, the well-known products from 886 and 864, uh, you know, shellcodes. So, uh, there
2057020	2063300	are, uh, good amount of shellcodes that start with the same set of, uh, opcodes. Uh, and
2063300	2067780	this is something that I am develop- developing right now. So this is a, uh, you know, some
2067780	2072500	evasions that have started to appear, uh, a couple of, uh, I think it was the last year,
2072500	2076220	between last year and the, uh, the year before the last one. So ways to evade the EDR
2076220	2082700	solutions like, uh, uh, parent PID spoofing, uh, and the, uh, and, uh, common line spoofing.
2082700	2087020	So the way to do that is to, again, to cross check information from the OS with the
2087020	2092160	current things, uh, on the PID. Okay, uh, this is, uh, the, the eventing information and
2092160	2096600	this will be later available for reference. Uh, the set of information, forensic
2096600	2114570	information that the tool reports. And after that, we will jump into the demo. Okay, so
2114570	2122870	Carlos here will help me with the demo. Thank you, Carlos. Uh, okay, so the, the idea, uh,
2123350	2130370	the idea, yeah, the idea is that we will look first at the, you know, the, uh, the expected
2130370	2140070	behavior of a process. So Carlos will, will open, uh, uh, Notepad. Um, are you able to see?
2140070	2144670	Yeah, so he, he will open Notepad with, uh, Process Hacker, which is, uh, really convenient
2144670	2151350	tool to, to look for, you know, uh, the details on the property of, uh, of a process. Uh, and
2151350	2157830	within, uh, um, Notepad, he will check for the running threads of the processes, uh, of, uh,
2157830	2163450	that process. He will check for the call stack of those threads. And he will also, he, he will
2163450	2169270	also check for the memory regions currently located just to, just allow you to see that there
2169270	2175290	are no memory regions with, uh, read, write, execute, uh, permissions. And after that, uh, we
2175290	2181590	will, uh, exercise the reflective DLL injection, uh, the technique that we, that we just
2181590	2188330	mentioned. Uh, and we will come back again to the tool, to the Process Hacker tool. We will, we
2188330	2193150	will look for the anomalies and then we will run Memhunter to see the, the thing that, that, uh,
2193150	2237240	reports. Okay, just a second guys. Okay, we'll switch, uh, computers. Okay. Just a second.
2237240	2257990	Okay. So we will use, uh, Win10 RS4 machine for, for this, uh, testing. Uh, yeah. Okay. Just one
2257990	2274080	more second. Uh, there you go. Okay, so we have, uh, we have, uh, our environment over here.
2274740	2284740	Uh, we will, as I mentioned, we will run, uh, Notepad first. Uh, then, uh, we will go and, uh,
2284740	2289660	Process Hacker. We will check for the properties of Notepad. We, we see that, uh, there are a
2289660	2294880	bunch of, uh, threads running because of, uh, Windows. Uh, but, uh, the important thing is
2294880	2299660	that, that there is, uh, this thread running, uh, out of, uh, the main executable image from
2299660	2304440	Notepad. If we open that thread, we can see the call stack. Uh, and the call stack, you see
2304440	2309120	that all the, all the symbols in the call stack are mapped to a byte, uh, to a file on disk.
2309140	2316760	Right? Uh, and then if we go and check the memory, uh, we will see that there are, I mean, no
2316760	2324460	memory, uh, region with, uh, read, write, execute. There are only read, either, uh, read, read,
2324460	2331960	execute, or read, write. Uh, and there is also memory regions with, uh, copy and write, uh, um,
2331960	2338100	which are the, which is the thing that, um, uh, Microsoft use for the, his, uh, uh, copy and
2338100	2344160	write, uh, capabilities. Uh, okay, so, uh, yeah, so let's, uh, go ahead and, and execute an
2344160	2353520	attack against, uh, Notepad. So it's, Notepad is process 6020. So we will, uh, we will run
2353520	2358920	this tool. So this is an M-injector tool, uh, supports, uh, 15, uh, techniques. I'm going to,
2358920	2366720	uh, add a couple more, uh, after, uh, DEFCON. So if we run the, uh, the technique number 5,
2366720	2373100	which is, uh, reflective DLL injection, and then we ask the tool to run, uh, payload that is
2373100	2382900	part of, uh, the M-injector project called, uh, M-reflective payload. And then we target, uh,
2382900	2391620	the, the PID of Notepad, which is 60, 6020. And we run this, uh, we will get, uh, this popup
2391620	2399140	coming from Notepad that indicates there is now code that was injected and is running, uh, uh,
2399140	2406160	out of, uh, Notepad. Uh, and then if we go, uh, back to the project, uh, to the process, sorry,
2406160	2411980	uh, and check on the threats, uh, area, we will see now that there is a new threat, uh, RTL
2411980	2417940	use that I started, uh, that's supposed to start, uh, that's showing to start from RTL user
2417940	2423340	threat to start. And if we check on the code stack of that threat, we will see that there is now
2423340	2429600	two, uh, uh, symbols that are not backed by any, anything on disk. Uh, process hacker just
2429600	2435780	run, is showing the, the memory addresses of, uh, those symbols. Uh, and then, uh, the memory
2435780	2441880	area, we can check that, uh, there is, there will be a read, write, execute, uh, allocation
2441880	2449760	uh, that will contain the malicious payload, which is this private commit allocation. Uh, if
2449760	2457620	we open the allocation, we will see the P header signs in here. Okay, so now if we run MemHunter,
2457620	2462420	so let's go ahead and run MemHunter. So MemHunter, this is the output that you get from
2462420	2466960	MemHunter, so we will apply a specific heuristic to MemHunter. The one that, that we're
2466960	2472180	interested in is the, the suspicious threat. Uh, you, you don't have to apply any heuristic when
2472180	2477360	you run this. In this case we're, we're just doing it for, for the sake of, of time. Uh, and
2477360	2483780	then we will ask MemHunter to be verbose on his output. Uh, so MemHunter will run a bit, it
2483780	2488140	will, again it will enumerate the process, it will perform the beautiful query walk on all
2488140	2493820	the processes. Uh, and after that it will report that there is something suspicious on
2493820	2501920	nowpa.dxc on this specific threat ID. Uh, and these are the details of that memory region.
2502280	2516620	Uh, okay so that's uh, demo number one. Okay, uh, demo number two, uh, again is uh, uh, the, the, the
2516620	2523300	defensivation example that we just uh, mentioned. Uh, demo number two we are uh, launching,
2523300	2528920	let's uh, close this notepad instance and we will use also notepad as a, as a target, as a
2528920	2533960	hosting process for our attack. So we are running technique number seven, uh, which is
2533960	2542780	uh, process Halloween. We are uh, pointing uh, uh, M injector to use another payload, oh,
2542780	2552160	sorry, another payload uh, which is in this case is uh, uh, MSX payload. There you go. And
2552160	2564610	then the target is going to be notepad again. Yeah, there you go. So the technique just
2564610	2572210	executed, so we just hollow out the main memory of uh, notepad. So if we check on notepad, uh, the
2572210	2578110	process uh, looks uh, pretty legit. Looks as a signed process from Microsoft. Uh, it, it
2578110	2586570	contains uh, uh, some threats. The, the, the threat is con- contains a potentially valid
2586570	2593310	uh, call stack. I mean there are no issues from a simple uh, site. So we'll run uh, uh, uh, uh,
2593310	2601210	Memhunter, but this time uh, we will use uh, a different uh, uh, heuristic. Uh, heuristic
2601210	2607630	number four that will perform the uh, the cross check between the, the, the P header uh, uh,
2607630	2612170	fields from the things in memory versus something on disk on all the processes running on the,
2612170	2617370	on the end point. Uh, uh, and there will be a mismatch on notepad.exe because of uh,
2617370	2623350	process hollowing. Uh, so Memhunter will, will flag that out. Uh, okay. So that's it. Thank you
2623350	2629870	very much for, for being here, for attending our call. There are some uh, stickers of the tool
2629870	2633530	uh, on the, on the tables. Uh, yeah. Thank you very much.
