Skip to main content

Extract signatures from IoT event network traffic

Project description

signature-extraction

GitHub License GitHub language count

signature-extraction is a Python library for extracting signatures from network traffic. It is designed to be used in the context of smart home network security.

Features

This library is composed of three monolithic scripts that can be used independently. The scripts are:

  • Read pcap files and extract headers from packets (packet-translator.py) ;
  • Merge packets into flows (stream-identifier.py) ;
  • Extract the recurring patterns from the flows (signature-extractor.py) ;
  • Generate profile.yaml files containing the extracted signatures (WIP).

All the scripts can be used as standalone scripts, arguments can be passed to them using the command line.

profile.yaml files generated are the one compatible with the smart-home-firewall by @fdekeers.

Installation

Requirements: Python 3.8 or higher, pip and git.

Clone the repository and install the dependencies using pip.

git clone https://github.com/smart-home-network-security/smart-home-firewall
cd smart-home-firewall
pip install -r requirements.txt

Usage

The library can be used as a standalone script or as a Python library.

python3 ./scripts/main.py DEVICE IPV4 PCAP [PCAP ...] [-o OUTPUT_DIR] [-h]
  • Positional arguments:
    • DEVICE: name of the device to analyze the traffic from.
    • IPV4: IPv4 address of the device.
    • PCAP: path(s) to the PCAP file(s) to analyze.
  • Optional arguments:
    • -o OUTPUT_DIR: path to the output directory.
      • If not specified, the working directory is used.
    • -h: display the help message.

This folder will be used to store the extracted signatures and all the intermediate files. It should be readable and writable for the user running the script.

Interpreting the results

Pattern X: IP Addresses: ('hosta.com', 'hostb.com')
Protocol: TCP
Ports: [(443, {'number': 2, 'host': ['hostb.com']}), (48597, {'number': 1, 'host': ['hosta.com']}), (54457, {'number': 1, 'host': ['hosta.com']})]
Fixed port: 443 -> ['hostb.com']
Application Data: {'Length': {9608: 1, 9635: 1}, 'ApplicationSpecific': {'https': 2}, 'nbPacket': {22: 1, 24: 1}}
  • Pattern X is the signature number.
  • IP Addresses are the IP addresses involved in the signature.
  • Protocol is the protocol used in the signature.
  • Ports are the ports used in the signature with the number of packets and the hostnames. By default, it will only show the three most used ports for each host (usually, one of them is fixed).
  • Most Used Port is the port most used in the signature. Useful to identify the application or when the port is not standard.
  • Application Data contains the length of the packets, the application specific data and the number of packets.

Possible improvements: make the output more readable, add more information about the signature.

The profile.yaml is generated in the same folder as the pcap file. It contains the extracted signatures but can also provide incorrect signatures. It is recommended to check the generated profile.yaml file before using it and match the given information with those given in the terminal after the script execution.

[!TIP] You can find the output of the script also in the pattern.txt file in the same folder as the pcap file.

License

This project is licensed under the GPL-3.0 License - see the LICENSE file for details.

Project Status

This work is part of the Smart Home Network Security research project made by @fdekeers and UCLouvain.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

signature_extraction-0.2.0.tar.gz (53.3 kB view details)

Uploaded Source

Built Distribution

signature_extraction-0.2.0-py3-none-any.whl (45.4 kB view details)

Uploaded Python 3

File details

Details for the file signature_extraction-0.2.0.tar.gz.

File metadata

  • Download URL: signature_extraction-0.2.0.tar.gz
  • Upload date:
  • Size: 53.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for signature_extraction-0.2.0.tar.gz
Algorithm Hash digest
SHA256 17c8b82a3120c7e1cb87dbf315e875de2c11aa23ae4fcd8cbed83697d62f8115
MD5 16bb2c001949167287e7e6265058eabf
BLAKE2b-256 a50b352c23ea1120a66a1a4e3b01c15620ed7d53351b12744755ac72f44a943a

See more details on using hashes here.

File details

Details for the file signature_extraction-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for signature_extraction-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee1594995d49d561838e62cad67a4744561880e855c6823715c6c052ac53e6fd
MD5 a3c15cff43d0c3550c9b57edb1f6a56f
BLAKE2b-256 ac149b0f2a182737e39877183a59bc1d64a2b2e410166da1fa80d3c8f9e78117

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page