Rog*_*oge 1 c kernel freebsd kernel-module
尝试一些FreeBSD内核黑客攻击,我在一个简单的钩子示例中遇到了错误.代码如下
*注意 - 我添加了#include <sys/stat.h>尽可能多的建议,但继续得到相同的错误.
#include <sys/types.h>
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/module.h>
#include <sys/sysent.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/syscall.h>
#include <sys/sysproto.h>
#include <sys/stat.h>
static int mkdir_hook(struct thread *td, void *syscall_args) {
struct mkdir_args *uap;
uap = (struct mkdir_args *)syscall_args;
char path[255];
size_t done;
int error;
error = copyinstr(uap->path, path, 255, &done);
if(error != 0)
return (error);
uprintf("hooked it\n");
return (mkdir(td, syscall_args));
}
static int load(struct module *module, int cmd, void *arg) {
int error = 0;
switch(cmd){
case MOD_LOAD:
sysent[SYS_mkdir].sy_call = (sy_call_t *)mkdir_hook;
break;
case MOD_UNLOAD:
sysent[SYS_mkdir].sy_call = (sy_call_t *)mkdir;
break;
default:
error = EOPNOTSUPP;
break;
}
return(error);
}
static moduledata_t mkdir_hook_mod = {
"mkdir_hook",
load,
NULL
};
DECLARE_MODULE(mkdir_hook, mkdir_hook_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
Run Code Online (Sandbox Code Playgroud)
编译器错误是
mkdirhook.c:23:11: error: implicit declaration of function 'mkdir' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
return (mkdir(td, syscall_args));
^
1 error generated.
*** Error code 1
Run Code Online (Sandbox Code Playgroud)
我猜这是一个简单的问题,我使用的代码示例已经过时了.