Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Looking for c source code to generate cvs passwords



On Tue, May 01, 2001 at 05:16:34AM -0700, Jake Morrison wrote:
> Yes, the passwords stored in .cvslogin are trivially 
> encoded, as they need to be sent to the server in cleartext. 
> But the passwords on the server are in crypt format.
The attached .c file should do the trick.  Compile as neccecary.
(I plucked this out of a IRC daemon source tarball)

-- 
Austin K. Kurahone
Tokyo Linux Users Group / SIGUSR1 R&D
Hail Eris! All Hail Discordia!
"One must still have chaos in one to give birth to a dancing star!" --Nietzshe 
/***********************************************************************
 *   IRC - Internet Relay Chat, src/mkpasswd.c
 *   Copyright (C) 2000 Alasdair McWilliam. RageIRCd, Inc.
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 1, or (at your option)
 *   any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

extern char *getpass();

int main(argc, argv)
	int		argc;
	char		*argv[];
{
	static	char	saltChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
	char		salt[3];
	char		*plaintext;
	int		i;

	if (argc < 2)
	{
		srandom(time(0));
		salt[0] = saltChars[random() % 64];
		salt[1] = saltChars[random() % 64];
		salt[2] = 0;
	}
	else
	{
		salt[0] = argv[1][0];
		salt[1] = argv[1][1];
		salt[2] = '\0';

		if ((strchr(saltChars, salt[0]) == NULL) || (strchr(saltChars, salt[1]) == NULL))
		{
			(void)fprintf(stderr, " \n");
			(void)fprintf(stderr, "ERROR: Illegal salt %s\n", salt);
			(void)fprintf(stderr, " \n");
			exit (1);
		}
	}

	(void)fprintf(stderr, " \n");
	plaintext = getpass("Plain text: ");
	(void)fprintf(stderr, " \n");
	(void)fprintf(stderr, "Encrypted text: %s\n", crypt(plaintext, salt));
	(void)fprintf(stderr, " \n");

	return 0;
}

PGP signature


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links