Advertisement
FlyFar

user mode application_sourcecode

Jun 5th, 2023
738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.07 KB | Cybersecurity | 0 0
  1. #include <stdio.h>
  2. #include <Windows.h>
  3.  
  4. typedef struct _INJECT_INFO
  5. {
  6.     HANDLE ProcessId;
  7.     wchar_t DllName[1024];
  8. }INJECT_INFO,*PINJECT_INFO;
  9.  
  10. int wmain(int argc,wchar_t* argv[])
  11. {
  12.     HANDLE hFile;
  13.     DWORD write;
  14.  
  15.     INJECT_INFO InjectInfo;
  16.  
  17.     if(argc<3)
  18.     {
  19.         printf("\nUsage: kinject [PID] [DLL name]\n");
  20.         return -1;
  21.     }
  22.  
  23.     hFile=CreateFile(L"\\\\.\\KeInject",GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,NULL);
  24.  
  25.     if(hFile==INVALID_HANDLE_VALUE)
  26.     {
  27.         printf("\nError: Unable to connect to the driver (%d)\n",GetLastError());
  28.         return -1;
  29.     }
  30.  
  31.     memset(&InjectInfo,0,sizeof(INJECT_INFO));
  32.  
  33.     InjectInfo.ProcessId=(HANDLE)wcstoul(argv[1],NULL,0);
  34.     wcscpy(InjectInfo.DllName,argv[2]);
  35.  
  36.     if(!WriteFile(hFile,&InjectInfo,sizeof(INJECT_INFO),&write,NULL))
  37.     {
  38.         printf("\nError: Unable to write data to the driver (%d)\n",GetLastError());
  39.          
  40.         CloseHandle(hFile);
  41.         return -1;
  42.     }
  43.  
  44.     CloseHandle(hFile);
  45.     return 0;
  46. }
Tags: kinjectuma
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement