Register callback functions that trigger on tcp/udp requests.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmd/plisten
examples
internal/dnscap
pkg/dnsl
.gitignore
.travis.yml
Gopkg.lock
Gopkg.toml
LICENSE
README.md

README.md

plisten

Register callback functions that trigger on tcp/udp requests. Currently only supports DNS; I may add more functionality in the future.

Documentation

The godoc can be found here: https://godoc.org/github.com/ScottyFillups/plisten/pkg/dnsl

Installation

The binary provided in cmd/ is currently just a DNS sniffer that logs requests; in the future I'm considering making a CLI for sniffing different layers (eg. HTTP)

go get github.com/ScottyFillups/plisten/cmd/plisten

If $GOPATH/bin is in your $PATH, then you can invoke the binary:

sudo plisten

Usage

package main

import (
	"github.com/ScottyFillups/plisten/pkg/dnsl"
	"fmt"
	"log"
)

func logDNSWarn(d *dnsl.DNSListener, match string) {
	fmt.Println("You visited: " + match + ". Shouldn't you be working?")
}

func main() {
	dataChan := make(chan dnsl.Packet)
	dl := dnsl.New()

	err := dl.Listen(dataChan)
	if err != nil {
		log.Fatal("Failed to initialize DNS listener")
	}

	err = dl.Register(".*facebook.*", logDNSWarn)
	if err != nil {
		log.Fatal("Failed to compile regexp")
	}

	for data := range dataChan {
		if data.Error != nil {
			fmt.Println(data.Error)
			dl.Close()
			break
		}

		fmt.Println(data.Host)
	}
}

See /examples for more specific and creative usages.