Hauptseite | ETPro config certification tool - Forum | Registrieren | Login
[ Neue Beiträge · User · Suche · RSS ]

Seite 1 von 11
Forum » Server Stuff » Server Stuff » ETPro config certification tool

ETPro config certification tool
ETPro offers a 'certified configs' feature which basically means "this server is running the unmodified version of the config file leagues uploaded to their site". It's used for stopping people from modifying limitations and other stuff.

Here's a small command line tool you can use for certifying official configs with your modifications. To compile it, you will need PolarSSL's sha1 library.

Code
/* Implementation of the ETPro's config certification system */
/* chaplja.blogspot.com | chaplja@gmail.com */

#define _CRT_SECURE_NO_WARNINGS /* microsoft's deprecated function warnings */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sha1.h" /* polarssl.org */

/* helper funcs */
void *read_text_file(const char *);

unsigned char etpro_sig[1024] = {
  0x18, 0x73, 0xE1, 0x02, 0xCA, 0x8A, 0xDD, 0x08, 0xBA, 0xBC, 0x1D, 0xC6,
  0xE9, 0x8C, 0xCD, 0x7B, 0x54, 0x2A, 0xAC, 0x95, 0xAE, 0xDE, 0xB3, 0xE2,
  0xA7, 0x76, 0x94, 0x34, 0xB0, 0xEC, 0xAB, 0x08, 0x9A, 0xFD, 0x41, 0xAF,
  0x6F, 0x4F, 0x03, 0xF5, 0x1F, 0x86, 0x95, 0x97, 0xEE, 0xBB, 0x2D, 0x03,
  0x00, 0x93, 0xA0, 0xA3, 0x67, 0x00, 0x17, 0x4B, 0xC3, 0x56, 0x82, 0xD8,
  0xE8, 0xBB, 0x40, 0xFA, 0x9C, 0x4E, 0x17, 0x91, 0xE5, 0xAF, 0x0D, 0x25,
  0xCD, 0x25, 0x44, 0xE8, 0xA8, 0x5C, 0x3A, 0x15, 0x8A, 0x47, 0x7E, 0x36,
  0xA6, 0x2C, 0x70, 0x9B, 0xFD, 0x1E, 0x75, 0x0B, 0xEA, 0xDC, 0x7F, 0x14,
  0x70, 0x19, 0x09, 0x97, 0xC7, 0x7F, 0x29, 0xC4, 0xA0, 0x79, 0x46, 0x4D,
  0x42, 0x52, 0xBC, 0x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x4D, 0xDA, 0x9C, 0x0D, 0x1D, 0xE9,
  0x55, 0x9F, 0x0F, 0xE5
};

#define OUTPUT_FILENAME    "certified.config"

int main(int argc, char **argv)
{
  sha1_context ctx;
  FILE *fout = NULL;
  unsigned char hash[20];
  char *input, *p;
  int c;
  size_t len;

  /* application name + author */
  puts("etpro config certification by chaplja");
  puts("chaplja.blogspot.com | chaplja@gmail.com ");

  /* usage information */
  if (argc != 2) {
   printf("Usage: %s <config_to_certify>\n", argv[0]);
   exit(1);
  }

  /* read and open necessary files */
  if (!(input = read_text_file(argv[1]))) {
   printf("Failed reading '%s'\n", argv[1]);
   goto end;
  }

  if (!(fout = fopen(OUTPUT_FILENAME, "wb"))) {
   puts("Failed opening '" OUTPUT_FILENAME "'\n");
   goto end;
  }

  /* perform sha on the 'junk' data */
  sha1_starts(&ctx);
  sha1_update(&ctx, etpro_sig, sizeof(etpro_sig));

  /* remove the existing signature from the config if it exists */
  p = strstr(input, "\nsignature");
  if (p)
   len = p - input + 1;
  else
   len = strlen(input);

  /* hash the actual config data and new line */
  sha1_update(&ctx, (unsigned char *) input, len);
  sha1_update(&ctx, (unsigned char *) "\r\n", 2);
  sha1_finish(&ctx, hash);

  /* write the certified config */
  fwrite(input, len, 1, fout);
  fwrite("\r\nsignature ", 12, 1, fout);
  for (c = 0; c < 20; c++)
   fprintf(fout, "%02x", hash[c]);

  /* success message */
  puts("Successfully written a certified config to " OUTPUT_FILENAME);

  /* cleanup */
end:
  free(input);
  if (fout)
   fclose(fout);

  return 0;
}

void *read_text_file(const char *path)
{
  FILE *fp;
  size_t flen;
  void *file;
  size_t cnt;

  /* sanity check */
  if (!path || !(*path))
   return NULL;

  /* open the file */
  fp = fopen(path, "rb");
  if (!fp) {
   return NULL;
  }

  /* get file length */
  fseek(fp, 0, SEEK_END);
  flen = ftell(fp);
  fseek(fp, 0, SEEK_SET);

  /* allocate memory for the file data */
  file = malloc(flen + 1);
  if (!file) {
   fclose(fp);
   return NULL;
  }

  /* read the file from disk and append the nul char */
  cnt = fread(file, 1, flen, fp);
  ((char *) file)[cnt] = 0;

  /* data loaded, close the file */
  fclose(fp);

  return file;
}


Source

Forum » Server Stuff » Server Stuff » ETPro config certification tool
Seite 1 von 11
Suche:

Copyright etpro.de © 2008-2016 . Toolbar | Impressum | Kontakt

Bookmark and Share