All Projects → echothrust → pf-diverters

echothrust / pf-diverters

Licence: BSD-2-Clause License
A collection of (OpenBSD) PF divert socket daemons

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to pf-diverters

icmpmon
A simple ICMP monitor with web interface.
Stars: ✭ 33 (-21.43%)
Mutual labels:  daemon
deswappify-auto
automatically swap-in pages when enough memory is available
Stars: ✭ 30 (-28.57%)
Mutual labels:  daemon
scrapy-do
A daemon for scheduling Scrapy spiders
Stars: ✭ 60 (+42.86%)
Mutual labels:  daemon
daemonize
Template code for writing UNIX-daemons.
Stars: ✭ 33 (-21.43%)
Mutual labels:  daemon
ggr-ui
The missing /status API for Ggr
Stars: ✭ 37 (-11.9%)
Mutual labels:  daemon
git-slack-notify
Sends Slack notifications for new commits in Git repositories
Stars: ✭ 12 (-71.43%)
Mutual labels:  daemon
WSD-python
Web Services for Devices (WSD) tools and utilities for cross platform support
Stars: ✭ 22 (-47.62%)
Mutual labels:  daemon
gateway
A proxy to buffer and forward metrics, events, and traces.
Stars: ✭ 94 (+123.81%)
Mutual labels:  daemon
g910-gkey-macro-support
GKey support for Logitech G910 Keyboard on Linux
Stars: ✭ 85 (+102.38%)
Mutual labels:  daemon
dxhd
daky's X11 Hotkey Daemon
Stars: ✭ 80 (+90.48%)
Mutual labels:  daemon
ProxySwitcher
Easily enable / disable WiFi proxy on a jailbroken iOS device
Stars: ✭ 55 (+30.95%)
Mutual labels:  daemon
touchtest
MacOS Touch Bar Control Strip daemon
Stars: ✭ 22 (-47.62%)
Mutual labels:  daemon
break-time
break timer that forces you to take a break
Stars: ✭ 13 (-69.05%)
Mutual labels:  daemon
installer
remote.it command line installer tool
Stars: ✭ 21 (-50%)
Mutual labels:  daemon
macos
macOS load bootup and optimization
Stars: ✭ 29 (-30.95%)
Mutual labels:  daemon
sway-alttab
Simple Alt-Tab daemon for SwayWM/i3. Switches back to previous focused window on Alt-Tab or SIGUSR1
Stars: ✭ 36 (-14.29%)
Mutual labels:  daemon
conceal-explorer
Conceal Explorer - CCX Block Explorer
Stars: ✭ 26 (-38.1%)
Mutual labels:  daemon
tarssh
A simple SSH tarpit inspired by endlessh
Stars: ✭ 98 (+133.33%)
Mutual labels:  daemon
OpenBSDFirewall
Simple OpenBSD Home Firewall Config for ALIX Board
Stars: ✭ 41 (-2.38%)
Mutual labels:  pf
ccxx
This is a cross-platform library software library about c, c ++, unix4, posix. Include gtest, benchmark, cmake, process lock, daemon, libuv, lua, cpython, re2, json, yaml, mysql, redis, opencv, qt, lz4, oci ... https://hub.docker.com/u/oudream
Stars: ✭ 31 (-26.19%)
Mutual labels:  daemon

pf diverters

A collection of daemons written for OpenBSD PF, that listen on divert(4) sockets.

PF can be configured to send matching packets to a divert socket via the parameter divert-packet port <port>. Divert sockets are bound to divert ports (completely separated from tcp/udp) and enable us to queue raw packets from the kernel stack to userspace applications and vice versa.

This synergy leaves plenty of space for innovation; matching packets from PF can be stopped from propagating through the IP stack, in order to be brought to our userspace daemons, and optionally be re-injected back into the kernel stack for normal processing. Certainly, the daemons can perform additional checks on intercepted connections and, based on those checks, immediately enforce firewall policy.

WARNING: THESE TOOLS ARE EXPERIMENTAL AND IN NO-WAY PRODUCTION READY.

Feel free to test and run them on your systems, but make sure you keep a close eye.

