我必须解码一个名为cache.log
的Chrome缓存文件的二进制内容数据。我试图解码它的方式是使用我在这里找到的PHP脚本
http://www.frozax.com/blog/2011/05/recover-file-google-chrome-cache-gzipped/
我已经使用以下命令安装了php
sudo apt-get install php5 libapache2-mod-php5
sudo apt-get install php5-cgi
当我尝试运行index1.php
脚本时,我在终端
s3z@s3z-laptop:~/Desktop$ php index1.php
PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0
// cache.log is a copy of chrome cache page with only the file content section
$cacheString = file_get_contents("cache.log");
$matches = array();
preg_match_all('/\s[0-9a-f]{2}\s/', $cacheString, $matches);
$f = fopen("t.bin","wb");
foreach ($matches[0] as $match)
{
fwrite($f,chr(hexdec($match)));
}
fclose($f);
ob_start();
readgzfile("t.bin");
$decoded_data=ob_get_clean();
echo $decoded_data;
正如您所看到的,它正在做的就是回显脚本。
如何实际运行脚本?
答案 0 :(得分:17)
看起来代码不包含在:
<?php
?>
如果没有,它只是回声而不是执行。原因是PHP允许您将服务器脚本和HTML混合在同一个文件中。
<html>
<head><title></title></head>
<body>
<?php
//Inside the php block so it gets executed and prints 'Hello World'
echo "Hello, World!";
?>
<!--Outside the php block so it just gets echoed and prints 'echo "Hello, World!";' -->
echo "Hello, World!";
</body>
</html>