start	end	text
0	16140	Welcome Vegas! Woohoo! Let's go guys! Ladies and gentlemen, LVO. Thank you guys to be here. It is
16140	26640	amazing experience to be here for my first time. And let's talk about EDR, XDR, bypassing.
26640	36720	First of all, our agenda. Uh, a little bit who I am. Uh, a little bit what is hookchain and what
36720	47560	is not hookchain is. And these research limitations. And after that, let's talk about the
47560	56620	basics to understand how does hookchain works. And after, look through rootchains. And
57360	66240	who I am. My name is Elvio Junior Aka Mabarik. Uh, my undergraduation school, uh, I did a
66240	78380	airplane pilot. So yes, I am a pilot. And I was the first in America Latina to learn OSCE3. Uh, and I
78380	86620	studied, or maybe studied too, OSCE. This research, uh, that I have here. Uh, I studied OSCE3. Uh,
86640	92820	I have no much time to study OSCE. And what I like, I like low level exploitation, buffer
92820	102520	overflow, shell coding, malware, and so on. And also, I am CEO of SecForUs, a company, a
102520	112040	Brazilian company that, uh, provide training and research and consulting and so on. What is the
112040	121400	motivation of this talk and this research? Many people believes that I, I have solution X, that I
122060	133560	talk of the Gartner, and I am a hundred percent protected. No, there is no silver bullet. And when
133560	142020	I doing, uh, pentesting or red team exercise, I just need to bypass the red team exercise.
142040	151640	Your environment. I don't need to bypass everything, just your environment. So, and full
151640	160020	undetectable. Sometimes it happens. And what is hookchain? Hookchain is a technique. It is not a
160020	168460	tool. I'm not pretending to launch a tool. Yeah, obviously, I need to do some programming. I
168460	176720	need to, to create a code to prove the concept, but it is a technique. Okay? And what is the
176720	191240	focus of hookchain? Do hook, do bypassing of monitoring of EDRs and XDRs inside of NET DLL.
191240	198440	In other words, a hundred percent user land. Nothing about kernel land. Okay? So, what is
198460	209800	hookchain? And limitation. As I said, it is, uh, 64 bits programming and limited just to
209800	222860	NT DLL. User land hooks. And I'm not pretending here to classify the EDR vendors, XDR vendors
222860	231840	as his effectivity. I'm just launching a new technique. Okay? I need to do some tests, but
232380	242740	I'm focused just in one point, not entire ecosystem. So, I'm not pretending to classify EDRs.
242740	252840	It must be clear for, for all guys. During this study, I, I did, uh, public call for vendors
253600	262720	to work together with me to get early access to this code, to this technique, and no one
262720	272380	answered. When I published it, some bypass in LinkedIn, I received some calls, not too
272380	279900	happy calls sometimes, but I received just three years, three weeks ago, some calls in
279900	288560	order to test this. Okay? And let's go to the technical things. First of all, we have
289240	298040	almost two layers in order to protect and split the time during inside of our operational
298040	308340	test. Ring zero, kernel land, and ring three, user land. To transition between user land to
308340	319380	kernel land, in a few words, we have just one way to do this. Using a gate calling system
319380	328600	call, or system dispatcher and so on, that I can transit from user mode to the kernel mode.
328600	336400	In general, we have this picture where we have user process, system services, and so on.
336400	345340	Doesn't matter what is the, his level is, it is a system level, a certain level, or a simple
345340	354600	non-privileged user process. Every time I need to do this transition. In general, this, this
354600	366380	is a responsibility to NTDLL to do this for me. So, this is a common stack call where I have
366400	372420	one common application for, that must be, that need to be, for example, need to execute
372420	379120	first a virtual lock to locate a, a memory. And the common stack call, the application will
379120	389580	call this from kernel 32 DLL and the kernel 32 will call another uh, API inside of NTDLL and
390360	400960	the NTDLL will prepare stack call parameters, register parameters, and will execute uh,
400960	410720	assembly instruction called sys call that will transit from user mode to the kernel mode.
411900	419440	This is just another image to explain that. So, I have the user mode application and the
419440	427380	important here, system service number. There's a table called system service descriptor
427380	438580	table where I have uh, indexes from zero to, I have no idea how much, more than 400, uh,
438580	449420	numbers that match each ID from a pointer to a kernel function. So, when I need to uh,
449440	457060	to transit from the user mode to kernel mode, I put the system service number inside of
457060	467120	register RAL. Sorry about the noise. But uh, I put this number in this register and I execute
467120	475120	the system call instruction. And system call will come to the kernel uh, address space and
475120	483460	this function will match inside of this table and get the pointer to the real kernel
483460	490300	function. And the real kernel function will be executed and return to the user mode space
490300	497760	with the return of the executed function. Doesn't matter uh, what this means. This is
497760	505100	another uh, uh, image to illustrate that. System service call, system service dispatcher,
505100	512520	the table with the indexes and uh, the pointers to the function and the real code from, through
512520	523220	the function. Okay? And when I execute some proxies uh, un-executed or uh, when I load uh,
523220	532760	DLL inside of another proxies, when I initiate uh, a proxies, several actions are, have been
532760	539800	done behind the scenes. One of the most important that uh, uh, to this talk is related to
539800	547180	import address table. Import address table in a few words is a table that have uh, the name of
547180	553620	the function that I want to execute. For example, uh, create proxies and the name of the
553620	562740	function and the uh, ID representing, ID representing inside of this table and the function
562760	568720	that when I run this, when I run the, the application, the operational system, the, the
568720	575400	loading of the operational system will look through uh, all loaded DLLs and fill this table
575400	582920	with the address, the real address of this function in the operational system. Virtual address,
582920	589000	of course, but the virtual address. So when I try to execute these proxies, my application
589000	596800	will comes uh, to the import address table and request, import address table, what is the
596800	604340	real virtual address to this function? And put this, for example, in a history and after that
604340	613740	call the address of this hazards, history in order to call the uh, real uh, function code.
613740	621700	And another things that image loader do is uh, look through the, the loaded DLLs if this
621700	629000	DLLs uh, uh, was already loaded, the recursive loading and so on and fill this, this function
629000	635460	pointer. There is another image to, to illustrate this, this same thing that I have the name
635460	642960	of DLLs and the functions that I imported in my application by default and the, the, the
642960	650540	name and the code of the application inside the, the uh, the target DLL. Let's start
650540	661680	talking about the techniques. Uh, when I, when I saw this, this kind of hooking, uh, we
661680	667800	need to say, we must say that the techniques that we use to attack, it's the same
667800	675340	techniques that the EDR vendors are using to protect. The first time that uh, someone
675340	685780	published uh, uh, something related with this techniques in, in Windows 95. So uh, a few,
685780	696200	few years ago. Uh, and what is hook? Like a interception of the stack call. When I try to
696200	704240	execute some function, this function uh, I, I'm not executing the real function. I, I will
704240	711960	be uh, intercepted and redirected to another function. Like a man in the middle. In this
711960	718920	case it will be a function in the middle. But it's the same concept. Okay? The, the most
718920	726180	common techniques to do that is using instruction jump or call. Or I can use uh, uh, uh,
726940	736660	import address table hooking. How can I do that? Let's see. Uh, talking about jumping.
736660	742460	This is a strategy that I, I'm uh, that we can see here. It's the most common strategy uh,
742460	752620	used by EDR and XDR vendors. That is when I run a, an application uh, NTDLL is the first
752620	762360	DLL uh, that is, is attached to my process. And after that the EDR DLL will be uh, attached
762880	774460	and the DLL from EDR will patch or change in memory uh, the instructions of the NTDLL.
774460	781600	So, when I try to execute for example this function, this function is uh, uh, changes to
781600	789720	jump to address space of EDR uh, code. In order the, the, the EDR can uh, check our
789720	799080	parameters and response and so on. This is uh, an example of original execution flow where
799080	804860	when I get the address of the, the, the, the function, the target function, we will receive
804860	811580	the real address. But if after the EDR changes or after our change in the target function,
811600	819160	that, because we will change this table, uh, after that, instead of receive the address of the
819160	828040	real function, the original function, we will receive an address to a hooked function or to a
828040	834980	uh, function in the middle in this case. Okay? So we will receive a malicious function or
834980	841580	uh, when I EDR doing that, the fu- the, the address of the EDR function. So, when I, when I
841600	848600	call this address, we will call the, receive the function. In this case, uh, arbitrary code
848600	858660	from EDR or from our perspective, and it is a decision if we will or not execute the real
858660	866380	function. In uh, talking about EDR infrastructure, the EDR will uh, analyze the parameters
866810	876060	and decide, yes, uh, LV is a good guy, I can allow this. Oh no, LV is a bad guy, let's drop
876060	886860	this. And uh, uh, pop, pop up alert and uh, send this to, to SOC and so on. Uh, this is
887020	896120	a, that I am talking, this is a, uh, when I EDR load, EDR puts an, another DLL and it will be
896120	905220	redirected and decide, yes, no, execute or no, and do if, yeah, LV is a good guy, let's uh,
905220	913580	permit this execution, so do system call in kernel land. It's everything as usual and after
913580	924400	that, come back to the user land process. Okay, I can see here an unhooked API, okay, so I can
924400	934780	see this typically uh, instructions where uh, there is a, a, a moving from R-C-X to R10 and
934780	945880	after that there is a, an ID here in hexadecimal uh, where I put this ID in uh, E-A-X or R-A-X,
945880	952760	doesn't matter. And after that there is a system call. This is a typical uh, uh, code from
952760	962480	NTDLL's uh, uh, functions that will transmit from user land to kernel land. And here we can
962480	972060	see a hooked API where he is unhooked and he is a hooked API. As you can see, there is no
972060	980660	this typical code. There is a jump code where I'm doing a, a jumping or a interception to
980660	992920	the API or to the EDR uh, code. Okay, said that the most common bypasses is remapping NTDLL
993440	1003060	but to do that we need to load the NTDLL from the disk or from the another uh, memory area.
1003080	1010640	It seems to be malicious in most of case. Uh, another technique, it's direct syscall.
1010660	1019660	When instead of goes through NTDLL, I get the system service number and do uh, and execute
1020500	1029060	the system call inside of my, my process. This sounds malicious again because the system
1029060	1037560	call was not coming back from NTDLL memory address space. It's coming from my application
1037560	1047000	address space. Okay, and EDR catch this. I direct syscall, it's uh, similar to direct
1047000	1055160	syscall but instead of uh, do uh, system call instruction inside of my application, I will
1055160	1064240	jump it to address inside of NTDLL that exists just system call instruction. So, who will
1064240	1073160	execute NTDLL? So, sounds less malicious. But in this case, the stack trace will be broken
1073940	1081500	because I'm executing directly from my code inside of NTDLL. In general, the application
1081500	1091160	doesn't do that. The application in general calls system 32 DLL, kernel base DLLs, GDI DLL
1091160	1100780	and so on. And DLL will call NTDLL and, and et cetera. So, sounds malicious. Then, there
1100780	1108720	are amazing guys uh, without this research, this talk today was not possible. So, this is
1108720	1115880	amazing guys uh, created uh, uh, Heaven Gate technique, Hell's Gate technique and the
1115880	1123900	Hell's Gate technique. So, uh, for this research, I used the part of Hell's Gate technique
1123900	1133640	in order to uh, resolve dynamically uh, the system service numbers. Okay? So, let's
1133640	1140140	understand a little bit better about Hell's Gate, this part of Hell's Gate. In general,
1140140	1147200	in Hell's Gate, locate the current address of the uh, target function that, the function that
1147200	1154440	I want to execute. For example, uh, create a virtual memory or um, create processor and
1155400	1163980	look that uh, that code that we, we saw, the, the typically code and check if the typically
1163980	1172820	code uh, match with these uh, uh, these instructions. If yes, okay, this function was not
1172820	1186300	hooked. If no, the function is hooked. Okay? So, we can uh, see that and how can I uh, get
1186300	1193960	the system service number? If, if the function is hooked, the real code uh, does not exist
1193980	1200500	more there. How, how can I see this? Let's, let, let's see uh, uh, another screen here.
1201580	1210600	We can see that the functions are linear. So, we can see here, for example, the system
1210600	1218900	service number six, system service number seven, this function is hooked. So, in general,
1218900	1223960	I have no idea what's the, the, the system service ID of this function. And the next
1223960	1231860	function will be nine and we, the next function will be ten. In other words, we can see the
1231860	1238820	neighborhood uh, functions before and after our uh, uh, uh, desired function in order to
1238820	1247900	calculate. If this function is six, that function is seven. My function will be eight. So, we
1247900	1257840	can dynamically check this. This is hollows gate technique, ok? And uh, before this, this
1257840	1269560	research, this study, uh, in a sunny day, uh, playing with my two uh, boys, my two kids, I
1269560	1277880	have an idea. Whoa! The major part of EDRs are hooking in an NTDLL. If the function is
1277900	1287160	high, step above and try to catch or try to do a, a, a function in the middle, uh, changing
1287160	1295420	the flow before NTDLL. Ok, because, because some uh, uh, several EDRs are checking if we
1295420	1304760	are changing NTDLL. So, because they are changing there, the EDR are checking if we also
1304760	1315080	change there and flag us as malicious. So, if EDR are checking there, and what if I did or
1315080	1323760	I do this in a step above? So, to check the uh, viability of this technique, I, I create a
1323760	1334060	code in order to check the EDRs hookings. So, nine percent of the EDRs are hooking just in
1334060	1347680	NTDLL. So, the technique can be viable. Ok, and I created the new technique called hook
1347680	1354700	chain. What is hook chain? Hook chain, the first step I will uh, resolve system service
1354700	1364040	number. After that, create a table where I store the system service number and uh, another
1364060	1371600	address of my custom stub function. In other words, the function that will be executed
1372800	1382960	instead of original function. EDR do this, whoa, I can do this also. And implant or change
1383400	1393060	the import address table from our proxies to our custom stub function. And after that,
1393060	1403460	continue as usual. With this, I have in more details the hook chain implant flow. First
1403460	1413840	one, uh, I resolve dynamically, map some critical functions because in this, in this phase,
1413840	1423040	uh, I have no, uh, I had no bypass at EDR yet. So, I need to use some functions, not
1423330	1432060	uh, monitor it by EDR in order to change some memory address and change some uh, memory areas
1432060	1441500	and so on. Read and etc. Uh, so I map statically these main functions that I call it here
1441500	1447620	critical functions. And after that, I create a table. We will see the structure of this
1447620	1454560	table, uh, later on. Uh, we create a table that holds system service number that I already
1454560	1463620	mapped. The function address, the real function address inside of NTDLL and uh, the, the
1463620	1474200	closest uh, address that holds a system call instruction inside of NTDLL. And after that, I
1474200	1482240	loaded, I preloaded some functions. For example, uh, if we will run uh, MetaExploit payload
1482240	1489480	or Havoc payload, uh, payload and uh, I have no idea. Uh, there are another uh, DLLs that
1489480	1497000	must be called before the execution of this payload. Because a simple uh, a simple executable
1497000	1504180	for example, has no access to the uh, URL uh, APIs or uh, critical functions. So, we
1504740	1513100	must preload this DLL in order to change the import address table of this DLL. So, here we
1513100	1522160	preloaded these DLLs and after that do the magics. Change the import address table of all
1522760	1530760	needed DLLs. In this time I, I, I need to say that that is not a good idea to change the import
1530760	1540980	address table of all loaded DLLs. I tried that and I lose my hair trying that and that's not a
1540980	1550080	good idea. Believe me, believe me. So, I, I, I created like a, a blacklist DLLs where I put
1550080	1557820	inside of the application and uh, do this preloading and after that changing that. This is
1557820	1566320	the typical flow after hookchain planting. The simplified version. So, my application must
1566320	1572800	call virtual unlock for example to create uh, uh, malicious error in order to put there a
1572800	1580760	meta exploit shellcode for example. And I need to create this. I will call kernel to 32 DLL.
1580760	1587800	Instead of call direct NT DLL, this function as I hook it, as I did the uh, the, the
1587820	1596900	function in the middle, I will, this, this flow will be redirected to my application stub
1596900	1604220	code. This application stub code will, will check several things and create a stack frame,
1604300	1609260	a stack call, create uh, uh, put the, the, the, the, uh, the information inside the
1609260	1617380	registers and after that do an indirect syscall in order to execute. And kernel mode as
1617380	1627300	usual. Here, this uh, I can present you the, the first struct that I, that I, uh, I will
1627300	1637440	use. I will use here uh, a list, okay, with this system call information and each entry of
1637440	1647340	this list uh, has a system service number, real address from the real function, okay,
1647380	1657740	uh, the, the address of the function or the address that holds the system call instruction
1658370	1667000	and the address of my stub function that will be redirected to. And uh, a hash use it to
1667000	1672940	bypass uh, static analysis instead of the name of the functions and the, and so on, okay.
1672940	1684560	And this is the entire flow where the same, my application want to execute some function will
1684560	1694100	call kernel 32 DLL and that call kernel base DLL and after that I will check in a import
1694100	1699820	address table. When I check in import address table instead of receive the original address I
1699820	1706760	will receive my stub function. So, the application will be, will redirect to my stub function
1706760	1715880	inside of this function. Uh, I can check the system call list, the list that I saw, and the
1715880	1721020	list there are several items in order to check, get the parameters that were the real
1721020	1729320	function, syscall uh, uh, address and so on. Create the stack call frame and put everything
1729820	1737760	that we, we need in the registers and after that do indirect syscall. Okay? What are the
1737760	1747500	advantages of that? How this works? Why? Uh, reduction of probability to identification
1748330	1757160	for several reasons. The first one, total time of execution. As I have several times similar
1757160	1765360	to the regular execution, the DDR cannot flag us because the total time of execution, the
1765360	1773360	telemetry of total time of execution will be okay. Will be uh, seems to be uh, valid. And
1773360	1782040	stack, stack framing. Talking about stack frame, I'm flowing, I'm uh, uh, uh, executing as
1782040	1790520	usual. Came in for a kernel 32 for example, kernel base and so on. So, I, I'm not stepping
1790520	1803120	steps. Yeah, I'm not skipping steps. Okay? And the most important, I did not or I uh, uh,
1803820	1812020	I, I didn't need to change the code of the original application. For example, if I
1814080	1824480	want to execute Mimikatz for example, I uh, uh, I don't need to touch the code. I just
1824480	1832360	execute the hookchain in order to implant and execute Mimikatz. That's it. Because the
1832360	1841560	hookchain implanted uh, uh, uh, everything that we need. The function in the middle. Let's
1841560	1850660	see the first demo where we will execute and uh, command and control using Havoc. Okay,
1850660	1864840	this is uh, flag as malicious as usual. And let's see this first one. Here we can see uh, Bit
1864840	1876600	Defender updated with uh, advanced threat protection. Full enable and in the left side we
1876600	1889500	can see our uh, console where uh, we will have, let me see, uh, let's stop here. Just uh, let
1889500	1900380	me put here together in order to, okay. Okay, no problem. Uh, first time I will implant
1900380	1911160	hookchain. After that, download remotely from HTTP the malicious payload and after that
1911840	1919480	execute this malicious payload. So, we are using Havoc to do that. And uh, let's see
1919500	1929420	and here we go. Executed our first, first command control. We can interact with that without
1929820	1943060	any identification. Thank you guys. You are amazing. It's just a starting one. Let's go.
1943060	1953850	Let's go back to the presentation. Whoa. Here it is. Looking in the browser, we can see
1953870	1964190	details. We have the first step is mapping everything that we need. So, in this operational
1964190	1972450	system we have four, four hundred seventy two NTDLL functions where we can map and these
1972450	1981310	functions are hooked or I need this as a critical function. And after that, I create this
1981310	1988090	table, okay. This is the, the, the showing of this table. And after that, I do the import
1988090	1995370	address table hooking. So, I can see here the output of this, this hookings in kernel
1995370	2005170	two thirty two, kernel base user thirty two and so on. Let's talk about the real environment.
2005170	2014030	The first of all, thank you for all friends, all Brazilian community that there are most, most
2014030	2026290	guys here. Uh, that share with me, uh, your environment license and help me and support me in
2026290	2034850	order to make this research works. Uh, without you guys, nothing will be possible. Uh, thank
2034850	2046030	you. Thank, thank you so much. Uh, because obviously some EDR vendors are not too happy and
2046030	2052530	not sharing their license or their environment in order that I test. So, uh, there are a lot
2052530	2059970	of friends, uh, sharing his environment with me in order to, to make this test, okay. So, we
2059970	2071190	did this in a closed environment. As the focus, the focus of this research is talk about, uh,
2071190	2080190	EDR protections, uh, and we will touch here else, else us. Uh, I disabled the run as
2080190	2086030	prepare and coordination guard inside of the windows because the, the, the, the target
2086030	2095090	the full focus, it is not the windows, it is not the EDR and the XDR products. So, let's
2095090	2110530	execute the second DEM for you guys. The same as again, we have the antivirals, EDR working
2110530	2122170	with advanced threat protection and we will execute, uh, as usual, Mimikatz. I downloaded
2122170	2132650	from GitHub, put on my server, as you can see, and execute this guy in a protected
2133210	2140510	environment. And let's see this working. Woo! So, uh, this is a, this is a, this is a
2140530	2153230	demo. It's not all. Execute and show a coffee, it, it's a easy part. Let's dump the creds.
2153370	2164870	Without creds, we have nothing. So, yeah, we can touch the else us without any identification
2164870	2185270	with regular Mimikatz guys. Woo! Coming to the end, uh, we are able to test with 66, uh,
2185270	2195430	percent of the products, uh, present in Gartner and in additional four other products. And
2195430	2206010	this is the result table. Okay? We tested remote process injection, Meterpreter, and
2206010	2218870	Havoc as non-privileged user, and Meterpreter loading QE model, Mimikatz, ProcDump, and
2219350	2225410	a custom, a hundred percent developed by me, a hundred percent assembled by me, uh,
2225430	2236050	assembly, else us dump. Okay? I created this in order to do this test. And this is the
2236050	2242850	result table, okay? This is the products that I, I was able to test. And as you can see,
2242850	2253470	uh, we, we have, uh, a lot of effectivity in order to, to doing this little things. Uh,
2253470	2261830	as I told you guys, uh, three weeks ago, two vendors, uh, reached me in order to, to
2261830	2270710	test, uh, again. The Sentinel one was the first and the second one was the trench. This
2270710	2280590	results that I'm showing you, uh, the Sentinel one was able to, uh, stop hookchain. They
2280590	2289950	did some patches in his product and, uh, uh, I was able to, to test this and stop it at all.
2289950	2298450	Okay? Deadline, end line. Uh, and the trench, uh, is still working on this, this, uh, uh,
2298450	2305530	identification. And they tried some behaviors but, but not at all. Okay? The other vendors,
2305530	2321030	non-contact. Okay? I love it this, uh, this phrase of Sif Hawking. I'm just, uh, a child
2321970	2330790	asking who, how and why. Occasionally I found the answer. Thank you guys. This is my
2330790	2342750	contact, full white paper, source code, reference and feel free to contact me, feel free to
2342750	2352210	reach me by, uh, LinkedIn. My LinkedIn, it's my name, just Elvio Junior and that's it.
2352210	2358410	Now it's your time, time to ask questions. Thank you.
