Aadec

From PhatHack Wiki
Revision as of 21:18, 5 July 2005 by Sbingner (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

[[Category::Definitions]] [[Category::HOWTO]] aadec is a utility that decodes inst.pnt files and perhaps other things. This is used to authenticate installation of plugins. Below is code that can be used to create a version of aadec that will always provide output saying a given plugin is authorized for installation into the current phatbox. This may or may not cause other problems, use at your own risk.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>



int main(int argc, char **argv)
{
  char filename[256], cpuid[256], *file;
  int pwid=-1;
  FILE *in;
  struct stat stbuf;
  int len=0;

  if (argc < 2 || (strlen(argv[1]) > 255))
    return 1;

  strcpy(filename, "/proc/pn_cpu_id");
  in = fopen(filename, "r");
  if (fscanf(in, "Unique ID: %s", cpuid) != 1)
    return -1;
  fclose(in);

  strcpy(filename, argv[1]);
  file = (char *)strrchr(filename, '/');
  if ((file-filename) > 244)
    return 2;
  strcpy(file, "/plugin.ini");
  if (stat(filename, &stbuf) != 0)
    return 3;

  in = fopen(filename, "r");
  while(fscanf(in, " id = %d", &pwid) != 1) {
    if (fscanf(in, " %*s") == EOF)
      break;
  }
  fclose(in);

  printf("Unique ID: %s\nPWid: %d\n", cpuid, pwid);
  return 0;
}