Last active
January 8, 2017 12:59
-
-
Save yani/8ce85bf2bad289d285c29a9b1e2c1eca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
A Simple Dynamic PHP & JS obfuscation script | |
- Made by Yani | |
https://github.com/Yanikore - https://gist.github.com/Yanikore | |
*/ | |
function randomString($length = 8) { //Just a randomstring function | |
$randomString = ''; | |
$characters = implode("", array_merge(range('a', 'z'), range('A', 'Z'))); | |
for ($i = 0; $i < $length; $i++) | |
$randomString .= $characters[mt_rand(0, strlen($characters) - 1)]; | |
return $randomString; | |
} | |
function enc($output) { //Obfuscation code | |
$randomFunc = randomString(mt_rand(6,12)); | |
$randomOut = randomString(mt_rand(6,12)); | |
$randomNum = randomString(mt_rand(6,12)); | |
$randomVal = mt_rand(1337, 99999999); | |
$return = '<script>' . PHP_EOL; | |
$return .= 'var ' . $randomOut . ' = "";' . PHP_EOL; | |
$return .= 'var ' . $randomNum . ' = ['; | |
foreach(str_split($output) as $x) { | |
$return .= (ord($x) + $randomVal) . ', '; | |
} | |
$return = rtrim($return, ', '); | |
$return .= '];' . PHP_EOL; | |
$return .= $randomNum . '.forEach(function ' . $randomFunc . '(value) { ' . $randomOut . ' += String.fromCharCode(parseInt(value) - ' . $randomVal . '); } );' . PHP_EOL; | |
$return .= 'document.write(' . $randomOut . ');'; | |
$return .= '</script>'; | |
return $return; | |
} | |
ob_start("enc"); // Open our buffer and use the enc() function on it | |
echo "YANI"; | |
ob_end_flush(); // Close our buffer which will display the output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment