Introducing the p0f BPF compiler
blog.cloudflare.com
blog.cloudflare.com
Detected OS = Linux 3.x [generic]
HTTP client = unknown
Network link = Ethernet or modem
Distance = 11
Language = English
Uptime = 36 days 18 hrs 26 min (modulo 198 days)
WARNING: Inconsistent fingerprints, probably indicative of
IP sharing or proxyingNote: looks like you're hitting this
page through a proxy (your Via header is set). This
affects the apparent identity of your system on TCP/IP
level.
Perhaps my cell network is acting via proxy (wouldn't surprise me), but your average user won't know this. If you're going to filter or identify traffic based on p0f, be careful to not negatively impact honest users who might be misidentified (either because p0f got the fingerprint wrong or because there's some proxy in the middle). block in proto tcp from any os Windows
http://man.openbsd.org/OpenBSD-current/man5/pf.conf.5#OPERAT...The differences are:
- my understanding is that pf module is written in C and runs in kernel mode.
- my understanding is that pf os detection uses old p0f (2.x series) (not sure if it matters though)
- here, you have code in readable python that produces sandboxed bpf - which makes it actually useful.
Is it more complex? Well, you decide. Is kernel mode C "more complex" than p0f-to-bpf compiler in python?
Obviously C code running in a kernel is "more complex" than a Python script.
I was talking about how users would actually use this p0f BPF tool. Compare this:
./bpfgen p0f -- 4:64:0:*:mss*10,6:mss,sok,ts,nop,ws:df,id+:0
sudo iptables -A INPUT -p tcp --dport 80 -m bpf --bytecode "39,0 0 0 0,48 0 0 8,37 [...]"
with how you would actually use the "complex" C code in pf: block in proto tcp from any os Windows pass in proto tcp from any to any port www synproxy state
I'm being a little tongue-in-cheek, though. It seems your solution is either a superset of the above, or perhaps just an alternative. And compiling p0f to BPF is definitely an interesting topic and quite noteworthy.Though, I would dispute the notion that compiling to BPF is either simpler or more secure. The BPF JIT has been responsible for several kernel exploits recently. The original BPF was much simpler but irrelevant at this point. While I believe the design of the contemporary incarnation in Linux is still provably correct, the implementation manifestly still has bugs. And from a user perspective it's really difficult to beat the syntax of PF's pf.conf. pf.conf can't be emulated by using a front-end configuration generator for iptables + company as the semantics of many tasks require implementation logic in the kernel, whether as extensions to BPF or to the networking subsystem.