misc: updated deps

This commit is contained in:
evilsocket 2019-02-22 12:59:11 +01:00
parent b8e5872040
commit c3a4dc8cf5
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
22 changed files with 218 additions and 48 deletions

14
Gopkg.lock generated
View file

@ -67,7 +67,7 @@
revision = "2ce16c963a8ac5bd6af851d4877e38701346983f" revision = "2ce16c963a8ac5bd6af851d4877e38701346983f"
[[projects]] [[projects]]
digest = "1:c706034658cd03896bcde87e0770048bb1443378d18932d5897c3d7f3e44133b" digest = "1:cbae049ade5f135f52da4cc6e3fd6aca532dffbde65160ad1510dee6c3e8dc4f"
name = "github.com/evilsocket/islazy" name = "github.com/evilsocket/islazy"
packages = [ packages = [
"data", "data",
@ -80,8 +80,8 @@
"zip", "zip",
] ]
pruneopts = "UT" pruneopts = "UT"
revision = "268495ba2f4621f397a274dc33b9296553db855d" revision = "949884336bbf7e535e4e0e6a3f75af89091488e5"
version = "v1.10.0" version = "v1.10.1"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -206,11 +206,11 @@
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:450f3a64f7a76d3f229ff33a30f0a889629dde46b0f82ece7c53404528316665" digest = "1:34fe44dd2bbe5723068e0a7a266847965a88297d383fe611e0358e556d82de09"
name = "github.com/mdlayher/raw" name = "github.com/mdlayher/raw"
packages = ["."] packages = ["."]
pruneopts = "UT" pruneopts = "UT"
revision = "fa5ef3332ca961deab5782da07b1616fea8a9dd8" revision = "480b93709cce56651807d3fdeb260a5a7c4e2d5f"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -270,11 +270,11 @@
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:8207c052fb873f83c61a5aa16f6add5feb9881eda2112b56f69fd3b9e7f55c3f" digest = "1:7a8067e267a25694dd7bdde6e5016053a3f61bb7141448bf8e0025a84eb7d11c"
name = "golang.org/x/sys" name = "golang.org/x/sys"
packages = ["unix"] packages = ["unix"]
pruneopts = "UT" pruneopts = "UT"
revision = "983097b1a8a340cd1cc7df17d735154d89e10b1a" revision = "a9d3bda3a223baa6bba6ef412cb273f0fd163c05"
[[projects]] [[projects]]
digest = "1:9935525a8c49b8434a0b0a54e1980e94a6fae73aaff45c5d33ba8dff69de123e" digest = "1:9935525a8c49b8434a0b0a54e1980e94a6fae73aaff45c5d33ba8dff69de123e"

View file

