Git Product home page Git Product logo

pcap_injector's Introduction

pcapStego

pcapStego is a simple CLI tool for creating network covert channels within a .pcap file. The modified .pcap can be then used for simulations, create datasets or be lively replayed on a network via tools like Tcpreplay. In general, there are two modes:

  • interactive mode, which allows the user to manually establish the covert channel choosing the flow to inject, the secret and the injection mechanism.
  • bulk mode, which enables the automatization of the entire process, combining multiple secrets and injection mechanisms at once.

Each mode consists of two Python scripts that allows the injection and the extraction processes.

Currently pcapStego supports the following protocols and covert channels:

  • IPv4: Type of Service (8 bit/pkt), Time To Live (1 bit/pkt), Identification Number (16 bit/pkt), Timing (1 bit/pkt)
  • IPv6: Flow Label (20 bit/pkt), Traffic Class (8 bit/pkt), Hop Limit (1 bit/pkt), Timing (1 bit/pkt)
  • ICMPv4: Payload (48 bit/pkt), Timing (1 bit/pkt)
  • ICMPv6: Payload (8 bit/pkt), Timing (8 bit/pkt)

Updates

  • 03/02/22: ICMPv4/v6 support for interactive mode. Covert channels: Payload, Timing
  • 10/09/21: IPv4 support for both interactive and bulk mode. Covert channels: Type of Service, Time To Live, Identification Number, Timing
  • 07/09/21: first release, IPv6 support for both interactive and bulk mode. Covert channels: Flow Label, Traffic Class, Hop Limit, Timing

Background

A network covert channel is a hidden communication path laying within a network conversation (see, here for a crash-course on network information hiding). pcapStego can be used to transmit an arbitrary string/content via both storage and timing network covert channels.

Even if network covert channels can be used for licit purposes, e.g., to enforce privacy and to protect sources in investigative journalism, they are mainly exploited by malware to conceal its presence. Specifically, covert channels are regularly used to exfiltrate data, orchestrate attacks, retrieve malicious payloads and support several steps of the cyber kill chain. To this aim, pcapStego comes with two "databases" of attacks that can be used to simulate the transfer of various malicious entities. Specifically:

  • fileless.db: contains several samples of file-less malware that can be injected in the .pcap to simulate the transmission of a threat via a covert channel;

  • payload.db. contains several samples of malicious payloads (both obfuscated and clean) that can be injected in the .pcap for simulating a multi-stage loading architecture.

Commands and payloads are took from FCL repository.

Dependencies

Two libraries are necessary to work with pcapStego.

  • Scapy: pip3 install scapy
  • Pandas: pip3 install pandas

Basic Usage

Let's take a look at the parameters of the injector_int.py script for the interactive mode in the IPv6 folder:

$ python3 injector_int.py [-h HELP] [-r PCAP] [-f FIELD] [-a ATTACK] [-w OUTPUT]

The three mandatory parameters represent:

  • -r PCAP it specifies the .pcap file to read and inject.
  • -f FIELD it specifies the target field to exploit. The available fields are: Flow Label (FL), Traffic Class (TC), Hop Limit (HL), and TIMING.
  • -a ATTACK it specifies the attack to inject. It can be either a txt file or a string.
  • -w OUTPUT it specifies the output pcap file (optional, the default is "output.pcap").

Instead, its counterpart the extractor_int.py script:

$ python3 extractor_int.py [-h HELP] [-r PCAP] [-f FIELD] [-p PACKETS] [-b BITS] [-i IMAGE]

The three mandatory parameters represent:

  • -r PCAP it specifies the .pcap file to read and parse.
  • -f FIELD it specifies the target field to inspect. The available fields are: Flow Label (FL), Traffic Class (TC), Hop Limit (HL), and TIMING.
  • -p PACKETS it specifies the number of packets to extract.
  • -b BITS it specifies the number of bits to extract. It is strongly recommended in the case of the 20-bit Flow Label field, otherwise is optional.
  • -i IMAGE it specifies whether to extract an image.

Similar commands are used for the bulk mode:

$ python3 injector_bulk.py [-h HELP] [-r PCAP] [-a ATTACK] [-w OUTPUT] 

The two parameters represent:

  • -r PCAP it specifies the .pcap file to read and inject.
  • -a ATTACK it specifies a .txt file containing multiple attacks. It is formatted in the following form: [FIELD], [ATTACK].
  • -w OUTPUT it specifies the output pcap file (optional, the default is "output.pcap").

The extraction process takes advantage of the .csv generated by the injection:

$ python3 extractor_bulk.py [-h HELP] [-r PCAP] [-i INJECTED-CSV]

The two parameters represent:

  • -r PCAP it specifies the .pcap file to read and parse.
  • -i INJECTED-CSV it specifies the .csv generated by the injection that contains all the information of the injected flows.

Example Usages

$ python3 injector_int.py -r pcap_example.pcap -f TC -a hello_world.txt

This command will inject the payload contained in the "cmd.txt" into the Traffic Class field of a flow chosen by the user within the specified pcap. Each attack is tracked in a csv file for future purposes.

$ python3 extractor_int.py -r TC_a=hello_world.txt_pcap_example.pcap -f TC -p 11

This command will extract the Traffic Class values of the first 11 packets of a flow chosen by the user within the specified pcap.

For bulk mode, instead:

python3 injector_bulk.py -r pcap_example.pcap -a attacks.txt
python3 extractor_bulk.py -r attacks.txt_pcap_example.pcap -i injected_flows.csv

Similar commands can be used for the IPv4 protocol.

References

Papers on Stegomalware

Paper on IPv6 Covert Channels

  • W. Mazurczyk, K. Powójski, L. Caviglione, IPv6 Covert Channels in the Wild, in Proceedings of the Third Central European Cybersecurity Conference (CECC 2019), Munich, Germany, pp. 1 - 6, Nov. 2019.

Tools, Curated Lists and Attacks

  • Steg-in-the-wild: a curated list of real-world threats, attacks and malware leveraging information hiding, covert channels and steganography.
  • Malware - Fileless Command Lines: a repository containing malicious command-lines and malware execution processes.

pcap Traces

Acknowledgement

This work has been supported by EU Project SIMARGL - Secure Intelligent Methods for Advanced Recognition of Malware and Stegomalware, Grant Agreement No 833042.

pcap_injector's People

Contributors

ocram95 avatar lucacav avatar

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.