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