├── README.md ├── modified └── obfuscator.php └── original ├── Docs - Please read!.txt ├── HunterObfuscator.php └── index.php /README.md: -------------------------------------------------------------------------------- 1 | # Hunter - PHP Javascript Obfuscator 2 | > :lock: Protect your JavaScript source code with the simplest and fastest way. 3 | 4 | ### :squirrel: [Investigate the live demo](https://damidev.000webhostapp.com/) 5 | 6 | ## Requirement 7 | ```php 8 | require_once 'HunterObfuscator.php'; //Include the class 9 | ``` 10 | 11 | ## Simple usage to obfuscate JS code: 12 | ```php 13 | $jsCode = "alert('Hello world!');"; //Simple JS code 14 | $hunter = new HunterObfuscator($jsCode); //Initialize with JS code in parameter 15 | $obsfucated = $hunter->Obfuscate(); //Do obfuscate and get the obfuscated code 16 | echo ""; 17 | ``` 18 | 19 | ## Simple usage to obfuscate HTML code: 20 | 21 | ```php 22 | $htmlCode = "
Hello world!
"; //Simple HTML code 23 | $hunter = new HunterObfuscator($htmlCode, true); //Initialize with HTML code in first parameter and set second one to TRUE 24 | $obsfucated = $hunter->Obfuscate(); //Do obfuscate and get the obfuscated code 25 | echo ""; 26 | ``` 27 | 28 | > **Note**: If your HTML code contains any JS codes please remove any comments in that js code to prevent issues. 29 | 30 | ## Set expiration time: 31 | 32 | ```php 33 | $hunter->setExpiration('+10 day'); //Expires after 10 days 34 | $hunter->setExpiration('Next Friday'); //Expires next Friday 35 | $hunter->setExpiration('tomorrow'); //Expires tomorrow 36 | $hunter->setExpiration('+5 hours'); //Expires after 5 hours 37 | $hunter->setExpiration('+1 week 3 days 7 hours 5 seconds'); //Expires after +1 week 3 days 7 hours and 5 seconds 38 | ``` 39 | 40 | ## Domain name lock: 41 | 42 | ```php 43 | $hunter->addDomainName('google.com'); //the generated code will work only on google.com 44 | ``` 45 | 46 | > **Note**: you can add multiple domains by adding one by one. 47 | 48 | #### See the included demo (/original/index.php) for more. 49 | 50 | #### Happy Coding :) 51 | 52 | 53 | ## CHANGE LOG (YYYY/MM/DD) 54 | 55 | * v1.2 - **2018-01-11** 56 | * fixed utf8 characters 57 | 58 | * v1.1 - **2017-11-20** 59 | * Some improvments 60 | * Added expiration time 61 | * Added domain name lock 62 | * Added ability to obfuscate HTML code 63 | * New demo script 64 | 65 | * v1.0 - **2017-07-27** 66 | * Initial release 67 | -------------------------------------------------------------------------------- /modified/obfuscator.php: -------------------------------------------------------------------------------- 1 | [^\S ]+/s','/[^\S ]+\/'),$replace=array('>','<','\\1',''); 5 | 6 | static function getMask(){ return substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'),0,9); } 7 | 8 | static function hashIt($s){ 9 | for($i=0;$iHello world!
"; //Simple HTML code 17 | $hunter = new HunterObfuscator($htmlCode, true); //Initialize with HTML code in first parameter and set second one to TRUE 18 | $obsfucated = $hunter->Obfuscate(); //Do obfuscate and get the obfuscated code 19 | echo ""; 20 | 21 | Note: If your HTML code contains any JS codes please remove any comments in that js code to prevent issues. 22 | 23 | 24 | ##Set expiration time: 25 | $hunter->setExpiration('+10 day'); //Expires after 10 days 26 | $hunter->setExpiration('Next Friday'); //Expires next Friday 27 | $hunter->setExpiration('tomorrow'); //Expires tomorrow 28 | $hunter->setExpiration('+5 hours'); //Expires after 5 hours 29 | $hunter->setExpiration('+1 week 3 days 7 hours 5 seconds'); //Expires after +1 week 3 days 7 hours and 5 seconds 30 | 31 | ##Domain name lock: 32 | $hunter->addDomainName('google.com'); //the generated code will work only on google.com 33 | Note: you can add multiple domains by adding one by one. 34 | 35 | See the included demo for more. 36 | 37 | Happy Coding :) 38 | 39 | 40 | ******* CHANGE LOG ******* 41 | 42 | v1.0 2017-07-27 43 | #Initial release 44 | 45 | v1.1 2017-11-20 46 | #Some improvments 47 | #Added expiration time 48 | #Added domain name lock 49 | #Added ability to obfuscate HTML code 50 | #New demo script -------------------------------------------------------------------------------- /original/HunterObfuscator.php: -------------------------------------------------------------------------------- 1 | cleanHtml($Code); 17 | $this->code = $this->html2Js($Code); 18 | } else { 19 | $Code = $this->cleanJS($Code); 20 | $this->code = $Code; 21 | } 22 | 23 | $this->mask = $this->getMask(); 24 | $this->interval = rand(1, 50); 25 | $this->option = rand(2, 8); 26 | } 27 | 28 | private function getMask() 29 | { 30 | $charset = str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); 31 | return substr($charset, 0, 9); 32 | } 33 | 34 | private function hashIt($s) 35 | { 36 | for ($i = 0; $i < strlen($this->mask); ++$i) 37 | $s = str_replace("$i", $this->mask[$i], $s); 38 | return $s; 39 | } 40 | 41 | private function prepare() 42 | { 43 | if (count($this->domainNames) > 0) { 44 | $code = "if(window.location.hostname==='" . $this->domainNames[0] . "' "; 45 | for ($i = 1; $i < count($this->domainNames); $i++) 46 | $code .= "|| window.location.hostname==='" . $this->domainNames[$i] . "' "; 47 | $this->code = $code . "){" . $this->code . "}"; 48 | } 49 | if ($this->expireTime > 0) 50 | $this->code = 'if((Math.round(+new Date()/1000)) < ' . $this->expireTime . '){' . $this->code . '}'; 51 | } 52 | 53 | private function encodeIt() 54 | { 55 | $this->prepare(); 56 | $str = ""; 57 | for ($i = 0; $i < strlen($this->code); ++$i) 58 | $str .= $this->hashIt(base_convert(ord($this->code[$i]) + $this->interval, 10, $this->option)) . $this->mask[$this->option]; 59 | return $str; 60 | } 61 | 62 | public function Obfuscate() 63 | { 64 | $rand = rand(0,99); 65 | $rand1 = rand(0,99); 66 | return "var _0xc{$rand}e=[\"\",\"\x73\x70\x6C\x69\x74\",\"\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x2B\x2F\",\"\x73\x6C\x69\x63\x65\",\"\x69\x6E\x64\x65\x78\x4F\x66\",\"\",\"\",\"\x2E\",\"\x70\x6F\x77\",\"\x72\x65\x64\x75\x63\x65\",\"\x72\x65\x76\x65\x72\x73\x65\",\"\x30\"];function _0xe{$rand1}c(d,e,f){var g=_0xc{$rand}e[2][_0xc{$rand}e[1]](_0xc{$rand}e[0]);var h=g[_0xc{$rand}e[3]](0,e);var i=g[_0xc{$rand}e[3]](0,f);var j=d[_0xc{$rand}e[1]](_0xc{$rand}e[0])[_0xc{$rand}e[10]]()[_0xc{$rand}e[9]](function(a,b,c){if(h[_0xc{$rand}e[4]](b)!==-1)return a+=h[_0xc{$rand}e[4]](b)*(Math[_0xc{$rand}e[8]](e,c))},0);var k=_0xc{$rand}e[0];while(j>0){k=i[j%f]+k;j=(j-(j%f))/f}return k||_0xc{$rand}e[11]}eval(function(h,u,n,t,e,r){r=\"\";for(var i=0,len=h.length;i