badcapt

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

README

Build Status

About

Badcapt is a project inspired by Bad Packets' work and the Remote Identification of Port Scan Toolchains paper by Vincent Ghiette, Norbert Blenn, Christian Doerr.

It will try to detect malicious packets and export them to the Elastic storage or output to the stdout for your further processing.

Install

The app is built on top of gopacket package which provides C bindings for the libpcap, so you should have libpcap-dev package installed first.

go get github.com/ilyaglow/badcapt/cmd/badcapt

Also you can use the docker image (see below on how to use it):

docker build -t badcapt https://github.com/ilyaglow/badcapt.git

or

docker pull ilyaglow/badcapt

Usage

./badcapt -h
Usage of badcapt:
  -e string
    	Elasticsearch URL (optional)
  -i string
    	Interface name to listen

If no Elasticsearch URL provided, badcapt will simply output records to the screen.

To use the dockerized version you must run it with --net=host switch:

docker run -d --net=host ilyaglow/badcapt -i eth0

You can also take a look at the badsearch companion script for the Elasticsearch: it dumps all records in the database for the last 24 hours.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPacketMarker

func AddPacketMarker(m Marker) func(*Badcapt) error

AddPacketMarker adds a packet marking routine.

func LowMSSIdentifier added in v0.3.0

func LowMSSIdentifier(p gopacket.Packet) []string

LowMSSIdentifier adds low-mss tag for a packet which TCP Maximum Segment Size is less than 500. This fact indicates potential SACK Panic attack (CVE-2019-11477). Details: https://github.com/Netflix/security-bulletins/blob/master/advisories/third-party/2019-001.md#1-cve-2019-11477-sack-panic-linux--2629

func MasscanIdentifier

func MasscanIdentifier(p gopacket.Packet) []string

MasscanIdentifier adds masscan tag for a packet which IP ID header = dstip ⊕ dstport ⊕ tcpseq.

func MiraiIdentifier

func MiraiIdentifier(p gopacket.Packet) []string

MiraiIdentifier adds mirai tag for a packet which TCP sequence equals destination IP-address in a decimal format

func SetElastic

func SetElastic(client *elastic.Client) func(*Badcapt) error

SetElastic sets elasticsearch client to export events to.

func SetElasticDocType

func SetElasticDocType(doc string) func(*Badcapt) error

SetElasticDocType sets the events documents type.

func SetElasticIndexName

func SetElasticIndexName(name string) func(*Badcapt) error

SetElasticIndexName sets an index name where events are going to be written.

func ZmapIdentifier

func ZmapIdentifier(p gopacket.Packet) []string

ZmapIdentifier adds zmap tag for a packet which IP ID header equals 54321.

Types

type Badcapt

type Badcapt struct {
	// contains filtered or unexported fields
}

Badcapt defines badcapt configuration

func New

func New(opts ...func(*Badcapt) error) (*Badcapt, error)

New bootstraps badcapt configuration.

func NewConfig

func NewConfig(elasticLoc string, markers ...Marker) (*Badcapt, error)

NewConfig bootstraps badcapt configuration. Deprecated. Use New instead.

func (*Badcapt) Listen

func (b *Badcapt) Listen(iface string) error

Listen starts packet sniffing and processing

type Marker

type Marker func(gopacket.Packet) []string

Marker represents a routine that identifies the raw packet.

type Record

type Record struct {
	SrcIP         net.IP    `json:"src_ip,omitempty"`
	Protocols     []string  `json:"protocols,omitempty"`
	SrcPort       uint16    `json:"src_port,omitempty"`
	DstIP         net.IP    `json:"dst_ip,omitempty"`
	DstPort       uint16    `json:"dst_port,omitempty"`
	Timestamp     time.Time `json:"date"`
	Tags          []string  `json:"tags"`
	Payload       []byte    `json:"payload,omitempty"`
	PayloadString string    `json:"payload_str,omitempty"`
}

Record contains packet data, that is ready to be exported

func NewRecord

func NewRecord(tp *TaggedPacket) (*Record, error)

NewRecord constructs a record to write to the database

type TaggedPacket

type TaggedPacket struct {
	Packet gopacket.Packet
	Tags   []string
}

TaggedPacket represents a packet that went through markers.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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