#!/usr/bin/perl -Tw #Author (as such): #Michael Wallette (mike AT gecko DASH ak DOT org) # #Purpose: #This software is intended to allow a Samba system administrator to generate #NT or LanManager passwords for inclusion in a Samba database, such as LDAP. #It is essentially just a wrapper for the Crypt::SmbHash Perl module written #by Benjamin Kuit, and available on CPAN. # #License: #This program is free software. You may redistribute it and/or modify it #under the terms of the Gnu General Public License (GPL) as published by #the Free Software Foundation, either version 2 of the License or, at your #option, any later version. # #This program is distributed in the hope that it will be useful, but WITHOUT #ANY WARRANTY, eithout even the implied warranty of MERCHANTABILITY or #FITNESS FOR A PARTICULAR PURPOSE. See the Gnu General Public License for #more details. use strict; use Crypt::SmbHash; use Crypt::SmbHash qw(ntlmgen lmhash nthash); my $Username; my $Password; my $LMHash; my $NTHash; my $License="License:\nThis program is free software. You may redistribute it and/or modify it\nunder the terms of the Gnu General Public License (GPL) as published by\nthe Free Software Foundation, either version 2 of the License or, at your\noption, any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT\nANY WARRANTY, eithout even the implied warranty of MERCHANTABILITY or\nFITNESS FOR A PARTICULAR PURPOSE. See the Gnu General Public License for\nmore details.\n\n"; if ($#ARGV == 1) { $Username = $ARGV[0]; $Password = $ARGV[1]; } elsif (($#ARGV == 0) && (($ARGV[0] eq "-l") || ($ARGV[0] eq "-L"))) { die($License); } else { die("Usage is $0 username password\nUse\n\t$0 -l\nor\n\t$0 -L\nto display the license terms\n\n"); } $Password=~m/([a-zA-Z0-9_\-\.]+)/; $Password=$1; $Username=~m/([a-zA-Z0-9_\-\.]+)/; $Username=$1; if ((! defined($Password)) || (! defined($Username))) { die("Error -- Username and Password must match [a-zA-Z0-9_\-\.]*\n"); } else { $LMHash = lmhash($Password); $NTHash = nthash($Password); print "LanManager hash is $LMHash\n"; print "NT hash is $NTHash\n"; }