GithubHelp home page GithubHelp logo

fnzv / phalanx Goto Github PK

View Code? Open in Web Editor NEW
42.0 6.0 15.0 121 KB

DDos detection and mitigation system written in Go (Experimental)

License: GNU General Public License v3.0

Go 98.27% Shell 1.73%
ddos-protection ddos-detection netflow-v9

phalanx's Introduction

phalanx

DDos dedection and mitigation system written in Go (Experimental)

Project components:

  • collectord
  • detectord
  • viewer
  1. collectord is the daemon responsible to collect Netflow or Pcap data and forward it to Redis for post-analysis.
    When configured on "host-based" mode the collector will gather data from an attached interface (via libpcap.. don't use it on high traffic rates) and send all the occurencies of an IP address to Redis
    (Example 100 requests from 8.8.8.8 --> will create on redis 8.8.8.8 --> 100 ).
    If Netflow is configured the collector will read all the netflow v9 records from port 0.0.0.0:9995 and send them into redis with the same logic but this time we take note also of Packets and Bytes sent by the IP address.
    An Influx output can be configured to collect Netflow data such as network Throughput,Packets,Requests. (If empty the collector won't do nothing)

  2. detectord reads all the collected data from Redis and apply the thresholds defined in the configuration file (detector.conf). Bans can result into ipset rules added into the current host or trigger a bash script to launch remote commands/tools (ssh into machine, shutoff, bgp announce)

  3. viewer is a client that reads current information from redis and prints it on screen (current bans, packets and bytes if netflow is enabled)

Requirements:

- All golang deps & golang
- sudo apt-get install libpcap0.8-dev
- redis-server
- (optional) influxdb and grafana for dashboarding https://grafana.com/dashboards/4208

Install

  • Git clone project into the machine
  • Get all deps with: go get -d ./...
  • Edit config files under conf/ (Example.. choose between host-based or netflow..thresholds.. on both conf files)
  • Build time!! go build detectord.go && go build collectord.go && go build viewer.go
  • Start the services: ./service start and to stop them ./service stop or kill processes via killall collectord && killall detectord

Scenarios

  • Host-based: Install Phalanx on Front-End machine that distribute traffic to a few web servers of a constant targeted site by Applicative DDoS attacks (Reaching maximum Apache workers or php fpm processes) from bots or crawlers (Add to whitelist all customers and "clean" IPs) then let Phalanx ban via configured thresholds.

  • Netflow: Get Netflow traffic from router or a configured linux box (An easy way to export nf from linux machines is: https://github.com/aabc/ipt-netflow ) to the machine where Phalanx is configured (port 9995) then after configured the thresholds you can call an external trigger (trigger.sh) to push some remote configurations (ssh into box + shutdown|/bgp announce|/set ipt|/shutoff via hypervisor API) or just notify your Slack/Telegram channel about it.



If you have any cool idea/problem just open an issue and i'll look into it.


Known issues

  • Netflow parse doesn't work on all netflow v9 records (tested on ipt and cisco nf export without issues)

phalanx's People

Contributors

fnzv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

phalanx's Issues

Compile error

./detectord.go:175:36: not enough arguments in call to client.cmdable.Scan
have (uint64, string, number)
want (context.Context, uint64, string, int64)
./detectord.go:190:34: not enough arguments in call to client.cmdable.Get
have (string)
want (context.Context, string)
./detectord.go:215:16: not enough arguments in call to client.cmdable.FlushAll
have ()
want (context.Context)
./detectord.go:252:36: not enough arguments in call to client.cmdable.Scan
have (uint64, string, number)
want (context.Context, uint64, string, int64)
./detectord.go:271:34: not enough arguments in call to client.cmdable.Get
have (string)
want (context.Context, string)
./detectord.go:288:63: not enough arguments in call to ban_client.cmdable.Set
have (string, string, time.Duration)
want (context.Context, string, interface {}, time.Duration)
./detectord.go:293:63: not enough arguments in call to ban_client.cmdable.Set
have (string, string, time.Duration)
want (context.Context, string, interface {}, time.Duration)
./detectord.go:297:31: client.FlushDb undefined (type *redis.Client has no field or method FlushDb)
./detectord.go:319:63: not enough arguments in call to ban_client.cmdable.Set
have (string, string, time.Duration)
want (context.Context, string, interface {}, time.Duration)
./detectord.go:325:63: not enough arguments in call to ban_client.cmdable.Set
have (string, string, time.Duration)
want (context.Context, string, interface {}, time.Duration)
./detectord.go:325:63: too many errors

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.