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.
Metadata
Release files for sniperpy 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sniperpy-1.0.1.tar.gz | 3.1 kB | Without provenance | Details for sniperpy-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sniperpy-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for sniperpy-1.0.1-py3-none-any.whl |
Total release size: 6.6 kB
Release files / sniperpy-1.0.1.tar.gz
| Download URL | sniperpy-1.0.1.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b0f2a559efcf2a84030f5fb76ad734db80f82dc1ea40b602c1655a71556c4be0
|
|
BLAKE2b-256 checksum How to use checksums |
c7f34fff096e7ccdeb39e371c53817cdbeece196b938c1c18a8556b7ccfcdc3d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.5
|
Release files / sniperpy-1.0.1-py3-none-any.whl
| Download URL | sniperpy-1.0.1-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
729b16e1162e830857848383b69c874b8bb0cfde0a4ed5930c9f5f2bf7517413
|
|
BLAKE2b-256 checksum How to use checksums |
14a894c25c027c9a64a84f8da29fe2faf592b8acb731c626c2a36b87e836f35e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.5
|
Security for sniperpy 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.