1 00:00:01,560 --> 00:00:04,980 Welcome, welcome, welcome to DEF CON. 2 00:00:05,660 --> 00:00:06,780 My name is Dr. 3 00:00:06,780 --> 00:00:07,840 Bramall Brizendine. 4 00:00:07,840 --> 00:00:12,040 I am the director of the Verona Lab, which deals with vulnerability research. 5 00:00:12,040 --> 00:00:18,000 Creator of the Shell WOS, which allows us to utilize Windows syscalls in shellcode. 6 00:00:18,000 --> 00:00:23,940 I've created the JopRocket and RopRocket, both of which deal with return oriented programming and jump oriented programming. 7 00:00:23,940 --> 00:00:30,720 And I've also created an NSA funded research project called Sherem, which allows us to analyze, uh, shellcode. 8 00:00:31,080 --> 00:00:34,240 Uh, I've spoken at many different conferences in the past. 9 00:00:34,240 --> 00:00:38,560 Um, and I'm also an assistant professor of cyber security. 10 00:00:38,740 --> 00:00:44,240 I have a PhD in cyber operations, which is a highly technical degree. 11 00:00:44,360 --> 00:00:51,760 And all of those, uh, previous projects have, um, previously been presented at DEF CON, so check them out. 12 00:00:52,180 --> 00:00:56,960 My co-speaker is, uh, Shiva Shashank Kusuma. 13 00:00:57,000 --> 00:01:03,440 He is a research assistant and, uh, he has a master's in computer science and is pursuing a master's in cyber security. 14 00:01:03,460 --> 00:01:07,040 Uh, he's looking for internship opportunities for the summer as well. 15 00:01:07,660 --> 00:01:09,580 So, our agenda. 16 00:01:09,580 --> 00:01:12,440 What are we going to focus on? 17 00:01:12,440 --> 00:01:16,960 Well, firstly, we'll talk briefly about a general approach to shellcodeless ROP. 18 00:01:16,960 --> 00:01:21,720 How do we create unique patterns to facilitate process injection? 19 00:01:21,720 --> 00:01:24,740 Some generic ROP techniques for process injection. 20 00:01:24,740 --> 00:01:34,580 And then we will look at a sample process injection technique that has a, uh, highly novel solution to a rather significant problem. 21 00:01:34,580 --> 00:01:42,480 We'll have a demo and then we'll have another brief, uh, uh, process injection and then we'll, we will conclude. 22 00:01:43,320 --> 00:01:47,180 So, some, uh, preliminary words on our experiment. 23 00:01:47,180 --> 00:02:03,360 Now this, when we, we conducted this research, we did it on a contrived binary uh, one that is intentionally vulnerable and is filled with convenient gadgets because we want our work to be applicable not just to one particular vulnerable binary but to potentially, 24 00:02:03,360 --> 00:02:04,300 uh, any binary. 25 00:02:04,300 --> 00:02:06,300 So we want to discover everything that is possible. 26 00:02:06,300 --> 00:02:13,120 And this research is really focused on, uh, ROP from the standpoint of you compromise a binary. 27 00:02:13,120 --> 00:02:19,980 It's not something where we're trying to integrate ROP and some kind of custom malware or some kind of custom red team software. 28 00:02:20,560 --> 00:02:23,900 So let's introduce the idea of shellcode with ROP. 29 00:02:23,900 --> 00:02:25,400 What does it mean exactly? 30 00:02:25,400 --> 00:02:37,780 Well, it's this idea of instead of, uh, bypassing data execution prevention depth, we are instead going to invoke the, uh, functionality of a shellcode directly via ROP gadgets. 31 00:02:37,920 --> 00:02:43,460 And it's something that has very seldom been done in the Windows ecosystem. 32 00:02:43,460 --> 00:02:49,560 When you see it, it's almost always 2, 3 APIs chained together. 33 00:02:49,620 --> 00:02:56,900 But you'll see, uh, later today that we have, uh, vastly, uh, more APIs to achieve what we want to do. 34 00:02:57,300 --> 00:03:00,280 Some also, uh, some previous work on shellcode with ROP. 35 00:03:00,280 --> 00:03:04,860 There's a video link in the slides so I do encourage you to, uh , check it out if you're interested. 36 00:03:06,180 --> 00:03:12,300 So in terms of approaching shellcode with ROP, there are a couple approaches we could take. 37 00:03:12,300 --> 00:03:21,020 One is utilizing push add where we're going to populate values on, uh, certain registers, uh, with certain predefined values. 38 00:03:21,400 --> 00:03:27,160 Um, and then that causes them to be loaded onto the stack in a, a certain predefined order. 39 00:03:27,160 --> 00:03:40,280 And we'll also use move dereference or the sniper technique and this allows us to precisely write our values to the stack and we can then increment or decrement to the next, uh, slot that we want to provide values for. 40 00:03:40,280 --> 00:03:44,280 So those are both critically, uh, important for us. 41 00:03:44,560 --> 00:03:55,500 And I want to re-emphasize the importance of this idea of finding patterns because again, we're not really just approaching one process injection technique, but we want our work to be applicable broadly to many different techniques. 42 00:03:55,500 --> 00:03:59,380 How do we do this in terms of return oriented programming? 43 00:03:59,500 --> 00:04:07,100 So we really want to emphasize that, you know, we have these particular slots, uh, where we have, uh, registers going in a certain order. 44 00:04:07,100 --> 00:04:21,020 Uh, so we really, uh, weaponize this in terms of developing new patterns for different APIs, uh, both Windows APIs as well as native APIs to allow us to invoke those easily using return oriented programming. 45 00:04:22,000 --> 00:04:28,140 So, uh, and when using many different APIs, we want to be able to chain them together. 46 00:04:28,340 --> 00:04:34,460 Lar- kind of like the sense where you have a, uh, a ROP chain, you have different, uh, ROP gadgets chained together, we'll be chaining different APIs together. 47 00:04:34,460 --> 00:04:42,840 So you may get one, uh, return value, uh, in this case, uh, open process runtime address is provided to us in EAX. 48 00:04:42,840 --> 00:04:50,320 We can use that subsequently in a pattern for open process because, of course, we need to call open process. 49 00:04:51,400 --> 00:04:56,960 So a large part of our research is really focused on generating a lot of these different types of patterns. 50 00:04:56,960 --> 00:05:04,020 And actually we've de- developed more than 150 unique patterns to provide a lot of opportunities. 51 00:05:04,160 --> 00:05:08,200 Um, we'll talk more in depth about some of them and we'll give some examples. 52 00:05:08,200 --> 00:05:17,400 But historically, uh, some of the tools that have done this have been things like, uh, Mona, Mona, you know, Virtual Alloc, Virtual Protect, and you have a couple patterns. 53 00:05:17,400 --> 00:05:19,460 So it's not a significant number of patterns. 54 00:05:19,820 --> 00:05:28,280 So let's talk now briefly about some generic ROP techniques that we can use to help us with, uh, process injection. 55 00:05:29,240 --> 00:05:37,180 So one is the idea of using function output, using that function output as a way to, um, to be a parameter. 56 00:05:37,180 --> 00:05:43,700 So Gitproc address and little library often go hand in hand and they're very familiar and well known. 57 00:05:44,000 --> 00:05:54,580 Uh, so with a little library, we can get a handle to a module, which is the, the base address of a certain DLL, and that's required for Gitproc address. 58 00:05:54,600 --> 00:06:04,260 So we take the output from the one, which is going to be returned to us in EAX, and then we use that subsequently in, uh, Gitproc address. 59 00:06:04,260 --> 00:06:10,880 And we'll do this time and time again, so return values as well as other out parameters if you're dealing with native APIs. 60 00:06:12,100 --> 00:06:16,140 And then this gets a little bit more complex, so structures is parameters. 61 00:06:16,140 --> 00:06:18,820 Can we do that with return oriented programming? 62 00:06:18,940 --> 00:06:19,980 Yeah, we actually can. 63 00:06:19,980 --> 00:06:27,960 So with a structure, we need to look clearly at the, the definition of the structure, and then we need to build that byte by byte through return oriented programming. 64 00:06:27,960 --> 00:06:37,440 And we'll typically do that with a series of move dereferences, and we can just increment and decrement to the, to the next slot as we slowly build our, uh, structure. 65 00:06:37,640 --> 00:06:42,740 And in some cases we may actually have nested structures, so take a look at adjust token privileges. 66 00:06:42,740 --> 00:06:51,400 We have several nested structures , and it needs to be done exactly correctly, or else it simply will just not work. 67 00:06:51,660 --> 00:07:07,340 Um, one thing that is also, uh, immensely important is this idea of storing important values, um, addresses, handles, things which may be obtained by calling a Windows API. 68 00:07:07,340 --> 00:07:11,680 If we call a Windows API to obtain one of these values, well that takes a lot of effort. 69 00:07:11,700 --> 00:07:21,960 And if we needed it again, well of course we don't want to call it a second time, so we will make an effort to save that value somewhere in memory, and then we can retrieve it later. 70 00:07:21,960 --> 00:07:30,740 So we might have a common reference point, we move ESP to a location, maybe we advance forward 500 bytes, and we just start writing different values there. 71 00:07:30,740 --> 00:07:38,940 And that common, uh, reference point can, will change from gadget to gadget, but we can manually calculate that and make adjustments, uh, as need be. 72 00:07:38,940 --> 00:07:46,460 So, again, you'll have lots of important values and you can save them and then retrieve them subsequently, uh, later on. 73 00:07:47,160 --> 00:07:54,660 So another thing we did is, and this is actually, uh, completely novel, combining move dereference and push add in terms of building a pattern. 74 00:07:54,660 --> 00:07:58,960 So, we can use that to create a, a, a ROP chain pattern. 75 00:07:59,180 --> 00:08:06,960 Uh, push add, you can have a maximum of 4 parameters, 5 if you use ESP, but that can be rather, uh, challenging to do. 76 00:08:07,440 --> 00:08:11,960 Um, so we can do push add and then do the remainder, we can supply those via move dereference. 77 00:08:13,000 --> 00:08:21,920 Now, if you have the option to, uh, place your strings and data in the payload directly, then by all means do it, because it's going to save you effort. 78 00:08:22,060 --> 00:08:28,940 Again, if you have a common reference point, you can use these, you have a pointer to a string and you might be saying, well, what about EDR? 79 00:08:28,940 --> 00:08:32,780 Well, yes, EDR will be an issue at times and so this may not always be plausible. 80 00:08:32,960 --> 00:08:41,480 If you have no payload size restrictions, one option is to obfuscate some of this and then you could use a ROP to go and de-obfuscate it as need be. 81 00:08:42,700 --> 00:08:46,160 So, let's get into an actual, uh, process injection technique. 82 00:08:46,160 --> 00:08:50,920 Now this is based on something that I actually did at Hack in the Box Amsterdam 2023. 83 00:08:51,060 --> 00:08:53,820 That was all Windows sys calls and shell code. 84 00:08:53,820 --> 00:08:56,860 This obviously is not, it's return oriented programming. 85 00:08:56,860 --> 00:09:03,340 And so these are more, uh, these are Windows APIs and native APIs, it's not necessarily strikingly original. 86 00:09:03,480 --> 00:09:15,700 Um, but in any case, we have a new URL, we're going to create that, it's going to slither up inside of our victim target and external process and then we're going to write our shell code there and then cause it to launch. 87 00:09:16,240 --> 00:09:22,380 So, in terms of ROP, the actual complete chain of gadgets that we have, 29 gadgets. 88 00:09:22,380 --> 00:09:24,220 It's an extraordinary amount. 89 00:09:24,500 --> 00:09:32,440 Uh, I'm not familiar with any, uh, ROP chain in, in the Windows ecosystem that has anywhere near this level of gadgets. 90 00:09:32,440 --> 00:09:38,360 And so it's a lot of work to, to maintain these from, um, from API, API call to API call. 91 00:09:38,360 --> 00:09:44,900 And it would be a lot more actually if we did not use that technique of storing and retrieving certain values that we need. 92 00:09:45,760 --> 00:09:47,400 So, let's talk about load library. 93 00:09:47,400 --> 00:09:50,340 We can use that with, uh, push add in a pattern. 94 00:09:50,340 --> 00:09:55,440 So we load the particular values into, uh, registers and then we go and do push add. 95 00:09:55,440 --> 00:09:59,420 Then that causes it to go in a predefined, uh, location. 96 00:10:00,000 --> 00:10:01,900 And so let's see what happens exactly. 97 00:10:01,900 --> 00:10:06,280 So we, we have our stack values there and those correspond to our pattern. 98 00:10:06,280 --> 00:10:09,200 So we have red 8, that means we're going to do this ROP NOP. 99 00:10:09,200 --> 00:10:13,300 We're going to skip 8 bytes, so we skip that, we do a jump EDP dereference. 100 00:10:13,420 --> 00:10:19,320 We therefore invoke load library, we have a return address, we have a parameter, everything checks out. 101 00:10:19,580 --> 00:10:21,080 And then we get a result. 102 00:10:21,580 --> 00:10:23,120 Exact result that we want. 103 00:10:23,120 --> 00:10:26,280 So we get the base address of NTDLL. 104 00:10:27,520 --> 00:10:31,600 And then we can use that subsequently for git proc address, which, which is our next one. 105 00:10:31,600 --> 00:10:36,840 And we'll do the same thing, we'll populate different values into the registers that we can then call push add. 106 00:10:37,420 --> 00:10:43,220 And we get the runtime address, in this case we're doing create tool help 32 snapshot. 107 00:10:43,320 --> 00:10:46,580 An extremely important thing that we'll talk about momentarily. 108 00:10:46,980 --> 00:10:50,340 So these are the patterns for load library, we have a lot of them, 9. 109 00:10:50,740 --> 00:10:52,820 And git proc address, we have 11. 110 00:10:53,380 --> 00:10:59,580 So that gives us a lot of flexibilities because if you're trying to do something, you don't have a particular gadget, well you just give up. 111 00:10:59,700 --> 00:11:01,560 If you do then the chain is incomplete. 112 00:11:01,760 --> 00:11:07,860 But having multiple patterns, we can drill down deeper and maybe find something that actually works. 113 00:11:08,060 --> 00:11:16,060 In any case, our next API is create tool help 32 snapshot, which will allow us to take a snapshot of all the active processes that are out there. 114 00:11:16,280 --> 00:11:22,440 And it's immensely important, we need it to discover uh the different PIDs, we're gonna target one of those. 115 00:11:24,000 --> 00:11:29,820 So there are actually 11 patterns, so a lot of flexibility there in terms of how you can invoke it with the push add instruction. 116 00:11:31,140 --> 00:11:34,280 Um there's an example of the ROP and we got the push add at the bottom. 117 00:11:34,660 --> 00:11:40,340 Virtual alloc, um it's one way to allocate memory, yes some EDR can block it, there are other ways you could do it. 118 00:11:40,460 --> 00:11:46,540 Uh the pattern for that is very uh familiar, uh one of the most familiar goes back probably about 15 years. 119 00:11:47,100 --> 00:11:54,100 Um but with this we're gonna allocate a region of memory, we're gonna use that for a couple very uh important uh things. 120 00:11:54,620 --> 00:12:04,500 One of which is to build the process entry 32, the process entry 32 is where we're going to go in and check our PID, we're gonna check our uh string. 121 00:12:06,120 --> 00:12:13,520 So the first thing is we process 32 first, it's gonna kick everything off, it's gonna initiate the whole uh process. 122 00:12:15,180 --> 00:12:22,300 So how we're gonna do that, uh first we actually need to build the structure, so we can go ahead and build the structure via ROP and our move dereferences. 123 00:12:22,300 --> 00:12:29,280 Most of it are null bytes so it's relatively simple, we have a DW size, uh it's an arbitrary value so you can make it whatever you want. 124 00:12:29,360 --> 00:12:34,040 And then once we're done we get a pointer to that, we supply that pointer as the parameter. 125 00:12:34,340 --> 00:12:37,800 So all of that work and we just get a pointer to that. 126 00:12:37,860 --> 00:12:44,400 So again the idea of being able to uh dynamically locate something in memory and use that is kind of like a pointer, can be very useful. 127 00:12:45,180 --> 00:12:50,440 And then the patterns for process 32 first and process 32 next are actually interchangeable. 128 00:12:51,560 --> 00:12:55,600 So one of the biggest challenges is this idea of string comparison, how do we do that with ROP? 129 00:12:55,600 --> 00:13:01,200 Well the gadgets are not really very common so that can be very uh problematic. 130 00:13:01,200 --> 00:13:06,640 We need to identify a specific process otherwise you really can't proceed forward. 131 00:13:06,640 --> 00:13:11,340 So you're kind of at a, an uh, you can't really go forward without this. 132 00:13:11,340 --> 00:13:15,240 So we came up with a solution , we're going to build our own custom function in memory . 133 00:13:15,240 --> 00:13:20,040 It's an enumerate process function and we're actually writing the raw assembly. 134 00:13:20,160 --> 00:13:25,060 So remember we made a writable memory with virtual alloc, we can write our code there. 135 00:13:25,060 --> 00:13:26,840 You can do it other ways as well. 136 00:13:26,940 --> 00:13:35,280 And so this will cycle through process 32 next, it can do it hundreds of times in a loop until it finds the exact uh string, VU player. 137 00:13:35,280 --> 00:13:39,460 We can supply that and then once it does that it'll go ahead and exit out. 138 00:13:39,480 --> 00:13:40,620 So how do we write that? 139 00:13:40,620 --> 00:13:48,540 Well we simply just compile it, we can then write our bytes to memory using the move dereference technique one by one until they're all written. 140 00:13:48,560 --> 00:13:52,120 Make sure the code is executable and there are multiple ways in which you can do that. 141 00:13:52,120 --> 00:14:00,820 And then we need to supply the appropriate values so things like our HP snapshot, our VU player string, uh dereference process 32 address. 142 00:14:01,240 --> 00:14:03,040 And then how do we kick it off? 143 00:14:03,040 --> 00:14:15,040 Uh again multiple ways but in this case we're gonna do a simple push ret which will then push the address onto the stack and then return to that and then we can uh immediately start executing our custom code that we just wrote there. 144 00:14:15,920 --> 00:14:21,260 And so that'll invoke process 32 uh repeatedly until it finds our particular PID. 145 00:14:21,260 --> 00:14:22,960 In this case we have VU player. 146 00:14:24,360 --> 00:14:30,260 It's gonna look at offset 24 and once it finds offset 24 then again it's gonna break out of that loop. 147 00:14:30,600 --> 00:14:35,580 And um from there the base of the structure we can just go to simply offset 8. 148 00:14:35,580 --> 00:14:37,860 Offset 8 will then hold the PID. 149 00:14:37,860 --> 00:14:40,060 We can capture that PID. 150 00:14:40,440 --> 00:14:42,300 In this case it's 668. 151 00:14:42,780 --> 00:14:45,400 And how do we do that via return oriented programming? 152 00:14:45,400 --> 00:14:48,980 Well we just basically take exactly what I said, translate it to ROP. 153 00:14:48,980 --> 00:14:54,320 So some move dereferences, some POPs, uh sequence of 8 uh increments. 154 00:14:54,460 --> 00:15:00,080 And uh in this case we have a different PID B98 and uh we can supply that. 155 00:15:00,080 --> 00:15:03,560 Uh we can save that to memory so we can use that later. 156 00:15:03,560 --> 00:15:05,780 Remember the idea of save and then retrieve. 157 00:15:06,660 --> 00:15:11,820 And then that brings us to our next API and with that we're gonna have Shiva uh take the podium. 158 00:15:16,200 --> 00:15:23,920 Here we take this PID that we just obtained after all of that hard work and uh we are going to convert that into the handle to the process. 159 00:15:24,060 --> 00:15:25,180 We're gonna have this. 160 00:15:25,180 --> 00:15:29,420 It's impossible to move forward if you don't have a PID to your target process. 161 00:15:30,060 --> 00:15:34,120 And we don't want to just randomly inject into some other unknown process. 162 00:15:34,120 --> 00:15:38,560 Uh so this one we are going to use both push add as well as move dereference technique. 163 00:15:39,400 --> 00:15:45,980 So here we have multiple patterns for open process and then we'll follow that up after push add. 164 00:15:45,980 --> 00:15:49,860 And we also have a move dereference with the process ID. 165 00:15:50,680 --> 00:15:58,300 In this ROP chain the process ID has been provided by move dereference uh with everything else being done via push add. 166 00:15:59,340 --> 00:16:04,240 Next we'll open a handle to our current process with open process token. 167 00:16:04,860 --> 00:16:13,300 And then we'll use that so right here we have a handle and we are using ROP to create a pointer to hold the access token that we'll retrieve. 168 00:16:14,700 --> 00:16:21,960 With adjust token privileges uh we are going to take that token handle and we can then change the privileges as we need. 169 00:16:21,960 --> 00:16:25,540 We need to do this to avoid some problems that could happen otherwise. 170 00:16:26,920 --> 00:16:31,520 And this requires multiple complex structures such as token privileges. 171 00:16:31,520 --> 00:16:37,040 Such as uh where we can specify the AC privilege enabled and AC debug privilege. 172 00:16:38,520 --> 00:16:42,300 With adjust token privileges uh here we have a ROP. 173 00:16:42,300 --> 00:16:45,080 So we are setting disable all privileges to false. 174 00:16:45,180 --> 00:16:50,900 And what that means is that whatever we specify inside the new state structure will be then done. 175 00:16:52,000 --> 00:16:58,820 With adjust token privileges we can then go inspect where the debugger and see if it has all of our values. 176 00:16:58,820 --> 00:17:02,180 Like AC privilege enabled and AC debug privilege. 177 00:17:02,640 --> 00:17:05,440 And then everything is going according to the plan. 178 00:17:06,400 --> 00:17:13,640 Our goal with this is to take a common DLL URL mon, create a file for it and then go ahead and map that out. 179 00:17:13,640 --> 00:17:16,340 And then we can inject our payload into that. 180 00:17:16,340 --> 00:17:18,280 Then causing that to be executed. 181 00:17:18,740 --> 00:17:22,260 And we'll do this with these APIs which we'll be talking about. 182 00:17:22,880 --> 00:17:25,380 So create file A is the first. 183 00:17:25,380 --> 00:17:28,480 We get a handle to the URL mon which is our file. 184 00:17:28,480 --> 00:17:30,760 We are going to be using this later on. 185 00:17:30,760 --> 00:17:34,220 Uh but we are going to do this with sequence of moody references. 186 00:17:35,500 --> 00:17:41,280 And here we are providing the absolute address, the string pointer to that and also generic read. 187 00:17:41,280 --> 00:17:45,900 We are doing generic read to avoid some possible detections. 188 00:17:46,660 --> 00:17:55,180 And then NT create section, a lower level native API will allow us to then create a section object for URL mon DLL. 189 00:17:55,180 --> 00:17:57,460 And here we are doing page read only. 190 00:17:58,640 --> 00:18:01,760 And then with drop we are specifying the sec image. 191 00:18:02,840 --> 00:18:04,740 NT map your section. 192 00:18:04,920 --> 00:18:11,900 Now that we have the URL mon section handle, we can now map that view of the section into address space of view player. 193 00:18:11,900 --> 00:18:18,940 We'll do this purely through moody references because uh we have many nulls and also we have page read only. 194 00:18:18,940 --> 00:18:20,720 So it's a bit more limited. 195 00:18:21,740 --> 00:18:26,220 One more important thing is providing the base address or pointer to the base address. 196 00:18:26,220 --> 00:18:30,360 And that will receive a base address inside of view player. 197 00:18:30,700 --> 00:18:37,380 So that will be provided to us as you can see in this example which we'll be talking about later. 198 00:18:37,380 --> 00:18:38,780 So it is very important. 199 00:18:40,740 --> 00:18:47,140 Virtual protect EX will then allow us to change the target DLL URL mon to RWX. 200 00:18:47,300 --> 00:18:50,480 And so we are going to do this with sequence of moody references. 201 00:18:50,560 --> 00:18:53,720 Because remember we have limited permissions for it. 202 00:18:54,960 --> 00:18:59,860 And so we'll get the handle to the view player as well as the base address that we just retrieved. 203 00:18:59,940 --> 00:19:03,420 And then once it's done we'll have the page execute read right. 204 00:19:04,940 --> 00:19:08,080 Here is a route where we can provide the pointer to the base address. 205 00:19:08,080 --> 00:19:11,840 We then go and dereference that and we'll pull the base address out of that. 206 00:19:12,040 --> 00:19:14,280 And then we do the moody reference. 207 00:19:15,380 --> 00:19:20,840 Right process memory allows us to inject the cell code into the process memory of view player. 208 00:19:21,180 --> 00:19:24,400 We are doing this via push add as well as moody references. 209 00:19:25,280 --> 00:19:28,660 Which you can see right here so pointing to the cell code up there. 210 00:19:28,800 --> 00:19:31,220 And also providing the size. 211 00:19:32,080 --> 00:19:37,220 Same thing here we are, we have the cell code and the size and then the remaining parameters with push add. 212 00:19:38,100 --> 00:19:46,680 Right process memory at this point once it's done then our cell code will be injected into inside of urlmon which is an external process. 213 00:19:46,980 --> 00:19:50,200 So we have gone from one process to a completely different process. 214 00:19:50,240 --> 00:19:53,100 And the cell code is just sitting there waiting for us. 215 00:19:54,320 --> 00:19:56,100 So how do we cause it to execute? 216 00:19:56,100 --> 00:19:57,300 The answer is very simple. 217 00:19:57,300 --> 00:19:58,740 It's create remote thread. 218 00:19:58,740 --> 00:20:00,960 But the actual technique is not so simple. 219 00:20:01,180 --> 00:20:04,520 So we'll have a moody reference and also push add pattern. 220 00:20:04,700 --> 00:20:07,300 And then we'll have a sequence of moody references. 221 00:20:08,620 --> 00:20:14,280 We'll go inside the other space of view player and then we do the push add. 222 00:20:16,020 --> 00:20:17,820 So here is some of our ROP. 223 00:20:17,820 --> 00:20:21,080 We can provide the LP parameter as well as the address. 224 00:20:21,180 --> 00:20:23,360 And then we follow that up after push add. 225 00:20:23,420 --> 00:20:28,040 And finally with create remote thread our injected cell code will execute. 226 00:20:28,100 --> 00:20:29,600 We have achieved our goal. 227 00:20:30,240 --> 00:20:31,700 Let's do a demo. 228 00:20:33,780 --> 00:20:38,140 We start the things with create help 32 snapshot and we have been given a handle. 229 00:20:38,840 --> 00:20:42,640 Let's write the process function to memory byte by byte. 230 00:20:43,160 --> 00:20:45,540 We invoke the function using push thread. 231 00:20:46,320 --> 00:20:50,000 Now we are inside the function, special function that we created. 232 00:20:50,760 --> 00:20:52,540 And let's take the process entry. 233 00:20:53,320 --> 00:20:55,460 Let's see what we have as the first entry. 234 00:20:55,460 --> 00:20:56,560 We have system. 235 00:20:56,560 --> 00:21:00,020 Let's move forward until we find our desired PID. 236 00:21:00,020 --> 00:21:04,020 And we finally found the PID for view player. 237 00:21:04,020 --> 00:21:04,920 That's good. 238 00:21:05,560 --> 00:21:07,040 We'll keep moving forward. 239 00:21:07,760 --> 00:21:09,580 And we'll do the create file A. 240 00:21:10,520 --> 00:21:12,420 We'll get a handle from create file A. 241 00:21:12,420 --> 00:21:14,020 Let's verify what we have. 242 00:21:14,500 --> 00:21:15,560 We have the URL month. 243 00:21:15,560 --> 00:21:16,380 That's good. 244 00:21:16,680 --> 00:21:20,380 Let's map that out using NT map section and let's set the base address. 245 00:21:20,380 --> 00:21:22,240 Right now we don't have any base address . 246 00:21:22,620 --> 00:21:27,960 But right after the function execution we'll get the base address and base address has been provided. 247 00:21:31,240 --> 00:21:33,400 We'll change the permissions for the base address. 248 00:21:33,740 --> 00:21:34,980 And we'll see. 249 00:21:35,620 --> 00:21:38,660 We have the page execute read write permissions. 250 00:21:41,710 --> 00:21:42,970 We have the MZ. 251 00:21:42,970 --> 00:21:46,590 It's a PE file and let's inject the shellcode using write process memory. 252 00:21:48,530 --> 00:21:50,450 And let's see what we have. 253 00:21:50,450 --> 00:21:53,690 We have successfully injected the shellcode into external process. 254 00:21:55,010 --> 00:21:57,690 And finally create remote thread. 255 00:21:58,470 --> 00:21:59,690 We got it. 256 00:22:04,650 --> 00:22:06,450 Thank you Shiva. 257 00:22:06,450 --> 00:22:08,910 So we're going to wrap things up very briefly here. 258 00:22:08,910 --> 00:22:17,010 So I just want to say our goal is not to enumerate all process injection techniques. 259 00:22:17,010 --> 00:22:18,950 We've seen talks like that before. 260 00:22:18,990 --> 00:22:24,170 But we really want to provide a methodology in terms of how we can do that with ROP and focus on the practicalities. 261 00:22:24,170 --> 00:22:33,810 We want to provide a novel concept of building a enumerate processes function purely via ROP which can be extendable to other process injection techniques. 262 00:22:33,810 --> 00:22:37,730 And then create a rich set of patterns that we can utilize for that purpose. 263 00:22:38,010 --> 00:22:41,850 With that we'd like to thank you and invite you to check out the ROP rocket tool.