Skip to content

Instantly share code, notes, and snippets.

@dozykeys
Last active June 30, 2022 13:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dozykeys/9b76b16bd675447a6f7592a14efa64c6 to your computer and use it in GitHub Desktop.
Save dozykeys/9b76b16bd675447a6f7592a14efa64c6 to your computer and use it in GitHub Desktop.
This is a php Obfuscator class. It simply obfuscates the php source code while still parsing it correctly when implemented.
<?php
namespace Obfuscator;
/**
* Class Obfuscator
* @author Duru Chidozie
* @copyright 2019
* @version 1.0.0
*
*/
class Obfuscator {
public static $inputPath;
public static $outputPath;
public function __construct($inputPath,$outputPath){
self::$inputPath=$inputPath;
self::$outputPath=$outputPath;
}
public static function obfuscate(){
if (!self::$inputPath || !self::$outputPath) {
die("Error: Not Found - input file or output file\n");
}
$data="ob_end_clean();?>";
$data.=php_strip_whitespace(self::$inputPath);
// compress data
$data=gzcompress($data,9);
// encode in base64
$data=base64_encode($data);
$out='<?php ob_start();$akugkjugkjgkujfkhdjdutduydihfoufkudysiyikufolufkudikydiufoujfoudkyxujtsyrsrfsytgdihogipigogoakugkjugkjgkujfkhdjdutduydihfoufkudysiyikufolufkudikydiufoujfoudkyxujtsyrsrfsytgdihogipigogoakugkjugkjgkujfkhdjdutduydihfoufkudysiyikufolufkudikydiufoujfoudkyxujtsyrsrfsytgdihogipigogo=\''.$data.'\';eval(gzuncompress(base64_decode($akugkjugkjgkujfkhdjdutduydihfoufkudysiyikufolufkudikydiufoujfoudkyxujtsyrsrfsytgdihogipigogoakugkjugkjgkujfkhdjdutduydihfoufkudysiyikufolufkudikydiufoujfoudkyxujtsyrsrfsytgdihogipigogoakugkjugkjgkujfkhdjdutduydihfoufkudysiyikufolufkudikydiufoujfoudkyxujtsyrsrfsytgdihogipigogo)));$v=ob_get_contents();ob_end_clean(); echo $v;?>';
// write output text
file_put_contents(self::$outputPath,$out);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment