|
<?php
/***********************************
* Granville Shield PHP encryption expert decryption algorithm By:zhrt
*http://www.111cn.net
*2013.12.31
* Put the program into the directory of the Web site program, can be targeted at the file directory and subdirectory files to crack, the source encrypted files are renamed to. bak.php.
***********************************/
Decode ("Image.class.php");
function Explorerdir ($dir)
{
$DP =opendir ($dir); Open a table of contents handle
echo "". $dir. " RN "; Output Directory
while ($file = Readdir ($DP))//Traverse Directory
{
if ($file!= '. ') && $file!= ' ... ') If the file is not the current directory and the parent directory
{
$path = $dir. Directory_separator. $file; Get path
if (Is_dir ($path))//If the current file is a directory
{
Explorerdir ($path); Recursive call
}
else//If not directory
{
echo "-". $path. " n "; Output file name
echo Decode ($path);
}
}
}
Closedir ($DP); Close the filename handle
}
Explorerdir ("."); Call current directory
function decode ($filename = "")
{
if (PathInfo ($filename, pathinfo_extension)!= "php" | | strpos ($filename, ". bak.php") | | Realpath ($filename) = = __file__) {return;}
$filename = "intro.class.php";//Files to decrypt
if (!file_exists ($filename))
{
Exit ("file is not exist;");
}
$lines = file ($filename);//0,1,2 Line
The first time Base64 decryption
$content = "";
if (Preg_match ("/o0o0000o0")/", $lines [1], $y))
{
$content =str_replace ("O0o0000o0", "", $y [0]);
$content =str_replace ("')", "", $content);
$content =base64_decode ($content);
}
Else
{
Weidun_log (False,realpath ($filename). "is not encrypted!");
return false;
}
//Find the key in the first Base64 decrypted content
$decode _key= "";
if (Preg_match ("/), '. * ',/", $content, $k))
{
$decode _key=str_replace ("), '", "", $k [0]);
$decode _key=str_replace ("',", "" " , $decode _key);
}
//Find to intercept string length
$str _length= "";
if (Preg_match ("/,d*),/", $content, $k)
{
$str _length=str_replace ("),", "", $k [0]);
$str _length=str_replace (",", "", $str _length);
}
//the encrypted ciphertext after intercepting the file
$Secret =substr ($lines [2], $str _length);
//echo $Secret;
Direct Restore ciphertext output
echo "<!--<?phpn". Base64_decode (Strtr ($Secret, $decode _key, ' abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789+/')). "? >--> "; Very strange, remove this line, the following code is a problem, may be related to coding, here I temporarily do not do further analysis, watch out to avoid the interface blinds.
echo "....<br> in decryption";
$filecontent = "<?phpn". Base64_decode (Strtr ($Secret, $decode _key, ' abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789+/')). "? > ";
Echo $filecontent;
$filenamebak = Str_replace (". php", ". bak.php", $filename);
if (!file_exists ($filenamebak)) {
if (rename ($filename, $filenamebak))
{
if (!file_exists ($filename) && file_exists ($filenamebak))//File changed successfully
{
$fp = fopen ($filename, "w");
Fwrite ($fp, $filecontent);
Fclose ($FP);
}
}
}else{
Return ("Backup file". $filenamebak. " already exists, stop decrypting. ");
Weidun_log (False,realpath ($filenamebak). "Is exist!");
return false;
}
Weidun_log (True,realpath ($filename). "-successful!");
return $filename. "-successful! n ";
}
function Weidun_log ($s = true, $c = "")
{
if ($s)
{
$fp = fopen ("./log.txt", "A +");
Fwrite ($FP, $c. " n ");
Fclose ($FP);
}
Else
{
$fp = fopen ("./log_error.txt", "A +");
Fwrite ($FP, $c. " n ");
Fclose ($FP);
}
}
?>
|