Skip to content

Instantly share code, notes, and snippets.

@blaquee
Created October 19, 2015 20:03
Show Gist options
  • Select an option

  • Save blaquee/5f5d3b1f356fae2173fe to your computer and use it in GitHub Desktop.

Select an option

Save blaquee/5f5d3b1f356fae2173fe to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <sys/ptrace.h>
void pre_check(int argc, char **argv, char **envp)
{
printf("Inside pre_check!\n");
if(ptrace(PTRACE_TRACEME, 0, 0, 0) < 0)
{
printf("Aliens found!\n");
exit(0);
}
}
__attribute__((section(".preinit_array"))) typeof(pre_check) *_preinit = pre_check;
void __attribute__ ((constructor)) anti_trace(void);
void anti_trace(void)
{
printf("Inside constructor!\n");
}
void message()
{
printf("Last place, called from main() :(\n");
}
int main(int argc, char **argv)
{
message();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment