From f12f44ce190d25c4468560e212cd3e3580c5959e Mon Sep 17 00:00:00 2001 From: Jean Ouina Date: Wed, 3 Jun 2020 22:19:12 +0200 Subject: [PATCH] mini fix --- BetterDiscordApp/js/main.js | 2 +- BetterDiscordApp/src/modules/pluginCertifier.js | 7 +++++-- .../discord_desktop_core/core/app/BetterDiscord/index.js | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/BetterDiscordApp/js/main.js b/BetterDiscordApp/js/main.js index 342746e..56f117f 100644 --- a/BetterDiscordApp/js/main.js +++ b/BetterDiscordApp/js/main.js @@ -311,7 +311,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _0gl /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var node_fetch__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node-fetch */ \"node-fetch\");\n/* harmony import */ var node_fetch__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(node_fetch__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var electron__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! electron */ \"electron\");\n/* harmony import */ var electron__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(electron__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! crypto */ \"crypto\");\n/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _v2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./v2 */ \"./src/modules/v2.js\");\n/* harmony import */ var _ui_tooltipWrap__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../ui/tooltipWrap */ \"./src/ui/tooltipWrap.js\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils */ \"./src/modules/utils.js\");\n\n\n\n\n\n\nconst debug = true;\nconst cache = {};\nconst cache2 = {};\n/*\r\nconst PinnedModule = BDModules.get(e => e.default && e.default.getPinnedMessages)[0].default\r\nconst ChannelModule = BDModules.get(e => e.default && e.default.getChannelId)[0].default\r\nconst fetchMessagesModule = BDModules.get(e => e.default && e.default.fetchMessages)[0].default\r\nconst fetchMessagesModule2 = BDModules.get(e => e.default && e.default.fetchMessages)[1].default\r\nconst getMessagesModule = BDModules.get(e => e.default && e.default.getMessages)[0].default*/\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (new class PluginCertifier {\n constructor() {}\n\n patch(attachment, id) {\n process.nextTick(() => {\n processAttachment(attachment, id);\n });\n }\n\n start() {\n /*const dispatcher = window.Lightcord.DiscordModules.dispatcher\r\n const constants = window.Lightcord.DiscordModules.constants\r\n const originalFetchMessages = fetchMessagesModule.fetchMessages\r\n fetchMessagesModule.fetchMessages = function(){\r\n const returnValue = originalFetchMessages.apply(this, arguments)\r\n if(returnValue instanceof Promise){\r\n returnValue\r\n .then(() => {\r\n const ev = getMessagesModule.getMessages(ChannelModule.getChannelId())\r\n process.nextTick(() => {\r\n for(const message of ev._array){\r\n const attachments = message.attachments || []\r\n if(attachments.length === 0)continue // no attachments\r\n \r\n attachments.forEach(attachment => {\r\n processAttachment(attachment)\r\n })\r\n }\r\n })\r\n })\r\n }\r\n return returnValue\r\n }\r\n const originalFetchMessages2 = fetchMessagesModule2.fetchMessages\r\n fetchMessagesModule2.fetchMessages = function(){\r\n const returnValue = originalFetchMessages2.apply(this, arguments)\r\n if(returnValue instanceof Promise){\r\n returnValue\r\n .then(() => {\r\n const ev = getMessagesModule.getMessages(ChannelModule.getChannelId())\r\n process.nextTick(() => {\r\n for(const message of ev._array){\r\n const attachments = message.attachments || []\r\n if(attachments.length === 0)continue // no attachments\r\n \r\n attachments.forEach(attachment => {\r\n processAttachment(attachment)\r\n })\r\n }\r\n })\r\n })\r\n }\r\n return returnValue\r\n }\r\n const alreadyUsed = {}\r\n const originalGetPinnedMessages = PinnedModule.getPinnedMessages.bind(PinnedModule)\r\n PinnedModule.getPinnedMessages = function(){\r\n const pinned = originalGetPinnedMessages(...arguments)\r\n if(!pinned || alreadyUsed[pinned.id])return pinned\r\n alreadyUsed[pinned.id] = true\r\n \r\n setTimeout(() => {\r\n delete alreadyUsed[pinned.id]\r\n for(const message of pinned.messages){\r\n const attachments = message.attachments || []\r\n if(attachments.length === 0)continue // no attachments\r\n attachments.forEach(attachment => {\r\n processAttachment(attachment)\r\n })\r\n }\r\n }, 50);\r\n return pinned\r\n }\r\n dispatcher.subscribe(constants.ActionTypes.MESSAGE_CREATE, (ev) => {\r\n const message = ev.message\r\n if(message.channel_id !== ChannelModule.getChannelId())return\r\n process.nextTick(() => {\r\n const attachments = message.attachments || []\r\n if(attachments.length === 0)return // no attachments\r\n attachments.forEach(attachment => {\r\n processAttachment(attachment)\r\n })\r\n })\r\n })\r\n const messages = getMessagesModule.getMessages(ChannelModule.getChannelId())\r\n process.nextTick(() => {\r\n for(const message of messages._array){\r\n const attachments = message.attachments || []\r\n if(attachments.length === 0)continue // no attachments\r\n attachments.forEach(attachment => {\r\n processAttachment(attachment)\r\n })\r\n }\r\n })*/\n }\n\n}());\n\nfunction checkViruses(hash, data, id) {\n data = data.toString(\"utf8\").split(/[^\\w\\d]+/g);\n let isHarmful = false;\n\n for (let keyword of data) {\n for (let oof of [\"token\", \"email\", \"phone\", \"MFA\", \"2fa\", \"process\", \"child_process\", \"localStorage\", \"eval\", \"getGlobal\", \"BrowserWindow\"]) {\n if (keyword.toLowerCase().includes(oof.toLowerCase())) {\n isHarmful = \"token stealer/virus\";\n break;\n }\n }\n\n if (isHarmful) break;\n }\n\n if (!isHarmful) {\n /**\r\n * @type {string}\r\n */\n const no_comments = data.replace(/\\/\\*[\\s\\S]*?\\*\\/|([^\\\\:]|^)\\/\\/.*$/gm, \"\").trim(); // removing the META{} comment from plugins\n\n if (/var [\\w\\d_$]+=\\[\"/gi.test(no_comments)) {\n isHarmful = \"obfuscation/hidden code\";\n }\n\n if (!isHarmful) {\n const regexps = [\n /** hexadecimal */\n /_0x\\w{4}\\('0x[\\dabcdef]+'\\)/g, /_0x\\w{4}\\('0x[\\dabcdef]+'[, ]+'[^']{4}'\\)/g, // _0x8db7('0x0', 'x1]f')\n\n /** mangled */\n /\\w+\\('0x[\\dabcdef]+'\\)/g, /\\w+\\('0x[\\dabcdef]+'[, ]+'[^']{4}'\\)/g // _0x8db7('0x0', 'x1]f')\n ];\n\n for (let regex of regexps) {\n if (isHarmful) break;\n isHarmful = regex.test(no_comments) ? \"obfuscation/hidden code\" : false;\n }\n }\n }\n\n if (!isHarmful) return;\n cache[hash] = {\n suspect: true,\n name: hashToUrl[hash].split(\"/\").pop(),\n type: hashToUrl[hash].endsWith(\".js\") ? \"Plugin\" : \"Theme\",\n harm: isHarmful\n };\n console.log(`Found potentially dangerous virus: ${cache[hash].name}`);\n renderToElements(id, cache[hash], cache[hash].name);\n}\n\nconst hashToUrl = {};\n\nfunction processAttachment(attachment, id) {\n if (!document.getElementById(id)) return;\n if (!attachment.url.startsWith(\"https://cdn.discordapp.com/\")) return document.getElementById(id).remove();\n if (!attachment.filename.endsWith(\".plugin.js\") && !attachment.filename.endsWith(\".theme.css\")) return document.getElementById(id).remove();\n\n let nextHash = (hash, data) => {\n if (!cache[hash]) {\n node_fetch__WEBPACK_IMPORTED_MODULE_0___default()(\"https://cdn.jsdelivr.net/gh/Lightcord/filehashes@master/hashes/\" + hash, {\n // Using node-fetch to bypass cors\n headers: {\n \"User-Agent\": electron__WEBPACK_IMPORTED_MODULE_1__[\"remote\"].getCurrentWebContents().userAgent // have to set user-agent\n\n }\n }).then(async res => {\n if (res.status !== 200) return checkViruses(hash, data, id);\n const result = await res.json();\n cache[hash] = result;\n renderToElements(id, result, attachment.filename);\n }).catch(() => {});\n } else {\n const result = cache[hash];\n renderToElements(id, result, attachment.filename);\n }\n };\n\n if (cache2[attachment.url]) return nextHash(cache2[attachment.url]);\n node_fetch__WEBPACK_IMPORTED_MODULE_0___default()(attachment.url, {\n headers: {\n \"User-Agent\": electron__WEBPACK_IMPORTED_MODULE_1__[\"remote\"].getCurrentWebContents().userAgent\n }\n }).then(res => {\n if (res.status !== 200) throw new Error(\"File doesn't exist.\");\n const hash = crypto__WEBPACK_IMPORTED_MODULE_2__[\"createHash\"](\"sha256\");\n let data = Buffer.alloc(0);\n res.body.on(\"data\", chunk => {\n data = Buffer.concat([data, chunk]);\n hash.update(chunk);\n });\n res.body.on(\"end\", () => {\n const hashResult = hash.digest(\"hex\");\n cache2[attachment.url] = hashResult;\n hashToUrl[hashResult] = attachment.url;\n nextHash(hashResult, data);\n });\n }).catch(() => {});\n}\n\nlet flowerStarModule = BDModules.get(e => e.flowerStarContainer)[0];\nlet childModule = BDModules.get(e => e.childContainer)[0];\n/**\r\n * \r\n * @param {HTMLDivElement[]} elements \r\n * @param {{type: \"Theme\"|\"Plugin\", name: string, official?: boolean}|{suspect:true, type: \"Theme\"|\"Plugin\", name: string, harm: string}} result\r\n */\n\nfunction renderToElements(id, result, filename) {\n const div = document.getElementById(id);\n if (!div || div.childNodes.length > 0) return; // already certified/div does not exist anymore.\n // TODO: implements suspect plugins.\n\n if (!flowerStarModule) flowerStarModule = BDModules.get(e => e.flowerStarContainer)[0];\n if (!childModule) childModule = BDModules.get(e => e.childContainer)[0];\n\n if (result.suspect) {\n try {\n div.parentNode.style.borderColor = \"rgb(240, 71, 71)\";\n /**\r\n * \r\n * @param {HTMLElement} node \r\n */\n\n let nextNode = node => {\n for (let child of node.children) {\n if (child.tagName === \"A\") {\n child.addEventListener(\"click\", e => {\n e.preventDefault();\n e.stopImmediatePropagation();\n _utils__WEBPACK_IMPORTED_MODULE_5__[\"default\"].showConfirmationModal(\"Are you sure you want to download this ?\", \"The \" + result.type.toLowerCase() + \" **\" + filename + \"** might be dangerous **(\" + result.harm + \")**. \\n\\n**We don't recommand to download it**. However, you can still do it below.\", {\n confirmText: \"Download Anyway\",\n cancelText: \"Don't !\",\n danger: true,\n onCancel: () => {},\n onConfirm: () => {\n electron__WEBPACK_IMPORTED_MODULE_1__[\"remote\"].shell.openExternal(child.href);\n }\n });\n });\n } else if ([\"div\"].includes(child.tagName.toLowerCase())) {\n nextNode(child);\n }\n }\n };\n\n nextNode(div.parentNode);\n } catch (e) {\n console.error(e);\n }\n\n _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].reactDom.render(_v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(_ui_tooltipWrap__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n text: result.type + \" \" + result.name + \" is potentially dangerous.\"\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"div\", {\n className: flowerStarModule.flowerStarContainer,\n style: {\n width: \"16px\",\n height: \"16px\"\n }\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"svg\", {\n className: BDModules.get(e => e.svg)[0].svg,\n \"aria-hidden\": \"false\",\n width: \"16px\",\n height: \"16px\",\n viewBox: \"0 0 40 32\"\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"rect\", {\n x: \"0\",\n y: \"0\",\n width: \"32\",\n height: \"32\",\n mask: \"url(#svg-mask-avatar-status-round-32)\",\n fill: \"#f04747\",\n mask: \"url(#svg-mask-status-dnd)\",\n className: BDModules.get(e => e.pointerEvents)[0].pointerEvents\n })))), div);\n } else if (!result.official) {\n div.parentNode.style.borderColor = \"#4087ed\";\n _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].reactDom.render(_v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(_ui_tooltipWrap__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n text: result.type + \" \" + result.name + \" is certified by Lightcord.\"\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"div\", {\n className: flowerStarModule.flowerStarContainer,\n style: {\n width: \"16px\",\n height: \"16px\"\n }\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"svg\", {\n className: flowerStarModule.flowerStar,\n \"aria-hidden\": \"false\",\n width: \"16px\",\n height: \"16px\",\n viewBox: \"0 0 16 15.2\"\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"path\", {\n fill: \"#4f545c\",\n \"fill-rule\": \"evenodd\",\n d: \"m16 7.6c0 .79-1.28 1.38-1.52 2.09s.44 2 0 2.59-1.84.35-2.46.8-.79 1.84-1.54 2.09-1.67-.8-2.47-.8-1.75 1-2.47.8-.92-1.64-1.54-2.09-2-.18-2.46-.8.23-1.84 0-2.59-1.54-1.3-1.54-2.09 1.28-1.38 1.52-2.09-.44-2 0-2.59 1.85-.35 2.48-.8.78-1.84 1.53-2.12 1.67.83 2.47.83 1.75-1 2.47-.8.91 1.64 1.53 2.09 2 .18 2.46.8-.23 1.84 0 2.59 1.54 1.3 1.54 2.09z\"\n })), _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"div\", {\n className: childModule.childContainer\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"svg\", {\n \"aria-hidden\": \"false\",\n width: \"16px\",\n height: \"16px\",\n viewBox: \"0 0 16 15.2\"\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"path\", {\n fill: \"#ffffff\",\n d: \"M7.4,11.17,4,8.62,5,7.26l2,1.53L10.64,4l1.36,1Z\"\n }))))), div);\n } else {\n div.parentNode.style.borderColor = \"#4087ed\";\n _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].reactDom.render(_v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(_ui_tooltipWrap__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n text: result.type + \" \" + result.name + \" was made by the developers of Lightcord.\",\n style: \"brand\"\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"div\", {\n className: flowerStarModule.flowerStarContainer,\n style: {\n width: \"16px\",\n height: \"16px\"\n }\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"svg\", {\n className: flowerStarModule.flowerStar,\n \"aria-hidden\": \"false\",\n width: \"16px\",\n height: \"16px\",\n viewBox: \"0 0 16 15.2\",\n stroke: \"#36393f\",\n style: {\n color: \"#4087ed\"\n }\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"path\", {\n fill: \"currentColor\",\n \"fill-rule\": \"evenodd\",\n d: \"m16 7.6c0 .79-1.28 1.38-1.52 2.09s.44 2 0 2.59-1.84.35-2.46.8-.79 1.84-1.54 2.09-1.67-.8-2.47-.8-1.75 1-2.47.8-.92-1.64-1.54-2.09-2-.18-2.46-.8.23-1.84 0-2.59-1.54-1.3-1.54-2.09 1.28-1.38 1.52-2.09-.44-2 0-2.59 1.85-.35 2.48-.8.78-1.84 1.53-2.12 1.67.83 2.47.83 1.75-1 2.47-.8.91 1.64 1.53 2.09 2 .18 2.46.8-.23 1.84 0 2.59 1.54 1.3 1.54 2.09z\"\n })), _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"div\", {\n className: childModule.childContainer\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"svg\", {\n \"aria-hidden\": \"false\",\n width: \"16px\",\n height: \"16px\",\n viewBox: \"0 0 16 15.2\"\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"path\", {\n fill: \"#ffffff\",\n d: \"M10.7,5.28a2.9,2.9,0,0,0-2.11.86.11.11,0,0,0,0,.16l1.05.94a.11.11,0,0,0,.15,0,1.27,1.27,0,0,1,.9-.33c.65,0,.65.73.65.73a.64.64,0,0,1-.65.65,1.73,1.73,0,0,1-1.18-.54c-.31-.26-.36-.32-.73-.66S7.06,5.28,5.65,5.28A2.26,2.26,0,0,0,3.37,7.56,2.59,2.59,0,0,0,3.82,9a2.18,2.18,0,0,0,1.83.89,2.94,2.94,0,0,0,2.1-.81.11.11,0,0,0,0-.16L6.74,8A.11.11,0,0,0,6.6,8a1.58,1.58,0,0,1-.94.29h0A.71.71,0,0,1,5,7.56H5a.63.63,0,0,1,.65-.64c.71,0,1.42.75,1.94,1.27.75.76,1.66,1.79,3.11,1.74A2.28,2.28,0,0,0,13,7.64a2.59,2.59,0,0,0-.45-1.47A2.14,2.14,0,0,0,10.7,5.28Z\"\n }))))), div);\n }\n}//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9zcmMvbW9kdWxlcy9wbHVnaW5DZXJ0aWZpZXIuanMuanMiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly9CZXR0ZXJEaXNjb3JkLy4vc3JjL21vZHVsZXMvcGx1Z2luQ2VydGlmaWVyLmpzPzQyODMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IG5vZGVGZXRjaCBmcm9tIFwibm9kZS1mZXRjaFwiO1xuaW1wb3J0ICogYXMgZWxlY3Ryb24gZnJvbSBcImVsZWN0cm9uXCI7XG5pbXBvcnQgKiBhcyBjcnlwdG8gZnJvbSBcImNyeXB0b1wiO1xuaW1wb3J0IEJEVjIgZnJvbSBcIi4vdjJcIjtcbmltcG9ydCB0b29sdGlwV3JhcCBmcm9tIFwiLi4vdWkvdG9vbHRpcFdyYXBcIjtcbmltcG9ydCBVdGlscyBmcm9tIFwiLi91dGlsc1wiO1xuY29uc3QgZGVidWcgPSB0cnVlO1xuY29uc3QgY2FjaGUgPSB7fTtcbmNvbnN0IGNhY2hlMiA9IHt9O1xuLypcclxuY29uc3QgUGlubmVkTW9kdWxlID0gQkRNb2R1bGVzLmdldChlID0+IGUuZGVmYXVsdCAmJiBlLmRlZmF1bHQuZ2V0UGlubmVkTWVzc2FnZX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jaE1lc3NhZ2VzXHJcbiAgICBmZXRjaE1lc3NhZ2VzTW9kdWxlLmZldGNoTWVzc2FnZXMgPSBmdW5jdGlvbigpe1xyXG4gICAgICAgIGNvbnN0IHJldHVyblZhbHVlID0gb3JpZ2luYWxGZXRjaE1lc3NhZ2VzLmFwcGx5KHRoaXMsIGFyZ3VtZW50cylcclxuICAgICAgICBpZihyZXR1cm5WYWx1ZSBpbnN0YW5jZW9mIFByb21pc2Upe1xyXG4gICAgICAgICAgICByZXR1cm5WYWx1ZVxyXG4gICAgICAgICAgICAudGhlbigoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBldiA9IGdldE1lc3NhZ2VzTW9kdWxlLmdldE1lc3NhZ2VzKENoYW5uZWxNb2R1bGUuZ2V0Q2hhbm5lbElkKCkpXHJcbiAgICAgICAgICAgICAgICBwcm9jZXNzLm5leHRUaWNrKCgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBmb3IoY29uc3QgbWVzc2FnZSBvZiBldi5fYXJyYXkpe1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhdHRhY2htZW50cyA9IG1lc3NhZ2UuYXR0YWNobWVudHMgfHwgW11cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYoYXR0YWNobWVudHMubGVuZ3RoID09PSAwKWNvbnRpbnVlIC8vIG5vIGF0dGFjaG1lbnRzXHJcbiAgICAgICAgXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGF0dGFjaG1lbnRzLmZvckVhY2goYXR0YWNobWVudCA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzQXR0YWNobWVudChhdHRhY2htZW50KVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgIH0pXHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiByZXR1cm5WYWx1ZVxyXG4gICAgfVxyXG4gICAgICBjb25zdCBvcmlnaW5hbEZldGNoTWVzc2FnZXMyID0gZmV0Y2hNZXNzYWdlc01vZHVsZTIuZmV0Y2hNZXNzYWdlc1xyXG4gICAgZmV0Y2hNZXNzYWdlc01vZHVsZTIuZmV0Y2hNZXNzYWdlcyA9IGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgY29uc3QgcmV0dXJuVmFsdWUgPSBvcmlnaW5hbEZldGNoTWVzc2FnZXMyLmFwcGx5KHRoaXMsIGFyZ3VtZW50cylcclxuICAgICAgICBpZihyZXR1cm5WYWx1ZSBpbnN0YW5jZW9mIFByb21pc2Upe1xyXG4gICAgICAgICAgICByZXR1cm5WYWx1ZVxyXG4gICAgICAgICAgICAudGhlbigoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBldiA9IGdldE1lc3NhZ2VzTW9kdWxlLmdldE1lc3NhZ2VzKENoYW5uZWxNb2R1bGUuZ2V0Q2hhbm5lbElkKCkpXHJcbiAgICAgICAgICAgICAgICBwcm9jZXNzLm5leHRUaWNrKCgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBmb3IoY29uc3QgbWVzc2FnZSBvZiBldi5fYXJyYXkpe1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhdHRhY2htZW50cyA9IG1lc3NhZ2UuYXR0YWNobWVudHMgfHwgW11cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYoYXR0YWNobWVudHMubGVuZ3RoID09PSAwKWNvbnRpbnVlIC8vIG5vIGF0dGFjaG1lbnRzXHJcbiAgICAgICAgXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGF0dGFjaG1lbnRzLmZvckVhY2goYXR0YWNobWVudCA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzQXR0YWNobWVudChhdHRhY2htZW50KVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgIH0pXHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiByZXR1cm5WYWx1ZVxyXG4gICAgfVxyXG4gICAgICBjb25zdCBhbHJlYWR5VXNlZCA9IHt9XHJcbiAgICBjb25zdCBvcmlnaW5hbEdldFBpbm5lZE1lc3NhZ2VzID0gUGlubmVkTW9kdWxlLmdldFBpbm5lZE1lc3NhZ2VzLmJpbmQoUGlubmVkTW9kdWxlKVxyXG4gICAgUGlubmVkTW9kdWxlLmdldFBpbm5lZE1lc3NhZ2VzID0gZnVuY3Rpb24oKXtcclxuICAgICAgICBjb25zdCBwaW5uZWQgPSBvcmlnaW5hbEdldFBpbm5lZE1lc3NhZ2VzKC4uLmFyZ3VtZW50cylcclxuICAgICAgICBpZighcGlubmVkIHx8IGFscmVhZHlVc2VkW3Bpbm5lZC5pZF0pcmV0dXJuIHBpbm5lZFxyXG4gICAgICAgIGFscmVhZHlVc2VkW3Bpbm5lZC5pZF0gPSB0cnVlXHJcbiAgICAgICAgXHJcbiAgICAgICAgc2V0VGltZW91dCgoKSA9PiB7XHJcbiAgICAgICAgICAgIGRlbGV0ZSBhbHJlYWR5VXNlZFtwaW5uZWQuaWRdXHJcbiAgICAgICAgICAgIGZvcihjb25zdCBtZXNzYWdlIG9mIHBpbm5lZC5tZXNzYWdlcyl7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBhdHRhY2htZW50cyA9IG1lc3NhZ2UuYXR0YWNobWVudHMgfHwgW11cclxuICAgICAgICAgICAgICAgIGlmKGF0dGFjaG1lbnRzLmxlbmd0aCA9PT0gMCljb250aW51ZSAvLyBubyBhdHRhY2htZW50c1xyXG4gICAgICAgICAgICAgICAgICAgICAgYXR0YWNobWVudHMuZm9yRWFjaChhdHRhY2htZW50ID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBwcm9jZXNzQXR0YWNobWVudChhdHRhY2htZW50KVxyXG4gICAgICAgICAgICAgIC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ack-internal:///./src/modules/pluginCertifier.js\n"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var node_fetch__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node-fetch */ \"node-fetch\");\n/* harmony import */ var node_fetch__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(node_fetch__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var electron__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! electron */ \"electron\");\n/* harmony import */ var electron__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(electron__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! crypto */ \"crypto\");\n/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _v2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./v2 */ \"./src/modules/v2.js\");\n/* harmony import */ var _ui_tooltipWrap__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../ui/tooltipWrap */ \"./src/ui/tooltipWrap.js\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils */ \"./src/modules/utils.js\");\n\n\n\n\n\n\nconst debug = true;\nconst cache = {};\nconst cache2 = {};\n/*\r\nconst PinnedModule = BDModules.get(e => e.default && e.default.getPinnedMessages)[0].default\r\nconst ChannelModule = BDModules.get(e => e.default && e.default.getChannelId)[0].default\r\nconst fetchMessagesModule = BDModules.get(e => e.default && e.default.fetchMessages)[0].default\r\nconst fetchMessagesModule2 = BDModules.get(e => e.default && e.default.fetchMessages)[1].default\r\nconst getMessagesModule = BDModules.get(e => e.default && e.default.getMessages)[0].default*/\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (new class PluginCertifier {\n constructor() {}\n\n patch(attachment, id) {\n process.nextTick(() => {\n processAttachment(attachment, id);\n });\n }\n\n start() {\n /*const dispatcher = window.Lightcord.DiscordModules.dispatcher\r\n const constants = window.Lightcord.DiscordModules.constants\r\n const originalFetchMessages = fetchMessagesModule.fetchMessages\r\n fetchMessagesModule.fetchMessages = function(){\r\n const returnValue = originalFetchMessages.apply(this, arguments)\r\n if(returnValue instanceof Promise){\r\n returnValue\r\n .then(() => {\r\n const ev = getMessagesModule.getMessages(ChannelModule.getChannelId())\r\n process.nextTick(() => {\r\n for(const message of ev._array){\r\n const attachments = message.attachments || []\r\n if(attachments.length === 0)continue // no attachments\r\n \r\n attachments.forEach(attachment => {\r\n processAttachment(attachment)\r\n })\r\n }\r\n })\r\n })\r\n }\r\n return returnValue\r\n }\r\n const originalFetchMessages2 = fetchMessagesModule2.fetchMessages\r\n fetchMessagesModule2.fetchMessages = function(){\r\n const returnValue = originalFetchMessages2.apply(this, arguments)\r\n if(returnValue instanceof Promise){\r\n returnValue\r\n .then(() => {\r\n const ev = getMessagesModule.getMessages(ChannelModule.getChannelId())\r\n process.nextTick(() => {\r\n for(const message of ev._array){\r\n const attachments = message.attachments || []\r\n if(attachments.length === 0)continue // no attachments\r\n \r\n attachments.forEach(attachment => {\r\n processAttachment(attachment)\r\n })\r\n }\r\n })\r\n })\r\n }\r\n return returnValue\r\n }\r\n const alreadyUsed = {}\r\n const originalGetPinnedMessages = PinnedModule.getPinnedMessages.bind(PinnedModule)\r\n PinnedModule.getPinnedMessages = function(){\r\n const pinned = originalGetPinnedMessages(...arguments)\r\n if(!pinned || alreadyUsed[pinned.id])return pinned\r\n alreadyUsed[pinned.id] = true\r\n \r\n setTimeout(() => {\r\n delete alreadyUsed[pinned.id]\r\n for(const message of pinned.messages){\r\n const attachments = message.attachments || []\r\n if(attachments.length === 0)continue // no attachments\r\n attachments.forEach(attachment => {\r\n processAttachment(attachment)\r\n })\r\n }\r\n }, 50);\r\n return pinned\r\n }\r\n dispatcher.subscribe(constants.ActionTypes.MESSAGE_CREATE, (ev) => {\r\n const message = ev.message\r\n if(message.channel_id !== ChannelModule.getChannelId())return\r\n process.nextTick(() => {\r\n const attachments = message.attachments || []\r\n if(attachments.length === 0)return // no attachments\r\n attachments.forEach(attachment => {\r\n processAttachment(attachment)\r\n })\r\n })\r\n })\r\n const messages = getMessagesModule.getMessages(ChannelModule.getChannelId())\r\n process.nextTick(() => {\r\n for(const message of messages._array){\r\n const attachments = message.attachments || []\r\n if(attachments.length === 0)continue // no attachments\r\n attachments.forEach(attachment => {\r\n processAttachment(attachment)\r\n })\r\n }\r\n })*/\n }\n\n}());\n\nfunction checkViruses(hash, data, id) {\n data = data.toString(\"utf8\").split(/[^\\w\\d]+/g);\n let isHarmful = false;\n\n for (let keyword of data) {\n for (let oof of [\"token\", \"email\", \"phone\", \"MFA\", \"2fa\", \"process\", \"child_process\", \"localStorage\", \"eval\", \"getGlobal\", \"BrowserWindow\"]) {\n if (keyword.toLowerCase().includes(oof.toLowerCase())) {\n isHarmful = \"token stealer/virus\";\n break;\n }\n }\n\n if (isHarmful) break;\n }\n\n if (!isHarmful) {\n /**\r\n * @type {string}\r\n */\n const no_comments = data.replace(/\\/\\*[\\s\\S]*?\\*\\/|([^\\\\:]|^)\\/\\/.*$/gm, \"\").trim(); // removing the META comment from plugins\n\n if (/var [\\w\\d_$]+=\\[\"/gi.test(no_comments)) {\n isHarmful = \"obfuscation/hidden code\";\n }\n\n if (!isHarmful) {\n const regexps = [\n /** hexadecimal */\n /_0x\\w{4}\\('0x[\\dabcdef]+'\\)/g, /_0x\\w{4}\\('0x[\\dabcdef]+'[, ]+'[^']{4}'\\)/g, // _0x8db7('0x0', 'x1]f')\n\n /** mangled */\n /\\w+\\('0x[\\dabcdef]+'\\)/g, /\\w+\\('0x[\\dabcdef]+'[, ]+'[^']{4}'\\)/g // _0x8db7('0x0', 'x1]f')\n ];\n\n for (let regex of regexps) {\n if (isHarmful) break;\n isHarmful = regex.test(no_comments) ? \"obfuscation/hidden code\" : false;\n }\n }\n }\n\n if (!isHarmful) return;\n cache[hash] = {\n suspect: true,\n name: hashToUrl[hash].split(\"/\").pop(),\n type: hashToUrl[hash].endsWith(\".js\") ? \"Plugin\" : \"Theme\",\n harm: isHarmful\n };\n console.log(`Found potentially dangerous ${cache[hash].type.toLowerCase()}: ${cache[hash].name}`);\n renderToElements(id, cache[hash], cache[hash].name);\n}\n\nconst hashToUrl = {};\n\nfunction processAttachment(attachment, id) {\n if (!document.getElementById(id)) return;\n if (!attachment.url.startsWith(\"https://cdn.discordapp.com/\")) return document.getElementById(id).remove();\n if (!attachment.filename.endsWith(\".plugin.js\") && !attachment.filename.endsWith(\".theme.css\")) return document.getElementById(id).remove();\n\n let nextHash = (hash, data) => {\n if (!cache[hash]) {\n node_fetch__WEBPACK_IMPORTED_MODULE_0___default()(\"https://cdn.jsdelivr.net/gh/Lightcord/filehashes@master/hashes/\" + hash, {\n // Using node-fetch to bypass cors\n headers: {\n \"User-Agent\": electron__WEBPACK_IMPORTED_MODULE_1__[\"remote\"].getCurrentWebContents().userAgent // have to set user-agent\n\n }\n }).then(async res => {\n if (res.status !== 200) return checkViruses(hash, data, id);\n const result = await res.json();\n result.official = true;\n cache[hash] = result;\n renderToElements(id, result, attachment.filename);\n }).catch(() => {});\n } else {\n const result = cache[hash];\n renderToElements(id, result, attachment.filename);\n }\n };\n\n if (cache2[attachment.url]) return nextHash(cache2[attachment.url]);\n node_fetch__WEBPACK_IMPORTED_MODULE_0___default()(attachment.url, {\n headers: {\n \"User-Agent\": electron__WEBPACK_IMPORTED_MODULE_1__[\"remote\"].getCurrentWebContents().userAgent\n }\n }).then(res => {\n if (res.status !== 200) throw new Error(\"File doesn't exist.\");\n const hash = crypto__WEBPACK_IMPORTED_MODULE_2__[\"createHash\"](\"sha256\");\n let data = Buffer.alloc(0);\n res.body.on(\"data\", chunk => {\n data = Buffer.concat([data, chunk]);\n hash.update(chunk);\n });\n res.body.on(\"end\", () => {\n const hashResult = hash.digest(\"hex\");\n cache2[attachment.url] = hashResult;\n hashToUrl[hashResult] = attachment.url;\n nextHash(hashResult, data);\n });\n }).catch(() => {});\n}\n\nlet flowerStarModule = BDModules.get(e => e.flowerStarContainer)[0];\nlet childModule = BDModules.get(e => e.childContainer)[0];\n/**\r\n * \r\n * @param {HTMLDivElement[]} elements \r\n * @param {{type: \"Theme\"|\"Plugin\", name: string, official?: boolean}|{suspect:true, type: \"Theme\"|\"Plugin\", name: string, harm: string}} result\r\n */\n\nfunction renderToElements(id, result, filename) {\n const div = document.getElementById(id);\n if (!div || div.childNodes.length > 0) return; // already certified/div does not exist anymore.\n // TODO: implements suspect plugins.\n\n if (!flowerStarModule) flowerStarModule = BDModules.get(e => e.flowerStarContainer)[0];\n if (!childModule) childModule = BDModules.get(e => e.childContainer)[0];\n console.log(result);\n\n if (result.suspect) {\n try {\n div.parentNode.style.borderColor = \"rgb(240, 71, 71)\";\n /**\r\n * \r\n * @param {HTMLElement} node \r\n */\n\n let nextNode = node => {\n for (let child of node.children) {\n if (child.tagName === \"A\") {\n child.addEventListener(\"click\", e => {\n e.preventDefault();\n e.stopImmediatePropagation();\n _utils__WEBPACK_IMPORTED_MODULE_5__[\"default\"].showConfirmationModal(\"Are you sure you want to download this ?\", \"The \" + result.type.toLowerCase() + \" **\" + filename + \"** might be dangerous **(\" + result.harm + \")**. \\n\\n**We don't recommand to download it**. However, you can still do it below.\", {\n confirmText: \"Download Anyway\",\n cancelText: \"Don't !\",\n danger: true,\n onCancel: () => {},\n onConfirm: () => {\n electron__WEBPACK_IMPORTED_MODULE_1__[\"remote\"].shell.openExternal(child.href);\n }\n });\n });\n } else if ([\"div\"].includes(child.tagName.toLowerCase())) {\n nextNode(child);\n }\n }\n };\n\n nextNode(div.parentNode);\n } catch (e) {\n console.error(e);\n }\n\n _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].reactDom.render(_v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(_ui_tooltipWrap__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n text: result.type + \" \" + result.name + \" is potentially dangerous.\"\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"div\", {\n className: flowerStarModule.flowerStarContainer,\n style: {\n width: \"16px\",\n height: \"16px\"\n }\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"svg\", {\n className: BDModules.get(e => e.svg)[0].svg,\n \"aria-hidden\": \"false\",\n width: \"16px\",\n height: \"16px\",\n viewBox: \"0 0 40 32\"\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"rect\", {\n x: \"0\",\n y: \"0\",\n width: \"32\",\n height: \"32\",\n mask: \"url(#svg-mask-avatar-status-round-32)\",\n fill: \"#f04747\",\n mask: \"url(#svg-mask-status-dnd)\",\n className: BDModules.get(e => e.pointerEvents)[0].pointerEvents\n })))), div);\n } else if (!result.official) {\n div.parentNode.style.borderColor = \"#4087ed\";\n _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].reactDom.render(_v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(_ui_tooltipWrap__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n text: result.type + \" \" + result.name + \" is certified by Lightcord.\"\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"div\", {\n className: flowerStarModule.flowerStarContainer,\n style: {\n width: \"16px\",\n height: \"16px\"\n }\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"svg\", {\n className: flowerStarModule.flowerStar,\n \"aria-hidden\": \"false\",\n width: \"16px\",\n height: \"16px\",\n viewBox: \"0 0 16 15.2\"\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"path\", {\n fill: \"#4f545c\",\n \"fill-rule\": \"evenodd\",\n d: \"m16 7.6c0 .79-1.28 1.38-1.52 2.09s.44 2 0 2.59-1.84.35-2.46.8-.79 1.84-1.54 2.09-1.67-.8-2.47-.8-1.75 1-2.47.8-.92-1.64-1.54-2.09-2-.18-2.46-.8.23-1.84 0-2.59-1.54-1.3-1.54-2.09 1.28-1.38 1.52-2.09-.44-2 0-2.59 1.85-.35 2.48-.8.78-1.84 1.53-2.12 1.67.83 2.47.83 1.75-1 2.47-.8.91 1.64 1.53 2.09 2 .18 2.46.8-.23 1.84 0 2.59 1.54 1.3 1.54 2.09z\"\n })), _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"div\", {\n className: childModule.childContainer\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"svg\", {\n \"aria-hidden\": \"false\",\n width: \"16px\",\n height: \"16px\",\n viewBox: \"0 0 16 15.2\"\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"path\", {\n fill: \"#ffffff\",\n d: \"M7.4,11.17,4,8.62,5,7.26l2,1.53L10.64,4l1.36,1Z\"\n }))))), div);\n } else {\n div.parentNode.style.borderColor = \"#4087ed\";\n _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].reactDom.render(_v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(_ui_tooltipWrap__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n text: result.type + \" \" + result.name + \" was made by the developers of Lightcord.\",\n style: \"brand\"\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"div\", {\n className: flowerStarModule.flowerStarContainer,\n style: {\n width: \"16px\",\n height: \"16px\"\n }\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"svg\", {\n className: flowerStarModule.flowerStar,\n \"aria-hidden\": \"false\",\n width: \"16px\",\n height: \"16px\",\n viewBox: \"0 0 16 15.2\",\n stroke: \"#36393f\",\n style: {\n color: \"#4087ed\"\n }\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"path\", {\n fill: \"currentColor\",\n \"fill-rule\": \"evenodd\",\n d: \"m16 7.6c0 .79-1.28 1.38-1.52 2.09s.44 2 0 2.59-1.84.35-2.46.8-.79 1.84-1.54 2.09-1.67-.8-2.47-.8-1.75 1-2.47.8-.92-1.64-1.54-2.09-2-.18-2.46-.8.23-1.84 0-2.59-1.54-1.3-1.54-2.09 1.28-1.38 1.52-2.09-.44-2 0-2.59 1.85-.35 2.48-.8.78-1.84 1.53-2.12 1.67.83 2.47.83 1.75-1 2.47-.8.91 1.64 1.53 2.09 2 .18 2.46.8-.23 1.84 0 2.59 1.54 1.3 1.54 2.09z\"\n })), _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"div\", {\n className: childModule.childContainer\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"svg\", {\n \"aria-hidden\": \"false\",\n width: \"16px\",\n height: \"16px\",\n viewBox: \"0 0 16 15.2\"\n }, _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react.createElement(\"path\", {\n fill: \"#ffffff\",\n d: \"M10.7,5.28a2.9,2.9,0,0,0-2.11.86.11.11,0,0,0,0,.16l1.05.94a.11.11,0,0,0,.15,0,1.27,1.27,0,0,1,.9-.33c.65,0,.65.73.65.73a.64.64,0,0,1-.65.65,1.73,1.73,0,0,1-1.18-.54c-.31-.26-.36-.32-.73-.66S7.06,5.28,5.65,5.28A2.26,2.26,0,0,0,3.37,7.56,2.59,2.59,0,0,0,3.82,9a2.18,2.18,0,0,0,1.83.89,2.94,2.94,0,0,0,2.1-.81.11.11,0,0,0,0-.16L6.74,8A.11.11,0,0,0,6.6,8a1.58,1.58,0,0,1-.94.29h0A.71.71,0,0,1,5,7.56H5a.63.63,0,0,1,.65-.64c.71,0,1.42.75,1.94,1.27.75.76,1.66,1.79,3.11,1.74A2.28,2.28,0,0,0,13,7.64a2.59,2.59,0,0,0-.45-1.47A2.14,2.14,0,0,0,10.7,5.28Z\"\n }))))), div);\n }\n}//# sourceURL=[module]\n//# sourceMapp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dCBldiA9IGdldE1lc3NhZ2VzTW9kdWxlLmdldE1lc3NhZ2VzKENoYW5uZWxNb2R1bGUuZ2V0Q2hhbm5lbElkKCkpXHJcbiAgICAgICAgICAgICAgICBwcm9jZXNzLm5leHRUaWNrKCgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBmb3IoY29uc3QgbWVzc2FnZSBvZiBldi5fYXJyYXkpe1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhdHRhY2htZW50cyA9IG1lc3NhZ2UuYXR0YWNobWVudHMgfHwgW11cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYoYXR0YWNobWVudHMubGVuZ3RoID09PSAwKWNvbnRpbnVlIC8vIG5vIGF0dGFjaG1lbnRzXHJcbiAgICAgICAgXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGF0dGFjaG1lbnRzLmZvckVhY2goYXR0YWNobWVudCA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzQXR0YWNobWVudChhdHRhY2htZW50KVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgIH0pXHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiByZXR1cm5WYWx1ZVxyXG4gICAgfVxyXG4gICAgICBjb25zdCBvcmlnaW5hbEZldGNoTWVzc2FnZXMyID0gZmV0Y2hNZXNzYWdlc01vZHVsZTIuZmV0Y2hNZXNzYWdlc1xyXG4gICAgZmV0Y2hNZXNzYWdlc01vZHVsZTIuZmV0Y2hNZXNzYWdlcyA9IGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgY29uc3QgcmV0dXJuVmFsdWUgPSBvcmlnaW5hbEZldGNoTWVzc2FnZXMyLmFwcGx5KHRoaXMsIGFyZ3VtZW50cylcclxuICAgICAgICBpZihyZXR1cm5WYWx1ZSBpbnN0YW5jZW9mIFByb21pc2Upe1xyXG4gICAgICAgICAgICByZXR1cm5WYWx1ZVxyXG4gICAgICAgICAgICAudGhlbigoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBldiA9IGdldE1lc3NhZ2VzTW9kdWxlLmdldE1lc3NhZ2VzKENoYW5uZWxNb2R1bGUuZ2V0Q2hhbm5lbElkKCkpXHJcbiAgICAgICAgICAgICAgICBwcm9jZXNzLm5leHRUaWNrKCgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBmb3IoY29uc3QgbWVzc2FnZSBvZiBldi5fYXJyYXkpe1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhdHRhY2htZW50cyA9IG1lc3NhZ2UuYXR0YWNobWVudHMgfHwgW11cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYoYXR0YWNobWVudHMubGVuZ3RoID09PSAwKWNvbnRpbnVlIC8vIG5vIGF0dGFjaG1lbnRzXHJcbiAgICAgICAgXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGF0dGFjaG1lbnRzLmZvckVhY2goYXR0YWNobWVudCA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzQXR0YWNobWVudChhdHRhY2htZW50KVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgIH0pXHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiByZXR1cm5WYWx1ZVxyXG4gICAgfVxyXG4gICAgICBjb25zdCBhbHJlYWR5VXNlZCA9IHt9XHJcbiAgICBjb25zdCBvcmlnaW5hbEdldFBpbm5lZE1lc3NhZ2VzID0gUGlubmVkTW9kdWxlLmdldFBpbm5lZE1lc3NhZ2VzLmJpbmQoUGlubmVkTW9kdWxlKVxyXG4gICAgUGlubmVkTW9kdWxlLmdldFBpbm5lZE1lc3NhZ2VzID0gZnVuY3Rpb24oKXtcclxuICAgICAgICBjb25zdCBwaW5uZWQgPSBvcmlnaW5hbEdldFBpbm5lZE1lc3NhZ2VzKC4uLmFyZ3VtZW50cylcclxuICAgICAgICBpZighcGlubmVkIHx8IGFscmVhZHlVc2VkW3Bpbm5lZC5pZF0pcmV0dXJuIHBpbm5lZFxyXG4gICAgICAgIGFscmVhZHlVc2VkW3Bpbm5lZC5pZF0gPSB0cnVlXHJcbiAgICAgICAgXHJcbiAgICAgICAgc2V0VGltZW91dCgoKSA9PiB7XHJcbiAgICAgICAgICAgIGRlbGV0ZSBhbHJlYWR5VXNlZFtwaW5uZWQuaWRdXHJcbiAgICAgICAgICAgIGZvcihjb25zdCBtZXNzYWdlIG9mIHBpbm5lZC5tZXNzYWdlcyl7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBhdHRhY2htZW50cyA9IG1lc3NhZ2UuYXR0YWNobWVudHMgfHwgW11cclxuICAgICAgICAgICAgICAgIGlmKGF0dGFjaG1lbnRzLmxlbmd0aCA9PT0gMCljb250aW51ZSAvLyBubyBhdHRhY2htZW50c1xyXG4gICAgICAgICAgICAgICAgICAgICAgYXR0YWNobWVudHMuZm9yRWFjaChhdHRhY2htZW50ID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBwcm9jZXNzQXR0YWNobWVudChhdHRhY2htZW50KVxyXG4gICAgICAgICAgICAgICAgfSlcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sIDUwKTtcclxuICAgICAgICAgIHJldHVybiBwaW5uZWRcclxuICAgIH1cclxuICAgICAgZGlzcGF0Y2hlci5zdWJzY3JpYmUoY29uc3RhbnRzLkFjdGlvblR5cGVzLk1FU1NBR0VfQ1JFQVRFLCAoZXYpID0+IHtcclxuICAgICAgICBjb25zdCBtZXNzYWdlID0gZXYubWVzc2FnZVxyXG4gICAgICAgIGlmKG1lc3NhZ2UuY2hhbm5lbF9pZCAhPT0gQ2hhbm5lbE1vZHVsZS5nZXRDaGFubmVsSWQoKSlyZXR1cm5cclxuICAgICAgICBwcm9jZXNzLm5leHRUaWNrKCgpID0+IHtcclxuICAgICAgICAgICAgY29uc3QgYXR0YWNobWVudHMgPSBtZXNzYWdlLmF0dGFjaG1lbnRzIHx8IFtdXHJcbiAgICAgICAgICAgIGlmKGF0dGFjaG1lbnRzLmxlbmd0aCA9PT0gMClyZXR1cm4gLy8gbm8gYXR0YWNobWVudHNcclxuICAgICAgICAgICAgICBhdHRhY2htZW50cy5mb3JFYWNoKGF0dGFjaG1lbnQgPT4ge1xyXG4gICAgICAgICAgICAgICAgcHJvY2Vzc0F0dGFjaG1lbnQoYXR0YWNobWVudClcclxuICAgICAgICAgICAgfSlcclxuICAgICAgICB9KVxyXG4gICAgfSlcclxuICAgICAgY29uc3QgbWVzc2FnZXMgPSBnZXRNZXNzYWdlc01vZHVsZS5nZXRNZXNzYWdlcyhDaGFubmVsTW9kdWxlLmdldENoYW5uZWxJZCgpKVxyXG4gICAgcHJvY2Vzcy5uZXh0VGljaygoKSA9PiB7XHJcbiAgICAgICAgZm9yKGNvbnN0IG1lc3NhZ2Ugb2YgbWVzc2FnZXMuX2FycmF5KXtcclxuICAgICAgICAgICAgY29uc3QgYXR0YWNobWVudHMgPSBtZXNzYWdlLmF0dGFjaG1lbnRzIHx8IFtdXHJcbiAgICAgICAgICAgIGlmKGF0dGFjaG1lbnRzLmxlbmd0aCA9PT0gMCljb250aW51ZSAvLyBubyBhdHRhY2htZW50c1xyXG4gICAgICAgICAgICAgIGF0dGFjaG1lbnRzLmZvckVhY2goYXR0YWNobWVudCA9PiB7XHJcbiAgICAgICAgICAgICAgICBwcm9jZXNzQXR0YWNobWVudChhdHRhY2htZW50KVxyXG4gICAgICAgICAgICB9KVxyXG4gICAgICAgIH1cclxuICAgIH0pKi9cbiAgfVxuXG59KCk7XG5cbmZ1bmN0aW9uIGNoZWNrVmlydXNlcyhoYXNoLCBkYXRhLCBpZCkge1xuICBkYXRhID0gZGF0YS50b1N0cmluZyhcInV0ZjhcIikuc3BsaXQoL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cm0gKyBcIikqKi4gXFxuXFxuKipXZSBkb24ndCByZWNvbW1hbmQgdG8gZG93bmxvYWQgaXQqKi4gSG93ZXZlciwgeW91IGNhbiBzdGlsbCBkbyBpdCBiZWxvdy5cIiwge1xuICAgICAgICAgICAgICAgIGNvbmZpcm1UZXh0OiBcIkRvd25sb2FkIEFueXdheVwiLFxuICAgICAgICAgICAgICAgIGNhbmNlbFRleHQ6IFwiRG9uJ3QgIVwiLFxuICAgICAgICAgICAgICAgIGRhbmdlcjogdHJ1ZSxcbiAgICAgICAgICAgICAgICBvbkNhbmNlbDogKCkgPT4ge30sXG4gICAgICAgICAgICAgICAgb25Db25maXJtOiAoKSA9PiB7XG4gICAgICAgICAgICAgICAgICBlbGVjdHJvbi5yZW1vdGUuc2hlbGwub3BlbkV4dGVybmFsKGNoaWxkLmhyZWYpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICB9IGVsc2UgaWYgKFtcImRpdlwiXS5pbmNsdWRlcyhjaGlsZC50YWdOYW1lLnRvTG93ZXJDYXNlKCkpKSB7XG4gICAgICAgICAgICBuZXh0Tm9kZShjaGlsZCk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9O1xuXG4gICAgICBuZXh0Tm9kZShkaXYucGFyZW50Tm9kZSk7XG4gICAgfSBjYXRjaCAoZSkge1xuICAgICAgY29uc29sZS5lcnJvcihlKTtcbiAgICB9XG5cbiAgICBCRFYyLnJlYWN0RG9tLnJlbmRlcihCRFYyLnJlYWN0LmNyZWF0ZUVsZW1lbnQodG9vbHRpcFdyYXAsIHtcbiAgICAgIHRleHQ6IHJlc3VsdC50eXBlICsgXCIgXCIgKyByZXN1bHQubmFtZSArIFwiIGlzIHBvdGVudGlhbGx5IGRhbmdlcm91cy5cIlxuICAgIH0sIEJEVjIucmVhY3QuY3JlYXRlRWxlbWVudChcImRpdlwiLCB7XG4gICAgICBjbGFzc05hbW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QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///./src/modules/pluginCertifier.js\n"); /***/ }), diff --git a/BetterDiscordApp/src/modules/pluginCertifier.js b/BetterDiscordApp/src/modules/pluginCertifier.js index eb86177..c60f0b2 100644 --- a/BetterDiscordApp/src/modules/pluginCertifier.js +++ b/BetterDiscordApp/src/modules/pluginCertifier.js @@ -150,7 +150,7 @@ function checkViruses(hash, data, id){ /** * @type {string} */ - const no_comments = data.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm, "").trim()// removing the META{} comment from plugins + const no_comments = data.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm, "").trim()// removing the META comment from plugins if((/var [\w\d_$]+=\["/gi).test(no_comments)){ isHarmful = "obfuscation/hidden code" } @@ -179,7 +179,7 @@ function checkViruses(hash, data, id){ harm: isHarmful } - console.log(`Found potentially dangerous virus: ${cache[hash].name}`) + console.log(`Found potentially dangerous ${cache[hash].type.toLowerCase()}: ${cache[hash].name}`) renderToElements(id, cache[hash], cache[hash].name) } @@ -201,6 +201,7 @@ function processAttachment(attachment, id){ if(res.status !== 200)return checkViruses(hash, data, id) const result = await res.json() + result.official = true cache[hash] = result renderToElements(id, result, attachment.filename) @@ -253,6 +254,8 @@ function renderToElements(id, result, filename){ if(!flowerStarModule)flowerStarModule = BDModules.get(e => e.flowerStarContainer)[0] if(!childModule)childModule = BDModules.get(e => e.childContainer)[0] + + console.log(result) if(result.suspect){ try{ div.parentNode.style.borderColor = "rgb(240, 71, 71)" diff --git a/modules/discord_desktop_core/core/app/BetterDiscord/index.js b/modules/discord_desktop_core/core/app/BetterDiscord/index.js index e237021..9677b04 100644 --- a/modules/discord_desktop_core/core/app/BetterDiscord/index.js +++ b/modules/discord_desktop_core/core/app/BetterDiscord/index.js @@ -258,7 +258,7 @@ async function privateInit(){ dispatcher.subscribe(constants.ActionTypes.CONNECTION_OPEN || "CONNECTION_OPEN", onConn) } - const BetterDiscord = window.BetterDiscord = window.mainCore = new(require("../../../../../BetterDiscordApp/js/main.min.jsbr").default)(BetterDiscordConfig) + const BetterDiscord = window.BetterDiscord = window.mainCore = new(require("../../../../../BetterDiscordApp/js/main.js").default)(BetterDiscordConfig) const Utils = window.Lightcord.BetterDiscord.Utils // security delete