home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / +Sandman / Imperium / easy / seek.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  2.1 KB  |  92 lines

  1. /* this program convert a string containing differents token separated with *
  2.  and return the string needed to be put in _challenge1.htm.
  3.  for example : type "The_Seeker*Sandman" when prompted for the input string
  4. */
  5.  
  6. #include <math.h>
  7. #include <stdio.h>
  8. #include <conio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11.  
  12. const char* al="AH2ypN(TZ>RCKi*z;U7G)?dQ<Je]0-=~M$%ahruoSnWEx4YFqmL(5`IOPB}|s6g:#&Vj+l1_[cvD,9./^f3@tXbw!k8";
  13.  
  14.  
  15. //return the first 2 char in a string as a integer (from 0 to 99)
  16. int stoi(char* st) {return ((st[0]&0x0F)*10+(st[1]&0x0F));}
  17.  
  18. //convert int i to a 2 char string
  19. void itos(char* buff, int i) {sprintf(buff,"%02d",i);}
  20.  
  21.  
  22. //return the index of char c in the string al
  23. int GetCharIndex(char c)
  24.  
  25. {
  26.  int i;
  27.  for (i=0; i<strlen(al); i++)
  28.  {
  29.   if (al[i] == c) return i;
  30.  }
  31.  printf("error\n");
  32.  return 0;
  33. }
  34.  
  35.  
  36. //append to dest the string source crypted with the 'offset' a
  37. void CryptString(char* dest, char* source, int a)
  38.  
  39. {
  40.  int i;
  41.  char buff[3];
  42.  itos(buff, strlen(source)+89);   //append string length
  43.  strcat(dest, buff);
  44.  for (i=0; i<strlen(source); i++)
  45.  {
  46.   itos(buff, GetCharIndex(source[i])+a); //append each char
  47.   strcat(dest, buff);
  48.  }
  49. }
  50.  
  51.  
  52. void main(void)
  53.  
  54. {
  55.  char buff[80];
  56.  char inputstring[30];    //hold the input string (The_Seeker*Sandman for example)
  57.  int a_offset;            //hold the crypting offset
  58.  char* tok;                   //will contain each substring to be crypted
  59.  
  60.  FILE *out;
  61.  
  62.  printf("enter string to convert : ");
  63.  scanf("%s", inputstring);
  64.  printf("enter 'a' offset : ");
  65.  scanf("%d", &a_offset);
  66.  
  67.  out = fopen("code.txt", "at");
  68.  fprintf(out,"'%s' crypted with offset %d -> ", inputstring, a_offset);
  69.  
  70.  
  71.  itos(buff, a_offset+91);       //begin to store the a_offset
  72.  
  73.  tok = strtok(inputstring, "*");                //get the first substring
  74.  if (tok)
  75.  {
  76.   do
  77.      {
  78.       printf("crypting '%s' ...\n", tok);
  79.       CryptString(buff, tok, a_offset);        //store it
  80.       tok = strtok(NULL, "*");                    //get the next substring ... and loop to store it too
  81.      }
  82.   while(tok!=NULL);
  83.  }
  84.  
  85.  
  86.  printf("%s", buff);
  87.  fprintf(out,"%s\n", buff);
  88.  
  89.  fclose(out);
  90.  int ch = getch();
  91. }
  92.