Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <sys/ptrace.h>
- #include <sys/types.h>
- #include <sys/wait.h>
- #include <sys/user.h>
- #include <sys/reg.h>
- #include <sys/syscall.h>
- #include <unistd.h>
- int main()
- {
- struct user data;
- pid_t child;
- child = fork();
- if(child == 0) {
- ptrace(PTRACE_TRACEME, 0, NULL, NULL);
- execl("/bin/ls", "ls", NULL);
- }
- else {
- // Get syscall:
- ptrace(PTRACE_SYSCALL,child, NULL ,NULL);
- // Check syscall:
- long sys = ptrace(PTRACE_PEEKUSER,child, NULL, ((long long)&data.regs.orig_rax - (long long)&data));
- printf("Syscall called: %d",(int)sys);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement