56 lines
2.2 KiB
PHP
Executable File
56 lines
2.2 KiB
PHP
Executable File
<?php
|
|
require_once "constants.php";
|
|
if(isset($argv[3]) && $argv[3])
|
|
$password = getLocalMachineHash($argv[1],$argv[2],$argv[3]);
|
|
else
|
|
$password = simple_decrypt($argv[1],$argv[2]);
|
|
|
|
print $password;exit;
|
|
|
|
/****************************************************************************************************
|
|
* Function Name : simple_decrypt
|
|
* Objective : Get decrypted string of actual string which is needs to be secured using key String
|
|
* Added By : Senthil Pandian
|
|
******************************************************************************************************/
|
|
function simple_decrypt($str,$flag) { //flag - DEFAULT_ENC, CUSTOM_ENC
|
|
$digit1 = substr($str,0,1);
|
|
$digit2 = substr($str,-1,1);
|
|
$first = substr($str,1,$digit1);
|
|
$last = substr($str,-($digit2+1),$digit2);
|
|
$actual = substr($str,$digit1+1);
|
|
$actual = substr($actual,0,strlen($actual)-($digit2+1));
|
|
$keyIndex = ($first+$last)-(strlen($actual));
|
|
$decrypted = getLocalMachineHash($actual, $flag, $keyIndex);
|
|
return $decrypted;
|
|
}
|
|
|
|
/****************************************************************************************************
|
|
* Function Name : getLocalMachineHash
|
|
* Objective : DEcrypt NAS password using mcrypt if module exists or using only base64_decode
|
|
* Added By : A.K. Kamalraj
|
|
******************************************************************************************************/
|
|
function getLocalMachineHash($str="", $flag="", $keyIndex=""){
|
|
|
|
if(!trim($str) || $keyIndex<0 || !isset($flag))
|
|
return "";
|
|
|
|
GLOBAL $staticString;
|
|
$keyString = $staticString[$keyIndex];
|
|
$decrypted = "";
|
|
|
|
if($flag == DEFAULT_ENC){
|
|
$decrypted = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $keyString, base64_decode($str), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)));
|
|
}
|
|
else{
|
|
$decrypted_data = trim(base64_decode($str));
|
|
$keyIndex = substr($decrypted_data, 0, 3);
|
|
$strIndex = intval($keyIndex);
|
|
$keyString = $staticString[$strIndex];
|
|
$replace_str = $keyIndex.$keyString;
|
|
$first_occurance = 1;
|
|
$decrypted = trim(str_replace($replace_str,"",$decrypted_data,$first_occurance));
|
|
}
|
|
return $decrypted;
|
|
}
|
|
?>
|