[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7B5P0KG5N3EN7AB0JC4EZGJ":3,"skill-same:01M7B5P0KG5N3EN7AB0JC4EZGJ":81},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":15,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":45,"commitSha":46,"skillDirectory":47,"forksCount":13,"repositoryHtmlUrl":48,"repositoryHomepageUrl":6,"ownerHtmlUrl":49,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":50,"install":51,"resources":64},"01M7B5P0KG5N3EN7AB0JC4EZGJ","deobfuscating-javascript-malware",null,"Deobfuscates malicious JavaScript found in phishing pages, web skimmers, and dropper scripts by reversing encoding layers, eval chains, string manipulation, and control-flow obfuscation to reveal the original malicious logic. Use when investigating a phishing page's obfuscated JavaScript, analyzing a Magecart-style web skimmer, or deobfuscating a JavaScript dropper that fetches second-stage malware.","vikasvardhanv\u002Fjerry_skills","vikasvardhanv","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F99010657?v=4","01M7B2B0VN78W7529RQX5BR6DZ","01M7B2B0WDNTXJHRK3QNPNWRP6",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fdeobfuscating-javascript-malware\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fdeobfuscating-javascript-malware\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: deobfuscating-javascript-malware\ndescription: Deobfuscates malicious JavaScript found in phishing pages, web skimmers, and dropper scripts by reversing encoding layers, eval chains, string manipulation, and control-flow obfuscation to reveal the original malicious logic. Use when investigating a phishing page's obfuscated JavaScript, analyzing a Magecart-style web skimmer, or deobfuscating a JavaScript dropper that fetches second-stage malware.\ndomain: cybersecurity\nsubdomain: malware-analysis\ntags:\n- malware\n- JavaScript\n- deobfuscation\n- web-malware\n- script-analysis\nversion: 1.0.0\nauthor: mahipal\nlicense: Apache-2.0\nnist_csf:\n- DE.AE-02\n- RS.AN-03\n- ID.RA-01\n- DE.CM-01\nmitre_attack:\n- T1027\n- T1027.010\n- T1140\n- T1059.007\n- T1027.006\n---\n\n# Deobfuscating JavaScript Malware\n\n## When to Use\n\n- Investigating a phishing page with obfuscated JavaScript that performs credential harvesting or redirect\n- Analyzing a web skimmer (Magecart-style) injected into an e-commerce site\n- Deobfuscating a JavaScript dropper that downloads and executes second-stage malware\n- Examining malicious email attachments containing HTML files with embedded obfuscated scripts\n- Analyzing browser exploit kits that use heavy JavaScript obfuscation to hide exploit delivery\n\n**Do not use** for obfuscated JavaScript that is merely minified production code; use a standard beautifier instead.\n\n## Prerequisites\n\n- Node.js 18+ installed for executing and debugging JavaScript in a controlled environment\n- Python 3.8+ with `jsbeautifier` library for code formatting\n- Browser developer tools (Chrome DevTools) for controlled execution in an isolated browser\n- CyberChef (https:\u002F\u002Fgchq.github.io\u002FCyberChef\u002F) for encoding\u002Fdecoding operations\n- de4js or JStillery for automated JavaScript deobfuscation\n- Isolated analysis VM with no access to production systems or sensitive data\n\n## Workflow\n\n### Step 1: Safely Extract and Examine the Obfuscated Script\n\nIsolate the malicious JavaScript without executing it:\n\n```bash\n# Extract JavaScript from HTML file\npython3 \u003C\u003C 'PYEOF'\nfrom html.parser import HTMLParser\n\nclass ScriptExtractor(HTMLParser):\n    def __init__(self):\n        super().__init__()\n        self.in_script = False\n        self.scripts = []\n        self.current = \"\"\n\n    def handle_starttag(self, tag, attrs):\n        if tag == \"script\":\n            self.in_script = True\n            self.current = \"\"\n\n    def handle_endtag(self, tag):\n        if tag == \"script\":\n            self.in_script = False\n            if self.current.strip():\n                self.scripts.append(self.current)\n\n    def handle_data(self, data):\n        if self.in_script:\n            self.current += data\n\nwith open(\"malicious_page.html\") as f:\n    parser = ScriptExtractor()\n    parser.feed(f.read())\n\nfor i, script in enumerate(parser.scripts):\n    with open(f\"script_{i}.js\", \"w\") as f:\n        f.write(script)\n    print(f\"Extracted script_{i}.js ({len(script)} bytes)\")\nPYEOF\n\n# Beautify the extracted JavaScript\nnpx js-beautify script_0.js -o script_0_pretty.js\n```\n\n### Step 2: Identify Obfuscation Techniques\n\nCategorize the obfuscation methods used:\n\n```\nCommon JavaScript Obfuscation Techniques:\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nString Encoding:\n  - Hex encoding:          \"\\x68\\x65\\x6c\\x6c\\x6f\" -> \"hello\"\n  - Unicode escapes:       \"\\u0068\\u0065\\u006c\\u006c\\u006f\" -> \"hello\"\n  - Base64:                atob(\"aGVsbG8=\") -> \"hello\"\n  - charCodeAt\u002FfromCharCode: String.fromCharCode(104,101,108,108,111)\n  - Array-based lookup:    var _0x1234 = [\"hello\",\"world\"]; _0x1234[0]\n\nEval Chains:\n  - eval(atob(\"...\"))\n  - eval(unescape(\"...\"))\n  - new Function(\"return \" + decoded)()\n  - document.write(\"\u003Cscript>\" + decoded + \"\u003C\u002Fscript>\")\n  - setTimeout(decoded, 0)\n\nControl Flow:\n  - Switch-case dispatcher with shuffled case order\n  - Opaque predicates (always-true\u002Ffalse conditions)\n  - Dead code insertion\n  - Variable name mangling (_0x4a3b, _0xab12)\n\nAnti-Analysis:\n  - Debugger traps: setInterval(function(){debugger;}, 100)\n  - Console detection: overriding console.log\n  - Timing checks: performance.now() deltas\n  - DevTools detection: window.outerWidth - window.innerWidth > 100\n```\n\n### Step 3: Remove Anti-Analysis Protections\n\nNeutralize anti-debugging and anti-analysis traps:\n\n```javascript\n\u002F\u002F Remove debugger traps before analysis\n\u002F\u002F Replace in the obfuscated script:\n\n\u002F\u002F Before:\nsetInterval(function() { debugger; }, 100);\n\n\u002F\u002F After (neutralized):\nsetInterval(function() { \u002F* debugger removed *\u002F }, 100);\n\n\u002F\u002F Neutralize DevTools detection\n\u002F\u002F Before:\nif (window.outerWidth - window.innerWidth > 160) { window.location = \"about:blank\"; }\n\n\u002F\u002F After:\nif (false) { window.location = \"about:blank\"; }\n\n\u002F\u002F Neutralize timing checks\n\u002F\u002F Override performance.now to return consistent values\nconst originalNow = performance.now;\nperformance.now = function() { return 0; };\n```\n\n### Step 4: Decode String Obfuscation Layers\n\nProgressively decode encoded strings:\n\n```python\n# Python script to decode common JS obfuscation patterns\nimport re\nimport base64\nimport urllib.parse\n\ndef decode_hex_strings(code):\n    \"\"\"Replace \\\\xNN sequences with ASCII characters\"\"\"\n    def hex_replace(match):\n        hex_str = match.group(0)\n        try:\n            return bytes.fromhex(hex_str.replace(\"\\\\x\", \"\")).decode(\"ascii\")\n        except:\n            return hex_str\n    return re.sub(r'(?:\\\\x[0-9a-fA-F]{2})+', hex_replace, code)\n\ndef decode_unicode_escapes(code):\n    \"\"\"Replace \\\\uNNNN sequences with characters\"\"\"\n    def unicode_replace(match):\n        return chr(int(match.group(1), 16))\n    return re.sub(r'\\\\u([0-9a-fA-F]{4})', unicode_replace, code)\n\ndef decode_charcode_arrays(code):\n    \"\"\"Resolve String.fromCharCode calls\"\"\"\n    def charcode_replace(match):\n        codes = [int(c.strip()) for c in match.group(1).split(\",\")]\n        return '\"' + \"\".join(chr(c) for c in codes) + '\"'\n    return re.sub(r'String\\.fromCharCode\\(([0-9,\\s]+)\\)', charcode_replace, code)\n\ndef decode_base64_strings(code):\n    \"\"\"Resolve atob() calls with static strings\"\"\"\n    def atob_replace(match):\n        try:\n            decoded = base64.b64decode(match.group(1)).decode(\"utf-8\")\n            return f'\"{decoded}\"'\n        except:\n            return match.group(0)\n    return re.sub(r'atob\\([\"\\']([A-Za-z0-9+\u002F=]+)[\"\\']\\)', atob_replace, code)\n\n# Apply all decoders\nwith open(\"script_0.js\") as f:\n    code = f.read()\n\ncode = decode_hex_strings(code)\ncode = decode_unicode_escapes(code)\ncode = decode_charcode_arrays(code)\ncode = decode_base64_strings(code)\n\nwith open(\"script_0_decoded.js\", \"w\") as f:\n    f.write(code)\nprint(\"Decoded strings written to script_0_decoded.js\")\n```\n\n### Step 5: Resolve Eval Chains Safely\n\nUnwrap eval\u002FFunction constructor chains without executing:\n\n```javascript\n\u002F\u002F Node.js script to safely resolve eval chains\n\u002F\u002F Run in isolated environment: node --experimental-vm-modules deobfuscate.js\n\nconst vm = require('vm');\n\n\u002F\u002F Create sandboxed context with logging\nconst sandbox = {\n    eval: function(code) {\n        console.log(\"=== EVAL INTERCEPTED ===\");\n        console.log(code.substring(0, 500));\n        console.log(\"========================\");\n        return code; \u002F\u002F Return the code instead of executing it\n    },\n    document: {\n        write: function(html) {\n            console.log(\"=== DOCUMENT.WRITE INTERCEPTED ===\");\n            console.log(html.substring(0, 500));\n        },\n        getElementById: function() { return { innerHTML: \"\" }; }\n    },\n    window: { location: { href: \"\" } },\n    atob: function(s) { return Buffer.from(s, 'base64').toString(); },\n    unescape: unescape,\n    setTimeout: function(fn) { if (typeof fn === 'string') console.log(\"TIMEOUT CODE:\", fn); },\n    console: console,\n    String: String,\n    Array: Array,\n    parseInt: parseInt,\n    RegExp: RegExp,\n};\n\nconst context = vm.createContext(sandbox);\n\n\u002F\u002F Load and execute the obfuscated script in sandbox\nconst fs = require('fs');\nconst code = fs.readFileSync('script_0.js', 'utf8');\n\ntry {\n    vm.runInContext(code, context, { timeout: 5000 });\n} catch(e) {\n    console.log(\"Execution error (expected):\", e.message);\n}\n```\n\n### Step 6: Analyze the Deobfuscated Payload\n\nExamine the revealed malicious logic:\n\n```\nDeobfuscated Malware Categories and IOC Extraction:\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nCredential Harvester:\n  - Form action URLs (exfiltration endpoints)\n  - XMLHttpRequest\u002Ffetch destinations\n  - Targeted input field names (username, password, cc_number)\n\nWeb Skimmer (Magecart):\n  - Payment form overlay injection\n  - Card data exfiltration URLs\n  - Keylogger event listeners (onkeypress, oninput)\n\nRedirect Script:\n  - Destination URLs in location.href assignments\n  - Conditional redirects based on user-agent or referrer\n  - Cloaking logic (show benign content to bots)\n\nExploit Kit Landing:\n  - Browser\u002Fplugin version checks\n  - Exploit payload URLs\n  - Shellcode embedded as arrays or encoded strings\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| **Eval Chain** | Nested layers of eval(), Function(), or document.write() calls that each decode one layer of obfuscation before passing to the next |\n| **String Array Rotation** | Obfuscation technique storing all strings in a shuffled array and accessing them by computed index to hide string literals |\n| **Dead Code Insertion** | Adding non-functional code blocks that never execute to increase analysis complexity and confuse pattern matching |\n| **Opaque Predicate** | Conditional expression whose outcome is predetermined but difficult to determine statically; used to obscure control flow |\n| **Anti-Debugging** | JavaScript techniques to detect and thwart browser DevTools or debugger usage including debugger statements and timing checks |\n| **Web Skimmer** | Malicious JavaScript injected into e-commerce sites to steal payment card data from checkout forms (Magecart attack) |\n\n## Tools & Systems\n\n- **CyberChef**: GCHQ's web-based tool for encoding\u002Fdecoding transformations useful for unwinding multi-layer obfuscation\n- **de4js**: Online JavaScript deobfuscator supporting common obfuscation tools (obfuscator.io, JScrambler)\n- **Node.js VM Module**: Sandboxed JavaScript execution environment for safely evaluating obfuscated code with intercepted APIs\n- **Chrome DevTools**: Browser developer tools for stepping through JavaScript execution with breakpoints and console access\n- **JSDetox**: JavaScript malware analysis tool providing execution emulation and deobfuscation\n\n## Common Scenarios\n\n### Scenario: Deobfuscating a Magecart Web Skimmer\n\n**Context**: A compromised e-commerce site has obfuscated JavaScript injected into its checkout page. The script needs deobfuscation to identify the data exfiltration endpoint and determine what customer data was stolen.\n\n**Approach**:\n1. Extract the injected script from the page source (often appended to a legitimate JS file or loaded from an external domain)\n2. Beautify the code and identify the obfuscation technique (typically string array + rotation + hex encoding)\n3. Decode string encoding layers (hex -> Unicode -> base64) using the Python decoder script\n4. Resolve the string array by evaluating the array definition and rotation function\n5. Identify the form targeting logic (querySelector for payment form fields)\n6. Extract the exfiltration URL from the XMLHttpRequest or fetch call\n7. Document stolen data fields and exfiltration endpoint for incident response\n\n**Pitfalls**:\n- Executing obfuscated scripts on a connected system (the script may phone home during analysis)\n- Not removing anti-debugging traps before using browser DevTools (infinite debugger loops)\n- Missing additional obfuscation layers loaded dynamically from external URLs\n- Overlooking base64-encoded inline images or data URIs that may contain additional scripts\n\n## Output Format\n\n```\nJAVASCRIPT MALWARE DEOBFUSCATION REPORT\n=========================================\nSource:           checkout.js (injected into example-shop.com)\nObfuscation:      obfuscator.io (string array + rotation + hex encoding)\nLayers Removed:   3\n\nOBFUSCATION TECHNIQUES IDENTIFIED\n[1] String array with 247 entries, rotated by 0x1a3\n[2] Hex-encoded string references (\\x68\\x65\\x6c\\x6c\\x6f)\n[3] Base64-wrapped eval chain (2 layers)\n[4] Anti-debugging: setInterval debugger trap\n\nDEOBFUSCATED FUNCTIONALITY\nType:             Magecart Payment Card Skimmer\nTarget Forms:     input[name*=\"card\"], input[name*=\"cc_\"]\nData Captured:    Card number, expiration, CVV, cardholder name\nExfil Method:     POST via XMLHttpRequest\nExfil URL:        hxxps:\u002F\u002Fanalytics-cdn[.]com\u002Fcollect\nExfil Format:     JSON { \"cn\": card_number, \"exp\": expiry, \"cv\": cvv }\nTrigger:          Form submit event on checkout page\n\nEXTRACTED IOCs\nDomains:          analytics-cdn[.]com\nIPs:              185.220.101[.]42\nURLs:             hxxps:\u002F\u002Fanalytics-cdn[.]com\u002Fcollect\n                  hxxps:\u002F\u002Fanalytics-cdn[.]com\u002Fgate.js\n```\n","# Deobfuscating JavaScript Malware\n\n## When to Use\n\n- Investigating a phishing page with obfuscated JavaScript that performs credential harvesting or redirect\n- Analyzing a web skimmer (Magecart-style) injected into an e-commerce site\n- Deobfuscating a JavaScript dropper that downloads and executes second-stage malware\n- Examining malicious email attachments containing HTML files with embedded obfuscated scripts\n- Analyzing browser exploit kits that use heavy JavaScript obfuscation to hide exploit delivery\n\n**Do not use** for obfuscated JavaScript that is merely minified production code; use a standard beautifier instead.\n\n## Prerequisites\n\n- Node.js 18+ installed for executing and debugging JavaScript in a controlled environment\n- Python 3.8+ with `jsbeautifier` library for code formatting\n- Browser developer tools (Chrome DevTools) for controlled execution in an isolated browser\n- CyberChef (https:\u002F\u002Fgchq.github.io\u002FCyberChef\u002F) for encoding\u002Fdecoding operations\n- de4js or JStillery for automated JavaScript deobfuscation\n- Isolated analysis VM with no access to production systems or sensitive data\n\n## Workflow\n\n### Step 1: Safely Extract and Examine the Obfuscated Script\n\nIsolate the malicious JavaScript without executing it:\n\n```bash\n# Extract JavaScript from HTML file\npython3 \u003C\u003C 'PYEOF'\nfrom html.parser import HTMLParser\n\nclass ScriptExtractor(HTMLParser):\n    def __init__(self):\n        super().__init__()\n        self.in_script = False\n        self.scripts = []\n        self.current = \"\"\n\n    def handle_starttag(self, tag, attrs):\n        if tag == \"script\":\n            self.in_script = True\n            self.current = \"\"\n\n    def handle_endtag(self, tag):\n        if tag == \"script\":\n            self.in_script = False\n            if self.current.strip():\n                self.scripts.append(self.current)\n\n    def handle_data(self, data):\n        if self.in_script:\n            self.current += data\n\nwith open(\"malicious_page.html\") as f:\n    parser = ScriptExtractor()\n    parser.feed(f.read())\n\nfor i, script in enumerate(parser.scripts):\n    with open(f\"script_{i}.js\", \"w\") as f:\n        f.write(script)\n    print(f\"Extracted script_{i}.js ({len(script)} bytes)\")\nPYEOF\n\n# Beautify the extracted JavaScript\nnpx js-beautify script_0.js -o script_0_pretty.js\n```\n\n### Step 2: Identify Obfuscation Techniques\n\nCategorize the obfuscation methods used:\n\n```\nCommon JavaScript Obfuscation Techniques:\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nString Encoding:\n  - Hex encoding:          \"\\x68\\x65\\x6c\\x6c\\x6f\" -> \"hello\"\n  - Unicode escapes:       \"\\u0068\\u0065\\u006c\\u006c\\u006f\" -> \"hello\"\n  - Base64:                atob(\"aGVsbG8=\") -> \"hello\"\n  - charCodeAt\u002FfromCharCode: String.fromCharCode(104,101,108,108,111)\n  - Array-based lookup:    var _0x1234 = [\"hello\",\"world\"]; _0x1234[0]\n\nEval Chains:\n  - eval(atob(\"...\"))\n  - eval(unescape(\"...\"))\n  - new Function(\"return \" + decoded)()\n  - document.write(\"\u003Cscript>\" + decoded + \"\u003C\u002Fscript>\")\n  - setTimeout(decoded, 0)\n\nControl Flow:\n  - Switch-case dispatcher with shuffled case order\n  - Opaque predicates (always-true\u002Ffalse conditions)\n  - Dead code insertion\n  - Variable name mangling (_0x4a3b, _0xab12)\n\nAnti-Analysis:\n  - Debugger traps: setInterval(function(){debugger;}, 100)\n  - Console detection: overriding console.log\n  - Timing checks: performance.now() deltas\n  - DevTools detection: window.outerWidth - window.innerWidth > 100\n```\n\n### Step 3: Remove Anti-Analysis Protections\n\nNeutralize anti-debugging and anti-analysis traps:\n\n```javascript\n\u002F\u002F Remove debugger traps before analysis\n\u002F\u002F Replace in the obfuscated script:\n\n\u002F\u002F Before:\nsetInterval(function() { debugger; }, 100);\n\n\u002F\u002F After (neutralized):\nsetInterval(function() { \u002F* debugger removed *\u002F }, 100);\n\n\u002F\u002F Neutralize DevTools detection\n\u002F\u002F Before:\nif (window.outerWidth - window.innerWidth > 160) { window.location = \"about:blank\"; }\n\n\u002F\u002F After:\nif (false) { window.location = \"about:blank\"; }\n\n\u002F\u002F Neutralize timing checks\n\u002F\u002F Override performance.now to return consistent values\nconst originalNow = performance.now;\nperformance.now = function() { return 0; };\n```\n\n### Step 4: Decode String Obfuscation Layers\n\nProgressively decode encoded strings:\n\n```python\n# Python script to decode common JS obfuscation patterns\nimport re\nimport base64\nimport urllib.parse\n\ndef decode_hex_strings(code):\n    \"\"\"Replace \\\\xNN sequences with ASCII characters\"\"\"\n    def hex_replace(match):\n        hex_str = match.group(0)\n        try:\n            return bytes.fromhex(hex_str.replace(\"\\\\x\", \"\")).decode(\"ascii\")\n        except:\n            return hex_str\n    return re.sub(r'(?:\\\\x[0-9a-fA-F]{2})+', hex_replace, code)\n\ndef decode_unicode_escapes(code):\n    \"\"\"Replace \\\\uNNNN sequences with characters\"\"\"\n    def unicode_replace(match):\n        return chr(int(match.group(1), 16))\n    return re.sub(r'\\\\u([0-9a-fA-F]{4})', unicode_replace, code)\n\ndef decode_charcode_arrays(code):\n    \"\"\"Resolve String.fromCharCode calls\"\"\"\n    def charcode_replace(match):\n        codes = [int(c.strip()) for c in match.group(1).split(\",\")]\n        return '\"' + \"\".join(chr(c) for c in codes) + '\"'\n    return re.sub(r'String\\.fromCharCode\\(([0-9,\\s]+)\\)', charcode_replace, code)\n\ndef decode_base64_strings(code):\n    \"\"\"Resolve atob() calls with static strings\"\"\"\n    def atob_replace(match):\n        try:\n            decoded = base64.b64decode(match.group(1)).decode(\"utf-8\")\n            return f'\"{decoded}\"'\n        except:\n            return match.group(0)\n    return re.sub(r'atob\\([\"\\']([A-Za-z0-9+\u002F=]+)[\"\\']\\)', atob_replace, code)\n\n# Apply all decoders\nwith open(\"script_0.js\") as f:\n    code = f.read()\n\ncode = decode_hex_strings(code)\ncode = decode_unicode_escapes(code)\ncode = decode_charcode_arrays(code)\ncode = decode_base64_strings(code)\n\nwith open(\"script_0_decoded.js\", \"w\") as f:\n    f.write(code)\nprint(\"Decoded strings written to script_0_decoded.js\")\n```\n\n### Step 5: Resolve Eval Chains Safely\n\nUnwrap eval\u002FFunction constructor chains without executing:\n\n```javascript\n\u002F\u002F Node.js script to safely resolve eval chains\n\u002F\u002F Run in isolated environment: node --experimental-vm-modules deobfuscate.js\n\nconst vm = require('vm');\n\n\u002F\u002F Create sandboxed context with logging\nconst sandbox = {\n    eval: function(code) {\n        console.log(\"=== EVAL INTERCEPTED ===\");\n        console.log(code.substring(0, 500));\n        console.log(\"========================\");\n        return code; \u002F\u002F Return the code instead of executing it\n    },\n    document: {\n        write: function(html) {\n            console.log(\"=== DOCUMENT.WRITE INTERCEPTED ===\");\n            console.log(html.substring(0, 500));\n        },\n        getElementById: function() { return { innerHTML: \"\" }; }\n    },\n    window: { location: { href: \"\" } },\n    atob: function(s) { return Buffer.from(s, 'base64').toString(); },\n    unescape: unescape,\n    setTimeout: function(fn) { if (typeof fn === 'string') console.log(\"TIMEOUT CODE:\", fn); },\n    console: console,\n    String: String,\n    Array: Array,\n    parseInt: parseInt,\n    RegExp: RegExp,\n};\n\nconst context = vm.createContext(sandbox);\n\n\u002F\u002F Load and execute the obfuscated script in sandbox\nconst fs = require('fs');\nconst code = fs.readFileSync('script_0.js', 'utf8');\n\ntry {\n    vm.runInContext(code, context, { timeout: 5000 });\n} catch(e) {\n    console.log(\"Execution error (expected):\", e.message);\n}\n```\n\n### Step 6: Analyze the Deobfuscated Payload\n\nExamine the revealed malicious logic:\n\n```\nDeobfuscated Malware Categories and IOC Extraction:\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nCredential Harvester:\n  - Form action URLs (exfiltration endpoints)\n  - XMLHttpRequest\u002Ffetch destinations\n  - Targeted input field names (username, password, cc_number)\n\nWeb Skimmer (Magecart):\n  - Payment form overlay injection\n  - Card data exfiltration URLs\n  - Keylogger event listeners (onkeypress, oninput)\n\nRedirect Script:\n  - Destination URLs in location.href assignments\n  - Conditional redirects based on user-agent or referrer\n  - Cloaking logic (show benign content to bots)\n\nExploit Kit Landing:\n  - Browser\u002Fplugin version checks\n  - Exploit payload URLs\n  - Shellcode embedded as arrays or encoded strings\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| **Eval Chain** | Nested layers of eval(), Function(), or document.write() calls that each decode one layer of obfuscation before passing to the next |\n| **String Array Rotation** | Obfuscation technique storing all strings in a shuffled array and accessing them by computed index to hide string literals |\n| **Dead Code Insertion** | Adding non-functional code blocks that never execute to increase analysis complexity and confuse pattern matching |\n| **Opaque Predicate** | Conditional expression whose outcome is predetermined but difficult to determine statically; used to obscure control flow |\n| **Anti-Debugging** | JavaScript techniques to detect and thwart browser DevTools or debugger usage including debugger statements and timing checks |\n| **Web Skimmer** | Malicious JavaScript injected into e-commerce sites to steal payment card data from checkout forms (Magecart attack) |\n\n## Tools & Systems\n\n- **CyberChef**: GCHQ's web-based tool for encoding\u002Fdecoding transformations useful for unwinding multi-layer obfuscation\n- **de4js**: Online JavaScript deobfuscator supporting common obfuscation tools (obfuscator.io, JScrambler)\n- **Node.js VM Module**: Sandboxed JavaScript execution environment for safely evaluating obfuscated code with intercepted APIs\n- **Chrome DevTools**: Browser developer tools for stepping through JavaScript execution with breakpoints and console access\n- **JSDetox**: JavaScript malware analysis tool providing execution emulation and deobfuscation\n\n## Common Scenarios\n\n### Scenario: Deobfuscating a Magecart Web Skimmer\n\n**Context**: A compromised e-commerce site has obfuscated JavaScript injected into its checkout page. The script needs deobfuscation to identify the data exfiltration endpoint and determine what customer data was stolen.\n\n**Approach**:\n1. Extract the injected script from the page source (often appended to a legitimate JS file or loaded from an external domain)\n2. Beautify the code and identify the obfuscation technique (typically string array + rotation + hex encoding)\n3. Decode string encoding layers (hex -> Unicode -> base64) using the Python decoder script\n4. Resolve the string array by evaluating the array definition and rotation function\n5. Identify the form targeting logic (querySelector for payment form fields)\n6. Extract the exfiltration URL from the XMLHttpRequest or fetch call\n7. Document stolen data fields and exfiltration endpoint for incident response\n\n**Pitfalls**:\n- Executing obfuscated scripts on a connected system (the script may phone home during analysis)\n- Not removing anti-debugging traps before using browser DevTools (infinite debugger loops)\n- Missing additional obfuscation layers loaded dynamically from external URLs\n- Overlooking base64-encoded inline images or data URIs that may contain additional scripts\n\n## Output Format\n\n```\nJAVASCRIPT MALWARE DEOBFUSCATION REPORT\n=========================================\nSource:           checkout.js (injected into example-shop.com)\nObfuscation:      obfuscator.io (string array + rotation + hex encoding)\nLayers Removed:   3\n\nOBFUSCATION TECHNIQUES IDENTIFIED\n[1] String array with 247 entries, rotated by 0x1a3\n[2] Hex-encoded string references (\\x68\\x65\\x6c\\x6c\\x6f)\n[3] Base64-wrapped eval chain (2 layers)\n[4] Anti-debugging: setInterval debugger trap\n\nDEOBFUSCATED FUNCTIONALITY\nType:             Magecart Payment Card Skimmer\nTarget Forms:     input[name*=\"card\"], input[name*=\"cc_\"]\nData Captured:    Card number, expiration, CVV, cardholder name\nExfil Method:     POST via XMLHttpRequest\nExfil URL:        hxxps:\u002F\u002Fanalytics-cdn[.]com\u002Fcollect\nExfil Format:     JSON { \"cn\": card_number, \"exp\": expiry, \"cv\": cvv }\nTrigger:          Form submit event on checkout page\n\nEXTRACTED IOCs\nDomains:          analytics-cdn[.]com\nIPs:              185.220.101[.]42\nURLs:             hxxps:\u002F\u002Fanalytics-cdn[.]com\u002Fcollect\n                  hxxps:\u002F\u002Fanalytics-cdn[.]com\u002Fgate.js\n```\n",{"name":5,"tags":24,"author":30,"domain":31,"license":14,"version":32,"nist_csf":33,"subdomain":38,"description":7,"mitre_attack":39},[25,26,27,28,29],"malware","JavaScript","deobfuscation","web-malware","script-analysis","mahipal","cybersecurity","1.0.0",[34,35,36,37],"DE.AE-02","RS.AN-03","ID.RA-01","DE.CM-01","malware-analysis",[40,41,42,43,44],"T1027","T1027.010","T1140","T1059.007","T1027.006","main","1eb986d0b0ecc180291597e08eb5a58288843536","skills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fdeobfuscating-javascript-malware","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv","2026-08-25 13:16:33",{"source":8,"skillName":5,"commands":52,"prompt":62,"zipAvailable":63},[53,56,59],{"tool":54,"command":55},"npx","npx skills add vikasvardhanv\u002Fjerry_skills --skill deobfuscating-javascript-malware",{"tool":57,"command":58},"bunx","bunx skills add vikasvardhanv\u002Fjerry_skills --skill deobfuscating-javascript-malware",{"tool":60,"command":61},"pnpm","pnpm dlx skills add vikasvardhanv\u002Fjerry_skills --skill deobfuscating-javascript-malware","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fdeobfuscating-javascript-malware\u002FSKILL.md",true,[65,69,75],{"path":66,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":68,"sourceHtmlUrl":15},"LICENSE","许可证",11255,{"path":70,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":73,"sourceHtmlUrl":74},"references\u002Fapi-reference.md","REFERENCE","参考文档",2029,"https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fdeobfuscating-javascript-malware\u002Freferences\u002Fapi-reference.md",{"path":76,"resourceType":77,"resourceTypeDesc":78,"sizeBytes":79,"sourceHtmlUrl":80},"scripts\u002Fagent.py","SCRIPT","脚本",7239,"https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fdeobfuscating-javascript-malware\u002Fscripts\u002Fagent.py",[82,90,97,104,111,118],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":86,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M7BESR1CJ3H5SP9XM8KYJZ9W","syllabus","Generates a curated supplementary reading list from any course syllabus using Consensus academic search. Grill-me intake (syllabus input format + course audience + year range) plus a grouping forcing-options checkpoint before any search runs — so the reading list matches the course's level and recency need. Parses the syllabus to extract topics and learning outcomes, searches Consensus for recent peer-reviewed papers per topic, and produces a professionally formatted .docx with clickable Consensus links, plain-language summaries calibrated to audience level, and Bloom-higher-order discussion questions tied to course learning goals. Use when the user uploads a syllabus, course outline, or curriculum document and wants supplementary readings (e.g., 'create a reading list from this syllabus', 'find recent papers for my course') — even casual mentions with a syllabus attached should trigger this skill.","MIT","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fsyllabus\u002Fskills\u002Fsyllabus\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":86,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M7BES1YA6R97W7QPMFFM1PED","pulse","Multi-source recency research skill that takes the pulse of any topic across Reddit, Hacker News, the open web, and optionally X\u002FTwitter within a configurable recent window (default 30 days). Forcing intake clarifies topic specificity, angle (trend\u002Fsentiment\u002Fproblems\u002Fopportunities\u002Fcomparison), time window, and platform scope before searching. Returns a synthesized briefing with citations, engagement metrics, and cross-platform pattern analysis. Use when the user requests multi-source recency intelligence on a topic (e.g., 'pulse on [topic]', 'what's happening with [topic]', 'what are people saying about [topic]', 'current conversation about [topic]', 'take the pulse of [topic]', 'trending: [topic]', 'find me info on [topic]'), and for competitor research, trend discovery, tool comparisons, and audience sentiment analysis.","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fpulse\u002Fskills\u002Fpulse\u002FSKILL.md",[],[],{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":86,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":19},"01M7BERNHYGY035AR00VRT03KE","patent","Patent prior-art and landscape intelligence skill — not generic patent help. Commits to one of five sub-use-cases via forcing intake (novelty search \u002F freedom-to-operate \u002F competitive landscape \u002F acquisition diligence \u002F litigation prior-art) before any search runs. Searches Google Patents, Espacenet, USPTO, and optionally Lens.org for citation-graph signals. Output is an editable Word document (.docx) with verdict, ranked closest art (claim-text extracted), CPC-class-aware landscape, family-resolved hits, geographic coverage, FTO flags where applicable, strategy recommendations, and full audit log. Use when the user asks for patent searching or analysis (e.g., 'prior art search for [invention]', 'freedom to operate analysis for [product]'). Produces search signal, not legal advice — always recommends consulting a patent attorney before filing or licensing decisions. Trademark, copyright, and trade-secret questions are out of scope.","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fpatent\u002Fskills\u002Fpatent\u002FSKILL.md",[],[],{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":86,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":19},"01M7BERCK1EAKTWW7R436WAR0J","notebooklm","Browser automation skill for controlling Google's NotebookLM. Use when the user wants anything done in NotebookLM (e.g., 'open NotebookLM', 'check my [name] notebook', 'ask my notebook about X', 'add [source] to NotebookLM', 'generate a Video Overview from my notebook', 'use NotebookLM Studio'). Handles reading and querying notebooks, adding sources (URLs, text, files, YouTube links, synthesized content), generating Studio outputs (Audio\u002FVideo Overviews, Mind Maps, Reports incl. Briefing Doc\u002FStudy Guide\u002FFAQ, Flashcards, Quiz, slide decks, infographics — discover the exact set from the live Studio panel; the UI evolves fast), and creating new notebooks. Requires browser automation environment — fails gracefully when unavailable.","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fnotebooklm\u002Fskills\u002Fnotebooklm\u002FSKILL.md",[],[],{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":86,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":19},"01M7BEQZAZAQRTXFJRY7RHV3TY","litreview","Academic literature orientation skill that searches papers via free keyless APIs (PubMed E-utilities + OpenAlex) by default — with the Consensus MCP as an optional enhancement lane when connected — builds a strategic search plan using PICO (default) or SPIDER \u002F Decomposition \u002F hybrid as fallbacks, and synthesizes findings into a formatted Word (.docx) research guide. Grill-me intake (research question specificity + framework hint + tentative depth) before the recon search; a second forcing checkpoint after Phase 2 confirms framework + sub-areas + depth before searches consume budget. Configurable depth (5\u002F10\u002F20 queries) controls coverage vs. speed. Output is a 'launching pad' — an orientation guide that lets a researcher dive in confidently, not a finished review. Use when the user starts literature-oriented research (e.g., 'litreview on [topic]', 'literature review on [topic]', 'I'm starting a literature review on X', 'I'm writing a paper on X', 'help me research X', 'I'm doing research on X', 'can you help me research X'). Do NOT use for single one-off paper searches wanting a quick list — that's a plain PubMed\u002FOpenAlex (or Consensus) query.","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Flitreview\u002Fskills\u002Flitreview\u002FSKILL.md",[],[],{"skillNo":119,"name":120,"nameZh":6,"description":121,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":86,"licenseFileUrl":6,"sourceHtmlUrl":122,"categories":123,"keywords":124,"publishedAt":19},"01M7BEQKJ45K31QK5VRAQSVJCJ","grants","NIH grant research skill for clinical researchers. Grill-me intake (research idea + career stage + preliminary data + environment + submission posture + known institute targets) locks down the funding strategy before any search runs. Runs a 5-facet Consensus positioning analysis (with draft Significance\u002FInnovation language), maps the research to the right NIH institutes and study sections via RePORTER, finds NOSIs and funded overlap, and produces an editable Word document (.docx) with budget\u002Fscope-aware mechanism recommendations, submission timelines, and a mandatory program officer recommendation. Use when the user asks about research funding or makes any grant-related request (e.g., 'grants for [topic]', 'find grants for my research idea', 'what grants match my research', 'help me find NIH funding', 'grant opportunities for my research'). NIH-only scope — non-NIH funders (PCORI, DOD CDMRP, VA, foundations) are out of scope and flagged at intake.","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fgrants\u002Fskills\u002Fgrants\u002FSKILL.md",[],[]]