Created
April 3, 2021 16:43
-
-
Save sysraccoon/0fd1c056a56576d2ddbaabe881af4510 to your computer and use it in GitHub Desktop.
BPF hello world
This file contains hidden or 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
| #!/bin/env python3 | |
| from bcc import BPF | |
| bpf_text = ''' | |
| int syscall__execve(void *ctx) | |
| { | |
| bpf_trace_printk("execve detected"); | |
| return 0; | |
| } | |
| ''' | |
| bpf = BPF(text=bpf_text) | |
| execve_fname = bpf.get_syscall_fnname("execve") | |
| bpf.attach_kprobe(event=execve_fname, fn_name="syscall__execve").trace_print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment