Congratulations!! i have read it and it’s very good tutorial 😉 good luck for your next tutorials ( if you are planning to make so)Peter! Regards! Jacky
Another way to solve the egghunter running fragments of shellcode instead of whole shellcode is to extend/change the huntercode slightly. Write your shellcode like this: “w00t” + shellcode + “w00t” Then add a bit of logic after the first 2 JNZ lines that tries to compare the ‘w00t’ tag at the end of the shellcode too (based on your knowledge of the exact size of shellcode in bytes). Truncated or damaged shellcodes would likely not contain this but complete ones in the heap should. Now this will make your egghunter code about twice as long but still FAR shorter than most shellcodes. I got mine down to 48 bytes. –Nate_M
Hi corelanc0d3r! I’m still studying your tutorials to prepare for the OSCE exam (tomorrow!). They are amazing! Thanks again! Reading the “Tweaking the egg hunter start position” section I realized that when you say “Replacing FF0F with 00 00 will allow you to search the current stack frame if that is required” it should be an AND operation, instead of a OR, as the OR with 00 00 would take no effect! In this case, the instruction must be “66:83E2 00 AND DX,0”. Also, few lines below, you talk about some strategies to avoid the null byte when changing the first address that the egghunter will search. In your examples you’ve used EDX as the counter but when you explain the solutions you say to update EDI value. I tested the strategy of writing another register’s value to EDX (EDI in the case of Eureka Email) and then subtracting its value until it gets the value of the last address in previous page and it works like a charm! Thanks again for all the good stuff made by the corelan team! (mona is also amazing!)
“If the shellcode could only be found on the current stack frame (which would be rare – but hey, can happen), then it may not be possible to find the shellcode using this egg hunter” dont forget for overflow EDX if it stay 0xFFFFFFFF, inc EDX make it 00000000 and hunting continues again from 00000000 to FFFFFFFF NB! if egghunter not founds eggs – it stay at infinity loop
“Replacing FF0F with 00 00 will allow you to search the current stack frame if that is required…” “or bx, 0x0fff/inc ebx” used for passing “access violation” pages basically (becouse min page granularity is 1000h) if u replace it another NUM, if hunter check page after bad, non-existent page and page is correct – it begin scan not at start of page, but NUM
I got stuck trying to figure out the code that zeroes-out EAX : e.g. AND EAX,554E4D4A (“\x25\x4A\x4D\x4E\x55”) AND EAX,2A313235 (“\x25\x35\x32\x31\x2A”) —— In the end I came up with this 😛 “%ZERO”. #zeroing-out eax “%!0!0” #the memorable way
Corndawg wrote: “Another way to solve the egghunter running fragments of shellcode instead of whole shellcode is to extend/change the huntercode slightly. Write your shellcode like this: “w00t” + shellcode + “w00t”… I’d like to experiment on that idea, but first, let me ask you this: Based on your experience, would it be possible for an egg to be found spoiled in the yolk :-). I mean, sth like this: w00t+shellcode-shellcode-she-@#$%-carbage-!@#$!@#-ode-shellcode+w00t. Starts OK, gets -somehow- corrupted in the middle, but the final bytes (rearguard-w00t included) remain intact. Cause in that case, using the ‘w00t’ tag at the end of the shellcode as confirmation, would be, of course, misleading.
might want to check out one of our later posts – the solution for this is to use a checksum routine We added the checksum routine to the metasploit egghunter(s) and you can use mona.py as well to create an egghunter that contains the routine