Broihon

Untitled

Dec 27th, 2015
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. char* swag;
  2. DWORD  MagicMemoryLocation;
  3. __declspec(naked) void ourFunct(SOCKET s, const char* buf, int len, int flags)
  4. {
  5.     __asm
  6.     {
  7.         push ebp
  8.         mov ebp, esp
  9.  
  10.         mov eax, buf
  11.         mov swag, eax
  12.  
  13.         jmp [MagicMemoryLocation]
  14.     }
  15. }
  16.  
  17.  
  18. int main()
  19. {
  20.     MagicMemoryLocation = (DWORD)send + 5;
  21.  
  22.     DWORD dwOld;
  23.     VirtualProtect(send, 5, PAGE_EXECUTE_READWRITE, &dwOld);
  24.     *reinterpret_cast<BYTE*>(send) = 0xE9;
  25.     *reinterpret_cast<DWORD*>(reinterpret_cast<DWORD>(send)+1) = reinterpret_cast<DWORD>(ourFunct)-reinterpret_cast<DWORD>(send)-5;
  26.     VirtualProtect(send, 5, dwOld, &dwOld);
  27.  
  28.     send(2, "ehueuhe", 5, 0);
  29.     std::cout << swag;
  30.     Sleep(-1);
  31. }
Add Comment
Please, Sign In to add comment