@mherod/get-cookie 1.3.0 → 2.0.0-beta.1
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/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/main.js +294 -225
- package/dist/main.js.map +1 -1
- package/package.json +2 -1
- package/src/browsers/AbstractCookieQueryStrategy.js +8 -0
- package/src/browsers/ChromeCookieQueryStrategy.js +263 -0
- package/src/browsers/CompositeCookieQueryStrategy.js +28 -0
- package/src/browsers/FirefoxCookieQueryStrategy.js +77 -0
- package/src/browsers/SafariCookieQueryStrategy.js +3 -0
- package/src/cli.js +56 -44
- package/src/findAllFiles.js +73 -0
- package/src/global.js +4 -0
- package/src/index.js +38 -439
- package/src/isValidJwt.js +17 -0
- package/src/queryCookies.js +28 -0
- package/src/utils.js +12 -16
package/dist/main.js
CHANGED
|
@@ -1,32 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var $bU6Ve$
|
|
2
|
+
var $bU6Ve$lodash = require("lodash");
|
|
3
3
|
var $bU6Ve$fs = require("fs");
|
|
4
4
|
var $bU6Ve$crypto = require("crypto");
|
|
5
|
-
var $bU6Ve$
|
|
5
|
+
var $bU6Ve$path = require("path");
|
|
6
6
|
var $bU6Ve$child_process = require("child_process");
|
|
7
7
|
var $bU6Ve$sqlite3 = require("sqlite3");
|
|
8
|
+
var $bU6Ve$jsonwebtoken = require("jsonwebtoken");
|
|
8
9
|
|
|
10
|
+
function $parcel$export(e, n, v, s) {
|
|
11
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
12
|
+
}
|
|
9
13
|
function $parcel$interopDefault(a) {
|
|
10
14
|
return a && a.__esModule ? a.default : a;
|
|
11
15
|
}
|
|
12
16
|
|
|
17
|
+
$parcel$export(module.exports, "getCookie", () => $af7abeb0794bd6fa$export$4be65e66cfa2648a);
|
|
18
|
+
$parcel$export(module.exports, "getFirefoxCookie", () => $af7abeb0794bd6fa$export$c44c5fdef43f0941);
|
|
19
|
+
$parcel$export(module.exports, "getChromeCookie", () => $af7abeb0794bd6fa$export$e5637297e9eb6f2e);
|
|
20
|
+
class $36bba8acd7b702be$export$2e2bcd8739ae039 {
|
|
21
|
+
async queryCookies(name, domain) {
|
|
22
|
+
if (process.env.NODE_ENV === "development") console.log("queryCookie", name, domain);
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
13
26
|
|
|
14
27
|
|
|
15
|
-
var $fa5ed5287f8fdf72$require$merge = $bU6Ve$lodash.merge;
|
|
16
|
-
const $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3 = {};
|
|
17
|
-
$fa5ed5287f8fdf72$require$merge($fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3, process.env);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (process.platform !== "darwin") throw new Error("This script only works on macOS");
|
|
21
|
-
var $c0cdc003fbf917f0$exports = {};
|
|
22
28
|
|
|
23
|
-
var $c0cdc003fbf917f0$require$exec = $bU6Ve$child_process.exec;
|
|
24
29
|
|
|
25
|
-
async function $c0cdc003fbf917f0$
|
|
30
|
+
async function $c0cdc003fbf917f0$export$8d71c74f97c0202e(command) {
|
|
26
31
|
if (typeof command !== "string") throw new TypeError("execSimple: command must be a string");
|
|
27
32
|
if (process.env.VERBOSE) console.log(command);
|
|
28
33
|
return new Promise((resolve, reject)=>{
|
|
29
|
-
$
|
|
34
|
+
(0, $bU6Ve$child_process.exec)(command, {
|
|
30
35
|
encoding: "binary",
|
|
31
36
|
maxBuffer: 5120
|
|
32
37
|
}, (error, stdout, stderr)=>{
|
|
@@ -42,11 +47,11 @@ async function $c0cdc003fbf917f0$var$execSimple(command) {
|
|
|
42
47
|
});
|
|
43
48
|
});
|
|
44
49
|
}
|
|
45
|
-
async function $c0cdc003fbf917f0$
|
|
50
|
+
async function $c0cdc003fbf917f0$export$1704cc27537f7088(command) {
|
|
46
51
|
if (typeof command !== "string") throw new TypeError("execAsBuffer: command must be a string");
|
|
47
52
|
if (process.env.VERBOSE) console.log(command);
|
|
48
53
|
return await new Promise((resolve, reject)=>{
|
|
49
|
-
$
|
|
54
|
+
(0, $bU6Ve$child_process.exec)(command, {
|
|
50
55
|
encoding: "binary",
|
|
51
56
|
maxBuffer: 5120
|
|
52
57
|
}, (error, stdout, stderr)=>{
|
|
@@ -65,7 +70,7 @@ async function $c0cdc003fbf917f0$var$execAsBuffer(command) {
|
|
|
65
70
|
});
|
|
66
71
|
});
|
|
67
72
|
}
|
|
68
|
-
function $c0cdc003fbf917f0$
|
|
73
|
+
function $c0cdc003fbf917f0$export$33d3adc27420eed5(r) {
|
|
69
74
|
if (process.env.VERBOSE) console.log("Printing value", r);
|
|
70
75
|
if (r) {
|
|
71
76
|
if (typeof r === "string") return r;
|
|
@@ -73,7 +78,7 @@ function $c0cdc003fbf917f0$var$toStringValue(r) {
|
|
|
73
78
|
return r.toString("utf8");
|
|
74
79
|
}
|
|
75
80
|
}
|
|
76
|
-
function $c0cdc003fbf917f0$
|
|
81
|
+
function $c0cdc003fbf917f0$export$1ed1ce2ec2b4f5a3(r) {
|
|
77
82
|
if (process.env.VERBOSE) console.log("Printing value", r);
|
|
78
83
|
if (r) {
|
|
79
84
|
if (typeof r === "string") console.log(r);
|
|
@@ -81,11 +86,7 @@ function $c0cdc003fbf917f0$var$printStringValue(r) {
|
|
|
81
86
|
console.log(r.toString("utf8"));
|
|
82
87
|
}
|
|
83
88
|
}
|
|
84
|
-
|
|
85
|
-
*
|
|
86
|
-
* @param result
|
|
87
|
-
* @returns {string|null}
|
|
88
|
-
*/ function $c0cdc003fbf917f0$var$toStringOrNull(result) {
|
|
89
|
+
function $c0cdc003fbf917f0$export$d53bf2de587a369(result) {
|
|
89
90
|
if (result == null) return null;
|
|
90
91
|
if (process.env.VERBOSE) console.log("result", result);
|
|
91
92
|
if (typeof result === "string" && result.length > 0) return result;
|
|
@@ -94,15 +95,10 @@ function $c0cdc003fbf917f0$var$printStringValue(r) {
|
|
|
94
95
|
return null;
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
|
|
98
|
-
*
|
|
99
|
-
* @param {string} file
|
|
100
|
-
* @param {string} sql
|
|
101
|
-
* @returns {Promise<Buffer[]>}
|
|
102
|
-
*/ async function $c0cdc003fbf917f0$var$doSqliteQuery1(file, sql) {
|
|
98
|
+
async function $c0cdc003fbf917f0$export$f19f611d1fa7c6f3(file, sql) {
|
|
103
99
|
if (typeof sql !== "string") throw new TypeError("doSqliteQuery1: sql must be a string");
|
|
104
100
|
if (typeof file !== "string") throw new TypeError("doSqliteQuery1: file must be a string");
|
|
105
|
-
if (
|
|
101
|
+
if (!(0, ($parcel$interopDefault($bU6Ve$fs))).existsSync(file)) throw new Error(`doSqliteQuery1: file ${file} does not exist`);
|
|
106
102
|
if (process.env.VERBOSE) {
|
|
107
103
|
console.log(`doSqliteQuery1: file ${file}`);
|
|
108
104
|
console.log(`doSqliteQuery1: sql ${sql}`);
|
|
@@ -137,106 +133,151 @@ function $c0cdc003fbf917f0$var$printStringValue(r) {
|
|
|
137
133
|
});
|
|
138
134
|
});
|
|
139
135
|
}
|
|
140
|
-
$c0cdc003fbf917f0$
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
136
|
+
function $c0cdc003fbf917f0$export$99ce3e33a555daf1(input) {
|
|
137
|
+
return typeof input !== "string" || input.length === 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
var $fa5ed5287f8fdf72$require$merge = $bU6Ve$lodash.merge;
|
|
143
|
+
const $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3 = {};
|
|
144
|
+
$fa5ed5287f8fdf72$require$merge($fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3, process.env);
|
|
145
|
+
const $fa5ed5287f8fdf72$export$a7c5707626fc90f = $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3["HOME"];
|
|
146
|
+
if (!$fa5ed5287f8fdf72$export$a7c5707626fc90f) throw new Error("HOME environment variable is not set");
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
async function $d6c2e79f3cdd498d$export$2c9faf86071156ae({ path: path , name: name , maxDepth: maxDepth = 2 }) {
|
|
153
|
+
if (typeof path !== "string") throw new Error("path must be a string");
|
|
154
|
+
if (typeof name !== "string") throw new Error("name must be a string");
|
|
155
|
+
const rootSegments = path.split("/").length;
|
|
156
|
+
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log(`Searching for ${name} in ${path}`);
|
|
157
|
+
const files = [];
|
|
158
|
+
let readdirSync;
|
|
157
159
|
try {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
return true;
|
|
163
|
-
} catch (err) {
|
|
164
|
-
return false;
|
|
160
|
+
readdirSync = (0, ($parcel$interopDefault($bU6Ve$fs))).readdirSync(path);
|
|
161
|
+
} catch (e) {
|
|
162
|
+
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log(`Error reading ${path}`, e);
|
|
163
|
+
return files;
|
|
165
164
|
}
|
|
165
|
+
for (const file of readdirSync){
|
|
166
|
+
const filePath = path + "/" + file;
|
|
167
|
+
let stat;
|
|
168
|
+
try {
|
|
169
|
+
stat = (0, ($parcel$interopDefault($bU6Ve$fs))).statSync(filePath);
|
|
170
|
+
} catch (e1) {
|
|
171
|
+
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.error(`Error getting stat for ${filePath}`, e1);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (stat.isDirectory()) {
|
|
175
|
+
if (filePath.split("/").length < rootSegments + maxDepth) try {
|
|
176
|
+
const subFiles = await $d6c2e79f3cdd498d$export$2c9faf86071156ae({
|
|
177
|
+
path: filePath,
|
|
178
|
+
name: name,
|
|
179
|
+
rootSegments: rootSegments,
|
|
180
|
+
maxDepth: 2
|
|
181
|
+
});
|
|
182
|
+
files.push(...subFiles);
|
|
183
|
+
} catch (e2) {
|
|
184
|
+
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.error(e2);
|
|
185
|
+
}
|
|
186
|
+
} else if (file === name) files.push(filePath);
|
|
187
|
+
}
|
|
188
|
+
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) {
|
|
189
|
+
if (files.length > 0) {
|
|
190
|
+
console.log(`Found ${files.length} ${name} files`);
|
|
191
|
+
console.log(files);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return files;
|
|
166
195
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).CHROME_ONLY) {
|
|
179
|
-
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("chrome only");
|
|
180
|
-
return $af7abeb0794bd6fa$var$getChromeCookie(params).then((cookie)=>{
|
|
181
|
-
if (cookie && cookie.length > 0) return $af7abeb0794bd6fa$require$toStringValue(cookie);
|
|
182
|
-
}).catch((err)=>{
|
|
183
|
-
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.error(err);
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
class $1c57ad353fa3519e$export$2e2bcd8739ae039 extends (0, $36bba8acd7b702be$export$2e2bcd8739ae039) {
|
|
201
|
+
async queryCookies(name, domain) {
|
|
202
|
+
if (process.platform !== "darwin") throw new Error("This only works on macOS");
|
|
203
|
+
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).FIREFOX_ONLY) return [];
|
|
204
|
+
const cookies = await $1c57ad353fa3519e$var$getChromeCookies({
|
|
205
|
+
name: name,
|
|
206
|
+
domain: domain
|
|
184
207
|
});
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
208
|
+
return cookies.map((0, $c0cdc003fbf917f0$export$33d3adc27420eed5));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
async function $1c57ad353fa3519e$var$getPromise1(name, domain, file) {
|
|
212
|
+
try {
|
|
213
|
+
return await $1c57ad353fa3519e$var$getEncryptedChromeCookie({
|
|
214
|
+
name: name,
|
|
215
|
+
domain: domain,
|
|
216
|
+
file: file
|
|
192
217
|
});
|
|
193
|
-
}
|
|
194
|
-
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
218
|
+
} catch (e) {
|
|
219
|
+
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error getting encrypted cookie", e);
|
|
220
|
+
return [];
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
async function $1c57ad353fa3519e$var$getPromise(name, domain) {
|
|
224
|
+
try {
|
|
225
|
+
const files = await (0, $d6c2e79f3cdd498d$export$2c9faf86071156ae)({
|
|
226
|
+
path: $1c57ad353fa3519e$var$chromeLocal,
|
|
227
|
+
name: "Cookies"
|
|
199
228
|
});
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
229
|
+
const promises = files.map((file)=>$1c57ad353fa3519e$var$getPromise1(name, domain, file));
|
|
230
|
+
const results1 = await Promise.all(promises);
|
|
231
|
+
const results2 = results1.flat();
|
|
232
|
+
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("getEncryptedChromeCookie results", results2);
|
|
233
|
+
return results2.filter((result)=>result);
|
|
234
|
+
} catch (error) {
|
|
235
|
+
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("error", error);
|
|
236
|
+
return [];
|
|
237
|
+
}
|
|
203
238
|
}
|
|
204
239
|
/**
|
|
205
240
|
*
|
|
206
|
-
* @param name
|
|
207
|
-
* @param domain
|
|
208
|
-
* @
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if (
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
241
|
+
* @param {string|undefined} name
|
|
242
|
+
* @param {string} domain
|
|
243
|
+
* @param {boolean} requireJwt
|
|
244
|
+
* @returns {Promise<[string]>}
|
|
245
|
+
*/ async function $1c57ad353fa3519e$var$getChromeCookies({ name: name , domain: domain = "%" , requireJwt: requireJwt = false }) {
|
|
246
|
+
if ((0, $c0cdc003fbf917f0$export$99ce3e33a555daf1)(name)) throw new Error("name must be a string");
|
|
247
|
+
if ((0, $c0cdc003fbf917f0$export$99ce3e33a555daf1)(domain)) throw new Error("domain must be a string");
|
|
248
|
+
const encryptedDataItems = await $1c57ad353fa3519e$var$getPromise(name, domain);
|
|
249
|
+
const password = await $1c57ad353fa3519e$var$getChromePassword();
|
|
250
|
+
const decrypted = encryptedDataItems.filter((encryptedData)=>{
|
|
251
|
+
return encryptedData != null && encryptedData.length > 0;
|
|
252
|
+
}).map(async (encryptedData)=>{
|
|
253
|
+
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Received encrypted", encryptedData);
|
|
254
|
+
let d;
|
|
255
|
+
try {
|
|
256
|
+
d = await $1c57ad353fa3519e$var$decrypt(password, encryptedData);
|
|
257
|
+
} catch (e) {
|
|
258
|
+
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error decrypting cookie", e);
|
|
259
|
+
return null;
|
|
225
260
|
}
|
|
226
|
-
if (
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
261
|
+
if (d) {
|
|
262
|
+
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Decrypted", d);
|
|
263
|
+
return d;
|
|
264
|
+
}
|
|
265
|
+
return null;
|
|
230
266
|
});
|
|
267
|
+
const results = await Promise.all(decrypted);
|
|
268
|
+
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("results", results);
|
|
269
|
+
return results.map((0, $c0cdc003fbf917f0$export$d53bf2de587a369));
|
|
231
270
|
}
|
|
232
|
-
const $
|
|
233
|
-
|
|
234
|
-
async function $af7abeb0794bd6fa$var$getEncryptedChromeCookie({ name: name , domain: domain , file: file = $af7abeb0794bd6fa$var$defaultChromeCookies , }) {
|
|
271
|
+
const $1c57ad353fa3519e$var$chromeLocal = $bU6Ve$path.join((0, $fa5ed5287f8fdf72$export$a7c5707626fc90f), "Library", "Application Support", "Google", "Chrome");
|
|
272
|
+
async function $1c57ad353fa3519e$var$getEncryptedChromeCookie({ name: name , domain: domain , file: file = $bU6Ve$path.join($1c57ad353fa3519e$var$chromeLocal, "Default", "Cookies") , }) {
|
|
235
273
|
if (name && typeof name !== "string") throw new Error("name must be a string");
|
|
236
274
|
if (domain && typeof domain !== "string") throw new Error("domain must be a string");
|
|
237
275
|
if (file && typeof file !== "string") throw new Error("file must be a string");
|
|
238
|
-
if (!(0,
|
|
239
|
-
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE)
|
|
276
|
+
if (!(0, $bU6Ve$fs.existsSync)(file)) throw new Error(`File ${file} does not exist`);
|
|
277
|
+
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) {
|
|
278
|
+
const s = file.split("/").slice(-3).join("/");
|
|
279
|
+
console.log(`Trying Chrome (at ${s}) cookie ${name} for domain ${domain}`);
|
|
280
|
+
}
|
|
240
281
|
let sql;
|
|
241
282
|
sql = `SELECT encrypted_value FROM cookies`;
|
|
242
283
|
if (typeof name === "string" || typeof domain === "string") {
|
|
@@ -247,14 +288,20 @@ async function $af7abeb0794bd6fa$var$getEncryptedChromeCookie({ name: name , dom
|
|
|
247
288
|
}
|
|
248
289
|
if (typeof domain === "string") sql += `host_key LIKE '${domain}';`;
|
|
249
290
|
}
|
|
250
|
-
return
|
|
291
|
+
return (0, $c0cdc003fbf917f0$export$f19f611d1fa7c6f3)(file, sql);
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
*
|
|
295
|
+
* @returns {Promise<string>}
|
|
296
|
+
*/ async function $1c57ad353fa3519e$var$getChromePassword() {
|
|
297
|
+
return (0, $c0cdc003fbf917f0$export$8d71c74f97c0202e)('security find-generic-password -w -s "Chrome Safe Storage"');
|
|
251
298
|
}
|
|
252
299
|
/**
|
|
253
300
|
*
|
|
254
301
|
* @param {string} password
|
|
255
302
|
* @param {Buffer} encryptedData
|
|
256
303
|
* @returns {Promise<string>}
|
|
257
|
-
*/ async function $
|
|
304
|
+
*/ async function $1c57ad353fa3519e$var$decrypt(password, encryptedData) {
|
|
258
305
|
if (typeof password !== "string") throw new Error("password must be a string: " + password);
|
|
259
306
|
let encryptedData1;
|
|
260
307
|
encryptedData1 = encryptedData;
|
|
@@ -297,7 +344,7 @@ async function $af7abeb0794bd6fa$var$getEncryptedChromeCookie({ name: name , dom
|
|
|
297
344
|
reject(e);
|
|
298
345
|
return;
|
|
299
346
|
}
|
|
300
|
-
|
|
347
|
+
const padding = decoded[decoded.length - 1];
|
|
301
348
|
if (padding) decoded = decoded.slice(0, 0 - padding);
|
|
302
349
|
// noinspection JSCheckFunctionSignatures
|
|
303
350
|
decoded = decoded.toString("utf8");
|
|
@@ -308,123 +355,145 @@ async function $af7abeb0794bd6fa$var$getEncryptedChromeCookie({ name: name , dom
|
|
|
308
355
|
});
|
|
309
356
|
});
|
|
310
357
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
name: name,
|
|
327
|
-
domain: domain,
|
|
328
|
-
file: file
|
|
329
|
-
}).catch((e)=>{
|
|
330
|
-
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error getting encrypted cookie", e);
|
|
331
|
-
return [];
|
|
332
|
-
});
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
class $d66ab4010a2fe667$export$2e2bcd8739ae039 extends (0, $36bba8acd7b702be$export$2e2bcd8739ae039) {
|
|
367
|
+
async queryCookies(name, domain) {
|
|
368
|
+
if (process.platform !== "darwin") throw new Error("This only works on macOS");
|
|
369
|
+
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).CHROME_ONLY) return [];
|
|
370
|
+
const cookies = await this.#getFirefoxCookie({
|
|
371
|
+
name: name,
|
|
372
|
+
domain: domain
|
|
333
373
|
});
|
|
334
|
-
return
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
374
|
+
return Array.isArray(cookies) ? cookies.map((0, $c0cdc003fbf917f0$export$d53bf2de587a369)) : [];
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
*
|
|
378
|
+
* @param name
|
|
379
|
+
* @param domain
|
|
380
|
+
* @returns {Promise<Buffer>}
|
|
381
|
+
*/ async #getFirefoxCookie({ name: name , domain: domain }) {
|
|
382
|
+
if (name && typeof name !== "string") throw new Error("name must be a string");
|
|
383
|
+
if (domain && typeof domain !== "string") throw new Error("domain must be a string");
|
|
384
|
+
const files = await (0, $d6c2e79f3cdd498d$export$2c9faf86071156ae)({
|
|
385
|
+
path: $bU6Ve$path.join((0, $fa5ed5287f8fdf72$export$a7c5707626fc90f), "Library", "Application Support", "Firefox", "Profiles"),
|
|
386
|
+
name: "cookies.sqlite"
|
|
339
387
|
});
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Decrypted", decrypted);
|
|
359
|
-
return decrypted;
|
|
388
|
+
const all = Promise.all(files.map((file)=>{
|
|
389
|
+
return this.#queryCookiesDb(file, name, domain);
|
|
390
|
+
}));
|
|
391
|
+
return all.flat();
|
|
392
|
+
}
|
|
393
|
+
#queryCookiesDb(file, name1, domain1) {
|
|
394
|
+
if (file && !(0, $bU6Ve$fs.existsSync)(file)) throw new Error(`File ${file} does not exist`);
|
|
395
|
+
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log(`Trying Firefox cookie ${name1} for domain ${domain1}`);
|
|
396
|
+
let sql;
|
|
397
|
+
//language=SQL
|
|
398
|
+
sql = "SELECT value FROM moz_cookies";
|
|
399
|
+
if (typeof name1 === "string" || typeof domain1 === "string") {
|
|
400
|
+
sql += ` WHERE `;
|
|
401
|
+
if (typeof name1 === "string") {
|
|
402
|
+
sql += `name = '${name1}'`;
|
|
403
|
+
if (typeof domain1 === "string") sql += ` AND `;
|
|
404
|
+
}
|
|
405
|
+
if (typeof domain1 === "string") sql += `host LIKE '${domain1}';`;
|
|
360
406
|
}
|
|
361
|
-
return
|
|
362
|
-
}
|
|
363
|
-
const results = await Promise.all(decrypted);
|
|
364
|
-
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("results", results);
|
|
365
|
-
return results.map($af7abeb0794bd6fa$require$toStringOrNull).find((result)=>{
|
|
366
|
-
return typeof result === "string" && result.length > 0 && (requireJwt === false || $af7abeb0794bd6fa$var$isValidJwt(result));
|
|
367
|
-
});
|
|
407
|
+
return (0, $c0cdc003fbf917f0$export$f19f611d1fa7c6f3)(file, sql).then((rows)=>rows.map((0, $c0cdc003fbf917f0$export$d53bf2de587a369))).catch(()=>[]);
|
|
408
|
+
}
|
|
368
409
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
class $ebf338ffba2ec9e7$export$2e2bcd8739ae039 extends (0, $36bba8acd7b702be$export$2e2bcd8739ae039) {
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
class $b4be7ecb8cbd1374$export$2e2bcd8739ae039 extends (0, $36bba8acd7b702be$export$2e2bcd8739ae039) {
|
|
419
|
+
#strategies;
|
|
420
|
+
constructor(){
|
|
421
|
+
super();
|
|
422
|
+
this.#strategies = [
|
|
423
|
+
(0, $1c57ad353fa3519e$export$2e2bcd8739ae039),
|
|
424
|
+
(0, $d66ab4010a2fe667$export$2e2bcd8739ae039),
|
|
425
|
+
(0, $ebf338ffba2ec9e7$export$2e2bcd8739ae039),
|
|
426
|
+
].map((strategy)=>{
|
|
427
|
+
return new strategy();
|
|
428
|
+
});
|
|
388
429
|
}
|
|
389
|
-
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
} catch (e1) {
|
|
395
|
-
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.error(`Error getting stat for ${filePath}`, e1);
|
|
396
|
-
continue;
|
|
397
|
-
}
|
|
398
|
-
if (stat.isDirectory()) {
|
|
399
|
-
if (filePath.split("/").length < rootSegments + maxDepth) try {
|
|
400
|
-
const subFiles = await $af7abeb0794bd6fa$var$findAllFiles({
|
|
401
|
-
path: filePath,
|
|
402
|
-
name: name,
|
|
403
|
-
rootSegments: rootSegments,
|
|
404
|
-
maxDepth: 2
|
|
405
|
-
});
|
|
406
|
-
files.push(...subFiles);
|
|
407
|
-
} catch (e2) {
|
|
408
|
-
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.error(e2);
|
|
409
|
-
}
|
|
410
|
-
} else if (file === name) files.push(filePath);
|
|
430
|
+
async queryCookies(name, domain) {
|
|
431
|
+
const results = await Promise.all(this.#strategies.map(async (strategy)=>{
|
|
432
|
+
return strategy.queryCookies(name, domain).catch(()=>[]);
|
|
433
|
+
}));
|
|
434
|
+
return results.flat();
|
|
411
435
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
function $e0bc45c44166a2ff$export$2e2bcd8739ae039(token) {
|
|
444
|
+
if (typeof token !== "string") return false;
|
|
445
|
+
try {
|
|
446
|
+
const result = (0, ($parcel$interopDefault($bU6Ve$jsonwebtoken))).decode(token, {
|
|
447
|
+
complete: true
|
|
448
|
+
});
|
|
449
|
+
if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log(result);
|
|
450
|
+
return true;
|
|
451
|
+
} catch (err) {
|
|
452
|
+
return false;
|
|
417
453
|
}
|
|
418
|
-
return files;
|
|
419
454
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
async function $8dc1bcea169affbc$export$e6d428437cf2cacb({ name: name , domain: domain }, strategy = new (0, $b4be7ecb8cbd1374$export$2e2bcd8739ae039)()) {
|
|
458
|
+
const results = await strategy.queryCookies(name, domain);
|
|
459
|
+
const results1 = (0, $bU6Ve$lodash.uniq)(results).map((cookie)=>{
|
|
460
|
+
return {
|
|
461
|
+
name: name,
|
|
462
|
+
domain: domain,
|
|
463
|
+
value: cookie
|
|
464
|
+
};
|
|
465
|
+
});
|
|
466
|
+
const jwtCookies = [];
|
|
467
|
+
for (const result of results1){
|
|
468
|
+
const value = result.value;
|
|
469
|
+
if ((0, $e0bc45c44166a2ff$export$2e2bcd8739ae039)(value)) jwtCookies.push(result);
|
|
470
|
+
}
|
|
471
|
+
const results2 = (0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).REQUIRE_JWT ? jwtCookies : results1;
|
|
472
|
+
const resultsUniq = (0, $bU6Ve$lodash.uniq)(results2).map((cookie)=>cookie.value);
|
|
473
|
+
return (0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).SINGLE ? [
|
|
474
|
+
resultsUniq[0]
|
|
475
|
+
] : resultsUniq;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
async function $af7abeb0794bd6fa$export$4be65e66cfa2648a(params) {
|
|
483
|
+
const cookies = await (0, $8dc1bcea169affbc$export$e6d428437cf2cacb)(params, new (0, $b4be7ecb8cbd1374$export$2e2bcd8739ae039)());
|
|
484
|
+
if (Array.isArray(cookies) && cookies.length > 0) return cookies.find((cookie)=>cookie != null);
|
|
485
|
+
else throw new Error("Cookie not found");
|
|
486
|
+
}
|
|
487
|
+
async function $af7abeb0794bd6fa$export$c44c5fdef43f0941(params) {
|
|
488
|
+
const cookies = await (0, $8dc1bcea169affbc$export$e6d428437cf2cacb)(params, new (0, $d66ab4010a2fe667$export$2e2bcd8739ae039)());
|
|
489
|
+
if (Array.isArray(cookies) && cookies.length > 0) return cookies.find((cookie)=>cookie != null);
|
|
490
|
+
else throw new Error("Cookie not found");
|
|
491
|
+
}
|
|
492
|
+
async function $af7abeb0794bd6fa$export$e5637297e9eb6f2e(params) {
|
|
493
|
+
const cookies = await (0, $8dc1bcea169affbc$export$e6d428437cf2cacb)(params, new (0, $1c57ad353fa3519e$export$2e2bcd8739ae039)());
|
|
494
|
+
if (Array.isArray(cookies) && cookies.length > 0) return cookies.find((cookie)=>cookie != null);
|
|
495
|
+
else throw new Error("Cookie not found");
|
|
496
|
+
}
|
|
428
497
|
|
|
429
498
|
|
|
430
499
|
//# sourceMappingURL=main.js.map
|