How can I read Chrome Cache files?

前端 未结 12 1148
無奈伤痛
無奈伤痛 2020-12-12 21:22

A forum I frequent was down today, and upon restoration, I discovered that the last two days of forum posting had been rolled back completely.

Needless to say, I\'d

相关标签:
12条回答
  • 2020-12-12 21:45

    It was removed on purpose and it won't be coming back.

    Both chrome://cache and chrome://view-http-cache have been removed starting chrome 66. They work in version 65.

    Workaround

    You can check the chrome://chrome-urls/ for complete list of internal Chrome URLs.

    The only workaround that comes into my mind is to use menu/more tools/developer tools and having a Network tab selected.

    The reason why it was removed is this bug:

    • https://chromium.googlesource.com/chromium/src.git/+/6ebc11f6f6d112e4cca5251d4c0203e18cd79adc
    • https://bugs.chromium.org/p/chromium/issues/detail?id=811956

    The discussion:

    • https://groups.google.com/a/chromium.org/forum/#!msg/net-dev/YNct7Nk6bd8/ODeGPq6KAAAJ
    0 讨论(0)
  • 2020-12-12 21:48

    EDIT: The below answer no longer works see here


    Google Chrome cache file format description.

    Cache files list, see URLs (copy and paste to your browser address bar):

    • chrome://cache/
    • chrome://view-http-cache/

    Cache folder in Linux: $~/.cache/google-chrome/Default/Cache

    Let's determine in file GZIP encoding:

    $ head f84358af102b1064_0 | hexdump -C | grep --before-context=100 --after-context=5 "1f 8b 08"
    

    Extract Chrome cache file by one line on PHP (without header, CRC32 and ISIZE block):

    $ php -r "echo gzinflate(substr(strchr(file_get_contents('f84358af102b1064_0'), \"\x1f\x8b\x08\"), 10,
    -8));"
    
    0 讨论(0)
  • 2020-12-12 21:51

    The Google Chrome cache directory $HOME/.cache/google-chrome/Default/Cache on Linux contains one file per cache entry named <16 char hex>_0 in "simple entry format":

    • 20 Byte SimpleFileHeader
    • key (i.e. the URI)
    • payload (the raw file content i.e. the PDF in our case)
    • SimpleFileEOF record
    • HTTP headers
    • SHA256 of the key (optional)
    • SimpleFileEOF record

    If you know the URI of the file you're looking for it should be easy to find. If not, a substring like the domain name, should help narrow it down. Search for URI in your cache like this:

    fgrep -Rl '<URI>' $HOME/.cache/google-chrome/Default/Cache
    

    Note: If you're not using the default Chrome profile, replace Default with the profile name, e.g. Profile 1.

    0 讨论(0)
  • 2020-12-12 21:52

    EDIT: The below answer no longer works see here


    Chrome stores the cache as a hex dump. OSX comes with xxd installed, which is a command line tool for converting hex dumps. I managed to recover a jpg from my Chrome's HTTP cache on OSX using these steps:

    1. Goto: chrome://cache
    2. Find the file you want to recover and click on it's link.
    3. Copy the 4th section to your clipboard. This is the content of the file.
    4. Follow the steps on this gist to pipe your clipboard into the python script which in turn pipes to xxd to rebuild the file from the hex dump: https://gist.github.com/andychase/6513075

    Your final command should look like:

    pbpaste | python chrome_xxd.py | xxd -r - image.jpg

    If you're unsure what section of Chrome's cache output is the content hex dump take a look at this page for a good guide: http://www.sparxeng.com/blog/wp-content/uploads/2013/03/chrome_cache_html_report.png

    Image source: http://www.sparxeng.com/blog/software/recovering-images-from-google-chrome-browser-cache

    More info on XXD: http://linuxcommand.org/man_pages/xxd1.html

    Thanks to Mathias Bynens above for sending me in the right direction.

    0 讨论(0)
  • 2020-12-12 21:52

    EDIT: The below answer no longer works see here


    If the file you try to recover has Content-Encoding: gzip in the header section, and you are using linux (or as in my case, you have Cygwin installed) you can do the following:

    1. visit chrome://view-http-cache/ and click the page you want to recover
    2. copy the last (fourth) section of the page verbatim to a text file (say: a.txt)
    3. xxd -r a.txt| gzip -d

    Note that other answers suggest passing -p option to xxd - I had troubles with that presumably because the fourth section of the cache is not in the "postscript plain hexdump style" but in a "default style".

    It also does not seem necessary to replace double spaces with a single space, as chrome_xxd.py is doing (in case it is necessary you can use sed 's/ / /g' for that).

    0 讨论(0)
  • 2020-12-12 21:55

    I had some luck with this open-source Python project, seemingly inactive: https://github.com/JRBANCEL/Chromagnon

    I ran:

    python2 Chromagnon/chromagnonCache.py path/to/Chrome/Cache -o browsable_cache/
    

    And I got a locally-browsable extract of all my open tabs cache.

    0 讨论(0)
提交回复
热议问题