Forums / Install & configuration / Password lost - help!

Password lost - help!

Author Message

Noicokuna Niemoge

Friday 05 June 2009 1:14:22 am

Hello;

How to retrieve admin password? I tried to insert new md5 hash into ezuser table but it's not working for me. What's the "type 2 hash"?

Shiki soku ze ku...

Sébastien Morel

Friday 05 June 2009 1:26:32 am

Hi,

If you look in the class user : kernel/classes/datatypes/ezuser/ezuer.php (line 1557 )

static function createHash( $user, $password, $site, $type, $hash = false )
    {
        $str = '';
        if( $type == self::PASSWORD_HASH_MD5_USER )
        {
            $str = md5( "$user\n$password" );
        }
        else if ( $type == self::PASSWORD_HASH_MD5_SITE )
        {
            $str = md5( "$user\n$password\n$site" );
        }
        else if ( $type == self::PASSWORD_HASH_MYSQL )
        {
            $db = eZDB::instance();
            $hash = $db->escapeString( $password );

            $str = $db->arrayQuery( "SELECT PASSWORD( '$hash' )" );
            $hashes = array_values( $str[0] );
            $str = $hashes[0];
        }
        else if ( $type == self::PASSWORD_HASH_PLAINTEXT )
        {
            $str = $password;
        }
        else if ( $type == self::PASSWORD_HASH_CRYPT )
        {
            if ( $hash )
            {
                $str = crypt( $password, $hash );
            }
            else
            {
                $str = crypt( $password );
            }
        }
        else // self::PASSWORD_HASH_MD5_PASSWORD
        {
            $str = md5( $password );
        }
        eZDebugSetting::writeDebug( 'kernel-user', $str, "ezuser($type)" );
        return $str;
    }

at the begining of class

    /// MD5 of password
    const PASSWORD_HASH_MD5_PASSWORD = 1;
    const PASSWORD_HASH_MD5_USER = 2;
    const PASSWORD_HASH_MD5_SITE = 3;
    const PASSWORD_HASH_MYSQL = 4;
    const PASSWORD_HASH_PLAINTEXT = 5;
    const PASSWORD_HASH_CRYPT = 6;

So in your case (the default case) the constant is PASSWORD_HASH_MD5_USER.

So to force a new valid pass in the ezuser table you have to make a hash like

$str = md5( "admin\n$MYPASSWORD" );

++

--
eZ c'est plus fort que toi !
http://www.ez-france.org
http://blog.plopix.net
@Novactive (http://www.novactive.com)

Noicokuna Niemoge

Friday 05 June 2009 1:28:58 am

Thanks for fast reply :)

Hmm... I try to generate this password as type 2 in an md5 hash calculator, but without any success. Any ideas? Should I include there that \n string or is it a break? I think it's a string?

I generated a password like admin\nmypassword, but the hash doesn't work. By now I login as type 1 pass, but every time I log out it gets changed in the DB to type 2, which is not that convenient.

Shiki soku ze ku...

Sébastien Morel

Friday 05 June 2009 1:55:01 am

For me

print md5("admin\nmypassword");

return

4a964898a3133cf2507ff82962c3a88a

and it's ok for me( I just tested)

Are you sure, your problem comes from the password ? eZ shows error from user/password or siteaccess ?

++

--
eZ c'est plus fort que toi !
http://www.ez-france.org
http://blog.plopix.net
@Novactive (http://www.novactive.com)

Noicokuna Niemoge

Friday 05 June 2009 1:58:48 am

Well, I noticed that whenever I log out (when I change hash in the database and hash type to 1), eZ Publish changes hash type to 2 and also... changes the hash itself (changes password).

eZ even doesn't display an error "invalid password" just redirects me again to login form. Also, no errors are visible in error log.

Hmm, is it possible that I got hacked?

If yes, tell me please how to manually disable logins because today I'm going abroad and won't be able to sit and solve that problem instantly. :/

Shiki soku ze ku...

Łukasz Serwatka

Friday 05 June 2009 3:20:31 am

Try run:

UPDATE  `YOURDBNAME`.`ezuser` SET  `password_hash` =  '',
`password_hash_type` =  '4' WHERE  `ezuser`.`contentobject_id` =14;

Then login as admin without password and click change password on the right to set new admin password from eZ Publish,

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

eZ debug

Timing: Jan 30 2025 00:17:19
Script start
Timing: Jan 30 2025 00:17:19
Module start 'content'
Timing: Jan 30 2025 00:17:19
Module end 'content'
Timing: Jan 30 2025 00:17:19
Script end

Main resources:

Total runtime0.2372 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0066 587.9297180.8359
Module start 'content' 0.00660.0070 768.7656101.9141
Module end 'content' 0.01360.2235 870.6797529.7813
Script end 0.2371  1,400.4609 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00311.3214200.0002
Check MTime0.00120.5209200.0001
Mysql Total
Database connection0.00080.336910.0008
Mysqli_queries0.192781.25601410.0014
Looping result0.00100.40841390.0000
Template Total0.223294.110.2232
Template load0.00070.287510.0007
Template processing0.222593.825510.2225
Override
Cache load0.00050.205810.0005
Sytem overhead
Fetch class attribute can translate value0.00060.245410.0006
XML
Image XML parsing0.00020.093610.0002
General
dbfile0.01104.6212200.0005
String conversion0.00000.002430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs