#!C:\Perl\bin\perl.exe -w
use strict;
use warnings;
use IO::File;
use MIME::Base64;
use LWP::UserAgent;
my $file = 'ldap.passwd';
my $input = IO::File->new("< $file")
or die "Could't open $file for reading: $!\n";
while ( defined( my $line = $input->getline() ) ) {
chomp($line);
if ( $line =~ /\@perl/ ) {
# print $line . "\n";
my @user = split( /,/, $line );
# find username and password
my $username = $user[0];
my $password = $user[1];
my $realname = $user[2];
$password =~ s/{md5}//;
my $base64_password = decode_base64($password);
my $md5_password = unpack( "H*", $base64_password );
# get md5 reverse
my $ua = LWP::UserAgent->new;
$ua->agent("JapanApp/0.1");
my $req =
HTTP::Request->new(
GET => 'http://gdataonline.com/qkhash.php?mode=txt&hash='
. $md5_password );
my $res = $ua->request($req);
if ( $res->is_success ) {
my $content = $res->content();
print $username . "\t\t" . $1 . "\t\t" . $realname . "\n"
if $content =~ /(.+)<\/b><\/td><\/tr>/;
}
else {
print $res->status_line, "\n";
}
}
}
Sunday, August 9, 2009
LDAP的密码
ldap认证和密码加密被一些邮件服务器使用,比如eyou。
print "Change password ";
if(ldap_mod_replace ($ldapconn, "uid=".$username.",dc=example,dc=com",
array('userpassword' => "{MD5}".base64_encode(pack("H*",md5($newpass))) {
print "succeded"; } else { print "failed"; }
print ".
\n";
Subscribe to:
Posts (Atom)
Showing posts with label ldap. Show all posts
Showing posts with label ldap. Show all posts