Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- define('ENCRYPTION_KEY', md5('Ghost'));
- Ghost::getInst();
- class Ghost
- {
- public $core = null;
- public static function getInst()
- {
- static $inst = null;
- if ($inst === null)
- {
- $inst = new self;
- }
- return $inst;
- }
- public function __construct()
- {
- $this->core = $this->encryptCore();
- #echo $this->core . "\r\n";
- $this->core = $this->decryptCore();
- #echo $this->core . "\r\n";
- eval($this->core);
- }
- private function encryptCore()
- {
- $data = ($this->core!='')?$this->core:file_get_contents(__FILE__);
- $lines = explode("\n", $data);
- foreach($lines as $key => $line)
- {
- $first_char = substr($line, 0, 1);
- if($first_char == '#')
- {
- $line = substr($line, 1);
- $encrypt = serialize($line);
- $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC), MCRYPT_DEV_URANDOM);
- $key = pack('H*', ENCRYPTION_KEY);
- $mac = hash_hmac('sha256', $encrypt, substr(bin2hex($key), -32));
- $passcrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $encrypt.$mac, MCRYPT_MODE_CBC, $iv);
- $encoded = base64_encode($passcrypt).'|'.base64_encode($iv);
- $return[] = "#$encoded";
- }
- }
- //print_r($return);
- return implode("\n", $return);
- }
- private function decryptCore()
- {
- $data = ($this->core!='')?$this->core:file_get_contents(__FILE__);
- $lines = explode("\n", $data);
- foreach($lines as $key => $line)
- {
- $first_char = substr($line, 0, 1);
- if($first_char == '#')
- {
- $line = substr($line, 1);
- $decrypt = explode('|', $line.'|');
- $decoded = base64_decode($decrypt[0]);
- $iv = base64_decode($decrypt[1]);
- if(strlen($iv)!==mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC)){ return false; }
- $key = pack('H*', ENCRYPTION_KEY);
- $decrypted = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $decoded, MCRYPT_MODE_CBC, $iv));
- $mac = substr($decrypted, -64);
- $decrypted = substr($decrypted, 0, -64);
- $calcmac = hash_hmac('sha256', $decrypted, substr(bin2hex($key), -32));
- if($calcmac!==$mac){ return false; }
- $decrypted = unserialize($decrypted);
- $return[] = "$decrypted";
- }
- }
- //print_r($return);
- return implode("\n", $return);
- }
- }
- #GhostCore::getInst();
- #class GhostCore
- #{
- # private $request = null;
- # private $hostargs = null;
- #
- # public static function getInst()
- # {
- # static $inst = null;
- # if ($inst === null)
- # {
- # $inst = new self;
- # }
- # return $inst;
- # }
- #
- # public function __construct()
- # {
- # echo "GhostCore Init";
- # }
- #}
Advertisement
Add Comment
Please, Sign In to add comment