I try to build a PHP script to obfuscate the code on the swf files replacing variables and functions. I try this:
function replaceSwf($src,$dest) {
$content=file_get_contents($src);
$header=substr($content, 0, 8);
$content=gzuncompress(substr($content, 8));
// replace variables
$content=str_replace($str_find,$str_repl,$content);
// compress SWF file
$real_size=pack("V", strlen($header.$content));
$header=substr($header,0,4).$real_size;
$header="CWS".substr($header,3);
$content=$header.gzcompress($content);
// save new SWF
$fp=fopen($dest,"wb");
$result=fwrite($fp,$content);
fclose($fp);
}
This code work only if $str_find and $str_repl variables have the same length. Why don't with different length ?