List of diverters available:

  • bofh-divert Divert connections to this daemon and add each src host to a predefined PF table (used for banning abusers).
  • dnsbl-divert Divert connections to this daemon and check if the source ip is on a dnsbl and drop packet, or else reinject packet to reach its original destination. (still work-in-progress)

Building

On an OpenBSD system, get the source and simply run make:

Note: if git(1) is not installed on your system, you can always download the code as a tar.gz archive (http link).

$ git clone https://github.com/echothrust/pf-diverters
$ cd pf-diverters
$ make

This will compile the binaries for the diverters. If you wish, you can also run make install to place the executables in /usr/local/sbin and the rc scripts in /etc/rc.d.

Running

bofh-divert

A simple divert socket daemon that can used to automaticaly block connections. With the help of PF, you redirect a bunch of unused (by you) ports to this daemon listening on a divert socket and hosts that attempt access are instantly added to a predefined PF table. Combined with a block rule for that table, this essentially sets tripwires for any attackers probing those unused TCP ports, effectively blocking the rest of the attempts originating from the same IP addresses.

$ ./bofh-divert                                                            
usage: bofh-divert <divert_port> <pf_table_name>
        <divert_port> divert port number to bind (1-65535)
        <pf_table_name> table to add collected host IPs (up to 32 chars)

Say you run bofh-divert 1100 bastards, you would also need the corresponding PF rules for this to work, in /etc/pf.conf, say for a list of well-known scanner ports:

table <bastards> persist counters
block in log quick from <bastards>
pass in log quick on { egress } inet proto tcp from !<bastards> to port { 22, 23, 81, 138, 139, 445, 1024, 3389, 5900, 6001, 8080, 8888 } divert-packet port 1100 no state

All daemon activity is appropriately logged through syslog, e.g.:

Sep 17 18:56:16 fw01 bofh-divert: attacker_ip:13477 -> your_ip:3389

dnsbl-divert

A similar daemon that can be used on firewalls to fence connections on listening (used) ports. Based on DNS blacklists, source IPs can be validated prior to allowing the connection to happen.

$ ./dnsbl-divert                                                           
usage: dnsbl-divert <divert_port> <pf_table_black> <pf_table_cache> [dns_ip]
        <divert_port>    divert port number to bind (1-65535)
        <pf_table_black> table to populate with DNSBLed hosts (up to 32 chars)
        <pf_table_cache> table to cache already-looked-up hosts (up to 32 chars)
        <dns_ip>         DNS server address (default: use system-configured dns)

This is BETA/untested software that can take numerous improvements. Usage is very similar to bofh-divert, but this is destined for application in front of listening ports. For up-to-date running instructions, PF config and also for setting your prefered DNSBLs, please take a look in the source code.

rc.scripts

Run controlscripts can be used to start diverters on system boot, for example:

ln -s /etc/rc.d/rc.bofh /etc/rc.d/bofh_bastards
echo 'bofh_bastards_flags="1100 bastards"' >> /etc/rc.conf.local

This will configure the system to start bofh-divert daemon on boot, listening on divert_port '1100' and logging offenders in PF table 'bastards'. Of course, PF should be configured to create the table 'bastards' and forward offending connections to divert_port 1100.

Notes

The code is destined to compile and run on OpenBSD 5.3 amd64. It could also be suitable for other platforms featuring PF, but modifications may be needed.

On OpenBSD, superuser privileges are required to open a divert socket (and thus run these programs).

When dealing with pf tables you also need write access to /dev/pf.

All the diverters require the pre-existance of the pf table.

Contributing

There sure is room for improvement, but also many ideas on similar diverters to implement. Code contributions are always welcome:

  1. Fork it
  2. Clone your forked project (git clone https://github.com/YOUR-ACCOUNT/pf-diverters)
  3. (Optional) Create your feature branch (git checkout -b my-new-feature)
  4. Add code as you see fit (introduce new files with git add my-new-feature.c)
  5. Commit your changes (if any) to existing code (git commit -am 'Add some feature')
  6. Push back to your forked clone (git push or git push origin my-new-feature)
  7. Create new Pull Request Info
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].