Reset Your Joomla Super Admin Password in 5 Seconds

With tried and tested to utter destruction perl script.

Yes, you can, 5 seconds is all it takes !

It’s tried, it tested, (are you feeling sleepy)

Empower yourself, save time and avoid stress

No need to wreck your brain trawling the configuration.php file for the db parameters you need.

No, this script does it all! (are you feeling sleeeeepy)

No money back guarantee

What will it cost you … just a pauper ransom, that’s 00.00 centissime!

Yes, I know I been reading one of those Web marketing books, were you hypnotised, are you feeling sleepy, by my copy. Simply put this perl script derives the database information from the Joomla configuration file – just supply the correct path to the joomla top level directory instance when executing the script.from the command line.

Enter the new password at the prompt and (as Francoise Hardy would say) voila, the password is reset.

The script is verbose so even non perl wizzes/witchees can understand it.

Warning – using the script is at your own risk!

#!/usr/bin/perl

use DBI;

my $jmldir =  $ARGV[0];

if(-e $ARGV[0])
{
  if(-d $ARGV[0]) { $jmldir = "$ARGV[0]"."configuration.php"};
  my %conf_args = {};
  if((-f $jmldir) && open (DATA, "< $jmldir"))
  {
    while( <DATA> )
    {
      chomp $_;
      #([\w]*)to capture all settings
      $m2=m/\$(user|db|password|dbprefix)\s\=.\'([\w]*)\'?/;
      if ($1 && $2) {
        $conf_args{$1} = $2;
      }
    }
    close (DATA);

    my $dbh = DBI->connect("DBI:mysql:$conf_args{'db'}", $conf_args{'user'}, $conf_args{'password'}, {RaiseError=>1})
      or die "Couldn't connect to database: " . DBI->errstr;
    my $jml_tbl = "$conf_args{'dbprefix'}users";

    print "\nEnter new password: ";
    my $name = ;;
    chomp($name);

    my $sql="UPDATE $jml_tbl SET PASSWORD=MD5('$name') WHERE username='admin'";
    my $qu = $dbh->prepare($sql)
      or die "Prepared failed: " . $dbh->errstr;

    $affected = $qu->execute or die 'Execute failed: ' . $dbh->errstr;
    die "$dbh->errstr" if (!affected); # trap errors
    die "No rows updated" if ($affected eq '0E0');

    print "Joomla admin account updated!\n";

    $qu -> finish();
    $dbh->disconnect();
  }
  else
  {
    print "can not open $jmldir!";
  }
}
else
{
  print "$jmldir does not exist!";
}
exit;
Advertisements

Joomla Password Reset

If you forget your Joomla (version 1.5 and above) super admin password and you have access to the local machine you can run the following PERL script to reset it. Note, if you have changed the default name of the super admin (which you should always do and the id) then you will have to change the SQL update WHERE clause to the appropriate value. The code is quite verbose: meaning anybody with a little PERL can modify it to include changing the super admins username.

#!/usr/bin/perl

use DBI;

if ($#ARGV != 3) {
  print “\nUsage: jmlpasswd.pl dbname prefix dbuser dbpasswd\n”;
  exit;
}

my $dbname = $ARGV[0];
my $jml_prefix = $ARGV[1] . ‘_users’;
my $dbuser = $ARGV[2];
my $dbpasswd = $ARGV[3];

my $dbh = DBI->connect(“DBI:mysql:$dbname”, $dbuser, $dbpasswd, {RaiseError=>1})
  or die “Couldn’t connect to database: ” . DBI->errstr;

print “Enter new password: “;

my $name = <STDIN>;;
chomp($name);

my $sql=”UPDATE $jml_prefix SET PASSWORD=MD5(‘$name’) WHERE username=’admin’”;
#’admin’ is the joomla default user name
my $qu = $dbh->prepare($sql)
  or die “Prepared failed: ” . $dbh->errstr;

$affected = $qu->execute or die ‘Execute failed: ‘ . $dbh->errstr;
die “$dbh->errstr” if (!affected); # trap errors
die “No rows updated” if ($affected eq ’0E0′);

print “Joomla admin password changed!\n”;

$qu -> finish();
$dbh->disconnect();