<?php
define('INCLUDE_CHECK',true);
include ("./include/connect.php");
session_start();
if(isset($_POST['user'])) {
$login = mysql_escape_string($_POST['user']);
$postPass = mysql_escape_string($_POST['password']);
function generateSessionId(){
srand(time());
$randNum = rand(1000000000, 2147483647).rand(1000000000, 2147483647).rand(0,9);
return $randNum;
}
function hash_xauth()
{
global $realPass, $postPass;
$cryptPass = false;
$saltPos = (strlen($postPass) >= strlen($realPass) ? strlen($realPass) : strlen($postPass));
$salt = substr($realPass, $saltPos, 12);
$hash = hash('whirlpool', $salt . $postPass);
$cryptPass = substr($hash, 0, $saltPos) . $salt . substr($hash, $saltPos);
return $cryptPass;
}
function hash_md5()
{
global $postPass;
$cryptPass = false;
$cryptPass = md5($postPass);
return $cryptPass;
}
function hash_dle()
{
global $postPass;
$cryptPass = false;
$cryptPass = md5(md5($postPass));
return $cryptPass;
}
function hash_cauth()
{
global $realPass, $postPass;
$cryptPass = false;
if (strlen($realPass) < 32)
{
$cryptPass = md5($postPass);
$rp = str_replace('0', '', $realPass);
$cp = str_replace('0', '', $cryptPass);
(strcasecmp($rp,$cp) == 0 ? $cryptPass = $realPass : $cryptPass = false);
}
else
{
$cryptPass = md5($postPass);
}
return $cryptPass;
}
function hash_authme()
{
global $realPass, $postPass;
$cryptPass = false;
$ar = preg_split("/\\$/",$realPass);
$salt = $ar[2];
$cryptPass = '$SHA$'.$salt.'$'.hash('sha256',hash('sha256',$postPass).$salt);
return $cryptPass;
}
function hash_joomla()
{
global $realPass, $postPass;
$cryptPass = false;
$parts = explode( ':', $realPass);
$salt = $parts[1];
$cryptPass = md5($postPass . $salt) . ":" . $salt;
return $cryptPass;
}
function hash_ipb()
{
global $postPass, $salt;
$cryptPass = false;
$cryptPass = md5(md5($salt).md5($postPass));
return $cryptPass;
}
function hash_xenforo()
{
global $postPass, $salt;
$cryptPass = false;
$cryptPass = hash('sha256', hash('sha256', $postPass) . $salt);
return $cryptPass;
}
function hash_wordpress()
{
global $realPass, $postPass;
$cryptPass = false;
$itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$count_log2 = strpos($itoa64, $realPass[3]);
$count = 1 << $count_log2;
$salt = substr($realPass, 4, 8);
$input = md5($salt . $postPass, TRUE);
do
{
$input = md5($input . $postPass, TRUE);
}
while (--$count);
$output = substr($realPass, 0, 12);
$count = 16;
$i = 0;
do
{
$value = ord($input[$i++]);
$cryptPass .= $itoa64[$value & 0x3f];
if ($i < $count)
$value |= ord($input[$i]) << 8;
$cryptPass .= $itoa64[($value >> 6) & 0x3f];
if ($i++ >= $count)
break;
if ($i < $count)
$value |= ord($input[$i]) << 16;
$cryptPass .= $itoa64[($value >> 12) & 0x3f];
if ($i++ >= $count)
break;
$cryptPass .= $itoa64[($value >> 18) & 0x3f];
}
while ($i < $count);
$cryptPass = $output . $cryptPass;
return $cryptPass;
}
function hash_vbulletin()
{
global $postPass, $salt;
$cryptPass = false;
$cryptPass = md5(md5($postPass) . $salt);
return $cryptPass;
}
function hash_drupal()
{
global $postPass, $realPass;
$cryptPass = false;
$setting = substr($realPass, 0, 12);
$itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$count_log2 = strpos($itoa64, $setting[3]);
$salt = substr($setting, 4, 8);
$count = 1 << $count_log2;
$input = hash('sha512', $salt . $postPass, TRUE);
do
{
$input = hash('sha512', $input . $postPass, TRUE);
}
while (--$count);
$count = strlen($input);
$i = 0;
do
{
$value = ord($input[$i++]);
$cryptPass .= $itoa64[$value & 0x3f];
if ($i < $count)
$value |= ord($input[$i]) << 8;
$cryptPass .= $itoa64[($value >> 6) & 0x3f];
if ($i++ >= $count)
break;
if ($i < $count)
$value |= ord($input[$i]) << 16;
$cryptPass .= $itoa64[($value >> 12) & 0x3f];
if ($i++ >= $count)
break;
$cryptPass .= $itoa64[($value >> 18) & 0x3f];
}
while ($i < $count);
$cryptPass = $setting . $cryptPass;
$cryptPass = substr($cryptPass, 0, 55);
return $cryptPass;
}
if ($crypt == 'hash_md5' || $crypt == 'hash_authme' || $crypt == 'hash_xauth' || $crypt == 'hash_cauth' || $crypt == 'hash_joomla' || $crypt == 'hash_wordpress' || $crypt == 'hash_dle' || $crypt == 'hash_drupal')
{
$row = mysql_fetch_assoc(mysql_query("SELECT $db_columnUser,$db_columnPass FROM $db_table WHERE $db_columnUser='{$_POST['user']}'"));
$realPass = $row[$db_columnPass];
}
if ($crypt == 'hash_ipb' || $crypt == 'hash_vbulletin')
{
$row = mysql_fetch_assoc(mysql_query("SELECT $db_columnUser,$db_columnPass,$db_columnSalt FROM $db_table WHERE $db_columnUser='{$_POST['user']}'"));
$realPass = $row[$db_columnPass];
$salt = $row[$db_columnSalt];
}
if ($crypt == 'hash_xenforo')
{
$row = mysql_fetch_assoc(mysql_query("SELECT $db_table.$db_columnId,$db_table.$db_columnUser,$db_tableOther.$db_columnId,$db_tableOther.$db_columnPass FROM $db_table, $db_tableOther WHERE $db_table.$db_columnId = $db_tableOther.$db_columnId AND $db_table.$db_columnUser='{$_POST['user']}'"));
$realPass = substr($row[$db_columnPass],22,64);
$salt = substr($row[$db_columnPass],105,64);
}
if ($realPass)
{
$checkPass = $crypt();
if(strcmp($realPass,$checkPass) == 0)
{
$sessid = generateSessionId();
$dlticket = md5($login);
$_SESSION['id'] = $sessid;
if($crypt == 'hash_authme') $login = strtolower($login);
$_SESSION['name'] = $login;
$_SESSION['password'] = md5(md5($postPass));
header("Location: index.php");
}
else
{
header("Location: index.php?error");
}
}
else {
header("Location: index.php?error");
}
} else {
header("Location: index.php");
}
?>