@mherod/get-cookie 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +19 -9
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -46,7 +46,7 @@ async function getFirefoxCookie({name, domain}) {
|
|
|
46
46
|
if (domain && typeof domain !== 'string') {
|
|
47
47
|
throw new Error('domain must be a string');
|
|
48
48
|
}
|
|
49
|
-
const file = await findFile(`${process.env.HOME}/Library/Application Support/Firefox/Profiles
|
|
49
|
+
const file = await findFile(`${process.env.HOME}/Library/Application Support/Firefox/Profiles`, "cookies.sqlite")
|
|
50
50
|
if (!fs.existsSync(file)) {
|
|
51
51
|
throw new Error(`File ${file} does not exist`);
|
|
52
52
|
}
|
|
@@ -55,7 +55,7 @@ async function getFirefoxCookie({name, domain}) {
|
|
|
55
55
|
}
|
|
56
56
|
return await new Promise((resolve, reject) => {
|
|
57
57
|
let sql;
|
|
58
|
-
sql =
|
|
58
|
+
sql = "SELECT value FROM moz_cookies";
|
|
59
59
|
if (typeof name === 'string' || typeof domain === 'string') {
|
|
60
60
|
sql += ` WHERE `;
|
|
61
61
|
if (typeof name === 'string') {
|
|
@@ -72,7 +72,7 @@ async function getFirefoxCookie({name, domain}) {
|
|
|
72
72
|
if (process.env.VERBOSE) {
|
|
73
73
|
console.log(command);
|
|
74
74
|
}
|
|
75
|
-
exec(command, {encoding: 'binary', maxBuffer: 1024}, (error, stdout, stderr) => {
|
|
75
|
+
exec(command, {encoding: 'binary', maxBuffer: 5 * 1024}, (error, stdout, stderr) => {
|
|
76
76
|
if (error) {
|
|
77
77
|
reject(error);
|
|
78
78
|
return;
|
|
@@ -127,7 +127,7 @@ async function getEncryptedChromeCookie(name, domain) {
|
|
|
127
127
|
if (process.env.VERBOSE) {
|
|
128
128
|
console.log(command);
|
|
129
129
|
}
|
|
130
|
-
exec(command, {encoding: 'binary', maxBuffer: 1024}, (error, stdout, stderr) => {
|
|
130
|
+
exec(command, {encoding: 'binary', maxBuffer: 5 * 1024}, (error, stdout, stderr) => {
|
|
131
131
|
if (error) {
|
|
132
132
|
reject(error);
|
|
133
133
|
return;
|
|
@@ -186,6 +186,14 @@ async function decrypt(password, encryptedData) {
|
|
|
186
186
|
decipher.setAutoPadding(false);
|
|
187
187
|
encryptedData = encryptedData.slice(3);
|
|
188
188
|
|
|
189
|
+
if (encryptedData.length % 16 !== 0) {
|
|
190
|
+
if (process.env.VERBOSE) {
|
|
191
|
+
console.log("Error doing pbkdf2, encryptedData length is not a multiple of 16", encryptedData.length);
|
|
192
|
+
}
|
|
193
|
+
reject(new Error('encryptedData length is not a multiple of 16'));
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
189
197
|
let decoded = decipher.update(encryptedData, 'binary', 'utf8');
|
|
190
198
|
// let decoded = decipher.update(encryptedData);
|
|
191
199
|
try {
|
|
@@ -264,11 +272,13 @@ function printStringValue(r) {
|
|
|
264
272
|
if (process.env.VERBOSE) {
|
|
265
273
|
console.log("Printing value", r);
|
|
266
274
|
}
|
|
267
|
-
if (
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
275
|
+
if (r) {
|
|
276
|
+
if (typeof r === 'string') {
|
|
277
|
+
console.log(r);
|
|
278
|
+
} else if (r.toString) {
|
|
279
|
+
// noinspection JSCheckFunctionSignatures
|
|
280
|
+
console.log(r.toString('utf8'));
|
|
281
|
+
}
|
|
272
282
|
}
|
|
273
283
|
}
|
|
274
284
|
|