WCM Forum

WCM Forum (http://www.wcm.at/forum/index.php)
-   Programmierung (http://www.wcm.at/forum/forumdisplay.php?f=17)
-   -   [perl] .htpasswd-Einträge erstellen (http://www.wcm.at/forum/showthread.php?t=44596)

SNo0py 29.01.2002 17:07

[perl] .htpasswd-Einträge erstellen
 
Hallo allerseits!

Ich such schon verzweifelt im Netz, finde aber nirgens was! Wie kann ich ein Kennwort so verschlüsseln, dass es im Apache funktioniert??? (d.h. wenn ich es in die .htpasswd-Datei eintrage)???

Gelöst sollte das ganze natürlich mit Perl werden ;)

mfg

MZ 29.01.2002 17:17

http://www.users.f2s.com/faq/htaccess.php3

hth

SNo0py 29.01.2002 17:25

Zitat:

Original geschrieben von MZ
http://www.users.f2s.com/faq/htaccess.php3

hth

Die Seite kenn ich, aber da steht nirgens ein Code zum Abschreiben ;)

Wie .htaccess funktioniert, ist mir klar!! Ich will nur meine eigenen Kennwörter verschlüsseln!!!

_m3 29.01.2002 18:42

Nicht verzagen, m3 Fragen:
Code:

#!/usr/bin/perl
if (scalar(@ARGV) < 2) {
print <<EOF;
usage: make-password <htpasswd file> <user> <password>
EOF
exit;
}

$salt="XX";
$file=$ARGV[0];
$key=$ARGV[1];
$value=$ARGV[2];

if ($file && $key && $value) {
$hash = crypt($value, "$salt");
open(DB, ">>$file") || die "Error: $!\n";
print DB "$key:$hash\n";
close(DB);
print "User $key added with password $value,
encrypted to $hash\n";
exit;
}


SNo0py 29.01.2002 18:49

Und warum ist $salt gleich "XX"?? Ist das bei jedem Apache so?? Das glaub ich nämlich nicht... weil im Netz gibt es viele Tools, und jedes liefert einen anderen Hash (=codiertes Passwort) zurück.

Deswegen würd ich gerne wissen, was $salt ist? Der "Rest" des Programmes war mir klar ;)

Trotzdem mal ein Danke!

Sloter 30.01.2002 07:18

Mit SSH verbinden:
htpasswd /pfad/zur/userdatei Username /Return

Oder auf der Apacheseite www.apache.org

Sloter

SNo0py 30.01.2002 07:51

Hi Sloter!

Ich hab kein SSH (erstes Problem) und ich will gerne ein Perl-Script schreiben, welches mir das "automatisch" erledigt (ohne auf htpasswd zuzugreifen).

@apache.org: dort steht leider auch nicht, wie das Script funkt :(

Trotzdem danke!

_m3 30.01.2002 07:58

Google rulez:
http://hotwired.lycos.com/webmonkey/...tw=programming
Zitat:

A "salt" is a little bit of data used to skew an otherwise standard DES encryption algorithm. The salt of a DES-encrypted string is available to you as the first two characters of the final output. This is important to remember — keep on reading to find out why.

If you have used .htaccess-based authentication in the past, you know that usernames and passwords are kept in a file, usually called .htpasswd. The passwords are stored in a format something like this:
joe:WvzodahMR9USk
jane:g3RYjX5evEvdM
julie:YzASzTGEo2VMA

Now, "WvzodahMR9USk" is not Joe User's password. His password is actually "abba001," but after encryption, it looks like "WvzodahMR9USk." Which is the salt ("Wv") tacked on to the DES-encrypted version of "abba001" ("zodahMR9Usk"). Similarly, "g3" is the salt used to encrypt Jane User's password, and "Yz" is the salt used to encrypt Julie User's password. By knowing the salt, you can perform password-matching as outlined below.

SNo0py 30.01.2002 08:35

:eek:

Wow! So is des also!

Werd ich gleich ausprobieren!!

Danke einstweilen!

mfg
Mike


Alle Zeitangaben in WEZ +2. Es ist jetzt 12:37 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© 2009 FSL Verlag