home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / cops_104.zip / cops_104 / src / crack.h < prev    next >
C/C++ Source or Header  |  1992-03-10  |  3KB  |  127 lines

  1. /*
  2.  * This program is copyright Alec Muffett 1991 except for some portions of
  3.  * code in "crack-fcrypt.c" which are copyright Robert Baldwin, Icarus
  4.  * Sparry and Alec Muffett.  The author(s) disclaims all responsibility or
  5.  * liability with respect to it's usage or its effect upon hardware or
  6.  * computer systems, and maintain copyright as set out in the "LICENCE"
  7.  * document which accompanies distributions of Crack v4.0 and upwards. 
  8.  */
  9.  
  10. #define Log printf
  11.  
  12. #include "conf.h"
  13.  
  14. #define STRINGSIZE    255
  15.  
  16. extern void Trim ();
  17. extern char *Reverse ();
  18. extern char *Uppercase ();
  19. extern char *Lowercase ();
  20. extern char *Clone ();
  21. extern char *Mangle ();
  22. extern char *gethostname ();
  23.  
  24. #ifdef FAST_TOCASE
  25. #define toupper(x)     _toupper(x)
  26. #define tolower(x)    _tolower(x)
  27. #endif
  28.  
  29. /* #ifdef FCRYPT
  30. #define crypt(a,b)    fcrypt(a,b)
  31. #endif */
  32.  
  33. #ifdef INDEX_NOT_STRCHR
  34. #define strchr(a,b)     index(a,b)
  35. #endif
  36.  
  37. struct USER
  38. {
  39.     int done;            /* bool flag */
  40.     char *filename;        /* where we got it from */
  41.     char *passwd_txt;        /* plaintext of password */
  42.     struct passwd passwd;    /* ...guess... */
  43.     struct USER *across;    /* line of users with same salt */
  44.     struct USER *next;        /* next users with different salt */
  45. };
  46.  
  47. struct DICT
  48. {
  49.     char *word;            /* simple linked list */
  50.     struct DICT *next;
  51. };
  52.  
  53. struct RULE
  54. {
  55.     char *rule;
  56.     struct RULE *next;
  57. };
  58.  
  59. #define STRCMP(x,y) ((x)[0] != (y)[0] ? -1 : strcmp((x),(y)))
  60.  
  61. /* Rest of stuff is from crack-fcrypt.c */
  62.  
  63. #define    reg    register
  64. #define    uns    unsigned
  65. #define unsb    uns char
  66. #define    unsl    uns long
  67.  
  68. /*
  69.  * Types for the different ways to represent DES bit patterns.  Bits are
  70.  * always right justified within fields.  Bits which have lower indices in
  71.  * the NBS spec are stored in the vax bits with less significance (e.g., Bit
  72.  * 1 of NBS spec is stored in the bit with weight 2 ** 0 to the Vax.
  73.  */
  74.  
  75. #define    obpb1    unsb        /* One bit per byte. */
  76. #define sbpb6    unsb        /* Six bits per byte, 6 held. */
  77. #define sbpb6R    unsb        /* Six bits per byte Reversed order, 6 held. */
  78. #define    sbpb24    unsl        /* Six bits per byte, 24 held. */
  79. #define    ebpb24    unsl        /* Eight bits per bit, 24 held. */
  80. #define    fbpb4    unsb        /* Four bits per byte, 4 held. */
  81. #define    fbpb4R    unsb        /* Four bits per byte Reversed order, 4 held. */
  82.  
  83. /*
  84.  * The operation (6 * x) is often better optimised as this (for really
  85.  * braindead compilers) - AEM
  86.  */
  87.  
  88. #ifdef BRAINDEAD6
  89. #define SIX_TIMES(exprn)        (((exprn) << 2) + ((exprn) << 1))
  90. #else
  91. #define SIX_TIMES(exprn)        (6 * (exprn))
  92. #endif                /* BRAINDEAD6 */
  93.  
  94. /* DES transformation type... */
  95.  
  96. union SDATA
  97. {
  98.     sbpb24 b[2];
  99.     sbpb6 c[8];
  100. };
  101.  
  102. #ifndef FDES_8BYTE        /* Not on a Cray */
  103. #ifndef FDES_4BYTE        /* Thanks to Matt Bishop for this idea -AEM. */
  104. #define SIZEFIX        0
  105. #define INDIRECT(a,b)     (a)[b]
  106. #else
  107. #define SIZEFIX        2    /* "n" where 2^n == sizeof(sbpb24) */
  108. #define INDIRECT(a,b)     (*((sbpb24 *)(((unsigned char *) a) + (b))))
  109. #endif
  110. #endif
  111.  
  112. /*
  113.  * These used to be rather slow and frequently used functions - AEM
  114.  */
  115.  
  116. #define TF_TO_SIXBIT(tf) \
  117.     (sbpb24)((tf & 077L) | \
  118.         ((tf & 07700L) << 2) | \
  119.         ((tf & 0770000L) << 4) | \
  120.         ((tf & 077000000L) << 6))
  121.  
  122. #define SIXBIT_TO_TF(sb) \
  123.     (ebpb24)((sb & 0x3fL) | \
  124.         ((sb & 0x3f00L) >> 2) | \
  125.         ((sb & 0x3f0000L) >> 4) | \
  126.         ((sb & 0x3f000000L) >> 6))
  127.