Antony Stace was once rumoured to have said:
> Hi Folks
> 
> Does anyone know where I can find some c source code which
> can generate the passwords used by cvs.

Since it uses the Unix crypt() call, Its a trivial C program.

---BEGIN SOURCE---
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

inline char
itos(int n)
{
        if (n < 0) {
                return -1;
        } else if (n < 26) {
                return 'a' + n;
        } else if (n < 52) {
                return 'A' + n - 26;
        } else if (n < 62) {
                return '0' + n - 52;
        } else if (n == 62) {
                return '.';
        } else if (n == 63) {
                return '/';
        } else {
                return -1;
        }
}

int
main (int argc, char **argv)
{
        char    salt[3]={0,0,0};
        char*   crypttext;
        int     ctr;

        srandom(time(NULL));

        for (ctr = 1; ctr < argc; ctr++) {
                salt[0]=itos(random()%64);
                salt[1]=itos(random()%64);
                printf ("%s\n", crypt(argv[ctr], salt));
        }

        return 0;
}
---END SOURCE---

Save as cryptit.c, compile using: gcc -o cryptit{,.c} -lcrypt

use ala:  ./cryptit plaintextpassword plaintextpassword.

It'll print the crypttext for each password on its own line.

Of course, this is much smaller if you write it in perl.

C.
-- 
--==============================================--
  Crossfire      | This email was brought to you
  [EMAIL PROTECTED] | on 100% Recycled Electrons
--==============================================--

-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://slug.org.au/lists/listinfo/slug

Reply via email to