@ -120,7 +120,7 @@ func Error(format string, args ...interface{}) {
do(ERROR, format, args...) do(ERROR, format, args...)
} }
// Fata emits a fatal error message and calls the log.OnFatal callback. // Fatal emits a fatal error message and calls the log.OnFatal callback.
func Fatal(format string, args ...interface{}) { func Fatal(format string, args ...interface{}) {
do(FATAL, format, args...) do(FATAL, format, args...)
OnFatal() OnFatal()

View file

@ -58,6 +58,43 @@ func padded(s string, maxLen int, align alignment) string {
return fmt.Sprintf("%s%s%s", strings.Repeat(" ", lPad), s, strings.Repeat(" ", rPad)) return fmt.Sprintf("%s%s%s", strings.Repeat(" ", lPad), s, strings.Repeat(" ", rPad))
} }
func lineSeparator(num int, columns []string, rows [][]string) string {
lineSep := ""
first := ""
div := ""
end := ""
if num == 0 {
first = "┌"
div = "┬"
end = "┐"
} else if num == 1 {
first = "├"
div = "┼"
end = "┤"
} else if num == 2 {
first = "└"
div = "┴"
end = "┘"
}
for colIndex, colHeader := range columns {
column := []string{colHeader}
for _, row := range rows {
column = append(column, row[colIndex])
}
mLen := maxLen(column)
if colIndex == 0 {
lineSep += fmt.Sprintf(first+"%s", strings.Repeat("─", mLen+1))
} else {
lineSep += fmt.Sprintf(div+"%s", strings.Repeat("─", mLen+1))
}
}
lineSep += end
return lineSep
}
// Table accepts a slice of column labels and a 2d slice of rows // Table accepts a slice of column labels and a 2d slice of rows
// and prints on the writer an ASCII based datagrid of such // and prints on the writer an ASCII based datagrid of such
// data. // data.
@ -73,7 +110,6 @@ func Table(w io.Writer, columns []string, rows [][]string) {
} }
colPaddings := make([]int, 0) colPaddings := make([]int, 0)
lineSep := ""
for colIndex, colHeader := range columns { for colIndex, colHeader := range columns {
column := []string{colHeader} column := []string{colHeader}
for _, row := range rows { for _, row := range rows {
@ -81,30 +117,29 @@ func Table(w io.Writer, columns []string, rows [][]string) {
} }
mLen := maxLen(column) mLen := maxLen(column)
colPaddings = append(colPaddings, mLen) colPaddings = append(colPaddings, mLen)
lineSep += fmt.Sprintf("+%s", strings.Repeat("-", mLen+1))
} }
lineSep += "+"
table := "" table := "\n"
// header // header
table += fmt.Sprintf("%s\n", lineSep) table += fmt.Sprintf("%s\n", lineSeparator(0, columns, rows))
for colIndex, colHeader := range columns { for colIndex, colHeader := range columns {
table += fmt.Sprintf("|%s", padded(colHeader, colPaddings[colIndex], alignCenter)) table += fmt.Sprintf("%s", padded(colHeader, colPaddings[colIndex], alignCenter))
} }
table += fmt.Sprintf("|\n") table += fmt.Sprintf("│\n")
table += fmt.Sprintf("%s\n", lineSep)
table += fmt.Sprintf("%s\n", lineSeparator(1, columns, rows))
// rows // rows
for _, row := range rows { for _, row := range rows {
for colIndex, cell := range row { for colIndex, cell := range row {
table += fmt.Sprintf("|%s", padded(cell, colPaddings[colIndex], alignLeft)) table += fmt.Sprintf("%s", padded(cell, colPaddings[colIndex], alignLeft))
} }
table += fmt.Sprintf("|\n") table += fmt.Sprintf("\n")
} }
// footer // footer
table += lineSep table += fmt.Sprintf("%s\n", lineSeparator(2, columns, rows))
fmt.Fprintf(w, "\n%s\n", table) fmt.Fprintf(w, "%s", table)
} }

View file

@ -168,13 +168,6 @@ type Config struct {
NoCumulativeStats bool NoCumulativeStats bool
} }
// htons converts a short (uint16) from host-to-network byte order.
// Thanks to mikioh for this neat trick:
// https://github.com/mikioh/-stdyng/blob/master/afpacket.go
func htons(i uint16) uint16 {
return (i<<8)&0xff00 | i>>8
}
// Copyright (c) 2012 The Go Authors. All rights reserved. // Copyright (c) 2012 The Go Authors. All rights reserved.
// Source code in this file is based on src/net/interface_linux.go, // Source code in this file is based on src/net/interface_linux.go,
// from the Go standard library. The Go license can be found here: // from the Go standard library. The Go license can be found here:

View file

