diff --git a/Gopkg.lock b/Gopkg.lock index 254bee11..1e81eb5c 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -67,7 +67,7 @@ revision = "2ce16c963a8ac5bd6af851d4877e38701346983f" [[projects]] - digest = "1:c706034658cd03896bcde87e0770048bb1443378d18932d5897c3d7f3e44133b" + digest = "1:cbae049ade5f135f52da4cc6e3fd6aca532dffbde65160ad1510dee6c3e8dc4f" name = "github.com/evilsocket/islazy" packages = [ "data", @@ -80,8 +80,8 @@ "zip", ] pruneopts = "UT" - revision = "268495ba2f4621f397a274dc33b9296553db855d" - version = "v1.10.0" + revision = "949884336bbf7e535e4e0e6a3f75af89091488e5" + version = "v1.10.1" [[projects]] branch = "master" @@ -206,11 +206,11 @@ [[projects]] branch = "master" - digest = "1:450f3a64f7a76d3f229ff33a30f0a889629dde46b0f82ece7c53404528316665" + digest = "1:34fe44dd2bbe5723068e0a7a266847965a88297d383fe611e0358e556d82de09" name = "github.com/mdlayher/raw" packages = ["."] pruneopts = "UT" - revision = "fa5ef3332ca961deab5782da07b1616fea8a9dd8" + revision = "480b93709cce56651807d3fdeb260a5a7c4e2d5f" [[projects]] branch = "master" @@ -270,11 +270,11 @@ [[projects]] branch = "master" - digest = "1:8207c052fb873f83c61a5aa16f6add5feb9881eda2112b56f69fd3b9e7f55c3f" + digest = "1:7a8067e267a25694dd7bdde6e5016053a3f61bb7141448bf8e0025a84eb7d11c" name = "golang.org/x/sys" packages = ["unix"] pruneopts = "UT" - revision = "983097b1a8a340cd1cc7df17d735154d89e10b1a" + revision = "a9d3bda3a223baa6bba6ef412cb273f0fd163c05" [[projects]] digest = "1:9935525a8c49b8434a0b0a54e1980e94a6fae73aaff45c5d33ba8dff69de123e" diff --git a/vendor/github.com/evilsocket/islazy/log/log.go b/vendor/github.com/evilsocket/islazy/log/log.go index eac0dd3f..eecd2b3e 100644 --- a/vendor/github.com/evilsocket/islazy/log/log.go +++ b/vendor/github.com/evilsocket/islazy/log/log.go @@ -120,7 +120,7 @@ func Error(format string, args ...interface{}) { 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{}) { do(FATAL, format, args...) OnFatal() diff --git a/vendor/github.com/evilsocket/islazy/tui/table.go b/vendor/github.com/evilsocket/islazy/tui/table.go index 91d5e475..aafa08c4 100644 --- a/vendor/github.com/evilsocket/islazy/tui/table.go +++ b/vendor/github.com/evilsocket/islazy/tui/table.go @@ -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)) } +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 // and prints on the writer an ASCII based datagrid of such // data. @@ -73,7 +110,6 @@ func Table(w io.Writer, columns []string, rows [][]string) { } colPaddings := make([]int, 0) - lineSep := "" for colIndex, colHeader := range columns { column := []string{colHeader} for _, row := range rows { @@ -81,30 +117,29 @@ func Table(w io.Writer, columns []string, rows [][]string) { } mLen := maxLen(column) colPaddings = append(colPaddings, mLen) - lineSep += fmt.Sprintf("+%s", strings.Repeat("-", mLen+1)) } - lineSep += "+" - table := "" + table := "\n" // header - table += fmt.Sprintf("%s\n", lineSep) + table += fmt.Sprintf("%s\n", lineSeparator(0, columns, rows)) 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("%s\n", lineSep) + table += fmt.Sprintf("│\n") + + table += fmt.Sprintf("%s\n", lineSeparator(1, columns, rows)) // rows for _, row := range rows { 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 - table += lineSep + table += fmt.Sprintf("%s\n", lineSeparator(2, columns, rows)) - fmt.Fprintf(w, "\n%s\n", table) + fmt.Fprintf(w, "%s", table) } diff --git a/vendor/github.com/mdlayher/raw/raw.go b/vendor/github.com/mdlayher/raw/raw.go index fff8e354..ea91020b 100644 --- a/vendor/github.com/mdlayher/raw/raw.go +++ b/vendor/github.com/mdlayher/raw/raw.go @@ -168,13 +168,6 @@ type Config struct { 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. // 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: diff --git a/vendor/github.com/mdlayher/raw/raw_bsd.go b/vendor/github.com/mdlayher/raw/raw_bsd.go index cdde0f26..fc55129d 100644 --- a/vendor/github.com/mdlayher/raw/raw_bsd.go +++ b/vendor/github.com/mdlayher/raw/raw_bsd.go @@ -128,7 +128,7 @@ func (p *packetConn) ReadFrom(b []byte) (int, net.Addr, error) { if deadline.IsZero() { timeout = readTimeout } else { - timeout = deadline.Sub(time.Now()) + timeout = time.Until(deadline) if timeout > readTimeout { timeout = readTimeout } @@ -280,25 +280,6 @@ func configureBPF(fd int, ifi *net.Interface, proto uint16) (int, error) { 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 // package syscall. func assembleBpfInsn(filter []bpf.RawInstruction) []syscall.BpfInsn { diff --git a/vendor/github.com/mdlayher/raw/raw_direction_bsd.go b/vendor/github.com/mdlayher/raw/raw_direction_bsd.go new file mode 100644 index 00000000..8060a2fc --- /dev/null +++ b/vendor/github.com/mdlayher/raw/raw_direction_bsd.go @@ -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 +} diff --git a/vendor/github.com/mdlayher/raw/raw_direction_openbsd.go b/vendor/github.com/mdlayher/raw/raw_direction_openbsd.go new file mode 100644 index 00000000..2afc5270 --- /dev/null +++ b/vendor/github.com/mdlayher/raw/raw_direction_openbsd.go @@ -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 +} diff --git a/vendor/github.com/mdlayher/raw/raw_linux.go b/vendor/github.com/mdlayher/raw/raw_linux.go index be894657..d11b9ce4 100644 --- a/vendor/github.com/mdlayher/raw/raw_linux.go +++ b/vendor/github.com/mdlayher/raw/raw_linux.go @@ -53,6 +53,13 @@ type socket interface { 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 // data at the device driver level. 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 { if !deadline.IsZero() { - timeout = deadline.Sub(time.Now()) + timeout = time.Until(deadline) if timeout > readTimeout { timeout = readTimeout } diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index a07ee49e..4bb86aa0 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -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)) } +// 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) // KeyctlInt calls keyctl commands in which each argument is an int. diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go index d262150c..3e9c18e6 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go @@ -405,6 +405,11 @@ type TCPInfo struct { Total_retrans uint32 } +type CanFilter struct { + Id uint32 + Mask uint32 +} + const ( SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet6 = 0x1c @@ -434,6 +439,7 @@ const ( SizeofICMPv6Filter = 0x20 SizeofUcred = 0xc SizeofTCPInfo = 0x68 + SizeofCanFilter = 0x8 ) const ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go index e492caac..14365ff6 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go @@ -406,6 +406,11 @@ type TCPInfo struct { Total_retrans uint32 } +type CanFilter struct { + Id uint32 + Mask uint32 +} + const ( SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet6 = 0x1c @@ -435,6 +440,7 @@ const ( SizeofICMPv6Filter = 0x20 SizeofUcred = 0xc SizeofTCPInfo = 0x68 + SizeofCanFilter = 0x8 ) const ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go index ad434215..80ad473c 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go @@ -409,6 +409,11 @@ type TCPInfo struct { Total_retrans uint32 } +type CanFilter struct { + Id uint32 + Mask uint32 +} + const ( SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet6 = 0x1c @@ -438,6 +443,7 @@ const ( SizeofICMPv6Filter = 0x20 SizeofUcred = 0xc SizeofTCPInfo = 0x68 + SizeofCanFilter = 0x8 ) const ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go index ef76a362..20e78cc1 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go @@ -407,6 +407,11 @@ type TCPInfo struct { Total_retrans uint32 } +type CanFilter struct { + Id uint32 + Mask uint32 +} + const ( SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet6 = 0x1c @@ -436,6 +441,7 @@ const ( SizeofICMPv6Filter = 0x20 SizeofUcred = 0xc SizeofTCPInfo = 0x68 + SizeofCanFilter = 0x8 ) const ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go index dbf05903..bdeb0cb2 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go @@ -408,6 +408,11 @@ type TCPInfo struct { Total_retrans uint32 } +type CanFilter struct { + Id uint32 + Mask uint32 +} + const ( SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet6 = 0x1c @@ -437,6 +442,7 @@ const ( SizeofICMPv6Filter = 0x20 SizeofUcred = 0xc SizeofTCPInfo = 0x68 + SizeofCanFilter = 0x8 ) const ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go index 1b7e6707..2d3f5911 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go @@ -407,6 +407,11 @@ type TCPInfo struct { Total_retrans uint32 } +type CanFilter struct { + Id uint32 + Mask uint32 +} + const ( SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet6 = 0x1c @@ -436,6 +441,7 @@ const ( SizeofICMPv6Filter = 0x20 SizeofUcred = 0xc SizeofTCPInfo = 0x68 + SizeofCanFilter = 0x8 ) const ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go index 57379005..5fb57ff2 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go @@ -407,6 +407,11 @@ type TCPInfo struct { Total_retrans uint32 } +type CanFilter struct { + Id uint32 + Mask uint32 +} + const ( SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet6 = 0x1c @@ -436,6 +441,7 @@ const ( SizeofICMPv6Filter = 0x20 SizeofUcred = 0xc SizeofTCPInfo = 0x68 + SizeofCanFilter = 0x8 ) const ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go index 0e88bf47..b46b26f6 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go @@ -408,6 +408,11 @@ type TCPInfo struct { Total_retrans uint32 } +type CanFilter struct { + Id uint32 + Mask uint32 +} + const ( SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet6 = 0x1c @@ -437,6 +442,7 @@ const ( SizeofICMPv6Filter = 0x20 SizeofUcred = 0xc SizeofTCPInfo = 0x68 + SizeofCanFilter = 0x8 ) const ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go index 5ac91b3f..e14e3c90 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go @@ -408,6 +408,11 @@ type TCPInfo struct { Total_retrans uint32 } +type CanFilter struct { + Id uint32 + Mask uint32 +} + const ( SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet6 = 0x1c @@ -437,6 +442,7 @@ const ( SizeofICMPv6Filter = 0x20 SizeofUcred = 0xc SizeofTCPInfo = 0x68 + SizeofCanFilter = 0x8 ) const ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go index 1e59b450..2332e8fd 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go @@ -408,6 +408,11 @@ type TCPInfo struct { Total_retrans uint32 } +type CanFilter struct { + Id uint32 + Mask uint32 +} + const ( SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet6 = 0x1c @@ -437,6 +442,7 @@ const ( SizeofICMPv6Filter = 0x20 SizeofUcred = 0xc SizeofTCPInfo = 0x68 + SizeofCanFilter = 0x8 ) const ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go index 508885f1..efec4f81 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go @@ -407,6 +407,11 @@ type TCPInfo struct { Total_retrans uint32 } +type CanFilter struct { + Id uint32 + Mask uint32 +} + const ( SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet6 = 0x1c @@ -436,6 +441,7 @@ const ( SizeofICMPv6Filter = 0x20 SizeofUcred = 0xc SizeofTCPInfo = 0x68 + SizeofCanFilter = 0x8 ) const ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go index d315f2c3..71cc23f2 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go @@ -406,6 +406,11 @@ type TCPInfo struct { Total_retrans uint32 } +type CanFilter struct { + Id uint32 + Mask uint32 +} + const ( SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet6 = 0x1c @@ -435,6 +440,7 @@ const ( SizeofICMPv6Filter = 0x20 SizeofUcred = 0xc SizeofTCPInfo = 0x68 + SizeofCanFilter = 0x8 ) const ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go index a1a9279c..48805ba1 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go @@ -410,6 +410,11 @@ type TCPInfo struct { Total_retrans uint32 } +type CanFilter struct { + Id uint32 + Mask uint32 +} + const ( SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet6 = 0x1c @@ -439,6 +444,7 @@ const ( SizeofICMPv6Filter = 0x20 SizeofUcred = 0xc SizeofTCPInfo = 0x68 + SizeofCanFilter = 0x8 ) const (