SHARE
TWEET

getting syscall table address

a guest Aug 6th, 2012 204 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static char mapfile[ ] = "/boot/System.map-";
  2. static char query[ ] = "sys_call_table";
  3.  
  4. char *GetFile() {
  5.  static char *filename;
  6.  int fns;
  7.  struct utsname info_s;
  8.  
  9.         if (uname(&info_s)>=0){
  10.                 fns=strlen(mapfile)+strlen(info_s.release);
  11.                 filename=(char *)malloc(fns);
  12.                 sprintf(filename,"%s%s",mapfile,info_s.release);
  13.         } else return NULL;
  14.  return filename;
  15. }
  16.  
  17. unsigned long position(char *file) {
  18.  FILE *fp;
  19.  char buf[100];
  20.  unsigned long *sctable;
  21.  
  22.         fp = fopen(file,"r");
  23.         if (!fp) return 0;
  24.         for(;;) {
  25.                 if(NULL == fgets(buf,99,fp)) break;
  26.                 if(strstr(buf,query)) {
  27.                         sctable=(unsigned long*)strtoul(strtok(buf," "),NULL,16);
  28.                         break;
  29.                 }
  30.         }
  31.         fclose(fp);
  32.  return sctable;
  33. }
  34.  
  35. int main() {
  36.  char *filename=NULL;
  37.  unsigned long sctaddr;
  38.  
  39.         filename=GetFile();
  40.         sctaddr=position(filename);
  41.         printf("[*] Syscall Table hosted at: %x\n",sctaddr);
  42.  return 0;
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top