-
-
Save slankdev/6964d20b8a8ebe82723e1b236b37d515 to your computer and use it in GitHub Desktop.
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <stdbool.h> | |
void slankdev_test(int id, const char* str, bool isUS) | |
{ | |
printf("%d: fuckin %s. slankdev \"I %s understand PACKET.\"\n", | |
id, | |
str, | |
isUS?"can":"cannot" | |
); | |
} | |
int main() | |
{ | |
for (size_t i=0; ; i++) { | |
bool cond = rand()%2 == 0 ? true : false; | |
slankdev_test(i, "kusobpf", cond); | |
sleep(1); | |
} | |
} |
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
make: | |
sudo ./slankdev.py | |
src: | |
gcc -static main.c |
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
#!/usr/bin/env python | |
from bcc import BPF | |
prog = """ | |
#include <uapi/linux/ptrace.h> | |
void call(struct pt_regs *ctx) | |
{ | |
bpf_trace_printk("Call Func\\n"); | |
bpf_trace_printk(" arg[1]: %d \\n", PT_REGS_PARM1(ctx)); | |
bpf_trace_printk(" arg[2]: %s \\n", (char*)PT_REGS_PARM2(ctx)); | |
bpf_trace_printk(" arg[3]: %d \\n", PT_REGS_PARM3(ctx)?1:0); | |
} | |
""" | |
b = BPF(text=prog) | |
b.attach_uprobe (name="./a.out", sym="slankdev_test", fn_name="call") | |
while True: | |
print(b.trace_fields()[5]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment