Chrome 扩展的文件提取

在 google chrome store 上有一个很不错的扩展,叫做 dream afar,他会修改 chrome 的新标签页,替换成很漂亮的背景图,而且还会定时更新,图片确实很不错,于是我就想找到图片源,一开始以为,页面上的图片嘛,总是应该从网络上下载的,于是开 google chrome 的开发者工具,抓了半天没抓到,都提示 from cache,那我就开隐身模式,结果还是不行,哪怕我拿 wireshark 去抓,也不行。

于是只能从另外的思路去想,这个扩展本身提供一个下载的功能,但是只能下载当前图片,下载的路径是类似,filesystem:chrome-extension://henmfoppjjkcencpbjaigfahdjlgpegn/temporary/backgrounds/Niagara_Falls/1.jpg,这样的路径。那么就想到这肯定对应磁盘上的一个文件嘛。前面那个 henmfoppjjkcencpbjaigfahdjlgpegn 应该就是这个扩展的 id 了,操起全盘的文件搜索工具就是一阵搜,结果还真的找到这个文件夹,但是进去翻了半天,只找到一张图,剩下的全都不见踪影,这个图估计是第一次的 init 的图。这就见鬼了,既不是从网络上搞的图,本地也找不到,那么图片会在哪里呢。

继续搜,在这里,http://tieba.baidu.com/p/30306…,有人提到

更正:
在地址栏输入:filesystem:chrome-extension://henmfoppjjkcencpbjaigfahdjlgpegn/temporary/backgrounds/
就能看到图片列表了。

试了一下,确实可行,而且这里可以看到所有的图片。

那么问题就来了,这些图片,到底藏身在磁盘上的什么地方呢。他的 url 是 filesystem:chrome-extension: 开头的,看起来,跟 google 的一些文件操作的 api 有关,这个也是 html5 的 api,看到这里,http://stackoverflow.com/quest…

Also, the HTML5 Filesystem API only provides access to a virtual filesystem, as you’ve observed.

人家说了,这是一个虚拟的文件系统,那么就不是常规的那种管理磁盘文件的方式了,但是文件在哪里呢,继续搜,看到这里,http://stackoverflow.com/quest…

For me, at least on Mac OSX, they’re stored under /Users/USERNAME/Library/Application Support/Google/Chrome/Default/File System for me.

这是说的 mac 的情况,在 windows 上,情况类似,路径在这里,C:\Users\xxxx\AppData\Local\Google\Chrome\User Data\Default\File System,可以看到一堆没有后缀名的 raw 文件,结合文件大小,挑了几个来看,确实是想要的图片没错。

另外也说明了怎么去调试这些文件系统:

For debugging the Filesystem API, you have a few options:

Use this extension to view/remove files.
See the tips here: http://updates.html5rocks.com/… That includes viewing stored files very easily using the filesystem: URLs.
Drop the Filesystem Playground demo (http://html5-demos.appspot.com…) into your origin. You can use that to view/rename/delete files/folders easily.
Chrome DevTools now has support for the Filesystem API for viewing the files stored under an origin. To use that, you will need to enable the Developer Tools experiments in about:flags, restart, hit the gear in the devtools (lower right corner), and enable the ‘FileSystem inspection’ under the experimental tab.

但是,问题是,怎么把这些文件按照原样的目录结构,导出来呢

有一个想法是考虑到 filesystem:chrome-extension://henmfoppjjkcencpbjaigfahdjlgpegn/temporary/backgrounds/ 这个页面既然是 web 界面,那可以用以前那些下载工具,自动递归的遍历,把所有文件抓回来,可惜的是,这个貌似是一个比较特殊的 web 界面,那些工具都没有成功的加上右键的批量下载的触发。

于是就直接把那些没有后缀名的文件拷出来,批量加上后缀,就算了。这种方式简单粗暴,但是只能在预先知道后缀的情况下可以这么搞。

———————–

2014-12-9 17:44:46 update 图片真的不错,我把图片都丢到豆瓣相册上了,这里,http://www.douban.com/photos/a…

Leave a Reply

Your email address will not be published. Required fields are marked *