Skip to content
emilioaabPublic

About

Network anomaly / DDoS detection tool (defensive) — Python, Scapy, Flask

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

ShieldNet

Know the moment your machine is being flooded, and who is really doing it.

A zero-config, local-only flood/DoS detector. It watches the traffic reaching your computer, alerts the moment a flood starts, explains the attack in plain language and points at the real sender, even when the source IPs are forged.

version python platform tests privacy scope

ShieldNet dashboard showing a detected SYN flood with the forged source IPs traced to one MAC address

Why ShieldNet

A flood rarely announces itself. You see "the internet is slow" or "my server stopped answering", and when you do open a packet capture, the attacker has forged thousands of different source addresses.

Enterprise IDSs like Snort, Suricata and Zeek can catch this, but they are built for network teams and need rules, tuning and log pipelines. Mac firewalls like Little Snitch and LuLu watch your apps going out, not floods coming in.

ShieldNet fills that gap:

  • Unmasks forged senders. When hundreds of source IPs come from one network card, ShieldNet flags them as forged and shows the real sender's MAC address (and its IP, where ARP knows it).
  • Zero configuration. Built-in thresholds and a sliding window. No rule files.
  • Local-only and private. Listens on 127.0.0.1, with no cloud, accounts, telemetry or CDNs. Packet payloads are never stored.
  • Explains, not just alerts. It reports what the attack is, when it started and ended, peak rate and top sources.
  • Low false-positive design. Replies are matched against requests this host actually sent, so your own browsing and pings never count as attacks.
  • Works on recordings too. It analyzes Wireshark/tcpdump captures offline, with no admin rights needed.

Full positioning, competitive landscape and roadmap: docs/PRODUCT.md.

Features

Attack How ShieldNet recognises it Status
TCP SYN flood Too many connection requests (SYN, no ACK) aimed at this host inside a sliding time window Shipped
TCP SYN-ACK flood (reflection) SYN-ACK replies for connections this host never opened. Real handshakes are matched and ignored. Shipped
Ping of Death An ICMP fragment whose end lies beyond 65,535 bytes, the largest legal IP datagram Shipped
ICMP Smurf Echo replies this host never asked for, or ICMP sent with this host's IP from another network card Shipped
UDP flood High rate of UDP datagrams aimed at this host Shipped
ICMP ping flood High rate of echo requests aimed at this host Shipped

Each incident report includes start and end time, attack packet count, peak rate in the window, distinct source IPs, top source IPs, top source MAC addresses (with the IP resolved via ARP) and a "source IPs look forged" verdict.

Interfaces

  • Local web dashboard at http://127.0.0.1:8765 with live updates over WebSocket and capture-file upload.
  • Command line: analyze prints a readable report, or JSON with --json.
  • macOS app (beta): an always-on background service, a menu-bar shield icon (check = quiet, ! = attack, pause bars = paused; click opens the dashboard) and a native notification the moment a flood starts.

How detection works

flowchart LR
    NIC[(Network card)] -->|Scapy sniffer<br/>root| P[packets.py<br/>packet -> PacketInfo]
    PCAP[(.pcap file)] -->|no root needed| P
    P --> D[detector.py<br/>pure logic, unit-tested<br/>sliding-window counters<br/>reply matching<br/>MAC attribution]
    D -->|/api/state + WebSocket<br/>127.0.0.1 only| W[Web dashboard]
    D -->|polls /api/state| M[Menu-bar icon +<br/>notifications]
    D --> C[CLI report / JSON]
Loading
  1. Parse. Each packet becomes a small PacketInfo record (addresses, ports, flags, fragment info). No payloads are kept.
  2. Classify. The detector decides whether the packet is attack-shaped. For example, a SYN-ACK is attack-shaped only if this host never sent the matching SYN.
  3. Count. Each attack type has its own sliding window (default 5 s). Crossing the threshold opens an incident, and an empty window closes it.
  4. Attribute. Sources are tallied by IP and by MAC. Twenty or more source IPs with over 80% from one MAC means the IPs are forged, and the MAC is the real sender (or your router, if the flood comes from the internet).

