Cooler_

is_aslr()

Aug 20th, 2014
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. const char *ReadLine(char * NameFile)
  6. {
  7.  FILE * file;
  8.  file = fopen(NameFile, "r");
  9.  if(!file)
  10.  {
  11.   puts("error in file");
  12.   return;
  13.  }
  14.  char *lineBuffer=calloc(1,1), line[128];
  15.  
  16.  if(!lineBuffer)
  17.  {
  18.   printf("error in readLine() at %s",NameFile);
  19.   return;
  20.  }
  21.  
  22.  while(fgets(line,sizeof line-1,file))
  23.  {
  24.   lineBuffer=realloc(lineBuffer,strlen(lineBuffer)+strlen(line)+1);
  25.   if(!lineBuffer)
  26.   {
  27.    printf("error in readLine() at %s",NameFile);
  28.    return;
  29.   }
  30.   strcat(lineBuffer,line);
  31.  }
  32.  
  33.  
  34.  return lineBuffer;
  35. }
  36.  
  37.  
  38.  
  39. int main()
  40. {
  41.  int *aslr=(int *)atoi(ReadLine("/proc/sys/kernel/randomize_va_space"));
  42.  
  43.  printf("%d \n",(int)aslr);
  44.  
  45.  if(aslr == 0)
  46.  {
  47.   puts("sem ASLR");
  48.   exit(0); 
  49.  } else
  50.   puts("com ASLR");
  51.  
  52.  
  53. //  programm code....
  54.  
  55.  
  56.  exit(0);
  57. }
Advertisement
Add Comment
Please, Sign In to add comment