Created
July 1, 2025 07:30
-
-
Save Jobians/c2dfd2cc19b26fa3dbd2d3500c45114e to your computer and use it in GitHub Desktop.
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
const crypto = require('crypto'); | |
const { | |
TextDecoder | |
} = require('util'); | |
// Static Key and IV (from client JS) | |
const base64IV = "Wzk3LCAxMDksIC0xMDAsIC05MCwgMTIyLCAtMTI0LCAxMSwgLTY5LCAtNDIsIDExNSwgLTU4LCAtNjcsIDQzLCAtNzUsIDMxLCA3NF0="; | |
const base64Key = "Wy0zLCAtMTEyLCAxNSwgLTEyNCwgLTcxLCAzMywgLTg0LCAxMDksIDU3LCAtMTI3LCAxMDcsIC00NiwgMTIyLCA0OCwgODIsIC0xMjYsIDQ3LCA3NiwgLTEyNywgNjUsIDc1LCAxMTMsIC0xMjEsIDg5LCAtNzEsIDUwLCAtODMsIDg2LCA5MiwgLTQ2LCA0OSwgNTZd"; | |
function parseKey(base64Str) { | |
const jsonStr = Buffer.from(base64Str, 'base64').toString('utf8'); | |
return Uint8Array.from(JSON.parse(jsonStr)); | |
} | |
// AES-GCM Decrypt | |
function decrypt(buffer, key, iv) { | |
const tag = buffer.slice(-16); // auth tag = last 16 bytes | |
const encrypted = buffer.slice(0, -16); // encrypted data | |
const decipher = crypto.createDecipheriv('aes-256-gcm', key, iv); | |
decipher.setAuthTag(tag); | |
const decrypted = Buffer.concat([ | |
decipher.update(encrypted), | |
decipher.final() | |
]); | |
const decoded = new TextDecoder().decode(decrypted); | |
return JSON.parse(decoded); | |
} | |
async function fetchAndDecrypt(url, token) { | |
const iv = parseKey(base64IV); | |
const key = parseKey(base64Key); | |
const res = await fetch(url, { | |
headers: { | |
'accept': '*/*', | |
'authorization': `Bearer ${token}`, | |
'referer': 'https://www.viewstats.com/', | |
} | |
}); | |
const contentType = res.headers.get("content-type") || ""; | |
if (contentType.includes("application/json")) { | |
return await res.json(); | |
} | |
const buffer = Buffer.from(await res.arrayBuffer()); | |
return decrypt(buffer, key, iv); | |
} | |
(async () => { | |
const token = '32ev9m0qggn227ng1rgpbv5j8qllas8uleujji3499g9had6oj7f0ltnvrgi00cq'; | |
const url = `https://api.viewstats.com/channels/%40mrbeast`; | |
try { | |
const result = await fetchAndDecrypt(url, token); | |
console.dir(result, { | |
depth: null | |
}); | |
} catch (err) { | |
console.error("❌ Decryption failed:", err.message); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to
https://youtu.be/TEwE3fol_As?si=YOfHmwYfouLb82cC