@mherod/get-cookie 1.3.0 → 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 +335 -288
- package/dist/main.js.map +1 -1
- package/package.json +15 -6
- package/src/CookieRow.ts +21 -0
- package/src/argv.js +1 -0
- package/src/browsers/AbstractCookieQueryStrategy.ts +10 -0
- package/src/browsers/ChromeCookieQueryStrategy.ts +256 -0
- package/src/browsers/CompositeCookieQueryStrategy.ts +31 -0
- package/src/browsers/FirefoxCookieQueryStrategy.ts +92 -0
- package/src/browsers/SafariCookieQueryStrategy.ts +3 -0
- package/src/cli.js +77 -45
- package/src/doSqliteQuery1.ts +47 -0
- package/src/findAllFiles.ts +68 -0
- package/src/global.ts +7 -0
- package/src/index.js +38 -439
- package/src/isValidJwt.ts +14 -0
- package/src/queryCookies.ts +28 -0
- package/src/utils.ts +118 -0
- package/tsconfig.json +23 -0
- package/src/global.js +0 -3
- package/src/utils.js +0 -185
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;AAAA;;ACAA;sCAAM,mBAA6B;AAC5B,MAAM,yCAAG,GAAG,EAAE,AAAC;AACtB,gCAAM,yCAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;;;ADIxB,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAC/B,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;;AELrD;qCAAM,yBAAmC;;AAGzC,eAAe,gCAAU,CAAC,OAAO,EAAE;IACjC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAC7B,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAC;IA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C,GAAG,CAAC,KAAK,CAAC,CAAC;SACpB;KAAA,AACF;IACD,OAAO,KAAK,CAAC;CACd;AAED,qCAAqC;AACrC,cAAc,GAAG;IACf,kBAAkB,EAAE,qCAAe;qBACnC,qCAAe;sBACf,sCAAgB;eAChB,+BAAS;aACT,6BAAO;CACR,CAAC","sources":["src/index.js","src/global.js","src/utils.js"],"sourcesContent":["#!/usr/bin/env node\n\nimport fs from \"fs\";\nimport crypto from \"crypto\";\nimport { env } from \"./global\";\n\nif (process.platform !== \"darwin\") {\n throw new Error(\"This script only works on macOS\");\n}\n\nconst {\n execSimple,\n toStringOrNull,\n doSqliteQuery1,\n toStringValue,\n} = require(\"./utils\");\nconst jsonwebtoken = require(\"jsonwebtoken\");\n\nfunction isValidJwt(token) {\n if (typeof token !== \"string\") {\n return false;\n }\n try {\n const result = jsonwebtoken.decode(token, { complete: true });\n if (env.VERBOSE) {\n console.log(result);\n }\n return true;\n } catch (err) {\n return false;\n }\n}\n\n/**\n *\n * @returns {Promise<string>}\n */\nasync function getChromePassword() {\n return execSimple(\n 'security find-generic-password -w -s \"Chrome Safe Storage\"'\n );\n}\n\n/**\n *\n * @param params\n * @returns {Promise<string>}\n */\nasync function getCookie(params) {\n if (env.CHROME_ONLY) {\n if (env.VERBOSE) {\n console.log(\"chrome only\");\n }\n return getChromeCookie(params)\n .then((cookie) => {\n if (cookie && cookie.length > 0) {\n return toStringValue(cookie);\n }\n })\n .catch((err) => {\n if (env.VERBOSE) {\n console.error(err);\n }\n });\n } else if (env.FIREFOX_ONLY) {\n if (env.VERBOSE) {\n console.log(\"firefox only\");\n }\n return getFirefoxCookie(params)\n .then((b) => b.toString(\"utf8\"))\n .then((cookie) => {\n if (cookie && cookie.length > 0) {\n return toStringValue(cookie);\n } else {\n console.log(\"No cookie found\");\n }\n })\n .catch((err) => {\n if (env.VERBOSE) {\n console.error(\"Error getting Firefox cookie\", err);\n }\n });\n } else {\n return await getChromeCookie(params)\n .catch((err) => {\n if (env.VERBOSE) {\n console.error(\"Error getting Chrome cookie\", err);\n }\n })\n .then((r) => {\n if (typeof r === \"string\" && r.trim().length > 0) {\n return r;\n } else {\n return getFirefoxCookie(params).catch((err) => {\n if (env.VERBOSE) {\n console.error(\"Error getting Firefox cookie\", err);\n }\n });\n }\n })\n .catch((e) => {\n if (env.VERBOSE) {\n console.error(\"Error getting Chrome or Firefox cookie\", e);\n }\n })\n .then(toStringValue);\n }\n}\n\n/**\n *\n * @param name\n * @param domain\n * @returns {Promise<Buffer>}\n */\nasync function getFirefoxCookie({ name, domain }) {\n if (name && typeof name !== \"string\") {\n throw new Error(\"name must be a string\");\n }\n if (domain && typeof domain !== \"string\") {\n throw new Error(\"domain must be a string\");\n }\n const [file] = await findAllFiles({\n path: `${env.HOME}/Library/Application Support/Firefox/Profiles`,\n name: \"cookies.sqlite\",\n });\n if (file && !fs.existsSync(file)) {\n throw new Error(`File ${file} does not exist`);\n }\n if (env.VERBOSE) {\n console.log(`Trying Firefox cookie ${name} for domain ${domain}`);\n }\n let sql;\n sql = \"SELECT value FROM moz_cookies\";\n if (typeof name === \"string\" || typeof domain === \"string\") {\n sql += ` WHERE `;\n if (typeof name === \"string\") {\n sql += `name = '${name}'`;\n if (typeof domain === \"string\") {\n sql += ` AND `;\n }\n }\n if (typeof domain === \"string\") {\n sql += `host LIKE '${domain}';`;\n }\n }\n return await doSqliteQuery1(file, sql).then((rows) => {\n return rows.map(toStringOrNull).find((v) => v !== null);\n });\n}\n\nconst defaultChromeRoot = `${env.HOME}/Library/Application Support/Google/Chrome`;\nconst defaultChromeCookies = `${defaultChromeRoot}/Default/Cookies`;\n\nasync function getEncryptedChromeCookie({\n name,\n domain,\n file = defaultChromeCookies,\n}) {\n if (name && typeof name !== \"string\") {\n throw new Error(\"name must be a string\");\n }\n if (domain && typeof domain !== \"string\") {\n throw new Error(\"domain must be a string\");\n }\n if (file && typeof file !== \"string\") {\n throw new Error(\"file must be a string\");\n }\n if (!fs.existsSync(file)) {\n throw new Error(`File ${file} does not exist`);\n }\n if (env.VERBOSE) {\n console.log(\n `Trying Chrome (at ${file\n .split(\"/\")\n .slice(-3)\n .join(\"/\")}) cookie ${name} for domain ${domain}`\n );\n }\n let sql;\n sql = `SELECT encrypted_value FROM cookies`;\n if (typeof name === \"string\" || typeof domain === \"string\") {\n sql += ` WHERE `;\n if (typeof name === \"string\") {\n sql += `name = '${name}'`;\n if (typeof domain === \"string\") {\n sql += ` AND `;\n }\n }\n if (typeof domain === \"string\") {\n sql += `host_key LIKE '${domain}';`;\n }\n }\n return await doSqliteQuery1(file, sql);\n}\n\n/**\n *\n * @param {string} password\n * @param {Buffer} encryptedData\n * @returns {Promise<string>}\n */\nasync function decrypt(password, encryptedData) {\n if (typeof password !== \"string\") {\n throw new Error(\"password must be a string: \" + password);\n }\n let encryptedData1;\n encryptedData1 = encryptedData;\n if (encryptedData1 == null || typeof encryptedData1 !== \"object\") {\n throw new Error(\"encryptedData must be a object: \" + encryptedData1);\n }\n if (!(encryptedData1 instanceof Buffer)) {\n if (Array.isArray(encryptedData1) && encryptedData1[0] instanceof Buffer) {\n [encryptedData1] = encryptedData1;\n if (env.VERBOSE) {\n console.log(\n `encryptedData is an array of buffers, selected first: ${encryptedData1}`\n );\n }\n } else {\n throw new Error(\"encryptedData must be a Buffer: \" + encryptedData1);\n }\n encryptedData1 = Buffer.from(encryptedData1);\n }\n if (env.VERBOSE) {\n console.log(`Trying to decrypt with password ${password}`);\n }\n return new Promise((resolve, reject) => {\n crypto.pbkdf2(password, \"saltysalt\", 1003, 16, \"sha1\", (error, buffer) => {\n try {\n if (error) {\n if (env.VERBOSE) {\n console.log(\"Error doing pbkdf2\", error);\n }\n reject(error);\n return;\n }\n\n if (buffer.length !== 16) {\n if (env.VERBOSE) {\n console.log(\n \"Error doing pbkdf2, buffer length is not 16\",\n buffer.length\n );\n }\n reject(new Error(\"Buffer length is not 16\"));\n return;\n }\n\n const iv = new Buffer.from(new Array(17).join(\" \"), \"binary\");\n const decipher = crypto.createDecipheriv(\"aes-128-cbc\", buffer, iv);\n decipher.setAutoPadding(false);\n\n if (encryptedData1 && encryptedData1.slice) {\n encryptedData1 = encryptedData1.slice(3);\n }\n\n if (encryptedData1.length % 16 !== 0) {\n if (env.VERBOSE) {\n console.log(\n \"Error doing pbkdf2, encryptedData length is not a multiple of 16\",\n encryptedData1.length\n );\n }\n reject(new Error(\"encryptedData length is not a multiple of 16\"));\n return;\n }\n\n let decoded = decipher.update(encryptedData1);\n try {\n decipher.final(\"utf-8\");\n } catch (e) {\n if (env.VERBOSE) {\n console.log(\"Error doing decipher.final()\", e);\n }\n reject(e);\n return;\n }\n\n let padding = decoded[decoded.length - 1];\n if (padding) {\n decoded = decoded.slice(0, 0 - padding);\n }\n // noinspection JSCheckFunctionSignatures\n decoded = decoded.toString(\"utf8\");\n resolve(decoded);\n } catch (e) {\n reject(e);\n }\n });\n });\n}\n\n/**\n *\n * @param {string|undefined} name\n * @param {string} domain\n * @param {boolean} requireJwt\n * @returns {Promise<string>}\n */\nasync function getChromeCookie({ name, domain = \"%\", requireJwt = false }) {\n if (name && typeof name !== \"string\") {\n throw new Error(\"name must be a string\");\n }\n if (typeof domain !== \"string\") {\n throw new Error(\"domain must be a string\");\n }\n const encryptedDataItems = await findAllFiles({\n path: defaultChromeRoot,\n name: \"Cookies\",\n })\n .then((files) => {\n const promises = files.map((file) => {\n return getEncryptedChromeCookie({\n name: name,\n domain: domain,\n file: file,\n }).catch((e) => {\n if (env.VERBOSE) {\n console.log(\"Error getting encrypted cookie\", e);\n }\n return [];\n });\n });\n return Promise.all(promises)\n .then((results) => results.flat())\n .then((results) => {\n if (env.VERBOSE) {\n console.log(\"getEncryptedChromeCookie results\", results);\n }\n return results.filter((result) => {\n return result;\n });\n });\n })\n .catch((error) => {\n if (env.VERBOSE) {\n console.log(\"error\", error);\n }\n return [];\n });\n const password = await getChromePassword();\n if (env.VERBOSE) {\n console.log(\"encryptedDataItems\", encryptedDataItems);\n }\n const decrypted = encryptedDataItems\n .filter((encryptedData) => {\n return encryptedData != null && encryptedData.length > 0;\n })\n .map(async (encryptedData) => {\n if (env.VERBOSE) {\n console.log(\"Received encrypted\", encryptedData);\n }\n let decrypted;\n try {\n decrypted = await decrypt(password, encryptedData);\n } catch (e) {\n if (env.VERBOSE) {\n console.log(\"Error decrypting cookie\", e);\n }\n return null;\n }\n if (decrypted) {\n if (env.VERBOSE) {\n console.log(\"Decrypted\", decrypted);\n }\n return decrypted;\n }\n return null;\n });\n const results = await Promise.all(decrypted);\n if (env.VERBOSE) {\n console.log(\"results\", results);\n }\n return results.map(toStringOrNull).find((result) => {\n return (\n typeof result === \"string\" &&\n result.length > 0 &&\n (requireJwt === false || isValidJwt(result))\n );\n });\n}\n\n/**\n *\n * @param path\n * @param name\n * @param rootSegments\n * @param maxDepth\n * @returns {Promise<[string]>}\n */\nasync function findAllFiles({ path, name, maxDepth = 2 }) {\n if (typeof path !== \"string\") {\n throw new Error(\"path must be a string\");\n }\n if (typeof name !== \"string\") {\n throw new Error(\"name must be a string\");\n }\n\n const rootSegments = path.split(\"/\").length;\n\n if (env.VERBOSE) {\n console.log(`Searching for ${name} in ${path}`);\n }\n const files = [];\n let readdirSync;\n try {\n readdirSync = fs.readdirSync(path);\n } catch (e) {\n if (env.VERBOSE) {\n console.log(`Error reading ${path}`, e);\n }\n return files;\n }\n for (const file of readdirSync) {\n const filePath = path + \"/\" + file;\n let stat;\n try {\n stat = fs.statSync(filePath);\n } catch (e) {\n if (env.VERBOSE) {\n console.error(`Error getting stat for ${filePath}`, e);\n }\n continue;\n }\n if (stat.isDirectory()) {\n if (filePath.split(\"/\").length < rootSegments + maxDepth) {\n try {\n const subFiles = await findAllFiles({\n path: filePath,\n name: name,\n rootSegments: rootSegments,\n maxDepth: 2,\n });\n files.push(...subFiles);\n } catch (e) {\n if (env.VERBOSE) {\n console.error(e);\n }\n }\n }\n } else if (file === name) {\n files.push(filePath);\n }\n }\n if (env.VERBOSE) {\n if (files.length > 0) {\n console.log(`Found ${files.length} ${name} files`);\n console.log(files);\n }\n }\n return files;\n}\n\n// noinspection JSUnusedGlobalSymbols\nmodule.exports = {\n getDecryptedCookie: getChromeCookie,\n getChromeCookie,\n getFirefoxCookie,\n getCookie,\n decrypt,\n};\n","const { merge } = require(\"lodash\");\nexport const env = {};\nmerge(env, process.env);\n","// noinspection JSUnusedGlobalSymbols\n\nconst { exec } = require(\"child_process\");\nconst fs = require(\"fs\");\n\nasync function execSimple(command) {\n if (typeof command !== \"string\") {\n throw new TypeError(\"execSimple: command must be a string\");\n }\n if (process.env.VERBOSE) {\n console.log(command);\n }\n return new Promise((resolve, reject) => {\n exec(\n command,\n { encoding: \"binary\", maxBuffer: 5 * 1024 },\n (error, stdout, stderr) => {\n if (error) {\n reject(error);\n return;\n }\n if (stderr) {\n reject(error);\n return;\n }\n if (stdout) {\n resolve(stdout.toString(\"utf8\").trim());\n }\n }\n );\n });\n}\n\nasync function execAsBuffer(command) {\n if (typeof command !== \"string\") {\n throw new TypeError(\"execAsBuffer: command must be a string\");\n }\n if (process.env.VERBOSE) {\n console.log(command);\n }\n return await new Promise((resolve, reject) => {\n exec(\n command,\n { encoding: \"binary\", maxBuffer: 5 * 1024 },\n (error, stdout, stderr) => {\n if (error) {\n reject(error);\n return;\n }\n if (stderr) {\n reject(error);\n return;\n }\n let stdoutAsBuffer = stdout;\n if (typeof stdoutAsBuffer === \"string\" && stdoutAsBuffer.length > 0) {\n // noinspection JSCheckFunctionSignatures\n stdoutAsBuffer = Buffer.from(stdoutAsBuffer, \"binary\").slice(0, -1);\n }\n if (stdoutAsBuffer && stdoutAsBuffer.length > 0) {\n resolve(stdoutAsBuffer);\n }\n }\n );\n });\n}\n\nfunction toStringValue(r) {\n if (process.env.VERBOSE) {\n console.log(\"Printing value\", r);\n }\n if (r) {\n if (typeof r === \"string\") {\n return r;\n } else if (r.toString) {\n // noinspection JSCheckFunctionSignatures\n return r.toString(\"utf8\");\n }\n }\n}\n\nfunction printStringValue(r) {\n if (process.env.VERBOSE) {\n console.log(\"Printing value\", r);\n }\n if (r) {\n if (typeof r === \"string\") {\n console.log(r);\n } else if (r.toString) {\n // noinspection JSCheckFunctionSignatures\n console.log(r.toString(\"utf8\"));\n }\n }\n}\n\n/**\n *\n * @param result\n * @returns {string|null}\n */\nfunction toStringOrNull(result) {\n if (result == null) {\n return null;\n }\n if (process.env.VERBOSE) {\n console.log(\"result\", result);\n }\n if (typeof result === \"string\" && result.length > 0) {\n return result;\n }\n if (result.slice && result.toString) {\n // noinspection JSCheckFunctionSignatures\n return result.toString(\"utf8\");\n }\n return null;\n}\n\n/**\n *\n * @param {string} file\n * @param {string} sql\n * @returns {Promise<Buffer[]>}\n */\nasync function doSqliteQuery1(file, sql) {\n if (typeof sql !== \"string\") {\n throw new TypeError(\"doSqliteQuery1: sql must be a string\");\n }\n if (typeof file !== \"string\") {\n throw new TypeError(\"doSqliteQuery1: file must be a string\");\n }\n if (!fs.existsSync(file)) {\n throw new Error(`doSqliteQuery1: file ${file} does not exist`);\n }\n if (process.env.VERBOSE) {\n console.log(`doSqliteQuery1: file ${file}`);\n console.log(`doSqliteQuery1: sql ${sql}`);\n }\n const sqlite3 = require(\"sqlite3\");\n const db = new sqlite3.Database(file);\n return new Promise((resolve, reject) => {\n db.all(sql, (err, rows) => {\n if (err) {\n if (process.env.VERBOSE) {\n console.log(`doSqliteQuery1: error ${err}`);\n }\n reject(err);\n return;\n }\n const rows1 = rows;\n if (rows1 == null || rows1.length === 0) {\n if (process.env.VERBOSE) {\n console.log(`doSqliteQuery1: no rows`);\n }\n resolve([]);\n return;\n }\n if (Array.isArray(rows1)) {\n if (process.env.VERBOSE) {\n console.log(`doSqliteQuery1: ${rows1.length} rows`);\n }\n // noinspection JSCheckFunctionSignatures\n const buffers = rows1\n .flatMap((row) => Object.values(row))\n .map((v) => Buffer.from(v, \"binary\"));\n if (process.env.VERBOSE) {\n console.log(`doSqliteQuery1: ${buffers.length} buffers`);\n }\n resolve(buffers);\n return;\n }\n if (process.env.VERBOSE) {\n console.log(`doSqliteQuery1: rows ${JSON.stringify(rows1)}`);\n }\n resolve([rows1]);\n });\n });\n}\n\nmodule.exports = {\n execSimple: execSimple,\n execAsBuffer: execAsBuffer,\n printStringValue: printStringValue,\n toStringValue,\n toStringOrNull: toStringOrNull,\n doSqliteQuery1,\n};\n"],"names":[],"version":3,"file":"main.js.map","sourceRoot":"../"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;AIEe;IACb,MAAM,YAAY,CAAC,IAAY,EAAE,MAAc,EAA6B;QAC1E,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EACxC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAE3C,OAAO,EAAE,CAAC;KACX;CACF;;ADTD;AEEA;AAEO,eAAe,yCAAU,CAAC,OAAe,EAAmB;IACjE,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,EACrB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAEvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,GAAK;QACtC,CAAA,GAAA,yBAAI,CAAA,CACF,OAAO,EACP;YAAE,QAAQ,EAAE,QAAQ;YAAE,SAAS,EAAE,IAAQ;SAAE,EAC3C,CAAC,KAA2B,EAAE,MAAc,EAAE,MAAc,GAAK;YAC/D,IAAI,KAAK,EAAE;gBACT,MAAM,CAAC,KAAK,CAAC,CAAC;gBACd,OAAO;aACR;YACD,IAAI,MAAM,EAAE;gBACV,MAAM,CAAC,KAAK,CAAC,CAAC;gBACd,OAAO;aACR;YACD,IAAI,MAAM,EACR,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;SAE1B,CACF,CAAC;KACH,CAAC,CAAC;CACJ;AAiCM,SAAS,yCAAa,CAAC,CAAM,EAAU;IAC5C,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,EACrB,OAAO,CAAC,GAAG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stractCookieQueryStrategy.ts","src/utils.ts","src/global.ts","src/findAllFiles.ts","src/CookieRow.ts","src/doSqliteQuery1.ts","src/browsers/FirefoxCookieQueryStrategy.ts","src/browsers/SafariCookieQueryStrategy.ts","src/isValidJwt.ts"],"sourcesContent":["#!/usr/bin/env node\n// noinspection JSUnusedGlobalSymbols\n\nimport { queryCookies } from \"./queryCookies\";\nimport FirefoxCookieQueryStrategy from \"./browsers/FirefoxCookieQueryStrategy\";\nimport ChromeCookieQueryStrategy from \"./browsers/ChromeCookieQueryStrategy\";\nimport CompositeCookieQueryStrategy from \"./browsers/CompositeCookieQueryStrategy\";\n\n/**\n *\n * @param params\n * @returns {Promise<string>}\n */\nexport async function getCookie(params) {\n const cookies = await queryCookies(\n params,\n new CompositeCookieQueryStrategy()\n //\n );\n if (Array.isArray(cookies) && cookies.length > 0) {\n return cookies.find((cookie) => cookie != null);\n } else {\n throw new Error(\"Cookie not found\");\n }\n}\n\n/**\n *\n * @param params\n * @returns {Promise<*>}\n */\nexport async function getFirefoxCookie(params) {\n const cookies = await queryCookies(\n params,\n new FirefoxCookieQueryStrategy()\n //\n );\n if (Array.isArray(cookies) && cookies.length > 0) {\n return cookies.find((cookie) => cookie != null);\n } else {\n throw new Error(\"Cookie not found\");\n }\n}\n\n/**\n *\n * @param params\n * @returns {Promise<*>}\n */\nexport async function getChromeCookie(params) {\n const cookies = await queryCookies(\n params,\n new ChromeCookieQueryStrategy()\n //\n );\n if (Array.isArray(cookies) && cookies.length > 0) {\n return cookies.find((cookie) => cookie != null);\n } else {\n throw new Error(\"Cookie not found\");\n }\n}\n","import CompositeCookieQueryStrategy from \"./browsers/CompositeCookieQueryStrategy\";\nimport { uniqBy } from \"lodash\";\nimport { env } from \"./global\";\nimport isValidJwt from \"./isValidJwt\";\nimport { ExportedCookie } from \"./CookieRow\";\n\nexport async function queryCookies(\n {\n name,\n domain\n }: {\n name: string;\n domain: string;\n },\n strategy = new CompositeCookieQueryStrategy()\n) {\n const results: ExportedCookie[] = await strategy.queryCookies(name, domain);\n const results1: ExportedCookie[] = uniqBy(results, JSON.stringify);\n const jwtCookies = [];\n for (const result of results1) {\n const value = result.value;\n if (isValidJwt(value)) {\n jwtCookies.push(result);\n }\n }\n const resultsUniq = env.REQUIRE_JWT ? jwtCookies : results1;\n return env.SINGLE ? [resultsUniq[0]] : resultsUniq;\n}\n","import ChromeCookieQueryStrategy from \"./ChromeCookieQueryStrategy\";\nimport FirefoxCookieQueryStrategy from \"./FirefoxCookieQueryStrategy\";\nimport SafariCookieQueryStrategy from \"./SafariCookieQueryStrategy\";\nimport AbstractCookieQueryStrategy from \"./AbstractCookieQueryStrategy\";\nimport {ExportedCookie} from \"../CookieRow\";\n\nexport default class CompositeCookieQueryStrategy extends AbstractCookieQueryStrategy {\n #strategies;\n\n constructor() {\n super();\n this.#strategies = [\n ChromeCookieQueryStrategy,\n FirefoxCookieQueryStrategy,\n SafariCookieQueryStrategy,\n ].map((strategy) => {\n return new strategy();\n });\n }\n\n async queryCookies(name: string, domain: string): Promise<ExportedCookie[]> {\n const results = await Promise.all(\n this.#strategies.map(async (strategy) => {\n // @ts-ignore\n const cookies: Promise<ExportedCookie[]> = strategy.queryCookies(name, domain);\n return cookies.catch(() => []);\n })\n );\n return results.flat();\n }\n}\n","import AbstractCookieQueryStrategy from \"./AbstractCookieQueryStrategy\";\nimport { execSimple } from \"../utils\";\nimport { env, HOME } from \"../global\";\nimport { existsSync } from \"fs\";\nimport { findAllFiles } from \"../findAllFiles\";\nimport * as crypto from \"crypto\";\nimport * as path from \"path\";\nimport { CookieRow, ExportedCookie, isCookieRow, isExportedCookie } from \"../CookieRow\";\nimport { doSqliteQuery1 } from \"../doSqliteQuery1\";\nimport { merge } from \"lodash\";\n\nexport default class ChromeCookieQueryStrategy extends AbstractCookieQueryStrategy {\n async queryCookies(name: string, domain: string): Promise<ExportedCookie[]> {\n if (process.platform !== \"darwin\") {\n throw new Error(\"This only works on macOS\");\n }\n if (env.FIREFOX_ONLY) {\n return [];\n }\n return getChromeCookies({\n requireJwt: false,\n name,\n domain\n });\n }\n}\n\nasync function getPromise1(name: string, domain: string, file: string): Promise<CookieRow[]> {\n try {\n return await getEncryptedChromeCookie({\n name: name,\n domain: domain,\n file: file\n });\n } catch (e) {\n if (env.VERBOSE) {\n console.log(\"Error getting encrypted cookie\", e);\n }\n return [];\n }\n}\n\nasync function getPromise(name: string, domain: string): Promise<CookieRow[]> {\n try {\n const files: string[] = await findAllFiles({\n path: chromeLocal,\n name: \"Cookies\"\n });\n const promises: Promise<CookieRow[]>[] = files.map((file) => getPromise1(name, domain, file));\n const results1: Awaited<CookieRow[]>[] = await Promise.all(promises);\n return results1.flat().filter(isCookieRow);\n } catch (error) {\n if (env.VERBOSE) {\n console.log(\"error\", error);\n }\n return [];\n }\n}\n\nasync function decryptValue(password: string, encryptedValue: Buffer) {\n let d: string | null;\n try {\n d = await decrypt(password, encryptedValue);\n } catch (e) {\n if (env.VERBOSE) {\n console.log(\"Error decrypting cookie\", e);\n }\n d = null;\n }\n return d ?? encryptedValue.toString(\"utf-8\");\n}\n\nasync function getChromeCookies(\n {\n name,\n domain = \"%\",\n requireJwt = false\n }: {\n name: string;\n domain: string;\n requireJwt: boolean | undefined;\n //\n }\n //\n): Promise<ExportedCookie[]> {\n const encryptedDataItems: CookieRow[] = await getPromise(name, domain);\n const password: string = await getChromePassword();\n const decrypted: Promise<ExportedCookie | null>[] = encryptedDataItems\n .filter(({ value }) => value != null && value.length > 0)\n .map(async (cookieRow: CookieRow) => {\n const encryptedValue: Buffer = cookieRow.value;\n const decryptedValue = await decryptValue(password, encryptedValue);\n const meta = {};\n merge(meta, cookieRow.meta ?? {});\n return {\n domain: cookieRow.domain,\n name: cookieRow.name,\n value: decryptedValue,\n meta: meta\n };\n });\n const results: ExportedCookie[] = (await Promise.all(decrypted)).filter(isExportedCookie);\n if (env.VERBOSE) {\n console.log(\"results\", results);\n }\n return results;\n}\n\nconst chromeLocal = path.join(\n HOME,\n \"Library\",\n \"Application Support\",\n \"Google\",\n \"Chrome\"\n);\n\nasync function getEncryptedChromeCookie(\n {\n name,\n domain,\n file = path.join(chromeLocal, \"Default\", \"Cookies\")\n //\n }: {\n name: string;\n domain: string;\n file: string;\n }): Promise<CookieRow[]> {\n if (!existsSync(file)) {\n throw new Error(`File ${file} does not exist`);\n }\n if (env.VERBOSE) {\n const s = file.split(\"/\").slice(-3).join(\"/\");\n console.log(`Trying Chrome (at ${s}) cookie ${name} for domain ${domain}`);\n }\n let sql;\n sql = `SELECT encrypted_value, name, host_key FROM cookies`;\n const wildcardRegexp = /^([*%])$/i;\n const specifiedName = name.match(wildcardRegexp) == null;\n const specifiedDomain = domain.match(wildcardRegexp) == null;\n if (specifiedName || specifiedDomain) {\n sql += ` WHERE `;\n if (specifiedName) {\n sql += `name = '${name}'`;\n if (specifiedDomain) {\n sql += ` AND `;\n }\n }\n if (specifiedDomain) {\n sql += `host_key LIKE '${domain}';`;\n }\n }\n return doSqliteQuery1(file, sql);\n}\n\nasync function getChromePassword(): Promise<string> {\n return execSimple(\n \"security find-generic-password -w -s \\\"Chrome Safe Storage\\\"\"\n );\n}\n\nasync function decrypt(password: crypto.BinaryLike, encryptedData: Buffer): Promise<string> {\n if (typeof password !== \"string\") {\n throw new Error(\"password must be a string: \" + password);\n }\n let encryptedData1: any;\n encryptedData1 = encryptedData;\n if (encryptedData1 == null || typeof encryptedData1 !== \"object\") {\n throw new Error(\"encryptedData must be a object: \" + encryptedData1);\n }\n if (!(encryptedData1 instanceof Buffer)) {\n if (Array.isArray(encryptedData1) && encryptedData1[0] instanceof Buffer) {\n [encryptedData1] = encryptedData1;\n if (env.VERBOSE) {\n console.log(\n `encryptedData is an array of buffers, selected first: ${encryptedData1}`\n );\n }\n } else {\n throw new Error(\"encryptedData must be a Buffer: \" + encryptedData1);\n }\n encryptedData1 = Buffer.from(encryptedData1);\n }\n if (env.VERBOSE) {\n console.log(`Trying to decrypt with password ${password}`);\n }\n return new Promise((resolve, reject) => {\n crypto.pbkdf2(password,\n \"saltysalt\",\n 1003,\n 16,\n \"sha1\",\n (error, buffer) => {\n try {\n if (error) {\n if (env.VERBOSE) {\n console.log(\"Error doing pbkdf2\", error);\n }\n reject(error);\n return;\n }\n\n if (buffer.length !== 16) {\n if (env.VERBOSE) {\n console.log(\n \"Error doing pbkdf2, buffer length is not 16\",\n buffer.length\n );\n }\n reject(new Error(\"Buffer length is not 16\"));\n return;\n }\n\n const str = new Array(17).join(\" \");\n const iv = Buffer.from(str, \"binary\");\n const decipher = crypto.createDecipheriv(\"aes-128-cbc\", buffer, iv);\n decipher.setAutoPadding(false);\n\n if (encryptedData1 && encryptedData1.slice) {\n encryptedData1 = encryptedData1.slice(3);\n }\n\n if (encryptedData1.length % 16 !== 0) {\n if (env.VERBOSE) {\n console.log(\n \"Error doing pbkdf2, encryptedData length is not a multiple of 16\",\n encryptedData1.length\n );\n }\n reject(new Error(\"encryptedData length is not a multiple of 16\"));\n return;\n }\n\n let decoded = decipher.update(encryptedData1);\n try {\n decipher.final(\"utf-8\");\n } catch (e) {\n if (env.VERBOSE) {\n console.log(\"Error doing decipher.final()\", e);\n }\n reject(e);\n return;\n }\n\n const padding = decoded[decoded.length - 1];\n if (padding) {\n decoded = decoded.slice(0, 0 - padding);\n }\n // noinspection JSCheckFunctionSignatures\n const decodedString = decoded.toString(\"utf8\");\n resolve(decodedString);\n } catch (e) {\n reject(e);\n }\n });\n });\n}\n","import {ExportedCookie} from \"../CookieRow\";\n\nexport default class AbstractCookieQueryStrategy {\n async queryCookies(name: string, domain: string): Promise<ExportedCookie[]> {\n if (process.env.NODE_ENV === \"development\") {\n console.log(\"queryCookie\", name, domain);\n }\n return [];\n }\n}\n","// noinspection JSUnusedGlobalSymbols\n\nimport {exec, ExecException} from \"child_process\";\n\nexport async function execSimple(command: string): Promise<string> {\n if (process.env.VERBOSE) {\n console.log(command);\n }\n return new Promise((resolve, reject) => {\n exec(\n command,\n { encoding: \"binary\", maxBuffer: 5 * 1024 },\n (error: ExecException | null, stdout: string, stderr: string) => {\n if (error) {\n reject(error);\n return;\n }\n if (stderr) {\n reject(error);\n return;\n }\n if (stdout) {\n resolve(stdout.trim());\n }\n }\n );\n });\n}\n\n// export async function execAsBuffer(command: string) {\n// if (process.env.VERBOSE) {\n// console.log(command);\n// }\n// return await new Promise((resolve, reject) => {\n// exec(\n// command,\n// { encoding: \"binary\", maxBuffer: 5 * 1024 },\n// (error: ExecException | null, stdout: string, stderr: string) => {\n// if (error) {\n// reject(error);\n// return;\n// }\n// if (stderr) {\n// reject(error);\n// return;\n// }\n// let stdoutAsBuffer: string = stdout;\n// if (typeof stdoutAsBuffer === \"string\" && stdoutAsBuffer.length > 0) {\n// // noinspection JSCheckFunctionSignatures\n// stdoutAsBuffer = Buffer.from(stdoutAsBuffer, \"binary\").slice(0, -1);\n// }\n// if (stdoutAsBuffer && stdoutAsBuffer.length > 0) {\n// resolve(stdoutAsBuffer);\n// }\n// }\n// );\n// });\n// }\n\n// @ts-ignore\nexport function toStringValue(r: any): string {\n if (process.env.VERBOSE) {\n console.log(\"Printing value\", r);\n }\n if (r) {\n if (typeof r === \"string\") {\n return r;\n } else if (r.toString) {\n // noinspection JSCheckFunctionSignatures\n return r.toString(\"utf8\");\n }\n }\n}\n\nexport function printStringValue(r: any) {\n if (process.env.VERBOSE) {\n console.log(\"Printing value\", r);\n }\n if (r) {\n if (typeof r === \"string\") {\n console.log(r);\n } else if (r.toString) {\n // noinspection JSCheckFunctionSignatures\n console.log(r.toString(\"utf8\"));\n }\n }\n}\n\n/**\n *\n * @param result\n * @returns {string|null}\n */\nexport function toStringOrNull(result: any) {\n if (result == null) {\n return null;\n }\n if (process.env.VERBOSE) {\n console.log(\"result\", result);\n }\n if (typeof result === \"string\" && result.length > 0) {\n return result;\n }\n if (result.slice && result.toString) {\n // noinspection JSCheckFunctionSignatures\n return result.toString(\"utf8\");\n }\n return null;\n}\n\nexport function invalidString(input: any): boolean {\n return typeof input !== \"string\" || input.length === 0;\n}\n\n\nexport function validString(input: any): input is string {\n return typeof input == \"string\" && input.length > 0;\n}\n","const { merge } = require(\"lodash\");\nexport const env: any = {};\nmerge(env, process.env);\nexport const HOME: string = env[\"HOME\"];\nif (!HOME) {\n throw new Error(\"HOME environment variable is not set\");\n}\n","import {env} from \"./global\";\nimport * as fs from \"fs\";\n\nexport async function findAllFiles(\n {\n path,\n name,\n maxDepth = 2\n//\n }: {\n path: string;\n name: string;\n maxDepth?: number;\n }\n): Promise<string[]> {\n if (typeof path !== \"string\") {\n throw new Error(\"path must be a string\");\n }\n if (typeof name !== \"string\") {\n throw new Error(\"name must be a string\");\n }\n\n const rootSegments = path.split(\"/\").length;\n\n if (env.VERBOSE) {\n console.log(`Searching for ${name} in ${path}`);\n }\n const files: string[] = [];\n let readdirSync;\n try {\n readdirSync = fs.readdirSync(path);\n } catch (e) {\n if (env.VERBOSE) {\n console.log(`Error reading ${path}`, e);\n }\n return [];\n }\n for (const file of readdirSync) {\n const filePath = path + \"/\" + file;\n let stat;\n try {\n stat = fs.statSync(filePath);\n } catch (e) {\n if (env.VERBOSE) {\n console.error(`Error getting stat for ${filePath}`, e);\n }\n continue;\n }\n if (stat.isDirectory()) {\n if (filePath.split(\"/\").length < rootSegments + maxDepth) {\n try {\n const subFiles = await findAllFiles({\n path: filePath,\n name: name,\n maxDepth: 2,\n });\n files.push(...subFiles);\n } catch (e) {\n if (env.VERBOSE) {\n console.error(e);\n }\n }\n }\n } else if (file === name) {\n files.push(filePath);\n }\n }\n if (env.VERBOSE) {\n if (files.length > 0) {\n console.log(`Found ${files.length} ${name} files`);\n console.log(files);\n }\n }\n return files;\n}\n","export interface CookieRow {\n domain: string;\n name: string;\n value: Buffer;\n meta?: any;\n}\n\nexport function isCookieRow(obj: any): obj is CookieRow {\n return obj.domain !== undefined && obj.name !== undefined && obj.value !== undefined;\n}\n\nexport interface ExportedCookie {\n domain: string;\n name: string;\n value: string;\n meta?: any;\n}\n\nexport function isExportedCookie(obj: any): obj is ExportedCookie {\n return obj.domain !== undefined && obj.name !== undefined && obj.value !== undefined;\n}\n","import * as fs from \"fs\";\nimport * as sqlite3 from \"sqlite3\";\nimport {CookieRow} from \"./CookieRow\";\n\nexport async function doSqliteQuery1(file: string, sql: string): Promise<CookieRow[]> {\n if (!fs.existsSync(file)) {\n throw new Error(`doSqliteQuery1: file ${file} does not exist`);\n }\n const db = new sqlite3.Database(file);\n return new Promise((resolve, reject) => {\n db.all(sql, (err: Error, rows: any[]) => {\n if (err) {\n if (process.env.VERBOSE) {\n console.log(`doSqliteQuery1: error ${err}`);\n }\n reject(err);\n return;\n }\n const rows1: any[] = rows;\n if (rows1 == null || rows1.length === 0) {\n if (process.env.VERBOSE) {\n console.log(`doSqliteQuery1: no rows`);\n }\n resolve([]);\n return;\n }\n if (Array.isArray(rows1)) {\n const cookieRows: CookieRow[] = rows1.map((row) => {\n return {\n domain: row[\"host_key\"],\n name: row[\"name\"],\n value: row[\"encrypted_value\"],\n meta: {\n file: file\n }\n }\n })\n resolve(cookieRows);\n return;\n }\n if (process.env.VERBOSE) {\n console.log(`doSqliteQuery1: rows ${JSON.stringify(rows1)}`);\n }\n resolve([rows1]);\n });\n });\n}\n","import AbstractCookieQueryStrategy from \"./AbstractCookieQueryStrategy\";\nimport { env, HOME } from \"../global\";\nimport { existsSync } from \"fs\";\nimport { toStringOrNull } from \"../utils\";\nimport { findAllFiles } from \"../findAllFiles\";\nimport * as path from \"path\";\nimport { doSqliteQuery1 } from \"../doSqliteQuery1\";\nimport { ExportedCookie } from \"../CookieRow\";\n\nexport default class FirefoxCookieQueryStrategy extends AbstractCookieQueryStrategy {\n async queryCookies(name: string, domain: string): Promise<ExportedCookie[]> {\n if (process.platform !== \"darwin\") {\n throw new Error(\"This only works on macOS\");\n }\n if (env.CHROME_ONLY) {\n return [];\n }\n const cookies = await this.#getFirefoxCookie({ name, domain });\n return Array.isArray(cookies) ? cookies.map(toStringOrNull) : [];\n }\n\n /**\n *\n * @param name\n * @param domain\n * @returns {Promise<Buffer>}\n */\n async #getFirefoxCookie(\n //\n {\n name,\n domain\n }: {\n name: string,\n domain: string\n //\n }\n //\n ) {\n const files: string[] = await findAllFiles({\n path: path.join(\n HOME,\n \"Library\",\n \"Application Support\",\n \"Firefox\",\n \"Profiles\"\n ),\n name: \"cookies.sqlite\"\n });\n const all = await Promise.all(\n files.map((file) => {\n return this.#queryCookiesDb(file, name, domain);\n })\n );\n return all.flat();\n }\n\n #queryCookiesDb(file: string, name: string, domain: string) {\n if (file && !existsSync(file)) {\n throw new Error(`File ${file} does not exist`);\n }\n if (env.VERBOSE) {\n console.log(`Trying Firefox cookie ${name} for domain ${domain}`);\n }\n let sql;\n //language=SQL\n sql = \"SELECT value FROM moz_cookies\";\n if (typeof name === \"string\" || typeof domain === \"string\") {\n sql += ` WHERE `;\n if (typeof name === \"string\") {\n sql += `name = '${name}'`;\n if (typeof domain === \"string\") {\n sql += ` AND `;\n }\n }\n if (typeof domain === \"string\") {\n sql += `host LIKE '${domain}';`;\n }\n }\n return doSqliteQuery1(file, sql)\n .then((rows) => {\n return rows.map((row) => {\n return {\n domain: row.domain,\n name: row.name,\n value: row.value.toString(\"utf8\")\n };\n });\n })\n .catch(() => []);\n }\n}\n","import AbstractCookieQueryStrategy from \"./AbstractCookieQueryStrategy\";\n\nexport default class SafariCookieQueryStrategy extends AbstractCookieQueryStrategy {}\n","import jsonwebtoken from \"jsonwebtoken\";\nimport { env } from \"./global\";\n\nexport default function isValidJwt(token: any) {\n try {\n const result = jsonwebtoken.decode(token, { complete: true });\n if (env.VERBOSE) {\n console.log(result);\n }\n return true;\n } catch (err) {\n return false;\n }\n}\n"],"names":[],"version":3,"file":"main.js.map","sourceRoot":"../"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mherod/get-cookie",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.3",
|
|
4
4
|
"description": "Node.js module for querying a local user's Chrome cookie",
|
|
5
5
|
"source": "src/index.js",
|
|
6
6
|
"bin": "dist/cli.js",
|
|
@@ -13,10 +13,12 @@
|
|
|
13
13
|
"clean": "git clean -fXd",
|
|
14
14
|
"build": "parcel build",
|
|
15
15
|
"test": "jest",
|
|
16
|
-
"postbuild": "npm run install:global",
|
|
16
|
+
"postbuild": "npm run check && npm run install:global",
|
|
17
|
+
"prepublish": "npm run build",
|
|
17
18
|
"install:global": "npm install --force --global .",
|
|
18
19
|
"postinstall:global": "find $NVM_BIN -exec chmod +x {} \\; || true",
|
|
19
|
-
"prettier": "prettier --write 'src/{**/*,*}.{js,json}'"
|
|
20
|
+
"prettier": "prettier --write 'src/{**/*,*}.{js,json,ts}'",
|
|
21
|
+
"check": "tsc --noEmit"
|
|
20
22
|
},
|
|
21
23
|
"targets": {
|
|
22
24
|
"main": {
|
|
@@ -45,12 +47,19 @@
|
|
|
45
47
|
"author": "Matthew Herod",
|
|
46
48
|
"license": "ISC",
|
|
47
49
|
"dependencies": {
|
|
50
|
+
"colorette": "^2.0.19",
|
|
48
51
|
"jsonwebtoken": "^8.5.1",
|
|
49
52
|
"lodash": "^4.17.21",
|
|
50
|
-
"sqlite3": "^5.
|
|
53
|
+
"sqlite3": "^5.1.1"
|
|
51
54
|
},
|
|
52
55
|
"devDependencies": {
|
|
53
|
-
"
|
|
54
|
-
"
|
|
56
|
+
"@types/jsonwebtoken": "^8.5.9",
|
|
57
|
+
"@types/lodash": "^4.14.186",
|
|
58
|
+
"@types/node": "^18.8.2",
|
|
59
|
+
"jest": "^29.0.3",
|
|
60
|
+
"parcel": "^2.7.0",
|
|
61
|
+
"prettier": "^2.7.1",
|
|
62
|
+
"ts-node": "^10.9.1",
|
|
63
|
+
"typescript": "^4.8.4"
|
|
55
64
|
}
|
|
56
65
|
}
|
package/src/CookieRow.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface CookieRow {
|
|
2
|
+
domain: string;
|
|
3
|
+
name: string;
|
|
4
|
+
value: Buffer;
|
|
5
|
+
meta?: any;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function isCookieRow(obj: any): obj is CookieRow {
|
|
9
|
+
return obj.domain !== undefined && obj.name !== undefined && obj.value !== undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ExportedCookie {
|
|
13
|
+
domain: string;
|
|
14
|
+
name: string;
|
|
15
|
+
value: string;
|
|
16
|
+
meta?: any;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function isExportedCookie(obj: any): obj is ExportedCookie {
|
|
20
|
+
return obj.domain !== undefined && obj.name !== undefined && obj.value !== undefined;
|
|
21
|
+
}
|
package/src/argv.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const argv = process.argv ?? [];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {ExportedCookie} from "../CookieRow";
|
|
2
|
+
|
|
3
|
+
export default class AbstractCookieQueryStrategy {
|
|
4
|
+
async queryCookies(name: string, domain: string): Promise<ExportedCookie[]> {
|
|
5
|
+
if (process.env.NODE_ENV === "development") {
|
|
6
|
+
console.log("queryCookie", name, domain);
|
|
7
|
+
}
|
|
8
|
+
return [];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import AbstractCookieQueryStrategy from "./AbstractCookieQueryStrategy";
|
|
2
|
+
import { execSimple } from "../utils";
|
|
3
|
+
import { env, HOME } from "../global";
|
|
4
|
+
import { existsSync } from "fs";
|
|
5
|
+
import { findAllFiles } from "../findAllFiles";
|
|
6
|
+
import * as crypto from "crypto";
|
|
7
|
+
import * as path from "path";
|
|
8
|
+
import { CookieRow, ExportedCookie, isCookieRow, isExportedCookie } from "../CookieRow";
|
|
9
|
+
import { doSqliteQuery1 } from "../doSqliteQuery1";
|
|
10
|
+
import { merge } from "lodash";
|
|
11
|
+
|
|
12
|
+
export default class ChromeCookieQueryStrategy extends AbstractCookieQueryStrategy {
|
|
13
|
+
async queryCookies(name: string, domain: string): Promise<ExportedCookie[]> {
|
|
14
|
+
if (process.platform !== "darwin") {
|
|
15
|
+
throw new Error("This only works on macOS");
|
|
16
|
+
}
|
|
17
|
+
if (env.FIREFOX_ONLY) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
return getChromeCookies({
|
|
21
|
+
requireJwt: false,
|
|
22
|
+
name,
|
|
23
|
+
domain
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function getPromise1(name: string, domain: string, file: string): Promise<CookieRow[]> {
|
|
29
|
+
try {
|
|
30
|
+
return await getEncryptedChromeCookie({
|
|
31
|
+
name: name,
|
|
32
|
+
domain: domain,
|
|
33
|
+
file: file
|
|
34
|
+
});
|
|
35
|
+
} catch (e) {
|
|
36
|
+
if (env.VERBOSE) {
|
|
37
|
+
console.log("Error getting encrypted cookie", e);
|
|
38
|
+
}
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function getPromise(name: string, domain: string): Promise<CookieRow[]> {
|
|
44
|
+
try {
|
|
45
|
+
const files: string[] = await findAllFiles({
|
|
46
|
+
path: chromeLocal,
|
|
47
|
+
name: "Cookies"
|
|
48
|
+
});
|
|
49
|
+
const promises: Promise<CookieRow[]>[] = files.map((file) => getPromise1(name, domain, file));
|
|
50
|
+
const results1: Awaited<CookieRow[]>[] = await Promise.all(promises);
|
|
51
|
+
return results1.flat().filter(isCookieRow);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
if (env.VERBOSE) {
|
|
54
|
+
console.log("error", error);
|
|
55
|
+
}
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function decryptValue(password: string, encryptedValue: Buffer) {
|
|
61
|
+
let d: string | null;
|
|
62
|
+
try {
|
|
63
|
+
d = await decrypt(password, encryptedValue);
|
|
64
|
+
} catch (e) {
|
|
65
|
+
if (env.VERBOSE) {
|
|
66
|
+
console.log("Error decrypting cookie", e);
|
|
67
|
+
}
|
|
68
|
+
d = null;
|
|
69
|
+
}
|
|
70
|
+
return d ?? encryptedValue.toString("utf-8");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function getChromeCookies(
|
|
74
|
+
{
|
|
75
|
+
name,
|
|
76
|
+
domain = "%",
|
|
77
|
+
requireJwt = false
|
|
78
|
+
}: {
|
|
79
|
+
name: string;
|
|
80
|
+
domain: string;
|
|
81
|
+
requireJwt: boolean | undefined;
|
|
82
|
+
//
|
|
83
|
+
}
|
|
84
|
+
//
|
|
85
|
+
): Promise<ExportedCookie[]> {
|
|
86
|
+
const encryptedDataItems: CookieRow[] = await getPromise(name, domain);
|
|
87
|
+
const password: string = await getChromePassword();
|
|
88
|
+
const decrypted: Promise<ExportedCookie | null>[] = encryptedDataItems
|
|
89
|
+
.filter(({ value }) => value != null && value.length > 0)
|
|
90
|
+
.map(async (cookieRow: CookieRow) => {
|
|
91
|
+
const encryptedValue: Buffer = cookieRow.value;
|
|
92
|
+
const decryptedValue = await decryptValue(password, encryptedValue);
|
|
93
|
+
const meta = {};
|
|
94
|
+
merge(meta, cookieRow.meta ?? {});
|
|
95
|
+
return {
|
|
96
|
+
domain: cookieRow.domain,
|
|
97
|
+
name: cookieRow.name,
|
|
98
|
+
value: decryptedValue,
|
|
99
|
+
meta: meta
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
const results: ExportedCookie[] = (await Promise.all(decrypted)).filter(isExportedCookie);
|
|
103
|
+
if (env.VERBOSE) {
|
|
104
|
+
console.log("results", results);
|
|
105
|
+
}
|
|
106
|
+
return results;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const chromeLocal = path.join(
|
|
110
|
+
HOME,
|
|
111
|
+
"Library",
|
|
112
|
+
"Application Support",
|
|
113
|
+
"Google",
|
|
114
|
+
"Chrome"
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
async function getEncryptedChromeCookie(
|
|
118
|
+
{
|
|
119
|
+
name,
|
|
120
|
+
domain,
|
|
121
|
+
file = path.join(chromeLocal, "Default", "Cookies")
|
|
122
|
+
//
|
|
123
|
+
}: {
|
|
124
|
+
name: string;
|
|
125
|
+
domain: string;
|
|
126
|
+
file: string;
|
|
127
|
+
}): Promise<CookieRow[]> {
|
|
128
|
+
if (!existsSync(file)) {
|
|
129
|
+
throw new Error(`File ${file} does not exist`);
|
|
130
|
+
}
|
|
131
|
+
if (env.VERBOSE) {
|
|
132
|
+
const s = file.split("/").slice(-3).join("/");
|
|
133
|
+
console.log(`Trying Chrome (at ${s}) cookie ${name} for domain ${domain}`);
|
|
134
|
+
}
|
|
135
|
+
let sql;
|
|
136
|
+
sql = `SELECT encrypted_value, name, host_key FROM cookies`;
|
|
137
|
+
const wildcardRegexp = /^([*%])$/i;
|
|
138
|
+
const specifiedName = name.match(wildcardRegexp) == null;
|
|
139
|
+
const specifiedDomain = domain.match(wildcardRegexp) == null;
|
|
140
|
+
if (specifiedName || specifiedDomain) {
|
|
141
|
+
sql += ` WHERE `;
|
|
142
|
+
if (specifiedName) {
|
|
143
|
+
sql += `name = '${name}'`;
|
|
144
|
+
if (specifiedDomain) {
|
|
145
|
+
sql += ` AND `;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (specifiedDomain) {
|
|
149
|
+
sql += `host_key LIKE '${domain}';`;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return doSqliteQuery1(file, sql);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async function getChromePassword(): Promise<string> {
|
|
156
|
+
return execSimple(
|
|
157
|
+
"security find-generic-password -w -s \"Chrome Safe Storage\""
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async function decrypt(password: crypto.BinaryLike, encryptedData: Buffer): Promise<string> {
|
|
162
|
+
if (typeof password !== "string") {
|
|
163
|
+
throw new Error("password must be a string: " + password);
|
|
164
|
+
}
|
|
165
|
+
let encryptedData1: any;
|
|
166
|
+
encryptedData1 = encryptedData;
|
|
167
|
+
if (encryptedData1 == null || typeof encryptedData1 !== "object") {
|
|
168
|
+
throw new Error("encryptedData must be a object: " + encryptedData1);
|
|
169
|
+
}
|
|
170
|
+
if (!(encryptedData1 instanceof Buffer)) {
|
|
171
|
+
if (Array.isArray(encryptedData1) && encryptedData1[0] instanceof Buffer) {
|
|
172
|
+
[encryptedData1] = encryptedData1;
|
|
173
|
+
if (env.VERBOSE) {
|
|
174
|
+
console.log(
|
|
175
|
+
`encryptedData is an array of buffers, selected first: ${encryptedData1}`
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
} else {
|
|
179
|
+
throw new Error("encryptedData must be a Buffer: " + encryptedData1);
|
|
180
|
+
}
|
|
181
|
+
encryptedData1 = Buffer.from(encryptedData1);
|
|
182
|
+
}
|
|
183
|
+
if (env.VERBOSE) {
|
|
184
|
+
console.log(`Trying to decrypt with password ${password}`);
|
|
185
|
+
}
|
|
186
|
+
return new Promise((resolve, reject) => {
|
|
187
|
+
crypto.pbkdf2(password,
|
|
188
|
+
"saltysalt",
|
|
189
|
+
1003,
|
|
190
|
+
16,
|
|
191
|
+
"sha1",
|
|
192
|
+
(error, buffer) => {
|
|
193
|
+
try {
|
|
194
|
+
if (error) {
|
|
195
|
+
if (env.VERBOSE) {
|
|
196
|
+
console.log("Error doing pbkdf2", error);
|
|
197
|
+
}
|
|
198
|
+
reject(error);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (buffer.length !== 16) {
|
|
203
|
+
if (env.VERBOSE) {
|
|
204
|
+
console.log(
|
|
205
|
+
"Error doing pbkdf2, buffer length is not 16",
|
|
206
|
+
buffer.length
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
reject(new Error("Buffer length is not 16"));
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const str = new Array(17).join(" ");
|
|
214
|
+
const iv = Buffer.from(str, "binary");
|
|
215
|
+
const decipher = crypto.createDecipheriv("aes-128-cbc", buffer, iv);
|
|
216
|
+
decipher.setAutoPadding(false);
|
|
217
|
+
|
|
218
|
+
if (encryptedData1 && encryptedData1.slice) {
|
|
219
|
+
encryptedData1 = encryptedData1.slice(3);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (encryptedData1.length % 16 !== 0) {
|
|
223
|
+
if (env.VERBOSE) {
|
|
224
|
+
console.log(
|
|
225
|
+
"Error doing pbkdf2, encryptedData length is not a multiple of 16",
|
|
226
|
+
encryptedData1.length
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
reject(new Error("encryptedData length is not a multiple of 16"));
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
let decoded = decipher.update(encryptedData1);
|
|
234
|
+
try {
|
|
235
|
+
decipher.final("utf-8");
|
|
236
|
+
} catch (e) {
|
|
237
|
+
if (env.VERBOSE) {
|
|
238
|
+
console.log("Error doing decipher.final()", e);
|
|
239
|
+
}
|
|
240
|
+
reject(e);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const padding = decoded[decoded.length - 1];
|
|
245
|
+
if (padding) {
|
|
246
|
+
decoded = decoded.slice(0, 0 - padding);
|
|
247
|
+
}
|
|
248
|
+
// noinspection JSCheckFunctionSignatures
|
|
249
|
+
const decodedString = decoded.toString("utf8");
|
|
250
|
+
resolve(decodedString);
|
|
251
|
+
} catch (e) {
|
|
252
|
+
reject(e);
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import ChromeCookieQueryStrategy from "./ChromeCookieQueryStrategy";
|
|
2
|
+
import FirefoxCookieQueryStrategy from "./FirefoxCookieQueryStrategy";
|
|
3
|
+
import SafariCookieQueryStrategy from "./SafariCookieQueryStrategy";
|
|
4
|
+
import AbstractCookieQueryStrategy from "./AbstractCookieQueryStrategy";
|
|
5
|
+
import {ExportedCookie} from "../CookieRow";
|
|
6
|
+
|
|
7
|
+
export default class CompositeCookieQueryStrategy extends AbstractCookieQueryStrategy {
|
|
8
|
+
#strategies;
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
this.#strategies = [
|
|
13
|
+
ChromeCookieQueryStrategy,
|
|
14
|
+
FirefoxCookieQueryStrategy,
|
|
15
|
+
SafariCookieQueryStrategy,
|
|
16
|
+
].map((strategy) => {
|
|
17
|
+
return new strategy();
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async queryCookies(name: string, domain: string): Promise<ExportedCookie[]> {
|
|
22
|
+
const results = await Promise.all(
|
|
23
|
+
this.#strategies.map(async (strategy) => {
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
const cookies: Promise<ExportedCookie[]> = strategy.queryCookies(name, domain);
|
|
26
|
+
return cookies.catch(() => []);
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
return results.flat();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import AbstractCookieQueryStrategy from "./AbstractCookieQueryStrategy";
|
|
2
|
+
import { env, HOME } from "../global";
|
|
3
|
+
import { existsSync } from "fs";
|
|
4
|
+
import { toStringOrNull } from "../utils";
|
|
5
|
+
import { findAllFiles } from "../findAllFiles";
|
|
6
|
+
import * as path from "path";
|
|
7
|
+
import { doSqliteQuery1 } from "../doSqliteQuery1";
|
|
8
|
+
import { ExportedCookie } from "../CookieRow";
|
|
9
|
+
|
|
10
|
+
export default class FirefoxCookieQueryStrategy extends AbstractCookieQueryStrategy {
|
|
11
|
+
async queryCookies(name: string, domain: string): Promise<ExportedCookie[]> {
|
|
12
|
+
if (process.platform !== "darwin") {
|
|
13
|
+
throw new Error("This only works on macOS");
|
|
14
|
+
}
|
|
15
|
+
if (env.CHROME_ONLY) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
const cookies = await this.#getFirefoxCookie({ name, domain });
|
|
19
|
+
return Array.isArray(cookies) ? cookies.map(toStringOrNull) : [];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param name
|
|
25
|
+
* @param domain
|
|
26
|
+
* @returns {Promise<Buffer>}
|
|
27
|
+
*/
|
|
28
|
+
async #getFirefoxCookie(
|
|
29
|
+
//
|
|
30
|
+
{
|
|
31
|
+
name,
|
|
32
|
+
domain
|
|
33
|
+
}: {
|
|
34
|
+
name: string,
|
|
35
|
+
domain: string
|
|
36
|
+
//
|
|
37
|
+
}
|
|
38
|
+
//
|
|
39
|
+
) {
|
|
40
|
+
const files: string[] = await findAllFiles({
|
|
41
|
+
path: path.join(
|
|
42
|
+
HOME,
|
|
43
|
+
"Library",
|
|
44
|
+
"Application Support",
|
|
45
|
+
"Firefox",
|
|
46
|
+
"Profiles"
|
|
47
|
+
),
|
|
48
|
+
name: "cookies.sqlite"
|
|
49
|
+
});
|
|
50
|
+
const all = await Promise.all(
|
|
51
|
+
files.map((file) => {
|
|
52
|
+
return this.#queryCookiesDb(file, name, domain);
|
|
53
|
+
})
|
|
54
|
+
);
|
|
55
|
+
return all.flat();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#queryCookiesDb(file: string, name: string, domain: string) {
|
|
59
|
+
if (file && !existsSync(file)) {
|
|
60
|
+
throw new Error(`File ${file} does not exist`);
|
|
61
|
+
}
|
|
62
|
+
if (env.VERBOSE) {
|
|
63
|
+
console.log(`Trying Firefox cookie ${name} for domain ${domain}`);
|
|
64
|
+
}
|
|
65
|
+
let sql;
|
|
66
|
+
//language=SQL
|
|
67
|
+
sql = "SELECT value FROM moz_cookies";
|
|
68
|
+
if (typeof name === "string" || typeof domain === "string") {
|
|
69
|
+
sql += ` WHERE `;
|
|
70
|
+
if (typeof name === "string") {
|
|
71
|
+
sql += `name = '${name}'`;
|
|
72
|
+
if (typeof domain === "string") {
|
|
73
|
+
sql += ` AND `;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (typeof domain === "string") {
|
|
77
|
+
sql += `host LIKE '${domain}';`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return doSqliteQuery1(file, sql)
|
|
81
|
+
.then((rows) => {
|
|
82
|
+
return rows.map((row) => {
|
|
83
|
+
return {
|
|
84
|
+
domain: row.domain,
|
|
85
|
+
name: row.name,
|
|
86
|
+
value: row.value.toString("utf8")
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
})
|
|
90
|
+
.catch(() => []);
|
|
91
|
+
}
|
|
92
|
+
}
|