sslug-teknik team mailing list archive
-
sslug-teknik team
-
Mailing list archive
-
Message #15889
RE: CVS: Er pserver sikker? Alternativ?
> Jeg har bemærket at det ikke vil compile under Slackware 7.0,
> men godt under
> 4.0.. hmm
>
> Nogen der har en ide om hvad der kan være galt? Glibc-2.1.2
> fejl? Noget med
> den "nye" crypt()?
Hmmm, mit program kom ikke med, så jeg sender det lige inline...
---SNIP (passcrypt.c)
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
#include <crypt.h>
int main(int argc, char *argv[])
{
char a[2];
char pass[10];
char *b;
float c;
/* Array to hold the chars for our (not truly) random salt */
char table[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijlkmnopqrstuvwxyz/.";
if (argc == 3 && strlen(argv[1]) < 9 && strlen(argv[2]) == 2) { /* if 2
args, use the first as password, and the second as salt */
printf("%s\n", crypt(argv[1], argv[2]));
return 0;
}
else if (argc == 2 && strlen(argv[1]) < 9 && strcmp(argv[1], "-h")) {
c = strlen(table);
srandom(time(NULL));
a[0] = table[0+(int) (c * random()/(RAND_MAX + 0.0))];
srandom(a[0]);
a[1] = table[0+(int) (c * random()/(RAND_MAX + 0.0))];
printf("%s\n", crypt(argv[1], a));
return 0;
}
else if (argc == 1) {
c = strlen(table);
b = pass;
scanf("%s", b);
srandom(time(NULL));
a[0] = table[0+(int) (c * random()/(RAND_MAX + 0.0))];
srandom(a[0]);
a[1] = table[0+(int) (c * random()/(RAND_MAX + 0.0))];
printf("%s\n", crypt(pass, a));
return 0;
}
else {
printf("\nusage: passcrypt [password] [salt]\n");
printf("passcrypt encrypts a password, using either a supplied salt, or
a\n");
printf("(almost) random salt, if the salt is supplied it is used, usefull
for\n");
printf("checking passwords. If no command line arguments is passed, stdin
will be\n");
printf("read for the password, and a salt will be generated randomly.\n");
printf("Written by Emil S Hansen, uses no original ideas ;))\n\n");
return 1;
}
}
---SNIP
Mvh.
Emil S Hansen
laven.data@xxxxxxxx
UIN: 15749535 & 45621049
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GED d- s+:- a-- C++ UL++++ P+ L+++ E W++ N++ o K- w+ O- M-- V- PS+ PE-- Y+
PGP+ t- 5+ X++ R* tv- b++ DI++ D++
G e h r y+
------END GEEK CODE BLOCK------