马老板用JavaScript控制宇宙飞船,中国用ActionScript调度高速铁路,cui先生看着go代码里满屏的 if err != nil 骂街,人类有非常光明的未来
interpose!
interposelibc.so:
$(CC) -share -fPIC -o interposelibc.so $(OBJ)
#include <unistd.h>
#include <errno.h>
// original
pid_t (*fork_fp)(void);
// init
__attribute__((constructor))
void interposelibc_init()
{
fork_fp = dlsym(/*RTLD_NEXT*/ -1, "fork");
}
pid_t fork(void)
{
if(INTERPOSE_ALL_FAIL)
{
errno = ENOMEM;
return -1;
}
return fork_fp();
}
FreeBSD 加调试
设施
···txt
#include <sys/systm.h> // log()
#include <sys/syslog.h> // log level
log(LOG_LEVEL, “fmt string”, …);
···
结果
时间 主机 kernel: 日志。。。
实例
--- kern_exec.c.orig 2020-12-30 16:50:13.809780000 +0800
+++ kern_exec.c 2020-12-30 16:49:54.466415000 +0800
@@ -358,6 +358,8 @@
static int
do_execve(struct thread *td, struct image_args *args, struct mac *mac_p)
{
+ log(7 /*LOG_DEBUG*/, "execve(%s)\n", args->begin_argv); // TODO: literal
+
struct proc *p = td->td_proc;
struct nameidata nd;
struct ucred *oldcred;
莉特雅 literal
写代码业余爱好者 amateur coder