Skip to content

Instantly share code, notes, and snippets.

@Jobians
Created July 1, 2025 07:30
Show Gist options
  • Save Jobians/c2dfd2cc19b26fa3dbd2d3500c45114e to your computer and use it in GitHub Desktop.
Save Jobians/c2dfd2cc19b26fa3dbd2d3500c45114e to your computer and use it in GitHub Desktop.
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);
}
})();
@Jobians
Copy link
Author

Jobians commented Jul 1, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment