source: lab.git/misc/chrome-about.cache.pl

Last change on this file was dc0e430, checked in by mitty <mitty@…>, 12 years ago
  • convert Google Chrome cache file to regular file
  • cache files from chrome://cache/

git-svn-id: https://lab.mitty.jp/svn/lab/trunk@129 7d2118f6-f56c-43e7-95a2-4bb3031d96e7

  • Property mode set to 100644
File size: 1.2 KB
Line 
1#! /usr/bin/perl -w
2
3use strict;
4use warnings;
5
6my $cachefile = shift @ARGV || die "usage: $0 cache.file [filename.to.save]";
7if (! -r $cachefile) {
8    die "$0: cannot read $cachefile";
9}
10my $savefile = shift @ARGV;
11
12open CACHE, "<$cachefile";
13
14
15my $hrcount = 2;
16my $filename;
17my $line;
18while ($hrcount > 0) {
19    $line = <CACHE>;
20    if ($line =~ /<hr>/) { $hrcount--; }
21    if ($line =~ /https?:.+\/([^\/<]+)</) {
22        $filename = $1;
23    }
24    if ($line =~ /Content-Disposition:.+filename=(&quot;)?([\w.]+)(&quot;)?/) {
25        $filename = $2;
26    }
27}
28print STDERR "$0: filename from cache: '$filename'\n";
29if (! $savefile) {
30    $savefile = $filename;
31}
32print STDERR "$0: save file to '$savefile'\n";
33
34$hrcount = 1;
35while ($hrcount > 0) {
36    $line = <CACHE>;
37    if ($line =~ /<hr>/) { $hrcount--; }
38}
39
40$line = substr $line, 15;
41
42open SAVE, ">$savefile" || die "$0: cannot write $savefile";
43binmode(SAVE);
44
45$hrcount = 1;
46while ($hrcount > 0) {
47    print SAVE hex2bin($line);
48   
49    $line = <CACHE>;
50    if ($line =~ /<hr>/) { $hrcount--; }
51}
52
53print STDERR "$0: done\n";
54
55sub hex2bin {
56    my $str = shift @_;
57   
58    $str = substr $str, 11, 64;
59   
60    return pack("H*", join("", split(" ", $str)));
61}
Note: See TracBrowser for help on using the repository browser.