Subject: Re: Creating passwds for guests

From: Juergen Christoffel <[email-masked]>
Date: Mon, 16 Jun 1997 23:22:38 +0200

Date: Mon, 16 Jun 1997 10:58:27 -0600 (MDT)
   From: Sean S Coleman <[email-masked]>

   Is there a tool or clever way to create an encrypted passwd to put
   into the ftpgroups file? The only method I can think of right offhand is
   to set a passwd in the password file and copy it to the ftpgroups file?

It's possible in C and easy done in Perl:

sub encrypt  {
  my ($key, $salt) = @_;

  # possible chars for the salt, as specified in "man 3 crypt" 
  $FLAVORS = "abcdefghijklmnopqrstuvwxyz";
  $FLAVORS = $FLAVORS . "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  $FLAVORS = $FLAVORS . "0123456789.//";

  $l = length($FLAVORS);

  srand(time|$$);                       # initialize RNG

  # use salt if supplied, otherwise generate one
  return crypt($key, ($salt || spice()));
}

sub spice {
  # generate a random salt string for crypt
  $n=int(rand($l));             # $n is from [0..$l) now
  $m=int(rand($l));             # $m is from [0..$l) now
  return(substr($FLAVORS, $n, 1) . substr($FLAVORS, $m, 1));
}

Usage: call encrypt with one or two strings, the first one being the
clear text password and the optional second one the so called salt (a
string of at least two chars) to modify the encryption machinery:

while (<STDIN>) {
  chomp($text = $_);
  $result = encrypt($text);
  print "$result\n";
}

The example code is actually part of a web form I offer to our
internal users which they use to generate an encrypted password which
they send me when they ask for a login on our ftp server.

	--jc

-- 
   E-Mail: [email-masked] or one of {ftp,news,[email-masked]
   GMD - German National Research Center for Information Technology

   Superstition brings bad luck. -- Raymond Smullyan

---

From: Sean S Coleman <[email-masked]>
Date: Mon, 16 Jun 1997 10:58:27 -0600 (MDT)

Thanks

Sean Coleman
NIST
Boulder, CO

---

From: Kent Landfield <[email-masked]>
Date: Wed, 18 Jun 1997 22:35:37 -0500 (CDT)

# Date: Mon, 16 Jun 1997 10:58:27 -0600 (MDT)
# From: Sean S Coleman <[email-masked]>
# 
# Is there a tool or clever way to create an encrypted passwd to put
# into the ftpgroups file? The only method I can think of right offhand is
# to set a passwd in the password file and copy it to the ftpgroups file?

I have a utility I put together recently. It will do what you are looking 
for. Here's a help message from it.

usage: privatepw [-c] [-f ftpgroups] [-g group] accessgroup
       privatepw [-d] [-f ftpgroups] accessgroup
       privatepw [-l] [-f ftpgroups]
            -c:           creates a new ftpgroups file.
            -d:           deletes specified accessgroup.
            -l:           list contents of ftpgroups file.
            -f ftpgroups: updates the specified file.
            -g group:     set real group to the specified group.

There is more information on it in the Resource Center at

	http://www.landfield.com/wu-ftpd/privatepw/

Sources can be retrieved from there or from 

	ftp://ftp.landfield.com/wu-ftpd/privatepw/

Enjoy.

-- 
Kent Landfield                        Phone: 1-817-545-2502             
The Landfield Group                   FAX:   1-817-545-7650             
Email: [email-masked]             http://www.landfield.com/
Please send comp.sources.misc related mail to [email-masked].
Search the Usenet Hypertext FAQ Archive at http://www.faqs.org/faqs/