Advertisement
Guest User

Untitled

a guest
Jun 5th, 2014
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.27 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <windows.h>
  3. #include "CMutate.h"
  4.  
  5. __declspec(naked) void MutateCore( void )
  6. {
  7.     _asm _emit 0x90; //0
  8.     _asm _emit 0x90; //1
  9.     _asm _emit 0x90; //2
  10.     _asm _emit 0x90; //3
  11.     _asm _emit 0x90; //4
  12.     _asm _emit 0x90; //5
  13.     _asm _emit 0x90; //6
  14.     _asm _emit 0x90; //7
  15.     _asm _emit 0x90; //8
  16.     _asm _emit 0x90; //9
  17.     _asm _emit 0x90; //10
  18.     _asm _emit 0x90; //11
  19.     _asm _emit 0x90; //12
  20.     _asm _emit 0x90; //13
  21.     _asm _emit 0x90; //14
  22.     _asm _emit 0x90; //15
  23.     _asm _emit 0x90; //16
  24.     _asm _emit 0x90; //17
  25.     _asm _emit 0x90; //18
  26.     _asm _emit 0x90; //19
  27.     _asm _emit 0x90; //20
  28.     _asm _emit 0x90; //21
  29.     _asm _emit 0x90; //22
  30.     _asm _emit 0x90; //23
  31.     _asm _emit 0x90; //24
  32.     _asm _emit 0x90; //25
  33.     _asm _emit 0x90; //26
  34.     _asm _emit 0x90; //27
  35.     _asm _emit 0x90; //28
  36.     _asm _emit 0x90; //29
  37.     _asm _emit 0x90; //30
  38.     _asm _emit 0x90; //31
  39.     _asm _emit 0x90; //32
  40.     _asm retn;
  41. }
  42.  
  43. DWORD WINAPI lpMutate( LPVOID lpParams )
  44. {
  45.     int *iRandomSeed = (int *)lpParams;
  46.  
  47.     if( iRandomSeed == NULL )
  48.     {
  49.         iRandomSeed        = new int;
  50.         *iRandomSeed    = rand()%9999;
  51.     }
  52.     else
  53.     {
  54.         if( *iRandomSeed == 0 )
  55.         {
  56.             iRandomSeed        = new int;
  57.             *iRandomSeed    = rand()%9999;
  58.         }
  59.     }
  60.  
  61.     while( true )
  62.     {
  63.         MEMORY_BASIC_INFORMATION mbi;
  64.         VirtualQuery( MutateCore, &mbi, sizeof( mbi ) );
  65.         VirtualProtect( mbi.BaseAddress, mbi.RegionSize, PAGE_EXECUTE_READWRITE, &mbi.Protect );
  66.  
  67.         BYTE *byteArrayMutateCore = (BYTE *)MutateCore;
  68.  
  69.         for( int i = 0; i < 32; i++ )
  70.         {
  71.             srand( GetTickCount() * (i + i * i) * (*iRandomSeed));
  72.  
  73.             byteArrayMutateCore[i] = rand() % 255;
  74.         }
  75.  
  76.         VirtualProtect( mbi.BaseAddress, mbi.RegionSize, mbi.Protect, NULL );
  77.         FlushInstructionCache( GetCurrentProcess(), MutateCore, 32 );
  78.  
  79.         Sleep(10);
  80.     }
  81.  
  82.     return 0;
  83. }
  84.  
  85. void CMutate::SetRandomSeed( int iRandomSeed )
  86. {
  87.     m_iRandomSeed = iRandomSeed;
  88. }
  89.  
  90. void CMutate::InitiateMutation()
  91. {
  92.     //this will ensure its referenced as a function
  93.     MutateCore();
  94.  
  95.     CreateThread( 0, 0, lpMutate, &m_iRandomSeed, 0, 0 );
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement