Last active
March 8, 2022 15:42
-
-
Save TheIndra55/0489088590315b102e1b0813fa21b788 to your computer and use it in GitHub Desktop.
Discourse user-api-keys decryption
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { privateDecrypt, constants } from "crypto" | |
import fs from "fs" | |
import fetch from "node-fetch" | |
const input = `...` | |
// decrypt payload | |
const privateKey = fs.readFileSync("private.key") | |
const data = new Buffer.from(input, "base64") | |
const decrypted = privateDecrypt({ key: privateKey, padding: constants.RSA_PKCS1_PADDING }, data); | |
const payload = JSON.parse(decrypted) | |
console.log(payload) | |
// who is this? | |
fetch("https://forum.cfx.re/session/current.json", { headers: { "User-Api-Key": payload.key }}) | |
.then(x => x.json()) | |
.then(session => { | |
console.log(`It's ${session.current_user.username}!`) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment