Skip to content

About

A Python-based security simulation that models Sybil attacks on wireless sensor networks and detects fraudulent identities through RSSI-based clustering analysis.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SybilShield — Sybil attack detection for wireless sensor networks

🛡️ SybilShield

Sybil attack simulation & RSSI-based detection for Wireless Sensor Networks

Python NumPy Matplotlib Topic

English · Türkçe


📡 Overview

In a Sybil attack, a single malicious device claims many identities at once. In a wireless sensor network this lets one compromised node pose as dozens of fake sensors, poison the data and out-vote honest nodes.

SybilShield simulates the attack and a lightweight defense that runs on the sink / SOC node. The defense needs no cryptography and no extra hardware, only the signal strength the radio already measures.

Key idea: you can fake an ID, but you can't fake physics. Every fake identity is transmitted from the same physical device, so they all arrive with an almost identical RSSI. Honest nodes are spread across the field and their RSSI values differ. A tight RSSI cluster of many IDs reveals one device hiding behind many names.


⚙️ How It Works

1. Signal model

Each packet's RSSI is computed with a log-distance path-loss model plus Gaussian noise (nodes.py):

RSSI = TX_POWER − 10 · n · log10(d) + N(0, σ)
TX_POWER = −20 dBm   ·   n (path-loss exponent) = 2.0
Sender Noise σ Why
Legitimate node 2.0 dBm normal radio fluctuation
Attacker, disguised as a server 2.0 dBm blends in with honest traffic
Attacker, Sybil ghost IDs 0.2 dBm same antenna, same spot, so nearly identical RSSI

2. Detection: sliding-window RSSI clustering

SinkNode.run_sybil_detection() runs periodically on the sink:

  1. Keep a neighbor table of every sender ID with its RSSI readings.
  2. Compute the mean RSSI per ID and sort the IDs by it.
  3. Slide a window and group IDs whose mean RSSI is within RSSI_THRESHOLD = 3.0 dBm of the group's first member.
  4. Any group with MIN_CLUSTER = 5 or more IDs is flagged as a Sybil cluster.
  5. Flagged IDs go to the blacklist, and all their future packets are dropped at the sink.

3. Attack timeline (animasyon.py)

Phase Steps What happens
🟢 Normal operation t = 0 – 19 Two compromised devices (SRV-APP, SRV-BCKP) act as normal servers to build trust
🔴 Sybil attack t = 20 – 49 They flood the network with ghost IDs (GHOST-A-xxx, GHOST-B-xxx)
🛡️ Defense active t ≥ 30, every 10 steps The SOC runs RSSI clustering and blacklists the detected clusters
⛔ Replay blocked t = 50 – 74 The attackers retry with already-issued IDs, and every packet is dropped

🗺️ Scenario: Corporate Server Network vs. APT-BlackNet

Node          Position    Role
SOC_MERKEZI   ( 0,   0)   Security Operations Center (sink)
SRV-WEB       ( 0,   5)   Web server
SRV-DB        (-7,   0)   Database server
SRV-FTP       (-4,  -5)   File server
SRV-MAIL      ( 0, -28)   Mail server
SRV-DNS       (15, -26)   DNS server
SRV-APP  *    ( 8,   8)   Compromised: emits GHOST-A-xxx
SRV-BCKP *    (-11, 13)   Compromised: emits GHOST-B-xxx

📊 Results

Both scripts use a fixed seed (42), so the results are reproducible.

Animated SOC scenario (animasyon.py: 5 servers, 2 attackers)

Metric Value
Ghost IDs generated 120
IDs blacklisted 122: all 120 ghost IDs + the 2 compromised server IDs
Legitimate servers blacklisted (false positives) 0
Packets dropped from blacklisted IDs 135, of which 97 were in the replay phase

Static analysis (main.py: 4 sensor nodes, 1 attacker)

Metric Value
Fake IDs generated 50
IDs blacklisted 50 (100% detection)
Sybil packets dropped / accepted before detection 47 / 53
Legitimate packets accepted 280
Static result: topology, mean RSSI per ID, cumulative packet flow and detection results
Output of main.py: topology · mean RSSI per ID (ghost IDs line up on the attacker's RSSI) · packet flow · detection results

📂 Project Structure

Kablosuz Ağ/
├── nodes.py               # Node, MaliciousNode, SinkNode (+ detection algorithm)
├── animasyon.py           # Live animated SOC dashboard (corporate scenario)
├── main.py                # Static 4-panel analysis → simulation_result.png
├── simulation_result.png  # Output of main.py
├── requirements.txt       # numpy, matplotlib
└── README.md              # Detailed bilingual (EN/TR) documentation

🚀 Getting Started

git clone https://github.com/phevyy/SybilShield.git
cd "SybilShield/Kablosuz Ağ"
pip install -r requirements.txt

python animasyon.py   # live SOC dashboard
python main.py        # static analysis + simulation_result.png

Dashboard controls: SPACE pause / resume · ESC close


🔭 Possible Extensions

  • Port the sink logic to Contiki OS + Cooja (the original target platform) in C
  • Capture the simulated traffic with Wireshark and inspect the spoofed IDs in packet headers
  • Mobile attackers and RSSI drift, combining RSSI with time-of-arrival or multiple receivers
  • Adaptive thresholds instead of a fixed ±3 dBm window

🇹🇷 Türkçe Özet

SybilShield, Kablosuz Sensör Ağlarında (WSN) Sybil saldırısını ve buna karşı RSSI tabanlı bir savunmayı simüle eder. Sybil saldırısında tek bir kötü niyetli cihaz, aynı anda onlarca sahte kimlikle ağa katılır.

Temel fikir: Kimlik taklit edilebilir ama fizik taklit edilemez. Bütün sahte kimlikler aynı fiziksel cihazdan yayın yaptığı için merkeze neredeyse aynı sinyal gücüyle (RSSI) ulaşır. SOC düğümü ID'leri ortalama RSSI değerlerine göre sıralar. Aralarındaki fark ±3 dBm içinde kalan ve en az 5 kimlikten oluşan grupları Sybil kümesi olarak işaretler ve kara listeye alır. Bu kimliklerden gelen sonraki tüm paketler düşürülür.

Kurumsal senaryoda iki ele geçirilmiş sunucu (SRV-APP, SRV-BCKP) 120 sahte kimlik üretir. Bu kimliklerin hepsi ve iki saldırgan cihaz tespit edilir. Hiçbir meşru sunucu yanlışlıkla engellenmez. Detaylı iki dilli dokümantasyon için Kablosuz Ağ/README.md dosyasına bakabilirsiniz.


📚 References

  • Douceur, J. R. (2002). The Sybil Attack. IPTPS.
  • Newsome, J., Shi, E., Song, D., Perrig, A. (2004). The Sybil Attack in Sensor Networks: Analysis & Defenses. IPSN.
  • Demirbas, M., Song, Y. (2006). An RSSI-based Scheme for Sybil Attack Detection in Wireless Sensor Networks. WoWMoM.
Built by Fikret Emre Sınmaz · Network & Security

About

A Python-based security simulation that models Sybil attacks on wireless sensor networks and detects fraudulent identities through RSSI-based clustering analysis.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages