>>>>> "Kedar" == Kedar Patankar <[EMAIL PROTECTED]> writes:

    Kedar> Sorry, a typo. In the previous mail I intended to type
    Kedar> rootpw entry to read as

    Kedar> rootpw: {MD5}<hash_of_passwd_pasted_from_blah_blah>

    Kedar> Regards, Kedar.
--[[application/octet-stream
Content-Disposition: attachment; filename="md5_passwd.pl"][quoted-printable]]
#!/usr/bin/perl -w
use Digest::MD5 ;
use MD5 ;

@itoa64 =3D split(//, "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijkl=
mnopqrstuvwxyz");
$dollar =3D chr 0x24 ;        # $

sub to64
{
  local ($v, $n) =3D @_;
  local $r;
  while(--$n >=3D 0) {
    $r .=3D $itoa64[$v & 0x3f];
    $v >>=3D 6;
  }
  return $r;
}

sub md5_password
{
  local $passwd =3D $_[0];
  local $magic =3D $dollar."1$dollar";
  local $salt =3D substr(time(), -8);
  $salt =3D substr ( $_[1] , 3 , 8 ) if defined $_[1] ;
  =

  local $ctx =3D new MD5;
  $ctx->add($passwd);
  $ctx->add($magic);
  $ctx->add($salt);
  =

  local $ctx1 =3D new MD5;
  $ctx1->add($passwd);
  $ctx1->add($salt);
  $ctx1->add($passwd);
  local $final =3D $ctx1->digest();
  for($pl=3Dlength($passwd); $pl>0; $pl-=3D16) {
    $ctx->add($pl > 16 ? $final : substr($final, 0, $pl));
  }
  =

  local $j =3D 0;
  local ($i, $l);
  for($i=3Dlength($passwd); $i; $i >>=3D 1) {
    if ($i & 1) {
      $ctx->add("\0");
    }
    else {
      $ctx->add(substr($passwd, $j, 1));
    }
  }
  $final =3D $ctx->digest();
  =

  for($i=3D0; $i<1000; $i++) {
    $ctx1 =3D new MD5;
    $ctx1->add($i & 1 ? $passwd : $final);
    $ctx1->add($salt) if ($i % 3);
    $ctx1->add($passwd) if ($i % 7);
    $ctx1->add($i & 1 ? $final : $passwd);
    $final =3D $ctx1->digest();
  }
  =

  local $rv =3D $magic.$salt.$dollar;
  local @final =3D map { ord($_) } split(//, $final);
  $l =3D ($final[0]<<16) + ($final[ 6]<<8) + $final[12];
        $rv .=3D &to64($l, 4);
        $l =3D ($final[ 1]<<16) + ($final[ 7]<<8) + $final[13];
        $rv .=3D &to64($l, 4);
        $l =3D ($final[ 2]<<16) + ($final[ 8]<<8) + $final[14];
        $rv .=3D &to64($l, 4);
        $l =3D ($final[ 3]<<16) + ($final[ 9]<<8) + $final[15];
        $rv .=3D &to64($l, 4);
        $l =3D ($final[ 4]<<16) + ($final[10]<<8) + $final[ 5];
        $rv .=3D &to64($l, 4);
        $l =3D $final[11];
        $rv .=3D &to64($l, 2);

  return $rv;
}

print "clear-text: " ;
$pw =3D <STDIN> ;
chomp $pw ;
print "password: " ;
$oldpw =3D <STDIN> ;
chomp $oldpw ;
print "MD5: " , md5_password ( $pw , $oldpw ) , "\n" ;

-----------------------------------------------------------------------
LIH is all for free speech.  But it was created for a purpose - to help
people discuss issues about installing and running Linux.  If your
messages are counterproductive to this purpose, your privileges to
submit messages can and will be revoked.

Reply via email to