knox

package module
v0.0.0-...-5a1c0af Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2022 License: GPL-3.0 Imports: 3 Imported by: 0

README

knox

A package containing implementations of port knocking using the libpcap wrappers in Google's gopacket library. You can use it to create services that monitor your network interfaces for a specific sequence of ports, even if the ports in question are closed. When a successful port knock is detected, information about the triggering packet is exposed by the package so that you can act on it as you please.

Dependencies

Example

This is an example of a simple port knocking listener that triggers on ports 1337, 1338 and 1339:

package main

import "fmt"
import "github.com/ofasgard/knox"

func main() {
	ch := make(chan knox.Hostinfo, 0)
	sig := make(chan error, 0)
	go knox.PortStreamTCP("eth0", "45.33.32.156", 1600, ch, sig)
	res := <-sig
	if res != nil {
		fmt.Println("Error in setting up the sniffer. Check permissions, interface name, IP?")
		fmt.Println(res.Error())
		return
	}
	knock := make(chan knox.Hostinfo, 0)
	go knox.PortKnocker(ch, knock, 1337, 1338, 1339)
	for {
		host_data := <-knock
		fmt.Println("Received a successful knock from", host_data.IP)
	}
}

You can test out your portknocker using hping3 like so:

echo Knock Knock

hping3 -S 45.33.32.156 -p 1337 -c 1 
hping3 -S 45.33.32.156 -p 1338 -c 1 
hping3 -S 45.33.32.156 -p 1339 -c 1 

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PortKnocker

func PortKnocker(ch chan Hostinfo, res chan Hostinfo, ports ...int)

func PortStreamTCP

func PortStreamTCP(iface string, ip string, snaplen int, ch chan Hostinfo, sig chan error)

func SrcPortKnocker

func SrcPortKnocker(ch chan Hostinfo, res chan Hostinfo, ports ...int)

Types

type Hostinfo

type Hostinfo struct {
	Packet  gopacket.Packet
	Port    int
	Srcport int
	IP      string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL