lainconnors

Untitled

Aug 26th, 2020
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.07 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <Windows.h>
  3.  
  4. typedef INT64 (__cdecl* fnde)(LPCSTR url, LPCSTR path, int noExec);
  5.  
  6. int main(int argc, char** argv) {
  7.     //Load relevant library
  8.     HINSTANCE LibInseng = LoadLibrary(L"C:\\WINDOWS\\system32\\inseng.dll");
  9.     //DEBUG
  10.     //printf("%p", LibInseng);
  11.  
  12.     //Declare our function
  13.     LPVOID fn = (LPVOID)GetProcAddress(LibInseng, "DownloadFile");
  14.     const char* url = "https://www.google.com";
  15.     const char* path = "robots.txt_downloaded.txt";
  16.     INT64 result = 0;
  17.  
  18.  
  19.     //And we store the ESP value for future reference. No RSP beause inseng.dll is 32bit anyway. Just keep it optimized.
  20.     int espValue;
  21.     __asm mov espValue, esp;
  22.     printf("ESP: 0x%x\n", espValue);
  23.  
  24.     //Some inline ASM...
  25.     __asm {
  26.         push esp;
  27.         push 1;
  28.         push path;
  29.         push url;
  30.         call fn;
  31.         push 0;
  32.     }
  33.  
  34.     //And the new (old) ESP value to make sure function executed successfully...
  35.     __asm mov espValue, esp;
  36.     printf("ESP: 0x%x\n", espValue);
  37.     system("PAUSE");
  38.        
  39.     return 0;
  40.  
  41. }
Add Comment
Please, Sign In to add comment