Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php /* * Copyright (c) Ewoosoft Co., Ltd. * * All rights reserved. */ require_..

Decoded Output download

<?php 
/* 
 * Copyright (c) Ewoosoft Co., Ltd. 
 * 
 * All rights reserved. 
 */ 
require_once APPPATH . "libraries/StrUtils.php";  
require_once APPPATH . "libraries/VTPhpseclibCryptoWrapper.php";  
use Ewoosoft\Crypto\VTPhpseclibCryptoClassFactory;  
use Ewoosoft\Crypto\PaddingMode;  
use Ewoosoft\Crypto\CipherMode;  
use Ewoosoft\Crypto\ChunkSize;  
use Ewoosoft\Crypto\AESProperties;  
CryptoUtils::init();  
class CryptoUtils { private static $_IV; private static $_MAGIC;  
const PHPSECLIB = "PHPSECLIB";  
public static function init() { self::$_IV = base64_decode("ZHb9ocCngFgqfAGVbk/b7RlqhUsr6N2TBnhzFKRbf60="); 
self::$_MAGIC = base64_decode("6qACD0A="); } 
public static function encrypt_aes_with_magic($data, $key, $iv = null, $magic = null, $cipher = null, $mode = null) { if (is_null($iv)) { $iv = self::$_IV; } if (is_null($magic)) { $magic = self::$_MAGIC; } $factory = CryptoUtils::getCryptoClassFactory(CryptoUtils::PHPSECLIB); $engine = $factory->newAESEngine(); $props = new AESProperties(); $props->cipherMode = CipherMode::CBC; $props->paddingMode = PaddingMode::Zeros; $props->keySize = ChunkSize::e256bits; $props->blockSize = ChunkSize::e256bits; $engine->setProperties($props); $engine->setKey($key); $engine->setIV($iv); $engine->encrypt($data, $body); $header = "\x4" . StrUtils::int2bytes(mb_strlen($data, "8bit")) ^ $magic; $output = $header . $body; return $output; } public static function xor_string($string, $key) { $stringLen = strlen($string); $keyLen = strlen($key); for ($i = 0; $i < $stringLen; $i++) { $string[$i] = $string[$i] ^ $key[$i % $keyLen]; } return $string; } public static function decrypt_aes_with_magic($data, $key, $iv = null, $magic = null, $cipher = null, $mode = null) { if (is_null($iv)) { $iv = self::$_IV; } if (is_null($magic)) { $magic = self::$_MAGIC; } $body = substr($data, 5); $header = substr($data, 0, 5) ^ $magic; $size_type = substr($header, 0, 1); if ($size_type != "\x4") { throw new InvalidHeaderException(); } $size_data = StrUtils::bytes2int(substr($header, 1, 4)); $factory = CryptoUtils::getCryptoClassFactory(CryptoUtils::PHPSECLIB); $engine = $factory->newAESEngine(); $props = new AESProperties(); $props->cipherMode = CipherMode::CBC; $props->paddingMode = PaddingMode::Zeros; $props->keySize = ChunkSize::e256bits; $props->blockSize = ChunkSize::e256bits; $engine->setProperties($props); $engine->setKey($key); $engine->setIV($iv); $ret = $engine->decrypt($body, $decrypted); return substr($decrypted, 0, $size_data); } public static function getCryptoClassFactory($name = CryptoUtils::PHPSECLIB) { switch ($name) { case CryptoUtils::PHPSECLIB: return new VTPhpseclibCryptoClassFactory(); default: vt_loge("Unsupported CryptoClassFactory: " . $name); throw new \InvalidArgumentException("Unsupported CryptoClassFactory: " . $name); } } public static function pad($src, $paddingMode, $blockSize) { $blockSizeInBytes = $blockSize / 8; switch ($paddingMode) { case PaddingMode::NoPadding: return $src; case PaddingMode::Zeros: $pad = $blockSizeInBytes - strlen($src) % $blockSizeInBytes; $dst = $src . str_repeat(chr(0), $pad); return $dst; case PaddingMode::PKCS7: $pad = $blockSizeInBytes - strlen($src) % $blockSizeInBytes; $dst = $src . str_repeat(chr($pad), $pad); return $dst; case PaddingMode::OneAndZeros: $pad = $blockSizeInBytes - strlen($src) % $blockSizeInBytes; $dst = $src . chr(0x80) . str_repeat(chr(0), $pad - 1); return $dst; default: vt_loge("Unsupported padding mode: " . $paddingMode); throw new \InvalidArgumentException("Unsupported padding mode: " . $paddingMode); } } public static function unpad($src, $paddingMode, $blockSize) { if (strlen($src) == 0) { throw new \InvalidArgumentException("No input data."); } $blockSizeInBytes = $blockSize / 8; switch ($paddingMode) { case PaddingMode::NoPadding: return $src; case PaddingMode::Zeros: for ($i = 0; $i < $blockSizeInBytes; $i++) { if (ord($src[strlen($src) - 1 - $i]) != 0x0) { $pos = $i; break; } } return substr($src, 0, strlen($src) - $pos); case PaddingMode::PKCS7: $pad = ord($src[($len = strlen($src)) - 1]); $len = strlen($src); $pad = ord($src[$len - 1]); $dst = substr($src, 0, strlen($src) - $pad); return $dst; case PaddingMode::OneAndZeros: for ($i = 0; $i < $blockSizeInBytes; $i++) { $chr = ord($src[strlen($src) - 1 - $i]); if ($chr === 0x80) { $pos = $i + 1; break; } else { if ($chr != 0x0) { throw new \InvalidArgumentException("Not One and Zeros padding."); } } } return substr($src, 0, strlen($src) - $pos); default: vt_loge("Unsupported padding mode: " . $paddingMode); throw new \InvalidArgumentException("Unsupported padding mode: " . $paddingMode); } } } class InvalidHeaderException extends Exception { } 
 
 ?>

