修改Linux系统内核

发布于 2025-01-30 03:23:16 字数 234 浏览 7 评论 0原文

我想修改linux的系统kernell,我想更改打开的系统调用,因此当我尝试打开一个文件时,我想打开另一个文件,但是我找不到open.c文件中的位置。以及要使用的变量,将感谢一些信息。 Open SystemCall中有很多syscalls_defines,但我不明白我可以使用哪一个。我尝试在Open.c中的某些函数中添加一些printk()函数,当我sudo dmesg时,我就达到了输出,但是我仍然找不到确切的open.c呼叫和要修改的函数的函数。

i want to modify the system kernell for linux, i want to change the open system call, so when i try to open one file, i want to open another one, but i cannot find where in the open.c file this can be done and which variables to work with, would appreciate some information. There are a lot of syscalls_defines in the open systemcall, but i do not understand which one of them i could work with. I have tried to add some printk() functions into some functions in the open.c, and when i sudo dmesg i get there output, but i still can't find exactly which functions that open.c calls and which function to modify.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小草泠泠 2025-02-06 03:23:16

不确定要实现的目标,但是如果您只想劫持打开的系统调用而无需将其应用于机器上的所有进程,则无需使用内核。将共享库魔术与ld_preload一起使用,重新定义LIBC系统调用包装器可能就足够了。

您可以通过读写在这里。但是任何系统调用的想法都是相同的。

Not exactly sure what you want to achieve, but if you just want to hijack the open system call without the malign intention of applying this to all processes on a machine, you don't need to tinker with the kernel. Using shared library magic with LD_PRELOAD, and redefining the libc system call wrapper would probably be enough.

You can find how to do this with read and write here. But the idea is the same with any system call.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文