Results 1 to 2 of 2

Thread: MD5 hashing issue...I think... PHP

  1. #1
    Join Date
    Jul 2009
    Location
    North Carolina
    Posts
    265

    MD5 hashing issue...I think... PHP

    I posted on webmaster-talk.com earlier, and figured I'd post here as well...


    Hey guys, maybe someone can help me out on this one. I have a client (contract) through my work that asked for my assistance with an internal web site. It's a php site with a mySQL database. They migrated from a Red Hat server to a Sun Solaris 10 server and cannot log into anything with their passwords. They can select the tables and what not, and the link diag page shows a successful connection to the database. My concern was that the hashses for the passwords were being generated differently between the 2 different php engines.

    Red Hat - 4.3.2

    Sun Solaris - 4.4.5

    Here's the log in form:
    ----------------------------------------------------------------------

    PHP Code:
    <?php


    function login($Code$Password){
    include(
    "config.php");
    $data 'training';
    $table 'Agency';

    if(
    $Code == NULL || $Password ==NULL)
    return 
    "Agency Code or Password is incorrect";

    //connects to database
    if (!($link=mysql_pconnect($_SESSION['hostname'],$_SESSION['username'], $_SESSION['password']))) {
    error(sprintf("error connecting to host %s, by user %s"$_SESSION['hostname'], $_SESSION['username']));
    exit();
    }

    //select database
    if (!mysql_select_db($data$link)){
    error(sprintf("error in executing %s database"$data));
    error(sprintf("error:%d %s"mysql_errno($link), mysql_error($link)));
    exit();
    }

    $query "SELECT id, Code FROM $table WHERE ((Code = '$Code')) AND ((Password = md5('$Password')))";

    //stores the result of the query to the array $result
    if(!$result mysql_query($query$link)){
    error(sprintf("Error in executing %s stmt"$result));
    error(sprintf("error:%d %s"mysql_errno($link), mysql_error($link)));
    exit();
    }



    //if the user exists 
    if(mysql_num_rows($result)){
    //update last login and ip address


    $date mktime();
    $id mysql_result($result0id);
    $ip ip();
    $update "UPDATE Agency SET Last_Visit = '$date', ip_address = '$ip' WHERE id = '$id'";

    if(!
    mysql_query($update$link)){
    error(sprintf("Error in executing %s stmt"$update));
    error(sprintf("error:%d %s"mysql_errno($link), mysql_error($link)));
    exit();
    }
    $_SESSION['Code'] = mysql_result($result0Code);
    $_SESSION['AgencyID'] = mysql_result($result0ID);

    header("Location: $currentsite"); //after success it redirects
    exit;
    } else {
    return 
    "Username or Password is incorrect";
    }
    }


    ?>
    --------------------------------------------------------------------------


    Now, someone also mentioned to me that the encoding could be different. As in the old server interpreting the characters as ASCII or ANSI...and the new server interpreting the opposite. I'm not too sure, since I really haven't had to do this stuff before with passwords. I did see in the config.inc.php file the following:

    --------------------------------------------------------------------------
    PHP Code:
    <? php

    MySQL settings
    */
    // Column types;
    // varchar, tinyint, text and date are listed first, based on estimated popularity
    $cfg['ColumnTypes'] = array(
    'VARCHAR',
    'TINYINT',
    'TEXT',
    'DATE',
    'SMALLINT',
    'MEDIUMINT',
    'INT',
    'BIGINT',
    'FLOAT',
    'DOUBLE',
    'DECIMAL',
    'DATETIME',
    'TIMESTAMP',
    'TIME',
    'YEAR',
    'CHAR',
    'TINYBLOB',
    'TINYTEXT',
    'BLOB',
    'MEDIUMBLOB',
    'MEDIUMTEXT',
    'LONGBLOB',
    'LONGTEXT',
    'ENUM',
    'SET'
    );

    // Atributes
    $cfg['AttributeTypes'] = array(
    '',
    'BINARY',
    'UNSIGNED',
    'UNSIGNED ZEROFILL'
    );

    // Available functions
    if ($cfg['ShowFunctionFields']) {
    $cfg['Functions'] = array(
    'ASCII',
    'CHAR',
    'SOUNDEX',
    'LCASE',
    'UCASE',
    'NOW',
    'PASSWORD',
    'MD5',
    'ENCRYPT',
    'RAND',
    'LAST_INSERT_ID',
    'COUNT',
    'AVG',
    'SUM',
    'CURDATE',
    'CURTIME',
    'FROM_DAYS',
    'FROM_UNIXTIME',
    'PERIOD_ADD',
    'PERIOD_DIFF',
    'TO_DAYS',
    'UNIX_TIMESTAMP',
    'USER',
    'WEEKDAY',
    'CONCAT'
    );

    // Which column types will be mapped to which Group?
    $cfg['RestrictColumnTypes'] = array(
    'VARCHAR' => 'FUNC_CHAR',
    'TINYINT' => 'FUNC_NUMBER',
    'TEXT' => 'FUNC_CHAR',
    'DATE' => 'FUNC_DATE',
    'SMALLINT' => 'FUNC_NUMBER',
    'MEDIUMINT' => 'FUNC_NUMBER',
    'INT' => 'FUNC_NUMBER',
    'BIGINT' => 'FUNC_NUMBER',
    'FLOAT' => 'FUNC_NUMBER',
    'DOUBLE' => 'FUNC_NUMBER',
    'DECIMAL' => 'FUNC_NUMBER',
    'DATETIME' => 'FUNC_DATE',
    'TIMESTAMP' => 'FUNC_DATE',
    'TIME' => 'FUNC_DATE',
    'YEAR' => 'FUNC_DATE',
    'CHAR' => 'FUNC_CHAR',
    'TINYBLOB' => 'FUNC_CHAR',
    'TINYTEXT' => 'FUNC_CHAR',
    'BLOB' => 'FUNC_CHAR',
    'MEDIUMBLOB' => 'FUNC_CHAR',
    'MEDIUMTEXT' => 'FUNC_CHAR',
    'LONGBLOB' => 'FUNC_CHAR',
    'LONGTEXT' => 'FUNC_CHAR',
    'ENUM' => '',
    'SET' => ''
    );

    // Map above defined groups to any function
    $cfg['RestrictFunctions'] = array(
    'FUNC_CHAR' => array(
    'ASCII',
    'CHAR',
    'SOUNDEX',
    'LCASE',
    'UCASE',
    'PASSWORD',
    'MD5',
    'ENCRYPT',
    'LAST_INSERT_ID',
    'USER',
    'CONCAT'
    ),

    'FUNC_DATE' => array(
    'NOW',
    'CURDATE',
    'CURTIME',
    'FROM_DAYS',
    'FROM_UNIXTIME',
    'PERIOD_ADD',
    'PERIOD_DIFF',
    'TO_DAYS',
    'UNIX_TIMESTAMP',
    'WEEKDAY'
    ),

    'FUNC_NUMBER' => array(
    'ASCII',
    'CHAR',
    'MD5',
    'ENCRYPT',
    'RAND',
    'LAST_INSERT_ID',
    'COUNT',
    'AVG',
    'SUM'
    )
    );

    // end if


    /**
    * Unset magic_quotes_runtime - do not change!
    */
    set_magic_quotes_runtime(0);

    /**
    * File Revision - do not change either!
    */
    $cfg['FileRevision'] = '$Revision: 1.182 $';
    ?>
    --------------------------------------------------------------------------

    I've tried to do some searching online but haven't been successful in getting in the right direction. If anyone could point me in the right direction it would be greatly appreciated. I can post more info if need be. Thanks.
    Last edited by MDwebdev85; 29 Jan 2010 at 05:11 PM. Reason: code tags
    █| VEEROTECH.NET - Raleigh, NC Shared, Reseller & VPS Hosting
    █| High Performance *Pure SSD* CloudLinux & LiteSpeed Powered Web Hosting
    █| cPanel & WHM - Softaculous - LSCache - R1Soft - SpamExperts - Let's Encrypt
    █| Fully Managed KVM SSD VPS | ownCloud Storage Hosting | SSH/FTP Storage

  2. #2
    Join Date
    Jul 2009
    Location
    North Carolina
    Posts
    265
    Nevermind, I have fixed the problem... it was in fact a hashing problem.
    █| VEEROTECH.NET - Raleigh, NC Shared, Reseller & VPS Hosting
    █| High Performance *Pure SSD* CloudLinux & LiteSpeed Powered Web Hosting
    █| cPanel & WHM - Softaculous - LSCache - R1Soft - SpamExperts - Let's Encrypt
    █| Fully Managed KVM SSD VPS | ownCloud Storage Hosting | SSH/FTP Storage

Similar Threads

  1. Server issue or PHP? - Contact Form Not Sending HTML correctly?
    By Editor08 in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 03 Oct 2009, 04:37 PM
  2. Form Mailer - PHP Script - Data issue
    By dcj in forum Web Design, HTML Reference and CSS
    Replies: 1
    Last Post: 28 Sep 2009, 09:44 PM
  3. PHP session issue
    By ShotoCon in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 09 Feb 2009, 05:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •