Skip to content

Instantly share code, notes, and snippets.

@samdenty
Created March 4, 2018 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samdenty/450f87af61a8d8fb697610cce273656c to your computer and use it in GitHub Desktop.
Save samdenty/450f87af61a8d8fb697610cce273656c to your computer and use it in GitHub Desktop.
PoC discord realtime message decryption engine
(() => {
let styles = `
.un-decryptable,
.encrypted-msg {
background-color: rgba(255, 141, 0, 0.29);
padding: 5px;
border-radius: 5px;
}
.un-decryptable::before,
.encrypted-msg::before {
content: "Decrypted message: ";
display: block;
font-weight: bold;
padding-bottom: 10px;
margin-bottom: 10px;
border-bottom: 1px solid rgba(255, 255, 255, 0.39);
}
.un-decryptable {
background-color: rgba(255, 0, 0, 0.29)
}
.un-decryptable::before {
content: "Failed to decrypt message!";
}
`
let css = document.createElement('style')
css.innerHTML = styles
document.head.appendChild(css)
})();
function decrypt() {
let prefix = `[ENCRYPTED]`
let messages = document.getElementsByClassName('markup')
for (let i = 0; i < messages.length; i++) {
let message = messages[i].innerHTML
if (messages[i].classList.contains('un-decryptable')) return
if (message && message.startsWith(prefix)) {
let decrypted = message.replace(prefix, '')
try {
decrypted = atob(decrypted)
messages[i].classList.add('encrypted-msg')
messages[i].innerHTML = (
decrypted
.replace(/&/g, '&amp;')
.replace(/>/g, '&gt;')
.replace(/</g, '&lt;')
.replace(/"/g, '&quot;')
)
} catch(e) {
messages[i].classList.add('un-decryptable')
return
}
}
}
}
clearInterval(window.discordCrypt)
window.discordCrypt = setInterval(decrypt, 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment