Change website

From Jan 16 2015,


All post content will be move to we's offical website with many content...

Can access website here: http://justox.com

Thanks for your visit!

Thursday, 19 December 2013

Script to reset emaill account password in cpanel

To reset the  emailaccount password on a cPanel server without login whm or cpanel,  You can use the given script to reset the password.

#!/usr/bin/perl -wl # cpanel – chemailpass Copyright(c) 2011 prajith.in. # All rights Reserved. # http://prajith.in
BEGIN { unshift @INC, ‘/usr/local/cpanel’; }
use strict; use Cpanel::SafetyBits (); use Cpanel::AcctUtils (); use Cpanel::PublicAPI (); my ( $email, $pass ) = @ARGV; use Crypt::PasswdMD5 qw(unix_md5_crypt); my ( $user, $domain ) = split( /\@/, $email ); if ( !$email ) { die “Usage: chemailpass <emailaddress> <password>”; } if ( !$pass ) { die “Usage: chemailpass <emailaddress> <password>”; } my $owner = Cpanel::AcctUtils::getdomainowner( $domain, { ‘default’ => ” } ); if ( !$owner ) { die “Cannot find the owner of $domain, try rebuilding /etc/userdomains first with /usr/local/cpanel/scripts/updateuserdomains”; } my $pubapi = Cpanel::PublicAPI->new(); my $res = $pubapi->whm_api(‘domainuserdata’, “domain=$domain”); my $homedir = $res->{‘userdata’}->{‘homedir’}; if ( !$homedir ) { die “Cannot find the owner of $domain”; }
open(FILE, “$homedir/etc/$domain/shadow”); my @list=<FILE>;close FILE; my $string = $user; my @f=grep /$string/,@list;
if ( !@f ) { die “email account not created yet”; } system(“/bin/cat $homedir/etc/$domain/shadow|grep -v \”$user\” > $homedir/etc/$domain/shadow”);
my @salt = ( ‘.’, ‘/’, 0 .. 9, ‘A’ .. ‘Z’, ‘a’ .. ‘z’ );
my $password = $pass; my %encrypted; my $encrypted = unix_md5_crypt( $password, gensalt(8) ); print $encrypted; open FILE, “>>$homedir/etc/$domain/shadow” or die $!; print FILE “$user:$encrypted”; close FILE;
sub gensalt { my $count = shift;
my $salt; for (1..$count) { $salt .= (@salt)[rand @salt]; }
return $salt; }
Don’t copy paste the above script directly. Just use given command to download.
wget -O chemilpass.pl prajith.in/cpanel/emailpass

No comments:

Post a Comment