Giter VIP home page Giter VIP logo

audit-node-modules-with-yara's Introduction

Audit Node Modules With YARA Rules

(New Rules, Feedbacks, PRs are highly appreciated)

Table of content

Purpose

Software Requirements

  • Docker
  • Docker Compose
  • Makefile

How to use

  1. Clone this repo
git clone https://github.com/rpgeeganage/audit-node-modules-with-yara.git
  1. Execute audit operation
make NODE_MODULE_FOLDER_TO_AUDIT=<path to node_module> run

e.g:

make NODE_MODULE_FOLDER_TO_AUDIT=../restful4up/node_modules run

Report

The report is available in artifacts/output.json.

A sample report looks as follows

[
 {
  "rule": "evil_package_1",
  "string_information": [
   "0x6:$name: \"name\": \"nodecaffe\",",
   "0x1f:$version: \"version\": \"0.0.1\""
  ]
 },
 {
  "rule": "evil_package_2",
  "string_information": [
   "0x6:$name: \"name\": \"sqlserver\",",
   "0x1f:$version: \"version\": \"4.0.5\""
  ]
 },
 {
  "rule": "evil_package_3",
  "string_information": [
   "0x1d:$scripts: \"scripts\":",
   "0x39:$install: \"mkdir -p ~/Desktop/sploit && touch ~/Desktop/sploit/haxx\""
  ]
 }
]

CI/CD Integration

We can use this tool with CI/CD as mentioned below.

#!/bin/bash
make NODE_MODULE_FOLDER_TO_AUDIT=../restful4up/node_modules run

suspicious_file_count=$(jq length artifacts/output.json)

exit $suspicious_file_count

Adding YARA new rules

When we need to add new YARA rules, they must be added to the yara_rules folder with extension .yara.

(Existing rules are created based on this article. They might be outdated)

Sample YARA rule

Let's create a rule for this possible malicious package.

A possible rule is as below.

rule evil
{
    meta:
        name = "[email protected]"

    strings:
        $scripts = /"scripts":/
        $install = /"mkdir -p ~\/Desktop\/sploit && touch ~\/Desktop\/sploit\/haxx"/

    condition:
        all of them
}

Save this rule in yara_rules folder as evil.yara, and good to go

audit-node-modules-with-yara's People

Contributors

rpgeeganage avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

o4isec

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.