Benign Download

36febbaaee18944359bad74a574204089838cc3642ab410d6a237da2fd4ccc2c

For loop contains a try blockNode fs writeSync or writeFileSync call
SHA-25636febbaaee18944359bad74a574204089838cc3642ab410d6a237da2fd4ccc2c

Evidence

Imports Node net as a namespace lines 1–27
⋯7 lines
8 *
9 * 用法:
10 * ELECTRON_RUN_AS_NODE=1 QQPet.exe bridge.cjs 正常启动
11 * ELECTRON_RUN_AS_NODE=1 QQPet.exe bridge.cjs --doctor 自检
12 */
13"use strict";
14const net = require("node:net");
15const dgram = require("node:dgram");
16const tls = require("node:tls");
17const fs = require("node:fs");
18const path = require("node:path");
19const crypto = require("node:crypto");
20
21const HERE = __dirname;
22const CONF = path.join(HERE, "config.json");
23const PID = path.join(HERE, "bridge.pid");
24const LOG = path.join(HERE, "bridge.log");
25const UDP_PORT = 47777;
26const DEFAULT_BROKER = "broker.emqx.io";
27const DEFAULT …
JavaScript empty catch block lines 30–57
30:15… EOUT = 24000; // 远端多久没消息算掉线
31const DOCTOR = process.argv.includes("--doctor");
32
33/* ---------------- 日志 ---------------- */
34function log(...a) {
35 const line = new Date().toISOString().slice(11, 19) + " " + a.join(" ");
36 if (!DOCTOR) { try { fs.appendFileSync(LOG, line + "\r\n"); } catch {} }
37 console.log(line);
38}
39function trimLog() {
40 try { if (fs.statSync(LOG).size > 512 * 1024) fs.writeFileSync(LOG, ""); } catch {}
41}
42
43/* ---------------- 配置 ---------------- */
44function conf() {
45 try { return JSON.parse(fs.readFileSync(CONF, "utf8")); } catch { return {}; }
46}
47const cfg = conf();
48const ROOM = String(cfg.room || "").trim();
49const BROKER = String(cfg.broker || DEFAULT_BROKER);
50const PORT = Number(cfg.port || DEFAULT_PORT);
51const USERDATA = path.join(process.env.APPDATA || path.join(process.env.USERPROFILE || ".", "AppData", "Roaming"), "QQPet");
52
53/* ---------------- 身份 ---------------- */
⋯4 lines
Object literal declares host or user lines 60–76
60:31…
61 const f = path.join(HERE, "self-id.txt");
62 let v = "";
63 try { v = fs.readFileSync(f, "utf8").trim(); } catch {}
64 if (!v) { v = crypto.randomUUID(); try { fs.writeFileSync(f, v); } catch {} }
65 return v;
66 })();
67 return {
68 id: (idf && idf.id) || fallbackId,
69 name: p.name || "宠物",
70 host: p.host || "",
71 sex: p.sex || "MM",
72 level: Number(c.level || 1)
⋯4 lines
Calls a digest() method lines 77–81
77:45… �,���不可推导������是单向哈希���
78const TOPIC_HASH = crypto.createHash("sha256").update("qqpet-topic:" + ROOM).digest("hex");
79const TOPIC_BASE = "qqpet/v2/" + TOPIC_HASH.slice(0, 16);
80const T_PRESENCE = TOPIC_BASE + "/p";
81const ownTopic = (id) => TOPIC_BASE + "/d/" + i …
IV and authentication-tag concatenation lines 83–101
83:53… t-key:" + ROOM).digest();
84
85function seal(obj) {
86 const iv = crypto.randomBytes(12);
87 const c = crypto.createCipheriv("aes-256-gcm", KEY, iv);
88 const ct = Buffer.concat([c.update(Buffer.from(JSON.stringify(obj), "utf8")), c.final()]);
89 // iv(12) + authTag(16) + 密文,整体 base64,前缀 v2 便于版本区分
90 return "v2." + Buffer.concat([iv, c.getAuthTag(), ct]).toString("base64");
91}
92function unseal(b64) {
93 try {
94 const s = String(b64);
95 if (!s.startsWith("v2.")) return null; // 旧版混淆包直接忽略
96 const raw = Buffer.from(s.slice(3), "base64");
97 if (raw.length < 29) return null;
98 const d = crypto.createDecipheriv("aes-256-gcm", KEY, raw.subarray(0, 12));
99 d.setAuthTag(raw.subarray(12, 28)); // 被篡改会在这里抛错
100 const out = Buffer.concat([d.update(raw.subarray(28)), d.final()]);
101 return JS …

No evidence locations were recorded for this file. Raw result

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.