@ -128,7 +128,7 @@ func (p *packetConn) ReadFrom(b []byte) (int, net.Addr, error) {
if deadline.IsZero() { if deadline.IsZero() {
timeout = readTimeout timeout = readTimeout
} else { } else {
timeout = deadline.Sub(time.Now()) timeout = time.Until(deadline)
if timeout > readTimeout { if timeout > readTimeout {
timeout = readTimeout timeout = readTimeout
} }
@ -280,25 +280,6 @@ func configureBPF(fd int, ifi *net.Interface, proto uint16) (int, error) {
return buflen, nil return buflen, nil
} }
// setBPFDirection enables filtering traffic traveling in a specific direction
// using BPF, so that traffic sent by this package is not captured when reading
// using this package.
func setBPFDirection(fd int, direction int) error {
_, _, err := syscall.Syscall(
syscall.SYS_IOCTL,
uintptr(fd),
// Even though BIOCSDIRECTION is preferred on FreeBSD, BIOCSSEESENT continues
// to work, and is required for other BSD platforms
syscall.BIOCSSEESENT,
uintptr(unsafe.Pointer(&direction)),
)
if err != 0 {
return syscall.Errno(err)
}
return nil
}
// assembleBpfInsn assembles a slice of bpf.RawInstructions to the format required by // assembleBpfInsn assembles a slice of bpf.RawInstructions to the format required by
// package syscall. // package syscall.
func assembleBpfInsn(filter []bpf.RawInstruction) []syscall.BpfInsn { func assembleBpfInsn(filter []bpf.RawInstruction) []syscall.BpfInsn {

27
vendor/github.com/mdlayher/raw/raw_direction_bsd.go generated vendored Normal file
View file

@ -0,0 +1,27 @@
// +build darwin dragonfly freebsd netbsd
package raw
import (
"syscall"
"unsafe"
)
// setBPFDirection enables filtering traffic traveling in a specific direction
// using BPF, so that traffic sent by this package is not captured when reading
// using this package.
func setBPFDirection(fd int, direction int) error {
_, _, err := syscall.Syscall(
syscall.SYS_IOCTL,
uintptr(fd),
// Even though BIOCSDIRECTION is preferred on FreeBSD, BIOCSSEESENT continues
// to work, and is required for other BSD platforms
syscall.BIOCSSEESENT,
uintptr(unsafe.Pointer(&direction)),
)
if err != 0 {
return syscall.Errno(err)
}
return nil
}

View file

@ -0,0 +1,35 @@
// +build openbsd
package raw
import (
"syscall"
"unsafe"
)
// setBPFDirection enables filtering traffic traveling in a specific direction
// using BPF, so that traffic sent by this package is not captured when reading
// using this package.
func setBPFDirection(fd int, direction int) error {
var dirfilt uint
switch direction {
case bpfDIn:
// filter outbound
dirfilt = syscall.BPF_DIRECTION_OUT
default:
// no filter
}
_, _, err := syscall.Syscall(
syscall.SYS_IOCTL,
uintptr(fd),
syscall.BIOCSDIRFILT,
uintptr(unsafe.Pointer(&dirfilt)),
)
if err != 0 {
return syscall.Errno(err)
}
return nil
}

View file

@ -53,6 +53,13 @@ type socket interface {
SetTimeout(time.Duration) error SetTimeout(time.Duration) error
} }
// htons converts a short (uint16) from host-to-network byte order.
// Thanks to mikioh for this neat trick:
// https://github.com/mikioh/-stdyng/blob/master/afpacket.go
func htons(i uint16) uint16 {
return (i<<8)&0xff00 | i>>8
}
// listenPacket creates a net.PacketConn which can be used to send and receive // listenPacket creates a net.PacketConn which can be used to send and receive
// data at the device driver level. // data at the device driver level.
func listenPacket(ifi *net.Interface, proto uint16, cfg Config) (*packetConn, error) { func listenPacket(ifi *net.Interface, proto uint16, cfg Config) (*packetConn, error) {
@ -124,7 +131,7 @@ func (p *packetConn) ReadFrom(b []byte) (int, net.Addr, error) {
for { for {
if !deadline.IsZero() { if !deadline.IsZero() {
timeout = deadline.Sub(time.Now()) timeout = time.Until(deadline)
if timeout > readTimeout { if timeout > readTimeout {
timeout = readTimeout timeout = readTimeout
} }

View file

@ -994,6 +994,20 @@ func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) {
return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq)) return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq))
} }
// SetsockoptSockFprog attaches a classic BPF or an extended BPF program to a
// socket to filter incoming packets. See 'man 7 socket' for usage information.
func SetsockoptSockFprog(fd, level, opt int, fprog *SockFprog) error {
return setsockopt(fd, level, opt, unsafe.Pointer(fprog), unsafe.Sizeof(*fprog))
}
func SetsockoptCanRawFilter(fd, level, opt int, filter []CanFilter) error {
var p unsafe.Pointer
if len(filter) > 0 {
p = unsafe.Pointer(&filter[0])
}
return setsockopt(fd, level, opt, p, uintptr(len(filter)*SizeofCanFilter))
}
// Keyctl Commands (http://man7.org/linux/man-pages/man2/keyctl.2.html) // Keyctl Commands (http://man7.org/linux/man-pages/man2/keyctl.2.html)
// KeyctlInt calls keyctl commands in which each argument is an int. // KeyctlInt calls keyctl commands in which each argument is an int.

View file

@ -405,6 +405,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -434,6 +439,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (

View file

@ -406,6 +406,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -435,6 +440,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (

View file

@ -409,6 +409,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -438,6 +443,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (

View file

@ -407,6 +407,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -436,6 +441,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (

View file

@ -408,6 +408,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -437,6 +442,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (

View file

@ -407,6 +407,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -436,6 +441,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (

View file

@ -407,6 +407,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -436,6 +441,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (

View file

@ -408,6 +408,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -437,6 +442,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (

View file

@ -408,6 +408,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -437,6 +442,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (

View file

@ -408,6 +408,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -437,6 +442,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (

View file

@ -407,6 +407,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -436,6 +441,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (

View file

@ -406,6 +406,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -435,6 +440,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (

View file

@ -410,6 +410,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -439,6 +444,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (