All Projects → florianl → go-nflog

florianl / go-nflog

Licence: MIT license
c-binding free API for golang to communicate with the log subsystem of netfilter

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to go-nflog

zen-kernel
Zen Patched Kernel Sources
Stars: ✭ 1,303 (+3078.05%)
Mutual labels:  kernel
docker-cheat-sheet
All about docker commands
Stars: ✭ 50 (+21.95%)
Mutual labels:  kernel
mnist-challenge
My solution to TUM's Machine Learning MNIST challenge 2016-2017 [winner]
Stars: ✭ 68 (+65.85%)
Mutual labels:  kernel
CVE-2016-7255
An exploit for CVE-2016-7255 on Windows 7/8/8.1/10(pre-anniversary) 64 bit
Stars: ✭ 85 (+107.32%)
Mutual labels:  kernel
JamesM
me going through JamesM's kernel development tutorials
Stars: ✭ 35 (-14.63%)
Mutual labels:  kernel
scaraOS
A 32bit multiboot OS kernel for IA32 (PC/AT) systems.
Stars: ✭ 31 (-24.39%)
Mutual labels:  kernel
gdb 2 root
This python script adds some usefull command to stripped vmlinux image
Stars: ✭ 20 (-51.22%)
Mutual labels:  kernel
SimpleOS
Operating System Coded in Assembly and C
Stars: ✭ 72 (+75.61%)
Mutual labels:  kernel
cxos
Operating System development experiment in Ada
Stars: ✭ 32 (-21.95%)
Mutual labels:  kernel
poplar
Microkernel and userspace written in Rust exploring modern ideas
Stars: ✭ 217 (+429.27%)
Mutual labels:  kernel
pfSense-pkg-WireGuard
This is a port of the original WireGuard UI bits as implemented by Netgate in pfSense 2.5.0 to a package suitable for rapid iteration and more frequent updating on future releases of pfSense.
Stars: ✭ 194 (+373.17%)
Mutual labels:  kernel
os
x86-64 assembly µkernel
Stars: ✭ 15 (-63.41%)
Mutual labels:  kernel
ZeldaOS
32bit OS/kernel built from scratch with POSIX.1 compliance
Stars: ✭ 23 (-43.9%)
Mutual labels:  kernel
kernel
Main kernel tree
Stars: ✭ 28 (-31.71%)
Mutual labels:  kernel
iOS-Jailbreak-Development
GeoSn0w's majestic knowledge base for iOS 12 / iOS 13 Jailbreak Development.
Stars: ✭ 55 (+34.15%)
Mutual labels:  kernel
coq jupyter
Jupyter kernel for Coq
Stars: ✭ 70 (+70.73%)
Mutual labels:  kernel
yask
YASK--Yet Another Stencil Kit: a domain-specific language and framework to create high-performance stencil code for implementing finite-difference methods and similar applications.
Stars: ✭ 81 (+97.56%)
Mutual labels:  kernel
OpenHarmony
华为鸿蒙分布式操作系统(Huawei OpenHarmony)开发技术交流,鸿蒙技术资料,手册,指南,共建国产操作系统万物互联新生态。
Stars: ✭ 373 (+809.76%)
Mutual labels:  kernel
KA27
A Mod version of KernelAdiutor (An application which manages kernel parameters)
Stars: ✭ 15 (-63.41%)
Mutual labels:  kernel
HEVD Kernel Exploit
Exploits pack for the Windows Kernel mode driver HackSysExtremeVulnerableDriver written for educational purposes.
Stars: ✭ 44 (+7.32%)
Mutual labels:  kernel

go-nflog PkgGoDev Go Report Card Go

This is go-nflog and it is written in golang. It provides a C-binding free API to the netfilter based log subsystem of the Linux kernel.

Example

func main() {
	// Send outgoing pings to nflog group 100
	// # sudo iptables -I OUTPUT -p icmp -j NFLOG --nflog-group 100

	//Set configuration parameters
	config := nflog.Config{
		Group:       100,
		Copymode:    nflog.CopyPacket,
	}

	nf, err := nflog.Open(&config)
	if err != nil {
		fmt.Println("could not open nflog socket:", err)
		return
	}
	defer nf.Close()

	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
	defer cancel()

	// hook that is called for every received packet by the nflog group
	hook := func(attrs nflog.Attribute) int {
		// Just print out the payload of the nflog packet
		fmt.Fprintf(os.Stdout, "%#v\n", attrs.Payload)
		return 0
	}

	// errFunc that is called for every error on the registered hook
	errFunc := func(e error) int {
		// Just log the error and return 0 to continue receiving packets
		fmt.Fprintf(os.Stderr, "received error on hook: %v", e)
		return 0
	}

	// Register your function to listen on nflog group 100
	err = nf.RegisterWithErrorFunc(ctx, hook, errFunc)
	if err != nil {
		fmt.Fprintf(os.Stderr, "failed to register hook function: %v", err)
		return
	}

	// Block till the context expires
	<-ctx.Done()
}

Privileges

This package processes information directly from the kernel and therefore it requires special privileges. You can provide this privileges by adjusting the CAP_NET_ADMIN capabilities.

	setcap 'cap_net_admin=+ep' /your/executable

For documentation and more examples please take a look at PkgGoDev

Requirements

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].