@profullstack/threatcrush 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/av-worker.js +318 -1
- package/dist/av-worker.js.map +1 -1
- package/dist/index.js +318 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -53624,6 +53624,34 @@ var RULES = [
|
|
|
53624
53624
|
return /(?:navigator\.clipboard\.writeText|document\.execCommand\(\s*["']copy)/.test(t) && /(?:powershell|mshta|cmd(?:\.exe)?\s*\/c|curl\s[^\n]{0,200}\|\s*(?:ba|z)?sh|osascript)/i.test(t) && /(?:Win(?:dows)?\s*(?:key\s*)?\+\s*R|Windows\s+key|Ctrl\s*\+\s*V|Cmd\s*\+\s*Space|verify\s+you\s+are\s+(?:a\s+)?human|I(?:'|')?m\s+not\s+a\s+robot)/i.test(t);
|
|
53625
53625
|
}
|
|
53626
53626
|
},
|
|
53627
|
+
{
|
|
53628
|
+
id: "CrushAV.Web.PhishKitExfil",
|
|
53629
|
+
name: "Phishing page that sends passwords to a chat bot",
|
|
53630
|
+
severity: "critical",
|
|
53631
|
+
impact: "malicious",
|
|
53632
|
+
description: "A login page that sends whatever you type, including your password, to a Telegram bot or a Discord webhook. Real sites never do this: it is how phishing kits deliver stolen credentials. Do not enter anything on this page.",
|
|
53633
|
+
test: (c) => {
|
|
53634
|
+
if (!(WEB_EXTS.has(c.ext) || c.ext === "js" || c.ext === "mjs" || c.ext === "php")) return false;
|
|
53635
|
+
const t = c.text;
|
|
53636
|
+
const exfil = /api\.telegram\.org\/bot[\w$`'"+{}.:-]{0,80}\/send(?:Message|Document)/i.test(t) || /discord(?:app)?\.com\/api\/webhooks\/\d{5,}\//i.test(t);
|
|
53637
|
+
if (!exfil) return false;
|
|
53638
|
+
return /<input\b[^>]*\btype\s*=\s*["']?password\b/i.test(t) || /(?:getElementById|querySelector|getElementsByName)\s*\(\s*["'`][#.]?[\w-]*(?:pass(?:word|wd|code)?|pwd|otp|pin)[\w-]*["'`]/i.test(t) || /\$_(?:POST|REQUEST)\s*\[\s*["'][\w-]*(?:pass(?:word|wd)?|pwd)[\w-]*["']\s*\]/i.test(t);
|
|
53639
|
+
}
|
|
53640
|
+
},
|
|
53641
|
+
{
|
|
53642
|
+
id: "CrushAV.Web.BrowserMiner",
|
|
53643
|
+
name: "Web page that mines cryptocurrency in your browser",
|
|
53644
|
+
severity: "high",
|
|
53645
|
+
impact: "malicious",
|
|
53646
|
+
description: "This page loads a cryptocurrency miner that runs in the visitor's browser and uses their CPU for someone else's profit, usually without asking. Close it.",
|
|
53647
|
+
test: (c) => {
|
|
53648
|
+
if (!(WEB_EXTS.has(c.ext) || c.ext === "js" || c.ext === "mjs")) return false;
|
|
53649
|
+
const t = c.text;
|
|
53650
|
+
const started = /\b(?:CoinHive|CoinImp|Client|CRLT|WMP|deepMiner|Minero)\.(?:Anonymous|User|Init)\s*\(\s*["'`][\w$]{8,}["'`][\s\S]{0,400}?\.start\s*\(/.test(t);
|
|
53651
|
+
const poolScript = /<script\b[^>]*\bsrc\s*=\s*["']?(?:https?:)?\/\/(?:[\w-]+\.)*(?:coinhive\.com|coin-hive\.com|authedmine\.com|crypto-loot\.(?:com|org)|cryptoloot\.pro|webminepool\.com|coinimp\.com|www\.hostingcloud\.racing|minero\.cc|jsecoin\.com|monerominer\.rocks|webmine\.cz)\//i.test(t);
|
|
53652
|
+
return started || poolScript;
|
|
53653
|
+
}
|
|
53654
|
+
},
|
|
53627
53655
|
{
|
|
53628
53656
|
id: "CrushAV.Web.HtmlSmuggling",
|
|
53629
53657
|
name: "Web page that builds a hidden download",
|
|
@@ -53643,8 +53671,62 @@ var RULES = [
|
|
|
53643
53671
|
impact: "suspicious",
|
|
53644
53672
|
description: 'This SVG "image" contains a script that redirects you or decodes hidden content. Phishing emails use SVG attachments like this to send you to fake login pages.',
|
|
53645
53673
|
test: (c) => c.ext === "svg" && /<script\b/i.test(c.text) && /(?:location(?:\.href)?\s*=|location\.replace\(|window\.open\(|atob\s*\()/.test(c.text)
|
|
53674
|
+
},
|
|
53675
|
+
{
|
|
53676
|
+
// Seen 2026-11-22: "futures-trader", a Go Gate.io futures CLI (UPX, saved
|
|
53677
|
+
// as .txt). `save-key` stores your API key locally AND, in a goroutine,
|
|
53678
|
+
// runs `INSERT INTO api_keys (key_val, secret_val, exchange_name)` on the
|
|
53679
|
+
// author's free public MySQL (mysql5.sqlpub.com) with the DSN in plain text.
|
|
53680
|
+
id: "CrushAV.Stealer.SecretsToHardcodedDatabase",
|
|
53681
|
+
name: "Sends your secrets to someone else's database",
|
|
53682
|
+
severity: "critical",
|
|
53683
|
+
impact: "malicious",
|
|
53684
|
+
description: `This program carries the login for a remote database baked into it and writes API keys, passwords, tokens or wallet seeds into it. That is how fake trading bots and "tools" steal keys: whatever you give it ends up in the author's database. Delete it, and revoke any key or password you entered into it.`,
|
|
53685
|
+
test: (c) => isStealerHost(c) && findRemoteDsn(allText(c)) !== null && SECRET_INSERT.test(allText(c))
|
|
53686
|
+
},
|
|
53687
|
+
{
|
|
53688
|
+
id: "CrushAV.Stealer.ExchangeKeyHarvester",
|
|
53689
|
+
name: "Crypto exchange tool that leaks your API key",
|
|
53690
|
+
severity: "critical",
|
|
53691
|
+
impact: "malicious",
|
|
53692
|
+
description: "A crypto-exchange trading tool that also contains the password for someone's remote database. A real trading tool only talks to the exchange; one that also logs in to a private database is copying your exchange API key and secret there. Delete it, revoke the key on the exchange now and check for withdrawals.",
|
|
53693
|
+
test: (c) => isStealerHost(c) && EXCHANGE_API.test(allText(c)) && findRemoteDsn(allText(c)) !== null
|
|
53694
|
+
},
|
|
53695
|
+
{
|
|
53696
|
+
id: "CrushAV.Suspicious.FreePublicDatabase",
|
|
53697
|
+
name: "Logs in to a free public database",
|
|
53698
|
+
severity: "medium",
|
|
53699
|
+
impact: "suspicious",
|
|
53700
|
+
description: "This program has the password for a database on a free, anonymous hosting service built in. Real software almost never does this; data thieves use these services as a drop box. If you did not write it, do not give it any keys or passwords.",
|
|
53701
|
+
test: (c) => {
|
|
53702
|
+
if (!isStealerHost(c)) return false;
|
|
53703
|
+
const dsn = findRemoteDsn(allText(c));
|
|
53704
|
+
return dsn !== null && FREE_DB_HOSTS.test(dsn.host);
|
|
53705
|
+
}
|
|
53646
53706
|
}
|
|
53647
53707
|
];
|
|
53708
|
+
var isStealerHost = (c) => EXECUTABLE_KINDS.has(c.kind) || isScript(c) && !NON_RUNNABLE_SOURCE_EXTS.has(c.ext);
|
|
53709
|
+
var EXCHANGE_API = /\b(?:api\.gateio\.ws|api\.gate\.io|(?:f|d)?api\.binance\.(?:com|us)|api\.bybit\.com|www\.okx\.com\/api|api\.mexc\.com|contract\.mexc\.com|api\.bitget\.com|api(?:-futures)?\.kucoin\.com|api\.kraken\.com|futures\.kraken\.com|api\.huobi\.pro|api\.htx\.com|api\.coinbase\.com|api\.exchange\.coinbase\.com|api\.bitfinex\.com|api\.hyperliquid\.xyz|api\.bingx\.com|open-api\.bingx\.com|api\.phemex\.com|api\.lbkex\.com|api\.bitmart\.com)\b/i;
|
|
53710
|
+
var SECRET_INSERT = /\b(?:INSERT|REPLACE)\s+INTO\s+[`"[]?(?:\w+[`"\]]?\.)?[`"[]?\w*(?:api_?keys?|secrets?|passw\w*|credentials?|wallets?|seeds?|mnemonics?|tokens?|cookies?|private_?keys?)\w*[`"\]]?\s*\(|\b(?:INSERT|REPLACE)\s+INTO\s+[`"[]?\w+[`"\]]?\s*\([^)]{0,200}\b\w*(?:secret|passw|private_?key|seed|mnemonic|api_?key|access_?token|cookie)\w*\b[^)]{0,200}\)/i;
|
|
53711
|
+
var FREE_DB_HOSTS = /(?:^|\.)(?:sqlpub\.com|db4free\.net|freesqldatabase\.com|freemysqlhosting\.net|remotemysql\.com|freedb\.tech|filess\.io)$/i;
|
|
53712
|
+
var PLACEHOLDER_SECRET = /^(?:pass(?:word|wd)?|pwd|secret|changeme|example|xxx+|\*+|<[^>]*>|\{[^}]*\}|\$\{?\w+\}?|%[sv]|your_?\w*|user(?:name)?|root|test)$/i;
|
|
53713
|
+
var LOCAL_HOST = /^(?:localhost|127\.\d+\.\d+\.\d+|0\.0\.0\.0|::1|host|hostname|db|database|mysql|postgres|redis|mongo|example\.(?:com|org|net)|[\w.-]*\.example\.(?:com|org|net)|[\w-]*\.local|[\w-]*\.internal|10\.\d+\.\d+\.\d+|192\.168\.\d+\.\d+|172\.(?:1[6-9]|2\d|3[01])\.\d+\.\d+)$/i;
|
|
53714
|
+
function findRemoteDsn(t) {
|
|
53715
|
+
const res = [
|
|
53716
|
+
/([\w.-]{1,64}):([^\s@:/'"`()]{4,128})@tcp\(([a-z0-9.-]+)(?::\d{2,5})?\)\/[\w-]{0,64}/gi,
|
|
53717
|
+
/(?:mysql|mariadb|postgres(?:ql)?|mongodb(?:\+srv)?|rediss?|mssql|sqlserver):\/\/([\w.%-]{1,64}):([^\s@/'"`]{4,128})@([a-z0-9.-]+)(?::\d{2,5})?(?:\/|\b)/gi,
|
|
53718
|
+
/([\w.-]{1,64}):([^\s@:/'"`()]{4,128})@([a-z0-9-]+(?:\.[a-z0-9-]+)*\.[a-z]{2,24}):(?:3306|3307|3308|3309|3310|3311|5432|5433|6379|27017|1433)\/[\w-]{1,64}/gi
|
|
53719
|
+
];
|
|
53720
|
+
for (const re of res) {
|
|
53721
|
+
for (const m of t.matchAll(re)) {
|
|
53722
|
+
const [, user, pass, host] = m;
|
|
53723
|
+
if (PLACEHOLDER_SECRET.test(pass)) continue;
|
|
53724
|
+
if (LOCAL_HOST.test(host) || !/\.[a-z]{2,24}$|^\d+\.\d+\.\d+\.\d+$/i.test(host)) continue;
|
|
53725
|
+
return { user, host: host.toLowerCase() };
|
|
53726
|
+
}
|
|
53727
|
+
}
|
|
53728
|
+
return null;
|
|
53729
|
+
}
|
|
53648
53730
|
function buildContext(name, bytes, kind, size) {
|
|
53649
53731
|
let text = "";
|
|
53650
53732
|
const NodeBuffer = globalThis.Buffer;
|
|
@@ -53688,6 +53770,219 @@ function runRules(ctx, rules = RULES) {
|
|
|
53688
53770
|
return out;
|
|
53689
53771
|
}
|
|
53690
53772
|
|
|
53773
|
+
// ../../packages/av/src/upx.ts
|
|
53774
|
+
var UPX_MAX_OUTPUT = 64 * 1024 * 1024;
|
|
53775
|
+
var MAGIC = [85, 80, 88, 33];
|
|
53776
|
+
function methodName(id) {
|
|
53777
|
+
if (id === 2 || id === 3 || id === 4) return "nrv2b";
|
|
53778
|
+
if (id === 5 || id === 6 || id === 7) return "nrv2d";
|
|
53779
|
+
if (id === 8 || id === 9 || id === 10) return "nrv2e";
|
|
53780
|
+
if (id === 14) return "lzma";
|
|
53781
|
+
return "unknown";
|
|
53782
|
+
}
|
|
53783
|
+
var le32 = (b, o) => (b[o] | b[o + 1] << 8 | b[o + 2] << 16 | b[o + 3] << 24) >>> 0;
|
|
53784
|
+
function findUpxHeader(b) {
|
|
53785
|
+
const windows = [
|
|
53786
|
+
[0, Math.min(b.length, 8192)],
|
|
53787
|
+
[Math.max(0, b.length - 8192), b.length]
|
|
53788
|
+
];
|
|
53789
|
+
for (const [from, to] of windows) {
|
|
53790
|
+
for (let i = from; i + 32 <= to; i++) {
|
|
53791
|
+
if (b[i] !== MAGIC[0] || b[i + 1] !== MAGIC[1] || b[i + 2] !== MAGIC[2] || b[i + 3] !== MAGIC[3]) continue;
|
|
53792
|
+
const version = b[i + 4];
|
|
53793
|
+
const format2 = b[i + 5];
|
|
53794
|
+
const methodId = b[i + 6];
|
|
53795
|
+
const level = b[i + 7];
|
|
53796
|
+
if (version < 10 || version > 20 || level > 10 || format2 === 0) continue;
|
|
53797
|
+
const uLen = le32(b, i + 16);
|
|
53798
|
+
const cLen = le32(b, i + 20);
|
|
53799
|
+
if (cLen === 0 || uLen === 0 || cLen >= uLen || uLen > 2147483647) continue;
|
|
53800
|
+
return { headerOffset: i, version, format: format2, method: methodName(methodId), methodId, level, uLen, cLen };
|
|
53801
|
+
}
|
|
53802
|
+
}
|
|
53803
|
+
return null;
|
|
53804
|
+
}
|
|
53805
|
+
var Bits = class {
|
|
53806
|
+
constructor(src, pos) {
|
|
53807
|
+
this.src = src;
|
|
53808
|
+
this.pos = pos;
|
|
53809
|
+
}
|
|
53810
|
+
src;
|
|
53811
|
+
pos;
|
|
53812
|
+
bb = 0;
|
|
53813
|
+
bc = 0;
|
|
53814
|
+
bit() {
|
|
53815
|
+
if (this.bc > 0) return this.bb >>> --this.bc & 1;
|
|
53816
|
+
if (this.pos + 4 > this.src.length) throw new RangeError("upx: input overrun");
|
|
53817
|
+
this.bb = le32(this.src, this.pos);
|
|
53818
|
+
this.pos += 4;
|
|
53819
|
+
this.bc = 31;
|
|
53820
|
+
return this.bb >>> 31 & 1;
|
|
53821
|
+
}
|
|
53822
|
+
byte() {
|
|
53823
|
+
if (this.pos >= this.src.length) throw new RangeError("upx: input overrun");
|
|
53824
|
+
return this.src[this.pos++];
|
|
53825
|
+
}
|
|
53826
|
+
};
|
|
53827
|
+
function nrvDecompress(method, src, start, maxOut) {
|
|
53828
|
+
const out = new Uint8Array(Math.min(maxOut, UPX_MAX_OUTPUT));
|
|
53829
|
+
const r = new Bits(src, start);
|
|
53830
|
+
let o = 0;
|
|
53831
|
+
let lastOff = 1;
|
|
53832
|
+
for (; ; ) {
|
|
53833
|
+
while (r.bit()) {
|
|
53834
|
+
if (o >= out.length) return out;
|
|
53835
|
+
out[o++] = r.byte();
|
|
53836
|
+
}
|
|
53837
|
+
let off = 1;
|
|
53838
|
+
let len;
|
|
53839
|
+
if (method === "nrv2b") {
|
|
53840
|
+
do {
|
|
53841
|
+
off = off * 2 + r.bit();
|
|
53842
|
+
if (off > 16777218) throw new RangeError("upx: bad offset");
|
|
53843
|
+
} while (!r.bit());
|
|
53844
|
+
if (off === 2) off = lastOff;
|
|
53845
|
+
else {
|
|
53846
|
+
off = (off - 3) * 256 + r.byte() >>> 0;
|
|
53847
|
+
if (off === 4294967295) break;
|
|
53848
|
+
lastOff = ++off;
|
|
53849
|
+
}
|
|
53850
|
+
len = r.bit();
|
|
53851
|
+
len = len * 2 + r.bit();
|
|
53852
|
+
if (len === 0) {
|
|
53853
|
+
len = 1;
|
|
53854
|
+
do {
|
|
53855
|
+
len = len * 2 + r.bit();
|
|
53856
|
+
if (len > out.length) throw new RangeError("upx: bad length");
|
|
53857
|
+
} while (!r.bit());
|
|
53858
|
+
len += 2;
|
|
53859
|
+
}
|
|
53860
|
+
len += off > 3328 ? 1 : 0;
|
|
53861
|
+
} else {
|
|
53862
|
+
for (; ; ) {
|
|
53863
|
+
off = off * 2 + r.bit();
|
|
53864
|
+
if (r.bit()) break;
|
|
53865
|
+
off = (off - 1) * 2 + r.bit();
|
|
53866
|
+
if (off > 16777218) throw new RangeError("upx: bad offset");
|
|
53867
|
+
}
|
|
53868
|
+
if (off === 2) {
|
|
53869
|
+
off = lastOff;
|
|
53870
|
+
len = r.bit();
|
|
53871
|
+
} else {
|
|
53872
|
+
off = (off - 3) * 256 + r.byte() >>> 0;
|
|
53873
|
+
if (off === 4294967295) break;
|
|
53874
|
+
len = (off ^ 4294967295) & 1;
|
|
53875
|
+
off >>>= 1;
|
|
53876
|
+
lastOff = ++off;
|
|
53877
|
+
}
|
|
53878
|
+
if (method === "nrv2d") {
|
|
53879
|
+
len = len * 2 + r.bit();
|
|
53880
|
+
if (len === 0) {
|
|
53881
|
+
len = 1;
|
|
53882
|
+
do {
|
|
53883
|
+
len = len * 2 + r.bit();
|
|
53884
|
+
if (len > out.length) throw new RangeError("upx: bad length");
|
|
53885
|
+
} while (!r.bit());
|
|
53886
|
+
len += 2;
|
|
53887
|
+
}
|
|
53888
|
+
} else if (len) {
|
|
53889
|
+
len = 1 + r.bit();
|
|
53890
|
+
} else if (r.bit()) {
|
|
53891
|
+
len = 3 + r.bit();
|
|
53892
|
+
} else {
|
|
53893
|
+
len = 1;
|
|
53894
|
+
do {
|
|
53895
|
+
len = len * 2 + r.bit();
|
|
53896
|
+
if (len > out.length) throw new RangeError("upx: bad length");
|
|
53897
|
+
} while (!r.bit());
|
|
53898
|
+
len += 3;
|
|
53899
|
+
}
|
|
53900
|
+
len += off > 1280 ? 1 : 0;
|
|
53901
|
+
}
|
|
53902
|
+
if (off > o) throw new RangeError("upx: back-reference before start");
|
|
53903
|
+
const n = len + 1;
|
|
53904
|
+
for (let k = 0; k < n; k++) {
|
|
53905
|
+
if (o >= out.length) return out;
|
|
53906
|
+
out[o] = out[o - off];
|
|
53907
|
+
o++;
|
|
53908
|
+
}
|
|
53909
|
+
}
|
|
53910
|
+
return out.subarray(0, o);
|
|
53911
|
+
}
|
|
53912
|
+
function candidateStarts(b, info2) {
|
|
53913
|
+
const starts2 = [info2.headerOffset + 32];
|
|
53914
|
+
if (b[0] === 77 && b[1] === 90 && b.length > 64) {
|
|
53915
|
+
const pe = le32(b, 60);
|
|
53916
|
+
if (pe + 24 < b.length && le32(b, pe) === 17744) {
|
|
53917
|
+
const nSec = b[pe + 6] | b[pe + 7] << 8;
|
|
53918
|
+
const optSize = b[pe + 20] | b[pe + 21] << 8;
|
|
53919
|
+
const sec = pe + 24 + optSize;
|
|
53920
|
+
for (let s = 0; s < nSec && s < 16; s++) {
|
|
53921
|
+
const e = sec + s * 40;
|
|
53922
|
+
if (e + 40 > b.length) break;
|
|
53923
|
+
const rawSize = le32(b, e + 16);
|
|
53924
|
+
const rawPtr = le32(b, e + 20);
|
|
53925
|
+
if (rawSize >= info2.cLen && rawPtr < b.length) starts2.push(rawPtr);
|
|
53926
|
+
}
|
|
53927
|
+
}
|
|
53928
|
+
}
|
|
53929
|
+
for (let i = 0; i + 12 <= b.length; i += 4) {
|
|
53930
|
+
if (le32(b, i) === info2.uLen && le32(b, i + 4) === info2.cLen && b[i + 8] === info2.methodId) starts2.push(i + 12);
|
|
53931
|
+
}
|
|
53932
|
+
return starts2;
|
|
53933
|
+
}
|
|
53934
|
+
function upxUnpack(b) {
|
|
53935
|
+
const info2 = findUpxHeader(b);
|
|
53936
|
+
if (!info2) return null;
|
|
53937
|
+
if (info2.method !== "nrv2b" && info2.method !== "nrv2d" && info2.method !== "nrv2e") return { info: info2, bytes: null };
|
|
53938
|
+
if (info2.uLen > UPX_MAX_OUTPUT) return { info: info2, bytes: null };
|
|
53939
|
+
for (const start of candidateStarts(b, info2)) {
|
|
53940
|
+
try {
|
|
53941
|
+
const out = nrvDecompress(info2.method, b, start, info2.uLen);
|
|
53942
|
+
if (out.length === info2.uLen) return { info: info2, bytes: out };
|
|
53943
|
+
} catch {
|
|
53944
|
+
}
|
|
53945
|
+
}
|
|
53946
|
+
const blocks = decodeBlockChain(b, info2);
|
|
53947
|
+
return { info: info2, bytes: blocks };
|
|
53948
|
+
}
|
|
53949
|
+
function decodeBlockChain(b, info2) {
|
|
53950
|
+
const method = info2.method;
|
|
53951
|
+
const parts = [];
|
|
53952
|
+
let total = 0;
|
|
53953
|
+
for (let i = 0; i + 12 <= b.length; ) {
|
|
53954
|
+
const unc = le32(b, i);
|
|
53955
|
+
const cpr = le32(b, i + 4);
|
|
53956
|
+
if (parts.length && cpr === unc && unc > 0 && unc <= info2.uLen && i + 12 + cpr <= b.length && total + unc <= UPX_MAX_OUTPUT) {
|
|
53957
|
+
parts.push(b.subarray(i + 12, i + 12 + cpr));
|
|
53958
|
+
total += unc;
|
|
53959
|
+
i += 12 + cpr;
|
|
53960
|
+
continue;
|
|
53961
|
+
}
|
|
53962
|
+
if (b[i + 8] === info2.methodId && b[i + 11] === 0 && cpr > 0 && cpr < unc && unc <= info2.uLen && i + 12 + cpr <= b.length && total + unc <= UPX_MAX_OUTPUT) {
|
|
53963
|
+
try {
|
|
53964
|
+
const out = nrvDecompress(method, b, i + 12, unc);
|
|
53965
|
+
if (out.length === unc) {
|
|
53966
|
+
parts.push(out);
|
|
53967
|
+
total += unc;
|
|
53968
|
+
i += 12 + cpr;
|
|
53969
|
+
continue;
|
|
53970
|
+
}
|
|
53971
|
+
} catch {
|
|
53972
|
+
}
|
|
53973
|
+
}
|
|
53974
|
+
i++;
|
|
53975
|
+
}
|
|
53976
|
+
if (!total) return null;
|
|
53977
|
+
const all = new Uint8Array(total);
|
|
53978
|
+
let o = 0;
|
|
53979
|
+
for (const p of parts) {
|
|
53980
|
+
all.set(p, o);
|
|
53981
|
+
o += p.length;
|
|
53982
|
+
}
|
|
53983
|
+
return all;
|
|
53984
|
+
}
|
|
53985
|
+
|
|
53691
53986
|
// ../../packages/av/src/engine.ts
|
|
53692
53987
|
var DEFAULT_HEURISTIC_BYTES = 16 * 1024 * 1024;
|
|
53693
53988
|
var SignatureSet = class {
|
|
@@ -53751,11 +54046,33 @@ async function scanBytes(input, opts = {}) {
|
|
|
53751
54046
|
description: known.startsWith("EICAR") ? "The harmless standard antivirus test file. Seeing this means the scanner works." : `This exact file is known malware (${known}). Quarantine or delete it.`
|
|
53752
54047
|
});
|
|
53753
54048
|
}
|
|
54049
|
+
const rules = opts.rules ?? RULES;
|
|
53754
54050
|
const ctx = buildContext(input.name, input.bytes, kind, size);
|
|
53755
|
-
for (const d of runRules(ctx,
|
|
54051
|
+
for (const d of runRules(ctx, rules)) {
|
|
53756
54052
|
if (known && d.id === "CrushAV.Test.EICAR") continue;
|
|
53757
54053
|
detections.push(d);
|
|
53758
54054
|
}
|
|
54055
|
+
if (EXECUTABLE_KINDS.has(kind)) {
|
|
54056
|
+
const upx = upxUnpack(input.bytes);
|
|
54057
|
+
if (upx) {
|
|
54058
|
+
detections.push({
|
|
54059
|
+
engine: "heuristic",
|
|
54060
|
+
id: "CrushAV.Packer.UPX",
|
|
54061
|
+
name: "Compressed with UPX",
|
|
54062
|
+
severity: "info",
|
|
54063
|
+
impact: "info",
|
|
54064
|
+
description: upx.bytes ? `This program is compressed with UPX (${upx.info.method}). Some legitimate tools are; malware uses it to hide its contents. CrushAV unpacked it and scanned the inside too.` : `This program is compressed with UPX (${upx.info.method}) and CrushAV could not unpack it, so its contents were not inspected. Treat it with care if you do not know where it came from.`
|
|
54065
|
+
});
|
|
54066
|
+
if (upx.bytes) {
|
|
54067
|
+
const seen = new Set(detections.map((d) => d.id));
|
|
54068
|
+
const inner = buildContext(input.name, upx.bytes, kind, upx.bytes.length);
|
|
54069
|
+
for (const d of runRules(inner, rules)) {
|
|
54070
|
+
if (seen.has(d.id)) continue;
|
|
54071
|
+
detections.push({ ...d, description: `${d.description} (Found inside the UPX-packed program.)` });
|
|
54072
|
+
}
|
|
54073
|
+
}
|
|
54074
|
+
}
|
|
54075
|
+
}
|
|
53759
54076
|
return {
|
|
53760
54077
|
path: input.name,
|
|
53761
54078
|
size,
|