Did this file decode correctly?

Original Code

<?php
/*
 * Copyright (c) Ewoosoft Co., Ltd.
 *
 * All rights reserved.
 */
require_once APPPATH . "\154\151\x62\162\141\162\x69\145\x73\x2f\123\164\162\125\164\x69\154\x73\x2e\160\x68\x70"; 
require_once APPPATH . "\154\151\142\162\x61\x72\151\145\163\x2f\126\124\120\x68\160\x73\x65\143\x6c\151\x62\103\162\x79\160\x74\x6f\127\162\x61\160\x70\x65\x72\56\160\150\x70"; 
use Ewoosoft\Crypto\VTPhpseclibCryptoClassFactory; 
use Ewoosoft\Crypto\PaddingMode; 
use Ewoosoft\Crypto\CipherMode; 
use Ewoosoft\Crypto\ChunkSize; 
use Ewoosoft\Crypto\AESProperties; 
CryptoUtils::init(); 
class CryptoUtils { private static $_IV; private static $_MAGIC; 
const PHPSECLIB = "\x50\x48\x50\x53\x45\103\x4c\111\x42"; 
public static function init() { self::$_IV = base64_decode("\132\x48\142\x39\x6f\143\103\x6e\147\106\147\161\146\101\107\x56\x62\153\57\x62\67\122\x6c\161\150\125\x73\x72\66\x4e\x32\124\x42\x6e\x68\172\x46\113\122\x62\146\66\x30\x3d");
self::$_MAGIC = base64_decode("\66\x71\x41\103\x44\x30\101\x3d"); }
public static function encrypt_aes_with_magic($data, $key, $iv = null, $magic = null, $cipher = null, $mode = null) { if (is_null($iv)) { $iv = self::$_IV; } if (is_null($magic)) { $magic = self::$_MAGIC; } $factory = CryptoUtils::getCryptoClassFactory(CryptoUtils::PHPSECLIB); $engine = $factory->newAESEngine(); $props = new AESProperties(); $props->cipherMode = CipherMode::CBC; $props->paddingMode = PaddingMode::Zeros; $props->keySize = ChunkSize::e256bits; $props->blockSize = ChunkSize::e256bits; $engine->setProperties($props); $engine->setKey($key); $engine->setIV($iv); $engine->encrypt($data, $body); $header = "\x4" . StrUtils::int2bytes(mb_strlen($data, "\70\142\151\164")) ^ $magic; $output = $header . $body; return $output; } public static function xor_string($string, $key) { $stringLen = strlen($string); $keyLen = strlen($key); for ($i = 0; $i < $stringLen; $i++) { $string[$i] = $string[$i] ^ $key[$i % $keyLen]; } return $string; } public static function decrypt_aes_with_magic($data, $key, $iv = null, $magic = null, $cipher = null, $mode = null) { if (is_null($iv)) { $iv = self::$_IV; } if (is_null($magic)) { $magic = self::$_MAGIC; } $body = substr($data, 5); $header = substr($data, 0, 5) ^ $magic; $size_type = substr($header, 0, 1); if ($size_type != "\x4") { throw new InvalidHeaderException(); } $size_data = StrUtils::bytes2int(substr($header, 1, 4)); $factory = CryptoUtils::getCryptoClassFactory(CryptoUtils::PHPSECLIB); $engine = $factory->newAESEngine(); $props = new AESProperties(); $props->cipherMode = CipherMode::CBC; $props->paddingMode = PaddingMode::Zeros; $props->keySize = ChunkSize::e256bits; $props->blockSize = ChunkSize::e256bits; $engine->setProperties($props); $engine->setKey($key); $engine->setIV($iv); $ret = $engine->decrypt($body, $decrypted); return substr($decrypted, 0, $size_data); } public static function getCryptoClassFactory($name = CryptoUtils::PHPSECLIB) { switch ($name) { case CryptoUtils::PHPSECLIB: return new VTPhpseclibCryptoClassFactory(); default: vt_loge("\125\156\163\165\160\x70\x6f\162\x74\x65\144\x20\103\162\171\x70\164\x6f\103\x6c\x61\x73\x73\106\141\143\x74\157\162\171\x3a\x20" . $name); throw new \InvalidArgumentException("\125\x6e\163\x75\x70\x70\x6f\162\x74\x65\144\x20\x43\162\171\x70\164\157\x43\x6c\141\163\x73\106\x61\x63\x74\157\162\171\x3a\x20" . $name); } } public static function pad($src, $paddingMode, $blockSize) { $blockSizeInBytes = $blockSize / 8; switch ($paddingMode) { case PaddingMode::NoPadding: return $src; case PaddingMode::Zeros: $pad = $blockSizeInBytes - strlen($src) % $blockSizeInBytes; $dst = $src . str_repeat(chr(0), $pad); return $dst; case PaddingMode::PKCS7: $pad = $blockSizeInBytes - strlen($src) % $blockSizeInBytes; $dst = $src . str_repeat(chr($pad), $pad); return $dst; case PaddingMode::OneAndZeros: $pad = $blockSizeInBytes - strlen($src) % $blockSizeInBytes; $dst = $src . chr(0x80) . str_repeat(chr(0), $pad - 1); return $dst; default: vt_loge("\x55\156\163\x75\160\160\157\162\164\x65\144\x20\160\141\144\144\x69\156\x67\x20\x6d\157\x64\x65\x3a\40" . $paddingMode); throw new \InvalidArgumentException("\125\x6e\x73\165\x70\160\x6f\162\164\x65\x64\40\x70\x61\x64\144\x69\156\147\40\155\157\x64\x65\72\40" . $paddingMode); } } public static function unpad($src, $paddingMode, $blockSize) { if (strlen($src) == 0) { throw new \InvalidArgumentException("\116\157\x20\151\x6e\160\x75\164\40\x64\x61\x74\x61\x2e"); } $blockSizeInBytes = $blockSize / 8; switch ($paddingMode) { case PaddingMode::NoPadding: return $src; case PaddingMode::Zeros: for ($i = 0; $i < $blockSizeInBytes; $i++) { if (ord($src[strlen($src) - 1 - $i]) != 0x0) { $pos = $i; break; } } return substr($src, 0, strlen($src) - $pos); case PaddingMode::PKCS7: $pad = ord($src[($len = strlen($src)) - 1]); $len = strlen($src); $pad = ord($src[$len - 1]); $dst = substr($src, 0, strlen($src) - $pad); return $dst; case PaddingMode::OneAndZeros: for ($i = 0; $i < $blockSizeInBytes; $i++) { $chr = ord($src[strlen($src) - 1 - $i]); if ($chr === 0x80) { $pos = $i + 1; break; } else { if ($chr != 0x0) { throw new \InvalidArgumentException("\116\157\x74\40\117\x6e\x65\40\141\x6e\x64\x20\132\145\162\x6f\163\40\x70\x61\x64\144\x69\156\x67\56"); } } } return substr($src, 0, strlen($src) - $pos); default: vt_loge("\x55\156\x73\165\160\160\157\x72\x74\x65\144\40\x70\x61\x64\144\x69\x6e\147\x20\155\x6f\x64\145\x3a\40" . $paddingMode); throw new \InvalidArgumentException("\125\156\x73\165\160\160\x6f\x72\164\145\x64\40\160\141\144\x64\151\156\x67\x20\x6d\x6f\x64\x65\x3a\x20" . $paddingMode); } } } class InvalidHeaderException extends Exception { }

Function Calls

None

Variables

None

Stats

MD5 9574a256b74263af0b4e72c7c66e273a
Eval Count 0
Decode Time 55 ms