Reverse engineering the iPhone CacheResourceData web-app database

Status
Not open for further replies.

Catfish

Ars Tribunus Angusticlavius
9,954
Heya,
So I did something stupid earlier ("find . -delete -name '*.bak'" if you must know), and lost a bunch of work. Good news : it was a web app that my iPhone has cached for offline access. Bad news : it appears to be stored in a totally opaque database field.

In my iPhone backup files, I figured out which db file corresponds to the web caches. The CacheResources mentions the url of my app, and I'm reasonably sure I know which row of CacheResourceData it corresponds to. But the data column that stores the actual cache seems to be some compressed binary:

Code:
$ more manifest
??????ß½?“†²J?Éü²Jžƒ–{?
$ hexdump -C manifest
00000000  e4 85 83 e4 a1 83 e2 81  85 e4 85 8d e4 a5 8e e4  |................|
00000010  95 86 e5 91 93 e0 a8 8a  e6 90 af e7 9d af e4 85  |................|
00000020  ae e7 89 b2 e7 9d af e7  80 ae e6 9d ae e0 a8 8a  |................|
00000030

That (I think) is my manifest file, which means it probably starts with the text 'CACHE MANIFEST', if that helps at all. Anyone got any bright ideas on extracting it and the rest of my data?

A long shot, I know...
 

MooseAreFun

Ars Legatus Legionis
10,827
Subscriptor
Since your iPhone has it cached for offline use, can you put it into flight mode, open the site, and then copy the data out by hand?

If it's the HTML5 style website accessible database then this StackOverflow question suggests it's using SQLite, however the comment "The short name is the name for your database as stored on disk (usually in ~/Library/Safari/Databases/)." from the linked docs makes me think that's not what you have there.


Is what you've posted the entire file? It doesn't look like much data...

Mobile Safari is WebKit based - I haven't a clue what this means in practise as for how much mobile safari crosses over with the open source bits - but maybe the webkit source would be somewhere to dig through for ideas on how the offline caching works?
 

Catfish

Ars Tribunus Angusticlavius
9,954
The application cache is a sqlite database - the chunk I've posted is a dump of the data column from the CacheResourceData, from the row corresponding to my manifest url. So I'm fairly sure I've got the data, it's just decoding it that's tricky. I've been looking through the webkit source but haven't quite figured out why it's not just a plain utf8 dump of the resource ... it's getting to the point where it seems like it would be less work to just rewrite it from scratch.
 
Status
Not open for further replies.