home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume23 / crack / part04 < prev    next >
Encoding:
Text File  |  1991-09-22  |  51.8 KB  |  1,632 lines

  1. Newsgroups: comp.sources.misc,alt.sources,alt.security
  2. From: aem@aber.ac.uk (Alec David Muffett)
  3. Subject:  v23i004:  crack - The Password Cracker, version 3.3c, Part04/05
  4. Message-ID: <1991Sep22.050807.13731@sparky.imd.sterling.com>
  5. X-Md4-Signature: 3cf252ac278980799da48c2a286cf1a8
  6. Date: Sun, 22 Sep 1991 05:08:07 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: aem@aber.ac.uk (Alec David Muffett)
  10. Posting-number: Volume 23, Issue 4
  11. Archive-name: crack/part04
  12. Environment: UNIX
  13. Supersedes: crack: Volume 22, Issue 49-52
  14.  
  15. #! /bin/sh
  16. # it by saving it into a file and typing "sh file".  To overwrite existing
  17. # files, type "sh file -c".  You can also feed this as standard input via
  18. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  19. # will see the following message at the end:
  20. #        "End of archive 4 (of 5)."
  21. # Contents:  Docs/README.ms Sources/crack-fcrypt.c
  22. # Wrapped by aem@aberda on Fri Sep 20 12:26:55 1991
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. if test -f 'Docs/README.ms' -a "${1}" != "-c" ; then 
  25.   echo shar: Will not clobber existing file \"'Docs/README.ms'\"
  26. else
  27. echo shar: Extracting \"'Docs/README.ms'\" \(26560 characters\)
  28. sed "s/^X//" >'Docs/README.ms' <<'END_OF_FILE'
  29. X.de C
  30. X.ie n .B "\\$1" \\$2
  31. X.el .CW "\\$1" \\$2
  32. X..
  33. X.TL
  34. X"Crack Version 3.3c"
  35. X.br
  36. XA Sensible Password Checker for
  37. X.UX
  38. X.AU
  39. XAlec D.E. Muffett
  40. X.AI
  41. XComputer Unit, University College of Wales
  42. XAberystwyth, Wales, SY23 3DB
  43. X.I aem@aber.ac.uk
  44. X+44 970 622492
  45. X.AB
  46. X.B Crack \**
  47. X.FS
  48. X.C Crack
  49. Xis available for anonymous FTP from
  50. X.I "wuarchive.wustl.edu"
  51. X(128.252.135.4) in
  52. X.I ~/packages
  53. X.FE
  54. Xis a freely available program designed to find standard
  55. X.UX
  56. Xeight-character DES encrypted passwords by standard guessing techniques
  57. Xoutlined below.  It is written to be flexible, configurable and fast,
  58. Xand to be able to make use of several networked hosts via the Berkeley
  59. X.C rsh
  60. Xprogram (or similar), where possible.
  61. X.AE
  62. X.NH 1
  63. XIntent of this program
  64. X.LP
  65. XMy intentions, whilst writing this program, were
  66. X.IP 1)
  67. XTo provide the average system manager with a simple, flexible and fast
  68. Xtool to find passwords which would be easily compromised by a dictionary
  69. Xsearch.
  70. X.IP 2)
  71. XTo weaken the complacency which has developed amongst many (in)?experienced
  72. X.UX
  73. Xsystems managers about password security. Just because the
  74. X.C crypt()
  75. Xfunction cannot be reversed does not mean that your passwords are
  76. Xsecure.  If this program helps to raise the overall quotient of paranoia
  77. Xjust one little bit, then it will have served its purpose and is all to
  78. Xthe good.
  79. X.LP
  80. XI am quite certain that some childish morons out there will abuse the
  81. Xwork that I have put into creating this program.  It's up to them how
  82. Xthey use it, but if it's used for some illegal purpose it's not my
  83. Xintention, nor my fault. I hope they get caught.
  84. X.LP
  85. XCrack was not designed to do anything
  86. X.I nasty ,
  87. Xother than to attack passwords in sensible order.  This is why I feel I
  88. Xcan post it to the net without fear of recrimination.  This version of
  89. XCrack is supplied with a (hopefully) portable version of
  90. X.C fcrypt() ,
  91. Xfor speed reasons.  Fcrypt() is not yet widely available, but several
  92. Xversions have now been posted to USENET, and with the growing ability to
  93. Xaccess anonymous FTP databases like
  94. X.B Archie ,
  95. XI believe that people who really want access to such programs as
  96. Xfcrypt() will be able to get them easily.  People who need them but
  97. Xdon't have the time to look, on the other hand, will not get them.  This
  98. Xis not a good thing if you are a systems manager, because it gives the
  99. Xcrackers an advantage.  My philosophy is:
  100. X.I "give it to everyone, then at least the people who need it can get it" .
  101. X.NH 1
  102. XFcrypt() Statistics
  103. X.LP
  104. XThe version of fcrypt() that comes with Crack is several times faster
  105. Xthan the version that was originally supplied to me, and should
  106. Xoutperform most others which are publicly available.  I haven't tried
  107. Xmany speed-demon style tricks, but rather I have gone for portability,
  108. Xelegance and simplicity, where applicable
  109. X.C 8-).
  110. XOn a DECStation 5000/200, fcrypt() iterates about 580 times per second,
  111. Xand overall, I measure this to be about 15 times faster than standard
  112. Xcrypt().  There are faster versions available, but at least I feel free
  113. Xto redistribute this version without stepping on anyones toes.
  114. X.LP
  115. XA final note about my motives: If you think that I am a moron for
  116. Xwriting and then distributing this program, and you think that the
  117. Xprogram is in itself dangerous, I suggest that you carefully consider
  118. Xthe fact that any moron could have written this program.  Flames to
  119. X.C /dev/null ,
  120. Xplease.
  121. X.NH 1
  122. XImplementation
  123. X.LP
  124. XI have tried to make Crack as portable as possible without compromising
  125. Xspeed.  Needless to say, it is imperfect in the this respect, but I have
  126. Xtried.  If you have problems getting Crack up, please let me know what
  127. Xthese problems are, and what system you were trying to put Crack up on.
  128. XI believe that Crack will work on
  129. X.B Xenix
  130. Xand various versions of
  131. X.B "System V" ,
  132. Xbut it may require a little effort if your
  133. X.UX
  134. Xis not fairly modern.
  135. X.LP
  136. XTo use the
  137. X.C "Crack -network"
  138. Xoption, you must have
  139. X.C rsh ,
  140. Xor a similar program.
  141. X.C rsh
  142. Xis a BSD-ism which has become fairly common on non-BSD systems.  If you
  143. Xdon't have it or something similar, let me know what you do have which
  144. Xmight, with a little ingenuity, do the job, and I shall see what I can
  145. Xdo.  Have a look in
  146. X.C Scripts/RCrack
  147. Xand feel free to play around.
  148. X.QP
  149. X.B Note:
  150. X.B Xenix
  151. Xusers and some others have a
  152. X.C rcmd
  153. Xprogram instead of
  154. X.C rsh .
  155. XSimilarly, 
  156. X.B HP-UX 
  157. Xhas a 
  158. X.C remsh
  159. Xcommand.  I'm not sure of the correct syntax for these programs, but it
  160. Xshould not be hard to integrate them, if they do not already work. 
  161. XThere is a note about these commands in
  162. X.C Scripts/RCrack
  163. X.QP
  164. XOn
  165. X.B "System V"
  166. Xbased systems, users may also be missing the BSD
  167. Xfunction
  168. X.C gethostname() .
  169. XIf this is so, but you
  170. X.B do
  171. Xhave the
  172. X.C uname()
  173. Xsystem call, define the macro
  174. X.C CRACK_UNAME
  175. Xin
  176. X.C Sources/conf.h
  177. Xinstead. This ought to fix the problem, but it
  178. X.I may
  179. Xneed a little user intervention first (it depends where your header file for
  180. X.C uname()
  181. Xis).
  182. X.I "Caveat Emptor!"
  183. X.NH 1
  184. XMethod of Password Cracking
  185. X.LP
  186. XCrack does not take the serial approach to password guessing that other
  187. Xprograms like the
  188. X.B COPS
  189. Xpassword cracker does.  Rather, Crack makes two passes over the users'
  190. Xpassword entries.
  191. X.LP
  192. XThe first pass bases its guesses on the contents of the
  193. X.I gecos
  194. Xfield (containing the users' real name), and the username itself.  The
  195. Xfirst pass is fast and usually very fruitful, and completes quite
  196. Xquickly.  You would be surprised at the number of spods who still think
  197. Xthat their middle name, backwards and capitalised, is a good password. 
  198. X.LP
  199. XThe second pass is made by encrypting several pre-processed dictionaries
  200. Xon the fly, and comparing the results with users passwords.  Crack
  201. Xoptimises the number of calls to the encryption function by sorting the
  202. Xuser passwords by their
  203. X.I "encryption salt"
  204. Xbefore loading, so that the dictionaries only have to be encrypted once
  205. Xfor each different salt.  This generally saves about 30% of the calls
  206. Xyou would have to make to
  207. X.C crypt() .
  208. X.LP
  209. XThe preprocessed dictionaries are created by merging the source
  210. Xdictionaries found in the directory
  211. X.C DictSrc
  212. Xand then truncating, sorting and uniq'ing the output from the
  213. Xpreprocessor.  The default dictionaries named are
  214. X.C /usr/dict/words
  215. Xwhich provides the bulk of the input data, and
  216. X.C DictSrc/bad_pws.dat
  217. Xwhich is meant to provide all of those non-dictionary passwords, such as
  218. X.I 12345678
  219. Xor
  220. X.I qwerty .\**
  221. X.FS
  222. XExtra dictionaries (those used in Dan Klein's paper, below) can be
  223. Xobtained via anonymous FTP from
  224. X.I uunet.uu.net
  225. X(192.48.96.2) as
  226. X.I ~/pub/dictionaries.tar.Z
  227. X.FE
  228. X.LP
  229. XIf you wish to add a dictionary of your own, just copy it into the
  230. X.C DictSrc
  231. Xdirectory and then delete the contents of the
  232. X.C Dicts
  233. Xdirectory (run
  234. X.C Scripts/spotless
  235. Xfrom within
  236. X.C $CRACK_HOME ).
  237. XYour new dictionary will be merged in on the next run.  Do
  238. Xnot worry about replication of data, as the preprocessor's driver script
  239. Xsorts and uniq's the data before putting it into the
  240. X.C Dicts
  241. Xdirectory.
  242. X.LP
  243. XThe formats of the output dictionaries are:
  244. X.IP a)
  245. XUnique words that have been forced lowercase, forwards.  These are the
  246. Xmost common passwords you will find, thus they are tried first.
  247. X.IP b)
  248. XDictionary words which have been artificially pluralised, because not
  249. Xmany dictionaries contain plurals.
  250. X.IP c)
  251. XDictionary words forced capitalised (eg:
  252. X.I Capitalised ).
  253. X.IP d)
  254. XDictionary words, forced lowercase, with a trailing 0 or 1 (this may be
  255. Xextended by hacking Sources/crack-pp.c).
  256. X.IP e)
  257. XDictionary words forced lowercase and backwards.
  258. X.IP f)
  259. XDictionary words, forced lowercase, with a leading 0 or 1 (this may be
  260. Xextended by hacking Sources/crack-pp.c).
  261. X.IP g)
  262. XDictionary words, forced uppercase, forwards.
  263. X.IP h)
  264. XDictionary words, forced uppercase, backwards.
  265. X.IP i)
  266. XDictionary words forced capitalised, reversed (eg:
  267. X.I desilatipaC ).
  268. X.sp 1v
  269. X.LP
  270. XThis choice of attack is entirely empirical, my own, and made up on the
  271. Xspot.  It is also horrendously successful, and because Crack uses each
  272. Xof these dictionaries in turn, it tends to get passwords faster than a
  273. Xprogram like the
  274. X.B COPS
  275. Xpassword cracker which tries words every-which-way for each user.\**
  276. X.FS
  277. XFor more information, see "Foiling the Cracker: A Survey of, and
  278. XImprovements to, Password Security" by Daniel Klein, available from
  279. X.I "ftp.sei.cmu.edu"
  280. Xin
  281. X.I "~/pub/dvk/passwd.*" .
  282. XAlso, read the
  283. X.C APPENDIX
  284. Xfile supplied with this distribution.
  285. X.FE
  286. X.QP
  287. XOptimisation Note: Crack has an
  288. X.B compile-time
  289. Xoption, called
  290. X.C CRACK_SHORT_PASSWDS ,
  291. Xwhich, if
  292. X.B not
  293. Xdefined, makes the dictionary preprocessor
  294. X.I "throw away"
  295. Xwords which are less than 5 characters long.  The reasoning for this is
  296. Xthat many sites, with a semi-sensible
  297. X.C passwd
  298. Xprogram, will not have passwords shorter than 5 characters long.
  299. X.QP
  300. XIt is up to you whether you bother testing these short passwords, but I
  301. Xwould recommend that you do so at least once, to be safe.  (Setting the
  302. Xoption also leads to having smaller pre-processed dictionaries.  The
  303. Xoption, however, is defined by default).
  304. X.NH 1
  305. XInstallation
  306. X.LP
  307. XCrack is one of those most unusual of beasties, a self-installing
  308. Xprogram.  Once the necessary configuration options have been set, the
  309. Xexecutables are created via
  310. X.C make
  311. Xby running the Crack shellscript .
  312. X.LP
  313. XSome people have complained about this apparent weirdness, but it has
  314. Xgrown up with Crack ever since the earliest network version, when I
  315. Xcould not be bothered to log into several different machines with
  316. Xseveral different architectures, just in order to build the binaries.
  317. X.LP
  318. XDown to the nitty-gritty.  Crack needs to know where it has been
  319. Xinstalled.  You will have to edit the
  320. X.C CRACK_HOME
  321. Xvariable in the Crack shellscript to the correct value.  This variable
  322. Xshould be set to an absolute path name (relative to
  323. X.I ~user
  324. Xshould be OK, so long as you have some sort of
  325. X.C csh )
  326. Xthrough which the directory containing Crack may be accessed on
  327. X.B all
  328. Xthe machines that Crack will be run on. There is a similar variable
  329. X.C CRACK_OUT
  330. Xwhich specifies where Crack should put its output files - by default,
  331. Xthis is the same as
  332. X.C "$CRACK_HOME" .
  333. X.LP
  334. XThe next thing you will have to do is to edit the file
  335. X.C Sources/conf.h
  336. Xand work out which switches to enable.
  337. XEach
  338. X.C #define
  339. Xhas a small note explaining its purpose.  Where I have been in doubt about
  340. Xthe portability of certain library functions, usually I have re-written
  341. Xit, so you should be OK.  Let me know of your problems, if you have any.
  342. X.LP
  343. XOne of the most important switches in the conf.h file is the
  344. X.C CRACK_NETWORK
  345. Xsymbol.  This forces Crack to create all of its output files with an
  346. Xembedded hostname (obtained by the
  347. X.C gethostname()
  348. Xroutine) so that you can keep track of output from all over the network.
  349. XIf you have no
  350. X.C gethostname()
  351. Xbut have a
  352. X.C uname()
  353. Xsystem call, you can use that by defining
  354. X.C CRACK_UNAME
  355. Xin
  356. X.C Sources/conf.h .
  357. X.LP
  358. XIf you will be using
  359. X.C CRACK_NETWORK ,
  360. Xyou will then have to generate a
  361. X.C Scripts/network.conf
  362. Xfile. This contains a list of hostnames to
  363. X.C rsh
  364. Xto, what their
  365. X.I "binary type"
  366. Xis (useful when running a network Crack on several different
  367. Xarchitectures), a guesstimate of their
  368. X.I "relative power"
  369. X(take your slowest machine as unary, and measure all others relative to
  370. Xit), and a list of per-host
  371. X.I flags
  372. Xto
  373. X.B add
  374. Xto those specified on the
  375. X.C Crack
  376. Xcommand line, when calling that host.  There is an example of such a
  377. Xfile provided in the Scripts directory - take a look at it.
  378. X.LP
  379. XIf ever you wish to specify a more precise figure as to the relative
  380. Xpower of your machines, or you are simply at a loss, play with the
  381. Xcommand
  382. X.C "make tests"
  383. Xin the source code directory.  This will provide you with the number of
  384. Xfcrypt()s that your machine can do per second, which is a number that
  385. Xyou can plug into your
  386. X.C network.conf
  387. Xas a measure of your machines' power (after rounding the value to an
  388. Xinteger).
  389. X.NH 1
  390. XCrack Usage
  391. X.LP
  392. X.DS B
  393. X.fi
  394. X.C Crack
  395. X[\c
  396. X.I options ]
  397. X[\c
  398. X.I bindir ]
  399. X.C /etc/passwd
  400. X[...other passwd files]
  401. X.sp 1v
  402. X.C "Crack -network"
  403. X[\c
  404. X.I options ]
  405. X.C /etc/passwd
  406. X[...other passwd files]
  407. X.DE
  408. X.LP
  409. XWhere
  410. X.B bindir
  411. Xis the optional name of the directory where you want the binaries
  412. Xinstalled.  This is useful where you want to be able to run versions of
  413. XCrack on several different architectures. If
  414. X.B bindir
  415. Xdoes not exist, a warning will be issued, and the directory created.
  416. X.QP
  417. XNote:
  418. X.B bindir
  419. Xdefaults to the name
  420. X.C generic
  421. Xif not supplied.
  422. X.QP
  423. X.B "Notes for Yellow Pages (NIS) Users:"
  424. XI have had some queries about how to get Crack running from a YP
  425. Xpassword file.  There are several methods, but by far the simplest is to
  426. Xgenerate a passwd format file by running:-
  427. X.DS B
  428. X.C "ypcat passwd > passwd.yp"
  429. X.DE
  430. Xand then running Crack on this file.
  431. X.NH 1
  432. XOptions
  433. X.IP "\fB-f\fP"
  434. XRuns Crack in
  435. X.I foreground
  436. Xmode, ie: the password cracker is not backgrounded, and messages appear
  437. Xon stdout and stderr as you would expect.  This option is only really
  438. Xuseful for small password files, or when you want to put a wrapper
  439. Xscript around Crack, or after you have been running in feedback mode.
  440. X.IP
  441. XForeground mode is disabled if you try running
  442. X.C "Crack -network -f" ,
  443. Xon the command line, because of the insensibility of
  444. X.C rsh ing
  445. Xto several machines in turn, waiting for each one to finish before
  446. Xcalling the next. However, please read the section about
  447. X.I "Network Cracking without NFS/RFS" ,
  448. Xbelow.
  449. X.IP "\fB-F\fP"
  450. XPuts Crack into
  451. X.I feedback
  452. Xmode, ie: when a run of the password cracker terminates normally, the
  453. Xsoftware writes a list of the DES encrypted passwords which were (or
  454. Xwere not) cracked, into a 
  455. X.I "feedback file" , 
  456. Xnamed
  457. X.C Runtime/fbk.<pid> ,
  458. Xor similar.  When Crack is next invoked with the
  459. X.C "-F"
  460. Xoption, Crack removes from its input all encrypted passwords which can
  461. Xbe found in one of the feedback files, and reports on them immediately. 
  462. XThis prevents Crack from wasting time trying to crack passwords that it
  463. Xhas cracked (or not cracked) before. 
  464. X.IP
  465. XObviously, use of the
  466. X.C "-F"
  467. Xoption is
  468. X.B not
  469. Xrecommended when amendments have been made to the source dictionaries,
  470. Xbecause new words may have been added which would guess someones
  471. Xpassword.  After such amendments have been made, it is recommended that
  472. Xall the preprocessed dictionaries are removed and the feedback files
  473. Xtidied by running
  474. X.C "Scripts/spotless" ,
  475. Xand then a full run should be done.
  476. X.IP
  477. XUse of feedback mode is 
  478. X.B dependent 
  479. Xon defining the symbol
  480. X.C "CRACK_PRINTOUT"
  481. Xin
  482. X.C "Sources/conf.h" .
  483. X.IP
  484. XPlease note that for feedback mode to work properly during network
  485. Xcracks, the
  486. X.C "-F"
  487. Xoption must be specified on the
  488. X.C Crack
  489. X.B "command line"
  490. Xand not in the crack-flags field of the 
  491. X.C Scripts/network.conf
  492. Xfile. If you do not specify
  493. X.C "-F"
  494. Xon the command line, the program will fail to filter unguessable users
  495. Xfrom the input password files, and will therefore waste much time. 
  496. X.IP "\fB-v\fP"
  497. XSets verbose mode, whereby Crack will print every guess it is trying on
  498. Xa per-user basis.  This is a very quick way of flooding your filestore.
  499. XIf you undefine the
  500. X.C CRACK_VERBOSE
  501. Xsymbol in
  502. X.C Sources/conf.h ,
  503. Xverbose mode will be permanently disabled.
  504. X.IP "\fB-nvalue\fP"
  505. XSets the process to be
  506. X.C nice() ed
  507. Xto
  508. X.I value ,
  509. Xso that the switch
  510. X.C \&-n19
  511. Xsets the Crack process to run at the lowest priority.
  512. X.IP "\fB-network\fP"
  513. XThrows Crack into network mode, in which it reads the
  514. X.C Scripts/network.conf
  515. Xfile, splits its input into chunks which are sized according to the
  516. Xpower of the target machine, and calls
  517. X.C rsh
  518. Xto run Crack on that machine.  Options for Crack running on the target
  519. Xmachine may be supplied on the command line (eg: verbose or recover
  520. Xmode), or in the network.conf file if they pertain to specific hosts
  521. X(eg:
  522. X.C nice()
  523. Xvalues).
  524. X.IP "\fB-r<pointfile>\fP"
  525. XThis is only for use when running in
  526. X.I recover
  527. Xmode.  When a running Crack starts pass 2, it periodically saves its
  528. Xstate in a file in the directory
  529. X.C Runtime ,
  530. Xnamed
  531. X.C "pnt.<pid>"
  532. Xor
  533. X.C "pnt.<hostname>.<pid>"
  534. Xdepending on your naming convention (see 
  535. X.I "Installation" , 
  536. Xabove).  This file can be used to recover where you were should a host
  537. Xcrash.  Simply invoke Crack in
  538. X.B exactly
  539. Xthe same manner as the last time, with the addition of the
  540. X.C -rRuntime/pnt.file.name
  541. Xswitch.  Crack will startup and read the file, and jump to slightly
  542. Xbefore where it left off.  If you are cracking a very large password
  543. Xfile, this can save oodles of time after a crash.
  544. X.IP
  545. XIf you are running a
  546. X.I network
  547. XCrack, then the jobs will again be spawned onto all the machines of the
  548. Xoriginal Crack.  The program will then check that the host it is running
  549. Xon is the same as is mentioned in the pointfile.  If it is not, it will
  550. Xsilently die.  Thus, assuming that you supply the same input data and do
  551. Xnot change your
  552. X.C network.conf
  553. Xfile, Crack should pick up
  554. X.B exactly
  555. Xwhere it left off.  This is a bit inelegant, but it's better than
  556. Xnothing at the moment.
  557. X.NH
  558. XSupport Scripts
  559. X.LP
  560. XThe
  561. X.C Scripts
  562. Xdirectory contains a small number of support and utility scripts, some
  563. Xof which are designed to help Crack users check their progress.
  564. XBriefly, the most useful ones are:-
  565. X.IP "\fBScripts/shadmrg\fP"
  566. XThis is a small (but hopefully readable) script for merging
  567. X.C /etc/passwd
  568. Xand
  569. X.C /etc/shadow
  570. Xon System V style shadow password systems.  It produces the merged data
  571. Xto stdout, and will need redirecting into a file before Crack can work
  572. Xon it.  The script is meant to be fairly lucid, on the grounds that I
  573. Xworry that there are many shadowing schemes out there, and perhaps not
  574. Xall have the same data format.
  575. X.IP "\fBScripts/plaster\fP"
  576. Xwhich is named after a dumb joke, but is a simple frontend to the
  577. X.C "Runtime/die.*"
  578. Xscript each copy of the password cracker generates. Invoking
  579. X.C Scripts/plaster
  580. Xwill kill off all copies of the password cracker you are running, over
  581. Xthe network or otherwise.
  582. X.IP "\fBScripts/status\fP"
  583. XThis script
  584. X.C rsh es
  585. Xto each machine mentioned in the
  586. X.C Scripts/network.conf
  587. Xfile, and provides some information about processes and uptime on that
  588. Xmachine.  This is useful when you want to find out just how well your
  589. Xpassword crackers are getting on during a
  590. X.C "Crack -network" .
  591. X.IP "\fBScripts/{clean,spotless}\fP"
  592. XThese are really just frontends to a makefile. Invoking
  593. X.C Scripts/clean
  594. Xtidies up the Crack home directory, and removes probably unwanted files,
  595. Xbut leaves the pre-processed dictionaries intact.
  596. X.C Scripts/spotless
  597. Xdoes the same as
  598. X.C Scripts/clean
  599. Xbut obliterates the preprocessed dictionaries and output files too, and
  600. Xcompresses the feedback files into one. 
  601. X.IP "\fBScripts/guess2fbk\fP"
  602. XOnly useful if CRACK_PRINT is defined. This script takes your
  603. X.C out.*
  604. Xfiles as arguments and reformats the 'Guessed' lines into a slightly
  605. Xmessy
  606. X.I feedback 
  607. Xfile, suitable for storing with the others.
  608. X.IP 
  609. XAn occasion where this might be useful is when your cracker has guessed
  610. Xmany peoples passwords, and then died for some reason before writing out
  611. Xthe guesses to a feedback file. Running
  612. X.sp 1v
  613. X.C "Scripts/guess2fbk out.* > Runtime/fbk.new"
  614. X.sp 1v
  615. Xwill save the work that has been done.
  616. X.NH 1
  617. XMultiprocessing and parallelism
  618. X.LP
  619. XThe method of error recovery outlined above causes headaches for users
  620. Xwho want to do multiprocessing on parallel architectures.  Crack is in
  621. Xno way parallel, and because of the way it's structured, readind stdin
  622. Xfrom shellscript frontends, it is a pain to divide the work amongst
  623. Xseveral processes via
  624. X.C fork() ing.
  625. X.LP
  626. XThe hack solution to get several copies of Crack running on one machine
  627. Xwith
  628. X.I n
  629. Xprocessors at the moment is to run with the
  630. X.C CRACK_NETWORK
  631. Xoption enabled, and insert
  632. X.I n
  633. Xcopies of the entry for your parallel machine into the
  634. X.C Scripts/network.conf
  635. Xfile. If you use the
  636. X.C \&-r
  637. Xoption in these circumstances however, you will get
  638. X.I n
  639. Xcopies of the recovered process running, only one of them will have the
  640. Xcorrect input data.  I'm working on this.  My current solution is to
  641. Xsave the current username in the point file, and test it on
  642. Xstartup, but doing this
  643. X.I may
  644. Xbreak your recovery if you supply different input data (so that the data
  645. Xis sorted even slightly differently).  Hohum.  If you want to use this
  646. X.I "verify username"
  647. Xfacility, use
  648. X.C \&-R
  649. Xin place of
  650. X.C \&-r .
  651. X.LP
  652. XAs for not using the
  653. X.C network.conf
  654. Xfile to provide multiprocessing, I'm
  655. X.I still
  656. Xworking on it.
  657. X.NH 1
  658. XNetwork Cracking without NFS/RFS
  659. X.LP
  660. XFor those users who have some form of 
  661. X.C rsh
  662. Xcommand, but do not have a a networked filestore running between hosts,
  663. Xthere is now a solution which will allow you to do networked cracking,
  664. Xforwarded to me by Brian Tompsett at Hull.  Personally, I consider the
  665. Xidea to be potty, but it fills in missing functionality in a wonderfully
  666. Xtacky manner. 
  667. X.LP
  668. XFrom the documentation above, you will note that Crack will undo the 
  669. X.C "-f"
  670. X.I "(output in foreground)"
  671. Xoption, if it is invoked with the 
  672. X.C "-network" 
  673. Xswitch at the same time (see the 
  674. X.I Options
  675. Xsection above).  This is true, but it does not apply if you specify
  676. X.C "-f"
  677. Xoption in the 
  678. X.C network.conf
  679. Xfile.  
  680. X.LP
  681. XThe practical upshot of doing this is that remote copies of Crack
  682. Xcan be made to read from
  683. X.I stdin
  684. Xand write to 
  685. X.I stdout
  686. Xover a network link, and thus remote processing is accomplished.  I have
  687. Xtweaked Crack in such a way, therefore, that if the 
  688. X.C "-f"
  689. Xoption is specified amongst the crack-flags of a host in the
  690. Xnetwork.conf, rather than backgrounding itself on the remote host, the 
  691. X.C rsh
  692. Xcommand on the 
  693. X.B server
  694. Xis backgrounded, and output is written directly to the files on the
  695. Xserver's filestore.  
  696. X.LP
  697. XThere are restrictions upon this method, mostly involving the number of
  698. Xprocesses that a user may run on the server at any one time, and the
  699. Xfact that if you run in
  700. X.I feedback
  701. Xmode, you will have to collect the feedback output together manually
  702. X(dropping it into the
  703. X.C Runtime
  704. Xdirectory on the server).  However, it works. Also, if you try to use 
  705. X.C rsh
  706. Xas another user, you will suffer problems if
  707. X.C rsh 
  708. Xinsists on reading something from your terminal (eg: a password for the
  709. Xremote account).  Also, checkpointing goes out the window unless you
  710. Xspecify the name of the pointfile on the remote machine. 
  711. X.NH 1
  712. XNotes on fast crypt() implementations
  713. X.LP
  714. XThe stdlib version of the
  715. X.C crypt()
  716. Xsubroutine is incredibly slow.  It is a
  717. X.I massive
  718. Xbottleneck to the execution of Crack and on typical platforms that you
  719. Xget at universities, it is rare to find a machine which will achieve
  720. Xmore than 50 standard
  721. X.C crypt() s
  722. Xper second.  On low-end diskless workstations, you may expect 2 or 3 per
  723. Xsecond.  It was this slowness of the
  724. X.C crypt()
  725. Xalgorithm which originally supplied much of the security
  726. X.UX
  727. Xneeded.\**
  728. X.FS
  729. XSee: "Password Security, A Case History" by Bob Morris & Ken Thomson, in
  730. Xthe
  731. X.UX
  732. XProgrammer Docs.
  733. X.FE
  734. X.LP
  735. XHowever, there are now
  736. X.C many
  737. Ximplementations of faster versions of
  738. X.C crypt()
  739. Xto be found on the network.  The one supplied with Crack v3.2 and
  740. Xupwards is called
  741. X.C fcrypt() .
  742. X.LP
  743. X.C fcrypt()
  744. Xwas originally written in May 1986 by Robert Baldwin at MIT, and is a
  745. Xgood version of the
  746. X.C crypt()
  747. Xsubroutine.  I received a copy from Icarus Sparry at Bath University,
  748. Xwho had made a couple of portability enhancements to the code.
  749. X.LP
  750. XI rewrote most of the tables and the KeySchedule generating algorithm in
  751. Xthe original
  752. X.I fdes-init.c
  753. Xto knock 40% off the execution overhead of
  754. X.C fcrypt()
  755. Xin the form that it was shipped to me.  I inlined a bunch of stuff, put
  756. Xit into a single file, got some advice from Matt Bishop and Bob Baldwin
  757. X[both of whom I am greatly indebted to] about what to do to the
  758. X.C xform()
  759. Xroutine and to the fcrypt function itself, and tidied up some algorithms.
  760. XI have also added more lookup tables and reduced several formula for
  761. Xfaster use.
  762. X.C fcrypt()
  763. Xis now barely recognisable as being based on its former incarnation.
  764. X.LP
  765. XOn a DecStation 5000/200, it is also about 15 times faster than the
  766. Xstandard crypt (your mileage may vary with other architectures and
  767. Xcompilers).  This speed puts
  768. X.C fcrypt()
  769. Xinto the "moderately fast" league of crypt implementations.  By using
  770. X.C fcrypt()
  771. Xwith Crack, I extracted 135 passwords from my standard 1087 user
  772. Xpassword file in a little over 1 hour using 3 networked machines.  This
  773. Xis from a moderately good password file.
  774. X.LP
  775. XWhy am I saying this sort of thing ? Am I scaremongering ? In a word, yes.
  776. X.LP
  777. XIf a fast version of
  778. X.C crypt()
  779. Xis wired into a program like Crack it can break a poorly passworded site
  780. Xopen in minutes.  There are such programs available, eg: the "Killer
  781. XCracker" written by the anonymous "Doctor Dissector", with anonymous
  782. Xmotives.  It comes with a modified version of Baldwin's fcrypt, as a
  783. XMS-DOS executable with a GNU copyleft licence.
  784. X.LP
  785. XThe point that needs to be hammered home is that unless something is
  786. Xdone, and done soon, about the general quality of passwords on
  787. X.UX
  788. Xsystems, then in the near future our doors will be wide open to people
  789. Xwho have programs like Crack and questionable motives.
  790. X.NH 1
  791. XSolutions and Conclusions
  792. X.LP
  793. XWhat can be done about this form of attack ?
  794. X.LP
  795. XYou must get a drop-in replacement for the
  796. X.C passwd
  797. Xand
  798. X.C yppasswd
  799. Xcommands; one which will stop people from choosing bad passwords in the
  800. Xfirst place.  There are several programs to do this; Matt Bishop's
  801. X.C "passwd+"
  802. Xand Clyde Hoover's
  803. X.C "npasswd"
  804. Xprogram are good examples which are freely available.  Consult an
  805. X.B Archie
  806. Xdatabase for more details on where you can get them from.
  807. X.LP
  808. XA little common-sense is all that is required to vet passwords: I
  809. Xenclose a module in the Sources directory
  810. X.I goodpass.c
  811. Xwhich I use in a modified version of the
  812. X.C yppasswd
  813. Xin order to provide some security.  It is quite heavily customised for
  814. Xuse in the UK, but it should be easily portable.  The routine is invoked:
  815. X.sp 1v
  816. X.DS B
  817. X.C "char *retval = GoodPass(char *input);"
  818. X.DE
  819. X.LP
  820. Xwhere
  821. X.C input
  822. Xis the password under test, and
  823. X.C retval
  824. Xwill be set either to NULL (if the password is OK) or to a diagnostic
  825. Xstring which says what is wrong with the password.  It is far less
  826. Xcomplex than a system such as
  827. X.I passwd+ ,
  828. Xbut still effective enough to make a password file (probably) withstand
  829. X.C Crack .
  830. XIt would be nice if an organisation (such as
  831. X.B CERT ?)
  832. Xcould be persuaded to supply skeletons of
  833. X.I sensible
  834. Xpasswd commands for the public good, as well as an archive of security
  835. Xrelated utilities\**
  836. Xon top of the excellent
  837. X.C COPS .
  838. X.FS
  839. X.C COPS
  840. Xis available for anonymous FTP from
  841. X.I "cert.sei.cmu.edu"
  842. X(128.237.253.5) in
  843. X.I ~/cops
  844. X.FE
  845. XHowever, for
  846. X.UX
  847. Xsecurity to improve on a global scale, we will also require pressure on
  848. Xthe vendors, so that programs are written correctly from the beginning.
  849. END_OF_FILE
  850. if test 26560 -ne `wc -c <'Docs/README.ms'`; then
  851.     echo shar: \"'Docs/README.ms'\" unpacked with wrong size!
  852. fi
  853. # end of 'Docs/README.ms'
  854. fi
  855. if test -f 'Sources/crack-fcrypt.c' -a "${1}" != "-c" ; then 
  856.   echo shar: Will not clobber existing file \"'Sources/crack-fcrypt.c'\"
  857. else
  858. echo shar: Extracting \"'Sources/crack-fcrypt.c'\" \(22407 characters\)
  859. sed "s/^X//" >'Sources/crack-fcrypt.c' <<'END_OF_FILE'
  860. X/*
  861. X * This program is copyright (c) Alec Muffett 1991 except for certain
  862. X * portions of code ("crack-fcrypt.c") copyright (c) Robert Baldwin, Icarus
  863. X * Sparry and Alec Muffett.  The author(s) disclaims all responsibility or
  864. X * liability with respect to it's usage or its effect upon hardware or
  865. X * computer systems.  This software is in freely redistributable PROVIDED
  866. X * that this notice remains intact.
  867. X */
  868. X
  869. X/*
  870. X * Misc defs for the fast password transform optimisations.
  871. X */
  872. X
  873. X#include "crack.h"        /* contains switches - AEM */
  874. X
  875. X/*
  876. X * Rename the types for greater convenience ? - This is from original code.
  877. X */
  878. X#define    reg    register
  879. X#define    uns    unsigned
  880. X#define unsb    uns char
  881. X#define    unsl    uns long
  882. X
  883. X/*
  884. X * Types for the different ways to represent DES bit patterns.  Bits are
  885. X * always right justified within fields.  Bits which have lower indices in
  886. X * the NBS spec are stored in the vax bits with less significance (e.g., Bit
  887. X * 1 of NBS spec is stored in the bit with weight 2 ** 0 to the Vax.
  888. X */
  889. X
  890. X#define    obpb1    unsb        /* One bit per byte. */
  891. X#define sbpb6    unsb        /* Six bits per byte, 6 held. */
  892. X#define sbpb6R    unsb        /* Six bits per byte Reversed order, 6 held. */
  893. X#define    sbpb24    unsl        /* Six bits per byte, 24 held. */
  894. X#define    ebpb24    unsl        /* Eight bits per bit, 24 held. */
  895. X#define    fbpb4    unsb        /* Four bits per byte, 4 held. */
  896. X#define    fbpb4R    unsb        /* Four bits per byte Reversed order, 4 held. */
  897. X
  898. X/*
  899. X * The operation (6 * x) is often better optimised as this (for really
  900. X * braindead compilers) - AEM
  901. X */
  902. X
  903. X#ifdef BRAINDEAD6
  904. X#define SIX_TIMES(exprn)        (((exprn) << 2) + ((exprn) << 1))
  905. X#else
  906. X#define SIX_TIMES(exprn)        (6 * (exprn))
  907. X#endif                /* BRAINDEAD6 */
  908. X
  909. X/*
  910. X * Data segment gathered into one place - AEM
  911. X */
  912. X
  913. X/* Try to keep this stuff long aligned - AEM */
  914. Xstatic char iobuf[16];
  915. X
  916. Xstatic obpb1 crypt_block[72];    /* 72 is next multiple of 8 bytes after 66 */
  917. Xstatic sbpb24 KS[32];
  918. Xstatic sbpb24 S0H[64], S1H[64], S2H[64], S3H[64];
  919. Xstatic sbpb24 S4H[64], S5H[64], S6H[64], S7H[64];
  920. Xstatic sbpb24 S0L[64], S1L[64], S2L[64], S3L[64];
  921. Xstatic sbpb24 S4L[64], S5L[64], S6L[64], S7L[64];
  922. Xstatic sbpb24 out96[4];
  923. X
  924. X/*
  925. X * These used to be rather slow and frequently used functions - AEM
  926. X */
  927. X
  928. X#define TF_TO_SIXBIT(tf) \
  929. X    (sbpb24)((tf & 077L) | \
  930. X        ((tf & 07700L) << 2) | \
  931. X        ((tf & 0770000L) << 4) | \
  932. X        ((tf & 077000000L) << 6))
  933. X
  934. X#define SIXBIT_TO_TF(sb) \
  935. X    (ebpb24)((sb & 0x3fL) | \
  936. X        ((sb & 0x3f00L) >> 2) | \
  937. X        ((sb & 0x3f0000L) >> 4) | \
  938. X        ((sb & 0x3f000000L) >> 6))
  939. X/*
  940. X * Start of the real thing
  941. X */
  942. X
  943. Xvoid
  944. Xfsetkey ()
  945. X{
  946. X    /*
  947. X     * This used to be utterly horrendous. It still is, but it's much, much,
  948. X     * smaller... AEM.
  949. X     */
  950. X    static unsb KeyToKS[] =
  951. X    {
  952. X    9, 50, 33, 59, 48, 16, 32, 56, 1, 8, 18, 41, 2, 34, 25, 24,
  953. X    43, 57, 58, 0, 35, 26, 17, 40, 21, 27, 38, 53, 36, 3, 46, 29,
  954. X    4, 52, 22, 28, 60, 20, 37, 62, 14, 19, 44, 13, 12, 61, 54, 30,
  955. X    1, 42, 25, 51, 40, 8, 24, 48, 58, 0, 10, 33, 59, 26, 17, 16,
  956. X    35, 49, 50, 57, 56, 18, 9, 32, 13, 19, 30, 45, 28, 62, 38, 21,
  957. X    27, 44, 14, 20, 52, 12, 29, 54, 6, 11, 36, 5, 4, 53, 46, 22,
  958. X    50, 26, 9, 35, 24, 57, 8, 32, 42, 49, 59, 17, 43, 10, 1, 0,
  959. X    48, 33, 34, 41, 40, 2, 58, 16, 60, 3, 14, 29, 12, 46, 22, 5,
  960. X    11, 28, 61, 4, 36, 27, 13, 38, 53, 62, 20, 52, 19, 37, 30, 6,
  961. X    34, 10, 58, 48, 8, 41, 57, 16, 26, 33, 43, 1, 56, 59, 50, 49,
  962. X    32, 17, 18, 25, 24, 51, 42, 0, 44, 54, 61, 13, 27, 30, 6, 52,
  963. X    62, 12, 45, 19, 20, 11, 60, 22, 37, 46, 4, 36, 3, 21, 14, 53,
  964. X    18, 59, 42, 32, 57, 25, 41, 0, 10, 17, 56, 50, 40, 43, 34, 33,
  965. X    16, 1, 2, 9, 8, 35, 26, 49, 28, 38, 45, 60, 11, 14, 53, 36,
  966. X    46, 27, 29, 3, 4, 62, 44, 6, 21, 30, 19, 20, 54, 5, 61, 37,
  967. X    2, 43, 26, 16, 41, 9, 25, 49, 59, 1, 40, 34, 24, 56, 18, 17,
  968. X    0, 50, 51, 58, 57, 48, 10, 33, 12, 22, 29, 44, 62, 61, 37, 20,
  969. X    30, 11, 13, 54, 19, 46, 28, 53, 5, 14, 3, 4, 38, 52, 45, 21,
  970. X    51, 56, 10, 0, 25, 58, 9, 33, 43, 50, 24, 18, 8, 40, 2, 1,
  971. X    49, 34, 35, 42, 41, 32, 59, 17, 27, 6, 13, 28, 46, 45, 21, 4,
  972. X    14, 62, 60, 38, 3, 30, 12, 37, 52, 61, 54, 19, 22, 36, 29, 5,
  973. X    35, 40, 59, 49, 9, 42, 58, 17, 56, 34, 8, 2, 57, 24, 51, 50,
  974. X    33, 18, 48, 26, 25, 16, 43, 1, 11, 53, 60, 12, 30, 29, 5, 19,
  975. X    61, 46, 44, 22, 54, 14, 27, 21, 36, 45, 38, 3, 6, 20, 13, 52,
  976. X    56, 32, 51, 41, 1, 34, 50, 9, 48, 26, 0, 59, 49, 16, 43, 42,
  977. X    25, 10, 40, 18, 17, 8, 35, 58, 3, 45, 52, 4, 22, 21, 60, 11,
  978. X    53, 38, 36, 14, 46, 6, 19, 13, 28, 37, 30, 62, 61, 12, 5, 44,
  979. X    40, 16, 35, 25, 50, 18, 34, 58, 32, 10, 49, 43, 33, 0, 56, 26,
  980. X    9, 59, 24, 2, 1, 57, 48, 42, 54, 29, 36, 19, 6, 5, 44, 62,
  981. X    37, 22, 20, 61, 30, 53, 3, 60, 12, 21, 14, 46, 45, 27, 52, 28,
  982. X    24, 0, 48, 9, 34, 2, 18, 42, 16, 59, 33, 56, 17, 49, 40, 10,
  983. X    58, 43, 8, 51, 50, 41, 32, 26, 38, 13, 20, 3, 53, 52, 28, 46,
  984. X    21, 6, 4, 45, 14, 37, 54, 44, 27, 5, 61, 30, 29, 11, 36, 12,
  985. X    8, 49, 32, 58, 18, 51, 2, 26, 0, 43, 17, 40, 1, 33, 24, 59,
  986. X    42, 56, 57, 35, 34, 25, 16, 10, 22, 60, 4, 54, 37, 36, 12, 30,
  987. X    5, 53, 19, 29, 61, 21, 38, 28, 11, 52, 45, 14, 13, 62, 20, 27,
  988. X    57, 33, 16, 42, 2, 35, 51, 10, 49, 56, 1, 24, 50, 17, 8, 43,
  989. X    26, 40, 41, 48, 18, 9, 0, 59, 6, 44, 19, 38, 21, 20, 27, 14,
  990. X    52, 37, 3, 13, 45, 5, 22, 12, 62, 36, 29, 61, 60, 46, 4, 11,
  991. X    41, 17, 0, 26, 51, 48, 35, 59, 33, 40, 50, 8, 34, 1, 57, 56,
  992. X    10, 24, 25, 32, 2, 58, 49, 43, 53, 28, 3, 22, 5, 4, 11, 61,
  993. X    36, 21, 54, 60, 29, 52, 6, 27, 46, 20, 13, 45, 44, 30, 19, 62,
  994. X    25, 1, 49, 10, 35, 32, 48, 43, 17, 24, 34, 57, 18, 50, 41, 40,
  995. X    59, 8, 9, 16, 51, 42, 33, 56, 37, 12, 54, 6, 52, 19, 62, 45,
  996. X    20, 5, 38, 44, 13, 36, 53, 11, 30, 4, 60, 29, 28, 14, 3, 46,
  997. X    17, 58, 41, 2, 56, 24, 40, 35, 9, 16, 26, 49, 10, 42, 33, 32,
  998. X    51, 0, 1, 8, 43, 34, 25, 48, 29, 4, 46, 61, 44, 11, 54, 37,
  999. X    12, 60, 30, 36, 5, 28, 45, 3, 22, 27, 52, 21, 20, 6, 62, 38
  1000. X    };
  1001. X
  1002. X    reg int i;
  1003. X    reg int j;
  1004. X    reg int r;
  1005. X    reg unsb *k;
  1006. X
  1007. X    k = KeyToKS;
  1008. X
  1009. X    for (i = 0; i < 32; i++)    /* loops cache better ? - AEM */
  1010. X    {
  1011. X    r = 0;
  1012. X    for (j = 0; j < 24; j++)
  1013. X    {
  1014. X        r |= crypt_block[*(k++)] << j;
  1015. X    }
  1016. X    KS[i] = TF_TO_SIXBIT (r);
  1017. X    }
  1018. X}
  1019. X
  1020. Xvoid
  1021. XXForm (saltvalue)
  1022. X    sbpb24 saltvalue;
  1023. X{
  1024. X    union
  1025. X    {
  1026. X    sbpb24 b[2];
  1027. X    sbpb6 c[8];
  1028. X    } sdata;
  1029. X
  1030. X    /*
  1031. X     * Icarus Sparry, Bath - mod AEM
  1032. X     */
  1033. X
  1034. X#ifdef BIG_ENDIAN
  1035. X#define STEP --
  1036. X#define START &sdata.c[7]
  1037. X#define Dl sdata.b[1]
  1038. X#define Dh sdata.b[0]
  1039. X#else                /* LITTLE_ENDIAN */
  1040. X#define STEP ++
  1041. X#define START &sdata.c[0]
  1042. X#define Dl sdata.b[0]
  1043. X#define Dh sdata.b[1]
  1044. X#endif
  1045. X
  1046. X    /*
  1047. X     * Thanks to Matt Bishop for this idea... AEM.
  1048. X     */
  1049. X
  1050. X#ifndef FDES_4BYTE
  1051. X#define SIZEFIX        0
  1052. X#define INDIRECT(a,b)     (a)[b]
  1053. X#else
  1054. X#define SIZEFIX        2    /* "n" where 2^n == sizeof(sbpb24) */
  1055. X#define INDIRECT(a,b)     (*((sbpb24 *)(((unsigned char *) a) + (b))))
  1056. X#endif
  1057. X
  1058. X    reg sbpb24 Rl;
  1059. X    reg sbpb24 Rh;
  1060. X    reg sbpb24 Ll;
  1061. X    reg sbpb24 Lh;
  1062. X    reg sbpb6 *dp;
  1063. X
  1064. X    int loop;
  1065. X    reg sbpb24 k;
  1066. X    sbpb24 *kp;
  1067. X    sbpb24 *kend;
  1068. X#ifdef FDES_8BYTE
  1069. X    reg sbpb24 tmpi;
  1070. X#endif    /* FDES_8BYTE */
  1071. X
  1072. X    Ll = Lh = Rl = Rh = 0;
  1073. X
  1074. X    kend = &KS[32];
  1075. X
  1076. X    for (loop = 25; loop-- > 0; /* nothing */ )
  1077. X    {
  1078. X    for (kp = KS; kp < kend; /* nothing */ )
  1079. X    {
  1080. X        /*
  1081. X         * Oddly enough, direct addressing of dp slows things down, as
  1082. X         * well as knackering portability - AEM
  1083. X         */
  1084. X
  1085. X        k = (Rl ^ Rh) & saltvalue;
  1086. X#ifndef FDES_8BYTE
  1087. X        Dl = (k ^ Rl ^ *kp++) << SIZEFIX;
  1088. X        Dh = (k ^ Rh ^ *kp++) << SIZEFIX;
  1089. X#else
  1090. X        /* hack to make things work better - matthew kaufman */
  1091. X        /* I haven't tried any of this - I don't have a cray... AEM */
  1092. X        tmpi = (k ^ Rl ^ *kp++);
  1093. X        sdata.c[3] = (tmpi >> 24) & 0x00ff;
  1094. X        sdata.c[2] = (tmpi >> 16) & 0x00ff;
  1095. X        sdata.c[1] = (tmpi >> 8) & 0x00ff;
  1096. X        sdata.c[0] = (tmpi) & 0x00ff;
  1097. X        tmpi = (k ^ Rh ^ *kp++);
  1098. X        sdata.c[7] = (tmpi >> 24) & 0x00ff;
  1099. X        sdata.c[6] = (tmpi >> 16) & 0x00ff;
  1100. X        sdata.c[5] = (tmpi >> 8) & 0x00ff;
  1101. X        sdata.c[4] = (tmpi) & 0x00ff;
  1102. X#endif    /* FDES_8BYTE */
  1103. X
  1104. X        dp = START;
  1105. X        Lh ^= INDIRECT (S0H, *dp);
  1106. X        Ll ^= INDIRECT (S0L, *dp STEP);
  1107. X        Lh ^= INDIRECT (S1H, *dp);
  1108. X        Ll ^= INDIRECT (S1L, *dp STEP);
  1109. X        Lh ^= INDIRECT (S2H, *dp);
  1110. X        Ll ^= INDIRECT (S2L, *dp STEP);
  1111. X        Lh ^= INDIRECT (S3H, *dp);
  1112. X        Ll ^= INDIRECT (S3L, *dp STEP);
  1113. X        Lh ^= INDIRECT (S4H, *dp);
  1114. X        Ll ^= INDIRECT (S4L, *dp STEP);
  1115. X        Lh ^= INDIRECT (S5H, *dp);
  1116. X        Ll ^= INDIRECT (S5L, *dp STEP);
  1117. X        Lh ^= INDIRECT (S6H, *dp);
  1118. X        Ll ^= INDIRECT (S6L, *dp STEP);
  1119. X        Lh ^= INDIRECT (S7H, *dp);
  1120. X        Ll ^= INDIRECT (S7L, *dp STEP);
  1121. X
  1122. X        k = (Ll ^ Lh) & saltvalue;
  1123. X#ifndef FDES_8BYTE
  1124. X        Dl = (k ^ Ll ^ *kp++) << SIZEFIX;
  1125. X        Dh = (k ^ Lh ^ *kp++) << SIZEFIX;
  1126. X#else
  1127. X        tmpi = (k ^ Ll ^ *kp++);
  1128. X        sdata.c[3] = (tmpi >> 24) & 0x00ff;
  1129. X        sdata.c[2] = (tmpi >> 16) & 0x00ff;
  1130. X        sdata.c[1] = (tmpi >> 8) & 0x00ff;
  1131. X        sdata.c[0] = (tmpi) & 0x00ff;
  1132. X        tmpi = (k ^ Lh ^ *kp++);
  1133. X        sdata.c[7] = (tmpi >> 24) & 0x00ff;
  1134. X        sdata.c[6] = (tmpi >> 16) & 0x00ff;
  1135. X        sdata.c[5] = (tmpi >> 8) & 0x00ff;
  1136. X        sdata.c[4] = (tmpi) & 0x00ff;
  1137. X#endif    /* FDES_8BYTE */
  1138. X
  1139. X        dp = START;
  1140. X        Rh ^= INDIRECT (S0H, *dp);
  1141. X        Rl ^= INDIRECT (S0L, *dp STEP);
  1142. X        Rh ^= INDIRECT (S1H, *dp);
  1143. X        Rl ^= INDIRECT (S1L, *dp STEP);
  1144. X        Rh ^= INDIRECT (S2H, *dp);
  1145. X        Rl ^= INDIRECT (S2L, *dp STEP);
  1146. X        Rh ^= INDIRECT (S3H, *dp);
  1147. X        Rl ^= INDIRECT (S3L, *dp STEP);
  1148. X        Rh ^= INDIRECT (S4H, *dp);
  1149. X        Rl ^= INDIRECT (S4L, *dp STEP);
  1150. X        Rh ^= INDIRECT (S5H, *dp);
  1151. X        Rl ^= INDIRECT (S5L, *dp STEP);
  1152. X        Rh ^= INDIRECT (S6H, *dp);
  1153. X        Rl ^= INDIRECT (S6L, *dp STEP);
  1154. X        Rh ^= INDIRECT (S7H, *dp);
  1155. X        Rl ^= INDIRECT (S7L, *dp STEP);
  1156. X    }
  1157. X
  1158. X    Ll ^= Rl;
  1159. X    Lh ^= Rh;
  1160. X    Rl ^= Ll;
  1161. X    Rh ^= Lh;
  1162. X    Ll ^= Rl;
  1163. X    Lh ^= Rh;
  1164. X    }
  1165. X
  1166. X    /*
  1167. X     * for reasons that I cannot explain, if I insert the contents of the
  1168. X     * UnXForm function right HERE, making the tweaks as necessary to avoid
  1169. X     * using out96[] to pass data, I LOSE 30% of my speed.  I don't know why.
  1170. X     * Hence, I continue to use out96[]...
  1171. X     */
  1172. X    {
  1173. X    reg sbpb24 *qp;
  1174. X    qp = out96;
  1175. X    *qp++ = Ll;
  1176. X    *qp++ = Lh;
  1177. X    *qp++ = Rl;
  1178. X    *qp++ = Rh;
  1179. X    }
  1180. X}
  1181. X
  1182. Xvoid
  1183. XUnXForm ()
  1184. X{
  1185. X    reg obpb1 *ptr;
  1186. X    reg sbpb24 Rl;
  1187. X    reg sbpb24 Rh;
  1188. X    reg sbpb24 Ll;
  1189. X    reg sbpb24 Lh;
  1190. X
  1191. X    Ll = SIXBIT_TO_TF (out96[0]);
  1192. X    Lh = SIXBIT_TO_TF (out96[1]);
  1193. X    Rl = SIXBIT_TO_TF (out96[2]);
  1194. X    Rh = SIXBIT_TO_TF (out96[3]);
  1195. X    ptr = crypt_block;
  1196. X
  1197. X    *(ptr++) = Rl & 0x000400L ? 0x01 : 0;
  1198. X    *(ptr++) = Ll & 0x000400L ? 0x01 : 0;
  1199. X    *(ptr++) = Rl & 0x400000L ? 0x01 : 0;
  1200. X    *(ptr++) = Ll & 0x400000L ? 0x01 : 0;
  1201. X    *(ptr++) = Rh & 0x000400L ? 0x01 : 0;
  1202. X    *(ptr++) = Lh & 0x000400L ? 0x01 : 0;
  1203. X    *(ptr++) = Rh & 0x400000L ? 0x01 : 0;
  1204. X    *(ptr++) = Lh & 0x400000L ? 0x01 : 0;
  1205. X    *(ptr++) = Rl & 0x000200L ? 0x01 : 0;
  1206. X    *(ptr++) = Ll & 0x000200L ? 0x01 : 0;
  1207. X    *(ptr++) = Rl & 0x200000L ? 0x01 : 0;
  1208. X    *(ptr++) = Ll & 0x200000L ? 0x01 : 0;
  1209. X    *(ptr++) = Rh & 0x000200L ? 0x01 : 0;
  1210. X    *(ptr++) = Lh & 0x000200L ? 0x01 : 0;
  1211. X    *(ptr++) = Rh & 0x200000L ? 0x01 : 0;
  1212. X    *(ptr++) = Lh & 0x200000L ? 0x01 : 0;
  1213. X    *(ptr++) = Rl & 0x000100L ? 0x01 : 0;
  1214. X    *(ptr++) = Ll & 0x000100L ? 0x01 : 0;
  1215. X    *(ptr++) = Rl & 0x100000L ? 0x01 : 0;
  1216. X    *(ptr++) = Ll & 0x100000L ? 0x01 : 0;
  1217. X    *(ptr++) = Rh & 0x000100L ? 0x01 : 0;
  1218. X    *(ptr++) = Lh & 0x000100L ? 0x01 : 0;
  1219. X    *(ptr++) = Rh & 0x100000L ? 0x01 : 0;
  1220. X    *(ptr++) = Lh & 0x100000L ? 0x01 : 0;
  1221. X    *(ptr++) = Rl & 0x000080L ? 0x01 : 0;
  1222. X    *(ptr++) = Ll & 0x000080L ? 0x01 : 0;
  1223. X    *(ptr++) = Rl & 0x080000L ? 0x01 : 0;
  1224. X    *(ptr++) = Ll & 0x080000L ? 0x01 : 0;
  1225. X    *(ptr++) = Rh & 0x000080L ? 0x01 : 0;
  1226. X    *(ptr++) = Lh & 0x000080L ? 0x01 : 0;
  1227. X    *(ptr++) = Rh & 0x080000L ? 0x01 : 0;
  1228. X    *(ptr++) = Lh & 0x080000L ? 0x01 : 0;
  1229. X    *(ptr++) = Rl & 0x000010L ? 0x01 : 0;
  1230. X    *(ptr++) = Ll & 0x000010L ? 0x01 : 0;
  1231. X    *(ptr++) = Rl & 0x010000L ? 0x01 : 0;
  1232. X    *(ptr++) = Ll & 0x010000L ? 0x01 : 0;
  1233. X    *(ptr++) = Rh & 0x000010L ? 0x01 : 0;
  1234. X    *(ptr++) = Lh & 0x000010L ? 0x01 : 0;
  1235. X    *(ptr++) = Rh & 0x010000L ? 0x01 : 0;
  1236. X    *(ptr++) = Lh & 0x010000L ? 0x01 : 0;
  1237. X    *(ptr++) = Rl & 0x000008L ? 0x01 : 0;
  1238. X    *(ptr++) = Ll & 0x000008L ? 0x01 : 0;
  1239. X    *(ptr++) = Rl & 0x008000L ? 0x01 : 0;
  1240. X    *(ptr++) = Ll & 0x008000L ? 0x01 : 0;
  1241. X    *(ptr++) = Rh & 0x000008L ? 0x01 : 0;
  1242. X    *(ptr++) = Lh & 0x000008L ? 0x01 : 0;
  1243. X    *(ptr++) = Rh & 0x008000L ? 0x01 : 0;
  1244. X    *(ptr++) = Lh & 0x008000L ? 0x01 : 0;
  1245. X    *(ptr++) = Rl & 0x000004L ? 0x01 : 0;
  1246. X    *(ptr++) = Ll & 0x000004L ? 0x01 : 0;
  1247. X    *(ptr++) = Rl & 0x004000L ? 0x01 : 0;
  1248. X    *(ptr++) = Ll & 0x004000L ? 0x01 : 0;
  1249. X    *(ptr++) = Rh & 0x000004L ? 0x01 : 0;
  1250. X    *(ptr++) = Lh & 0x000004L ? 0x01 : 0;
  1251. X    *(ptr++) = Rh & 0x004000L ? 0x01 : 0;
  1252. X    *(ptr++) = Lh & 0x004000L ? 0x01 : 0;
  1253. X    *(ptr++) = Rl & 0x000002L ? 0x01 : 0;
  1254. X    *(ptr++) = Ll & 0x000002L ? 0x01 : 0;
  1255. X    *(ptr++) = Rl & 0x002000L ? 0x01 : 0;
  1256. X    *(ptr++) = Ll & 0x002000L ? 0x01 : 0;
  1257. X    *(ptr++) = Rh & 0x000002L ? 0x01 : 0;
  1258. X    *(ptr++) = Lh & 0x000002L ? 0x01 : 0;
  1259. X    *(ptr++) = Rh & 0x002000L ? 0x01 : 0;
  1260. X    *ptr = Lh & 0x002000L ? 0x01 : 0;
  1261. X}
  1262. X
  1263. Xchar *
  1264. Xfcrypt (pw, salt)
  1265. X    char *pw;
  1266. X    char *salt;
  1267. X{
  1268. X    /* Table lookups for salts reduce fcrypt() overhead dramatically */
  1269. X    static sbpb24 salt0[] =
  1270. X    {
  1271. X    18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
  1272. X    34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
  1273. X    50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 0, 1,
  1274. X    2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10,
  1275. X    11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
  1276. X    27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 32, 33, 34, 35, 36,
  1277. X    37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
  1278. X    53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 0, 1, 2, 3, 4,
  1279. X    5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
  1280. X    21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
  1281. X    37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
  1282. X    53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 0, 1, 2, 3, 4,
  1283. X    5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
  1284. X    21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
  1285. X    37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
  1286. X    53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 0, 1, 2, 3, 4
  1287. X    };
  1288. X    static sbpb24 salt1[] =
  1289. X    {
  1290. X    1152, 1216, 1280, 1344, 1408, 1472, 1536, 1600,
  1291. X    1664, 1728, 1792, 1856, 1920, 1984, 2048, 2112,
  1292. X    2176, 2240, 2304, 2368, 2432, 2496, 2560, 2624,
  1293. X    2688, 2752, 2816, 2880, 2944, 3008, 3072, 3136,
  1294. X    3200, 3264, 3328, 3392, 3456, 3520, 3584, 3648,
  1295. X    3712, 3776, 3840, 3904, 3968, 4032, 0, 64,
  1296. X    128, 192, 256, 320, 384, 448, 512, 576,
  1297. X    640, 704, 320, 384, 448, 512, 576, 640,
  1298. X    704, 768, 832, 896, 960, 1024, 1088, 1152,
  1299. X    1216, 1280, 1344, 1408, 1472, 1536, 1600, 1664,
  1300. X    1728, 1792, 1856, 1920, 1984, 2048, 2112, 2176,
  1301. X    2240, 2304, 2368, 2048, 2112, 2176, 2240, 2304,
  1302. X    2368, 2432, 2496, 2560, 2624, 2688, 2752, 2816,
  1303. X    2880, 2944, 3008, 3072, 3136, 3200, 3264, 3328,
  1304. X    3392, 3456, 3520, 3584, 3648, 3712, 3776, 3840,
  1305. X    3904, 3968, 4032, 0, 64, 128, 192, 256,
  1306. X    320, 384, 448, 512, 576, 640, 704, 768,
  1307. X    832, 896, 960, 1024, 1088, 1152, 1216, 1280,
  1308. X    1344, 1408, 1472, 1536, 1600, 1664, 1728, 1792,
  1309. X    1856, 1920, 1984, 2048, 2112, 2176, 2240, 2304,
  1310. X    2368, 2432, 2496, 2560, 2624, 2688, 2752, 2816,
  1311. X    2880, 2944, 3008, 3072, 3136, 3200, 3264, 3328,
  1312. X    3392, 3456, 3520, 3584, 3648, 3712, 3776, 3840,
  1313. X    3904, 3968, 4032, 0, 64, 128, 192, 256,
  1314. X    320, 384, 448, 512, 576, 640, 704, 768,
  1315. X    832, 896, 960, 1024, 1088, 1152, 1216, 1280,
  1316. X    1344, 1408, 1472, 1536, 1600, 1664, 1728, 1792,
  1317. X    1856, 1920, 1984, 2048, 2112, 2176, 2240, 2304,
  1318. X    2368, 2432, 2496, 2560, 2624, 2688, 2752, 2816,
  1319. X    2880, 2944, 3008, 3072, 3136, 3200, 3264, 3328,
  1320. X    3392, 3456, 3520, 3584, 3648, 3712, 3776, 3840,
  1321. X    3904, 3968, 4032, 0, 64, 128, 192, 256
  1322. X    };
  1323. X
  1324. X    /* final perutation desalting */
  1325. X    static obpb1 final[] =
  1326. X    {
  1327. X    46, 47, 48, 49, 50, 51, 52, 53,
  1328. X    54, 55, 56, 57, 65, 66, 67, 68,
  1329. X    69, 70, 71, 72, 73, 74, 75, 76,
  1330. X    77, 78, 79, 80, 81, 82, 83, 84,
  1331. X    85, 86, 87, 88, 89, 90, 97, 98,
  1332. X    99, 100, 101, 102, 103, 104, 105, 106,
  1333. X    107, 108, 109, 110, 111, 112, 113, 114,
  1334. X    115, 116, 117, 118, 119, 120, 121, 122,
  1335. X    123, 124, 125, 126, 127, 128, 129, 130,
  1336. X    131, 132, 133, 134, 135, 136, 137, 138,
  1337. X    139, 140, 141, 142, 143, 144, 145, 146,
  1338. X    147, 148, 149, 150, 151, 152, 153, 154,
  1339. X    155, 156, 157, 158, 159, 160, 161, 162,
  1340. X    163, 164, 165, 166, 167, 168, 169, 170,
  1341. X    171, 172, 173, 174, 175, 176, 177, 178,
  1342. X    179, 180, 181, 182, 183, 184, 185, 186,
  1343. X    187, 188, 189, 190, 191, 192, 193, 194,
  1344. X    195, 196, 197, 198, 199, 200, 201, 202,
  1345. X    203, 204, 205, 206, 207, 208, 209, 210,
  1346. X    211, 212, 213, 214, 215, 216, 217, 218,
  1347. X    219, 220, 221, 222, 223, 224, 225, 226,
  1348. X    227, 228, 229, 230, 231, 232, 233, 234,
  1349. X    235, 236, 237, 238, 239, 240, 241, 242,
  1350. X    243, 244, 245, 246, 247, 248, 249, 250,
  1351. X    251, 252, 253, 254, 255,
  1352. X    /* Truncate overflow bits at 256 */
  1353. X    0, 1, 2, 3, 4, 5, 6, 7,
  1354. X    8, 9, 10, 11, 12, 13, 14, 15,
  1355. X    16, 17, 18, 19, 20, 21, 22, 23,
  1356. X    24, 25, 26, 27, 28, 29, 30, 31,
  1357. X    32, 33, 34, 35, 36, 37, 38, 39,
  1358. X    40, 41, 42, 43, 44, 45, 46, 47,
  1359. X    48, 49, 50, 51, 52, 53, 54, 55,
  1360. X    56, 57, 58
  1361. X    };
  1362. X
  1363. X    reg int i, j, k;
  1364. X    reg long int *lip;
  1365. X    sbpb24 saltvalue;
  1366. X
  1367. X#ifdef BUILTIN_CLEAR
  1368. X    lip = (long int *) crypt_block;
  1369. X    for (i = (sizeof (crypt_block) / sizeof (long int)); i > 0; i--)
  1370. X    {
  1371. X    *(lip++) = 0L;
  1372. X    }
  1373. X#else                /* BUILTIN_CLEAR */
  1374. X#ifdef BZERO
  1375. X    bzero (crypt_block, 66);
  1376. X#else                /* BZERO */
  1377. X    for (i = 0; i < 66; i++)
  1378. X    {
  1379. X    crypt_block[i] = '\0';
  1380. X    }
  1381. X#endif                /* BZERO */
  1382. X#endif                /* BUILTIN_CLEAR */
  1383. X
  1384. X    for (i = 0; (k = *pw) && i < 64; pw++)
  1385. X    {
  1386. X    crypt_block[i++] = (k >> 6) & 01;
  1387. X    crypt_block[i++] = (k >> 5) & 01;
  1388. X    crypt_block[i++] = (k >> 4) & 01;
  1389. X    crypt_block[i++] = (k >> 3) & 01;
  1390. X    crypt_block[i++] = (k >> 2) & 01;
  1391. X    crypt_block[i++] = (k >> 1) & 01;
  1392. X    crypt_block[i++] = (k >> 0) & 01;
  1393. X    i++;            /* have to skip one here (parity bit) */
  1394. X    }
  1395. X
  1396. X    fsetkey ( /* crypt_block */ );
  1397. X
  1398. X#ifdef BUILTIN_CLEAR
  1399. X    lip = (long int *) crypt_block;
  1400. X    for (i = (sizeof (crypt_block) / sizeof (long int)); i > 0; i--)
  1401. X    {
  1402. X    *(lip++) = 0L;
  1403. X    }
  1404. X#else                /* BUILTIN_CLEAR */
  1405. X#ifdef BZERO
  1406. X    bzero (crypt_block, 66);
  1407. X#else                /* BZERO */
  1408. X    for (i = 0; i < 66; i++)
  1409. X    {
  1410. X    crypt_block[i] = '\0';
  1411. X    }
  1412. X#endif                /* BZERO */
  1413. X#endif                /* BUILTIN_CLEAR */
  1414. X
  1415. X    iobuf[0] = salt[0];
  1416. X    iobuf[1] = salt[1];
  1417. X
  1418. X    saltvalue = salt0[iobuf[0]] | salt1[iobuf[1]];
  1419. X    saltvalue = TF_TO_SIXBIT (saltvalue);
  1420. X
  1421. X    XForm (saltvalue);
  1422. X    UnXForm ();
  1423. X
  1424. X    for (i = 0; i < 11; i++)
  1425. X    {
  1426. X    k = 0;
  1427. X
  1428. X    for (j = 0; j < 6; j++)
  1429. X    {
  1430. X        k = (k << 1) | crypt_block[SIX_TIMES (i) + j];
  1431. X    }
  1432. X    iobuf[i + 2] = final[k];
  1433. X    }
  1434. X
  1435. X    iobuf[i + 2] = 0;
  1436. X
  1437. X    if (iobuf[1] == 0)
  1438. X    {
  1439. X    iobuf[1] = iobuf[0];
  1440. X    }
  1441. X    return (iobuf);
  1442. X}
  1443. X/********* INITIALISATION ROUTINES *********/
  1444. X
  1445. Xfbpb4
  1446. XlookupS (tableno, t6bits)
  1447. X    unsl tableno;
  1448. X    sbpb6R t6bits;
  1449. X{
  1450. X    static fbpb4R S[8][64] =
  1451. X    {
  1452. X    14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
  1453. X    0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
  1454. X    4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
  1455. X    15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13,
  1456. X
  1457. X    15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10,
  1458. X    3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5,
  1459. X    0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
  1460. X    13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9,
  1461. X
  1462. X    10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8,
  1463. X    13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1,
  1464. X    13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7,
  1465. X    1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12,
  1466. X
  1467. X    7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
  1468. X    13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9,
  1469. X    10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4,
  1470. X    3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14,
  1471. X
  1472. X    2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
  1473. X    14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6,
  1474. X    4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
  1475. X    11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3,
  1476. X
  1477. X    12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11,
  1478. X    10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8,
  1479. X    9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
  1480. X    4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13,
  1481. X
  1482. X    4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
  1483. X    13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6,
  1484. X    1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
  1485. X    6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12,
  1486. X
  1487. X    13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7,
  1488. X    1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2,
  1489. X    7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
  1490. X    2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11,
  1491. X    };
  1492. X    sbpb6 fixed6bits;
  1493. X    fbpb4R r;
  1494. X    fbpb4 fixedr;
  1495. X
  1496. X    fixed6bits = (((t6bits >> 0) & 01) << 5) +
  1497. X    (((t6bits >> 1) & 01) << 3) +
  1498. X    (((t6bits >> 2) & 01) << 2) +
  1499. X    (((t6bits >> 3) & 01) << 1) +
  1500. X    (((t6bits >> 4) & 01) << 0) +
  1501. X    (((t6bits >> 5) & 01) << 4);
  1502. X
  1503. X    r = S[tableno][fixed6bits];
  1504. X
  1505. X    fixedr = (((r >> 3) & 01) << 0) +
  1506. X    (((r >> 2) & 01) << 1) +
  1507. X    (((r >> 1) & 01) << 2) +
  1508. X    (((r >> 0) & 01) << 3);
  1509. X
  1510. X    return (fixedr);
  1511. X}
  1512. X
  1513. Xvoid
  1514. Xinit (tableno, lowptr, highptr)
  1515. X    unsl tableno;
  1516. X    sbpb24 *lowptr, *highptr;
  1517. X{
  1518. X
  1519. X    static unsb P[] =
  1520. X    {
  1521. X    15, 6, 19, 20,
  1522. X    28, 11, 27, 16,
  1523. X    0, 14, 22, 25,
  1524. X    4, 17, 30, 9,
  1525. X    1, 7, 23, 13,
  1526. X    31, 26, 2, 8,
  1527. X    18, 12, 29, 5,
  1528. X    21, 10, 3, 24,
  1529. X    };
  1530. X
  1531. X    static unsb E[] =
  1532. X    {
  1533. X    31, 0, 1, 2, 3, 4,
  1534. X    3, 4, 5, 6, 7, 8,
  1535. X    7, 8, 9, 10, 11, 12,
  1536. X    11, 12, 13, 14, 15, 16,
  1537. X    15, 16, 17, 18, 19, 20,
  1538. X    19, 20, 21, 22, 23, 24,
  1539. X    23, 24, 25, 26, 27, 28,
  1540. X    27, 28, 29, 30, 31, 0,
  1541. X    };
  1542. X
  1543. X    static obpb1 tmp32[32];
  1544. X    static obpb1 tmpP32[32];
  1545. X    static obpb1 tmpE[48];
  1546. X
  1547. X    int j, k, i;
  1548. X    int tablenoX4;
  1549. X    reg sbpb24 spare24;
  1550. X
  1551. X    tablenoX4 = tableno * 4;
  1552. X
  1553. X    for (j = 0; j < 64; j++)
  1554. X    {
  1555. X    k = lookupS (tableno, j);
  1556. X
  1557. X    for (i = 0; i < 32; i++)
  1558. X    {
  1559. X        tmp32[i] = 0;
  1560. X    }
  1561. X    for (i = 0; i < 4; i++)
  1562. X    {
  1563. X        tmp32[tablenoX4 + i] = (k >> i) & 01;
  1564. X    }
  1565. X    for (i = 0; i < 32; i++)
  1566. X    {
  1567. X        tmpP32[i] = tmp32[P[i]];
  1568. X    }
  1569. X    for (i = 0; i < 48; i++)
  1570. X    {
  1571. X        tmpE[i] = tmpP32[E[i]];
  1572. X    }
  1573. X
  1574. X    lowptr[j] = 0;
  1575. X    highptr[j] = 0;
  1576. X
  1577. X    for (i = 0; i < 24; i++)
  1578. X    {
  1579. X        lowptr[j] |= tmpE[i] << i;
  1580. X    }
  1581. X    for (k = 0, i = 24; i < 48; i++, k++)
  1582. X    {
  1583. X        highptr[j] |= tmpE[i] << k;
  1584. X    }
  1585. X
  1586. X    spare24 = lowptr[j];    /* to allow for macro expansion */
  1587. X    lowptr[j] = TF_TO_SIXBIT (spare24);
  1588. X    spare24 = highptr[j];    /* to allow for macro expansion */
  1589. X    highptr[j] = TF_TO_SIXBIT (spare24);
  1590. X    }
  1591. X}
  1592. Xinit_des ()
  1593. X{
  1594. X    init (0, S0L, S0H);
  1595. X    init (1, S1L, S1H);
  1596. X    init (2, S2L, S2H);
  1597. X    init (3, S3L, S3H);
  1598. X    init (4, S4L, S4H);
  1599. X    init (5, S5L, S5H);
  1600. X    init (6, S6L, S6H);
  1601. X    init (7, S7L, S7H);
  1602. X}
  1603. END_OF_FILE
  1604. if test 22407 -ne `wc -c <'Sources/crack-fcrypt.c'`; then
  1605.     echo shar: \"'Sources/crack-fcrypt.c'\" unpacked with wrong size!
  1606. fi
  1607. # end of 'Sources/crack-fcrypt.c'
  1608. fi
  1609. echo shar: End of archive 4 \(of 5\).
  1610. cp /dev/null ark4isdone
  1611. MISSING=""
  1612. for I in 1 2 3 4 5 ; do
  1613.     if test ! -f ark${I}isdone ; then
  1614.     MISSING="${MISSING} ${I}"
  1615.     fi
  1616. done
  1617. if test "${MISSING}" = "" ; then
  1618.     echo You have unpacked all 5 archives.
  1619.     rm -f ark[1-9]isdone
  1620. else
  1621.     echo You still need to unpack the following archives:
  1622.     echo "        " ${MISSING}
  1623. fi
  1624. ##  End of shell archive.
  1625. exit 0
  1626. exit 0 # Just in case...
  1627. -- 
  1628. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1629. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1630. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1631. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1632.