Skip to content

Latest commit

History

History
83 lines (69 loc) 路 1.97 KB

obfuscated-code.md

File metadata and controls

83 lines (69 loc) 路 1.97 KB

Obfuscated code

Code Severity i18n Experimental
obfuscated-code Critical sast_warnings.obfuscated_code 鉁旓笍

Introduction

An experimental warning capable of detecting obfuscation and sometimes the tool used.

JS-X-Ray is capable to detect the following internet tools:

Example of obfuscated code is in the root examples directory.

Technical note

A complete G.Drive document has been written to describe the patterns of obfuscation tools and some way of detecting them:

Caution

This is an early (beta) implementation

Example

The following code uses Morse code to obfuscate its real intent. This was used in an attack and I find it quite funny so i implemented morse detection 馃槀.

function decodeMorse(morseCode) {
  var ref = {
    '.-': 'a',
    '-...': 'b',
    '-.-.': 'c',
    '-..': 'd',
    '.': 'e',
    '..-.': 'f',
    '--.': 'g',
    '....': 'h',
    '..': 'i',
    '.---': 'j',
    '-.-': 'k',
    '.-..': 'l',
    '--': 'm',
    '-.': 'n',
    '---': 'o',
    '.--.': 'p',
    '--.-': 'q',
    '.-.': 'r',
    '...': 's',
    '-': 't',
    '..-': 'u',
    '...-': 'v',
    '.--': 'w',
    '-..-': 'x',
    '-.--': 'y',
    '--..': 'z',
    '.----': '1',
    '..---': '2',
    '...--': '3',
    '....-': '4',
    '.....': '5',
    '-....': '6',
    '--...': '7',
    '---..': '8',
    '----.': '9',
    '-----': '0',
  };

  return morseCode
    .split('   ')
    .map(a => a.split(' ').map(b => ref[b]).join(''))
    .join(' ');
}

var decoded = decodeMorse(".-- --- .-. -..   .-- --- .-. -..");
console.log(decoded);