Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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