detector.py has no Scapy and no I/O, so the same rules run live, on files and in tests.

Quick start

macOS app (always-on) (beta)

Build and install instructions are in docs/BUILD_MAC.md. The app installs a privileged background service (shieldnet service, a launchd daemon) and a menu-bar app (shieldnet tray) that runs as your user.

From source (macOS / Linux)

git clone https://github.com/emilioaab/shieldnet.git
cd shieldnet
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

sudo .venv/bin/python run.py          # live capture needs root; opens http://127.0.0.1:8765

On Windows, run it from source in an administrator terminal with Npcap installed. The packaged Windows app is on the roadmap.

Analyze a capture file (no root)

python3 run.py analyze capture.pcap                     # readable report
python3 run.py analyze capture.pcap --target 192.168.1.10 --json

You can also drag the file onto the dashboard's upload box.

Options

--window 5            sliding window in seconds
--syn-flood 100       SYN packets in the window that raise the alert
--synack-flood 50
--ping-of-death 1
--smurf 50
--udp-flood N / --icmp-flood N   (next release; see --help for defaults)
dashboard --port 8765 --iface en0 --no-browser

Try it safely

You don't need to attack anything to see ShieldNet work. samples/ contains simulated captures built offline by tests/make_samples.py. Nothing is sent on any network.

python3 run.py analyze samples/all_attacks.pcap
4 incident(s):

  [TCP SYN Flood]  2023-11-15 00:13:25 -> 2023-11-15 00:13:27
    attack packets: 600   peak in window: 600   distinct source IPs: 599
    source IPs look forged; the network card below is the real sender (or your router)
    MAC bb:bb:bb:bb:bb:66  (ip 192.168.1.66)  600 packets
  ...
Sample What it shows
normal.pcap Ordinary browsing and pings. It should produce no alerts.
syn_flood.pcap 600 SYNs from 599 forged IPs, all from one MAC
synack_reflection.pcap Unsolicited SYN-ACKs reflected via the router
ping_of_death.pcap An oversized fragmented ICMP echo
smurf.pcap Echo replies this host never asked for
all_attacks.pcap All of the above in one minute

Run the tests:

python3 -m pytest -q tests
python3 tests/make_samples.py      # regenerate samples/

Project structure

shieldnet/
  detector.py     pure detection logic (no Scapy, no I/O), fully unit-tested
  packets.py      Scapy packet -> PacketInfo; capture-file analysis
  capture.py      live background sniffer feeding the detector
  server.py       Quart web server, REST + WebSocket, 127.0.0.1 only
  __main__.py     command line (dashboard, analyze, service, tray)
  templates/, static/   dashboard (no external CDNs; all text rendered safely)
samples/          simulated attack captures (safe to share)
tests/            sample generator + pytest suite
docs/             product brief, demo script, landing page (index.html)
run.py            entry point

Also: service.py and tray.py (macOS service and menu-bar app), auth.py (control-API token), macos/ (launchd + install scripts), packaging/ and scripts/ (PyInstaller/.dmg build).

Security and responsible use

ShieldNet is a defensive tool. It detects attacks against the machine it runs on and never generates attack traffic. Run live capture only on machines and networks you own or are authorized to monitor. Captures can contain private data, so treat them carefully.

Roadmap

Next up: alert history, exportable incident reports, firewall-rule suggestions, a browser-only capture analyzer, then a Windows app and baseline learning. See docs/PRODUCT.md#7-roadmap and CHANGELOG.md.

License

MIT — see LICENSE. Use it only on networks you own or are authorized to monitor.


Student project at SCE (Software Engineering, cybersecurity track) by @emilioaab. Built with Python, Scapy, Quart and vanilla JS.

About

Network anomaly / DDoS detection tool (defensive) — Python, Scapy, Flask

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages