I'm wanting to run a Javascript script from my desktop that can pull info from a provided google chrome .localstorage file and I was curious how to do this. I know there is localstorage but that's for within the browser. I want to be able to specify say '\.config\google-chrome\Default\Local Storage\Default\http_asite.com_0.localstorage' where it then returns the k,v pairs inside. I know it is readable to some capacity since you can use tools like DB Browser to do this.
Asked
Active
Viewed 109 times
1
-
This is not JavaScript, it is for Google Chrome – Praveen Kumar Purushothaman Apr 29 '16 at 14:44
-
@PraveenKumar but I'm wanting to do this with JS – Obj3ctiv3_C_88 Apr 29 '16 at 14:44
-
Okay, updated as such. – Praveen Kumar Purushothaman Apr 29 '16 at 14:45
-
You should be able to use node and it's file system api to retrieve, read, and manipulate that data. See https://nodejs.org/api/fs.html – ruedamanuel Apr 29 '16 at 14:48
-
@ruedamanuel I considered that but I don't think it'd work since it is stored as sqlite3 – Obj3ctiv3_C_88 Apr 29 '16 at 14:50
-
Then maybe you could try using an sql3 package to read the file http://blog.modulus.io/nodejs-and-sqlite – ruedamanuel Apr 29 '16 at 16:59
-
@ruedamanuel I tried but for some reason it doesn't recognize the tables. – Obj3ctiv3_C_88 Apr 29 '16 at 17:01
-
what error do you get? – ruedamanuel Apr 29 '16 at 17:26
-
@ruedamanuel No table found not even for the master table. I did make a "solution" if you ever need something like this (posted below). – Obj3ctiv3_C_88 Apr 29 '16 at 19:27
1 Answers
0
SOOOO, if anyone else wants to do this I wrote this work in progress. It is UAF but concatenates all k,v pairs into a single string to then be parsed out. Since there isn't a really good format to interface with sqlite3, the tables aren't easy to find, and the values are stored as blob it is just a PITA to do. The index of is used to include characters that would typically be removed (so add more if needed). NOTE: This is a mac directory, ubuntu and Window users will need to account for this.
function get_storage() {
var arrayBuffer;
var file_path = '/Users/you/Library/Application\ Support/Google/Chrome/Default/Local\ Storage/asite.com.localstorage';
fs = require('fs');
fs.readFile(file_path, 'utf8', function (err, data) {
if (err) {
return console.log(err);
} else {
data = data.toString();
// Weed out garbage
data = data.replace(/[^\x00-\x7F]/g, "").replace(/\0/g, '').replace(/\3/g, '').replace('FAIL)', '').split(" ");
var user_credentials = data[data.length - 1].split("");
var my_result = [];
// Account for js keywords
for (var i = 0; i < user_credentials.length; i++) {
if (/\r|\n|\t|\b/.exec(user_credentials[i]) != null ||
user_credentials[i].indexOf("@") > -1 ||
user_credentials[i].indexOf("!") > -1 ||
user_credentials[i].indexOf(".") > -1) {
my_result.push(user_credentials[i]);
}
}
// final sweep because some will get missed
my_result = my_result.join("").split("\n")[0].split("\r")[1];
// a site's local storage
console.log(my_result)
}
});
}
get_storage();

Obj3ctiv3_C_88
- 1,478
- 1
- 17
- 29