Skip to content

Instantly share code, notes, and snippets.

@sysraccoon
Created April 3, 2021 16:43
Show Gist options
  • Select an option

  • Save sysraccoon/0fd1c056a56576d2ddbaabe881af4510 to your computer and use it in GitHub Desktop.

Select an option

Save sysraccoon/0fd1c056a56576d2ddbaabe881af4510 to your computer and use it in GitHub Desktop.
BPF hello world
#!/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