├── extension
├── .gitkeep
├── logo16.png
├── logo48.png
├── logo128.png
├── manifest.json
├── background.js
└── SimpleDiscordCryptLoader.js
├── key.png
├── logo.png
├── blacklist.txt
├── images
└── key128.png
├── SimpleDiscordCrypt.meta.js
├── SimpleDiscordCryptExtension.crx
├── PrivacyPolicy.md
├── SimpleDiscordCryptLoader.plugin.js
├── emojihash.html
├── LICENSE
├── SimpleDiscordCryptInstaller.ps1
└── README.md
/extension/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/key.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/An00nymushun/End-to-end-Discord-Encryption/HEAD/key.png
--------------------------------------------------------------------------------
/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/An00nymushun/End-to-end-Discord-Encryption/HEAD/logo.png
--------------------------------------------------------------------------------
/blacklist.txt:
--------------------------------------------------------------------------------
1 | 430057166368407584 owner request
2 | 703223547039842324 owner's request (nighthouse)
3 |
--------------------------------------------------------------------------------
/images/key128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/An00nymushun/End-to-end-Discord-Encryption/HEAD/images/key128.png
--------------------------------------------------------------------------------
/extension/logo16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/An00nymushun/End-to-end-Discord-Encryption/HEAD/extension/logo16.png
--------------------------------------------------------------------------------
/extension/logo48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/An00nymushun/End-to-end-Discord-Encryption/HEAD/extension/logo48.png
--------------------------------------------------------------------------------
/extension/logo128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/An00nymushun/End-to-end-Discord-Encryption/HEAD/extension/logo128.png
--------------------------------------------------------------------------------
/SimpleDiscordCrypt.meta.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name SimpleDiscordCrypt
3 | // @version 1.7.5.0
4 | // ==/UserScript==
5 |
--------------------------------------------------------------------------------
/SimpleDiscordCryptExtension.crx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/An00nymushun/End-to-end-Discord-Encryption/HEAD/SimpleDiscordCryptExtension.crx
--------------------------------------------------------------------------------
/extension/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "manifest_version": 2,
3 | "name": "SimpleDiscordCrypt",
4 | "version": "5",
5 | "description": "Discord message encryption plugin, it gives end-to-end clientside encryption for your messages and files with automatic key exchange",
6 | "icons": {
7 | "16": "logo16.png",
8 | "48": "logo48.png",
9 | "128": "logo128.png"
10 | },
11 | "permissions": [
12 | "storage",
13 | "webRequest",
14 | "webRequestBlocking",
15 | "https://gitlab.com/",
16 | "https://cdn.discordapp.com/",
17 | "https://discord.com/",
18 | "https://ptb.discord.com/",
19 | "https://canary.discord.com/"
20 | ],
21 | "background": {
22 | "scripts": ["background.js"],
23 | "persistent": true
24 | },
25 | "content_scripts": [ {
26 | "js": ["SimpleDiscordCryptLoader.js"],
27 | "matches": [
28 | "https://*.discord.com/channels/*",
29 | "https://*.discord.com/activity",
30 | "https://*.discord.com/login*",
31 | "https://*.discord.com/app",
32 | "https://*.discord.com/library",
33 | "https://*.discord.com/store",
34 | "https://*.discord.com/guild-discovery"
35 | ],
36 | "run_at": "document_start"
37 | } ]
38 | }
39 |
--------------------------------------------------------------------------------
/extension/background.js:
--------------------------------------------------------------------------------
1 | const onHeadersReceived = (details) => {
2 | let header = details.responseHeaders.find(x => x.name.toLowerCase() === 'content-security-policy');
3 | if(header != null) {
4 | header.value = "";
5 | return { responseHeaders: details.responseHeaders };
6 | }
7 | };
8 |
9 | const filter = {
10 | urls: ["https://discord.com/*","https://ptb.discord.com/*","https://canary.discord.com/*"],
11 | types: ["main_frame"]
12 | };
13 |
14 | chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, filter, ["blocking", "responseHeaders"]);
15 |
16 | chrome.runtime.onMessage.addListener((data, sender, sendResponse) => {
17 | if(data.type !== 'XMLHttpRequest') return;
18 |
19 | let request = data.request;
20 |
21 | let xhr = new XMLHttpRequest();
22 | if(request.responseType) xhr.responseType = request.responseType;
23 |
24 | xhr.onload = () => { sendResponse((xhr.responseType === 'arraybuffer') ? { bloburl: URL.createObjectURL(new Blob([xhr.response])) } : { response: xhr.response }) };
25 | xhr.onerror = () => { sendResponse(null) };
26 |
27 | xhr.open(request.method || 'GET', request.url);
28 | xhr.withCredentials = true;
29 | xhr.send();
30 |
31 | return true;
32 | });
--------------------------------------------------------------------------------
/extension/SimpleDiscordCryptLoader.js:
--------------------------------------------------------------------------------
1 | let script = document.createElement('script');
2 | script.textContent = `window.localStorageBackup = window.localStorage; Object.freeze = o => o;`;
3 | (document.head||document.documentElement).appendChild(script);
4 | script.remove();
5 |
6 |
7 | const makeRequest = (data, responseCallback) => {
8 | try {
9 | chrome.runtime.sendMessage(data, (result) => {
10 | if(result.bloburl !== undefined) {
11 | fetch(result.bloburl).then((response) => response.arrayBuffer()).then((response) => {
12 | responseCallback({ response });
13 | URL.revokeObjectURL(result.bloburl);
14 | });
15 | }
16 | else responseCallback(result);
17 | });
18 | } catch { location.reload() } //extension unloaded/reloaded
19 | };
20 |
21 | window.addEventListener('message', (event) => {
22 | if(event.source !== window && event.data.type !== 'XMLHttpRequest' || event.ports[0] == null) return;
23 |
24 | makeRequest(event.data, (result) => { event.ports[0].postMessage(result) });
25 | });
26 |
27 | chrome.runtime.sendMessage({ type: 'XMLHttpRequest', request: { url: "https://gitlab.com/An0/SimpleDiscordCrypt/raw/master/SimpleDiscordCrypt.user.js" } }, (result) => { //or chrome.runtime.getURL("SimpleDiscordCrypt.user.js")
28 | let script = document.createElement('script');
29 | script.textContent = `
30 | (()=>{
31 | const GM_xmlhttpRequest = (requestObject) => {
32 | let onload = requestObject.onload;
33 | let onerror = requestObject.onerror;
34 | delete requestObject.onload;
35 | delete requestObject.onerror;
36 | let channel = new MessageChannel();
37 | channel.port1.onmessage = (event) => {
38 | let response = event.data;
39 | if(response == null) {
40 | if(onerror) onerror();
41 | }
42 | else onload(event.data);
43 | }
44 | window.postMessage({ type: 'XMLHttpRequest', request: requestObject }, "*", [channel.port2]);
45 | };
46 | const localStorage = window.localStorageBackup;
47 | const CspDisarmed = true;
48 | ${result.response}})()`;
49 | (document.head||document.documentElement).appendChild(script);
50 | script.remove();
51 | });
--------------------------------------------------------------------------------
/PrivacyPolicy.md:
--------------------------------------------------------------------------------
1 |
Privacy Policy
2 |
3 |
4 | Effective date: May 30, 2019
5 |
6 |
7 | SDC ("us", "we", or "our") operates the SimpleDiscordCrypt browser extension (the "Service").
8 |
9 |
10 | Information Collection And Use
11 |
12 | We do not collect information about you.
13 |
14 | Types of Data Collected
15 |
16 | Nothing.
17 |
18 | While using our Service, we may ask you to provide us with certain personally identifiable information that can be used to contact or identify you ("Personal Data").
19 |
20 | Encryption keys which are not personal data and are generated by the Service and shared with other Service users.
21 |
22 |
23 | Use of Data
24 |
25 | SDC may use the collected data to provide customer care and support
Transfer Of Data
28 | SDC will take all steps reasonably necessary to ensure that your data is treated securely and in accordance with this Privacy Policy and no transfer of your Personal Data will take place to an organization or a country.
29 |
30 |
31 | Security Of Data
32 | The security of your data is important to us, but remember that no method of transmission over the Internet, or method of electronic storage is 100% secure. While we strive to use commercially acceptable means to protect your Personal Data, we cannot guarantee its absolute security.
33 |
34 | Service Providers
35 | We may employ third party companies and individuals to facilitate our Service ("Service Providers"), to provide the Service on our behalf, to perform Service-related services or to assist us in analyzing how our Service is used.
36 |
37 |
38 | Links To Other Sites
39 | Our Service may contain links to other sites that are not operated by us. If you click on a third party link, you will be directed to that third party's site. We strongly advise you to review the Privacy Policy of every site you visit.
40 | We have no control over and assume no responsibility for the content, privacy policies or practices of any third party sites or services.
41 |
42 |
43 | Children's Privacy
44 | Our Service does not address anyone under the age of 18 ("Children").
45 | We do not knowingly collect personally identifiable information from anyone under the age of 18.
46 |
47 |
48 | Changes To This Privacy Policy
49 | We may update our Privacy Policy from time to time. We will notify you of any changes by posting the new Privacy Policy on this page.
50 | You are advised to review this Privacy Policy periodically for any changes. Changes to this Privacy Policy are effective when they are posted on this page.
51 |
52 |
53 | Contact Us
54 | If you have any questions about this Privacy Policy, please contact us: https://gitlab.com/An0/SimpleDiscordCrypt/issues
--------------------------------------------------------------------------------
/SimpleDiscordCryptLoader.plugin.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @name SimpleDiscordCryptLoader
3 | * @version 1.2
4 | * @description Loads SimpleDiscordCrypt
5 | * @author An0
6 | * @source https://gitlab.com/An0/SimpleDiscordCrypt
7 | */
8 |
9 | /*@cc_on
10 | @if (@_jscript)
11 | var shell = WScript.CreateObject("WScript.Shell");
12 | var fs = new ActiveXObject("Scripting.FileSystemObject");
13 | var pathPlugins = shell.ExpandEnvironmentStrings("%APPDATA%\\BetterDiscord\\plugins");
14 | var pathSelf = WScript.ScriptFullName;
15 | shell.Popup("It looks like you've mistakenly tried to run me directly. \\n(Don't do that!)", 0, "I'm a plugin for BetterDiscord", 0x30);
16 | if (fs.GetParentFolderName(pathSelf) === fs.GetAbsolutePathName(pathPlugins)) {
17 | shell.Popup("I'm in the correct folder already.", 0, "I'm already installed", 0x40);
18 | } else if (!fs.FolderExists(pathPlugins)) {
19 | shell.Popup("I can't find the BetterDiscord plugins folder.\\nAre you sure it's even installed?", 0, "Can't install myself", 0x10);
20 | } else if (shell.Popup("Should I copy myself to BetterDiscord's plugins folder for you?", 0, "Do you need some help?", 0x34) === 6) {
21 | fs.CopyFile(pathSelf, fs.BuildPath(pathPlugins, fs.GetFileName(pathSelf)), true);
22 | // Show the user where to put plugins in the future
23 | shell.Exec("explorer " + pathPlugins);
24 | shell.Popup("I'm installed!", 0, "Successfully installed", 0x40);
25 | }
26 | WScript.Quit();
27 | @else @*/
28 |
29 |
30 | var SimpleDiscordCryptLoader = (() => {
31 |
32 | 'use strict';
33 |
34 | let localStorage;
35 | let iframe;
36 | const CspDisarmed = true;
37 | let Initialized = false;
38 | let Loaded = false;
39 |
40 | var InitPromise;
41 |
42 | function Start() {
43 | if(!Initialized) {
44 | iframe = document.createElement('iframe');
45 | iframe.style.display = 'none';
46 |
47 | iframe.onload = () => {
48 | iframe.contentDocument.body.innerHTML = "";
49 | localStorage = Object.getOwnPropertyDescriptor(iframe.contentDocument.body.children[0].__proto__, 'contentWindow').get.apply(iframe).localStorage;
50 |
51 | require('https').get("https://gitlab.com/An0/SimpleDiscordCrypt/raw/master/SimpleDiscordCrypt.user.js", (response) => {
52 | let data = [];
53 | response.on('data', (chunk) => data.push(chunk));
54 | response.on('end', () => eval(typeof data[0] === 'string' ? data.join("") : Buffer.concat(data).toString()));
55 | });
56 | };
57 | document.body.appendChild(iframe);
58 |
59 | Initialized = true;
60 | }
61 | else if(!Loaded && InitPromise) {
62 | InitPromise.then(({Load}) => {
63 | Load();
64 | Loaded = true;
65 | });
66 | }
67 | }
68 |
69 | function Stop() {
70 | if(!Initialized) return;
71 |
72 | if(Loaded && InitPromise) {
73 | InitPromise.then(({Unload}) => {
74 | Unload();
75 | Loaded = false;
76 | });
77 | }
78 | }
79 |
80 | return function() { return {
81 | start: Start,
82 | stop: Stop
83 | }};
84 |
85 | })();
86 |
87 | module.exports = SimpleDiscordCryptLoader;
88 |
89 | /*@end @*/
90 |
--------------------------------------------------------------------------------
/emojihash.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
--------------------------------------------------------------------------------
/SimpleDiscordCryptInstaller.ps1:
--------------------------------------------------------------------------------
1 | $ErrorActionPreference = 'Stop'
2 |
3 |
4 | $startMenuPath = [Environment]::GetFolderPath('StartMenu')+'\Programs\Discord Inc\'
5 | $desktopPath = [Environment]::GetFolderPath('Desktop')+'\'
6 | $taskbarPath = $env:APPDATA+'\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\'
7 | $discordPath = $env:LOCALAPPDATA+'\Discord'
8 | $discordDataPath = $env:APPDATA+'\discord'
9 | $discordResourcesPath = $discordPath+'\app-*'
10 | $discordIconPath = $startMenuPath+'Discord.lnk'
11 | $discordDesktopIconPath = $desktopPath+'Discord.lnk'
12 | $discordTaskbarIconPath = $taskbarPath+'Discord.lnk'
13 | $discordExeName = 'Discord.exe'
14 | $discordPtbPath = $env:LOCALAPPDATA+'\DiscordPTB'
15 | $discordPtbDataPath = $env:APPDATA+'\discordptb'
16 | $discordPtbResourcesPath = $discordPtbPath+'\app-*'
17 | $discordPtbIconPath = $startMenuPath+'Discord PTB.lnk'
18 | $discordPtbDesktopIconPath = $desktopPath+'Discord PTB.lnk'
19 | $discordPtbTaskbarIconPath = $taskbarPath+'Discord PTB.lnk'
20 | $discordPtbExeName = 'DiscordPTB.exe'
21 | $discordCanaryPath = $env:LOCALAPPDATA+'\DiscordCanary'
22 | $discordCanaryDataPath = $env:APPDATA+'\discordcanary'
23 | $discordCanaryResourcesPath = $discordCanaryPath+'\app-*'
24 | $discordCanaryIconPath = $startMenuPath+'Discord Canary.lnk'
25 | $discordCanaryDesktopIconPath = $desktopPath+'Discord Canary.lnk'
26 | $discordCanaryTaskbarIconPath = $taskbarPath+'Discord Canary.lnk'
27 | $discordCanaryExeName = 'DiscordCanary.exe'
28 | $iconLocation = '\app.ico,0'
29 | $pluginPath = $env:LOCALAPPDATA+'\SimpleDiscordCrypt'
30 | $startupRegistry = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run'
31 |
32 |
33 | $shell = New-Object -ComObject WScript.Shell
34 | function RootElectron([string]$discordIconPath, [string]$exeName, [string]$path, [string]$resourcesPath, [string]$desktopIconPath, [string]$taskbarIconPath) {
35 | 'rooting'
36 | $shortcut = $shell.CreateShortcut($discordIconPath)
37 | $workingDirectory = $shortcut.WorkingDirectory
38 | if($workingDirectory -eq "") {
39 | $shortcut.WorkingDirectory = $workingDirectory = (Resolve-Path $resourcesPath | % { $_.Path } | Measure -Maximum).Maximum
40 | $shortcut.IconLocation = $path + $iconLocation
41 | }
42 |
43 | $electronLink = "$workingDirectory\electron.exe"
44 | if(!(Test-Path $electronLink)) {
45 | [void](New-Item -Path $electronLink -Value "$workingDirectory\$exeName" -ItemType HardLink)
46 | }
47 |
48 | $shortcut.TargetPath = $env:WINDIR+'\System32\cmd.exe'
49 | $shortcut.Arguments = "/c `"set NODE_OPTIONS=-r ../../SimpleDiscordCrypt/NodeLoad.js && start ^`"^`" ^`"$path\Update.exe^`" --processStart electron.exe`""
50 | $shortcut.WindowStyle = 7
51 | $shortcut.Save()
52 |
53 | if(Test-Path $desktopIconPath) {
54 | copy $discordIconPath $desktopIconPath -Force
55 | }
56 | if(Test-Path $taskbarIconPath) {
57 | copy $discordIconPath $taskbarIconPath -Force
58 | }
59 | }
60 |
61 | function RemoveExtension([string]$electonDataPath) {
62 | $extensionListPath = "$electonDataPath\DevTools Extensions"
63 | if(Test-Path $extensionListPath) {
64 | [string]$s = Get-Content $extensionListPath
65 | if($s.Length -ne 0) {
66 | $extensionList = ConvertFrom-Json $s
67 | $newExtensionList = @($extensionList | ? { $_ -notmatch '(?:^|[\\\/])SimpleDiscordcrypt[\\\/]?$' })
68 | if($newExtensionList.Length -ne $extensionList.Length) {
69 | 'removing old extension'
70 | Set-Content $extensionListPath (ConvertTo-Json $newExtensionList)
71 | }
72 | }
73 | }
74 | }
75 |
76 | function ReplaceStartup([string]$registryKey, [string]$newPath) {
77 | if((Get-ItemProperty -Path $startupRegistry -Name $registryKey -ErrorAction SilentlyContinue).$registryKey -ne $null) {
78 | 'replacing startup'
79 | Set-ItemProperty -Path $startupRegistry -Name $registryKey -Value $newPath
80 | }
81 | }
82 |
83 |
84 | $install = $false
85 |
86 | try {
87 |
88 | while(Test-Path $discordPath) {
89 | 'Discord found'
90 | if(Test-Path $discordDataPath) { 'data directory found' } else { 'data directory not found'; break }
91 | if(Test-Path $discordResourcesPath) { 'resources directory found' } else { 'resources directory not found'; break }
92 |
93 | RemoveExtension $discordDataPath
94 |
95 | RootElectron $discordIconPath $discordExeName $discordPath $discordResourcesPath $discordDesktopIconPath $discordTaskbarIconPath
96 |
97 | ReplaceStartup 'Discord' $discordIconPath
98 |
99 | $install = $true
100 | break
101 | }
102 |
103 | while(Test-Path $discordPtbPath) {
104 | 'DiscordPTB found'
105 | if(Test-Path $discordPtbDataPath) { 'data directory found' } else { 'data directory not found'; break }
106 | if(Test-Path $discordPtbResourcesPath) { 'resources directory found' } else { 'resources directory not found'; break }
107 |
108 | RemoveExtension $discordPtbDataPath
109 |
110 | RootElectron $discordPtbIconPath $discordPtbExeName $discordPtbPath $discordPtbResourcesPath $discordPtbDesktopIconPath $discordPtbTaskbarIconPath
111 |
112 | ReplaceStartup 'DiscordPTB' $discordPtbIconPath
113 |
114 | $install = $true
115 | break
116 | }
117 |
118 | while(Test-Path $discordCanaryPath) {
119 | 'DiscordCanary found'
120 | if(Test-Path $discordCanaryDataPath) { 'data directory found' } else { 'data directory not found'; break }
121 | if(Test-Path $discordCanaryResourcesPath) { 'resources directory found' } else { 'resources directory not found'; break }
122 |
123 | RemoveExtension $discordCanaryDataPath
124 |
125 | RootElectron $discordCanaryIconPath $discordCanaryExeName $discordCanaryPath $discordCanaryResourcesPath $discordCanaryDesktopIconPath $discordCanaryTaskbarIconPath
126 |
127 | ReplaceStartup 'DiscordCanary' $discordCanaryIconPath
128 |
129 | $install = $true
130 | break
131 | }
132 |
133 |
134 | if($install) {
135 | 'installing'
136 |
137 | [void](New-Item "$pluginPath\NodeLoad.js" -Type File -Force -Value @'
138 | const onHeadersReceived = (details, callback) => {
139 | let response = { cancel: false };
140 | let responseHeaders = details.responseHeaders;
141 | if(responseHeaders['content-security-policy'] != null) {
142 | responseHeaders['content-security-policy'] = [""];
143 | response.responseHeaders = responseHeaders;
144 | }
145 | callback(response);
146 | };
147 |
148 | let originalBrowserWindow;
149 | function browserWindowHook(options) {
150 | if(options?.webPreferences?.preload != null && options.title?.startsWith("Discord")) {
151 | let webPreferences = options.webPreferences;
152 | let originalPreload = webPreferences.preload;
153 | webPreferences.preload = `${__dirname}/SimpleDiscordCryptLoader.js`;
154 | webPreferences.additionalArguments = [...(webPreferences.additionalArguments || []), `--sdc-preload=${originalPreload}`];
155 | }
156 | return new originalBrowserWindow(options);
157 | }
158 | browserWindowHook.ISHOOK = true;
159 |
160 |
161 | let originalElectronBinding;
162 | function electronBindingHook(name) {
163 | let result = originalElectronBinding.apply(this, arguments);
164 |
165 | if(name === 'electron_browser_window' && !result.BrowserWindow.ISHOOK) {
166 | originalBrowserWindow = result.BrowserWindow;
167 | Object.assign(browserWindowHook, originalBrowserWindow);
168 | browserWindowHook.prototype = originalBrowserWindow.prototype;
169 | result.BrowserWindow = browserWindowHook;
170 | const electron = require('electron');
171 | electron.app.whenReady().then(() => { electron.session.defaultSession.webRequest.onHeadersReceived(onHeadersReceived) });
172 | }
173 |
174 | return result;
175 | }
176 | electronBindingHook.ISHOOK = true;
177 |
178 | originalElectronBinding = process._linkedBinding;
179 | if(originalElectronBinding.ISHOOK) return;
180 | Object.assign(electronBindingHook, originalElectronBinding);
181 | electronBindingHook.prototype = originalElectronBinding.prototype;
182 | process._linkedBinding = electronBindingHook;
183 | '@)
184 |
185 | [void](New-Item "$pluginPath\SimpleDiscordCryptLoader.js" -Type File -Force -Value @'
186 | let requireGrab = require;
187 | if(requireGrab != null) {
188 | const require = requireGrab;
189 |
190 | if(window.chrome?.storage) delete chrome.storage;
191 |
192 | const localStorage = window.localStorage;
193 | const CspDisarmed = true;
194 |
195 | const electron = require('electron');
196 |
197 | require('https').get("https://gitlab.com/An0/SimpleDiscordCrypt/-/raw/master/SimpleDiscordCrypt.user.js", (response) => {
198 | response.setEncoding('utf8');
199 | let code = "";
200 | response.on('data', (chunk) => code += chunk);
201 | response.on('end', () => {
202 | const unsafeWindow = electron.webFrame.top.context;
203 | eval(code);
204 | });
205 | });
206 |
207 | const commandLineSwitches = process._linkedBinding('electron_common_command_line');
208 | let originalPreloadScript = commandLineSwitches.getSwitchValue('sdc-preload');
209 |
210 | if(originalPreloadScript != null) {
211 | commandLineSwitches.appendSwitch('preload', originalPreloadScript);
212 | require(originalPreloadScript);
213 | }
214 | }
215 | else console.error("Uh-oh, looks like something is blocking require");
216 | '@)
217 |
218 | 'FINISHED'
219 |
220 | $needsWait = $false
221 | $discordProcesses = Get-Process 'Discord' -ErrorAction SilentlyContinue
222 | $discordProcesses | % { $needsWait = $_.CloseMainWindow() -or $needsWait }
223 |
224 | $discordPtbProcesses = Get-Process 'DiscordPTB' -ErrorAction SilentlyContinue
225 | $discordPtbProcesses | % { $needsWait = $_.CloseMainWindow() -or $needsWait }
226 |
227 | $discordCanaryProcesses = Get-Process 'DiscordCanary' -ErrorAction SilentlyContinue
228 | $discordCanaryProcesses | % { $needsWait = $_.CloseMainWindow() -or $needsWait }
229 |
230 | if($needsWait) { sleep 1 }
231 |
232 | $processes = ($discordProcesses + $discordPtbProcesses + $discordCanaryProcesses)
233 | if($processes.Length -ne 0) {
234 | $processes | Stop-Process
235 | if($discordProcesses.Length -ne 0) { [void](start $discordIconPath) }
236 | if($discordPtbProcesses.Length -ne 0) { [void](start $discordPtbIconPath) }
237 | if($discordCanaryProcesses.Length -ne 0) { [void](start $discordCanaryIconPath) }
238 | }
239 | }
240 | else { 'Discord not found' }
241 |
242 | }
243 | catch { $_ }
244 | finally { [Console]::ReadLine() }
245 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | SimpleDiscordCrypt
4 |
5 |
6 | Discord message encryption plugin, it gives end-to-end client side encryption for your messages and files with automatic key exchange, works without BetterDiscord
7 |
8 | For `Chrome` (and similar) use the [extension](https://chrome.google.com/webstore/detail/simplediscordcrypt/hbplgmpfdabobhnadbfpknppljdfkiia)
9 | For `mobile` you should try Yandex Browser, it's Chromium based and supports extensions
10 | [`Firefox` is kind of supported](https://addons.mozilla.org/en-US/firefox/addon/simplediscordcrypt/) but there is incompatibility because of https://bugzilla.mozilla.org/show_bug.cgi?id=1048931
11 | If nothing works, install it as a [userscript](https://gitlab.com/An0/SimpleDiscordCrypt/raw/master/SimpleDiscordCrypt.user.js) (with [Tampermonkey](https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo)) or include the js file somehow else
12 |
13 | Please do not download this plugin from untrusted sources, for example there is one in chrome store with the same name
14 |
15 |
16 | **Right click on the lock icon** to open the menu
17 |
18 | If you would like to `download an encrypted image`, **middle click on the image**
19 |
20 | You can **toggle the encryption** with the `lock icon`. You can also use the `:ENC:`, `ENC` or `NOENC` prefix at the start of your message, but prefixes are deprecated since Discord starts uploads before you even send your message.
21 |
22 | If you want to **change** from one installation to another, `export and import` your database
23 | If you would like to use the plugin on **multiple devices**; choose a main one, export the database from that and click on `secondary` when **importing to others**, after new key exchanges you'll have to repeat these steps
24 |
25 | `ECDH P-521` is used for the key exchange and `AES256-CBC` for the messages offering the equivalent security of 256-bits
26 |
27 | I hope this is actually simple as the name suggests
28 |
29 |
30 | Here is a link to the original [DiscordCrypt](https://gitlab.com/leogx9r/DiscordCrypt)
31 | It has been discontinued
32 |
33 |
34 |
35 |
36 | If you have any questions come to my [Discord server](https://discord.gg/rSUyXeCHBE)
37 | If you want a server blacklisted or you would like users to not use embeds, do tell
38 | We have experimental BetterDiscord loaders for the plugin too.
39 |
40 | List of servers that use the plugin:
41 |
42 | Feel free to tell me if you have one
43 |
44 |
45 |
46 |
47 | # Database
48 | The `database password` is optional but the database isn't! **The database stores stuff like your keys and channel settings.**
49 | You should only have one database as having multiple will mess things up. In order to manage this, you should **keep backups** by `exporting` your database.
50 | If you are using **multiple devices** with the same account, **select one as the main** and **import** its database as `secondary` to the other(s).
51 | If you import the database as secondary you can still export it and import it normally again. The difference is that a client with the secondary setting will ignore key exchanges, which means you have to update your secondary devices with the new database.
52 | ##### Cleaning the database You can paste these into the `Ctrl+Shift+I` console
53 | SdcClearChannels(filterFunc)
54 |
55 | ```js
56 | deleteBefore = (now = new Date()).setMonth(now.getMonth() - 6);
57 | SdcClearChannels((channel) => (
58 | //Number(channel.lastseen) ms precision unix timestamp
59 | //String(channel.descriptor) descriptor from the channel manager
60 | //Boolean(channel.encrypted) is the encryption toggled on
61 |
62 | channel.lastseen < deleteBefore && //not seen in 6 months
63 | /^DM with \d{17,20}$/.test(channel.descriptor) //name resolution failed
64 |
65 | //'true' return value deletes the record
66 | ));
67 | ```
68 |
69 | SdcClearKeys(filterFunc)
70 |
71 | ```js
72 | deleteBefore = (now = new Date()).setMonth(now.getMonth() - 6);
73 | SdcClearKeys((key) => (
74 | //Number(key.lastseen) ms precision unix timestamp
75 | //String(key.descriptor) descriptor from the key manager
76 | //Boolean(key.hidden) is the key hidden
77 | //String(key.type) one of ['GROUP', 'CONVERSATION'/*DM*/, 'PERSONAL']
78 | //Number(key.registered) when the key was added to the database
79 |
80 | key.lastseen < deleteBefore && //not seen in 6 months
81 | /^(?:DM key with \d{17,20}|\d{17,20}'s personal key)$/.test(key.descriptor)
82 | //name resolution failed if the id is used as name
83 |
84 | //'true' return value deletes the record
85 | ));
86 | ```
87 |
88 |
89 | # Keys
90 | The things you use to **encrypt messages** (plus there is the `database key` for encrypting the plugin's local database)
91 | You can `select` which key to use for the channel at the top, besides the lock icon.
92 | ### Key Types
93 | **Personal key:** Everyone has this (and it's different for everyone), you can use it to encrypt messages in channels **where there are no other options**.
94 | It is shared with everyone you key-exchange with, so the security of it varies.
95 | **Group key:** You can `make` these from the plugin's menu if you are in a guild channel.
96 | It is advised that you **change the name** of the key right away to spot if someone accidentally generated a different key for your channel. You can do this in the `Key Manager`.
97 | After **generating the group key**, you can use it in other channels too.
98 | If you set a group key as `hidden` in the `Key Manager` it will **no longer show up in your key selector** and it **won't be automatically shared** with your friends.
99 | If you really want to know if the other is using the same key as you, compare the first few characters (up to 16) of the encrypted message.
100 | **DM key:** These keys are generated by a Diffie-Hellman key exchange **between two users**, it provides a `secure connection over unsafe medium`.
101 | # Key Exchanges
102 | If the plugin comes across a message with a key that you don't have it will **attempt to get that key by a key exchange** with the message's sender.
103 | You need to be able to `DM` the other user for the key exchange.
104 | If a group key **isn't** set as `hidden` it will **automatically** be shared with a **friend** if they ask for it.
105 | In order to share a key you need to establish a secure connection with an `initial key exchange`, it is usually **automatic** but you can start it manually from the menu by clicking on `Start Key Exchange` from the DM channel.
106 | You can manually share keys by using the `Share Keys` menu option.
107 | During a `key share`, the sharing party will **suggest you channels** to use so it's advised to **not** set anything for the channel (or toggle encryption) **before you have the key** for it.
108 | # Key Rotation and Trusted Keys
109 | Use the `SdcSetKeyRotation(7)` **console command** to **start a key rotation** on the key of the current channel. This will **periodically generate** a new key and switch to it in all the channels that use the `rotated key`.
110 | In the example above, it's every 7 days (by default this is aligned to arbitrary points so if you use the same command on your other primary devices within a day, it will do the same).
111 | If the key is set to `hidden`, the new key will be hidden too.
112 | `Trusted Keys` can be enabled in the `Key Visualizer` (in DM), this feature can be used to do **automatic key exchange** for `hidden keys` and/or `rotated keys`.
113 | Keys shared with `trusted keys` can swap keys for channels automatically, which is **useful for rotated keys**.
114 | # Extras
115 | You can click on an already enlarged **image** to **further enlarge** it, you can also `drag` the enlarged image if it doesn't fit the screen.
116 | Use the `arrow keys` to **navigate** like a gallery when zoomed in.
117 | You can use **any emote** (animated too) in `encrypted messages`.
118 | Messages above 1600 characters will be compressed, but this feature might have incompatibilities with future versions. This also means that the messages can be 2000 character long if they are mostly made of normal characters.
119 | For `large audio and video files`, you can use **Mega**, it automatically **embeds**.
120 | The **encryption** is completely secure unless someone at Discord replaces your messages right when you secure your DMs, to **make sure** you have the right keys, you can use the `Key Visualizer` and **compare** your result with the other party.
121 |
122 | Getting notifications on custom phrases
123 | This feature should be a good compensation for no searches and role mentions
124 | Use the SdcSetPingOn(regexStr) console command to set the match string or regex for the extra pings
125 | For example SdcSetPingOn('An0') will only ping if the message contains that exact word, SdcSetPingOn(/\bAn[0o]\b/i) will match every form of it
126 | Regex explanation: /An0/ is the same as the first example, /An[0o]/ will match An0 and Ano, /An[0o]/i will be case insensitive, so it matches ano and ANO and everything inbetween, \b means word border, which means start or end of word, so /\bano\b/ won't mach 'another' (only works if you use letters, numbers or '_')
127 | /(?:An0|SimpleDiscordCrypt|SDC)/ will match any of the three smaller regexes between the (?:)
128 | Please note that characters like .\\+?*()[]$^ etc, should be escaped like \.
129 | Sample regex for role mentions: /<@&(?:473998238156849152|474006463749160992)>/ you can get the role ids with \@Role in the chat
130 |
131 |
132 |
133 |
134 | To uninstall, just delete it from %localappdata% and make new shortcuts.
135 |
136 |
137 |
138 | 𝘚𝘪𝘮𝘱𝘭𝘦𝘋𝘪𝘴𝘤𝘰𝘳𝘥𝘊𝘳𝘺𝘱𝘵
139 | Or according to google: simple discord crypt
140 |
--------------------------------------------------------------------------------