Hey DEF CON! This is Rinzo from Sector7. I'm really glad to be here and today in this quick video I'm going to share with you some interesting technique I have learned some time ago that is about hiding your payload in the process memory. So let's jump straight into the source code. So originally I read about this technique in a paper by Frank Block and Ralf Palutke and the technique is really really simple. We create a file mapping which is backed by a page file and then we map a view to that mapping so that we can use that memory which is down here. So basically I take some fake random bytes which are pretend to be a payload and just copy them and paste them into the file. into this memory region and now if I want to hide that payload I just unmap the view. Okay and that's it basically. If we want to reuse that payload then we have to remap the view again to our process. So let's take a look at process hacker and how it works in reality. So let me start the guy. So implant and let's take process hacker to see. So we have mapped this memory region. It is here. Okay it is it doesn't contain anything. Currently after we copy the bytes the payload is here so to speak payload of course and then I do a mapping. So now if I try to reread the memory I get it is failing because this memory region is gone. Okay and actually it is it's five six eight five six eight it's here it's marked as free. So let's see what happens when if I remap this view again. As you can see the payload is still there. All right so how can we weaponize it? Let's do that. So for that I am going to use another example which is ninjasploit which was about hiding your payload against Windows Defender which is doing some memory like live process memory scans which are triggered by specific functions. For example create process. So in this example I'm going to use really simple shell code. So this payload is going to call create process which will then pop up our calc and in original technique and ninjasploit was actually hooking process create process internal function which is called by process. The hook the hooking technique I'm using here is utilizing page guards. It has its drawbacks but just for this example I'm gonna use that one. So for the purge got a page guard I'm registering my my own handler for for these these exceptions. Set up the the whole memory page to be so to speak secured by guard pay and page guard. All right and then I call go function which creates the mapping maps the view on that mapping then I decrypt my original payload the calc one copy that into this memory region. I clear the original payload from the memory and then I create a thread with my payload. So from that point the payload takes control and tries to create a new process by calling create process. Okay and if that happens the exception occurs because of the page guard and my handler will take over that will take care of that. And basically it will call my my own create process internal function which unmaps the view. So at this point the payload will be not present in so to speak in the process memory. I call the original create process internal function. Take some some time just for us to view what happens inside the process hacker and then remap the memory again so we can see it if it's there still right. And that's basically everything. So let's go to compile it and let's run it. So we have so calc popped up. That's good. So let's see we have this memory region two one three easy rows and it's not here. Okay it should be somewhere in here. Yep it's here. And let's wait for the memory region to get back. And yep it's back. And as you can see our original payload is there. Right. So that's it. Thank you for watching and enjoy the conference. Thank you for watching and enjoy the conference.