Skip to content

Secure Node.js scripts with in memory decryption and two factor authentication

Notifications You must be signed in to change notification settings

taythebot/cypher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cypher

Secure Node.js scripts with in memory decryption and two factor authentication

I am not responsible for your actions. Use at your own discretion.

Features

  • Randomly generated 32 character password
  • Uses AES-256-CBC encryption
  • Uses Scrypt to derive encryption key (Protects against bruteforce attacks)
  • OTP support for two factor authentication (OTP Secret is encrypted)
  • Calls garbage collector to clear memory after decryption (Protects against memory dump attacks)
  • Works with Vercel's pkg to compile into executable (Use --options expose_gc when building)

Use cases

  • Securely distribute Node.js scripts
  • Protect scripts from unauthorized execution
  • Protect script source code

How it works

  1. All local imports are localized (Disabled due to bugs)
  2. Implement OTP if enabled (--otp flag)
    1. Generate OTP secret
    2. Generate OTP code and wrap original code (OTP code & secret is encrypted)
  3. Generate random password
  4. Derive encryption key using Scrypt
  5. Encrypt code using AES-256-CBC
  6. Generate final code with decryption methods
  7. Write final code to output file

Check out the example in the example folder

Usage

node cypher --input <file> --output <file> --otp

You must use --expose_gc option when executing the output script

node --expose_gc <file>

Localize imports

You must localize your imports manually for the moment

Original

const lib = require('./lib/test')

lib()

Localized

const lib = (module.exports = () => console.log('test'))

lib()

Compile using Vercel Pkg

pkg <file> --options expose_gc

Todo

  • Automatic compiler
  • Randomize function names
  • Add second layer of encryption using OTP

About

Secure Node.js scripts with in memory decryption and two factor authentication

Topics

Resources

Stars

Watchers

Forks