#include <stdio.h>
#include <windows.h>
#include <winioctl.h>
#include <stdlib.h>
#include <string.h>
#define SIOCTL_TYPE 40000
#define IOCTL_LOL\
CTL_CODE( SIOCTL_TYPE, 0x800, METHOD_BUFFERED, FILE_READ_DATA|FILE_WRITE_DATA)
#define IOCTL_HIDE_PROCESS\
CTL_CODE( SIOCTL_TYPE, 0x801, METHOD_BUFFERED, FILE_READ_DATA|FILE_WRITE_DATA)
#define USAGE "./%s <mode> <nameProcess>\n<mode> : 1 -> IOCTL_LOL\n 2 -> IOCTL_HIDE_PROCESS\n\n<nameProcess> : Nom process si mode 2.\n"
int __cdecl main(int argc, char* argv[])
{
HANDLE hDevice;
DWORD NombreByte;
char *welcome = "Kikoo de l'userland." , out[50];
int choix;
ZeroMemory(out,sizeof(out));
printf("First steps in ring0 par 0vercl0k\n\n");
if(argc < 2){printf(USAGE,argv[0]);return 0;}
if(atoi(argv[1]) == 2 && !argv[2]){printf(USAGE,argv[0]);return 0;}
hDevice = CreateFile("\\\\.\\Ioctl",GENERIC_WRITE|GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
printf("Handle : %p\n",hDevice);
if(atoi(argv[1]) == 1)
{
DeviceIoControl(hDevice,IOCTL_LOL,welcome,strlen(welcome),out,sizeof(out),&NombreByte,NULL);
printf("Written.\n");
printf("Message reçu du kerneland : %s\n",out);
}
else
{
DeviceIoControl(hDevice,IOCTL_HIDE_PROCESS,argv[2],strlen(argv[2]),NULL,0,&NombreByte,NULL);
}
CloseHandle(hDevice);
return 0;
}