Skip to content

Instantly share code, notes, and snippets.

@djumaka
Created May 18, 2016 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djumaka/c1d97ff0916bd8eda4ad07df9c25d0a3 to your computer and use it in GitHub Desktop.
Save djumaka/c1d97ff0916bd8eda4ad07df9c25d0a3 to your computer and use it in GitHub Desktop.
decode encrypted JS file from array to real code
<?php
$jsString = file_get_contents("./load_save_banner.js");
preg_match("/^var (.*?) = (\[.*?\]);/i", $jsString, $output_array);
$varName = $output_array[1];
$varData = eval('return '.$output_array[2].';');
foreach($varData as $key => $val) {
$jsString = str_replace($varName.'['.$key.']', "\"".addslashes($val)."\"", $jsString);
}
file_put_contents('./js/load_save_banner.js', $jsString);
file_put_contents('./js/load_save_banner.js', preg_replace("/\[\"([a-zA-Z-_0-9]+?)\"\]\(/i", ".$1(", $jsString));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment