Skip to content

Instantly share code, notes, and snippets.

@ppmx
Created October 30, 2018 11:25
Show Gist options
  • Select an option

  • Save ppmx/65af8f9cf36c7aa905d51c83f9b76dc2 to your computer and use it in GitHub Desktop.

Select an option

Save ppmx/65af8f9cf36c7aa905d51c83f9b76dc2 to your computer and use it in GitHub Desktop.
illustrates a simple anti debugging technique
#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