diff --git a/package-lock.json b/package-lock.json index 3b4cf4d..b1b0acc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,10 +9,9 @@ "version": "2.0.5", "license": "MIT", "dependencies": { - "flast": "^2.1.1", - "isolated-vm": "^5.0.2", - "jsdom": "^25.0.1", - "obfuscation-detector": "^2.0.4" + "flast": "2.2.1", + "isolated-vm": "^5.0.3", + "obfuscation-detector": "^2.0.5" }, "bin": { "restringer": "bin/deobfuscate.js" @@ -449,9 +448,9 @@ } }, "node_modules/@eslint/js": { - "version": "9.16.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.16.0.tgz", - "integrity": "sha512-tw2HxzQkrbeuvyj1tG2Yqq+0H9wGoI2IMk4EOsQeX+vmd75FtJAzf+gTA69WF+baUKRYQ3x2kbLE08js5OsTVg==", + "version": "9.17.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.17.0.tgz", + "integrity": "sha512-Sxc4hqcs1kTu0iID3kcZDW3JHq2a77HO9P8CP6YEA/FpH3Ll8UXE2r/86Rz9YJLKme39S9vU5OWNjC6Xl0Cr3w==", "dev": true, "license": "MIT", "engines": { @@ -557,9 +556,9 @@ } }, "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", - "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.8.tgz", + "integrity": "sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==", "dev": true, "license": "MIT", "peer": true, @@ -659,15 +658,6 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, - "node_modules/agent-base": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz", - "integrity": "sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==", - "license": "MIT", - "engines": { - "node": ">= 14" - } - }, "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -708,12 +698,6 @@ "dev": true, "license": "Python-2.0" }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "license": "MIT" - }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -764,9 +748,9 @@ } }, "node_modules/browserslist": { - "version": "4.24.2", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.2.tgz", - "integrity": "sha512-ZIc+Q62revdMcqC6aChtW4jz3My3klmCO1fEmINZY/8J3EpBg5/A/D0AKmBveUh6pgoeycoMkVMko84tuYS+Gg==", + "version": "4.24.3", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.3.tgz", + "integrity": "sha512-1CPmv8iobE2fyRMV97dAcMVegvvWKxmq94hkLiAkUGwKVTyDLw33K+ZxiFrREKmmps4rIw6grcCFCnTMSZ/YiA==", "dev": true, "funding": [ { @@ -785,9 +769,9 @@ "license": "MIT", "peer": true, "dependencies": { - "caniuse-lite": "^1.0.30001669", - "electron-to-chromium": "^1.5.41", - "node-releases": "^2.0.18", + "caniuse-lite": "^1.0.30001688", + "electron-to-chromium": "^1.5.73", + "node-releases": "^2.0.19", "update-browserslist-db": "^1.1.1" }, "bin": { @@ -832,9 +816,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001687", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001687.tgz", - "integrity": "sha512-0S/FDhf4ZiqrTUiQ39dKeUjYRjkv7lOZU1Dgif2rIqrTzX/1wV2hfKu9TOm1IHkdSijfLswxTFzl/cvir+SLSQ==", + "version": "1.0.30001690", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001690.tgz", + "integrity": "sha512-5ExiE3qQN6oF8Clf8ifIDcMRCRE/dMGcETG/XGMD8/XiXm6HXQgQTh1yZYLXXpSOsEUlJm1Xr7kGULZTuGtP/w==", "dev": true, "funding": [ { @@ -896,18 +880,6 @@ "dev": true, "license": "MIT" }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "license": "MIT", - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -938,35 +910,11 @@ "node": ">= 8" } }, - "node_modules/cssstyle": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-4.1.0.tgz", - "integrity": "sha512-h66W1URKpBS5YMI/V8PyXvTMFT8SupJ1IzoIV8IeBC/ji8WVmrO8dGlTi+2dh6whmdk6BiKJLD/ZBkhWbcg6nA==", - "license": "MIT", - "dependencies": { - "rrweb-cssom": "^0.7.1" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/data-urls": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-5.0.0.tgz", - "integrity": "sha512-ZYP5VBHshaDAiVZxjbRVcFJpc+4xGgT0bK3vzy1HLN8jTO975HEbuYzZJcHoQEY5K1a0z8YayJkyVETa08eNTg==", - "license": "MIT", - "dependencies": { - "whatwg-mimetype": "^4.0.0", - "whatwg-url": "^14.0.0" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/debug": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", + "dev": true, "license": "MIT", "dependencies": { "ms": "^2.1.3" @@ -980,12 +928,6 @@ } } }, - "node_modules/decimal.js": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz", - "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==", - "license": "MIT" - }, "node_modules/decompress-response": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", @@ -1016,15 +958,6 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "license": "MIT" }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "license": "MIT", - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/detect-libc": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz", @@ -1035,9 +968,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.71", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.71.tgz", - "integrity": "sha512-dB68l59BI75W1BUGVTAEJy45CEVuEGy9qPVVQ8pnHyHMn36PLPPoE1mjLH+lo9rKulO3HC2OhbACI/8tCqJBcA==", + "version": "1.5.75", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.75.tgz", + "integrity": "sha512-Lf3++DumRE/QmweGjU+ZcKqQ+3bKkU/qjaKYhIJKEOhgIO9Xs6IiAQFkfFoj+RhgDk4LUeNsLo6plExHqSyu6Q==", "dev": true, "license": "ISC", "peer": true @@ -1051,18 +984,6 @@ "once": "^1.4.0" } }, - "node_modules/entities": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", - "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", - "license": "BSD-2-Clause", - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, "node_modules/escalade": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", @@ -1157,9 +1078,9 @@ } }, "node_modules/eslint": { - "version": "9.16.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.16.0.tgz", - "integrity": "sha512-whp8mSQI4C8VXd+fLgSM0lh3UlmcFtVwUQjyKCFfsp+2ItAIYhlq/hqGahGqHE6cv9unM41VlqKk2VtKYR2TaA==", + "version": "9.17.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.17.0.tgz", + "integrity": "sha512-evtlNcpJg+cZLcnVKwsai8fExnqjGPicK7gnUtlNuzu+Fv9bI0aLpND5T44VLQtoMEnI57LoXO9XAkIXwohKrA==", "dev": true, "license": "MIT", "dependencies": { @@ -1168,7 +1089,7 @@ "@eslint/config-array": "^0.19.0", "@eslint/core": "^0.9.0", "@eslint/eslintrc": "^3.2.0", - "@eslint/js": "9.16.0", + "@eslint/js": "9.17.0", "@eslint/plugin-kit": "^0.2.3", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", @@ -1177,7 +1098,7 @@ "@types/json-schema": "^7.0.15", "ajv": "^6.12.4", "chalk": "^4.0.0", - "cross-spawn": "^7.0.5", + "cross-spawn": "^7.0.6", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", "eslint-scope": "^8.2.0", @@ -1445,15 +1366,14 @@ } }, "node_modules/flast": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/flast/-/flast-2.1.1.tgz", - "integrity": "sha512-C2DY6cpUzQerbVw+K3YzFWehz8SSiQFcUZMV4dUd/2W8RXlue4qWPvh8oD0tnQK/RjhZvVtgUZVrI3aSIUm8YA==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/flast/-/flast-2.2.1.tgz", + "integrity": "sha512-04Pd2dulGdhZ9GJ1CNzsx9gTAu8oAvlwFm6n0HLDVdHhcaTGOb3xzntZSFeHEFsYf5QkVy7koFFqvZKmKLrZqA==", "license": "MIT", "dependencies": { "escodegen": "npm:@javascript-obfuscator/escodegen", "eslint-scope": "^8.2.0", - "espree": "^10.3.0", - "estraverse": "^5.3.0" + "espree": "^10.3.0" } }, "node_modules/flast/node_modules/eslint-scope": { @@ -1502,20 +1422,6 @@ "dev": true, "license": "ISC" }, - "node_modules/form-data": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", - "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", - "license": "MIT", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/fs-constants": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", @@ -1553,9 +1459,9 @@ } }, "node_modules/globals": { - "version": "15.13.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-15.13.0.tgz", - "integrity": "sha512-49TewVEz0UxZjr1WYYsWpPrhyC/B/pA8Bq0fUmet2n+eR7yn0IvNzNaoBwnK6mdkzcN+se7Ez9zUgULTz2QH4g==", + "version": "15.14.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.14.0.tgz", + "integrity": "sha512-OkToC372DtlQeje9/zHIo5CT8lRP/FUgEOKBEhU4e0abL7J7CD24fD9ohiLN5hagG/kWCYj4K5oaxxtj2Z0Dig==", "dev": true, "license": "MIT", "engines": { @@ -1575,44 +1481,6 @@ "node": ">=8" } }, - "node_modules/html-encoding-sniffer": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-4.0.0.tgz", - "integrity": "sha512-Y22oTqIU4uuPgEemfz7NDJz6OeKf12Lsu+QC+s3BVpda64lTiMYCyGwg5ki4vFxkMwQdeZDl2adZoqUgdFuTgQ==", - "license": "MIT", - "dependencies": { - "whatwg-encoding": "^3.1.1" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/http-proxy-agent": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", - "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", - "license": "MIT", - "dependencies": { - "agent-base": "^7.1.0", - "debug": "^4.3.4" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/https-proxy-agent": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", - "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", - "license": "MIT", - "dependencies": { - "agent-base": "^7.1.2", - "debug": "4" - }, - "engines": { - "node": ">= 14" - } - }, "node_modules/husky": { "version": "9.1.7", "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz", @@ -1629,18 +1497,6 @@ "url": "https://github.com/sponsors/typicode" } }, - "node_modules/iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "license": "MIT", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", @@ -1733,12 +1589,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-potential-custom-element-name": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", - "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", - "license": "MIT" - }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -1747,9 +1597,9 @@ "license": "ISC" }, "node_modules/isolated-vm": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/isolated-vm/-/isolated-vm-5.0.2.tgz", - "integrity": "sha512-q8zQIbVIg83nmV2x1r60gWGjgjaJ2srGMzJ5B4TIlvnWZMuZDIM0OxOOj+5FF9oui1XdAU29xWwT9M4ih6RJiQ==", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/isolated-vm/-/isolated-vm-5.0.3.tgz", + "integrity": "sha512-GNqX0j7dkwdaNQfFogLLb/tSuPZbXtKlk5ldaJ084ngjaW9/bn34x9FQFL856p20KSZoubIIummmiJf+2hzhCw==", "hasInstallScript": true, "license": "ISC", "dependencies": { @@ -1780,50 +1630,10 @@ "js-yaml": "bin/js-yaml.js" } }, - "node_modules/jsdom": { - "version": "25.0.1", - "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-25.0.1.tgz", - "integrity": "sha512-8i7LzZj7BF8uplX+ZyOlIz86V6TAsSs+np6m1kpW9u0JWi4z/1t+FzcK1aek+ybTnAC4KhBL4uXCNT0wcUIeCw==", - "license": "MIT", - "dependencies": { - "cssstyle": "^4.1.0", - "data-urls": "^5.0.0", - "decimal.js": "^10.4.3", - "form-data": "^4.0.0", - "html-encoding-sniffer": "^4.0.0", - "http-proxy-agent": "^7.0.2", - "https-proxy-agent": "^7.0.5", - "is-potential-custom-element-name": "^1.0.1", - "nwsapi": "^2.2.12", - "parse5": "^7.1.2", - "rrweb-cssom": "^0.7.1", - "saxes": "^6.0.0", - "symbol-tree": "^3.2.4", - "tough-cookie": "^5.0.0", - "w3c-xmlserializer": "^5.0.0", - "webidl-conversions": "^7.0.0", - "whatwg-encoding": "^3.1.1", - "whatwg-mimetype": "^4.0.0", - "whatwg-url": "^14.0.0", - "ws": "^8.18.0", - "xml-name-validator": "^5.0.0" - }, - "engines": { - "node": ">=18" - }, - "peerDependencies": { - "canvas": "^2.11.2" - }, - "peerDependenciesMeta": { - "canvas": { - "optional": true - } - } - }, "node_modules/jsesc": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.0.2.tgz", - "integrity": "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", "dev": true, "license": "MIT", "peer": true, @@ -1927,27 +1737,6 @@ "yallist": "^3.0.2" } }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "license": "MIT", - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, "node_modules/mimic-response": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", @@ -1992,6 +1781,7 @@ "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, "license": "MIT" }, "node_modules/napi-build-utils": { @@ -2032,26 +1822,20 @@ } }, "node_modules/node-releases": { - "version": "2.0.18", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.18.tgz", - "integrity": "sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==", + "version": "2.0.19", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.19.tgz", + "integrity": "sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw==", "dev": true, "license": "MIT", "peer": true }, - "node_modules/nwsapi": { - "version": "2.2.16", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.16.tgz", - "integrity": "sha512-F1I/bimDpj3ncaNDhfyMWuFqmQDBwDB0Fogc2qpL3BWvkQteFD/8BzWuIRl83rq0DXfm8SGt/HFhLXZyljTXcQ==", - "license": "MIT" - }, "node_modules/obfuscation-detector": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/obfuscation-detector/-/obfuscation-detector-2.0.4.tgz", - "integrity": "sha512-d8DhD7j6pQ68z1XcpWgEjNKtQAnLM2Opx464jU3tu3+dT4ycux9YgEeVmX4QEYmSfMWJXivvyTooj/Iz61Igrw==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/obfuscation-detector/-/obfuscation-detector-2.0.5.tgz", + "integrity": "sha512-g4VLMZronO5ZTZUWzTY9k8YfevkT1YGp0go514WStGAvHSQ6Yh2d9LzG1q4rJ+goDqYo0+tPOrP/xKLxptqkUw==", "license": "MIT", "dependencies": { - "flast": "^2.1.1" + "flast": "^2.2.1" }, "bin": { "obfuscation-detector": "bin/obfuscation-detector.js" @@ -2129,18 +1913,6 @@ "node": ">=6" } }, - "node_modules/parse5": { - "version": "7.2.1", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.2.1.tgz", - "integrity": "sha512-BuBYQYlv1ckiPdQi/ohiivi9Sagc9JG+Ozs0r7b/0iK3sKmrb0b9FdWdBbOdx6hBCM/F9Ir82ofnBhtZOjCRPQ==", - "license": "MIT", - "dependencies": { - "entities": "^4.5.0" - }, - "funding": { - "url": "https://github.com/inikulin/parse5?sponsor=1" - } - }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -2219,6 +1991,7 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -2272,12 +2045,6 @@ "node": ">=4" } }, - "node_modules/rrweb-cssom": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.7.1.tgz", - "integrity": "sha512-TrEMa7JGdVm0UThDJSx7ddw5nVm3UJS9o9CCIZ72B1vSyEZoziDqBYP3XIoi/12lKrJR8rE3jeFHMok2F/Mnsg==", - "license": "MIT" - }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -2298,24 +2065,6 @@ ], "license": "MIT" }, - "node_modules/safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "license": "MIT" - }, - "node_modules/saxes": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", - "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==", - "license": "ISC", - "dependencies": { - "xmlchars": "^2.2.0" - }, - "engines": { - "node": ">=v12.22.7" - } - }, "node_modules/semver": { "version": "6.3.1", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", @@ -2439,12 +2188,6 @@ "node": ">=8" } }, - "node_modules/symbol-tree": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", - "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", - "license": "MIT" - }, "node_modules/tar-fs": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", @@ -2473,48 +2216,6 @@ "node": ">=6" } }, - "node_modules/tldts": { - "version": "6.1.66", - "resolved": "https://registry.npmjs.org/tldts/-/tldts-6.1.66.tgz", - "integrity": "sha512-l3ciXsYFel/jSRfESbyKYud1nOw7WfhrBEF9I3UiarYk/qEaOOwu3qXNECHw4fHGHGTEOuhf/VdKgoDX5M/dhQ==", - "license": "MIT", - "dependencies": { - "tldts-core": "^6.1.66" - }, - "bin": { - "tldts": "bin/cli.js" - } - }, - "node_modules/tldts-core": { - "version": "6.1.66", - "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-6.1.66.tgz", - "integrity": "sha512-s07jJruSwndD2X8bVjwioPfqpIc1pDTzszPe9pL1Skbh4bjytL85KNQ3tolqLbCvpQHawIsGfFi9dgerWjqW4g==", - "license": "MIT" - }, - "node_modules/tough-cookie": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-5.0.0.tgz", - "integrity": "sha512-FRKsF7cz96xIIeMZ82ehjC3xW2E+O2+v11udrDYewUbszngYhsGa8z6YUMMzO9QJZzzyd0nGGXnML/TReX6W8Q==", - "license": "BSD-3-Clause", - "dependencies": { - "tldts": "^6.1.32" - }, - "engines": { - "node": ">=16" - } - }, - "node_modules/tr46": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-5.0.0.tgz", - "integrity": "sha512-tk2G5R2KRwBd+ZN0zaEXpmzdKyOYksXwywulIX95MBODjSzMIuQnQ3m8JxgbhnL1LeVo7lqQKsYa1O3Htl7K5g==", - "license": "MIT", - "dependencies": { - "punycode": "^2.3.1" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -2588,61 +2289,6 @@ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "license": "MIT" }, - "node_modules/w3c-xmlserializer": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz", - "integrity": "sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==", - "license": "MIT", - "dependencies": { - "xml-name-validator": "^5.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/webidl-conversions": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", - "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", - "license": "BSD-2-Clause", - "engines": { - "node": ">=12" - } - }, - "node_modules/whatwg-encoding": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-3.1.1.tgz", - "integrity": "sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==", - "license": "MIT", - "dependencies": { - "iconv-lite": "0.6.3" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/whatwg-mimetype": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz", - "integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==", - "license": "MIT", - "engines": { - "node": ">=18" - } - }, - "node_modules/whatwg-url": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.1.0.tgz", - "integrity": "sha512-jlf/foYIKywAt3x/XWKZ/3rz8OSJPiWktjmk891alJUEjiVxKX9LEO92qH3hv4aJ0mN3MWPvGMCy8jQi95xK4w==", - "license": "MIT", - "dependencies": { - "tr46": "^5.0.0", - "webidl-conversions": "^7.0.0" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -2674,42 +2320,6 @@ "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "license": "ISC" }, - "node_modules/ws": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", - "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", - "license": "MIT", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": ">=5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, - "node_modules/xml-name-validator": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz", - "integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==", - "license": "Apache-2.0", - "engines": { - "node": ">=18" - } - }, - "node_modules/xmlchars": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", - "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", - "license": "MIT" - }, "node_modules/yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", diff --git a/package.json b/package.json index 1fe7630..62eb5ce 100644 --- a/package.json +++ b/package.json @@ -12,10 +12,9 @@ "test": "tests" }, "dependencies": { - "flast": "^2.1.1", - "isolated-vm": "^5.0.2", - "jsdom": "^25.0.1", - "obfuscation-detector": "^2.0.4" + "flast": "2.2.1", + "isolated-vm": "^5.0.3", + "obfuscation-detector": "^2.0.5" }, "scripts": { "test": "node --test --trace-warnings --no-node-snapshot", diff --git a/src/modules/config.js b/src/modules/config.js index 1ea0dc2..77fb23e 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -15,7 +15,9 @@ const defaultMaxIterations = { valueOf() {return this.value--;}, }; -const propertiesThatModifyContent = ['push', 'forEach', 'pop', 'insert', 'add', 'set', 'delete']; +const propertiesThatModifyContent = [ + 'push', 'forEach', 'pop', 'insert', 'add', 'set', 'delete', 'shift', 'unshift', 'splice' +]; // Builtin functions that shouldn't be resolved in the deobfuscation context. const skipBuiltinFunctions = [ diff --git a/src/modules/safe/rearrangeSwitches.js b/src/modules/safe/rearrangeSwitches.js index 3688bfa..0942aeb 100644 --- a/src/modules/safe/rearrangeSwitches.js +++ b/src/modules/safe/rearrangeSwitches.js @@ -23,16 +23,32 @@ function rearrangeSwitches(arb, candidateFilter = () => true) { let counter = 0; while (currentVal !== undefined && counter < maxRepetition) { // A matching case or the default case - let currentCase = cases.find(c => c.test?.value === currentVal) || cases.find(c => !c.test); + let currentCase; + for (let j = 0; j < cases.length; j++) { + if (cases[j].test?.value === currentVal || !cases[j].test) { + currentCase = cases[j]; + break; + } + } if (!currentCase) break; - ordered.push(...currentCase.consequent.filter(c => c.type !== 'BreakStatement')); - + for (let j = 0; j < currentCase.consequent.length; j++) { + if (currentCase.consequent[j].type !== 'BreakStatement') { + ordered.push(currentCase.consequent[j]); + } + } let allDescendants = []; - currentCase.consequent.forEach(c => allDescendants.push(...getDescendants(c))); - const assignments2Next = allDescendants.filter(d => - d.declNode === n.discriminant.declNode && - d.parentKey === 'left' && - d.parentNode.type === 'AssignmentExpression'); + for (let j = 0; j < currentCase.consequent.length; j++) { + allDescendants.push(...getDescendants(currentCase.consequent[j])); + } + const assignments2Next = []; + for (let j = 0; j < allDescendants.length; j++) { + const d = allDescendants[j]; + if (d.declNode === n.discriminant.declNode && + d.parentKey === 'left' && + d.parentNode.type === 'AssignmentExpression') { + assignments2Next.push(d); + } + } if (assignments2Next.length === 1) { currentVal = assignments2Next[0].parentNode.right.value; } else { diff --git a/src/modules/safe/resolveFunctionConstructorCalls.js b/src/modules/safe/resolveFunctionConstructorCalls.js index 84084e1..396db60 100644 --- a/src/modules/safe/resolveFunctionConstructorCalls.js +++ b/src/modules/safe/resolveFunctionConstructorCalls.js @@ -11,24 +11,27 @@ function resolveFunctionConstructorCalls(arb, candidateFilter = () => true) { const relevantNodes = [ ...(arb.ast[0].typeMap.CallExpression || []), ]; - for (let i = 0; i < relevantNodes.length; i++) { + nodeLoop: for (let i = 0; i < relevantNodes.length; i++) { const n = relevantNodes[i]; if (n.callee?.type === 'MemberExpression' && (n.callee.property?.name || n.callee.property?.value) === 'constructor' && - n.arguments.length && n.arguments.slice(-1)[0].type === 'Literal' && - candidateFilter(n)) {let args = ''; + candidateFilter(n)) { + let args = ''; + let code = ''; if (n.arguments.length > 1) { - const originalArgs = n.arguments.slice(0, -1); - if (originalArgs.find(n => n.type !== 'Literal')) continue; - args = originalArgs.map(n => n.value).join(', '); - } + for (let j = 0; j < n.arguments.length; j++) { + if (n.arguments[j].type !== 'Literal') continue nodeLoop; + if (code) args += (args.length ? ', ' : '') + code; + code = n.arguments[j].value; + } + } else code = n.arguments[0].value; // Wrap the code in a valid anonymous function in the same way Function.constructor would. // Give the anonymous function any arguments it may require. // Wrap the function in an expression to make it a valid code (since it's anonymous). // Generate an AST without nodeIds (to avoid duplicates with the rest of the code). // Extract just the function expression from the AST. try { - const codeNode = generateFlatAST(`(function (${args}) {${n.arguments.slice(-1)[0].value}})`, + const codeNode = generateFlatAST(`(function (${args}) {${code}})`, {detailed: false, includeSrc: false})[2]; if (codeNode) arb.markNode(n, codeNode); } catch {} diff --git a/src/modules/safe/resolveMemberExpressionsWithDirectAssignment.js b/src/modules/safe/resolveMemberExpressionsWithDirectAssignment.js index 6a61bb1..12ac68e 100644 --- a/src/modules/safe/resolveMemberExpressionsWithDirectAssignment.js +++ b/src/modules/safe/resolveMemberExpressionsWithDirectAssignment.js @@ -13,20 +13,26 @@ function resolveMemberExpressionsWithDirectAssignment(arb, candidateFilter = () const relevantNodes = [ ...(arb.ast[0].typeMap.MemberExpression || []), ]; - for (let i = 0; i < relevantNodes.length; i++) { + rnLoop: for (let i = 0; i < relevantNodes.length; i++) { const n = relevantNodes[i]; if (n.object.declNode && n.parentNode.type === 'AssignmentExpression' && n.parentNode.right.type === 'Literal' && candidateFilter(n)) { const prop = n.property?.value || n.property?.name; - const valueUses = n.object.declNode.references.filter(ref => - ref.parentNode !== n && ref.parentNode.type === 'MemberExpression' && - prop === ref.parentNode.property[ref.parentNode.property.computed ? 'value' : 'name']); + const valueUses = []; + for (let j = 0; j < n.object.declNode.references.length; j++) { + /** @type {ASTNode} */ + const ref = n.object.declNode.references[j]; + if (ref.parentNode !== n && ref.parentNode.type === 'MemberExpression' && + prop === ref.parentNode.property[ref.parentNode.property.computed ? 'value' : 'name']) { + // Skip if the value is reassigned + if (ref.parentNode.parentNode.type === 'UpdateExpression' || + (ref.parentNode.parentNode.type === 'AssignmentExpression' && ref.parentNode.parentKey === 'left')) continue rnLoop; + valueUses.push(ref); + } + } if (valueUses.length) { - // Skip if the value is reassigned - if (valueUses.some(v => v.parentNode.parentNode.type === 'UpdateExpression' || - (v.parentNode.parentNode.type === 'AssignmentExpression' && v.parentNode.parentKey === 'left'))) continue; const replacementNode = n.parentNode.right; for (let j = 0; j < valueUses.length; j++) { arb.markNode(valueUses[j].parentNode, replacementNode); diff --git a/src/modules/safe/resolveProxyReferences.js b/src/modules/safe/resolveProxyReferences.js index 71aa567..cb4cc8a 100644 --- a/src/modules/safe/resolveProxyReferences.js +++ b/src/modules/safe/resolveProxyReferences.js @@ -1,5 +1,5 @@ -import {getDescendants} from '../utils/getDescendants.js'; import {areReferencesModified} from '../utils/areReferencesModified.js'; +import {doesDescendantMatchCondition} from '../utils/doesDescendantMatchCondition.js'; import {getMainDeclaredObjectOfMemberExpression} from '../utils/getMainDeclaredObjectOfMemberExpression.js'; /** @@ -28,7 +28,7 @@ function resolveProxyReferences(arb, candidateFilter = () => true) { const replacementMainIdentifier = getMainDeclaredObjectOfMemberExpression(n.init)?.declNode; if (replacementMainIdentifier && replacementMainIdentifier === relevantIdentifier) continue; // Exclude changes in the identifier's own init - if (getDescendants(n.init).find(n => n.declNode === relevantIdentifier)) continue; + if (doesDescendantMatchCondition(n.init, n => n === relevantIdentifier)) continue; if (refs.length && !areReferencesModified(arb.ast, refs) && !areReferencesModified(arb.ast, [replacementNode])) { for (const ref of refs) { arb.markNode(ref, replacementNode); diff --git a/src/modules/unsafe/resolveAugmentedFunctionWrappedArrayReplacements.js b/src/modules/unsafe/resolveAugmentedFunctionWrappedArrayReplacements.js index bea7e0d..1aa51f2 100644 --- a/src/modules/unsafe/resolveAugmentedFunctionWrappedArrayReplacements.js +++ b/src/modules/unsafe/resolveAugmentedFunctionWrappedArrayReplacements.js @@ -2,6 +2,7 @@ import {badValue} from '../config.js'; import {Sandbox} from '../utils/sandbox.js'; import {evalInVm} from '../utils/evalInVm.js'; import {getDescendants} from '../utils/getDescendants.js'; +import {doesDescendantMatchCondition} from '../utils/doesDescendantMatchCondition.js'; /** * A special case of function array replacement where the function is wrapped in another function, the array is @@ -17,49 +18,60 @@ export default function resolveAugmentedFunctionWrappedArrayReplacements(arb, ca ]; for (let i = 0; i < relevantNodes.length; i++) { const n = relevantNodes[i]; - if (n.id && candidateFilter(n)) { - const descendants = getDescendants(n); - if (descendants.find(d => + if (n.id && + doesDescendantMatchCondition(n, d => d.type === 'AssignmentExpression' && - d.left?.name === n.id?.name)) { - const arrDecryptor = n; - const arrCandidates = descendants.filter(c => - c.type === 'MemberExpression' && c.object.type === 'Identifier') - .map(n => n.object); - - for (let j = 0; j < arrCandidates.length; j++) { - const ac = arrCandidates[j]; - // If a direct reference to a global variable pointing at an array - let arrRef; - if (!ac.declNode) continue; - if (ac.declNode.scope.type === 'global') { - if (ac.declNode.parentNode?.init?.type === 'ArrayExpression') { - arrRef = ac.declNode.parentNode?.parentNode || ac.declNode.parentNode; - } - } else if (ac.declNode.parentNode?.init?.type === 'CallExpression') { - arrRef = ac.declNode.parentNode.init.callee?.declNode?.parentNode; + d.left?.name === n.id?.name) && + candidateFilter(n)) { + const descendants = getDescendants(n); + const arrDecryptor = n; + const arrCandidates = []; + for (let q = 0; q < descendants.length; q++) { + const c = descendants[q]; + if (c.type === 'MemberExpression' && c.object.type === 'Identifier') arrCandidates.push(c.object); + } + for (let j = 0; j < arrCandidates.length; j++) { + const ac = arrCandidates[j]; + // If a direct reference to a global variable pointing at an array + let arrRef; + if (!ac.declNode) continue; + if (ac.declNode.scope.type === 'global') { + if (ac.declNode.parentNode?.init?.type === 'ArrayExpression') { + arrRef = ac.declNode.parentNode?.parentNode || ac.declNode.parentNode; } - if (arrRef) { - const iife = (arb.ast[0].typeMap.ExpressionStatement || []).find(c => - c.type === 'ExpressionStatement' && - c.expression.type === 'CallExpression' && - c.expression.callee.type === 'FunctionExpression' && - c.expression.arguments.length && - c.expression.arguments[0].type === 'Identifier' && - c.expression.arguments[0].declNode === ac.declNode); - if (iife) { - const context = [arrRef.src, arrDecryptor.src, iife.src].join('\n'); - const skipScopes = [arrRef.scope, arrDecryptor.scope, iife.expression.callee.scope]; - const replacementCandidates = (arb.ast[0].typeMap.CallExpression || []).filter(c => - c?.callee?.name === arrDecryptor.id.name && - !skipScopes.includes(c.scope)); + } else if (ac.declNode.parentNode?.init?.type === 'CallExpression') { + arrRef = ac.declNode.parentNode.init.callee?.declNode?.parentNode; + } + if (arrRef) { + const expressionStatements = arb.ast[0].typeMap.ExpressionStatement || []; + for (let k = 0; k < expressionStatements.length; k++) { + const exp = expressionStatements[k]; + if (exp.expression.type === 'CallExpression' && + exp.expression.callee.type === 'FunctionExpression' && + exp.expression.arguments.length && + exp.expression.arguments[0].type === 'Identifier' && + exp.expression.arguments[0].declNode === ac.declNode) { + const context = [arrRef.src, arrDecryptor.src, exp.src].join('\n'); + const skipScopes = [arrRef.scope, arrDecryptor.scope, exp.expression.callee.scope]; + const callExpressions = arb.ast[0].typeMap.CallExpression || []; + const replacementCandidates = []; + for (let r = 0; r < callExpressions.length; r++) { + const c = callExpressions[r]; + if (c.callee?.name === arrDecryptor.id.name && + !skipScopes.includes(c.scope)) { + replacementCandidates.push(c); + } + } const sb = new Sandbox(); sb.run(context); for (let p = 0; p < replacementCandidates.length; p++) { const rc = replacementCandidates[p]; const replacementNode = evalInVm(`\n${rc.src}`, sb); - if (replacementNode !== badValue) arb.markNode(rc, replacementNode); + if (replacementNode !== badValue) { + arb.markNode(rc, replacementNode); + } } + break; } } } diff --git a/src/modules/unsafe/resolveEvalCallsOnNonLiterals.js b/src/modules/unsafe/resolveEvalCallsOnNonLiterals.js index 4da1611..35ae2ed 100644 --- a/src/modules/unsafe/resolveEvalCallsOnNonLiterals.js +++ b/src/modules/unsafe/resolveEvalCallsOnNonLiterals.js @@ -27,8 +27,9 @@ function resolveEvalCallsOnNonLiterals(arb, candidateFilter = () => true) { // The code inside the eval might contain references to outside code that should be included. const contextNodes = getDeclarationWithContext(n, true); // In case any of the target candidate is included in the context it should be removed. - for (const redundantNode in [n, n?.parentNode, n?.parentNode?.parentNode]) { - if (contextNodes.includes(redundantNode)) contextNodes.splice(contextNodes.indexOf(redundantNode), 1); + const possiblyRedundantNodes = [n, n?.parentNode, n?.parentNode?.parentNode]; + for (let i = 0; i < possiblyRedundantNodes.length; i++) { + if (contextNodes.includes(possiblyRedundantNodes[i])) contextNodes.splice(contextNodes.indexOf(possiblyRedundantNodes[i]), 1); } const context = contextNodes.length ? createOrderedSrc(contextNodes) : ''; const src = `${context}\n;var __a_ = ${createOrderedSrc([n.arguments[0]])}\n;__a_`; diff --git a/src/modules/unsafe/resolveLocalCalls.js b/src/modules/unsafe/resolveLocalCalls.js index 6ac7694..0d2f714 100644 --- a/src/modules/unsafe/resolveLocalCalls.js +++ b/src/modules/unsafe/resolveLocalCalls.js @@ -57,15 +57,19 @@ export default function resolveLocalCalls(arb, candidateFilter = () => true) { candidates.sort(sortByApperanceFrequency); const modifiedRanges = []; - for (let i = 0; i < candidates.length; i++) { + candidateLoop: for (let i = 0; i < candidates.length; i++) { const c = candidates[i]; - if (c.arguments.some(a => badArgumentTypes.includes(a.type)) || isNodeInRanges(c, modifiedRanges)) continue; + if (isNodeInRanges(c, modifiedRanges)) continue; + for (let j = 0; j < c.arguments.length; j++) { + const arg = c.arguments[j]; + if (badArgumentTypes.includes(arg.type)) continue candidateLoop; + } const callee = c.callee?.object || c.callee; const declNode = c.callee?.declNode || c.callee?.object?.declNode; if (declNode?.parentNode?.body?.body?.[0]?.type === 'ReturnStatement') { // Leave this replacement to a safe function const returnArg = declNode.parentNode.body.body[0].argument; - if (['Literal', 'Identifier'].includes(returnArg.type) || /Function/.test(returnArg.type)) continue; // Unwrap identifier + if (['Literal', 'Identifier'].includes(returnArg.type) || returnArg.type.includes('unction')) continue; // Unwrap identifier else if (returnArg.type === 'CallExpression' && returnArg.callee?.object?.type === 'FunctionExpression' && (returnArg.callee.property?.name || returnArg.callee.property?.value) === 'apply') continue; // Unwrap function shells @@ -96,7 +100,7 @@ export default function resolveLocalCalls(arb, candidateFilter = () => true) { // Prevent resolving a function's toString as it might be an anti-debugging mechanism // which will spring if the code is beautified if (c.callee.type === 'MemberExpression' && (c.callee.property?.name || c.callee.property?.value) === 'toString' && - (new RegExp('^function ')).test(replacementNode?.value)) continue; + replacementNode?.value.substring(0, 8) === 'function') continue; arb.markNode(c, replacementNode); modifiedRanges.push(c.range); } diff --git a/src/modules/unsafe/resolveMinimalAlphabet.js b/src/modules/unsafe/resolveMinimalAlphabet.js index f63902c..161661d 100644 --- a/src/modules/unsafe/resolveMinimalAlphabet.js +++ b/src/modules/unsafe/resolveMinimalAlphabet.js @@ -1,6 +1,6 @@ import {badValue} from '../config.js'; import {evalInVm} from '../utils/evalInVm.js'; -import {getDescendants} from '../utils/getDescendants.js'; +import {doesDescendantMatchCondition} from '../utils/doesDescendantMatchCondition.js'; /** * Resolve unary expressions on values which aren't numbers such as +true, +[], +[...], etc, @@ -25,7 +25,7 @@ export default function resolveMinimalAlphabet(arb, candidateFilter = () => true (n.left.type !== 'MemberExpression' && Number.isNaN(parseFloat(n.left?.value))) && ![n.left?.type, n.right?.type].includes('ThisExpression')) && candidateFilter(n)) { - if (getDescendants(n).some(n => n.type === 'ThisExpression')) continue; + if (doesDescendantMatchCondition(n, n => n.type === 'ThisExpression')) continue; const replacementNode = evalInVm(n.src); if (replacementNode !== badValue) { arb.markNode(n, replacementNode); diff --git a/src/modules/utils/areReferencesModified.js b/src/modules/utils/areReferencesModified.js index cd84d07..de16b4d 100644 --- a/src/modules/utils/areReferencesModified.js +++ b/src/modules/utils/areReferencesModified.js @@ -1,5 +1,20 @@ import {propertiesThatModifyContent} from '../config.js'; +/** + * @param {ASTNode} r + * @param {ASTNode[]} assignmentExpressions + * @return {boolean} + */ +function isMemberExpressionAssignedTo(r, assignmentExpressions) { + for (let i = 0; i < assignmentExpressions.length; i++) { + const n = assignmentExpressions[i]; + if (n.left.type === 'MemberExpression' && + (n.left.object.declNode && (r.object.declNode || r.object) === n.left.object.declNode) && + ((n.left.property?.name || n.left.property?.value) === (r.property?.name || r.property?.value))) return true; + } + return false; +} + /** * @param {ASTNode[]} ast * @param {ASTNode[]} refs @@ -7,8 +22,9 @@ import {propertiesThatModifyContent} from '../config.js'; */ function areReferencesModified(ast, refs) { // Verify no reference is on the left side of an assignment - return refs.some(r => - (r.parentKey === 'left' && ['AssignmentExpression', 'ForInStatement', 'ForOfStatement'].includes(r.parentNode.type)) || + for (let i = 0; i < refs.length; i++) { + const r = refs[i]; + if ((r.parentKey === 'left' && ['AssignmentExpression', 'ForInStatement', 'ForOfStatement'].includes(r.parentNode.type)) || // Verify no reference is part of an update expression r.parentNode.type === 'UpdateExpression' || // Verify no variable with the same name is declared in a subscope @@ -23,11 +39,9 @@ function areReferencesModified(ast, refs) { r.parentNode.parentKey === 'left')) || // Verify there are no member expressions among the references which are being assigned to (r.type === 'MemberExpression' && - (ast[0].typeMap.AssignmentExpression || []).some(n => - n.left.type === 'MemberExpression' && - n.left.object?.name === r.object?.name && - (n.left.property?.name || n.left.property?.value === r.property?.name || r.property?.value) && - (n.left.object.declNode && (r.object.declNode || r.object) === n.left.object.declNode)))); + isMemberExpressionAssignedTo(r, ast[0].typeMap.AssignmentExpression || []))) return true; + } + return false; } export {areReferencesModified}; \ No newline at end of file diff --git a/src/modules/utils/createOrderedSrc.js b/src/modules/utils/createOrderedSrc.js index dbfea1d..3c5f703 100644 --- a/src/modules/utils/createOrderedSrc.js +++ b/src/modules/utils/createOrderedSrc.js @@ -36,8 +36,14 @@ function createOrderedSrc(nodes, preserveOrder = false) { nodes[i] = n.parentNode; if (!preserveOrder && n.callee.type === 'FunctionExpression') { // Set nodeId to place IIFE just after its argument's declaration - const argDeclNodeId = n.arguments.find(a => a.nodeId === Math.max(...n.arguments.filter(arg => arg?.declNode?.nodeId).map(arg => arg.nodeId)))?.nodeId; - nodes[i].nodeId = argDeclNodeId ? argDeclNodeId + 1 : nodes[i].nodeId + largeNumber; + let maxArgNodeId = 0; + for (let j = 0; j < n.arguments.length; j++) { + const arg = n.arguments[j]; + if (arg?.declNode?.nodeId > maxArgNodeId) { + maxArgNodeId = arg.declNode.nodeId; + } + } + nodes[i].nodeId = maxArgNodeId ? maxArgNodeId + 1 : nodes[i].nodeId + largeNumber; } } else if (n.callee.type === 'FunctionExpression') { if (!preserveOrder) { diff --git a/src/modules/utils/doesDescendantMatchCondition.js b/src/modules/utils/doesDescendantMatchCondition.js new file mode 100644 index 0000000..f54610e --- /dev/null +++ b/src/modules/utils/doesDescendantMatchCondition.js @@ -0,0 +1,18 @@ +/** + * + * @param {ASTNode} targetNode + * @param {function} condition + * @param {boolean} [returnNode] Return the node that matches the condition + * @return {boolean|ASTNode} + */ +function doesDescendantMatchCondition(targetNode, condition, returnNode = false) { + const stack = [targetNode]; + while (stack.length) { + const currentNode = stack.pop(); + if (condition(currentNode)) return returnNode ? currentNode : true; + if (currentNode.childNodes?.length) stack.push(...currentNode.childNodes); + } + return false; +} + +export {doesDescendantMatchCondition}; \ No newline at end of file diff --git a/src/modules/utils/evalInVm.js b/src/modules/utils/evalInVm.js index 4107992..0ec49e7 100644 --- a/src/modules/utils/evalInVm.js +++ b/src/modules/utils/evalInVm.js @@ -1,14 +1,11 @@ -import {logger} from 'flast'; import {Sandbox} from './sandbox.js'; -import * as assert from 'node:assert'; import {badValue} from '../config.js'; import {getObjType} from './getObjType.js'; import {generateHash} from './generateHash.js'; import {createNewNode} from './createNewNode.js'; -const badTypes = [ // Types of objects which can't be resolved in the deobfuscation context. - 'Promise', -]; +// Types of objects which can't be resolved in the deobfuscation context. +const badTypes = ['Promise']; const matchingObjectKeys = { [Object.keys(console).sort().join('')]: {type: 'Identifier', name: 'console'}, @@ -52,23 +49,15 @@ function evalInVm(stringToEval, sb) { } let vm = sb || new Sandbox(); let res = vm.run(stringToEval); - // noinspection JSUnresolvedVariable if (vm.isReference(res) && !badTypes.includes(getObjType(res))) { + // noinspection JSUnresolvedVariable res = res.copySync(); // If the result is a builtin object / function, return a matching identifier const objKeys = Object.keys(res).sort().join(''); if (matchingObjectKeys[objKeys]) cache[cacheName] = matchingObjectKeys[objKeys]; - else { - // To exclude results based on randomness or timing, eval again and compare results - vm = sb || new Sandbox(); - const res2 = vm.run(stringToEval).copySync(); - assert.deepEqual(res.toString(), res2.toString()); - cache[cacheName] = createNewNode(res); - } + else cache[cacheName] = createNewNode(res); } - } catch (e) { - logger.debug(`[-] Error in _evalInVm: ${e.message}`); - } + } catch {} } return cache[cacheName]; } diff --git a/src/modules/utils/evalWithDom.js b/src/modules/utils/evalWithDom.js deleted file mode 100644 index 501b58d..0000000 --- a/src/modules/utils/evalWithDom.js +++ /dev/null @@ -1,56 +0,0 @@ -// noinspection HtmlRequiredLangAttribute,HtmlRequiredTitleElement - -import fs from 'node:fs'; -import {Sandbox} from './sandbox.js'; -// eslint-disable-next-line no-unused-vars -import {JSDOM} from 'jsdom'; -import {logger} from 'flast'; -import {generateHash} from './generateHash.js'; - -let jQuerySrc = ''; - -let cache = {}; -const maxCacheSize = 100; - -/** - * Place a string into a file and evaluate it with a simulated browser environment. - * @param {string} stringToEval - * @param {boolean} injectjQuery Inject jQuery into the VM if true. - * @return {string} The output string if successful; empty string otherwise. - */ -function evalWithDom(stringToEval, injectjQuery = false) { - const cacheName = `evalWithDom-${generateHash(stringToEval)}`; - if (!cache[cacheName]) { - if (Object.keys(cache).length >= maxCacheSize) cache = {}; - let out = ''; - const vm = new Sandbox(); - try { - // Set up the DOM, and allow script to run wild: - let runString = 'const dom = new JSDOM(``, {runScripts: \'dangerously\'}); ' + - 'const window = dom.window; ' + - 'const document = window.document; '; - // Lazy load the jQuery when needed, and inject it to the head - if (injectjQuery) { - jQuerySrc = jQuerySrc || fs.readFileSync(__dirname + '/jquery.slim.min.js'); - runString += 'const jqueryScript = document.createElement(\'script\'); ' + - 'jqueryScript.src = ' + jQuerySrc + '; ' + - 'document.head.appendChild(jqueryScript);'; - } - // Inject the string to eval as a script into the body - runString += 'const script = document.createElement(\'script\'); ' + - 'script.src = ' + stringToEval + '; ' + - 'document.body.appendChild(script);'; - // Catch and save the console.log's message - vm.on('console.log', function (msg) { - out = msg; - }); - vm.run(runString); - } catch (e) { - logger.debug(`[-] Error in evalWithDom: ${e}`); - } - cache[cacheName] = out; - } - return cache[cacheName]; -} - -export {evalWithDom}; \ No newline at end of file diff --git a/src/modules/utils/generateHash.js b/src/modules/utils/generateHash.js index 69d698f..56834d4 100644 --- a/src/modules/utils/generateHash.js +++ b/src/modules/utils/generateHash.js @@ -1,7 +1,7 @@ import crypto from 'node:crypto'; function generateHash(script) { - return crypto.createHash('sha256').update(script).digest('hex'); + return crypto.createHash('md5').update(script).digest('hex'); } export {generateHash}; \ No newline at end of file diff --git a/src/modules/utils/getDeclarationWithContext.js b/src/modules/utils/getDeclarationWithContext.js index f85ec3d..073e1c5 100644 --- a/src/modules/utils/getDeclarationWithContext.js +++ b/src/modules/utils/getDeclarationWithContext.js @@ -1,8 +1,8 @@ import {getCache} from './getCache.js'; import {generateHash} from './generateHash.js'; import {isNodeInRanges} from './isNodeInRanges.js'; -import {getDescendants} from './getDescendants.js'; import {propertiesThatModifyContent} from '../config.js'; +import {doesDescendantMatchCondition} from './doesDescendantMatchCondition.js'; // Types that give no context by themselves const irrelevantTypesToBeFilteredOut = [ @@ -33,18 +33,6 @@ const ifKeys = ['consequent', 'alternate']; // Node types which are acceptable when wrapping an anonymous function const standaloneNodeTypes = ['ExpressionStatement', 'AssignmentExpression', 'VariableDeclarator']; -/** - * @param {ASTNode} targetNode - * @return {boolean} True if any of the descendants are marked for modification; false otherwise. - */ -function areDescendantsModified(targetNode) { - const descendants = getDescendants(targetNode); - for (let i = 0; i < descendants.length; i++) { - if (descendants[i].isMarked) return true; - } - return false; -} - /** * @param {ASTNode} targetNode * @return {boolean} True if the target node is directly under an if statement; false otherwise @@ -109,12 +97,9 @@ export function getDeclarationWithContext(originNode, excludeOriginNode = false) * @param {ASTNode} node */ function addToStack(node) { - if (!( - seenNodes.includes(node) || + if (seenNodes.includes(node) || stack.includes(node) || - irrelevantTypesToAvoidIteratingOver.includes(node.type))) { - stack.push(node); - } + irrelevantTypesToAvoidIteratingOver.includes(node.type)) {} else stack.push(node); } const cache = getCache(originNode.scriptHash); const srcHash = generateHash(originNode.src); @@ -127,7 +112,7 @@ export function getDeclarationWithContext(originNode, excludeOriginNode = false) if (seenNodes.includes(node)) continue; seenNodes.push(node); // Do not collect any context if one of the relevant nodes is marked to be replaced or deleted - if (node.isMarked || areDescendantsModified(node)) { + if (node.isMarked || doesDescendantMatchCondition(node, n => n.isMarked)) { collected.length = 0; break; } @@ -189,10 +174,6 @@ export function getDeclarationWithContext(originNode, excludeOriginNode = false) // noinspection JSUnresolvedReference addToStack(targetNode.scope.through[j].identifier); } - } else if (targetNode.scope.scopeId && originNode.scope !== targetNode.scope) { - // Collect the scope itself instead of just the node, if the scope isn't the global scope - // noinspection JSUnresolvedVariable - addToStack(targetNode.scope.block); } for (let j = 0; j < targetNode?.childNodes.length; j++) { addToStack(targetNode.childNodes[j]); diff --git a/src/modules/utils/getDescendants.js b/src/modules/utils/getDescendants.js index 7abf550..f566223 100644 --- a/src/modules/utils/getDescendants.js +++ b/src/modules/utils/getDescendants.js @@ -3,6 +3,7 @@ * @return {ASTNode[]} A flat array of all decendants of the target node */ function getDescendants(targetNode) { + if (targetNode?.['decendants']) return targetNode['decendants']; /** @type {ASTNode[]} */ const offsprings = []; /** @type {ASTNode[]} */ @@ -18,7 +19,7 @@ function getDescendants(targetNode) { } } } - return offsprings; + return targetNode['decendants'] = offsprings; } export {getDescendants}; \ No newline at end of file diff --git a/src/modules/utils/index.js b/src/modules/utils/index.js index f4fb76f..6437669 100644 --- a/src/modules/utils/index.js +++ b/src/modules/utils/index.js @@ -4,8 +4,8 @@ export default { createNewNode: (await import('./createNewNode.js')).createNewNode, createOrderedSrc: (await import('./createOrderedSrc.js')).createOrderedSrc, doesBinaryExpressionContainOnlyLiterals: (await import('./doesBinaryExpressionContainOnlyLiterals.js')).doesBinaryExpressionContainOnlyLiterals, + doesDescendantMatchCondition: (await import('./doesDescendantMatchCondition.js')).doesDescendantMatchCondition, evalInVm: (await import('./evalInVm.js')).evalInVm, - evalWithDom: (await import('./evalWithDom.js')).evalWithDom, generateHash: (await import('./generateHash.js')).generateHash, getCache: (await import('./getCache.js')).getCache, getCalleeName: (await import('./getCalleeName.js')).getCalleeName, diff --git a/src/modules/utils/jquery.slim.min.js b/src/modules/utils/jquery.slim.min.js deleted file mode 100644 index 2a171fc..0000000 --- a/src/modules/utils/jquery.slim.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! jQuery v3.4.1 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector | (c) JS Foundation and other contributors | jquery.org/license */ -!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(g,e){"use strict";var t=[],v=g.document,r=Object.getPrototypeOf,s=t.slice,y=t.concat,u=t.push,i=t.indexOf,n={},o=n.toString,m=n.hasOwnProperty,a=m.toString,l=a.call(Object),b={},x=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},w=function(e){return null!=e&&e===e.window},c={type:!0,src:!0,nonce:!0,noModule:!0};function C(e,t,n){var r,i,o=(n=n||v).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function T(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.4.1 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector",E=function(e,t){return new E.fn.init(e,t)},d=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;function p(e){var t=!!e&&"length"in e&&e.length,n=T(e);return!x(e)&&!w(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+R+")"+R+"*"),U=new RegExp(R+"|>"),V=new RegExp(W),X=new RegExp("^"+B+"$"),Q={ID:new RegExp("^#("+B+")"),CLASS:new RegExp("^\\.("+B+")"),TAG:new RegExp("^("+B+"|[*])"),ATTR:new RegExp("^"+M),PSEUDO:new RegExp("^"+W),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+R+"*(even|odd|(([+-]|)(\\d*)n|)"+R+"*(?:([+-]|)"+R+"*(\\d+)|))"+R+"*\\)|)","i"),bool:new RegExp("^(?:"+I+")$","i"),needsContext:new RegExp("^"+R+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+R+"*((?:-\\d)?\\d*)"+R+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,G=/^(?:input|select|textarea|button)$/i,K=/^h\d$/i,J=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\([\\da-f]{1,6}"+R+"?|("+R+")|.)","ig"),ne=function(e,t,n){var r="0x"+t-65536;return r!=r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){C()},ae=xe(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{O.apply(t=P.call(m.childNodes),m.childNodes),t[m.childNodes.length].nodeType}catch(e){O={apply:t.length?function(e,t){q.apply(e,P.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,d=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==d&&9!==d&&11!==d)return n;if(!r&&((e?e.ownerDocument||e:m)!==T&&C(e),e=e||T,E)){if(11!==d&&(u=Z.exec(t)))if(i=u[1]){if(9===d){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return O.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&p.getElementsByClassName&&e.getElementsByClassName)return O.apply(n,e.getElementsByClassName(i)),n}if(p.qsa&&!S[t+" "]&&(!v||!v.test(t))&&(1!==d||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===d&&U.test(t)){(s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=N),o=(l=h(t)).length;while(o--)l[o]="#"+s+" "+be(l[o]);c=l.join(","),f=ee.test(t)&&ye(e.parentNode)||e}try{return O.apply(n,f.querySelectorAll(c)),n}catch(e){S(t,!0)}finally{s===N&&e.removeAttribute("id")}}}return g(t.replace(F,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>x.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[N]=!0,e}function ce(e){var t=T.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)x.attrHandle[n[r]]=t}function de(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function pe(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in p=se.support={},i=se.isXML=function(e){var t=e.namespaceURI,n=(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},C=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:m;return r!==T&&9===r.nodeType&&r.documentElement&&(a=(T=r).documentElement,E=!i(T),m!==T&&(n=T.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),p.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),p.getElementsByTagName=ce(function(e){return e.appendChild(T.createComment("")),!e.getElementsByTagName("*").length}),p.getElementsByClassName=J.test(T.getElementsByClassName),p.getById=ce(function(e){return a.appendChild(e).id=N,!T.getElementsByName||!T.getElementsByName(N).length}),p.getById?(x.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},x.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(x.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},x.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),x.find.TAG=p.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):p.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},x.find.CLASS=p.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(p.qsa=J.test(T.querySelectorAll))&&(ce(function(e){a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+R+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+R+"*(?:value|"+I+")"),e.querySelectorAll("[id~="+N+"-]").length||v.push("~="),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+N+"+*").length||v.push(".#.+[+~]")}),ce(function(e){e.innerHTML="";var t=T.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+R+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(p.matchesSelector=J.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){p.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",W)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=J.test(a.compareDocumentPosition),y=t||J.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!p.sortDetached&&t.compareDocumentPosition(e)===n?e===T||e.ownerDocument===m&&y(m,e)?-1:t===T||t.ownerDocument===m&&y(m,t)?1:u?H(u,e)-H(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e===T?-1:t===T?1:i?-1:o?1:u?H(u,e)-H(u,t):0;if(i===o)return de(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?de(a[r],s[r]):a[r]===m?-1:s[r]===m?1:0}),T},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if((e.ownerDocument||e)!==T&&C(e),p.matchesSelector&&E&&!S[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||p.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){S(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return Q.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&V.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=d[e+" "];return t||(t=new RegExp("(^|"+R+")"+e+"("+R+"|$)"))&&d(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function L(e,n,r){return x(n)?E.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?E.grep(e,function(e){return e===n!==r}):"string"!=typeof n?E.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(E.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||j,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof E?t[0]:t,E.merge(this,E.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:v,!0)),D.test(r[1])&&E.isPlainObject(t))for(r in t)x(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=v.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):x(e)?void 0!==n.ready?n.ready(e):e(E):E.makeArray(e,this)}).prototype=E.fn,j=E(v);var O=/^(?:parents|prev(?:Until|All))/,P={children:!0,contents:!0,next:!0,prev:!0};function H(e,t){while((e=e[t])&&1!==e.nodeType);return e}E.fn.extend({has:function(e){var t=E(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,pe=/^$|^module$|\/(?:java|ecma)script/i,he={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ge(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&S(e,t)?E.merge([e],n):n}function ve(e,t){for(var n=0,r=e.length;nx",b.noCloneChecked=!!ye.cloneNode(!0).lastChild.defaultValue;var we=/^key/,Ce=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Te=/^([^.]*)(?:\.(.+)|)/;function Ee(){return!0}function Ne(){return!1}function Ae(e,t){return e===function(){try{return v.activeElement}catch(e){}}()==("focus"===t)}function ke(e,t,n,r,i,o){var a,s;if("object"==typeof t){for(s in"string"!=typeof n&&(r=r||n,n=void 0),t)ke(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=Ne;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return E().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=E.guid++)),e.each(function(){E.event.add(this,t,i,r,n)})}function Se(e,i,o){o?(G.set(e,i,!1),E.event.add(e,i,{namespace:!1,handler:function(e){var t,n,r=G.get(this,i);if(1&e.isTrigger&&this[i]){if(r.length)(E.event.special[i]||{}).delegateType&&e.stopPropagation();else if(r=s.call(arguments),G.set(this,i,r),t=o(this,i),this[i](),r!==(n=G.get(this,i))||t?G.set(this,i,!1):n={},r!==n)return e.stopImmediatePropagation(),e.preventDefault(),n.value}else r.length&&(G.set(this,i,{value:E.event.trigger(E.extend(r[0],E.Event.prototype),r.slice(1),this)}),e.stopImmediatePropagation())}})):void 0===G.get(e,i)&&E.event.add(e,i,Ee)}E.event={global:{},add:function(t,e,n,r,i){var o,a,s,u,l,c,f,d,p,h,g,v=G.get(t);if(v){n.handler&&(n=(o=n).handler,i=o.selector),i&&E.find.matchesSelector(ie,i),n.guid||(n.guid=E.guid++),(u=v.events)||(u=v.events={}),(a=v.handle)||(a=v.handle=function(e){return"undefined"!=typeof E&&E.event.triggered!==e.type?E.event.dispatch.apply(t,arguments):void 0}),l=(e=(e||"").match(I)||[""]).length;while(l--)p=g=(s=Te.exec(e[l])||[])[1],h=(s[2]||"").split(".").sort(),p&&(f=E.event.special[p]||{},p=(i?f.delegateType:f.bindType)||p,f=E.event.special[p]||{},c=E.extend({type:p,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&E.expr.match.needsContext.test(i),namespace:h.join(".")},o),(d=u[p])||((d=u[p]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(t,r,h,a)||t.addEventListener&&t.addEventListener(p,a)),f.add&&(f.add.call(t,c),c.handler.guid||(c.handler.guid=n.guid)),i?d.splice(d.delegateCount++,0,c):d.push(c),E.event.global[p]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,d,p,h,g,v=G.hasData(e)&&G.get(e);if(v&&(u=v.events)){l=(t=(t||"").match(I)||[""]).length;while(l--)if(p=g=(s=Te.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),p){f=E.event.special[p]||{},d=u[p=(r?f.delegateType:f.bindType)||p]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=d.length;while(o--)c=d[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(d.splice(o,1),c.selector&&d.delegateCount--,f.remove&&f.remove.call(e,c));a&&!d.length&&(f.teardown&&!1!==f.teardown.call(e,h,v.handle)||E.removeEvent(e,p,v.handle),delete u[p])}else for(p in u)E.event.remove(e,p+t[l],n,r,!0);E.isEmptyObject(u)&&G.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,a,s=E.event.fix(e),u=new Array(arguments.length),l=(G.get(this,"events")||{})[s.type]||[],c=E.event.special[s.type]||{};for(u[0]=s,t=1;t\x20\t\r\n\f]*)[^>]*)\/>/gi,Le=/\s*$/g;function Oe(e,t){return S(e,"table")&&S(11!==t.nodeType?t:t.firstChild,"tr")&&E(e).children("tbody")[0]||e}function Pe(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function He(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Ie(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(G.hasData(e)&&(o=G.access(e),a=G.set(t,o),l=o.events))for(i in delete a.handle,a.events={},l)for(n=0,r=l[i].length;n")},clone:function(e,t,n){var r,i,o,a,s,u,l,c=e.cloneNode(!0),f=oe(e);if(!(b.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||E.isXMLDoc(e)))for(a=ge(c),r=0,i=(o=ge(e)).length;r
",2===pt.childNodes.length),E.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(b.createHTMLDocument?((r=(t=v.implementation.createHTMLDocument("")).createElement("base")).href=v.location.href,t.head.appendChild(r)):t=v),o=!n&&[],(i=D.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&E(o).remove(),E.merge([],i.childNodes)));var r,i,o},E.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=E.css(e,"position"),c=E(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=E.css(e,"top"),u=E.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),x(t)&&(t=t.call(e,n,E.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},E.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){E.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===E.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===E.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=E(e).offset()).top+=E.css(e,"borderTopWidth",!0),i.left+=E.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-E.css(r,"marginTop",!0),left:t.left-i.left-E.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===E.css(e,"position"))e=e.offsetParent;return e||ie})}}),E.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;E.fn[t]=function(e){return z(this,function(e,t,n){var r;if(w(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),E.each(["top","left"],function(e,n){E.cssHooks[n]=ze(b.pixelPosition,function(e,t){if(t)return t=Fe(e,n),Me.test(t)?E(e).position()[n]+"px":t})}),E.each({Height:"height",Width:"width"},function(a,s){E.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){E.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return z(this,function(e,t,n){var r;return w(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?E.css(e,t,i):E.style(e,t,n,i)},s,n?e:void 0,n)}})}),E.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){E.fn[n]=function(e,t){return 0 { describe('UNSAFE: resolveAugmentedFunctionWrappedArrayReplacements', async () => { // Load the module even though there are no tests for it - to include it in the coverage report // noinspection JSUnusedLocalSymbols - const targetModule = (await import('../src/modules/unsafe/resolveAugmentedFunctionWrappedArrayReplacements.js')).evalWithDom; + const targetModule = (await import('../src/modules/unsafe/resolveAugmentedFunctionWrappedArrayReplacements.js')).default; it.todo('TODO: Write tests for function', () => {}); }); describe('UNSAFE: resolveBuiltinCalls', async () => { diff --git a/tests/modules.utils.test.js b/tests/modules.utils.test.js index 20f9877..aa65673 100644 --- a/tests/modules.utils.test.js +++ b/tests/modules.utils.test.js @@ -25,11 +25,6 @@ describe('UTILS: evalInVm', async () => { assert.deepStrictEqual(result, expected); }); }); -describe.todo('UTILS: evalWithDom', async () => { - // Load the module even though there are no tests for it - to include it in the coverage report - // noinspection JSUnusedLocalSymbols - const targetModule = (await import('../src/modules/utils/evalWithDom.js')).evalWithDom; -}); describe('UTILS: areReferencesModified', async () => { const targetModule = (await import('../src/modules/utils/areReferencesModified.js')).areReferencesModified; it('TP-1: Update expression', () => { diff --git a/tests/resources/obfuscatorIo.js-deob.js b/tests/resources/obfuscatorIo.js-deob.js index 034000b..e73bd06 100644 --- a/tests/resources/obfuscatorIo.js-deob.js +++ b/tests/resources/obfuscatorIo.js-deob.js @@ -208,11 +208,11 @@ function _yk(a) { } else { if (('' + c / c).length !== 1 || c % 20 === 0) { (function () { - debugge_; + undefined; }.call('action')); } else { (function () { - debugge_; + undefined; }.apply('stateObject')); } }