Last active
December 29, 2019 00:14
-
-
Save Jongy/7c8f164be9138bf85545e9baf734abb1 to your computer and use it in GitHub Desktop.
Print all open()ed files on the system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kernel_ffi import kprobe, KP_ARGS_WATCH, str as s | |
from struct_access import partial_struct | |
filename = partial_struct("filename") | |
def do_filp_open_hook(dfd, fn): # don't have to receive all args if you don't need | |
print("do_filp_open: fd {} name {!r}".format(dfd, s(int(filename(fn).name)))) | |
kp = kprobe("do_filp_open", KP_ARGS_WATCH, do_filp_open_hook) | |
# when you're done: | |
kp.rm() | |
# if kp goes out of scope, the gc finalizer will also remove it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment