Created
October 30, 2018 11:25
-
-
Save ppmx/65af8f9cf36c7aa905d51c83f9b76dc2 to your computer and use it in GitHub Desktop.
illustrates a simple anti debugging technique
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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <sys/ptrace.h> | |
| void anti_debugging(void) __attribute__ ((constructor)); | |
| void run_evil_code(); | |
| void anti_debugging(void) | |
| { | |
| // if we are not traced: | |
| if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) != -1) | |
| run_evil_code(); | |
| } | |
| void run_evil_code() | |
| { | |
| printf("evil code.\n"); | |
| } | |
| int main(int argc, char **argv) | |
| { | |
| printf("everything's fine.\n"); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment