# SYN Flood detection

**URL:** <https://community.zeek.org/t/syn-flood-detection/3451>\
**Category:** Zeek\
**Created:** [January 26, 2015, 6:32pm UTC](https://community.zeek.org/t/syn-flood-detection/3451 "2015-01-26T18:32:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rens\_van\_der\_Heijden](https://avatars.discourse-cdn.com/v4/letter/r/9fc348/32.png) [@Rens\_van\_der\_Heijden](https://community.zeek.org/u/Rens_van_der_Heijden)\
**Post date:** [January 26, 2015, 6:32pm UTC](https://community.zeek.org/t/syn-flood-detection/3451/1 "2015-01-26T18:32:35Z")

</div>

Hi everyone,

As part of demonstrating Bro in a class setting, I’m preparing an exercise that asks students to detect SYN floods. I found some older Bro code that does this (and referenes to it on Robin Sommer’s slides from a 2007 talk):  
[http://www.gnu-darwin.org/www001/src/ports/security/bro/work/bro-1.2.1/policy/synflood.bro](http://www.gnu-darwin.org/www001/src/ports/security/bro/work/bro-1.2.1/policy/synflood.bro)  
I noticed, however, that I couldn’t find anything similar in SumStats. It might be that I missed something, but maybe SYN floods just aren’t as interesting anymore? Does anyone know what happened there?

Anyway, I tried to write a quick script to test it out first, which turned out to use a lot of memory (at least, in my perception – perhaps it’s an issue with the VM I’m testing it in though), which I guess might be the reason. Here’s the code I used (unlike [`/scripts/policy/misc/scan.bro`](https://www.bro.org/sphinx/_downloads/scan.bro), this script uses connection\_SYN\_packet, which means we can detect SYNs that are not responded to):

event connection\_SYN\_packet(c:connection, pkt: SYN\_packet)  
{  
SumStats::observe(“tcp.syn.rcvd”, [$host=c$id$orig\_h], [$str=fmt("%s",c$id$resp\_h)]);  
}  
function f(ts:time, key:SumStats::Key, result:SumStats::Result)  
{  
local r=result[“tcp.syn.rcvd”];  
print fmt(“Saw %d SYNs from %s”, r$num, key$host);  
}  
event bro\_init()  
{  
local r1 = SumStats::Reducer($stream=“tcp.syn.rcvd”, $apply=set(SumStats::SUM));  
SumStats::create([$name=“tcp.syn.scan”, $epoch=30min, $reducers=set(r1), $epoch\_result=f, $epoch\_finished(ts:time\_ = { print " – new Epoch --";}]);

Greetings,  
Rens

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/zeek/original/1X/f09d732bc2cc7c7cc7e35db67cf4e1d5233ce7a7.png) [@system](https://community.zeek.org/u/system)\
**Post date:** [May 6, 2022, 3:42pm UTC](https://community.zeek.org/t/syn-flood-detection/3451/2 "2022-05-06T15:42:24Z")

</div>

Closed on May 6, 2022, 3:42pm UTC


