Giter VIP home page Giter VIP logo

matissecallewaert / rustiflow Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 7.2 MB

Feature extraction tool build in Rust using eBPF for network intrusion detection

Home Page: https://matissecallewaert.github.io/RustiFlow/

License: MIT License

Rust 99.56% Dockerfile 0.44%
data-science dataset-generation ebpf-programs feature-extraction machine-learning network-analysis network-monitoring network-security packet-analyser packet-capture pcap rust throughput-performance traffic-analysis

rustiflow's Introduction

RustiFlow: A NIDS Feature Extraction Tool

RustiFlow Logo

Overview

This tool is designed for robust and efficient feature extraction in network intrusion detection systems. Leveraging Rust language and eBPF, it excels in processing high volumes of network traffic with remarkable speed and throughput. (When your traffic is already captured, don't worry! It also has a build in pcap reader.) With various pre-defined feature sets and the ability to create custom feature sets, RustiFlow offers a versatile solution for network security applications.

Badge displaying GitHub Actions Workflow Status Badge linking to the project documentation website GitHub license Ubuntu 22 Ubuntu 20

Animated image showing network flows

Key Features

  • High Throughput: Utilizes Rust and the Aya library for eBPF program compilation and execution, ensuring exceptional performance and resource efficiency.
  • Versatile Feature Sets: Offers a variety of pre-defined feature sets (flows) and the flexibility to create custom feature sets tailored to specific requirements.
  • Pcap File Support: Facilitates packet analysis from pcap files, compatible with both Linux and Windows generated files.
  • Diverse Output Options: Features can be outputted to the console, a CSV file, or other formats with minimal effort.

Feature sets

See the wiki for the different feature sets available.

Architecture

RustiFlow Architecture

Using the release binary:

Copy the rustiflow binary that you can find in this repo in releases to a location of your choice or to the /usr/local/bin folder. If it does not have the right permissions, you can run the following command:

chmod +x /path/to/rustiflow

You can then run the binary with the following commands:

See the help menu for the different options available.

RUST_LOG=info rustiflow pcap basic-flow 60 /path/to/pcap.pcap print
sudo RUST_LOG=info rustiflow realtime enp5s0 cic-flow 60 csv /path/to/output.csv

Using the Container:

Make sure that you don't use docker desktop and that you don't have it installed on your machine. If you have this setup, it will not work as intended as the --network host will not link the container to the host network, but to the network of a VM that docker desktop uses.

  • Build the Container:
    docker build -t rustiflow .
  • Run the Container:
    docker run --network host -v /path/on/host:/app rustiflow [ARGS like you are used to]
    Run it with the --privileged flag if you want to capture traffic in real-time.
  • Example:
    docker run --network host -v /home/user/pcap:/app rustiflow pcap basic-flow 60 /app/pcap.pcap print
    docker run --privileged --network host -v /home/matisse/Documents:/app rustiflow realtime enp5s0 cic-flow 60 csv /app/output.csv

Installation Guide for development

Prerequisites:

  • libpcap-dev:
    sudo apt install libpcap-dev
  • Rust Installation:
    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  • Nightly Rust Toolchain:
    rustup install stable
    rustup toolchain install nightly --component rust-src

bpf Linker Installation:

  • For Linux x86_64:
    cargo install bpf-linker
  • For MacOS/Linux (Other Architectures):
    brew install llvm
    cargo install --no-default-features bpf-linker
  • Ubuntu 20.04 LTS Specific:
    sudo apt install linux-tools-5.8.0-63-generic
    export PATH=/usr/lib/linux-tools/5.8.0-63-generic:$PATH

Building the Project

  • eBPF Programs:
    cargo xtask ebpf-ipv4
    cargo xtask ebpf-ipv6
  • User Space Programs:
    cargo build

Usage Instructions

Real-Time Traffic Capture:

  • Command Help:
    RUST_LOG=info cargo xtask run -- realtime --help
    Real-time feature extraction
    
    Usage: rustiflow realtime [OPTIONS] <INTERFACE> <FLOW_TYPE> <LIFESPAN> <METHOD> [EXPORT_PATH]
    
    Arguments:
      <INTERFACE>
              The network interface to capture packets from
    
      <FLOW_TYPE>
              Possible values:
              - basic-flow:  A basic flow that stores the basic features of a flow
              - cic-flow:    Represents the CIC Flow, giving 83 features
              - cidds-flow:  Represents the CIDDS Flow, giving 10 features
              - nf-flow:     Represents a nfstream inspired flow, giving 69 features
              - ntl-flow:    Represents the NTL Flow, giving 120 features
              - custom-flow: Represents a flow that you can implement yourself
    
      <LIFESPAN>
              The maximum lifespan of a flow in seconds
    
      <METHOD>
              Output method
    
              Possible values:
              - print: The output will be printed to the console
              - csv:   The output will be written to a CSV file
    
      [EXPORT_PATH]
              File path for output (used if method is Csv)
    
    Options:
      -n, --no-contaminant-features
              Whether not to include contaminant features
    
      -o, --only-ingress
              Only ingress traffic will be captured
    
          --interval <INTERVAL>
              The print interval for open flows in seconds, needs to be smaller than the flow maximum lifespan
    
      -h, --help
              Print help (see a summary with '-h')

Reading from a Pcap File:

  • Command Help:
    RUST_LOG=info cargo xtask run -- pcap --help
    Feature extraction from a pcap file
    
    Usage: rustiflow pcap [OPTIONS] <FLOW_TYPE> <LIFESPAN> <PATH> <METHOD> [EXPORT_PATH]
    
    Arguments:
      <FLOW_TYPE>
              Possible values:
              - basic-flow:  A basic flow that stores the basic features of a flow
              - cic-flow:    Represents the CIC Flow, giving 83 features
              - cidds-flow:  Represents the CIDDS Flow, giving 10 features
              - nf-flow:     Represents a nfstream inspired flow, giving 69 features
              - ntl-flow:    Represents the NTL Flow, giving 120 features
              - custom-flow: Represents a flow that you can implement yourself
    
      <LIFESPAN>
              The maximum lifespan of a flow in seconds
    
      <PATH>
              The relative path to the pcap file
    
      <METHOD>
              Output method
    
              Possible values:
              - print: The output will be printed to the console
              - csv:   The output will be written to a CSV file
    
      [EXPORT_PATH]
              File path for output (used if method is Csv)
    
    Options:
      -n, --no-contaminant-features
              Whether not to include contaminant features
    
      -h, --help
              Print help (see a summary with '-h')
    

Note: For specific logging levels, adjust RUST_LOG to error for error messages, and debug for debug messages. If you don't want any additional logs, just remove RUST_LOG=info.


rustiflow's People

Contributors

matissecallewaert avatar

Stargazers

小朱 avatar  avatar Tomas Galle avatar Bruno Volckaert avatar  avatar

Watchers

 avatar

rustiflow's Issues

Performance enhancement

Split up the ebpf programs of ipv4 and ipv6 into two parts: tcp and udp.

This creates 4 programs, each in ingress direction and egress direction.

In user space, 8 programs will be loaded in and 8 maps will be hooked.

This will result in being able to use 4 dashmaps. This will make them even smaller and enhance the edit times and lookup times.

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.