bamboozle.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*+-------------------------------------------------------------------------
  2. bamboozle.c - ecu/ecuungetty protection scheme
  3. wht@wht.net
  4. When bad men combine, the good must associate; else they will
  5. fall one by one, an unpitied sacrifice in a contemptible
  6. struggle. -Edmund Burke
  7. --------------------------------------------------------------------------*/
  8. /*+:EDITS:*/
  9. /*:04-26-2000-11:15-wht@bob-RELEASE 4.42 */
  10. /*:01-24-1997-02:36-wht@yuriatin-SOURCE RELEASE 4.00 */
  11. /*:09-11-1996-19:59-wht@yuriatin-3.48-major telnet,curses,structural overhaul */
  12. /*:09-06-1996-02:11-wht@kepler-bit fiddling fixes/cleanup */
  13. /*:11-23-1995-11:20-wht@kepler-source control 3.37 for tsx-11 */
  14. /*:11-14-1995-10:23-wht@kepler-3.37.80-source control point: SOCKETS */
  15. /*:05-04-1994-04:38-wht@n4hgf-ECU release 3.30 */
  16. /*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  17. /*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  18. /*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
  19. /*:01-09-1991-22:31-wht@n4hgf-ISC port */
  20. /*:01-09-1991-21:05-wht@n4hgf-no prototype for crypt if not __STDC__ */
  21. /*:08-14-1990-20:39-wht@n4hgf-ecu3.00-flush old edit history */
  22. #include <stdio.h>
  23. #if __STDC__ == 1
  24. char *crypt(char *, char *);
  25. #else
  26. char *crypt();
  27. #endif
  28. /*+-------------------------------------------------------------------------
  29. bamboozle(pid) - build encrypted string based on 'pid'
  30. If crypt not used, do something pretty basic (probably enough)
  31. If you are paranoid, don't use _ANY_ of these algorithms exactly
  32. --------------------------------------------------------------------------*/
  33. char *
  34. bamboozle(pid)
  35. int pid;
  36. {
  37. #if defined(CRYPT)
  38. char pidstr[16];
  39. char *cp;
  40. sprintf(pidstr, "z%08d", pid);
  41. pidstr[0] = 'G'; /* fool strings searchers */
  42. cp = crypt(pidstr, "ba");
  43. return (cp);
  44. #else /* probably enough */
  45. static char pidstr[16];
  46. sprintf(pidstr, "b%09da", (int)(((long)pid * 21) / 5));
  47. return (pidstr);
  48. #endif
  49. #ifdef VARIANT_1 /* very paranoid */
  50. char pidstr[16];
  51. char *cp;
  52. sprintf(pidstr, "z%08d", pid);
  53. pidstr[0] = 0xFF; /* fool strings searchers */
  54. cp = crypt(pidstr, pidstr);
  55. return (cp);
  56. #endif
  57. #ifdef VARIANT_2 /* not paranoid at all */
  58. char pidstr[16];
  59. sprintf(pidstr, "z%08d", pid - 2);
  60. #endif
  61. #ifdef VARIANT_3 /* invite trouble :-) */
  62. return ("I_am_easy");
  63. #endif
  64. } /* end of bamboozle */
  65. /* vi: set tabstop=4 shiftwidth=4: */
  66. /* end of bamboozle.c */