Forked from cr0nx/gist:1bd6daa7b0cc99320c771da95b203827
Created
July 4, 2025 09:29
-
-
Save socketz/a73416e51e10e3efeaa044af4380f3bb to your computer and use it in GitHub Desktop.
Find in-memory modification of kernel.yama.ptrace_scope with bpftrace - PoC
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
| #!/usr/bin/env bpftrace | |
| BEGIN | |
| { | |
| printf("ptrace_scope address: %p\n", kaddr("ptrace_scope")); | |
| $data_addr = kaddr("ptrace_scope"); | |
| @last_val = *(int32*)$data_addr; // Initial value | |
| printf("Monitoring kernel.yama.ptrace_scope at address 0x%x (initial value: %d)\n", | |
| $data_addr, @last_val); | |
| } | |
| interval:s:1 | |
| { | |
| $data_addr = kaddr("ptrace_scope"); | |
| $current = *(int32*)$data_addr; | |
| if (@last_val != $current) { | |
| time("%H:%M:%S "); | |
| printf("ALERT: kernel.yama.ptrace_scope changed from %d to %d!\n", | |
| @last_val, $current); | |
| @last_val = $current; | |
| } | |
| } | |
| END | |
| { | |
| clear(@last_val); | |
| printf("Monitoring stopped\n"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment