Giter Site home page Giter Site logo

mavroudisv / non-determinismdetectorjs Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 1.0 7.65 MB

Prototype that analyses JavaScript malware samples and detects those that exhibit non-deterministic behavior in order to evade detection.

License: MIT License

JavaScript 84.86% CSS 0.44% Python 5.02% HTML 9.68%
malware malware-analysis malware-detection malware-research randomness-testing non-determinism javascript

non-determinismdetectorjs's Introduction

Info

This is a prototype that analyses JavaScript malware samples and detects those that exhibit non-deterministic behavior in order to evade detection. The most interesting part of it are the two js scripts that lock and log native js functions (see 'scripts' directory). We focused on functions that can be used as sources of randomness but any function can be locked.

I developed it during my summer internship in 2014 at UCSB Seclab working with Alex Kapravelos, Luca Invernizzi, Giovanni Vigna and Chris Kruegel.

Installation

  • Python 2.7 (If interested in porting it into Python3 let me know!)
  • Firefox
  • Selenium

Usage

In one terminal window run (or run it in the backgroud instead):

$ python proxy.py

In another terminal:

$ python main.py

How it works

Proxy.py

The proxy captures the requested domains and when a "flag" domain is requested it generates "requests.log", containing all the requests made.

Main.py

The main.py works as follows:

  1. It attaches the logging.js on the examined webpage to capture all the js functions that are executed (each "call" is an object with a unique id, its input, output, caller etc). Additionally, proxy.py captures the network requests

  2. From the captured "calls", it creates a list with those which are suspicious for non-deterministic behavior (random etc)

  3. It then iterates on this list and attaches lock.js each time. This ensures that all the functions return the same values EXCEPT the one we examine for non-deterministic requests.

  4. The requests are compared with the ones captured on step 1. If they are not exactly the same, the non-locked function causes non-deterministic execution.

Known Shortcomings/Improvements

  • This approach cannot reliably detect all cases where randomness is "fetched" from external sources.

  • Build execution tree based on the call log. Useful for visual inspection of the malware.

non-determinismdetectorjs's People

Contributors

mavroudisv avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

71890799

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.