Skip to main content

A Python package to analyze SMB2 packets from pcap files

Project description

Sniperpy: SMB2 Packet Analyzer

sniperpy is a Python package designed to extract and analyze SMB2 packets from PCAP files. It helps security engineers quickly retrieve relevant SMB2 data like Create and Close requests/responses from packet captures.

Features

  • Extract SMB2 Create and Close requests/responses from PCAP files.
  • Parse and analyze metadata (source/destination IPs, ports).
  • Save extracted metadata as a JSON file.

Installation

You can install sniperpy using pip:

pip install sniperpy

Usage

After installing the package, you can import it and use the functions provided to work with SMB2 packets in your PCAP files.

Example Code

from sniperpy import extract_smb_packets, parse_smb_packets, save_extracted_files, SMBExtractorError

# Specify the path to your pcap file
pcap_file = "path_to_your_pcap_file.pcap"

try:
    # Extract SMB packets from the PCAP
    smb_packets = extract_smb_packets(pcap_file)

    # Parse SMB packet metadata
    metadata = parse_smb_packets(smb_packets)

    # Optionally, save the metadata to a JSON file
    save_extracted_files(metadata, output_dir="output_directory")

    # Print metadata to the console
    for entry in metadata:
        print(entry)

except SMBExtractorError as e:
    print(f"An error occurred: {e}")

Example output

{
    "Packet Type": "SMB2 Create Request",
    "Source IP": "192.168.1.100",
    "Source Port": 445,
    "Destination IP": "192.168.1.101",
    "Destination Port": 139
}

Functions Overview

  • extract_smb_packets(pcap_file): Extracts SMB2 packets from the provided pcap file.
  • parse_smb_packets(smb_packets): Parses SMB2 packets to extract metadata (IP addresses, ports, etc.).
  • save_extracted_files(metadata, output_dir): Saves the parsed metadata as a JSON file in the specified output directory.
  • SMBExtractorError: Custom exception to handle errors related to SMB packet extraction and parsing.

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

sniperpy-1.0.1.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sniperpy-1.0.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file sniperpy-1.0.1.tar.gz.

File metadata

  • Download URL: sniperpy-1.0.1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for sniperpy-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b0f2a559efcf2a84030f5fb76ad734db80f82dc1ea40b602c1655a71556c4be0
MD5 0eb3db13a19683189f120e238943ad0f
BLAKE2b-256 c7f34fff096e7ccdeb39e371c53817cdbeece196b938c1c18a8556b7ccfcdc3d

See more details on using hashes here.

File details

Details for the file sniperpy-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: sniperpy-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for sniperpy-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 729b16e1162e830857848383b69c874b8bb0cfde0a4ed5930c9f5f2bf7517413
MD5 1449e707a8dce01b93f1c88ae1b444e5
BLAKE2b-256 14a894c25c027c9a64a84f8da29fe2faf592b8acb731c626c2a36b87e836f35e

See more details on using hashes here.

Supported by

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