Extracting data from Apple Safari's cache

Five minutes ago, i overwritten my super-shining-new CSS stylesheet that implements the "diarrea con sangue (liquid shit with blood)" color scheme i set up some days ago, because i wanted to restore the original color scheme and put it in a new theme for this site, so that people who enjoyed the old theme could continue to use it.

But as the most kiddie system administrator, i decompressed the original files from the backup archive OVER the current ones..

Safari to the rescue! Every cached item by safari is stored into a SQlite3 database located in ~/Library/Caches/com.apple.Safari, let's inspect how it is structured:

 vjt@voyager:~/Library/Caches/com.apple.Safari$ sqlite3 Cache.db 
SQLite version 3.5.1
Enter ".help" for instructions

sqlite> .tables
cfurl_cache_blob_data       cfurl_cache_schema_version
cfurl_cache_response      

sqlite> .schema cfurl_cache_response 
CREATE TABLE cfurl_cache_response(
  entry_ID INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  version INTEGER,
  hash_value INTEGER,
  storage_policy INTEGER,
  request_key TEXT UNIQUE,
  time_stamp NOT NULL DEFAULT CURRENT_TIMESTAMP);

sqlite> .schema cfurl_cache_blob_data
CREATE TABLE cfurl_cache_blob_data(
  entry_ID INTEGER PRIMARY KEY,
  response_object BLOB,
  request_object BLOB,
  receiver_data BLOB,
  proto_props BLOB,
  user_info BLOB);

sqlite> select * from cfurl_cache_response limit 3;
1|0|1897220634|0|http://..../|2008-01-19 11:10:33
2|0|-662909776|0|http://..../|2008-01-19 11:10:33

Wow. Impressive. That's why i love Apple products, because they are so well structured that you can freely inspect them and use them and their resources for every unplanned task you could have to complete.. even to fix your own mistakes Eye-wink. And it's also intriguing because you have to scratch your own itch and find the solution while exploring a beautifully constructed software product! Smiling

To make a long story short, every cached URL is stored into the request_key field of the cfurl_cache_response table, while in the receiver_data field of the cfurl_cache_blob_data there is the actual cached data.
Now we can look for the overwritten bbs theme CSS stylesheet:

sqlite> select entry_ID, request_key from cfurl_cache_response
   ...> where request_key like '%bbs/style.css';
1950|http://sniffo.org/sites/all/themes/bbs/style.css

Now, let's search in the blob_data table the entry with ID 1950:

sqlite> select receiver_data from cfurl_cache_blob_data
   ...> where entry_ID = 1950;
/**
 * Themetastic, for Drupal 5.0
 * Stefan Nagtegaal, iStyledThis [dot] nl
 * Steven Wittens, acko [dot] net`
 *
 * If you use a customized color scheme, you must regenerate it after
 * modifying this file.
[......rest of the stylesheet removed.....]

YAY! Found it! A quick cut&paste.. and sniffo.org's "diarrea con sangue" theme is back! Laughing out loud

Comments

Thanks

Thanks you!

You just saved me two hours of hardworking Smiling

You're welcome . seeya! --

You're welcome Laughing out loud.
seeya!
--
il vero sballo e` dire SUX

about sequence a flash from some special webpage

First sorry to bother u,
yesterday i saw this page "http://www.animallogic.com/#Our%20Work,_68"
i want to sequence the flash .
can you tell me how to do it ? ijust try the method you tell above but i can't find use infoemation about it.
thank you very much and hope you can tell me how to get it .

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre>
  • Textual smileys will be replaced with graphical ones.
  • Inline assets are allowed.
  • You can use BBCode tags in the text, URLs will automatically be converted to links.

More information about formatting options

============================================================================================================================================