mirror of
https://github.com/bettercap/bettercap
synced 2025-07-06 04:52:10 -07:00
refact: refactored to use islazy and updated deps
This commit is contained in:
parent
a2b3ee79fb
commit
d070445225
238 changed files with 12662 additions and 1586 deletions
58
Gopkg.lock
generated
58
Gopkg.lock
generated
|
@ -52,15 +52,29 @@
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:2b7b174ae68705866555b73fd848de0749b93b1f99e3295e27f89bebe8702203"
|
digest = "1:7dc5d77e0d21759f0ba62f928f15519c961eee6a4ada94558d94094ccd792faa"
|
||||||
name = "github.com/elazarl/goproxy"
|
name = "github.com/elazarl/goproxy"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "947c36da3153ff334e74d9d980de341d25f358ba"
|
revision = "f58a169a71a51037728990b2d3597a14f56b525b"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:f46dd7c5783c6caa5ea1072eb4165446c58651ff0849c9d366ac318f140661fa"
|
digest = "1:09a1322d2fc6f021b23d389c045479cf4fe94fca0f504c61bb0ca2c67e244506"
|
||||||
|
name = "github.com/evilsocket/islazy"
|
||||||
|
packages = [
|
||||||
|
"fs",
|
||||||
|
"log",
|
||||||
|
"str",
|
||||||
|
"tui",
|
||||||
|
"zip",
|
||||||
|
]
|
||||||
|
pruneopts = "UT"
|
||||||
|
revision = "acbee79ddc39664d9a6ef5b2c4306dd470a58b2b"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
digest = "1:e5e45557e1871c967a6ccaa5b95d1233a2c01ab00615621825d1aca7383dc022"
|
||||||
name = "github.com/gobwas/glob"
|
name = "github.com/gobwas/glob"
|
||||||
packages = [
|
packages = [
|
||||||
".",
|
".",
|
||||||
|
@ -73,7 +87,7 @@
|
||||||
"util/strings",
|
"util/strings",
|
||||||
]
|
]
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "f756513aec94125582ee6c0dc94179251ef87370"
|
revision = "e7a84e9525fe90abcda167b604e483cc959ad4aa"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:51bee9f1987dcdb9f9a1b4c20745d78f6bf6f5f14ad4e64ca883eb64df4c0045"
|
digest = "1:51bee9f1987dcdb9f9a1b4c20745d78f6bf6f5f14ad4e64ca883eb64df4c0045"
|
||||||
|
@ -84,15 +98,15 @@
|
||||||
version = "v15.0.0"
|
version = "v15.0.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
|
||||||
digest = "1:a63cff6b5d8b95638bfe300385d93b2a6d9d687734b863da8e09dc834510a690"
|
digest = "1:a63cff6b5d8b95638bfe300385d93b2a6d9d687734b863da8e09dc834510a690"
|
||||||
name = "github.com/google/go-querystring"
|
name = "github.com/google/go-querystring"
|
||||||
packages = ["query"]
|
packages = ["query"]
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "53e6ce116135b80d037921a7fdd5138cf32d7a8a"
|
revision = "44c6ddd0a2342c386950e880b658017258da92fc"
|
||||||
|
version = "v1.0.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:a1b2a09d080e0229db471efc7f030b6d3931cd54989f6a1a4d676e085139cc2d"
|
digest = "1:eebcd2c096c6e4dada58e468e794146753d035fed7150cc0e2ff79ef28650709"
|
||||||
name = "github.com/google/gopacket"
|
name = "github.com/google/gopacket"
|
||||||
packages = [
|
packages = [
|
||||||
".",
|
".",
|
||||||
|
@ -101,8 +115,8 @@
|
||||||
"pcapgo",
|
"pcapgo",
|
||||||
]
|
]
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "11c65f1ca9081dfea43b4f9643f5c155583b73ba"
|
revision = "a6b099ece4680a8bdea84fa78166d0712108a95c"
|
||||||
version = "v1.1.14"
|
version = "v1.1.15"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:c79fb010be38a59d657c48c6ba1d003a8aa651fa56b579d959d74573b7dff8e1"
|
digest = "1:c79fb010be38a59d657c48c6ba1d003a8aa651fa56b579d959d74573b7dff8e1"
|
||||||
|
@ -180,6 +194,14 @@
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "e26af0688e455a82b14ebdbecf43f87ead3c4624"
|
revision = "e26af0688e455a82b14ebdbecf43f87ead3c4624"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
digest = "1:6569c2877d56f921a8a459d182af16b700c0e588c94b9938aef0d15d13d596db"
|
||||||
|
name = "github.com/mdlayher/raw"
|
||||||
|
packages = ["."]
|
||||||
|
pruneopts = "UT"
|
||||||
|
revision = "67a536258490ec29bca6d465b51dea32c0db3623"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:2b32af4d2a529083275afc192d1067d8126b578c7a9613b26600e4df9c735155"
|
digest = "1:2b32af4d2a529083275afc192d1067d8126b578c7a9613b26600e4df9c735155"
|
||||||
|
@ -230,11 +252,19 @@
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:6eb2645d74b43d9c87b51947df39f7c668a4f422cd512053f7f6f75bfaad0197"
|
digest = "1:ed32e5b8c2cb13ea42eaca9f9dda1233ee78e9e5aa9a9839afd7911c52f121fa"
|
||||||
|
name = "golang.org/x/net"
|
||||||
|
packages = ["bpf"]
|
||||||
|
pruneopts = "UT"
|
||||||
|
revision = "146acd28ed5894421fb5aac80ca93bc1b1f46f87"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
digest = "1:c2789211d4035eb0843b85958ecf7cb4a5ea91c2d4decee652c94ce898e433cb"
|
||||||
name = "golang.org/x/sys"
|
name = "golang.org/x/sys"
|
||||||
packages = ["unix"]
|
packages = ["unix"]
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "d0be0721c37eeb5299f245a996a483160fc36940"
|
revision = "4497e2df6f9e69048a54498c7affbbec3294ad47"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:9935525a8c49b8434a0b0a54e1980e94a6fae73aaff45c5d33ba8dff69de123e"
|
digest = "1:9935525a8c49b8434a0b0a54e1980e94a6fae73aaff45c5d33ba8dff69de123e"
|
||||||
|
@ -257,6 +287,11 @@
|
||||||
"github.com/chifflier/nfqueue-go/nfqueue",
|
"github.com/chifflier/nfqueue-go/nfqueue",
|
||||||
"github.com/dustin/go-humanize",
|
"github.com/dustin/go-humanize",
|
||||||
"github.com/elazarl/goproxy",
|
"github.com/elazarl/goproxy",
|
||||||
|
"github.com/evilsocket/islazy/fs",
|
||||||
|
"github.com/evilsocket/islazy/log",
|
||||||
|
"github.com/evilsocket/islazy/str",
|
||||||
|
"github.com/evilsocket/islazy/tui",
|
||||||
|
"github.com/evilsocket/islazy/zip",
|
||||||
"github.com/gobwas/glob",
|
"github.com/gobwas/glob",
|
||||||
"github.com/google/go-github/github",
|
"github.com/google/go-github/github",
|
||||||
"github.com/google/gopacket",
|
"github.com/google/gopacket",
|
||||||
|
@ -268,7 +303,6 @@
|
||||||
"github.com/inconshreveable/go-vhost",
|
"github.com/inconshreveable/go-vhost",
|
||||||
"github.com/jpillora/go-tld",
|
"github.com/jpillora/go-tld",
|
||||||
"github.com/malfunkt/iprange",
|
"github.com/malfunkt/iprange",
|
||||||
"github.com/mattn/go-isatty",
|
|
||||||
"github.com/mdlayher/dhcp6",
|
"github.com/mdlayher/dhcp6",
|
||||||
"github.com/mdlayher/dhcp6/dhcp6opts",
|
"github.com/mdlayher/dhcp6/dhcp6opts",
|
||||||
"github.com/robertkrimen/otto",
|
"github.com/robertkrimen/otto",
|
||||||
|
|
|
@ -77,10 +77,6 @@
|
||||||
name = "github.com/malfunkt/iprange"
|
name = "github.com/malfunkt/iprange"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
|
|
||||||
[[constraint]]
|
|
||||||
name = "github.com/mattn/go-isatty"
|
|
||||||
version = "0.0.3"
|
|
||||||
|
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/mdlayher/dhcp6"
|
name = "github.com/mdlayher/dhcp6"
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
"github.com/evilsocket/islazy/str"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -26,8 +26,8 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
for _, path := range core.SepSplit(core.Trim(os.Getenv(EnvVarName)), ":") {
|
for _, path := range str.SplitBy(str.Trim(os.Getenv(EnvVarName)), ":") {
|
||||||
if path = core.Trim(path); len(path) > 0 {
|
if path = str.Trim(path); len(path) > 0 {
|
||||||
LoadPaths = append(LoadPaths, path)
|
LoadPaths = append(LoadPaths, path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
"github.com/evilsocket/islazy/fs"
|
||||||
|
"github.com/evilsocket/islazy/str"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -62,7 +63,7 @@ func Load(name string) (error, *Caplet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, filename := range names {
|
for _, filename := range names {
|
||||||
if core.Exists(filename) {
|
if fs.Exists(filename) {
|
||||||
cap := &Caplet{
|
cap := &Caplet{
|
||||||
Path: filename,
|
Path: filename,
|
||||||
Code: make([]string, 0),
|
Code: make([]string, 0),
|
||||||
|
@ -77,7 +78,7 @@ func Load(name string) (error, *Caplet) {
|
||||||
scanner := bufio.NewScanner(input)
|
scanner := bufio.NewScanner(input)
|
||||||
scanner.Split(bufio.ScanLines)
|
scanner.Split(bufio.ScanLines)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := core.Trim(scanner.Text())
|
line := str.Trim(scanner.Text())
|
||||||
if line == "" || line[0] == '#' {
|
if line == "" || line[0] == '#' {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
107
core/core.go
107
core/core.go
|
@ -1,29 +1,13 @@
|
||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"archive/zip"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/user"
|
|
||||||
"path/filepath"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
|
"github.com/evilsocket/islazy/str"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
defaultTrimSet = "\r\n\t "
|
|
||||||
)
|
|
||||||
|
|
||||||
func Trim(s string) string {
|
|
||||||
return strings.Trim(s, defaultTrimSet)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TrimRight(s string) string {
|
|
||||||
return strings.TrimRight(s, defaultTrimSet)
|
|
||||||
}
|
|
||||||
|
|
||||||
func UniqueInts(a []int, sorted bool) []int {
|
func UniqueInts(a []int, sorted bool) []int {
|
||||||
tmp := make(map[int]bool)
|
tmp := make(map[int]bool)
|
||||||
uniq := make([]int, 0)
|
uniq := make([]int, 0)
|
||||||
|
@ -43,22 +27,6 @@ func UniqueInts(a []int, sorted bool) []int {
|
||||||
return uniq
|
return uniq
|
||||||
}
|
}
|
||||||
|
|
||||||
func SepSplit(sv string, sep string) []string {
|
|
||||||
filtered := make([]string, 0)
|
|
||||||
for _, part := range strings.Split(sv, sep) {
|
|
||||||
part = Trim(part)
|
|
||||||
if part != "" {
|
|
||||||
filtered = append(filtered, part)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return filtered
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func CommaSplit(csv string) []string {
|
|
||||||
return SepSplit(csv, ",")
|
|
||||||
}
|
|
||||||
|
|
||||||
func ExecSilent(executable string, args []string) (string, error) {
|
func ExecSilent(executable string, args []string) (string, error) {
|
||||||
path, err := exec.LookPath(executable)
|
path, err := exec.LookPath(executable)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -69,7 +37,7 @@ func ExecSilent(executable string, args []string) (string, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
} else {
|
} else {
|
||||||
return Trim(string(raw)), nil
|
return str.Trim(string(raw)), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,72 +48,3 @@ func Exec(executable string, args []string) (string, error) {
|
||||||
}
|
}
|
||||||
return out, err
|
return out, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func Exists(path string) bool {
|
|
||||||
if _, err := os.Stat(path); os.IsNotExist(err) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func ExpandPath(path string) (string, error) {
|
|
||||||
// Check if path is empty
|
|
||||||
if path != "" {
|
|
||||||
if strings.HasPrefix(path, "~") {
|
|
||||||
usr, err := user.Current()
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
} else {
|
|
||||||
// Replace only the first occurrence of ~
|
|
||||||
path = strings.Replace(path, "~", usr.HomeDir, 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return filepath.Abs(path)
|
|
||||||
}
|
|
||||||
return "", nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unzip will decompress a zip archive, moving all files and folders
|
|
||||||
// within the zip file (parameter 1) to an output directory (parameter 2).
|
|
||||||
// Credits to https://golangcode.com/unzip-files-in-go/
|
|
||||||
func Unzip(src string, dest string) ([]string, error) {
|
|
||||||
var filenames []string
|
|
||||||
|
|
||||||
r, err := zip.OpenReader(src)
|
|
||||||
if err != nil {
|
|
||||||
return filenames, err
|
|
||||||
}
|
|
||||||
defer r.Close()
|
|
||||||
|
|
||||||
for _, f := range r.File {
|
|
||||||
rc, err := f.Open()
|
|
||||||
if err != nil {
|
|
||||||
return filenames, err
|
|
||||||
}
|
|
||||||
defer rc.Close()
|
|
||||||
|
|
||||||
// Store filename/path for returning and using later on
|
|
||||||
fpath := filepath.Join(dest, f.Name)
|
|
||||||
|
|
||||||
// Check for ZipSlip. More Info: https://snyk.io/research/zip-slip-vulnerability#go
|
|
||||||
if !strings.HasPrefix(fpath, filepath.Clean(dest)+string(os.PathSeparator)) {
|
|
||||||
return filenames, fmt.Errorf("%s: illegal file path", fpath)
|
|
||||||
}
|
|
||||||
|
|
||||||
filenames = append(filenames, fpath)
|
|
||||||
if f.FileInfo().IsDir() {
|
|
||||||
os.MkdirAll(fpath, os.ModePerm)
|
|
||||||
} else if err = os.MkdirAll(filepath.Dir(fpath), os.ModePerm); err != nil {
|
|
||||||
return filenames, err
|
|
||||||
} else if outFile, err := os.OpenFile(fpath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode()); err != nil {
|
|
||||||
return filenames, err
|
|
||||||
} else {
|
|
||||||
defer outFile.Close()
|
|
||||||
if _, err = io.Copy(outFile, rc); err != nil {
|
|
||||||
return filenames, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return filenames, nil
|
|
||||||
}
|
|
||||||
|
|
122
core/swag.go
122
core/swag.go
|
@ -1,122 +0,0 @@
|
||||||
package core
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/mattn/go-isatty"
|
|
||||||
"os"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
DEBUG = iota
|
|
||||||
INFO
|
|
||||||
IMPORTANT
|
|
||||||
WARNING
|
|
||||||
ERROR
|
|
||||||
FATAL
|
|
||||||
)
|
|
||||||
|
|
||||||
// https://misc.flogisoft.com/bash/tip_colors_and_formatting
|
|
||||||
var (
|
|
||||||
BOLD = "\033[1m"
|
|
||||||
DIM = "\033[2m"
|
|
||||||
|
|
||||||
RED = "\033[31m"
|
|
||||||
GREEN = "\033[32m"
|
|
||||||
BLUE = "\033[34m"
|
|
||||||
YELLOW = "\033[33m"
|
|
||||||
|
|
||||||
FG_BLACK = "\033[30m"
|
|
||||||
FG_WHITE = "\033[97m"
|
|
||||||
|
|
||||||
BG_DGRAY = "\033[100m"
|
|
||||||
BG_RED = "\033[41m"
|
|
||||||
BG_GREEN = "\033[42m"
|
|
||||||
BG_YELLOW = "\033[43m"
|
|
||||||
BG_LBLUE = "\033[104m"
|
|
||||||
|
|
||||||
RESET = "\033[0m"
|
|
||||||
|
|
||||||
LogLabels = map[int]string{
|
|
||||||
DEBUG: "dbg",
|
|
||||||
INFO: "inf",
|
|
||||||
IMPORTANT: "imp",
|
|
||||||
WARNING: "war",
|
|
||||||
ERROR: "err",
|
|
||||||
FATAL: "!!!",
|
|
||||||
}
|
|
||||||
|
|
||||||
LogColors = map[int]string{
|
|
||||||
DEBUG: DIM + FG_BLACK + BG_DGRAY,
|
|
||||||
INFO: FG_WHITE + BG_GREEN,
|
|
||||||
IMPORTANT: FG_WHITE + BG_LBLUE,
|
|
||||||
WARNING: FG_WHITE + BG_YELLOW,
|
|
||||||
ERROR: FG_WHITE + BG_RED,
|
|
||||||
FATAL: FG_WHITE + BG_RED + BOLD,
|
|
||||||
}
|
|
||||||
|
|
||||||
HasColors = true
|
|
||||||
)
|
|
||||||
|
|
||||||
func isDumbTerminal() bool {
|
|
||||||
return os.Getenv("TERM") == "dumb" ||
|
|
||||||
os.Getenv("TERM") == "" ||
|
|
||||||
(!isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd()))
|
|
||||||
}
|
|
||||||
|
|
||||||
func InitSwag(disableColors bool) {
|
|
||||||
if disableColors || isDumbTerminal() {
|
|
||||||
BOLD = ""
|
|
||||||
DIM = ""
|
|
||||||
RED = ""
|
|
||||||
GREEN = ""
|
|
||||||
BLUE = ""
|
|
||||||
YELLOW = ""
|
|
||||||
FG_BLACK = ""
|
|
||||||
FG_WHITE = ""
|
|
||||||
BG_DGRAY = ""
|
|
||||||
BG_RED = ""
|
|
||||||
BG_GREEN = ""
|
|
||||||
BG_YELLOW = ""
|
|
||||||
BG_LBLUE = ""
|
|
||||||
RESET = ""
|
|
||||||
|
|
||||||
LogColors = map[int]string{
|
|
||||||
DEBUG: "",
|
|
||||||
INFO: "",
|
|
||||||
IMPORTANT: "",
|
|
||||||
WARNING: "",
|
|
||||||
ERROR: "",
|
|
||||||
FATAL: "",
|
|
||||||
}
|
|
||||||
|
|
||||||
HasColors = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// W for Wrap
|
|
||||||
func W(e, s string) string {
|
|
||||||
return e + s + RESET
|
|
||||||
}
|
|
||||||
|
|
||||||
func Bold(s string) string {
|
|
||||||
return W(BOLD, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Dim(s string) string {
|
|
||||||
return W(DIM, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Red(s string) string {
|
|
||||||
return W(RED, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Green(s string) string {
|
|
||||||
return W(GREEN, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Blue(s string) string {
|
|
||||||
return W(BLUE, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Yellow(s string) string {
|
|
||||||
return W(YELLOW, s)
|
|
||||||
}
|
|
|
@ -1,95 +0,0 @@
|
||||||
package core
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestIsDumbTerminal(t *testing.T) {
|
|
||||||
term := os.Getenv("TERM")
|
|
||||||
os.Setenv("TERM", "dumb")
|
|
||||||
if !isDumbTerminal() {
|
|
||||||
t.Fatal("Expected false when TERM==dumb")
|
|
||||||
}
|
|
||||||
os.Setenv("TERM", "")
|
|
||||||
if !isDumbTerminal() {
|
|
||||||
t.Fatal("Expected false when TERM empty")
|
|
||||||
}
|
|
||||||
os.Setenv("TERM", term)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestW(t *testing.T) {
|
|
||||||
exp := "<3\033[0m"
|
|
||||||
got := W("<", "3")
|
|
||||||
if got != exp {
|
|
||||||
t.Fatalf("expected '%s', got '%s'", exp, got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestBold(t *testing.T) {
|
|
||||||
exp := "\033[1mgohpers\033[0m"
|
|
||||||
got := Bold("gohpers")
|
|
||||||
if got != exp {
|
|
||||||
t.Fatalf("expected path '%s', got '%s'", exp, got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDim(t *testing.T) {
|
|
||||||
exp := "\033[2mgohpers\033[0m"
|
|
||||||
got := Dim("gohpers")
|
|
||||||
if got != exp {
|
|
||||||
t.Fatalf("expected path '%s', got '%s'", exp, got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRed(t *testing.T) {
|
|
||||||
exp := "\033[31mgohpers\033[0m"
|
|
||||||
got := Red("gohpers")
|
|
||||||
if got != exp {
|
|
||||||
t.Fatalf("expected path '%s', got '%s'", exp, got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGreen(t *testing.T) {
|
|
||||||
exp := "\033[32mgohpers\033[0m"
|
|
||||||
got := Green("gohpers")
|
|
||||||
if got != exp {
|
|
||||||
t.Fatalf("expected path '%s', got '%s'", exp, got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestBlue(t *testing.T) {
|
|
||||||
exp := "\033[34mgohpers\033[0m"
|
|
||||||
got := Blue("gohpers")
|
|
||||||
if got != exp {
|
|
||||||
t.Fatalf("expected path '%s', got '%s'", exp, got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestYellow(t *testing.T) {
|
|
||||||
exp := "\033[33mgohpers\033[0m"
|
|
||||||
got := Yellow("gohpers")
|
|
||||||
if got != exp {
|
|
||||||
t.Fatalf("expected path '%s', got '%s'", exp, got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestInitSwag(t *testing.T) {
|
|
||||||
// Run after other tests to avoid breaking globals
|
|
||||||
// Test InitSwag unsets globals when set
|
|
||||||
BOLD = "\033[1m"
|
|
||||||
InitSwag(true)
|
|
||||||
if BOLD != "" {
|
|
||||||
t.Fatal("expected BOLD to be empty string")
|
|
||||||
}
|
|
||||||
term := os.Getenv("TERM")
|
|
||||||
os.Setenv("TERM", "dumb")
|
|
||||||
BOLD = "\033[1m"
|
|
||||||
InitSwag(false)
|
|
||||||
if BOLD != "" {
|
|
||||||
t.Fatal("expected BOLD to be empty string")
|
|
||||||
}
|
|
||||||
os.Setenv("TERM", term)
|
|
||||||
// Would be good to test BOLD *isn't* unset when we have a TTY
|
|
||||||
// but less trivial to stub os.File.Fd() without complicating architecture
|
|
||||||
}
|
|
|
@ -1,82 +0,0 @@
|
||||||
package core
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"regexp"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestViewLen(t *testing.T) {
|
|
||||||
exp := 2
|
|
||||||
got := viewLen("<3")
|
|
||||||
if got != exp {
|
|
||||||
t.Fatalf("expected '%d', got '%d'", exp, got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMaxLen(t *testing.T) {
|
|
||||||
exp := 7
|
|
||||||
got := maxLen([]string{"go", "python", "ruby", "crystal"})
|
|
||||||
if got != exp {
|
|
||||||
t.Fatalf("expected '%d', got '%d'", exp, got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAlignLeft(t *testing.T) {
|
|
||||||
exp := Alignment(0)
|
|
||||||
got := AlignLeft
|
|
||||||
if got != exp {
|
|
||||||
t.Fatalf("expected '%d', got '%d'", exp, got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAlignCenter(t *testing.T) {
|
|
||||||
exp := Alignment(1)
|
|
||||||
got := AlignCenter
|
|
||||||
if got != exp {
|
|
||||||
t.Fatalf("expected '%d', got '%d'", exp, got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAlignRight(t *testing.T) {
|
|
||||||
exp := Alignment(2)
|
|
||||||
got := AlignRight
|
|
||||||
if got != exp {
|
|
||||||
t.Fatalf("expected '%d', got '%d'", exp, got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetPads(t *testing.T) {
|
|
||||||
lPadExp := -9
|
|
||||||
rPadExp := -8
|
|
||||||
lPadGot, rPadGot := getPads("Pikachu, thunderbolt!", 3, AlignCenter)
|
|
||||||
if rPadGot != rPadExp {
|
|
||||||
t.Fatalf("expected '%d', got '%d'", rPadExp, rPadGot)
|
|
||||||
}
|
|
||||||
if lPadGot != lPadExp {
|
|
||||||
t.Fatalf("expected '%d', got '%d'", lPadExp, lPadGot)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPadded(t *testing.T) {
|
|
||||||
exp := "<3"
|
|
||||||
got := padded("<3", 1, AlignLeft)
|
|
||||||
if got != exp {
|
|
||||||
t.Fatalf("expected '%s', got '%s'", exp, got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAsTable(t *testing.T) {
|
|
||||||
var b bytes.Buffer
|
|
||||||
|
|
||||||
AsTable(&b, []string{"top"}, [][]string{[]string{"bottom"}})
|
|
||||||
|
|
||||||
// look for "+-------+" table style for whichever size
|
|
||||||
match, err := regexp.MatchString(`\++-+\+`, b.String())
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unable to perform regex on table output")
|
|
||||||
}
|
|
||||||
if !match {
|
|
||||||
t.Fatalf("expected table in format not found")
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -148,13 +148,13 @@ func (f PfFirewall) EnableRedirection(r *Redirection, enabled bool) error {
|
||||||
lines := ""
|
lines := ""
|
||||||
scanner := bufio.NewScanner(fd)
|
scanner := bufio.NewScanner(fd)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := core.Trim(scanner.Text())
|
line := str.Trim(scanner.Text())
|
||||||
if line != rule {
|
if line != rule {
|
||||||
lines += line + "\n"
|
lines += line + "\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if core.Trim(lines) == "" {
|
if str.Trim(lines) == "" {
|
||||||
os.Remove(f.filename)
|
os.Remove(f.filename)
|
||||||
f.enable(false)
|
f.enable(false)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -7,6 +7,8 @@ import (
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
"github.com/bettercap/bettercap/core"
|
||||||
"github.com/bettercap/bettercap/network"
|
"github.com/bettercap/bettercap/network"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/str"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LinuxFirewall struct {
|
type LinuxFirewall struct {
|
||||||
|
@ -54,7 +56,7 @@ func (f LinuxFirewall) IsForwardingEnabled() bool {
|
||||||
if out, err := ioutil.ReadFile(IPV4ForwardingFile); err != nil {
|
if out, err := ioutil.ReadFile(IPV4ForwardingFile); err != nil {
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
return core.Trim(string(out)) == "1"
|
return str.Trim(string(out)) == "1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13
log/log.go
13
log/log.go
|
@ -1,26 +1,27 @@
|
||||||
package log
|
package log
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
|
||||||
|
ll "github.com/evilsocket/islazy/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Debug(format string, args ...interface{}) {
|
func Debug(format string, args ...interface{}) {
|
||||||
session.I.Events.Log(core.DEBUG, format, args...)
|
session.I.Events.Log(ll.DEBUG, format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Info(format string, args ...interface{}) {
|
func Info(format string, args ...interface{}) {
|
||||||
session.I.Events.Log(core.INFO, format, args...)
|
session.I.Events.Log(ll.INFO, format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Warning(format string, args ...interface{}) {
|
func Warning(format string, args ...interface{}) {
|
||||||
session.I.Events.Log(core.WARNING, format, args...)
|
session.I.Events.Log(ll.WARNING, format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Error(format string, args ...interface{}) {
|
func Error(format string, args ...interface{}) {
|
||||||
session.I.Events.Log(core.ERROR, format, args...)
|
session.I.Events.Log(ll.ERROR, format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Fatal(format string, args ...interface{}) {
|
func Fatal(format string, args ...interface{}) {
|
||||||
session.I.Events.Log(core.FATAL, format, args...)
|
session.I.Events.Log(ll.FATAL, format, args...)
|
||||||
}
|
}
|
||||||
|
|
13
main.go
13
main.go
|
@ -10,6 +10,9 @@ import (
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/modules"
|
"github.com/bettercap/bettercap/modules"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/str"
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -20,7 +23,7 @@ func main() {
|
||||||
}
|
}
|
||||||
defer sess.Close()
|
defer sess.Close()
|
||||||
|
|
||||||
if !core.HasColors {
|
if !tui.Effects() {
|
||||||
if *sess.Options.NoColors {
|
if *sess.Options.NoColors {
|
||||||
fmt.Printf("\n\nWARNING: Terminal colors have been disabled, view will be very limited.\n\n")
|
fmt.Printf("\n\nWARNING: Terminal colors have been disabled, view will be very limited.\n\n")
|
||||||
} else {
|
} else {
|
||||||
|
@ -30,7 +33,7 @@ func main() {
|
||||||
|
|
||||||
appName := fmt.Sprintf("%s v%s", core.Name, core.Version)
|
appName := fmt.Sprintf("%s v%s", core.Name, core.Version)
|
||||||
|
|
||||||
fmt.Printf("%s (type '%s' for a list of commands)\n\n", core.Bold(appName), core.Bold("help"))
|
fmt.Printf("%s (type '%s' for a list of commands)\n\n", tui.Bold(appName), tui.Bold("help"))
|
||||||
|
|
||||||
sess.Register(modules.NewEventsStream(sess))
|
sess.Register(modules.NewEventsStream(sess))
|
||||||
sess.Register(modules.NewTicker(sess))
|
sess.Register(modules.NewTicker(sess))
|
||||||
|
@ -67,13 +70,13 @@ func main() {
|
||||||
// modules might already be started.
|
// modules might already be started.
|
||||||
for _, cmd := range session.ParseCommands(*sess.Options.Commands) {
|
for _, cmd := range session.ParseCommands(*sess.Options.Commands) {
|
||||||
if err = sess.Run(cmd); err != nil {
|
if err = sess.Run(cmd); err != nil {
|
||||||
log.Error("Error while running '%s': %s", core.Bold(cmd), core.Red(err.Error()))
|
log.Error("Error while running '%s': %s", tui.Bold(cmd), tui.Red(err.Error()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some modules are enabled by default in order
|
// Some modules are enabled by default in order
|
||||||
// to make the interactive session useful.
|
// to make the interactive session useful.
|
||||||
for _, modName := range core.CommaSplit(*sess.Options.AutoStart) {
|
for _, modName := range str.Comma(*sess.Options.AutoStart) {
|
||||||
if err = sess.Run(modName + " on"); err != nil {
|
if err = sess.Run(modName + " on"); err != nil {
|
||||||
log.Fatal("Error while starting module %s: %s", modName, err)
|
log.Fatal("Error while starting module %s: %s", modName, err)
|
||||||
}
|
}
|
||||||
|
@ -82,7 +85,7 @@ func main() {
|
||||||
// Then run the caplet if specified.
|
// Then run the caplet if specified.
|
||||||
if *sess.Options.Caplet != "" {
|
if *sess.Options.Caplet != "" {
|
||||||
if err = sess.RunCaplet(*sess.Options.Caplet); err != nil {
|
if err = sess.RunCaplet(*sess.Options.Caplet); err != nil {
|
||||||
log.Error("Error while running caplet %s: %s", core.Bold(*sess.Options.Caplet), core.Red(err.Error()))
|
log.Error("Error while running caplet %s: %s", tui.Bold(*sess.Options.Caplet), tui.Red(err.Error()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,14 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
"github.com/bettercap/bettercap/tls"
|
"github.com/bettercap/bettercap/tls"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RestAPI struct {
|
type RestAPI struct {
|
||||||
|
@ -135,11 +136,11 @@ func (api *RestAPI) Configure() error {
|
||||||
return err
|
return err
|
||||||
} else if err, api.certFile = api.StringParam("api.rest.certificate"); err != nil {
|
} else if err, api.certFile = api.StringParam("api.rest.certificate"); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if api.certFile, err = core.ExpandPath(api.certFile); err != nil {
|
} else if api.certFile, err = fs.Expand(api.certFile); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if err, api.keyFile = api.StringParam("api.rest.key"); err != nil {
|
} else if err, api.keyFile = api.StringParam("api.rest.key"); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if api.keyFile, err = core.ExpandPath(api.keyFile); err != nil {
|
} else if api.keyFile, err = fs.Expand(api.keyFile); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if err, api.username = api.StringParam("api.rest.username"); err != nil {
|
} else if err, api.username = api.StringParam("api.rest.username"); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -150,7 +151,7 @@ func (api *RestAPI) Configure() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if api.isTLS() {
|
if api.isTLS() {
|
||||||
if !core.Exists(api.certFile) || !core.Exists(api.keyFile) {
|
if !fs.Exists(api.certFile) || !fs.Exists(api.keyFile) {
|
||||||
err, cfg := tls.CertConfigFromModule("api.rest", api.SessionModule)
|
err, cfg := tls.CertConfigFromModule("api.rest", api.SessionModule)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -11,11 +11,12 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/network"
|
"github.com/bettercap/bettercap/network"
|
||||||
|
|
||||||
"github.com/bettercap/gatt"
|
"github.com/bettercap/gatt"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -30,15 +31,15 @@ func (d *BLERecon) getRow(dev *network.BLEDevice) []string {
|
||||||
lastSeen := dev.LastSeen.Format("15:04:05")
|
lastSeen := dev.LastSeen.Format("15:04:05")
|
||||||
|
|
||||||
if sinceSeen <= bleAliveInterval {
|
if sinceSeen <= bleAliveInterval {
|
||||||
lastSeen = core.Bold(lastSeen)
|
lastSeen = tui.Bold(lastSeen)
|
||||||
} else if sinceSeen > blePresentInterval {
|
} else if sinceSeen > blePresentInterval {
|
||||||
lastSeen = core.Dim(lastSeen)
|
lastSeen = tui.Dim(lastSeen)
|
||||||
address = core.Dim(address)
|
address = tui.Dim(address)
|
||||||
}
|
}
|
||||||
|
|
||||||
isConnectable := core.Red("no")
|
isConnectable := tui.Red("no")
|
||||||
if dev.Advertisement.Connectable {
|
if dev.Advertisement.Connectable {
|
||||||
isConnectable = core.Green("yes")
|
isConnectable = tui.Green("yes")
|
||||||
}
|
}
|
||||||
|
|
||||||
return []string{
|
return []string{
|
||||||
|
@ -65,7 +66,7 @@ func (d *BLERecon) Show() error {
|
||||||
columns := []string{"RSSI", "Address", "Name", "Vendor", "Connectable", "Last Seen"}
|
columns := []string{"RSSI", "Address", "Name", "Vendor", "Connectable", "Last Seen"}
|
||||||
|
|
||||||
if nrows > 0 {
|
if nrows > 0 {
|
||||||
core.AsTable(os.Stdout, columns, rows)
|
tui.Table(os.Stdout, columns, rows)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.Session.Refresh()
|
d.Session.Refresh()
|
||||||
|
@ -87,7 +88,7 @@ func parseProperties(ch *gatt.Characteristic) (props []string, isReadable bool,
|
||||||
props = append(props, "read")
|
props = append(props, "read")
|
||||||
}
|
}
|
||||||
if (mask&gatt.CharWriteNR) != 0 || (mask&gatt.CharWrite) != 0 {
|
if (mask&gatt.CharWriteNR) != 0 || (mask&gatt.CharWrite) != 0 {
|
||||||
props = append(props, core.Bold("write"))
|
props = append(props, tui.Bold("write"))
|
||||||
isWritable = true
|
isWritable = true
|
||||||
withResponse = (mask & gatt.CharWriteNR) == 0
|
withResponse = (mask & gatt.CharWriteNR) == 0
|
||||||
}
|
}
|
||||||
|
@ -98,7 +99,7 @@ func parseProperties(ch *gatt.Characteristic) (props []string, isReadable bool,
|
||||||
props = append(props, "indicate")
|
props = append(props, "indicate")
|
||||||
}
|
}
|
||||||
if (mask & gatt.CharSignedWrite) != 0 {
|
if (mask & gatt.CharSignedWrite) != 0 {
|
||||||
props = append(props, core.Yellow("*write"))
|
props = append(props, tui.Yellow("*write"))
|
||||||
isWritable = true
|
isWritable = true
|
||||||
withResponse = true
|
withResponse = true
|
||||||
}
|
}
|
||||||
|
@ -121,7 +122,7 @@ func parseRawData(raw []byte) string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return core.Yellow(s)
|
return tui.Yellow(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *BLERecon) showServices(p gatt.Peripheral, services []*gatt.Service) {
|
func (d *BLERecon) showServices(p gatt.Peripheral, services []*gatt.Service) {
|
||||||
|
@ -138,7 +139,7 @@ func (d *BLERecon) showServices(p gatt.Peripheral, services []*gatt.Service) {
|
||||||
if name == "" {
|
if name == "" {
|
||||||
name = svc.UUID().String()
|
name = svc.UUID().String()
|
||||||
} else {
|
} else {
|
||||||
name = fmt.Sprintf("%s (%s)", core.Green(name), core.Dim(svc.UUID().String()))
|
name = fmt.Sprintf("%s (%s)", tui.Green(name), tui.Dim(svc.UUID().String()))
|
||||||
}
|
}
|
||||||
|
|
||||||
row := []string{
|
row := []string{
|
||||||
|
@ -163,7 +164,7 @@ func (d *BLERecon) showServices(p gatt.Peripheral, services []*gatt.Service) {
|
||||||
if name == "" {
|
if name == "" {
|
||||||
name = " " + ch.UUID().String()
|
name = " " + ch.UUID().String()
|
||||||
} else {
|
} else {
|
||||||
name = fmt.Sprintf(" %s (%s)", core.Green(name), core.Dim(ch.UUID().String()))
|
name = fmt.Sprintf(" %s (%s)", tui.Green(name), tui.Dim(ch.UUID().String()))
|
||||||
}
|
}
|
||||||
|
|
||||||
props, isReadable, isWritable, withResponse := parseProperties(ch)
|
props, isReadable, isWritable, withResponse := parseProperties(ch)
|
||||||
|
@ -186,7 +187,7 @@ func (d *BLERecon) showServices(p gatt.Peripheral, services []*gatt.Service) {
|
||||||
if isReadable {
|
if isReadable {
|
||||||
raw, err := p.ReadCharacteristic(ch)
|
raw, err := p.ReadCharacteristic(ch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
data = core.Red(err.Error())
|
data = tui.Red(err.Error())
|
||||||
} else {
|
} else {
|
||||||
data = parseRawData(raw)
|
data = parseRawData(raw)
|
||||||
}
|
}
|
||||||
|
@ -206,7 +207,7 @@ func (d *BLERecon) showServices(p gatt.Peripheral, services []*gatt.Service) {
|
||||||
if wantsToWrite && !foundToWrite {
|
if wantsToWrite && !foundToWrite {
|
||||||
log.Error("Writable characteristics %s not found.", d.writeUUID)
|
log.Error("Writable characteristics %s not found.", d.writeUUID)
|
||||||
} else {
|
} else {
|
||||||
core.AsTable(os.Stdout, columns, rows)
|
tui.Table(os.Stdout, columns, rows)
|
||||||
d.Session.Refresh()
|
d.Session.Refresh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,14 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/caplets"
|
"github.com/bettercap/bettercap/caplets"
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
|
||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/fs"
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
|
"github.com/evilsocket/islazy/zip"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CapletsModule struct {
|
type CapletsModule struct {
|
||||||
|
@ -83,13 +86,13 @@ func (c *CapletsModule) Show() error {
|
||||||
|
|
||||||
for _, caplet := range caplets {
|
for _, caplet := range caplets {
|
||||||
rows = append(rows, []string{
|
rows = append(rows, []string{
|
||||||
core.Bold(caplet.Name),
|
tui.Bold(caplet.Name),
|
||||||
caplet.Path,
|
caplet.Path,
|
||||||
core.Dim(humanize.Bytes(uint64(caplet.Size))),
|
tui.Dim(humanize.Bytes(uint64(caplet.Size))),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
core.AsTable(os.Stdout, colNames, rows)
|
tui.Table(os.Stdout, colNames, rows)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -104,14 +107,14 @@ func (c *CapletsModule) Paths() error {
|
||||||
rows = append(rows, []string{path})
|
rows = append(rows, []string{path})
|
||||||
}
|
}
|
||||||
|
|
||||||
core.AsTable(os.Stdout, colNames, rows)
|
tui.Table(os.Stdout, colNames, rows)
|
||||||
fmt.Printf("(paths can be customized by defining the %s environment variable)\n", core.Bold(caplets.EnvVarName))
|
fmt.Printf("(paths can be customized by defining the %s environment variable)\n", tui.Bold(caplets.EnvVarName))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CapletsModule) Update() error {
|
func (c *CapletsModule) Update() error {
|
||||||
if !core.Exists(caplets.InstallBase) {
|
if !fs.Exists(caplets.InstallBase) {
|
||||||
log.Info("creating caplets install path %s ...", caplets.InstallBase)
|
log.Info("creating caplets install path %s ...", caplets.InstallBase)
|
||||||
if err := os.MkdirAll(caplets.InstallBase, os.ModePerm); err != nil {
|
if err := os.MkdirAll(caplets.InstallBase, os.ModePerm); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -138,7 +141,7 @@ func (c *CapletsModule) Update() error {
|
||||||
|
|
||||||
log.Info("installing caplets to %s ...", caplets.InstallPath)
|
log.Info("installing caplets to %s ...", caplets.InstallPath)
|
||||||
|
|
||||||
if _, err = core.Unzip("/tmp/caplets.zip", caplets.InstallBase); err != nil {
|
if _, err = zip.Unzip("/tmp/caplets.zip", caplets.InstallBase); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/packets"
|
"github.com/bettercap/bettercap/packets"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
@ -22,6 +21,8 @@ import (
|
||||||
// will fix this > https://github.com/google/gopacket/issues/334
|
// will fix this > https://github.com/google/gopacket/issues/334
|
||||||
"github.com/mdlayher/dhcp6"
|
"github.com/mdlayher/dhcp6"
|
||||||
"github.com/mdlayher/dhcp6/dhcp6opts"
|
"github.com/mdlayher/dhcp6/dhcp6opts"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DHCP6Spoofer struct {
|
type DHCP6Spoofer struct {
|
||||||
|
@ -130,7 +131,7 @@ func (s *DHCP6Spoofer) dhcpAdvertise(pkt gopacket.Packet, solicit dhcp6.Packet,
|
||||||
fqdn = string(raw[0])
|
fqdn = string(raw[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("[%s] Got DHCPv6 Solicit request from %s (%s), sending spoofed advertisement for %d domains.", core.Green("dhcp6"), core.Bold(fqdn), target, len(s.Domains))
|
log.Info("[%s] Got DHCPv6 Solicit request from %s (%s), sending spoofed advertisement for %d domains.", tui.Green("dhcp6"), tui.Bold(fqdn), target, len(s.Domains))
|
||||||
|
|
||||||
err, adv := s.dhcp6For(dhcp6.MessageTypeAdvertise, solicit)
|
err, adv := s.dhcp6For(dhcp6.MessageTypeAdvertise, solicit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -224,7 +225,7 @@ func (s *DHCP6Spoofer) dhcpAdvertise(pkt gopacket.Packet, solicit dhcp6.Packet,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DHCP6Spoofer) dhcpReply(toType string, pkt gopacket.Packet, req dhcp6.Packet, target net.HardwareAddr) {
|
func (s *DHCP6Spoofer) dhcpReply(toType string, pkt gopacket.Packet, req dhcp6.Packet, target net.HardwareAddr) {
|
||||||
log.Debug("Sending spoofed DHCPv6 reply to %s after its %s packet.", core.Bold(target.String()), toType)
|
log.Debug("Sending spoofed DHCPv6 reply to %s after its %s packet.", tui.Bold(target.String()), toType)
|
||||||
|
|
||||||
err, reply := s.dhcp6For(dhcp6.MessageTypeReply, req)
|
err, reply := s.dhcp6For(dhcp6.MessageTypeReply, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -308,9 +309,9 @@ func (s *DHCP6Spoofer) dhcpReply(toType string, pkt gopacket.Packet, req dhcp6.P
|
||||||
}
|
}
|
||||||
|
|
||||||
if h, found := s.Session.Lan.Get(target.String()); found {
|
if h, found := s.Session.Lan.Get(target.String()); found {
|
||||||
log.Info("[%s] IPv6 address %s is now assigned to %s", core.Green("dhcp6"), addr.String(), h)
|
log.Info("[%s] IPv6 address %s is now assigned to %s", tui.Green("dhcp6"), addr.String(), h)
|
||||||
} else {
|
} else {
|
||||||
log.Info("[%s] IPv6 address %s is now assigned to %s", core.Green("dhcp6"), addr.String(), target)
|
log.Info("[%s] IPv6 address %s is now assigned to %s", tui.Green("dhcp6"), addr.String(), target)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Debug("DHCPv6 renew sent to %s", target)
|
log.Debug("DHCPv6 renew sent to %s", target)
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/packets"
|
"github.com/bettercap/bettercap/packets"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
@ -14,6 +13,8 @@ import (
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
"github.com/google/gopacket/pcap"
|
"github.com/google/gopacket/pcap"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DNSSpoofer struct {
|
type DNSSpoofer struct {
|
||||||
|
@ -120,7 +121,7 @@ func (s *DNSSpoofer) Configure() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, entry := range s.Hosts {
|
for _, entry := range s.Hosts {
|
||||||
log.Info("[%s] %s -> %s", core.Green("dns.spoof"), entry.Host, entry.Address)
|
log.Info("[%s] %s -> %s", tui.Green("dns.spoof"), entry.Host, entry.Address)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !s.Session.Firewall.IsForwardingEnabled() {
|
if !s.Session.Firewall.IsForwardingEnabled() {
|
||||||
|
@ -139,7 +140,7 @@ func (s *DNSSpoofer) dnsReply(pkt gopacket.Packet, peth *layers.Ethernet, pudp *
|
||||||
who = t.String()
|
who = t.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("[%s] sending spoofed DNS reply for %s %s to %s.", core.Green("dns"), core.Red(domain), core.Dim(redir), core.Bold(who))
|
log.Info("[%s] sending spoofed DNS reply for %s %s to %s.", tui.Green("dns"), tui.Red(domain), tui.Dim(redir), tui.Bold(who))
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
var src, dst net.IP
|
var src, dst net.IP
|
||||||
|
|
|
@ -8,9 +8,9 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
|
|
||||||
"github.com/gobwas/glob"
|
"github.com/gobwas/glob"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/str"
|
||||||
)
|
)
|
||||||
|
|
||||||
var hostsSplitter = regexp.MustCompile(`\s+`)
|
var hostsSplitter = regexp.MustCompile(`\s+`)
|
||||||
|
@ -57,7 +57,7 @@ func HostsFromFile(filename string) (err error, entries []HostEntry) {
|
||||||
scanner := bufio.NewScanner(input)
|
scanner := bufio.NewScanner(input)
|
||||||
scanner.Split(bufio.ScanLines)
|
scanner.Split(bufio.ScanLines)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := core.Trim(scanner.Text())
|
line := str.Trim(scanner.Text())
|
||||||
if line == "" || line[0] == '#' {
|
if line == "" || line[0] == '#' {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/str"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -32,7 +33,7 @@ func NewIgnoreList() *IgnoreList {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *IgnoreList) checkExpression(expr string) (string, error) {
|
func (l *IgnoreList) checkExpression(expr string) (string, error) {
|
||||||
expr = core.Trim(expr)
|
expr = str.Trim(expr)
|
||||||
if expr == "" {
|
if expr == "" {
|
||||||
return "", ErrEmptyExpression
|
return "", ErrEmptyExpression
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,12 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/fs"
|
||||||
|
"github.com/evilsocket/islazy/str"
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
type EventsStream struct {
|
type EventsStream struct {
|
||||||
|
@ -50,7 +53,7 @@ func NewEventsStream(s *session.Session) *EventsStream {
|
||||||
func(args []string) error {
|
func(args []string) error {
|
||||||
limit := -1
|
limit := -1
|
||||||
if len(args) == 1 {
|
if len(args) == 1 {
|
||||||
arg := core.Trim(args[0])
|
arg := str.Trim(args[0])
|
||||||
limit, _ = strconv.Atoi(arg)
|
limit, _ = strconv.Atoi(arg)
|
||||||
}
|
}
|
||||||
return stream.Show(limit)
|
return stream.Show(limit)
|
||||||
|
@ -62,7 +65,7 @@ func NewEventsStream(s *session.Session) *EventsStream {
|
||||||
tag := args[0]
|
tag := args[0]
|
||||||
timeout := 0
|
timeout := 0
|
||||||
if len(args) == 2 {
|
if len(args) == 2 {
|
||||||
t := core.Trim(args[1])
|
t := str.Trim(args[1])
|
||||||
if t != "" {
|
if t != "" {
|
||||||
n, err := strconv.Atoi(t)
|
n, err := strconv.Atoi(t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -143,7 +146,7 @@ func (s *EventsStream) Configure() (err error) {
|
||||||
if err, output = s.StringParam("events.stream.output"); err == nil {
|
if err, output = s.StringParam("events.stream.output"); err == nil {
|
||||||
if output == "" {
|
if output == "" {
|
||||||
s.output = os.Stdout
|
s.output = os.Stdout
|
||||||
} else if output, err = core.ExpandPath(output); err == nil {
|
} else if output, err = fs.Expand(output); err == nil {
|
||||||
s.output, err = os.OpenFile(output, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
s.output, err = os.OpenFile(output, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||||
}
|
}
|
||||||
} else if err, s.dumpHttpReqs = s.BoolParam("events.stream.http.request.dump"); err != nil {
|
} else if err, s.dumpHttpReqs = s.BoolParam("events.stream.http.request.dump"); err != nil {
|
||||||
|
@ -211,9 +214,9 @@ func (s *EventsStream) Show(limit int) error {
|
||||||
|
|
||||||
func (s *EventsStream) startWaitingFor(tag string, timeout int) error {
|
func (s *EventsStream) startWaitingFor(tag string, timeout int) error {
|
||||||
if timeout == 0 {
|
if timeout == 0 {
|
||||||
log.Info("waiting for event %s ...", core.Green(tag))
|
log.Info("waiting for event %s ...", tui.Green(tag))
|
||||||
} else {
|
} else {
|
||||||
log.Info("waiting for event %s for %d seconds ...", core.Green(tag), timeout)
|
log.Info("waiting for event %s for %d seconds ...", tui.Green(tag), timeout)
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(time.Duration(timeout) * time.Second)
|
time.Sleep(time.Duration(timeout) * time.Second)
|
||||||
s.waitFor = ""
|
s.waitFor = ""
|
||||||
|
|
|
@ -5,11 +5,12 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/network"
|
"github.com/bettercap/bettercap/network"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
|
||||||
"github.com/google/go-github/github"
|
"github.com/google/go-github/github"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
const eventTimeFormat = "15:04:05"
|
const eventTimeFormat = "15:04:05"
|
||||||
|
@ -17,7 +18,7 @@ const eventTimeFormat = "15:04:05"
|
||||||
func (s *EventsStream) viewLogEvent(e session.Event) {
|
func (s *EventsStream) viewLogEvent(e session.Event) {
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] [%s] %s\n",
|
fmt.Fprintf(s.output, "[%s] [%s] [%s] %s\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
||||||
core.Green(e.Tag),
|
tui.Green(e.Tag),
|
||||||
e.Label(),
|
e.Label(),
|
||||||
e.Data.(session.LogMessage).Message)
|
e.Data.(session.LogMessage).Message)
|
||||||
}
|
}
|
||||||
|
@ -37,21 +38,21 @@ func (s *EventsStream) viewWiFiEvent(e session.Event) {
|
||||||
if e.Tag == "wifi.ap.new" {
|
if e.Tag == "wifi.ap.new" {
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] wifi access point %s%s detected as %s%s.\n",
|
fmt.Fprintf(s.output, "[%s] [%s] wifi access point %s%s detected as %s%s.\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
||||||
core.Green(e.Tag),
|
tui.Green(e.Tag),
|
||||||
core.Bold(ap.ESSID()),
|
tui.Bold(ap.ESSID()),
|
||||||
core.Dim(core.Yellow(rssi)),
|
tui.Dim(tui.Yellow(rssi)),
|
||||||
core.Green(ap.BSSID()),
|
tui.Green(ap.BSSID()),
|
||||||
core.Dim(vend))
|
tui.Dim(vend))
|
||||||
} else if e.Tag == "wifi.ap.lost" {
|
} else if e.Tag == "wifi.ap.lost" {
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] wifi access point %s (%s) lost.\n",
|
fmt.Fprintf(s.output, "[%s] [%s] wifi access point %s (%s) lost.\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
||||||
core.Green(e.Tag),
|
tui.Green(e.Tag),
|
||||||
core.Red(ap.ESSID()),
|
tui.Red(ap.ESSID()),
|
||||||
ap.BSSID())
|
ap.BSSID())
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] %s\n",
|
fmt.Fprintf(s.output, "[%s] [%s] %s\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
||||||
core.Green(e.Tag),
|
tui.Green(e.Tag),
|
||||||
ap.String())
|
ap.String())
|
||||||
}
|
}
|
||||||
} else if e.Tag == "wifi.client.probe" {
|
} else if e.Tag == "wifi.client.probe" {
|
||||||
|
@ -69,11 +70,11 @@ func (s *EventsStream) viewWiFiEvent(e session.Event) {
|
||||||
|
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] station %s%s is probing for SSID %s%s\n",
|
fmt.Fprintf(s.output, "[%s] [%s] station %s%s is probing for SSID %s%s\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
||||||
core.Green(e.Tag),
|
tui.Green(e.Tag),
|
||||||
probe.FromAddr.String(),
|
probe.FromAddr.String(),
|
||||||
core.Dim(desc),
|
tui.Dim(desc),
|
||||||
core.Bold(probe.SSID),
|
tui.Bold(probe.SSID),
|
||||||
core.Yellow(rssi))
|
tui.Yellow(rssi))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,21 +96,21 @@ func (s *EventsStream) viewendpointEvent(e session.Event) {
|
||||||
if e.Tag == "endpoint.new" {
|
if e.Tag == "endpoint.new" {
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] endpoint %s%s detected as %s%s.\n",
|
fmt.Fprintf(s.output, "[%s] [%s] endpoint %s%s detected as %s%s.\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
||||||
core.Green(e.Tag),
|
tui.Green(e.Tag),
|
||||||
core.Bold(t.IpAddress),
|
tui.Bold(t.IpAddress),
|
||||||
core.Dim(name),
|
tui.Dim(name),
|
||||||
core.Green(t.HwAddress),
|
tui.Green(t.HwAddress),
|
||||||
core.Dim(vend))
|
tui.Dim(vend))
|
||||||
} else if e.Tag == "endpoint.lost" {
|
} else if e.Tag == "endpoint.lost" {
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] endpoint %s%s lost.\n",
|
fmt.Fprintf(s.output, "[%s] [%s] endpoint %s%s lost.\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
||||||
core.Green(e.Tag),
|
tui.Green(e.Tag),
|
||||||
core.Red(t.IpAddress),
|
tui.Red(t.IpAddress),
|
||||||
core.Dim(vend))
|
tui.Dim(vend))
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] %s\n",
|
fmt.Fprintf(s.output, "[%s] [%s] %s\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
||||||
core.Green(e.Tag),
|
tui.Green(e.Tag),
|
||||||
t.String())
|
t.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +118,7 @@ func (s *EventsStream) viewendpointEvent(e session.Event) {
|
||||||
func (s *EventsStream) viewModuleEvent(e session.Event) {
|
func (s *EventsStream) viewModuleEvent(e session.Event) {
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] %s\n",
|
fmt.Fprintf(s.output, "[%s] [%s] %s\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
||||||
core.Green(e.Tag),
|
tui.Green(e.Tag),
|
||||||
e.Data)
|
e.Data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +128,7 @@ func (s *EventsStream) viewSnifferEvent(e session.Event) {
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] %s\n",
|
fmt.Fprintf(s.output, "[%s] [%s] %s\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
||||||
core.Green(e.Tag),
|
tui.Green(e.Tag),
|
||||||
e.Data.(SnifferEvent).Message)
|
e.Data.(SnifferEvent).Message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,9 +137,9 @@ func (s *EventsStream) viewSynScanEvent(e session.Event) {
|
||||||
se := e.Data.(SynScanEvent)
|
se := e.Data.(SynScanEvent)
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] found open port %d for %s\n",
|
fmt.Fprintf(s.output, "[%s] [%s] found open port %d for %s\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
||||||
core.Green(e.Tag),
|
tui.Green(e.Tag),
|
||||||
se.Port,
|
se.Port,
|
||||||
core.Bold(se.Address))
|
tui.Bold(se.Address))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *EventsStream) viewUpdateEvent(e session.Event) {
|
func (s *EventsStream) viewUpdateEvent(e session.Event) {
|
||||||
|
@ -146,8 +147,8 @@ func (s *EventsStream) viewUpdateEvent(e session.Event) {
|
||||||
|
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] an update to version %s is available at %s\n",
|
fmt.Fprintf(s.output, "[%s] [%s] an update to version %s is available at %s\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
||||||
core.Bold(core.Yellow(e.Tag)),
|
tui.Bold(tui.Yellow(e.Tag)),
|
||||||
core.Bold(*update.TagName),
|
tui.Bold(*update.TagName),
|
||||||
*update.HTMLURL)
|
*update.HTMLURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +170,7 @@ func (s *EventsStream) View(e session.Event, refresh bool) {
|
||||||
} else if e.Tag == "update.available" {
|
} else if e.Tag == "update.available" {
|
||||||
s.viewUpdateEvent(e)
|
s.viewUpdateEvent(e)
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] %v\n", e.Time.Format(eventTimeFormat), core.Green(e.Tag), e)
|
fmt.Fprintf(s.output, "[%s] [%s] %v\n", e.Time.Format(eventTimeFormat), tui.Green(e.Tag), e)
|
||||||
}
|
}
|
||||||
|
|
||||||
if refresh && s.output == os.Stdout {
|
if refresh && s.output == os.Stdout {
|
||||||
|
|
|
@ -6,9 +6,10 @@ package modules
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/network"
|
"github.com/bettercap/bettercap/network"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *EventsStream) viewBLEEvent(e session.Event) {
|
func (s *EventsStream) viewBLEEvent(e session.Event) {
|
||||||
|
@ -16,40 +17,40 @@ func (s *EventsStream) viewBLEEvent(e session.Event) {
|
||||||
dev := e.Data.(*network.BLEDevice)
|
dev := e.Data.(*network.BLEDevice)
|
||||||
name := dev.Device.Name()
|
name := dev.Device.Name()
|
||||||
if name != "" {
|
if name != "" {
|
||||||
name = " " + core.Bold(name)
|
name = " " + tui.Bold(name)
|
||||||
}
|
}
|
||||||
vend := dev.Vendor
|
vend := dev.Vendor
|
||||||
if vend != "" {
|
if vend != "" {
|
||||||
vend = fmt.Sprintf(" (%s)", core.Yellow(vend))
|
vend = fmt.Sprintf(" (%s)", tui.Yellow(vend))
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] new BLE device%s detected as %s%s %s.\n",
|
fmt.Fprintf(s.output, "[%s] [%s] new BLE device%s detected as %s%s %s.\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
||||||
core.Green(e.Tag),
|
tui.Green(e.Tag),
|
||||||
name,
|
name,
|
||||||
dev.Device.ID(),
|
dev.Device.ID(),
|
||||||
vend,
|
vend,
|
||||||
core.Dim(fmt.Sprintf("%d dBm", dev.RSSI)))
|
tui.Dim(fmt.Sprintf("%d dBm", dev.RSSI)))
|
||||||
} else if e.Tag == "ble.device.lost" {
|
} else if e.Tag == "ble.device.lost" {
|
||||||
dev := e.Data.(*network.BLEDevice)
|
dev := e.Data.(*network.BLEDevice)
|
||||||
name := dev.Device.Name()
|
name := dev.Device.Name()
|
||||||
if name != "" {
|
if name != "" {
|
||||||
name = " " + core.Bold(name)
|
name = " " + tui.Bold(name)
|
||||||
}
|
}
|
||||||
vend := dev.Vendor
|
vend := dev.Vendor
|
||||||
if vend != "" {
|
if vend != "" {
|
||||||
vend = fmt.Sprintf(" (%s)", core.Yellow(vend))
|
vend = fmt.Sprintf(" (%s)", tui.Yellow(vend))
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] BLE device%s %s%s lost.\n",
|
fmt.Fprintf(s.output, "[%s] [%s] BLE device%s %s%s lost.\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
||||||
core.Green(e.Tag),
|
tui.Green(e.Tag),
|
||||||
name,
|
name,
|
||||||
dev.Device.ID(),
|
dev.Device.ID(),
|
||||||
vend)
|
vend)
|
||||||
} /* else {
|
} /* else {
|
||||||
fmt.Fprintf(s.output,"[%s] [%s]\n",
|
fmt.Fprintf(s.output,"[%s] [%s]\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
||||||
core.Green(e.Tag))
|
tui.Green(e.Tag))
|
||||||
} */
|
} */
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,9 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -67,20 +68,20 @@ func (s *EventsStream) dumpForm(body []byte) string {
|
||||||
value = parts[1]
|
value = parts[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
form = append(form, fmt.Sprintf("%s=%s", core.Green(name), core.Bold(core.Red(value))))
|
form = append(form, fmt.Sprintf("%s=%s", tui.Green(name), tui.Bold(tui.Red(value))))
|
||||||
} else {
|
} else {
|
||||||
value, err := url.QueryUnescape(v)
|
value, err := url.QueryUnescape(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
value = v
|
value = v
|
||||||
}
|
}
|
||||||
form = append(form, fmt.Sprintf("%s", core.Bold(core.Red(value))))
|
form = append(form, fmt.Sprintf("%s", tui.Bold(tui.Red(value))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "\n" + strings.Join(form, "&") + "\n"
|
return "\n" + strings.Join(form, "&") + "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *EventsStream) dumpText(body []byte) string {
|
func (s *EventsStream) dumpText(body []byte) string {
|
||||||
return "\n" + core.Bold(core.Red(string(body))) + "\n"
|
return "\n" + tui.Bold(tui.Red(string(body))) + "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *EventsStream) dumpGZIP(body []byte) string {
|
func (s *EventsStream) dumpGZIP(body []byte) string {
|
||||||
|
@ -105,7 +106,7 @@ func (s *EventsStream) dumpJSON(body []byte) string {
|
||||||
pretty = string(buf.Bytes())
|
pretty = string(buf.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
return "\n" + reJsonKey.ReplaceAllString(pretty, core.W(core.GREEN, `$1:`)) + "\n"
|
return "\n" + reJsonKey.ReplaceAllString(pretty, tui.Green(`$1:`)) + "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *EventsStream) dumpXML(body []byte) string {
|
func (s *EventsStream) dumpXML(body []byte) string {
|
||||||
|
@ -123,15 +124,15 @@ func (s *EventsStream) viewHttpRequest(e session.Event) {
|
||||||
|
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] %s\n",
|
fmt.Fprintf(s.output, "[%s] [%s] %s\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
||||||
core.Green(e.Tag),
|
tui.Green(e.Tag),
|
||||||
se.Message)
|
se.Message)
|
||||||
|
|
||||||
if s.shouldDumpHttpRequest(req) {
|
if s.shouldDumpHttpRequest(req) {
|
||||||
dump := fmt.Sprintf("%s %s %s\n", core.Bold(req.Method), req.URL, core.Dim(req.Proto))
|
dump := fmt.Sprintf("%s %s %s\n", tui.Bold(req.Method), req.URL, tui.Dim(req.Proto))
|
||||||
dump += fmt.Sprintf("%s: %s\n", core.Blue("Host"), core.Yellow(req.Host))
|
dump += fmt.Sprintf("%s: %s\n", tui.Blue("Host"), tui.Yellow(req.Host))
|
||||||
for name, values := range req.Headers {
|
for name, values := range req.Headers {
|
||||||
for _, value := range values {
|
for _, value := range values {
|
||||||
dump += fmt.Sprintf("%s: %s\n", core.Blue(name), core.Yellow(value))
|
dump += fmt.Sprintf("%s: %s\n", tui.Blue(name), tui.Yellow(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,14 +162,14 @@ func (s *EventsStream) viewHttpResponse(e session.Event) {
|
||||||
|
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] %s\n",
|
fmt.Fprintf(s.output, "[%s] [%s] %s\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
||||||
core.Green(e.Tag),
|
tui.Green(e.Tag),
|
||||||
se.Message)
|
se.Message)
|
||||||
|
|
||||||
if s.shouldDumpHttpResponse(res) {
|
if s.shouldDumpHttpResponse(res) {
|
||||||
dump := fmt.Sprintf("%s %s\n", core.Dim(res.Protocol), res.Status)
|
dump := fmt.Sprintf("%s %s\n", tui.Dim(res.Protocol), res.Status)
|
||||||
for name, values := range res.Headers {
|
for name, values := range res.Headers {
|
||||||
for _, value := range values {
|
for _, value := range values {
|
||||||
dump += fmt.Sprintf("%s: %s\n", core.Blue(name), core.Yellow(value))
|
dump += fmt.Sprintf("%s: %s\n", tui.Blue(name), tui.Yellow(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,13 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
|
||||||
"github.com/adrianmo/go-nmea"
|
"github.com/adrianmo/go-nmea"
|
||||||
"github.com/tarm/serial"
|
"github.com/tarm/serial"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/str"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GPS struct {
|
type GPS struct {
|
||||||
|
@ -97,7 +98,7 @@ func (gps *GPS) readLine() (line string, err error) {
|
||||||
return
|
return
|
||||||
} else if n == 1 {
|
} else if n == 1 {
|
||||||
if b[0] == '\n' {
|
if b[0] == '\n' {
|
||||||
return core.Trim(line), nil
|
return str.Trim(line), nil
|
||||||
} else {
|
} else {
|
||||||
line += string(b[0])
|
line += string(b[0])
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/firewall"
|
"github.com/bettercap/bettercap/firewall"
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
@ -23,6 +22,9 @@ import (
|
||||||
|
|
||||||
"github.com/elazarl/goproxy"
|
"github.com/elazarl/goproxy"
|
||||||
"github.com/inconshreveable/go-vhost"
|
"github.com/inconshreveable/go-vhost"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/fs"
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -116,7 +118,7 @@ func (p *HTTPProxy) Configure(address string, proxyPort int, httpPort int, scrip
|
||||||
|
|
||||||
if strings.HasPrefix(jsToInject, "http://") || strings.HasPrefix(jsToInject, "https://") {
|
if strings.HasPrefix(jsToInject, "http://") || strings.HasPrefix(jsToInject, "https://") {
|
||||||
p.jsHook = fmt.Sprintf("<script src=\"%s\" type=\"text/javascript\"></script></head>", jsToInject)
|
p.jsHook = fmt.Sprintf("<script src=\"%s\" type=\"text/javascript\"></script></head>", jsToInject)
|
||||||
} else if core.Exists(jsToInject) {
|
} else if fs.Exists(jsToInject) {
|
||||||
if data, err := ioutil.ReadFile(jsToInject); err != nil {
|
if data, err := ioutil.ReadFile(jsToInject); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
|
@ -187,7 +189,7 @@ func TLSConfigFromCA(ca *tls.Certificate) func(host string, ctx *goproxy.ProxyCt
|
||||||
|
|
||||||
cert := getCachedCert(hostname, port)
|
cert := getCachedCert(hostname, port)
|
||||||
if cert == nil {
|
if cert == nil {
|
||||||
log.Debug("Creating spoofed certificate for %s:%d", core.Yellow(hostname), port)
|
log.Debug("Creating spoofed certificate for %s:%d", tui.Yellow(hostname), port)
|
||||||
cert, err = btls.SignCertificateForHost(ca, hostname, port)
|
cert, err = btls.SignCertificateForHost(ca, hostname, port)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warning("Cannot sign host certificate with provided CA: %s", err)
|
log.Warning("Cannot sign host certificate with provided CA: %s", err)
|
||||||
|
@ -298,7 +300,7 @@ func (p *HTTPProxy) httpsWorker() error {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug("[%s] proxying connection from %s to %s", core.Green("https.proxy"), core.Bold(stripPort(c.RemoteAddr().String())), core.Yellow(hostname))
|
log.Debug("[%s] proxying connection from %s to %s", tui.Green("https.proxy"), tui.Bold(stripPort(c.RemoteAddr().String())), tui.Yellow(hostname))
|
||||||
|
|
||||||
req := &http.Request{
|
req := &http.Request{
|
||||||
Method: "CONNECT",
|
Method: "CONNECT",
|
||||||
|
@ -320,12 +322,12 @@ func (p *HTTPProxy) Start() {
|
||||||
go func() {
|
go func() {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
strip := core.Yellow("enabled")
|
strip := tui.Yellow("enabled")
|
||||||
if !p.stripper.Enabled() {
|
if !p.stripper.Enabled() {
|
||||||
strip = core.Dim("disabled")
|
strip = tui.Dim("disabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("%s started on %s (sslstrip %s)", core.Green(p.Name), p.Server.Addr, strip)
|
log.Info("%s started on %s (sslstrip %s)", tui.Green(p.Name), p.Server.Addr, strip)
|
||||||
|
|
||||||
if p.isTLS {
|
if p.isTLS {
|
||||||
err = p.httpsWorker()
|
err = p.httpsWorker()
|
||||||
|
|
|
@ -5,10 +5,11 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
|
|
||||||
"github.com/elazarl/goproxy"
|
"github.com/elazarl/goproxy"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *HTTPProxy) fixRequestHeaders(req *http.Request) {
|
func (p *HTTPProxy) fixRequestHeaders(req *http.Request) {
|
||||||
|
@ -20,7 +21,7 @@ func (p *HTTPProxy) fixRequestHeaders(req *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *HTTPProxy) onRequestFilter(req *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response) {
|
func (p *HTTPProxy) onRequestFilter(req *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response) {
|
||||||
log.Debug("(%s) < %s %s %s%s", core.Green(p.Name), req.RemoteAddr, req.Method, req.Host, req.URL.Path)
|
log.Debug("(%s) < %s %s %s%s", tui.Green(p.Name), req.RemoteAddr, req.Method, req.Host, req.URL.Path)
|
||||||
|
|
||||||
p.fixRequestHeaders(req)
|
p.fixRequestHeaders(req)
|
||||||
|
|
||||||
|
@ -99,11 +100,11 @@ func (p *HTTPProxy) doScriptInjection(res *http.Response, cType string) (error,
|
||||||
return err, nil
|
return err, nil
|
||||||
} else if html := string(raw); strings.Contains(html, "</head>") {
|
} else if html := string(raw); strings.Contains(html, "</head>") {
|
||||||
log.Info("(%s) > injecting javascript (%d bytes) into %s (%d bytes) for %s",
|
log.Info("(%s) > injecting javascript (%d bytes) into %s (%d bytes) for %s",
|
||||||
core.Green(p.Name),
|
tui.Green(p.Name),
|
||||||
len(p.jsHook),
|
len(p.jsHook),
|
||||||
core.Yellow(res.Request.Host+res.Request.URL.Path),
|
tui.Yellow(res.Request.Host+res.Request.URL.Path),
|
||||||
len(raw),
|
len(raw),
|
||||||
core.Bold(strings.Split(res.Request.RemoteAddr, ":")[0]))
|
tui.Bold(strings.Split(res.Request.RemoteAddr, ":")[0]))
|
||||||
|
|
||||||
html = strings.Replace(html, "</head>", p.jsHook, -1)
|
html = strings.Replace(html, "</head>", p.jsHook, -1)
|
||||||
newResp := goproxy.NewResponse(res.Request, cType, res.StatusCode, html)
|
newResp := goproxy.NewResponse(res.Request, cType, res.StatusCode, html)
|
||||||
|
@ -125,7 +126,7 @@ func (p *HTTPProxy) onResponseFilter(res *http.Response, ctx *goproxy.ProxyCtx)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug("(%s) > %s %s %s%s", core.Green(p.Name), res.Request.RemoteAddr, res.Request.Method, res.Request.Host, res.Request.URL.Path)
|
log.Debug("(%s) > %s %s %s%s", tui.Green(p.Name), res.Request.RemoteAddr, res.Request.Method, res.Request.Host, res.Request.URL.Path)
|
||||||
|
|
||||||
p.fixResponseHeaders(res)
|
p.fixResponseHeaders(res)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/packets"
|
"github.com/bettercap/bettercap/packets"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
@ -18,6 +17,8 @@ import (
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
"github.com/google/gopacket/pcap"
|
"github.com/google/gopacket/pcap"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -66,7 +67,7 @@ func (s *SSLStripper) dnsReply(pkt gopacket.Packet, peth *layers.Ethernet, pudp
|
||||||
who = t.String()
|
who = t.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug("[%s] Sending spoofed DNS reply for %s %s to %s.", core.Green("dns"), core.Red(domain), core.Dim(redir), core.Bold(who))
|
log.Debug("[%s] Sending spoofed DNS reply for %s %s to %s.", tui.Green("dns"), tui.Red(domain), tui.Dim(redir), tui.Bold(who))
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
var src, dst net.IP
|
var src, dst net.IP
|
||||||
|
@ -245,7 +246,7 @@ func (s *SSLStripper) Preprocess(req *http.Request, ctx *goproxy.ProxyCtx) (redi
|
||||||
// handle stripped domains
|
// handle stripped domains
|
||||||
original := s.hosts.Unstrip(req.Host)
|
original := s.hosts.Unstrip(req.Host)
|
||||||
if original != nil {
|
if original != nil {
|
||||||
log.Info("[%s] Replacing host %s with %s in request from %s", core.Green("sslstrip"), core.Bold(req.Host), core.Yellow(original.Hostname), req.RemoteAddr)
|
log.Info("[%s] Replacing host %s with %s in request from %s", tui.Green("sslstrip"), tui.Bold(req.Host), tui.Yellow(original.Hostname), req.RemoteAddr)
|
||||||
req.Host = original.Hostname
|
req.Host = original.Hostname
|
||||||
req.URL.Host = original.Hostname
|
req.URL.Host = original.Hostname
|
||||||
req.Header.Set("Host", original.Hostname)
|
req.Header.Set("Host", original.Hostname)
|
||||||
|
@ -254,7 +255,7 @@ func (s *SSLStripper) Preprocess(req *http.Request, ctx *goproxy.ProxyCtx) (redi
|
||||||
if !s.cookies.IsClean(req) {
|
if !s.cookies.IsClean(req) {
|
||||||
// check if we need to redirect the user in order
|
// check if we need to redirect the user in order
|
||||||
// to make unknown session cookies expire
|
// to make unknown session cookies expire
|
||||||
log.Info("[%s] Sending expired cookies for %s to %s", core.Green("sslstrip"), core.Yellow(req.Host), req.RemoteAddr)
|
log.Info("[%s] Sending expired cookies for %s to %s", tui.Green("sslstrip"), tui.Yellow(req.Host), req.RemoteAddr)
|
||||||
s.cookies.Track(req)
|
s.cookies.Track(req)
|
||||||
redir = s.cookies.Expire(req)
|
redir = s.cookies.Expire(req)
|
||||||
}
|
}
|
||||||
|
@ -267,7 +268,7 @@ func (s *SSLStripper) isMaxRedirs(hostname string) bool {
|
||||||
if nredirs, found := s.redirs[hostname]; found {
|
if nredirs, found := s.redirs[hostname]; found {
|
||||||
// reached the threshold?
|
// reached the threshold?
|
||||||
if nredirs >= maxRedirs {
|
if nredirs >= maxRedirs {
|
||||||
log.Warning("[%s] Hit max redirections for %s, serving HTTPS.", core.Green("sslstrip"), hostname)
|
log.Warning("[%s] Hit max redirections for %s, serving HTTPS.", tui.Green("sslstrip"), hostname)
|
||||||
// reset
|
// reset
|
||||||
delete(s.redirs, hostname)
|
delete(s.redirs, hostname)
|
||||||
return true
|
return true
|
||||||
|
@ -299,7 +300,7 @@ func (s *SSLStripper) Process(res *http.Response, ctx *goproxy.ProxyCtx) {
|
||||||
// are we getting redirected from http to https?
|
// are we getting redirected from http to https?
|
||||||
if orig.Scheme == "http" && location.Scheme == "https" {
|
if orig.Scheme == "http" && location.Scheme == "https" {
|
||||||
|
|
||||||
log.Info("[%s] Got redirection from HTTPS to HTTP: %s -> %s", core.Green("sslstrip"), core.Yellow("http://"+origHost), core.Bold("https://"+newHost))
|
log.Info("[%s] Got redirection from HTTPS to HTTP: %s -> %s", tui.Green("sslstrip"), tui.Yellow("http://"+origHost), tui.Bold("https://"+newHost))
|
||||||
|
|
||||||
// if we still did not reach max redirections, strip the URL down to
|
// if we still did not reach max redirections, strip the URL down to
|
||||||
// an alternative HTTP version
|
// an alternative HTTP version
|
||||||
|
@ -342,11 +343,11 @@ func (s *SSLStripper) Process(res *http.Response, ctx *goproxy.ProxyCtx) {
|
||||||
if nurls == 1 {
|
if nurls == 1 {
|
||||||
plural = ""
|
plural = ""
|
||||||
}
|
}
|
||||||
log.Info("[%s] Stripping %d SSL link%s from %s", core.Green("sslstrip"), nurls, plural, core.Bold(res.Request.Host))
|
log.Info("[%s] Stripping %d SSL link%s from %s", tui.Green("sslstrip"), nurls, plural, tui.Bold(res.Request.Host))
|
||||||
}
|
}
|
||||||
|
|
||||||
for url, stripped := range urls {
|
for url, stripped := range urls {
|
||||||
log.Debug("Stripping url %s to %s", core.Bold(url), core.Yellow(stripped))
|
log.Debug("Stripping url %s to %s", tui.Bold(url), tui.Yellow(stripped))
|
||||||
|
|
||||||
body = strings.Replace(body, url, stripped, -1)
|
body = strings.Replace(body, url, stripped, -1)
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,12 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
"github.com/bettercap/bettercap/tls"
|
"github.com/bettercap/bettercap/tls"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/fs"
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HttpServer struct {
|
type HttpServer struct {
|
||||||
|
@ -103,7 +105,7 @@ func (httpd *HttpServer) Configure() error {
|
||||||
fileServer := http.FileServer(http.Dir(path))
|
fileServer := http.FileServer(http.Dir(path))
|
||||||
|
|
||||||
router.HandleFunc("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
router.HandleFunc("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Info("(%s) %s %s %s%s", core.Green("httpd"), core.Bold(strings.Split(r.RemoteAddr, ":")[0]), r.Method, r.Host, r.URL.Path)
|
log.Info("(%s) %s %s %s%s", tui.Green("httpd"), tui.Bold(strings.Split(r.RemoteAddr, ":")[0]), r.Method, r.Host, r.URL.Path)
|
||||||
fileServer.ServeHTTP(w, r)
|
fileServer.ServeHTTP(w, r)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
@ -121,18 +123,18 @@ func (httpd *HttpServer) Configure() error {
|
||||||
|
|
||||||
if err, certFile = httpd.StringParam("http.server.certificate"); err != nil {
|
if err, certFile = httpd.StringParam("http.server.certificate"); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if certFile, err = core.ExpandPath(certFile); err != nil {
|
} else if certFile, err = fs.Expand(certFile); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err, keyFile = httpd.StringParam("http.server.key"); err != nil {
|
if err, keyFile = httpd.StringParam("http.server.key"); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if keyFile, err = core.ExpandPath(keyFile); err != nil {
|
} else if keyFile, err = fs.Expand(keyFile); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if certFile != "" && keyFile != "" {
|
if certFile != "" && keyFile != "" {
|
||||||
if !core.Exists(certFile) || !core.Exists(keyFile) {
|
if !fs.Exists(certFile) || !fs.Exists(keyFile) {
|
||||||
err, cfg := tls.CertConfigFromModule("http.server", httpd.SessionModule)
|
err, cfg := tls.CertConfigFromModule("http.server", httpd.SessionModule)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package modules
|
package modules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
"github.com/bettercap/bettercap/tls"
|
"github.com/bettercap/bettercap/tls"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HttpsProxy struct {
|
type HttpsProxy struct {
|
||||||
|
@ -107,11 +108,11 @@ func (p *HttpsProxy) Configure() error {
|
||||||
return err
|
return err
|
||||||
} else if err, certFile = p.StringParam("https.proxy.certificate"); err != nil {
|
} else if err, certFile = p.StringParam("https.proxy.certificate"); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if certFile, err = core.ExpandPath(certFile); err != nil {
|
} else if certFile, err = fs.Expand(certFile); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if err, keyFile = p.StringParam("https.proxy.key"); err != nil {
|
} else if err, keyFile = p.StringParam("https.proxy.key"); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if keyFile, err = core.ExpandPath(keyFile); err != nil {
|
} else if keyFile, err = fs.Expand(keyFile); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if err, scriptPath = p.StringParam("https.proxy.script"); err != nil {
|
} else if err, scriptPath = p.StringParam("https.proxy.script"); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -119,7 +120,7 @@ func (p *HttpsProxy) Configure() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !core.Exists(certFile) || !core.Exists(keyFile) {
|
if !fs.Exists(certFile) || !fs.Exists(keyFile) {
|
||||||
err, cfg := tls.CertConfigFromModule("https.proxy", p.SessionModule)
|
err, cfg := tls.CertConfigFromModule("https.proxy", p.SessionModule)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -10,6 +10,8 @@ import (
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/network"
|
"github.com/bettercap/bettercap/network"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MacChanger struct {
|
type MacChanger struct {
|
||||||
|
@ -110,14 +112,14 @@ func (mc *MacChanger) Start() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
return mc.SetRunning(true, func() {
|
return mc.SetRunning(true, func() {
|
||||||
log.Info("Interface mac address set to %s", core.Bold(mc.fakeMac.String()))
|
log.Info("Interface mac address set to %s", tui.Bold(mc.fakeMac.String()))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mc *MacChanger) Stop() error {
|
func (mc *MacChanger) Stop() error {
|
||||||
return mc.SetRunning(false, func() {
|
return mc.SetRunning(false, func() {
|
||||||
if err := mc.setMac(mc.originalMac); err == nil {
|
if err := mc.setMac(mc.originalMac); err == nil {
|
||||||
log.Info("Interface mac address restored to %s", core.Bold(mc.originalMac.String()))
|
log.Info("Interface mac address restored to %s", tui.Bold(mc.originalMac.String()))
|
||||||
} else {
|
} else {
|
||||||
log.Error("Error while restoring mac address: %s", err)
|
log.Error("Error while restoring mac address: %s", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,11 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/packets"
|
"github.com/bettercap/bettercap/packets"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MySQLServer struct {
|
type MySQLServer struct {
|
||||||
|
@ -103,10 +104,10 @@ func (mysql *MySQLServer) Start() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
return mysql.SetRunning(true, func() {
|
return mysql.SetRunning(true, func() {
|
||||||
log.Info("[%s] server starting on address %s", core.Green("mysql.server"), mysql.address)
|
log.Info("[%s] server starting on address %s", tui.Green("mysql.server"), mysql.address)
|
||||||
for mysql.Running() {
|
for mysql.Running() {
|
||||||
if conn, err := mysql.listener.AcceptTCP(); err != nil {
|
if conn, err := mysql.listener.AcceptTCP(); err != nil {
|
||||||
log.Warning("[%s] error while accepting tcp connection: %s", core.Green("mysql.server"), err)
|
log.Warning("[%s] error while accepting tcp connection: %s", tui.Green("mysql.server"), err)
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
@ -117,13 +118,13 @@ func (mysql *MySQLServer) Start() error {
|
||||||
reader := bufio.NewReader(conn)
|
reader := bufio.NewReader(conn)
|
||||||
read := 0
|
read := 0
|
||||||
|
|
||||||
log.Info("[%s] connection from %s", core.Green("mysql.server"), clientAddress)
|
log.Info("[%s] connection from %s", tui.Green("mysql.server"), clientAddress)
|
||||||
|
|
||||||
if _, err := conn.Write(packets.MySQLGreeting); err != nil {
|
if _, err := conn.Write(packets.MySQLGreeting); err != nil {
|
||||||
log.Warning("[%s] error while writing server greeting: %s", core.Green("mysql.server"), err)
|
log.Warning("[%s] error while writing server greeting: %s", tui.Green("mysql.server"), err)
|
||||||
continue
|
continue
|
||||||
} else if read, err = reader.Read(readBuffer); err != nil {
|
} else if read, err = reader.Read(readBuffer); err != nil {
|
||||||
log.Warning("[%s] error while reading client message: %s", core.Green("mysql.server"), err)
|
log.Warning("[%s] error while reading client message: %s", tui.Green("mysql.server"), err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,38 +135,38 @@ func (mysql *MySQLServer) Start() error {
|
||||||
loadData := string(capabilities[8])
|
loadData := string(capabilities[8])
|
||||||
username := string(bytes.Split(readBuffer[36:], []byte{0})[0])
|
username := string(bytes.Split(readBuffer[36:], []byte{0})[0])
|
||||||
|
|
||||||
log.Info("[%s] can use LOAD DATA LOCAL: %s", core.Green("mysql.server"), loadData)
|
log.Info("[%s] can use LOAD DATA LOCAL: %s", tui.Green("mysql.server"), loadData)
|
||||||
log.Info("[%s] login request username: %s", core.Green("mysql.server"), core.Bold(username))
|
log.Info("[%s] login request username: %s", tui.Green("mysql.server"), tui.Bold(username))
|
||||||
|
|
||||||
if _, err := conn.Write(packets.MySQLFirstResponseOK); err != nil {
|
if _, err := conn.Write(packets.MySQLFirstResponseOK); err != nil {
|
||||||
log.Warning("[%s] error while writing server first response ok: %s", core.Green("mysql.server"), err)
|
log.Warning("[%s] error while writing server first response ok: %s", tui.Green("mysql.server"), err)
|
||||||
continue
|
continue
|
||||||
} else if _, err := reader.Read(readBuffer); err != nil {
|
} else if _, err := reader.Read(readBuffer); err != nil {
|
||||||
log.Warning("[%s] error while reading client message: %s", core.Green("mysql.server"), err)
|
log.Warning("[%s] error while reading client message: %s", tui.Green("mysql.server"), err)
|
||||||
continue
|
continue
|
||||||
} else if _, err := conn.Write(packets.MySQLGetFile(mysql.infile)); err != nil {
|
} else if _, err := conn.Write(packets.MySQLGetFile(mysql.infile)); err != nil {
|
||||||
log.Warning("[%s] error while writing server get file request: %s", core.Green("mysql.server"), err)
|
log.Warning("[%s] error while writing server get file request: %s", tui.Green("mysql.server"), err)
|
||||||
continue
|
continue
|
||||||
} else if read, err = reader.Read(readBuffer); err != nil {
|
} else if read, err = reader.Read(readBuffer); err != nil {
|
||||||
log.Warning("[%s] error while readind buffer: %s", core.Green("mysql.server"), err)
|
log.Warning("[%s] error while readind buffer: %s", tui.Green("mysql.server"), err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(mysql.infile, "\\") {
|
if strings.HasPrefix(mysql.infile, "\\") {
|
||||||
log.Info("[%s] NTLM from '%s' relayed to %s", core.Green("mysql.server"), clientAddress, mysql.infile)
|
log.Info("[%s] NTLM from '%s' relayed to %s", tui.Green("mysql.server"), clientAddress, mysql.infile)
|
||||||
} else if fileSize := read - 9; fileSize < 4 {
|
} else if fileSize := read - 9; fileSize < 4 {
|
||||||
log.Warning("[%s] unpexpected buffer size %d", core.Green("mysql.server"), read)
|
log.Warning("[%s] unpexpected buffer size %d", tui.Green("mysql.server"), read)
|
||||||
} else {
|
} else {
|
||||||
log.Info("[%s] read file ( %s ) is %d bytes", core.Green("mysql.server"), mysql.infile, fileSize)
|
log.Info("[%s] read file ( %s ) is %d bytes", tui.Green("mysql.server"), mysql.infile, fileSize)
|
||||||
|
|
||||||
fileData := readBuffer[4 : read-4]
|
fileData := readBuffer[4 : read-4]
|
||||||
|
|
||||||
if mysql.outfile == "" {
|
if mysql.outfile == "" {
|
||||||
log.Info("\n%s", string(fileData))
|
log.Info("\n%s", string(fileData))
|
||||||
} else {
|
} else {
|
||||||
log.Info("[%s] saving to %s ...", core.Green("mysql.server"), mysql.outfile)
|
log.Info("[%s] saving to %s ...", tui.Green("mysql.server"), mysql.outfile)
|
||||||
if err := ioutil.WriteFile(mysql.outfile, fileData, 0755); err != nil {
|
if err := ioutil.WriteFile(mysql.outfile, fileData, 0755); err != nil {
|
||||||
log.Warning("[%s] error while saving the file: %s", core.Green("mysql.server"), err)
|
log.Warning("[%s] error while saving the file: %s", tui.Green("mysql.server"), err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,12 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/network"
|
"github.com/bettercap/bettercap/network"
|
||||||
"github.com/bettercap/bettercap/packets"
|
"github.com/bettercap/bettercap/packets"
|
||||||
|
|
||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -38,12 +39,12 @@ func (d *Discovery) getRow(e *network.Endpoint, withMeta bool) [][]string {
|
||||||
mac := e.HwAddress
|
mac := e.HwAddress
|
||||||
if d.Session.Lan.WasMissed(e.HwAddress) {
|
if d.Session.Lan.WasMissed(e.HwAddress) {
|
||||||
// if endpoint was not found in ARP at least once
|
// if endpoint was not found in ARP at least once
|
||||||
addr = core.Dim(addr)
|
addr = tui.Dim(addr)
|
||||||
mac = core.Dim(mac)
|
mac = tui.Dim(mac)
|
||||||
} else if sinceStarted > (justJoinedTimeInterval*2) && sinceFirstSeen <= justJoinedTimeInterval {
|
} else if sinceStarted > (justJoinedTimeInterval*2) && sinceFirstSeen <= justJoinedTimeInterval {
|
||||||
// if endpoint was first seen in the last 10 seconds
|
// if endpoint was first seen in the last 10 seconds
|
||||||
addr = core.Bold(addr)
|
addr = tui.Bold(addr)
|
||||||
mac = core.Bold(mac)
|
mac = tui.Bold(mac)
|
||||||
}
|
}
|
||||||
|
|
||||||
name := ""
|
name := ""
|
||||||
|
@ -52,9 +53,9 @@ func (d *Discovery) getRow(e *network.Endpoint, withMeta bool) [][]string {
|
||||||
} else if e == d.Session.Gateway {
|
} else if e == d.Session.Gateway {
|
||||||
name = "gateway"
|
name = "gateway"
|
||||||
} else if e.Alias != "" {
|
} else if e.Alias != "" {
|
||||||
name = core.Green(e.Alias)
|
name = tui.Green(e.Alias)
|
||||||
} else if e.Hostname != "" {
|
} else if e.Hostname != "" {
|
||||||
name = core.Yellow(e.Hostname)
|
name = tui.Yellow(e.Hostname)
|
||||||
}
|
}
|
||||||
|
|
||||||
var traffic *packets.Traffic
|
var traffic *packets.Traffic
|
||||||
|
@ -67,19 +68,19 @@ func (d *Discovery) getRow(e *network.Endpoint, withMeta bool) [][]string {
|
||||||
sinceLastSeen := time.Since(e.LastSeen)
|
sinceLastSeen := time.Since(e.LastSeen)
|
||||||
if sinceStarted > aliveTimeInterval && sinceLastSeen <= aliveTimeInterval {
|
if sinceStarted > aliveTimeInterval && sinceLastSeen <= aliveTimeInterval {
|
||||||
// if endpoint seen in the last 10 seconds
|
// if endpoint seen in the last 10 seconds
|
||||||
seen = core.Bold(seen)
|
seen = tui.Bold(seen)
|
||||||
} else if sinceLastSeen <= presentTimeInterval {
|
} else if sinceLastSeen <= presentTimeInterval {
|
||||||
// if endpoint seen in the last 60 seconds
|
// if endpoint seen in the last 60 seconds
|
||||||
} else {
|
} else {
|
||||||
// not seen in a while
|
// not seen in a while
|
||||||
seen = core.Dim(seen)
|
seen = tui.Dim(seen)
|
||||||
}
|
}
|
||||||
|
|
||||||
row := []string{
|
row := []string{
|
||||||
addr,
|
addr,
|
||||||
mac,
|
mac,
|
||||||
name,
|
name,
|
||||||
core.Dim(e.Vendor),
|
tui.Dim(e.Vendor),
|
||||||
humanize.Bytes(traffic.Sent),
|
humanize.Bytes(traffic.Sent),
|
||||||
humanize.Bytes(traffic.Received),
|
humanize.Bytes(traffic.Received),
|
||||||
seen,
|
seen,
|
||||||
|
@ -88,12 +89,12 @@ func (d *Discovery) getRow(e *network.Endpoint, withMeta bool) [][]string {
|
||||||
if !withMeta {
|
if !withMeta {
|
||||||
return [][]string{row}
|
return [][]string{row}
|
||||||
} else if e.Meta.Empty() {
|
} else if e.Meta.Empty() {
|
||||||
return [][]string{append(row, core.Dim("-"))}
|
return [][]string{append(row, tui.Dim("-"))}
|
||||||
}
|
}
|
||||||
|
|
||||||
metas := []string{}
|
metas := []string{}
|
||||||
e.Meta.Each(func(name string, value interface{}) {
|
e.Meta.Each(func(name string, value interface{}) {
|
||||||
metas = append(metas, fmt.Sprintf("%s:%s", core.Green(name), core.Yellow(value.(string))))
|
metas = append(metas, fmt.Sprintf("%s:%s", tui.Green(name), tui.Yellow(value.(string))))
|
||||||
})
|
})
|
||||||
sort.Strings(metas)
|
sort.Strings(metas)
|
||||||
|
|
||||||
|
@ -164,13 +165,13 @@ func (d *Discovery) Show(by string, expr string) (err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
core.AsTable(os.Stdout, colNames, rows)
|
tui.Table(os.Stdout, colNames, rows)
|
||||||
|
|
||||||
d.Session.Queue.Stats.RLock()
|
d.Session.Queue.Stats.RLock()
|
||||||
fmt.Printf("\n%s %s / %s %s / %d pkts / %d errs\n\n",
|
fmt.Printf("\n%s %s / %s %s / %d pkts / %d errs\n\n",
|
||||||
core.Red("↑"),
|
tui.Red("↑"),
|
||||||
humanize.Bytes(d.Session.Queue.Stats.Sent),
|
humanize.Bytes(d.Session.Queue.Stats.Sent),
|
||||||
core.Green("↓"),
|
tui.Green("↓"),
|
||||||
humanize.Bytes(d.Session.Queue.Stats.Received),
|
humanize.Bytes(d.Session.Queue.Stats.Received),
|
||||||
d.Session.Queue.Stats.PktReceived,
|
d.Session.Queue.Stats.PktReceived,
|
||||||
d.Session.Queue.Stats.Errors)
|
d.Session.Queue.Stats.Errors)
|
||||||
|
|
|
@ -4,12 +4,13 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
|
||||||
"github.com/google/gopacket/pcap"
|
"github.com/google/gopacket/pcap"
|
||||||
"github.com/google/gopacket/pcapgo"
|
"github.com/google/gopacket/pcapgo"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SnifferContext struct {
|
type SnifferContext struct {
|
||||||
|
@ -98,8 +99,8 @@ func NewSnifferContext() *SnifferContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
no = core.Red("no")
|
no = tui.Red("no")
|
||||||
yes = core.Green("yes")
|
yes = tui.Green("yes")
|
||||||
yn = map[bool]string{
|
yn = map[bool]string{
|
||||||
true: yes,
|
true: yes,
|
||||||
false: no,
|
false: no,
|
||||||
|
@ -109,9 +110,9 @@ var (
|
||||||
func (c *SnifferContext) Log(sess *session.Session) {
|
func (c *SnifferContext) Log(sess *session.Session) {
|
||||||
log.Info("Skip local packets : %s", yn[c.DumpLocal])
|
log.Info("Skip local packets : %s", yn[c.DumpLocal])
|
||||||
log.Info("Verbose : %s", yn[c.Verbose])
|
log.Info("Verbose : %s", yn[c.Verbose])
|
||||||
log.Info("BPF Filter : '%s'", core.Yellow(c.Filter))
|
log.Info("BPF Filter : '%s'", tui.Yellow(c.Filter))
|
||||||
log.Info("Regular expression : '%s'", core.Yellow(c.Expression))
|
log.Info("Regular expression : '%s'", tui.Yellow(c.Expression))
|
||||||
log.Info("File output : '%s'", core.Yellow(c.Output))
|
log.Info("File output : '%s'", tui.Yellow(c.Output))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *SnifferContext) Close() {
|
func (c *SnifferContext) Close() {
|
||||||
|
|
|
@ -3,10 +3,10 @@ package modules
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
|
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
|
func dnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
|
||||||
|
@ -41,11 +41,11 @@ func dnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
|
||||||
ip.DstIP.String(),
|
ip.DstIP.String(),
|
||||||
nil,
|
nil,
|
||||||
"%s %s > %s : %s is %s",
|
"%s %s > %s : %s is %s",
|
||||||
core.W(core.BG_DGRAY+core.FG_WHITE, "dns"),
|
tui.Wrap(tui.BACKDARKGRAY+tui.FOREWHITE, "dns"),
|
||||||
vIP(ip.SrcIP),
|
vIP(ip.SrcIP),
|
||||||
vIP(ip.DstIP),
|
vIP(ip.DstIP),
|
||||||
core.Yellow(hostname),
|
tui.Yellow(hostname),
|
||||||
core.Dim(strings.Join(ips, ", ")),
|
tui.Dim(strings.Join(ips, ", ")),
|
||||||
).Push()
|
).Push()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,12 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
|
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
|
|
||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HTTPRequest struct {
|
type HTTPRequest struct {
|
||||||
|
@ -126,10 +126,10 @@ func httpParser(ip *layers.IPv4, pkt gopacket.Packet, tcp *layers.TCP) bool {
|
||||||
req.Host,
|
req.Host,
|
||||||
toSerializableRequest(req),
|
toSerializableRequest(req),
|
||||||
"%s %s %s %s%s",
|
"%s %s %s %s%s",
|
||||||
core.W(core.BG_RED+core.FG_BLACK, "http"),
|
tui.Wrap(tui.BACKRED+tui.FOREBLACK, "http"),
|
||||||
vIP(ip.SrcIP),
|
vIP(ip.SrcIP),
|
||||||
core.W(core.BG_LBLUE+core.FG_BLACK, req.Method),
|
tui.Wrap(tui.BACKLIGHTBLUE+tui.FOREBLACK, req.Method),
|
||||||
core.Yellow(req.Host),
|
tui.Yellow(req.Host),
|
||||||
vURL(req.URL.String()),
|
vURL(req.URL.String()),
|
||||||
).Push()
|
).Push()
|
||||||
|
|
||||||
|
@ -143,13 +143,13 @@ func httpParser(ip *layers.IPv4, pkt gopacket.Packet, tcp *layers.TCP) bool {
|
||||||
ip.DstIP.String(),
|
ip.DstIP.String(),
|
||||||
sres,
|
sres,
|
||||||
"%s %s:%d %s -> %s (%s %s)",
|
"%s %s:%d %s -> %s (%s %s)",
|
||||||
core.W(core.BG_RED+core.FG_BLACK, "http"),
|
tui.Wrap(tui.BACKRED+tui.FOREBLACK, "http"),
|
||||||
vIP(ip.SrcIP),
|
vIP(ip.SrcIP),
|
||||||
tcp.SrcPort,
|
tcp.SrcPort,
|
||||||
core.Bold(res.Status),
|
tui.Bold(res.Status),
|
||||||
vIP(ip.DstIP),
|
vIP(ip.DstIP),
|
||||||
core.Dim(humanize.Bytes(uint64(len(sres.Body)))),
|
tui.Dim(humanize.Bytes(uint64(len(sres.Body)))),
|
||||||
core.Yellow(sres.ContentType),
|
tui.Yellow(sres.ContentType),
|
||||||
).Push()
|
).Push()
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -3,11 +3,12 @@ package modules
|
||||||
import (
|
import (
|
||||||
"encoding/asn1"
|
"encoding/asn1"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/packets"
|
"github.com/bettercap/bettercap/packets"
|
||||||
|
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
func krb5Parser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
|
func krb5Parser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
|
||||||
|
@ -29,7 +30,7 @@ func krb5Parser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
|
||||||
ip.DstIP.String(),
|
ip.DstIP.String(),
|
||||||
nil,
|
nil,
|
||||||
"%s %s -> %s : %s",
|
"%s %s -> %s : %s",
|
||||||
core.W(core.BG_RED+core.FG_BLACK, "krb-as-req"),
|
tui.Wrap(tui.BACKRED+tui.FOREBLACK, "krb-as-req"),
|
||||||
vIP(ip.SrcIP),
|
vIP(ip.SrcIP),
|
||||||
vIP(ip.DstIP),
|
vIP(ip.DstIP),
|
||||||
s,
|
s,
|
||||||
|
|
|
@ -3,11 +3,12 @@ package modules
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/packets"
|
"github.com/bettercap/bettercap/packets"
|
||||||
|
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
func mdnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
|
func mdnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
|
||||||
|
@ -22,10 +23,10 @@ func mdnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
|
||||||
ip.DstIP.String(),
|
ip.DstIP.String(),
|
||||||
nil,
|
nil,
|
||||||
"%s %s : %s query for %s",
|
"%s %s : %s query for %s",
|
||||||
core.W(core.BG_DGRAY+core.FG_WHITE, "mdns"),
|
tui.Wrap(tui.BACKDARKGRAY+tui.FOREWHITE, "mdns"),
|
||||||
vIP(ip.SrcIP),
|
vIP(ip.SrcIP),
|
||||||
core.Dim(q.Type.String()),
|
tui.Dim(q.Type.String()),
|
||||||
core.Yellow(string(q.Name)),
|
tui.Yellow(string(q.Name)),
|
||||||
).Push()
|
).Push()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,10 +51,10 @@ func mdnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
|
||||||
ip.DstIP.String(),
|
ip.DstIP.String(),
|
||||||
nil,
|
nil,
|
||||||
"%s %s : %s is %s",
|
"%s %s : %s is %s",
|
||||||
core.W(core.BG_DGRAY+core.FG_WHITE, "mdns"),
|
tui.Wrap(tui.BACKDARKGRAY+tui.FOREWHITE, "mdns"),
|
||||||
vIP(ip.SrcIP),
|
vIP(ip.SrcIP),
|
||||||
core.Yellow(hostname),
|
tui.Yellow(hostname),
|
||||||
core.Dim(strings.Join(ips, ", ")),
|
tui.Dim(strings.Join(ips, ", ")),
|
||||||
).Push()
|
).Push()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,12 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/packets"
|
"github.com/bettercap/bettercap/packets"
|
||||||
|
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -53,7 +54,7 @@ func ntlmParser(ip *layers.IPv4, pkt gopacket.Packet, tcp *layers.TCP) bool {
|
||||||
ip.DstIP.String(),
|
ip.DstIP.String(),
|
||||||
nil,
|
nil,
|
||||||
"%s %s > %s | %s",
|
"%s %s > %s | %s",
|
||||||
core.W(core.BG_DGRAY+core.FG_WHITE, "ntlm.response"),
|
tui.Wrap(tui.BACKDARKGRAY+tui.FOREWHITE, "ntlm.response"),
|
||||||
vIP(ip.SrcIP),
|
vIP(ip.SrcIP),
|
||||||
vIP(ip.DstIP),
|
vIP(ip.DstIP),
|
||||||
data.LcString(),
|
data.LcString(),
|
||||||
|
|
|
@ -3,12 +3,13 @@ package modules
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/packets"
|
"github.com/bettercap/bettercap/packets"
|
||||||
|
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
func tcpParser(ip *layers.IPv4, pkt gopacket.Packet, verbose bool) {
|
func tcpParser(ip *layers.IPv4, pkt gopacket.Packet, verbose bool) {
|
||||||
|
@ -30,12 +31,12 @@ func tcpParser(ip *layers.IPv4, pkt gopacket.Packet, verbose bool) {
|
||||||
"Size": len(ip.Payload),
|
"Size": len(ip.Payload),
|
||||||
},
|
},
|
||||||
"%s %s:%s > %s:%s %s",
|
"%s %s:%s > %s:%s %s",
|
||||||
core.W(core.BG_LBLUE+core.FG_BLACK, "tcp"),
|
tui.Wrap(tui.BACKLIGHTBLUE+tui.FOREBLACK, "tcp"),
|
||||||
vIP(ip.SrcIP),
|
vIP(ip.SrcIP),
|
||||||
vPort(tcp.SrcPort),
|
vPort(tcp.SrcPort),
|
||||||
vIP(ip.DstIP),
|
vIP(ip.DstIP),
|
||||||
vPort(tcp.DstPort),
|
vPort(tcp.DstPort),
|
||||||
core.Dim(fmt.Sprintf("%d bytes", len(ip.Payload))),
|
tui.Dim(fmt.Sprintf("%d bytes", len(ip.Payload))),
|
||||||
).Push()
|
).Push()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,12 +62,12 @@ func udpParser(ip *layers.IPv4, pkt gopacket.Packet, verbose bool) {
|
||||||
"Size": len(ip.Payload),
|
"Size": len(ip.Payload),
|
||||||
},
|
},
|
||||||
"%s %s:%s > %s:%s %s",
|
"%s %s:%s > %s:%s %s",
|
||||||
core.W(core.BG_DGRAY+core.FG_WHITE, "udp"),
|
tui.Wrap(tui.BACKDARKGRAY+tui.FOREWHITE, "udp"),
|
||||||
vIP(ip.SrcIP),
|
vIP(ip.SrcIP),
|
||||||
vPort(udp.SrcPort),
|
vPort(udp.SrcPort),
|
||||||
vIP(ip.DstIP),
|
vIP(ip.DstIP),
|
||||||
vPort(udp.DstPort),
|
vPort(udp.DstPort),
|
||||||
core.Dim(fmt.Sprintf("%d bytes", len(ip.Payload))),
|
tui.Dim(fmt.Sprintf("%d bytes", len(ip.Payload))),
|
||||||
).Push()
|
).Push()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,10 +83,10 @@ func unkParser(ip *layers.IPv4, pkt gopacket.Packet, verbose bool) {
|
||||||
"Size": len(ip.Payload),
|
"Size": len(ip.Payload),
|
||||||
},
|
},
|
||||||
"%s %s > %s %s",
|
"%s %s > %s %s",
|
||||||
core.W(core.BG_DGRAY+core.FG_WHITE, pkt.TransportLayer().LayerType().String()),
|
tui.Wrap(tui.BACKDARKGRAY+tui.FOREWHITE, pkt.TransportLayer().LayerType().String()),
|
||||||
vIP(ip.SrcIP),
|
vIP(ip.SrcIP),
|
||||||
vIP(ip.DstIP),
|
vIP(ip.DstIP),
|
||||||
core.Dim(fmt.Sprintf("%d bytes", len(ip.Payload))),
|
tui.Dim(fmt.Sprintf("%d bytes", len(ip.Payload))),
|
||||||
).Push()
|
).Push()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,12 @@ package modules
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
// poor man's TLS Client Hello with SNI extension parser :P
|
// poor man's TLS Client Hello with SNI extension parser :P
|
||||||
|
@ -38,9 +39,9 @@ func sniParser(ip *layers.IPv4, pkt gopacket.Packet, tcp *layers.TCP) bool {
|
||||||
domain,
|
domain,
|
||||||
nil,
|
nil,
|
||||||
"%s %s > %s",
|
"%s %s > %s",
|
||||||
core.W(core.BG_YELLOW+core.FG_WHITE, "sni"),
|
tui.Wrap(tui.BACKYELLOW+tui.FOREWHITE, "sni"),
|
||||||
vIP(ip.SrcIP),
|
vIP(ip.SrcIP),
|
||||||
core.Yellow("https://"+domain),
|
tui.Yellow("https://"+domain),
|
||||||
).Push()
|
).Push()
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -3,18 +3,20 @@ package modules
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/packets"
|
"github.com/bettercap/bettercap/packets"
|
||||||
|
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/str"
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
func upnpParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
|
func upnpParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
|
||||||
if data := packets.UPNPGetMeta(pkt); data != nil && len(data) > 0 {
|
if data := packets.UPNPGetMeta(pkt); data != nil && len(data) > 0 {
|
||||||
s := ""
|
s := ""
|
||||||
for name, value := range data {
|
for name, value := range data {
|
||||||
s += fmt.Sprintf("%s:%s ", core.Blue(name), core.Yellow(value))
|
s += fmt.Sprintf("%s:%s ", tui.Blue(name), tui.Yellow(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
NewSnifferEvent(
|
NewSnifferEvent(
|
||||||
|
@ -24,10 +26,10 @@ func upnpParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
|
||||||
ip.DstIP.String(),
|
ip.DstIP.String(),
|
||||||
nil,
|
nil,
|
||||||
"%s %s -> %s : %s",
|
"%s %s -> %s : %s",
|
||||||
core.W(core.BG_RED+core.FG_BLACK, "upnp"),
|
tui.Wrap(tui.BACKRED+tui.FOREBLACK, "upnp"),
|
||||||
vIP(ip.SrcIP),
|
vIP(ip.SrcIP),
|
||||||
vIP(ip.DstIP),
|
vIP(ip.DstIP),
|
||||||
core.Trim(s),
|
str.Trim(s),
|
||||||
).Push()
|
).Push()
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -4,15 +4,15 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/google/gopacket/layers"
|
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
|
"github.com/google/gopacket/layers"
|
||||||
)
|
)
|
||||||
|
|
||||||
func vIP(ip net.IP) string {
|
func vIP(ip net.IP) string {
|
||||||
if session.I.Interface.IP.Equal(ip) {
|
if session.I.Interface.IP.Equal(ip) {
|
||||||
return core.Dim("local")
|
return tui.Dim("local")
|
||||||
} else if session.I.Gateway.IP.Equal(ip) {
|
} else if session.I.Gateway.IP.Equal(ip) {
|
||||||
return "gateway"
|
return "gateway"
|
||||||
}
|
}
|
||||||
|
@ -32,11 +32,11 @@ func vPort(p interface{}) string {
|
||||||
sp := fmt.Sprintf("%d", p)
|
sp := fmt.Sprintf("%d", p)
|
||||||
if tcp, ok := p.(layers.TCPPort); ok {
|
if tcp, ok := p.(layers.TCPPort); ok {
|
||||||
if name, found := layers.TCPPortNames[tcp]; found {
|
if name, found := layers.TCPPortNames[tcp]; found {
|
||||||
sp = core.Yellow(name)
|
sp = tui.Yellow(name)
|
||||||
}
|
}
|
||||||
} else if udp, ok := p.(layers.UDPPort); ok {
|
} else if udp, ok := p.(layers.UDPPort); ok {
|
||||||
if name, found := layers.UDPPortNames[udp]; found {
|
if name, found := layers.UDPPortNames[udp]; found {
|
||||||
sp = core.Yellow(name)
|
sp = tui.Yellow(name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@ import (
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
|
||||||
"github.com/chifflier/nfqueue-go/nfqueue"
|
"github.com/chifflier/nfqueue-go/nfqueue"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/fs"
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PacketProxy struct {
|
type PacketProxy struct {
|
||||||
|
@ -141,8 +144,8 @@ func (pp *PacketProxy) Configure() (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if pp.pluginPath == "" {
|
if pp.pluginPath == "" {
|
||||||
return fmt.Errorf("The parameter %s can not be empty.", core.Bold("packet.proxy.plugin"))
|
return fmt.Errorf("The parameter %s can not be empty.", tui.Bold("packet.proxy.plugin"))
|
||||||
} else if !core.Exists(pp.pluginPath) {
|
} else if !fs.Exists(pp.pluginPath) {
|
||||||
return fmt.Errorf("%s does not exist.", pp.pluginPath)
|
return fmt.Errorf("%s does not exist.", pp.pluginPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +197,7 @@ func (pp *PacketProxy) Start() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
return pp.SetRunning(true, func() {
|
return pp.SetRunning(true, func() {
|
||||||
log.Info("%s started on queue number %d", core.Green("packet.proxy"), pp.queueNum)
|
log.Info("%s started on queue number %d", tui.Green("packet.proxy"), pp.queueNum)
|
||||||
|
|
||||||
defer pp.destroyQueue()
|
defer pp.destroyQueue()
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/network"
|
"github.com/bettercap/bettercap/network"
|
||||||
"github.com/bettercap/bettercap/packets"
|
"github.com/bettercap/bettercap/packets"
|
||||||
|
@ -17,6 +16,8 @@ import (
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
|
|
||||||
"github.com/malfunkt/iprange"
|
"github.com/malfunkt/iprange"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/str"
|
||||||
)
|
)
|
||||||
|
|
||||||
const synSourcePort = 666
|
const synSourcePort = 666
|
||||||
|
@ -55,8 +56,8 @@ func NewSynScanner(s *session.Session) *SynScanner {
|
||||||
ss.startPort = 1
|
ss.startPort = 1
|
||||||
ss.endPort = 65535
|
ss.endPort = 65535
|
||||||
|
|
||||||
if argc > 1 && core.Trim(args[1]) != "" {
|
if argc > 1 && str.Trim(args[1]) != "" {
|
||||||
if ss.startPort, err = strconv.Atoi(core.Trim(args[1])); err != nil {
|
if ss.startPort, err = strconv.Atoi(str.Trim(args[1])); err != nil {
|
||||||
return fmt.Errorf("Invalid START-PORT: %s", err)
|
return fmt.Errorf("Invalid START-PORT: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,8 +67,8 @@ func NewSynScanner(s *session.Session) *SynScanner {
|
||||||
ss.endPort = ss.startPort
|
ss.endPort = ss.startPort
|
||||||
}
|
}
|
||||||
|
|
||||||
if argc > 2 && core.Trim(args[2]) != "" {
|
if argc > 2 && str.Trim(args[2]) != "" {
|
||||||
if ss.endPort, err = strconv.Atoi(core.Trim(args[2])); err != nil {
|
if ss.endPort, err = strconv.Atoi(str.Trim(args[2])); err != nil {
|
||||||
return fmt.Errorf("Invalid END-PORT: %s", err)
|
return fmt.Errorf("Invalid END-PORT: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@ import (
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
|
||||||
"github.com/google/go-github/github"
|
"github.com/google/go-github/github"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UpdateModule struct {
|
type UpdateModule struct {
|
||||||
|
@ -87,7 +89,7 @@ func (u *UpdateModule) Start() error {
|
||||||
if u.versionToNum(core.Version) < u.versionToNum(*latest.TagName) {
|
if u.versionToNum(core.Version) < u.versionToNum(*latest.TagName) {
|
||||||
u.Session.Events.Add("update.available", latest)
|
u.Session.Events.Add("update.available", latest)
|
||||||
} else {
|
} else {
|
||||||
log.Info("you are running %s which is the latest stable version.", core.Bold(core.Version))
|
log.Info("you are running %s which is the latest stable version.", tui.Bold(core.Version))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Error("error while fetching latest release info from GitHub: %s", err)
|
log.Error("error while fetching latest release info from GitHub: %s", err)
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/network"
|
"github.com/bettercap/bettercap/network"
|
||||||
"github.com/bettercap/bettercap/packets"
|
"github.com/bettercap/bettercap/packets"
|
||||||
|
@ -17,6 +16,8 @@ import (
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
"github.com/google/gopacket/pcap"
|
"github.com/google/gopacket/pcap"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
type WiFiModule struct {
|
type WiFiModule struct {
|
||||||
|
@ -209,7 +210,7 @@ func (w *WiFiModule) Configure() error {
|
||||||
defer ihandle.CleanUp()
|
defer ihandle.CleanUp()
|
||||||
|
|
||||||
if err = ihandle.SetRFMon(true); err != nil {
|
if err = ihandle.SetRFMon(true); err != nil {
|
||||||
return fmt.Errorf("Error while setting interface %s in monitor mode: %s", core.Bold(w.Session.Interface.Name()), err)
|
return fmt.Errorf("Error while setting interface %s in monitor mode: %s", tui.Bold(w.Session.Interface.Name()), err)
|
||||||
} else if err = ihandle.SetSnapLen(65536); err != nil {
|
} else if err = ihandle.SetSnapLen(65536); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if err = ihandle.SetTimeout(pcap.BlockForever); err != nil {
|
} else if err = ihandle.SetTimeout(pcap.BlockForever); err != nil {
|
||||||
|
|
|
@ -5,11 +5,12 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/network"
|
"github.com/bettercap/bettercap/network"
|
||||||
"github.com/bettercap/bettercap/packets"
|
"github.com/bettercap/bettercap/packets"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
var errNoRecon = errors.New("Module wifi.ap requires module wifi.recon to be activated.")
|
var errNoRecon = errors.New("Module wifi.ap requires module wifi.recon to be activated.")
|
||||||
|
@ -44,12 +45,12 @@ func (w *WiFiModule) startAp() error {
|
||||||
w.apRunning = false
|
w.apRunning = false
|
||||||
}()
|
}()
|
||||||
|
|
||||||
enc := core.Yellow("WPA2")
|
enc := tui.Yellow("WPA2")
|
||||||
if !w.apConfig.Encryption {
|
if !w.apConfig.Encryption {
|
||||||
enc = core.Green("Open")
|
enc = tui.Green("Open")
|
||||||
}
|
}
|
||||||
log.Info("Sending beacons as SSID %s (%s) on channel %d (%s).",
|
log.Info("Sending beacons as SSID %s (%s) on channel %d (%s).",
|
||||||
core.Bold(w.apConfig.SSID),
|
tui.Bold(w.apConfig.SSID),
|
||||||
w.apConfig.BSSID.String(),
|
w.apConfig.BSSID.String(),
|
||||||
w.apConfig.Channel,
|
w.apConfig.Channel,
|
||||||
enc)
|
enc)
|
||||||
|
|
|
@ -7,10 +7,11 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/network"
|
"github.com/bettercap/bettercap/network"
|
||||||
|
|
||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (w *WiFiModule) isApSelected() bool {
|
func (w *WiFiModule) isApSelected() bool {
|
||||||
|
@ -25,22 +26,22 @@ func (w *WiFiModule) getRow(station *network.Station) ([]string, bool) {
|
||||||
bssid := station.HwAddress
|
bssid := station.HwAddress
|
||||||
if sinceStarted > (justJoinedTimeInterval*2) && sinceFirstSeen <= justJoinedTimeInterval {
|
if sinceStarted > (justJoinedTimeInterval*2) && sinceFirstSeen <= justJoinedTimeInterval {
|
||||||
// if endpoint was first seen in the last 10 seconds
|
// if endpoint was first seen in the last 10 seconds
|
||||||
bssid = core.Bold(bssid)
|
bssid = tui.Bold(bssid)
|
||||||
}
|
}
|
||||||
|
|
||||||
seen := station.LastSeen.Format("15:04:05")
|
seen := station.LastSeen.Format("15:04:05")
|
||||||
sinceLastSeen := time.Since(station.LastSeen)
|
sinceLastSeen := time.Since(station.LastSeen)
|
||||||
if sinceStarted > aliveTimeInterval && sinceLastSeen <= aliveTimeInterval {
|
if sinceStarted > aliveTimeInterval && sinceLastSeen <= aliveTimeInterval {
|
||||||
// if endpoint seen in the last 10 seconds
|
// if endpoint seen in the last 10 seconds
|
||||||
seen = core.Bold(seen)
|
seen = tui.Bold(seen)
|
||||||
} else if sinceLastSeen > presentTimeInterval {
|
} else if sinceLastSeen > presentTimeInterval {
|
||||||
// if endpoint not seen in the last 60 seconds
|
// if endpoint not seen in the last 60 seconds
|
||||||
seen = core.Dim(seen)
|
seen = tui.Dim(seen)
|
||||||
}
|
}
|
||||||
|
|
||||||
ssid := station.ESSID()
|
ssid := station.ESSID()
|
||||||
if ssid == "<hidden>" {
|
if ssid == "<hidden>" {
|
||||||
ssid = core.Dim(ssid)
|
ssid = tui.Dim(ssid)
|
||||||
}
|
}
|
||||||
|
|
||||||
encryption := station.Encryption
|
encryption := station.Encryption
|
||||||
|
@ -48,9 +49,9 @@ func (w *WiFiModule) getRow(station *network.Station) ([]string, bool) {
|
||||||
encryption = fmt.Sprintf("%s (%s, %s)", station.Encryption, station.Cipher, station.Authentication)
|
encryption = fmt.Sprintf("%s (%s, %s)", station.Encryption, station.Cipher, station.Authentication)
|
||||||
}
|
}
|
||||||
if encryption == "OPEN" || encryption == "" {
|
if encryption == "OPEN" || encryption == "" {
|
||||||
encryption = core.Green("OPEN")
|
encryption = tui.Green("OPEN")
|
||||||
ssid = core.Green(ssid)
|
ssid = tui.Green(ssid)
|
||||||
bssid = core.Green(bssid)
|
bssid = tui.Green(bssid)
|
||||||
}
|
}
|
||||||
sent := ""
|
sent := ""
|
||||||
if station.Sent > 0 {
|
if station.Sent > 0 {
|
||||||
|
@ -154,7 +155,7 @@ func (w *WiFiModule) Show(by string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if nrows > 0 {
|
if nrows > 0 {
|
||||||
core.AsTable(os.Stdout, columns, rows)
|
tui.Table(os.Stdout, columns, rows)
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Session.Refresh()
|
w.Session.Refresh()
|
||||||
|
|
|
@ -5,12 +5,14 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/packets"
|
"github.com/bettercap/bettercap/packets"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/str"
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -52,7 +54,7 @@ func NewWOL(s *session.Session) *WOL {
|
||||||
func parseMAC(args []string) (string, error) {
|
func parseMAC(args []string) (string, error) {
|
||||||
mac := "ff:ff:ff:ff:ff:ff"
|
mac := "ff:ff:ff:ff:ff:ff"
|
||||||
if len(args) == 1 {
|
if len(args) == 1 {
|
||||||
tmp := core.Trim(args[0])
|
tmp := str.Trim(args[0])
|
||||||
if tmp != "" {
|
if tmp != "" {
|
||||||
if !reMAC.MatchString(tmp) {
|
if !reMAC.MatchString(tmp) {
|
||||||
return "", fmt.Errorf("%s is not a valid MAC address.", tmp)
|
return "", fmt.Errorf("%s is not a valid MAC address.", tmp)
|
||||||
|
@ -103,7 +105,7 @@ func (w *WOL) wolETH(mac string) error {
|
||||||
defer w.SetRunning(false, nil)
|
defer w.SetRunning(false, nil)
|
||||||
|
|
||||||
payload := buildPayload(mac)
|
payload := buildPayload(mac)
|
||||||
log.Info("Sending %d bytes of ethernet WOL packet to %s", len(payload), core.Bold(mac))
|
log.Info("Sending %d bytes of ethernet WOL packet to %s", len(payload), tui.Bold(mac))
|
||||||
eth := layers.Ethernet{
|
eth := layers.Ethernet{
|
||||||
SrcMAC: w.Session.Interface.HW,
|
SrcMAC: w.Session.Interface.HW,
|
||||||
DstMAC: layers.EthernetBroadcast,
|
DstMAC: layers.EthernetBroadcast,
|
||||||
|
@ -124,7 +126,7 @@ func (w *WOL) wolUDP(mac string) error {
|
||||||
defer w.SetRunning(false, nil)
|
defer w.SetRunning(false, nil)
|
||||||
|
|
||||||
payload := buildPayload(mac)
|
payload := buildPayload(mac)
|
||||||
log.Info("Sending %d bytes of UDP WOL packet to %s", len(payload), core.Bold(mac))
|
log.Info("Sending %d bytes of UDP WOL packet to %s", len(payload), tui.Bold(mac))
|
||||||
|
|
||||||
eth := layers.Ethernet{
|
eth := layers.Ethernet{
|
||||||
SrcMAC: w.Session.Interface.HW,
|
SrcMAC: w.Session.Interface.HW,
|
||||||
|
|
|
@ -8,10 +8,11 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
"github.com/evilsocket/islazy/fs"
|
||||||
|
"github.com/evilsocket/islazy/str"
|
||||||
)
|
)
|
||||||
|
|
||||||
var fileName, _ = core.ExpandPath("~/bettercap.aliases")
|
var fileName, _ = fs.Expand("~/bettercap.aliases")
|
||||||
|
|
||||||
type Aliases struct {
|
type Aliases struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
|
@ -24,7 +25,7 @@ func LoadAliases() (err error, aliases *Aliases) {
|
||||||
data: make(map[string]string),
|
data: make(map[string]string),
|
||||||
}
|
}
|
||||||
|
|
||||||
if core.Exists(fileName) {
|
if fs.Exists(fileName) {
|
||||||
var file *os.File
|
var file *os.File
|
||||||
|
|
||||||
file, err = os.Open(fileName)
|
file, err = os.Open(fileName)
|
||||||
|
@ -37,8 +38,8 @@ func LoadAliases() (err error, aliases *Aliases) {
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := scanner.Text()
|
line := scanner.Text()
|
||||||
parts := strings.SplitN(line, " ", 2)
|
parts := strings.SplitN(line, " ", 2)
|
||||||
mac := core.Trim(parts[0])
|
mac := str.Trim(parts[0])
|
||||||
alias := core.Trim(parts[1])
|
alias := str.Trim(parts[1])
|
||||||
aliases.data[mac] = alias
|
aliases.data[mac] = alias
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OnHostResolvedCallback func(e *Endpoint)
|
type OnHostResolvedCallback func(e *Endpoint)
|
||||||
|
@ -152,7 +152,7 @@ func (t *Endpoint) String() string {
|
||||||
} else if t.Hostname == "" {
|
} else if t.Hostname == "" {
|
||||||
return fmt.Sprintf("%s%s ( %s )", ipPart, t.HwAddress, t.Vendor)
|
return fmt.Sprintf("%s%s ( %s )", ipPart, t.HwAddress, t.Vendor)
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s%s ( %s ) - %s", ipPart, t.HwAddress, t.Vendor, core.Bold(t.Hostname))
|
return fmt.Sprintf("%s%s ( %s ) - %s", ipPart, t.HwAddress, t.Vendor, tui.Bold(t.Hostname))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Endpoint) OnMeta(meta map[string]string) {
|
func (t *Endpoint) OnMeta(meta map[string]string) {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
"github.com/evilsocket/islazy/str"
|
||||||
|
|
||||||
"github.com/malfunkt/iprange"
|
"github.com/malfunkt/iprange"
|
||||||
)
|
)
|
||||||
|
@ -71,7 +71,7 @@ func ParseTargets(targets string, aliasMap *Aliases) (ips []net.IP, macs []net.H
|
||||||
ips = make([]net.IP, 0)
|
ips = make([]net.IP, 0)
|
||||||
macs = make([]net.HardwareAddr, 0)
|
macs = make([]net.HardwareAddr, 0)
|
||||||
|
|
||||||
if targets = core.Trim(targets); targets == "" {
|
if targets = str.Trim(targets); targets == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ func FindInterface(name string) (*Endpoint, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
name = core.Trim(name)
|
name = str.Trim(name)
|
||||||
if name != "" {
|
if name != "" {
|
||||||
return findInterfaceByName(name, ifaces)
|
return findInterfaceByName(name, ifaces)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ func FindGateway(iface *Endpoint) (*Endpoint, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
gw := core.Trim(output)
|
gw := str.Trim(output)
|
||||||
if IPv4Validator.MatchString(gw) {
|
if IPv4Validator.MatchString(gw) {
|
||||||
// we have the address, now we need its mac
|
// we have the address, now we need its mac
|
||||||
mac, err := ArpLookup(iface.Name(), gw, false)
|
mac, err := ArpLookup(iface.Name(), gw, false)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
"github.com/evilsocket/islazy/str"
|
||||||
|
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
|
@ -44,7 +44,7 @@ func MDNSGetMeta(pkt gopacket.Packet) map[string]string {
|
||||||
for _, raw := range answer.TXTs {
|
for _, raw := range answer.TXTs {
|
||||||
if value := string(raw); strings.Contains(value, "=") {
|
if value := string(raw); strings.Contains(value, "=") {
|
||||||
parts := strings.SplitN(value, "=", 2)
|
parts := strings.SplitN(value, "=", 2)
|
||||||
meta["mdns:"+core.Trim(parts[0])] = core.Trim(parts[1])
|
meta["mdns:"+str.Trim(parts[0])] = str.Trim(parts[1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package packets
|
package packets
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bettercap/bettercap/core"
|
"github.com/evilsocket/islazy/str"
|
||||||
|
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
|
@ -28,7 +28,7 @@ func NBNSGetMeta(pkt gopacket.Packet) map[string]string {
|
||||||
if ludp := pkt.Layer(layers.LayerTypeUDP); ludp != nil {
|
if ludp := pkt.Layer(layers.LayerTypeUDP); ludp != nil {
|
||||||
if udp := ludp.(*layers.UDP); udp != nil && udp.SrcPort == NBNSPort && len(udp.Payload) >= NBNSMinRespSize {
|
if udp := ludp.(*layers.UDP); udp != nil && udp.SrcPort == NBNSPort && len(udp.Payload) >= NBNSMinRespSize {
|
||||||
return map[string]string{
|
return map[string]string{
|
||||||
"nbns:hostname": core.Trim(string(udp.Payload[57:72])),
|
"nbns:hostname": str.Trim(string(udp.Payload[57:72])),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
// "net/url"
|
// "net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
"github.com/evilsocket/islazy/str"
|
||||||
|
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
|
@ -39,7 +39,7 @@ func UPNPGetMeta(pkt gopacket.Packet) map[string]string {
|
||||||
meta := make(map[string]string)
|
meta := make(map[string]string)
|
||||||
for name, values := range response.Header {
|
for name, values := range response.Header {
|
||||||
if name != "Cache-Control" && len(values) > 0 {
|
if name != "Cache-Control" && len(values) > 0 {
|
||||||
if data := core.Trim(strings.Join(values, ", ")); data != "" {
|
if data := str.Trim(strings.Join(values, ", ")); data != "" {
|
||||||
meta["upnp:"+name] = data
|
meta["upnp:"+name] = data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
"github.com/evilsocket/islazy/fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
type EnvironmentChangedCallback func(newValue string)
|
type EnvironmentChangedCallback func(newValue string)
|
||||||
|
@ -26,8 +26,8 @@ func NewEnvironment(envFile string) (*Environment, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if envFile != "" {
|
if envFile != "" {
|
||||||
envFile, _ := core.ExpandPath(envFile)
|
envFile, _ := fs.Expand(envFile)
|
||||||
if core.Exists(envFile) {
|
if fs.Exists(envFile) {
|
||||||
if err := env.Load(envFile); err != nil {
|
if err := env.Load(envFile); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,8 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
"github.com/evilsocket/islazy/log"
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Event struct {
|
type Event struct {
|
||||||
|
@ -17,7 +18,7 @@ type Event struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type LogMessage struct {
|
type LogMessage struct {
|
||||||
Level int
|
Level log.Verbosity
|
||||||
Message string
|
Message string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,10 +31,10 @@ func NewEvent(tag string, data interface{}) Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e Event) Label() string {
|
func (e Event) Label() string {
|
||||||
log := e.Data.(LogMessage)
|
m := e.Data.(LogMessage)
|
||||||
label := core.LogLabels[log.Level]
|
label := log.LevelNames[m.Level]
|
||||||
color := core.LogColors[log.Level]
|
color := log.LevelColors[m.Level]
|
||||||
return color + label + core.RESET
|
return color + label + tui.RESET
|
||||||
}
|
}
|
||||||
|
|
||||||
type EventPool struct {
|
type EventPool struct {
|
||||||
|
@ -114,10 +115,10 @@ func (p *EventPool) Add(tag string, data interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *EventPool) Log(level int, format string, args ...interface{}) {
|
func (p *EventPool) Log(level log.Verbosity, format string, args ...interface{}) {
|
||||||
if level == core.DEBUG && !p.debug {
|
if level == log.DEBUG && !p.debug {
|
||||||
return
|
return
|
||||||
} else if level < core.ERROR && p.silent {
|
} else if level < log.ERROR && p.silent {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +129,7 @@ func (p *EventPool) Log(level int, format string, args ...interface{}) {
|
||||||
message,
|
message,
|
||||||
})
|
})
|
||||||
|
|
||||||
if level == core.FATAL {
|
if level == log.FATAL {
|
||||||
fmt.Fprintf(os.Stderr, "%s\n", message)
|
fmt.Fprintf(os.Stderr, "%s\n", message)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,8 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
"github.com/evilsocket/islazy/str"
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Module interface {
|
type Module interface {
|
||||||
|
@ -66,7 +67,7 @@ func (m SessionModule) ListParam(name string) (err error, values []string) {
|
||||||
} else {
|
} else {
|
||||||
parts := strings.Split(list, ",")
|
parts := strings.Split(list, ",")
|
||||||
for _, part := range parts {
|
for _, part := range parts {
|
||||||
part = core.Trim(part)
|
part = str.Trim(part)
|
||||||
if part != "" {
|
if part != "" {
|
||||||
values = append(values, part)
|
values = append(values, part)
|
||||||
}
|
}
|
||||||
|
@ -169,7 +170,7 @@ func (m *SessionModule) SetRunning(running bool, cb func()) error {
|
||||||
case <-done:
|
case <-done:
|
||||||
return nil
|
return nil
|
||||||
case <-time.After(10 * time.Second):
|
case <-time.After(10 * time.Second):
|
||||||
fmt.Printf("%s: Stopping module %s timed out.\n", core.Yellow(core.Bold("WARNING")), m.Name)
|
fmt.Printf("%s: Stopping module %s timed out.\n", tui.Yellow(tui.Bold("WARNING")), m.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
const IPv4Validator = `^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$`
|
const IPv4Validator = `^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$`
|
||||||
|
@ -34,7 +34,7 @@ func NewModuleHandler(name string, expr string, desc string, exec func(args []st
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *ModuleHandler) Help(padding int) string {
|
func (h *ModuleHandler) Help(padding int) string {
|
||||||
return fmt.Sprintf(" "+core.Bold("%"+strconv.Itoa(padding)+"s")+" : %s\n", h.Name, h.Description)
|
return fmt.Sprintf(" "+tui.Bold("%"+strconv.Itoa(padding)+"s")+" : %s\n", h.Name, h.Description)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *ModuleHandler) Parse(line string) (bool, []string) {
|
func (h *ModuleHandler) Parse(line string) (bool, []string) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ParamType int
|
type ParamType int
|
||||||
|
@ -60,7 +60,7 @@ func NewIntParameter(name string, def_value string, desc string) *ModuleParam {
|
||||||
func (p ModuleParam) Validate(value string) (error, interface{}) {
|
func (p ModuleParam) Validate(value string) (error, interface{}) {
|
||||||
if p.Validator != nil {
|
if p.Validator != nil {
|
||||||
if !p.Validator.MatchString(value) {
|
if !p.Validator.MatchString(value) {
|
||||||
return fmt.Errorf("Parameter %s not valid: '%s' does not match rule '%s'.", core.Bold(p.Name), value, p.Validator.String()), nil
|
return fmt.Errorf("Parameter %s not valid: '%s' does not match rule '%s'.", tui.Bold(p.Name), value, p.Validator.String()), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,14 +105,14 @@ func (p ModuleParam) Get(s *Session) (error, interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p ModuleParam) Dump(padding int) string {
|
func (p ModuleParam) Dump(padding int) string {
|
||||||
return fmt.Sprintf(" "+core.YELLOW+"%"+strconv.Itoa(padding)+"s"+core.RESET+
|
return fmt.Sprintf(" "+tui.YELLOW+"%"+strconv.Itoa(padding)+"s"+tui.RESET+
|
||||||
" : %s\n", p.Name, p.Value)
|
" : %s\n", p.Name, p.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p ModuleParam) Help(padding int) string {
|
func (p ModuleParam) Help(padding int) string {
|
||||||
return fmt.Sprintf(" "+core.YELLOW+"%"+strconv.Itoa(padding)+"s"+core.RESET+
|
return fmt.Sprintf(" "+tui.YELLOW+"%"+strconv.Itoa(padding)+"s"+tui.RESET+
|
||||||
" : "+
|
" : "+
|
||||||
"%s "+core.DIM+"(default=%s"+core.RESET+")\n", p.Name, p.Description, p.Value)
|
"%s "+tui.DIM+"(default=%s"+tui.RESET+")\n", p.Name, p.Description, p.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p ModuleParam) Register(s *Session) {
|
func (p ModuleParam) Register(s *Session) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
"github.com/evilsocket/islazy/tui"
|
||||||
|
|
||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
)
|
)
|
||||||
|
@ -16,22 +16,22 @@ const (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// these are here because if colors are disabled,
|
// these are here because if colors are disabled,
|
||||||
// we need the updated core.* variables
|
// we need the updated tui.* variables
|
||||||
effects = map[string]string{
|
effects = map[string]string{
|
||||||
"{bold}": core.BOLD,
|
"{bold}": tui.BOLD,
|
||||||
"{dim}": core.DIM,
|
"{dim}": tui.DIM,
|
||||||
"{r}": core.RED,
|
"{r}": tui.RED,
|
||||||
"{g}": core.GREEN,
|
"{g}": tui.GREEN,
|
||||||
"{b}": core.BLUE,
|
"{b}": tui.BLUE,
|
||||||
"{y}": core.YELLOW,
|
"{y}": tui.YELLOW,
|
||||||
"{fb}": core.FG_BLACK,
|
"{fb}": tui.FOREBLACK,
|
||||||
"{fw}": core.FG_WHITE,
|
"{fw}": tui.FOREWHITE,
|
||||||
"{bdg}": core.BG_DGRAY,
|
"{bdg}": tui.BACKDARKGRAY,
|
||||||
"{br}": core.BG_RED,
|
"{br}": tui.BACKRED,
|
||||||
"{bg}": core.BG_GREEN,
|
"{bg}": tui.BACKGREEN,
|
||||||
"{by}": core.BG_YELLOW,
|
"{by}": tui.BACKYELLOW,
|
||||||
"{blb}": core.BG_LBLUE, // Ziggy this is for you <3
|
"{blb}": tui.BACKLIGHTBLUE, // Ziggy this is for you <3
|
||||||
"{reset}": core.RESET,
|
"{reset}": tui.RESET,
|
||||||
}
|
}
|
||||||
PromptCallbacks = map[string]func(s *Session) string{
|
PromptCallbacks = map[string]func(s *Session) string{
|
||||||
"{cidr}": func(s *Session) string {
|
"{cidr}": func(s *Session) string {
|
||||||
|
@ -80,8 +80,8 @@ func (p Prompt) Render(s *Session) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure an user error does not screw all terminal
|
// make sure an user error does not screw all terminal
|
||||||
if !strings.HasPrefix(prompt, core.RESET) {
|
if !strings.HasPrefix(prompt, tui.RESET) {
|
||||||
prompt += core.RESET
|
prompt += tui.RESET
|
||||||
}
|
}
|
||||||
|
|
||||||
return prompt
|
return prompt
|
||||||
|
|
|
@ -22,6 +22,11 @@ import (
|
||||||
"github.com/bettercap/bettercap/packets"
|
"github.com/bettercap/bettercap/packets"
|
||||||
|
|
||||||
"github.com/adrianmo/go-nmea"
|
"github.com/adrianmo/go-nmea"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/fs"
|
||||||
|
"github.com/evilsocket/islazy/log"
|
||||||
|
"github.com/evilsocket/islazy/str"
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -108,7 +113,10 @@ func New() (*Session, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
core.InitSwag(*s.Options.NoColors)
|
if *s.Options.NoColors || !tui.Effects() {
|
||||||
|
tui.Disable()
|
||||||
|
log.NoEffects = true
|
||||||
|
}
|
||||||
|
|
||||||
if *s.Options.CpuProfile != "" {
|
if *s.Options.CpuProfile != "" {
|
||||||
if f, err := os.Create(*s.Options.CpuProfile); err != nil {
|
if f, err := os.Create(*s.Options.CpuProfile); err != nil {
|
||||||
|
@ -169,7 +177,7 @@ func (s *Session) Close() {
|
||||||
s.Firewall.Restore()
|
s.Firewall.Restore()
|
||||||
|
|
||||||
if *s.Options.EnvFile != "" {
|
if *s.Options.EnvFile != "" {
|
||||||
envFile, _ := core.ExpandPath(*s.Options.EnvFile)
|
envFile, _ := fs.Expand(*s.Options.EnvFile)
|
||||||
if err := s.Env.Save(envFile); err != nil {
|
if err := s.Env.Save(envFile); err != nil {
|
||||||
fmt.Printf("error while storing the environment to %s: %s", envFile, err)
|
fmt.Printf("error while storing the environment to %s: %s", envFile, err)
|
||||||
}
|
}
|
||||||
|
@ -215,7 +223,7 @@ func (s *Session) Start() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.Gateway, err = network.FindGateway(s.Interface); err != nil {
|
if s.Gateway, err = network.FindGateway(s.Interface); err != nil {
|
||||||
s.Events.Log(core.WARNING, "%s", err.Error())
|
s.Events.Log(log.WARNING, "%s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.Gateway == nil || s.Gateway.IpAddress == s.Interface.IpAddress {
|
if s.Gateway == nil || s.Gateway.IpAddress == s.Interface.IpAddress {
|
||||||
|
@ -305,13 +313,13 @@ func (s *Session) RunCaplet(filename string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseCapletCommand(line string) (is bool, caplet *caplets.Caplet, argv []string) {
|
func parseCapletCommand(line string) (is bool, caplet *caplets.Caplet, argv []string) {
|
||||||
file := core.Trim(line)
|
file := str.Trim(line)
|
||||||
parts := strings.Split(file, " ")
|
parts := strings.Split(file, " ")
|
||||||
argc := len(parts)
|
argc := len(parts)
|
||||||
argv = make([]string, 0)
|
argv = make([]string, 0)
|
||||||
// check for any arguments
|
// check for any arguments
|
||||||
if argc > 1 {
|
if argc > 1 {
|
||||||
file = core.Trim(parts[0])
|
file = str.Trim(parts[0])
|
||||||
if argc >= 2 {
|
if argc >= 2 {
|
||||||
argv = parts[1:]
|
argv = parts[1:]
|
||||||
}
|
}
|
||||||
|
@ -325,7 +333,7 @@ func parseCapletCommand(line string) (is bool, caplet *caplets.Caplet, argv []st
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) Run(line string) error {
|
func (s *Session) Run(line string) error {
|
||||||
line = core.TrimRight(line)
|
line = str.TrimRight(line)
|
||||||
// remove extra spaces after the first command
|
// remove extra spaces after the first command
|
||||||
// so that 'arp.spoof on' is normalized
|
// so that 'arp.spoof on' is normalized
|
||||||
// to 'arp.spoof on' (fixes #178)
|
// to 'arp.spoof on' (fixes #178)
|
||||||
|
@ -365,5 +373,5 @@ func (s *Session) Run(line string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Errorf("unknown or invalid syntax \"%s%s%s\", type %shelp%s for the help menu.", core.BOLD, line, core.RESET, core.BOLD, core.RESET)
|
return fmt.Errorf("unknown or invalid syntax \"%s%s%s\", type %shelp%s for the help menu.", tui.BOLD, line, tui.RESET, tui.BOLD, tui.RESET)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,8 @@ import (
|
||||||
"github.com/bettercap/bettercap/network"
|
"github.com/bettercap/bettercap/network"
|
||||||
|
|
||||||
"github.com/bettercap/readline"
|
"github.com/bettercap/readline"
|
||||||
|
"github.com/evilsocket/islazy/str"
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Session) generalHelp() {
|
func (s *Session) generalHelp() {
|
||||||
|
@ -29,10 +31,10 @@ func (s *Session) generalHelp() {
|
||||||
pad := "%" + strconv.Itoa(maxLen) + "s"
|
pad := "%" + strconv.Itoa(maxLen) + "s"
|
||||||
|
|
||||||
for _, h := range s.CoreHandlers {
|
for _, h := range s.CoreHandlers {
|
||||||
fmt.Printf(" "+core.Yellow(pad)+" : %s\n", h.Name, h.Description)
|
fmt.Printf(" "+tui.Yellow(pad)+" : %s\n", h.Name, h.Description)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(core.Bold("\nModules\n"))
|
fmt.Println(tui.Bold("\nModules\n"))
|
||||||
|
|
||||||
maxLen = 0
|
maxLen = 0
|
||||||
for _, m := range s.Modules {
|
for _, m := range s.Modules {
|
||||||
|
@ -46,11 +48,11 @@ func (s *Session) generalHelp() {
|
||||||
for _, m := range s.Modules {
|
for _, m := range s.Modules {
|
||||||
status := ""
|
status := ""
|
||||||
if m.Running() {
|
if m.Running() {
|
||||||
status = core.Green("running")
|
status = tui.Green("running")
|
||||||
} else {
|
} else {
|
||||||
status = core.Red("not running")
|
status = tui.Red("not running")
|
||||||
}
|
}
|
||||||
fmt.Printf(" "+core.Yellow(pad)+" > %s\n", m.Name(), status)
|
fmt.Printf(" "+tui.Yellow(pad)+" > %s\n", m.Name(), status)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
@ -65,11 +67,11 @@ func (s *Session) moduleHelp(filter string) error {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
status := ""
|
status := ""
|
||||||
if m.Running() {
|
if m.Running() {
|
||||||
status = core.Green("running")
|
status = tui.Green("running")
|
||||||
} else {
|
} else {
|
||||||
status = core.Red("not running")
|
status = tui.Red("not running")
|
||||||
}
|
}
|
||||||
fmt.Printf("%s (%s): %s\n\n", core.Yellow(m.Name()), status, core.Dim(m.Description()))
|
fmt.Printf("%s (%s): %s\n\n", tui.Yellow(m.Name()), status, tui.Dim(m.Description()))
|
||||||
|
|
||||||
maxLen := 0
|
maxLen := 0
|
||||||
handlers := m.Handlers()
|
handlers := m.Handlers()
|
||||||
|
@ -114,7 +116,7 @@ func (s *Session) moduleHelp(filter string) error {
|
||||||
func (s *Session) helpHandler(args []string, sess *Session) error {
|
func (s *Session) helpHandler(args []string, sess *Session) error {
|
||||||
filter := ""
|
filter := ""
|
||||||
if len(args) == 2 {
|
if len(args) == 2 {
|
||||||
filter = core.Trim(args[1])
|
filter = str.Trim(args[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
if filter == "" {
|
if filter == "" {
|
||||||
|
@ -134,13 +136,13 @@ func (s *Session) activeHandler(args []string, sess *Session) error {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("%s (%s)\n", core.Bold(m.Name()), core.Dim(m.Description()))
|
fmt.Printf("%s (%s)\n", tui.Bold(m.Name()), tui.Dim(m.Description()))
|
||||||
params := m.Parameters()
|
params := m.Parameters()
|
||||||
if len(params) > 0 {
|
if len(params) > 0 {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
for _, p := range params {
|
for _, p := range params {
|
||||||
_, val := s.Env.Get(p.Name)
|
_, val := s.Env.Get(p.Name)
|
||||||
fmt.Printf(" %s : %s\n", core.Yellow(p.Name), val)
|
fmt.Printf(" %s : %s\n", tui.Yellow(p.Name), val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +239,7 @@ func (s *Session) readHandler(args []string, sess *Session) error {
|
||||||
fmt.Printf("%s ", prompt)
|
fmt.Printf("%s ", prompt)
|
||||||
|
|
||||||
value, _ := reader.ReadString('\n')
|
value, _ := reader.ReadString('\n')
|
||||||
value = core.Trim(value)
|
value = str.Trim(value)
|
||||||
if value == "\"\"" {
|
if value == "\"\"" {
|
||||||
value = ""
|
value = ""
|
||||||
}
|
}
|
||||||
|
@ -271,7 +273,7 @@ func (s *Session) shHandler(args []string, sess *Session) error {
|
||||||
|
|
||||||
func (s *Session) aliasHandler(args []string, sess *Session) error {
|
func (s *Session) aliasHandler(args []string, sess *Session) error {
|
||||||
mac := args[0]
|
mac := args[0]
|
||||||
alias := core.Trim(args[1])
|
alias := str.Trim(args[1])
|
||||||
|
|
||||||
if s.Lan.SetAliasFor(mac, alias) {
|
if s.Lan.SetAliasFor(mac, alias) {
|
||||||
return nil
|
return nil
|
||||||
|
@ -291,7 +293,7 @@ func (s *Session) registerCoreHandlers() {
|
||||||
"List available commands or show module specific help if no module name is provided.",
|
"List available commands or show module specific help if no module name is provided.",
|
||||||
s.helpHandler),
|
s.helpHandler),
|
||||||
readline.PcItem("help", readline.PcItemDynamic(func(prefix string) []string {
|
readline.PcItem("help", readline.PcItemDynamic(func(prefix string) []string {
|
||||||
prefix = core.Trim(prefix[4:])
|
prefix = str.Trim(prefix[4:])
|
||||||
modNames := []string{""}
|
modNames := []string{""}
|
||||||
for _, m := range s.Modules {
|
for _, m := range s.Modules {
|
||||||
if prefix == "" || strings.HasPrefix(m.Name(), prefix) {
|
if prefix == "" || strings.HasPrefix(m.Name(), prefix) {
|
||||||
|
@ -324,7 +326,7 @@ func (s *Session) registerCoreHandlers() {
|
||||||
"Get the value of variable NAME, use * alone for all, or NAME* as a wildcard.",
|
"Get the value of variable NAME, use * alone for all, or NAME* as a wildcard.",
|
||||||
s.getHandler),
|
s.getHandler),
|
||||||
readline.PcItem("get", readline.PcItemDynamic(func(prefix string) []string {
|
readline.PcItem("get", readline.PcItemDynamic(func(prefix string) []string {
|
||||||
prefix = core.Trim(prefix[3:])
|
prefix = str.Trim(prefix[3:])
|
||||||
varNames := []string{""}
|
varNames := []string{""}
|
||||||
for key := range s.Env.Data {
|
for key := range s.Env.Data {
|
||||||
if prefix == "" || strings.HasPrefix(key, prefix) {
|
if prefix == "" || strings.HasPrefix(key, prefix) {
|
||||||
|
@ -339,7 +341,7 @@ func (s *Session) registerCoreHandlers() {
|
||||||
"Set the VALUE of variable NAME.",
|
"Set the VALUE of variable NAME.",
|
||||||
s.setHandler),
|
s.setHandler),
|
||||||
readline.PcItem("set", readline.PcItemDynamic(func(prefix string) []string {
|
readline.PcItem("set", readline.PcItemDynamic(func(prefix string) []string {
|
||||||
prefix = core.Trim(prefix[3:])
|
prefix = str.Trim(prefix[3:])
|
||||||
varNames := []string{""}
|
varNames := []string{""}
|
||||||
for key := range s.Env.Data {
|
for key := range s.Env.Data {
|
||||||
if prefix == "" || strings.HasPrefix(key, prefix) {
|
if prefix == "" || strings.HasPrefix(key, prefix) {
|
||||||
|
@ -366,7 +368,7 @@ func (s *Session) registerCoreHandlers() {
|
||||||
"Load and run this caplet in the current session.",
|
"Load and run this caplet in the current session.",
|
||||||
s.includeHandler),
|
s.includeHandler),
|
||||||
readline.PcItem("include", readline.PcItemDynamic(func(prefix string) []string {
|
readline.PcItem("include", readline.PcItemDynamic(func(prefix string) []string {
|
||||||
prefix = core.Trim(prefix[8:])
|
prefix = str.Trim(prefix[8:])
|
||||||
if prefix == "" {
|
if prefix == "" {
|
||||||
prefix = "."
|
prefix = "."
|
||||||
}
|
}
|
||||||
|
@ -386,7 +388,7 @@ func (s *Session) registerCoreHandlers() {
|
||||||
"Assign an alias to a given endpoint given its MAC address.",
|
"Assign an alias to a given endpoint given its MAC address.",
|
||||||
s.aliasHandler),
|
s.aliasHandler),
|
||||||
readline.PcItem("alias", readline.PcItemDynamic(func(prefix string) []string {
|
readline.PcItem("alias", readline.PcItemDynamic(func(prefix string) []string {
|
||||||
prefix = core.Trim(prefix[5:])
|
prefix = str.Trim(prefix[5:])
|
||||||
macs := []string{""}
|
macs := []string{""}
|
||||||
s.Lan.EachHost(func(mac string, e *network.Endpoint) {
|
s.Lan.EachHost(func(mac string, e *network.Endpoint) {
|
||||||
if prefix == "" || strings.HasPrefix(mac, prefix) {
|
if prefix == "" || strings.HasPrefix(mac, prefix) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
"github.com/evilsocket/islazy/str"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ParseCommands(line string) []string {
|
func ParseCommands(line string) []string {
|
||||||
|
@ -62,7 +62,7 @@ func ParseCommands(line string) []string {
|
||||||
|
|
||||||
cmds := make([]string, 0)
|
cmds := make([]string, 0)
|
||||||
for _, cmd := range args {
|
for _, cmd := range args {
|
||||||
cmd = core.Trim(cmd)
|
cmd = str.Trim(cmd)
|
||||||
if cmd != "" || (len(cmd) > 0 && cmd[0] != '#') {
|
if cmd != "" || (len(cmd) > 0 && cmd[0] != '#') {
|
||||||
cmds = append(cmds, cmd)
|
cmds = append(cmds, cmd)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,11 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/caplets"
|
"github.com/bettercap/bettercap/caplets"
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
|
|
||||||
"github.com/bettercap/readline"
|
"github.com/bettercap/readline"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/fs"
|
||||||
|
"github.com/evilsocket/islazy/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func containsCapitals(s string) bool {
|
func containsCapitals(s string) bool {
|
||||||
|
@ -66,7 +68,7 @@ func (s *Session) setupReadline() (err error) {
|
||||||
|
|
||||||
history := ""
|
history := ""
|
||||||
if !*s.Options.NoHistory {
|
if !*s.Options.NoHistory {
|
||||||
history, _ = core.ExpandPath(HistoryFile)
|
history, _ = fs.Expand(HistoryFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg := readline.Config{
|
cfg := readline.Config{
|
||||||
|
@ -113,7 +115,7 @@ func (s *Session) setupSignals() {
|
||||||
go func() {
|
go func() {
|
||||||
<-c
|
<-c
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
s.Events.Log(core.WARNING, "Got SIGTERM")
|
s.Events.Log(log.WARNING, "Got SIGTERM")
|
||||||
s.Close()
|
s.Close()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}()
|
}()
|
||||||
|
|
24
vendor/github.com/elazarl/goproxy/README.md
generated
vendored
24
vendor/github.com/elazarl/goproxy/README.md
generated
vendored
|
@ -8,8 +8,8 @@ Package goproxy provides a customizable HTTP proxy library for Go (golang),
|
||||||
It supports regular HTTP proxy, HTTPS through CONNECT, and "hijacking" HTTPS
|
It supports regular HTTP proxy, HTTPS through CONNECT, and "hijacking" HTTPS
|
||||||
connection using "Man in the Middle" style attack.
|
connection using "Man in the Middle" style attack.
|
||||||
|
|
||||||
The intent of the proxy, is to be usable with reasonable amount of traffic
|
The intent of the proxy is to be usable with reasonable amount of traffic,
|
||||||
yet, customizable and programmable.
|
yet customizable and programmable.
|
||||||
|
|
||||||
The proxy itself is simply a `net/http` handler.
|
The proxy itself is simply a `net/http` handler.
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ For example, the URL you should use as proxy when running `./bin/basic` is
|
||||||
|
|
||||||
## Mailing List
|
## Mailing List
|
||||||
|
|
||||||
New features would be discussed on the [mailing list](https://groups.google.com/forum/#!forum/goproxy-dev)
|
New features will be discussed on the [mailing list](https://groups.google.com/forum/#!forum/goproxy-dev)
|
||||||
before their development.
|
before their development.
|
||||||
|
|
||||||
## Latest Stable Release
|
## Latest Stable Release
|
||||||
|
@ -32,13 +32,13 @@ Get the latest goproxy from `gopkg.in/elazarl/goproxy.v1`.
|
||||||
# Why not Fiddler2?
|
# Why not Fiddler2?
|
||||||
|
|
||||||
Fiddler is an excellent software with similar intent. However, Fiddler is not
|
Fiddler is an excellent software with similar intent. However, Fiddler is not
|
||||||
as customizable as goproxy intend to be. The main difference is, Fiddler is not
|
as customizable as goproxy intends to be. The main difference is, Fiddler is not
|
||||||
intended to be used as a real proxy.
|
intended to be used as a real proxy.
|
||||||
|
|
||||||
A possible use case that suits goproxy but
|
A possible use case that suits goproxy but
|
||||||
not Fiddler, is, gathering statistics on page load times for a certain website over a week.
|
not Fiddler, is gathering statistics on page load times for a certain website over a week.
|
||||||
With goproxy you could ask all your users to set their proxy to a dedicated machine running a
|
With goproxy you could ask all your users to set their proxy to a dedicated machine running a
|
||||||
goproxy server. Fiddler is a GUI app not designed to be ran like a server for multiple users.
|
goproxy server. Fiddler is a GUI app not designed to be run like a server for multiple users.
|
||||||
|
|
||||||
# A taste of goproxy
|
# A taste of goproxy
|
||||||
|
|
||||||
|
@ -90,12 +90,12 @@ proxy.OnRequest(goproxy.DstHostIs("www.reddit.com")).DoFunc(
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
`DstHostIs` returns a `ReqCondition`, that is a function receiving a `Request` and returning a boolean
|
`DstHostIs` returns a `ReqCondition`, that is a function receiving a `Request` and returning a boolean.
|
||||||
we will only process requests that matches the condition. `DstHostIs("www.reddit.com")` will return
|
We will only process requests that match the condition. `DstHostIs("www.reddit.com")` will return
|
||||||
a `ReqCondition` accepting only requests directed to "www.reddit.com".
|
a `ReqCondition` accepting only requests directed to "www.reddit.com".
|
||||||
|
|
||||||
`DoFunc` will receive a function that will preprocess the request. We can change the request, or
|
`DoFunc` will receive a function that will preprocess the request. We can change the request, or
|
||||||
return a response. If the time is between 8:00am and 17:00pm, we will neglect the request, and
|
return a response. If the time is between 8:00am and 17:00pm, we will reject the request, and
|
||||||
return a precanned text response saying "do not waste your time".
|
return a precanned text response saying "do not waste your time".
|
||||||
|
|
||||||
See additional examples in the examples directory.
|
See additional examples in the examples directory.
|
||||||
|
@ -108,14 +108,14 @@ See additional examples in the examples directory.
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
I put the software temporarily under the Go-compatible BSD license,
|
I put the software temporarily under the Go-compatible BSD license.
|
||||||
if this prevents someone from using the software, do let me know and I'll consider changing it.
|
If this prevents someone from using the software, do let me know and I'll consider changing it.
|
||||||
|
|
||||||
At any rate, user feedback is very important for me, so I'll be delighted to know if you're using this package.
|
At any rate, user feedback is very important for me, so I'll be delighted to know if you're using this package.
|
||||||
|
|
||||||
# Beta Software
|
# Beta Software
|
||||||
|
|
||||||
I've received a positive feedback from a few people who use goproxy in production settings.
|
I've received positive feedback from a few people who use goproxy in production settings.
|
||||||
I believe it is good enough for usage.
|
I believe it is good enough for usage.
|
||||||
|
|
||||||
I'll try to keep reasonable backwards compatibility. In case of a major API change,
|
I'll try to keep reasonable backwards compatibility. In case of a major API change,
|
||||||
|
|
596
vendor/github.com/evilsocket/islazy/LICENSE.md
generated
vendored
Normal file
596
vendor/github.com/evilsocket/islazy/LICENSE.md
generated
vendored
Normal file
|
@ -0,0 +1,596 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
==========================
|
||||||
|
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright © 2007 Free Software Foundation, Inc. <<https://www.fsf.org/>>
|
||||||
|
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies of this license
|
||||||
|
document, but changing it is not allowed.
|
||||||
|
|
||||||
|
## Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for software and other
|
||||||
|
kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed to take away
|
||||||
|
your freedom to share and change the works. By contrast, the GNU General Public
|
||||||
|
License is intended to guarantee your freedom to share and change all versions of a
|
||||||
|
program--to make sure it remains free software for all its users. We, the Free
|
||||||
|
Software Foundation, use the GNU General Public License for most of our software; it
|
||||||
|
applies also to any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not price. Our General
|
||||||
|
Public Licenses are designed to make sure that you have the freedom to distribute
|
||||||
|
copies of free software (and charge for them if you wish), that you receive source
|
||||||
|
code or can get it if you want it, that you can change the software or use pieces of
|
||||||
|
it in new free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you these rights or
|
||||||
|
asking you to surrender the rights. Therefore, you have certain responsibilities if
|
||||||
|
you distribute copies of the software, or if you modify it: responsibilities to
|
||||||
|
respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether gratis or for a fee,
|
||||||
|
you must pass on to the recipients the same freedoms that you received. You must make
|
||||||
|
sure that they, too, receive or can get the source code. And you must show them these
|
||||||
|
terms so they know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps: (1) assert
|
||||||
|
copyright on the software, and (2) offer you this License giving you legal permission
|
||||||
|
to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains that there is
|
||||||
|
no warranty for this free software. For both users' and authors' sake, the GPL
|
||||||
|
requires that modified versions be marked as changed, so that their problems will not
|
||||||
|
be attributed erroneously to authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run modified versions of
|
||||||
|
the software inside them, although the manufacturer can do so. This is fundamentally
|
||||||
|
incompatible with the aim of protecting users' freedom to change the software. The
|
||||||
|
systematic pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we have designed
|
||||||
|
this version of the GPL to prohibit the practice for those products. If such problems
|
||||||
|
arise substantially in other domains, we stand ready to extend this provision to
|
||||||
|
those domains in future versions of the GPL, as needed to protect the freedom of
|
||||||
|
users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents. States should
|
||||||
|
not allow patents to restrict development and use of software on general-purpose
|
||||||
|
computers, but in those that do, we wish to avoid the special danger that patents
|
||||||
|
applied to a free program could make it effectively proprietary. To prevent this, the
|
||||||
|
GPL assures that patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and modification follow.
|
||||||
|
|
||||||
|
## TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
### 0. Definitions.
|
||||||
|
|
||||||
|
“This License” refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
“Copyright” also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
“The Program” refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as “you”. “Licensees” and
|
||||||
|
“recipients” may be individuals or organizations.
|
||||||
|
|
||||||
|
To “modify” a work means to copy from or adapt all or part of the work in
|
||||||
|
a fashion requiring copyright permission, other than the making of an exact copy. The
|
||||||
|
resulting work is called a “modified version” of the earlier work or a
|
||||||
|
work “based on” the earlier work.
|
||||||
|
|
||||||
|
A “covered work” means either the unmodified Program or a work based on
|
||||||
|
the Program.
|
||||||
|
|
||||||
|
To “propagate” a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for infringement under
|
||||||
|
applicable copyright law, except executing it on a computer or modifying a private
|
||||||
|
copy. Propagation includes copying, distribution (with or without modification),
|
||||||
|
making available to the public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To “convey” a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through a computer
|
||||||
|
network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays “Appropriate Legal Notices” to the
|
||||||
|
extent that it includes a convenient and prominently visible feature that (1)
|
||||||
|
displays an appropriate copyright notice, and (2) tells the user that there is no
|
||||||
|
warranty for the work (except to the extent that warranties are provided), that
|
||||||
|
licensees may convey the work under this License, and how to view a copy of this
|
||||||
|
License. If the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
### 1. Source Code.
|
||||||
|
|
||||||
|
The “source code” for a work means the preferred form of the work for
|
||||||
|
making modifications to it. “Object code” means any non-source form of a
|
||||||
|
work.
|
||||||
|
|
||||||
|
A “Standard Interface” means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of interfaces
|
||||||
|
specified for a particular programming language, one that is widely used among
|
||||||
|
developers working in that language.
|
||||||
|
|
||||||
|
The “System Libraries” of an executable work include anything, other than
|
||||||
|
the work as a whole, that (a) is included in the normal form of packaging a Major
|
||||||
|
Component, but which is not part of that Major Component, and (b) serves only to
|
||||||
|
enable use of the work with that Major Component, or to implement a Standard
|
||||||
|
Interface for which an implementation is available to the public in source code form.
|
||||||
|
A “Major Component”, in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system (if any) on which
|
||||||
|
the executable work runs, or a compiler used to produce the work, or an object code
|
||||||
|
interpreter used to run it.
|
||||||
|
|
||||||
|
The “Corresponding Source” for a work in object code form means all the
|
||||||
|
source code needed to generate, install, and (for an executable work) run the object
|
||||||
|
code and to modify the work, including scripts to control those activities. However,
|
||||||
|
it does not include the work's System Libraries, or general-purpose tools or
|
||||||
|
generally available free programs which are used unmodified in performing those
|
||||||
|
activities but which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for the work, and
|
||||||
|
the source code for shared libraries and dynamically linked subprograms that the work
|
||||||
|
is specifically designed to require, such as by intimate data communication or
|
||||||
|
control flow between those subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users can regenerate
|
||||||
|
automatically from other parts of the Corresponding Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that same work.
|
||||||
|
|
||||||
|
### 2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of copyright on the
|
||||||
|
Program, and are irrevocable provided the stated conditions are met. This License
|
||||||
|
explicitly affirms your unlimited permission to run the unmodified Program. The
|
||||||
|
output from running a covered work is covered by this License only if the output,
|
||||||
|
given its content, constitutes a covered work. This License acknowledges your rights
|
||||||
|
of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not convey, without
|
||||||
|
conditions so long as your license otherwise remains in force. You may convey covered
|
||||||
|
works to others for the sole purpose of having them make modifications exclusively
|
||||||
|
for you, or provide you with facilities for running those works, provided that you
|
||||||
|
comply with the terms of this License in conveying all material for which you do not
|
||||||
|
control copyright. Those thus making or running the covered works for you must do so
|
||||||
|
exclusively on your behalf, under your direction and control, on terms that prohibit
|
||||||
|
them from making any copies of your copyrighted material outside their relationship
|
||||||
|
with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under the conditions
|
||||||
|
stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||||
|
|
||||||
|
### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological measure under any
|
||||||
|
applicable law fulfilling obligations under article 11 of the WIPO copyright treaty
|
||||||
|
adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention
|
||||||
|
of such measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid circumvention of
|
||||||
|
technological measures to the extent such circumvention is effected by exercising
|
||||||
|
rights under this License with respect to the covered work, and you disclaim any
|
||||||
|
intention to limit operation or modification of the work as a means of enforcing,
|
||||||
|
against the work's users, your or third parties' legal rights to forbid circumvention
|
||||||
|
of technological measures.
|
||||||
|
|
||||||
|
### 4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you receive it, in any
|
||||||
|
medium, provided that you conspicuously and appropriately publish on each copy an
|
||||||
|
appropriate copyright notice; keep intact all notices stating that this License and
|
||||||
|
any non-permissive terms added in accord with section 7 apply to the code; keep
|
||||||
|
intact all notices of the absence of any warranty; and give all recipients a copy of
|
||||||
|
this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey, and you may offer
|
||||||
|
support or warranty protection for a fee.
|
||||||
|
|
||||||
|
### 5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to produce it from
|
||||||
|
the Program, in the form of source code under the terms of section 4, provided that
|
||||||
|
you also meet all of these conditions:
|
||||||
|
|
||||||
|
* **a)** The work must carry prominent notices stating that you modified it, and giving a
|
||||||
|
relevant date.
|
||||||
|
* **b)** The work must carry prominent notices stating that it is released under this
|
||||||
|
License and any conditions added under section 7. This requirement modifies the
|
||||||
|
requirement in section 4 to “keep intact all notices”.
|
||||||
|
* **c)** You must license the entire work, as a whole, under this License to anyone who
|
||||||
|
comes into possession of a copy. This License will therefore apply, along with any
|
||||||
|
applicable section 7 additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no permission to license the
|
||||||
|
work in any other way, but it does not invalidate such permission if you have
|
||||||
|
separately received it.
|
||||||
|
* **d)** If the work has interactive user interfaces, each must display Appropriate Legal
|
||||||
|
Notices; however, if the Program has interactive interfaces that do not display
|
||||||
|
Appropriate Legal Notices, your work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent works, which are
|
||||||
|
not by their nature extensions of the covered work, and which are not combined with
|
||||||
|
it such as to form a larger program, in or on a volume of a storage or distribution
|
||||||
|
medium, is called an “aggregate” if the compilation and its resulting
|
||||||
|
copyright are not used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work in an aggregate
|
||||||
|
does not cause this License to apply to the other parts of the aggregate.
|
||||||
|
|
||||||
|
### 6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms of sections 4 and
|
||||||
|
5, provided that you also convey the machine-readable Corresponding Source under the
|
||||||
|
terms of this License, in one of these ways:
|
||||||
|
|
||||||
|
* **a)** Convey the object code in, or embodied in, a physical product (including a
|
||||||
|
physical distribution medium), accompanied by the Corresponding Source fixed on a
|
||||||
|
durable physical medium customarily used for software interchange.
|
||||||
|
* **b)** Convey the object code in, or embodied in, a physical product (including a
|
||||||
|
physical distribution medium), accompanied by a written offer, valid for at least
|
||||||
|
three years and valid for as long as you offer spare parts or customer support for
|
||||||
|
that product model, to give anyone who possesses the object code either (1) a copy of
|
||||||
|
the Corresponding Source for all the software in the product that is covered by this
|
||||||
|
License, on a durable physical medium customarily used for software interchange, for
|
||||||
|
a price no more than your reasonable cost of physically performing this conveying of
|
||||||
|
source, or (2) access to copy the Corresponding Source from a network server at no
|
||||||
|
charge.
|
||||||
|
* **c)** Convey individual copies of the object code with a copy of the written offer to
|
||||||
|
provide the Corresponding Source. This alternative is allowed only occasionally and
|
||||||
|
noncommercially, and only if you received the object code with such an offer, in
|
||||||
|
accord with subsection 6b.
|
||||||
|
* **d)** Convey the object code by offering access from a designated place (gratis or for
|
||||||
|
a charge), and offer equivalent access to the Corresponding Source in the same way
|
||||||
|
through the same place at no further charge. You need not require recipients to copy
|
||||||
|
the Corresponding Source along with the object code. If the place to copy the object
|
||||||
|
code is a network server, the Corresponding Source may be on a different server
|
||||||
|
(operated by you or a third party) that supports equivalent copying facilities,
|
||||||
|
provided you maintain clear directions next to the object code saying where to find
|
||||||
|
the Corresponding Source. Regardless of what server hosts the Corresponding Source,
|
||||||
|
you remain obligated to ensure that it is available for as long as needed to satisfy
|
||||||
|
these requirements.
|
||||||
|
* **e)** Convey the object code using peer-to-peer transmission, provided you inform
|
||||||
|
other peers where the object code and Corresponding Source of the work are being
|
||||||
|
offered to the general public at no charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded from the
|
||||||
|
Corresponding Source as a System Library, need not be included in conveying the
|
||||||
|
object code work.
|
||||||
|
|
||||||
|
A “User Product” is either (1) a “consumer product”, which
|
||||||
|
means any tangible personal property which is normally used for personal, family, or
|
||||||
|
household purposes, or (2) anything designed or sold for incorporation into a
|
||||||
|
dwelling. In determining whether a product is a consumer product, doubtful cases
|
||||||
|
shall be resolved in favor of coverage. For a particular product received by a
|
||||||
|
particular user, “normally used” refers to a typical or common use of
|
||||||
|
that class of product, regardless of the status of the particular user or of the way
|
||||||
|
in which the particular user actually uses, or expects or is expected to use, the
|
||||||
|
product. A product is a consumer product regardless of whether the product has
|
||||||
|
substantial commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
“Installation Information” for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install and execute
|
||||||
|
modified versions of a covered work in that User Product from a modified version of
|
||||||
|
its Corresponding Source. The information must suffice to ensure that the continued
|
||||||
|
functioning of the modified object code is in no case prevented or interfered with
|
||||||
|
solely because modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or specifically for
|
||||||
|
use in, a User Product, and the conveying occurs as part of a transaction in which
|
||||||
|
the right of possession and use of the User Product is transferred to the recipient
|
||||||
|
in perpetuity or for a fixed term (regardless of how the transaction is
|
||||||
|
characterized), the Corresponding Source conveyed under this section must be
|
||||||
|
accompanied by the Installation Information. But this requirement does not apply if
|
||||||
|
neither you nor any third party retains the ability to install modified object code
|
||||||
|
on the User Product (for example, the work has been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a requirement to
|
||||||
|
continue to provide support service, warranty, or updates for a work that has been
|
||||||
|
modified or installed by the recipient, or for the User Product in which it has been
|
||||||
|
modified or installed. Access to a network may be denied when the modification itself
|
||||||
|
materially and adversely affects the operation of the network or violates the rules
|
||||||
|
and protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided, in accord with
|
||||||
|
this section must be in a format that is publicly documented (and with an
|
||||||
|
implementation available to the public in source code form), and must require no
|
||||||
|
special password or key for unpacking, reading or copying.
|
||||||
|
|
||||||
|
### 7. Additional Terms.
|
||||||
|
|
||||||
|
“Additional permissions” are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions. Additional
|
||||||
|
permissions that are applicable to the entire Program shall be treated as though they
|
||||||
|
were included in this License, to the extent that they are valid under applicable
|
||||||
|
law. If additional permissions apply only to part of the Program, that part may be
|
||||||
|
used separately under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option remove any
|
||||||
|
additional permissions from that copy, or from any part of it. (Additional
|
||||||
|
permissions may be written to require their own removal in certain cases when you
|
||||||
|
modify the work.) You may place additional permissions on material, added by you to a
|
||||||
|
covered work, for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you add to a
|
||||||
|
covered work, you may (if authorized by the copyright holders of that material)
|
||||||
|
supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
* **a)** Disclaiming warranty or limiting liability differently from the terms of
|
||||||
|
sections 15 and 16 of this License; or
|
||||||
|
* **b)** Requiring preservation of specified reasonable legal notices or author
|
||||||
|
attributions in that material or in the Appropriate Legal Notices displayed by works
|
||||||
|
containing it; or
|
||||||
|
* **c)** Prohibiting misrepresentation of the origin of that material, or requiring that
|
||||||
|
modified versions of such material be marked in reasonable ways as different from the
|
||||||
|
original version; or
|
||||||
|
* **d)** Limiting the use for publicity purposes of names of licensors or authors of the
|
||||||
|
material; or
|
||||||
|
* **e)** Declining to grant rights under trademark law for use of some trade names,
|
||||||
|
trademarks, or service marks; or
|
||||||
|
* **f)** Requiring indemnification of licensors and authors of that material by anyone
|
||||||
|
who conveys the material (or modified versions of it) with contractual assumptions of
|
||||||
|
liability to the recipient, for any liability that these contractual assumptions
|
||||||
|
directly impose on those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered “further
|
||||||
|
restrictions” within the meaning of section 10. If the Program as you received
|
||||||
|
it, or any part of it, contains a notice stating that it is governed by this License
|
||||||
|
along with a term that is a further restriction, you may remove that term. If a
|
||||||
|
license document contains a further restriction but permits relicensing or conveying
|
||||||
|
under this License, you may add to a covered work material governed by the terms of
|
||||||
|
that license document, provided that the further restriction does not survive such
|
||||||
|
relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you must place, in
|
||||||
|
the relevant source files, a statement of the additional terms that apply to those
|
||||||
|
files, or a notice indicating where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the form of a
|
||||||
|
separately written license, or stated as exceptions; the above requirements apply
|
||||||
|
either way.
|
||||||
|
|
||||||
|
### 8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly provided under
|
||||||
|
this License. Any attempt otherwise to propagate or modify it is void, and will
|
||||||
|
automatically terminate your rights under this License (including any patent licenses
|
||||||
|
granted under the third paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your license from a
|
||||||
|
particular copyright holder is reinstated (a) provisionally, unless and until the
|
||||||
|
copyright holder explicitly and finally terminates your license, and (b) permanently,
|
||||||
|
if the copyright holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is reinstated permanently
|
||||||
|
if the copyright holder notifies you of the violation by some reasonable means, this
|
||||||
|
is the first time you have received notice of violation of this License (for any
|
||||||
|
work) from that copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the licenses of
|
||||||
|
parties who have received copies or rights from you under this License. If your
|
||||||
|
rights have been terminated and not permanently reinstated, you do not qualify to
|
||||||
|
receive new licenses for the same material under section 10.
|
||||||
|
|
||||||
|
### 9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or run a copy of the
|
||||||
|
Program. Ancillary propagation of a covered work occurring solely as a consequence of
|
||||||
|
using peer-to-peer transmission to receive a copy likewise does not require
|
||||||
|
acceptance. However, nothing other than this License grants you permission to
|
||||||
|
propagate or modify any covered work. These actions infringe copyright if you do not
|
||||||
|
accept this License. Therefore, by modifying or propagating a covered work, you
|
||||||
|
indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
### 10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically receives a license
|
||||||
|
from the original licensors, to run, modify and propagate that work, subject to this
|
||||||
|
License. You are not responsible for enforcing compliance by third parties with this
|
||||||
|
License.
|
||||||
|
|
||||||
|
An “entity transaction” is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an organization, or
|
||||||
|
merging organizations. If propagation of a covered work results from an entity
|
||||||
|
transaction, each party to that transaction who receives a copy of the work also
|
||||||
|
receives whatever licenses to the work the party's predecessor in interest had or
|
||||||
|
could give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if the predecessor
|
||||||
|
has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the rights granted or
|
||||||
|
affirmed under this License. For example, you may not impose a license fee, royalty,
|
||||||
|
or other charge for exercise of rights granted under this License, and you may not
|
||||||
|
initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging
|
||||||
|
that any patent claim is infringed by making, using, selling, offering for sale, or
|
||||||
|
importing the Program or any portion of it.
|
||||||
|
|
||||||
|
### 11. Patents.
|
||||||
|
|
||||||
|
A “contributor” is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The work thus
|
||||||
|
licensed is called the contributor's “contributor version”.
|
||||||
|
|
||||||
|
A contributor's “essential patent claims” are all patent claims owned or
|
||||||
|
controlled by the contributor, whether already acquired or hereafter acquired, that
|
||||||
|
would be infringed by some manner, permitted by this License, of making, using, or
|
||||||
|
selling its contributor version, but do not include claims that would be infringed
|
||||||
|
only as a consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, “control” includes the right to grant patent
|
||||||
|
sublicenses in a manner consistent with the requirements of this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license
|
||||||
|
under the contributor's essential patent claims, to make, use, sell, offer for sale,
|
||||||
|
import and otherwise run, modify and propagate the contents of its contributor
|
||||||
|
version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a “patent license” is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent (such as an
|
||||||
|
express permission to practice a patent or covenant not to sue for patent
|
||||||
|
infringement). To “grant” such a patent license to a party means to make
|
||||||
|
such an agreement or commitment not to enforce a patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license, and the
|
||||||
|
Corresponding Source of the work is not available for anyone to copy, free of charge
|
||||||
|
and under the terms of this License, through a publicly available network server or
|
||||||
|
other readily accessible means, then you must either (1) cause the Corresponding
|
||||||
|
Source to be so available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner consistent with
|
||||||
|
the requirements of this License, to extend the patent license to downstream
|
||||||
|
recipients. “Knowingly relying” means you have actual knowledge that, but
|
||||||
|
for the patent license, your conveying the covered work in a country, or your
|
||||||
|
recipient's use of the covered work in a country, would infringe one or more
|
||||||
|
identifiable patents in that country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or arrangement, you
|
||||||
|
convey, or propagate by procuring conveyance of, a covered work, and grant a patent
|
||||||
|
license to some of the parties receiving the covered work authorizing them to use,
|
||||||
|
propagate, modify or convey a specific copy of the covered work, then the patent
|
||||||
|
license you grant is automatically extended to all recipients of the covered work and
|
||||||
|
works based on it.
|
||||||
|
|
||||||
|
A patent license is “discriminatory” if it does not include within the
|
||||||
|
scope of its coverage, prohibits the exercise of, or is conditioned on the
|
||||||
|
non-exercise of one or more of the rights that are specifically granted under this
|
||||||
|
License. You may not convey a covered work if you are a party to an arrangement with
|
||||||
|
a third party that is in the business of distributing software, under which you make
|
||||||
|
payment to the third party based on the extent of your activity of conveying the
|
||||||
|
work, and under which the third party grants, to any of the parties who would receive
|
||||||
|
the covered work from you, a discriminatory patent license (a) in connection with
|
||||||
|
copies of the covered work conveyed by you (or copies made from those copies), or (b)
|
||||||
|
primarily for and in connection with specific products or compilations that contain
|
||||||
|
the covered work, unless you entered into that arrangement, or that patent license
|
||||||
|
was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting any implied
|
||||||
|
license or other defenses to infringement that may otherwise be available to you
|
||||||
|
under applicable patent law.
|
||||||
|
|
||||||
|
### 12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or otherwise)
|
||||||
|
that contradict the conditions of this License, they do not excuse you from the
|
||||||
|
conditions of this License. If you cannot convey a covered work so as to satisfy
|
||||||
|
simultaneously your obligations under this License and any other pertinent
|
||||||
|
obligations, then as a consequence you may not convey it at all. For example, if you
|
||||||
|
agree to terms that obligate you to collect a royalty for further conveying from
|
||||||
|
those to whom you convey the Program, the only way you could satisfy both those terms
|
||||||
|
and this License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
### 13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have permission to link or
|
||||||
|
combine any covered work with a work licensed under version 3 of the GNU Affero
|
||||||
|
General Public License into a single combined work, and to convey the resulting work.
|
||||||
|
The terms of this License will continue to apply to the part which is the covered
|
||||||
|
work, but the special requirements of the GNU Affero General Public License, section
|
||||||
|
13, concerning interaction through a network will apply to the combination as such.
|
||||||
|
|
||||||
|
### 14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of the GNU
|
||||||
|
General Public License from time to time. Such new versions will be similar in spirit
|
||||||
|
to the present version, but may differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program specifies that
|
||||||
|
a certain numbered version of the GNU General Public License “or any later
|
||||||
|
version” applies to it, you have the option of following the terms and
|
||||||
|
conditions either of that numbered version or of any later version published by the
|
||||||
|
Free Software Foundation. If the Program does not specify a version number of the GNU
|
||||||
|
General Public License, you may choose any version ever published by the Free
|
||||||
|
Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future versions of the GNU
|
||||||
|
General Public License can be used, that proxy's public statement of acceptance of a
|
||||||
|
version permanently authorizes you to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different permissions. However, no
|
||||||
|
additional obligations are imposed on any author or copyright holder as a result of
|
||||||
|
your choosing to follow a later version.
|
||||||
|
|
||||||
|
### 15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||||
|
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||||
|
PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||||
|
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE
|
||||||
|
QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
||||||
|
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
### 16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY
|
||||||
|
COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS
|
||||||
|
PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
|
||||||
|
INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||||
|
PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE
|
||||||
|
OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE
|
||||||
|
WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
### 17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided above cannot be
|
||||||
|
given local legal effect according to their terms, reviewing courts shall apply local
|
||||||
|
law that most closely approximates an absolute waiver of all civil liability in
|
||||||
|
connection with the Program, unless a warranty or assumption of liability accompanies
|
||||||
|
a copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
## How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest possible use to
|
||||||
|
the public, the best way to achieve this is to make it free software which everyone
|
||||||
|
can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest to attach them
|
||||||
|
to the start of each source file to most effectively state the exclusion of warranty;
|
||||||
|
and each file should have at least the “copyright” line and a pointer to
|
||||||
|
where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short notice like this
|
||||||
|
when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type 'show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands 'show w' and 'show c' should show the appropriate parts of
|
||||||
|
the General Public License. Of course, your program's commands might be different;
|
||||||
|
for a GUI interface, you would use an “about box”.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school, if any, to
|
||||||
|
sign a “copyright disclaimer” for the program, if necessary. For more
|
||||||
|
information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<<https://www.gnu.org/licenses/>>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program into
|
||||||
|
proprietary programs. If your program is a subroutine library, you may consider it
|
||||||
|
more useful to permit linking proprietary applications with the library. If this is
|
||||||
|
what you want to do, use the GNU Lesser General Public License instead of this
|
||||||
|
License. But first, please read
|
||||||
|
<<https://www.gnu.org/philosophy/why-not-lgpl.html>>.
|
2
vendor/github.com/evilsocket/islazy/fs/doc.go
generated
vendored
Normal file
2
vendor/github.com/evilsocket/islazy/fs/doc.go
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
// Package fs contains helper functions for file system access and enumeration.
|
||||||
|
package fs
|
20
vendor/github.com/evilsocket/islazy/fs/glob.go
generated
vendored
Normal file
20
vendor/github.com/evilsocket/islazy/fs/glob.go
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
package fs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Glob enumerates files on a given path using a globbing expression and
|
||||||
|
// execute a callback for each of the files. The callback can interrupt
|
||||||
|
// the loop by returning an error other than nil.
|
||||||
|
func Glob(path string, expr string, cb func(fileName string) error) (err error) {
|
||||||
|
var files []string
|
||||||
|
if files, err = filepath.Glob(filepath.Join(path, expr)); err == nil {
|
||||||
|
for _, fileName := range files {
|
||||||
|
if err = cb(fileName); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
31
vendor/github.com/evilsocket/islazy/fs/line_reader.go
generated
vendored
Normal file
31
vendor/github.com/evilsocket/islazy/fs/line_reader.go
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
package fs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LineReader accepts the name of a file and offset as argument
|
||||||
|
// and will return a channel from which lines can be read
|
||||||
|
// one at a time.
|
||||||
|
func LineReader(filename string) (chan string, error) {
|
||||||
|
fp, err := os.Open(filename)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
out := make(chan string)
|
||||||
|
go func() {
|
||||||
|
defer fp.Close()
|
||||||
|
// we need to close the out channel in order
|
||||||
|
// to signal the end-of-data condition
|
||||||
|
defer close(out)
|
||||||
|
scanner := bufio.NewScanner(fp)
|
||||||
|
scanner.Split(bufio.ScanLines)
|
||||||
|
for scanner.Scan() {
|
||||||
|
out <- scanner.Text()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
return out, nil
|
||||||
|
}
|
25
vendor/github.com/evilsocket/islazy/fs/misc.go
generated
vendored
Normal file
25
vendor/github.com/evilsocket/islazy/fs/misc.go
generated
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package fs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"os/user"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Expand will expand a path with ~ to a full path of the current user.
|
||||||
|
func Expand(path string) (string, error) {
|
||||||
|
usr, err := user.Current()
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return filepath.Abs(strings.Replace(path, "~", usr.HomeDir, 1))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exists returns true if the path exists.
|
||||||
|
func Exists(path string) bool {
|
||||||
|
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
2
vendor/github.com/evilsocket/islazy/log/doc.go
generated
vendored
Normal file
2
vendor/github.com/evilsocket/islazy/log/doc.go
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
// Package log provides access to log functions.
|
||||||
|
package log
|
62
vendor/github.com/evilsocket/islazy/log/format.go
generated
vendored
Normal file
62
vendor/github.com/evilsocket/islazy/log/format.go
generated
vendored
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
package log
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Tokens is a map of the tokens that can be used in Format
|
||||||
|
// to insert values returned by the execution of a callback.
|
||||||
|
Tokens = map[string]func() string{
|
||||||
|
"{date}": func() string {
|
||||||
|
return time.Now().Format(DateFormat)
|
||||||
|
},
|
||||||
|
"{time}": func() string {
|
||||||
|
return time.Now().Format(TimeFormat)
|
||||||
|
},
|
||||||
|
"{datetime}": func() string {
|
||||||
|
return time.Now().Format(DateTimeFormat)
|
||||||
|
},
|
||||||
|
"{level:value}": func() string {
|
||||||
|
return strconv.Itoa(int(currLevel))
|
||||||
|
},
|
||||||
|
"{level:name}": func() string {
|
||||||
|
return LevelNames[currLevel]
|
||||||
|
},
|
||||||
|
"{level:color}": func() string {
|
||||||
|
return LevelColors[currLevel]
|
||||||
|
},
|
||||||
|
"{message}": func() string {
|
||||||
|
return currMessage
|
||||||
|
},
|
||||||
|
}
|
||||||
|
// Effects is a map of the tokens that can be used in Format to
|
||||||
|
// change the properties of the text.
|
||||||
|
Effects = map[string]string{
|
||||||
|
"{bold}": tui.BOLD,
|
||||||
|
"{dim}": tui.DIM,
|
||||||
|
"{red}": tui.RED,
|
||||||
|
"{green}": tui.GREEN,
|
||||||
|
"{blue}": tui.BLUE,
|
||||||
|
"{yellow}": tui.YELLOW,
|
||||||
|
"{f:black}": tui.FOREBLACK,
|
||||||
|
"{f:white}": tui.FOREWHITE,
|
||||||
|
"{b:darkgray}": tui.BACKDARKGRAY,
|
||||||
|
"{b:red}": tui.BACKRED,
|
||||||
|
"{b:green}": tui.BACKGREEN,
|
||||||
|
"{b:yellow}": tui.BACKYELLOW,
|
||||||
|
"{b:lightblue}": tui.BACKLIGHTBLUE,
|
||||||
|
"{reset}": tui.RESET,
|
||||||
|
}
|
||||||
|
// DateFormat is the default date format being used when filling the {date} log token.
|
||||||
|
DateFormat = "06-Jan-02"
|
||||||
|
// TimeFormat is the default time format being used when filling the {time} or {datetime} log tokens.
|
||||||
|
TimeFormat = "15:04:05"
|
||||||
|
// DateTimeFormat is the default date and time format being used when filling the {datetime} log token.
|
||||||
|
DateTimeFormat = "2006-01-02 15:04:05"
|
||||||
|
// Format is the default format being used when logging.
|
||||||
|
Format = "{datetime} {level:color}{level:name}{reset} {message}"
|
||||||
|
)
|
44
vendor/github.com/evilsocket/islazy/log/level.go
generated
vendored
Normal file
44
vendor/github.com/evilsocket/islazy/log/level.go
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
package log
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Verbosity represents the verbosity level of the logger.
|
||||||
|
type Verbosity int
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Debug messages.
|
||||||
|
DEBUG Verbosity = iota
|
||||||
|
// Informative messages.
|
||||||
|
INFO
|
||||||
|
// Informative messages that are important.
|
||||||
|
IMPORTANT
|
||||||
|
// Warning messages.
|
||||||
|
WARNING
|
||||||
|
// Recoverable error conditions.
|
||||||
|
ERROR
|
||||||
|
// Fatal error conditions.
|
||||||
|
FATAL
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// LevelNames is a map of the names ( {level:name} ) of each verbosity level.
|
||||||
|
LevelNames = map[Verbosity]string{
|
||||||
|
DEBUG: "dbg",
|
||||||
|
INFO: "inf",
|
||||||
|
IMPORTANT: "imp",
|
||||||
|
WARNING: "war",
|
||||||
|
ERROR: "err",
|
||||||
|
FATAL: "!!!",
|
||||||
|
}
|
||||||
|
// LevelColors is a map of the colors ( {level:color} ) of each verbosity level.
|
||||||
|
LevelColors = map[Verbosity]string{
|
||||||
|
DEBUG: tui.DIM + tui.FOREBLACK + tui.BACKDARKGRAY,
|
||||||
|
INFO: tui.FOREWHITE + tui.BACKGREEN,
|
||||||
|
IMPORTANT: tui.FOREWHITE + tui.BACKLIGHTBLUE,
|
||||||
|
WARNING: tui.FOREWHITE + tui.BACKYELLOW,
|
||||||
|
ERROR: tui.FOREWHITE + tui.BACKRED,
|
||||||
|
FATAL: tui.FOREWHITE + tui.BACKRED + tui.BOLD,
|
||||||
|
}
|
||||||
|
)
|
127
vendor/github.com/evilsocket/islazy/log/log.go
generated
vendored
Normal file
127
vendor/github.com/evilsocket/islazy/log/log.go
generated
vendored
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
package log
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/tui"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Level represents the current verbosity level of the logging system.
|
||||||
|
Level = INFO
|
||||||
|
// Output represents the log output file path if filled or, if empty, stdout.
|
||||||
|
Output = ""
|
||||||
|
// NoEffects disables all effects and colors if set to true.
|
||||||
|
NoEffects = false
|
||||||
|
// OnFatal represents the callback/action to execute on Fatal messages.
|
||||||
|
OnFatal = ExitOnFatal
|
||||||
|
|
||||||
|
lock = &sync.Mutex{}
|
||||||
|
currMessage = ""
|
||||||
|
currLevel = INFO
|
||||||
|
writer = os.Stdout
|
||||||
|
|
||||||
|
reEffects = []*regexp.Regexp{
|
||||||
|
regexp.MustCompile("\x033\\[\\d+m"),
|
||||||
|
regexp.MustCompile("\\\\e\\[\\d+m"),
|
||||||
|
regexp.MustCompile("\x1b\\[\\d+m"),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Open initializes the logging system.
|
||||||
|
func Open() (err error) {
|
||||||
|
if Output != "" {
|
||||||
|
writer, err = os.OpenFile(Output, os.O_APPEND|os.O_RDWR|os.O_CREATE, 0644)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close finalizes the logging system.
|
||||||
|
func Close() {
|
||||||
|
if writer != os.Stdout {
|
||||||
|
writer.Close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func emit(s string) {
|
||||||
|
// remove all effects if found
|
||||||
|
if NoEffects {
|
||||||
|
for _, re := range reEffects {
|
||||||
|
s = re.ReplaceAllString(s, "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintf(writer, s)
|
||||||
|
fmt.Fprintf(writer, "\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
func do(v Verbosity, format string, args ...interface{}) {
|
||||||
|
lock.Lock()
|
||||||
|
defer lock.Unlock()
|
||||||
|
|
||||||
|
if Level > v {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
logLine := Format
|
||||||
|
currLevel = v
|
||||||
|
currMessage = fmt.Sprintf(format, args...)
|
||||||
|
// process token -> callback
|
||||||
|
for token, cb := range Tokens {
|
||||||
|
logLine = strings.Replace(logLine, token, cb(), -1)
|
||||||
|
}
|
||||||
|
// process token -> effect
|
||||||
|
for token, effect := range Effects {
|
||||||
|
logLine = strings.Replace(logLine, token, effect, -1)
|
||||||
|
}
|
||||||
|
// make sure an user error does not screw the log
|
||||||
|
if tui.HasEffect(logLine) && !strings.HasSuffix(logLine, tui.RESET) {
|
||||||
|
logLine += tui.RESET
|
||||||
|
}
|
||||||
|
|
||||||
|
emit(logLine)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Raw emits a message without format to the logs.
|
||||||
|
func Raw(format string, args ...interface{}) {
|
||||||
|
lock.Lock()
|
||||||
|
defer lock.Unlock()
|
||||||
|
|
||||||
|
currMessage = fmt.Sprintf(format, args...)
|
||||||
|
emit(currMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Debug emits a debug message.
|
||||||
|
func Debug(format string, args ...interface{}) {
|
||||||
|
do(DEBUG, format, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Info emits an informative message.
|
||||||
|
func Info(format string, args ...interface{}) {
|
||||||
|
do(INFO, format, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Important emits an important informative message.
|
||||||
|
func Important(format string, args ...interface{}) {
|
||||||
|
do(IMPORTANT, format, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Warning emits a warning message.
|
||||||
|
func Warning(format string, args ...interface{}) {
|
||||||
|
do(WARNING, format, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error emits an error message.
|
||||||
|
func Error(format string, args ...interface{}) {
|
||||||
|
do(ERROR, format, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fata emits a fatal error message and calls the log.OnFatal callback.
|
||||||
|
func Fatal(format string, args ...interface{}) {
|
||||||
|
do(FATAL, format, args...)
|
||||||
|
OnFatal()
|
||||||
|
}
|
23
vendor/github.com/evilsocket/islazy/log/policy.go
generated
vendored
Normal file
23
vendor/github.com/evilsocket/islazy/log/policy.go
generated
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
package log
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FatalPolicy represents a callback to be executed on Fatal messages.
|
||||||
|
type FatalPolicy func()
|
||||||
|
|
||||||
|
// os.Exit(1) on Fatal messages.
|
||||||
|
func ExitOnFatal() {
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// os.Exit(0) on Fatal messages.
|
||||||
|
func ExitCleanOnFatal() {
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do nothing on Fatal messages.
|
||||||
|
func NoneOnFatal() {
|
||||||
|
|
||||||
|
}
|
2
vendor/github.com/evilsocket/islazy/str/doc.go
generated
vendored
Normal file
2
vendor/github.com/evilsocket/islazy/str/doc.go
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
// Package str contains utilities for string manipulation.
|
||||||
|
package str
|
24
vendor/github.com/evilsocket/islazy/str/split.go
generated
vendored
Normal file
24
vendor/github.com/evilsocket/islazy/str/split.go
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
package str
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SplitBy splits by a separator a string and returns a
|
||||||
|
// list of the non empty parts.
|
||||||
|
func SplitBy(sv string, sep string) []string {
|
||||||
|
filtered := make([]string, 0)
|
||||||
|
for _, part := range strings.Split(sv, sep) {
|
||||||
|
part = Trim(part)
|
||||||
|
if part != "" {
|
||||||
|
filtered = append(filtered, part)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filtered
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comma splits by comma a string and returns a
|
||||||
|
// list of the non empty parts.
|
||||||
|
func Comma(csv string) []string {
|
||||||
|
return SplitBy(csv, ",")
|
||||||
|
}
|
24
vendor/github.com/evilsocket/islazy/str/trim.go
generated
vendored
Normal file
24
vendor/github.com/evilsocket/islazy/str/trim.go
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
package str
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
whiteSpaceTrimSet = "\r\n\t "
|
||||||
|
)
|
||||||
|
|
||||||
|
// Trim trims a string from white spaces.
|
||||||
|
func Trim(s string) string {
|
||||||
|
return strings.Trim(s, whiteSpaceTrimSet)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TrimRight trims the right part of a string from white spaces.
|
||||||
|
func TrimRight(s string) string {
|
||||||
|
return strings.TrimRight(s, whiteSpaceTrimSet)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TrimLeft trims the left part of a string from white spaces.
|
||||||
|
func TrimLeft(s string) string {
|
||||||
|
return strings.TrimLeft(s, whiteSpaceTrimSet)
|
||||||
|
}
|
104
vendor/github.com/evilsocket/islazy/tui/colors.go
generated
vendored
Normal file
104
vendor/github.com/evilsocket/islazy/tui/colors.go
generated
vendored
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
package tui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// https://misc.flogisoft.com/bash/tip_colors_and_formatting
|
||||||
|
var (
|
||||||
|
// effects
|
||||||
|
BOLD = "\033[1m"
|
||||||
|
DIM = "\033[2m"
|
||||||
|
RESET = "\033[0m"
|
||||||
|
// colors
|
||||||
|
RED = "\033[31m"
|
||||||
|
GREEN = "\033[32m"
|
||||||
|
BLUE = "\033[34m"
|
||||||
|
YELLOW = "\033[33m"
|
||||||
|
// foreground colors
|
||||||
|
FOREBLACK = "\033[30m"
|
||||||
|
FOREWHITE = "\033[97m"
|
||||||
|
// background colors
|
||||||
|
BACKDARKGRAY = "\033[100m"
|
||||||
|
BACKRED = "\033[41m"
|
||||||
|
BACKGREEN = "\033[42m"
|
||||||
|
BACKYELLOW = "\033[43m"
|
||||||
|
BACKLIGHTBLUE = "\033[104m"
|
||||||
|
|
||||||
|
ctrl = []string{"\x033", "\\e", "\x1b"}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Effects returns true if colors and effects are supported
|
||||||
|
// on the current terminal.
|
||||||
|
func Effects() bool {
|
||||||
|
if term := os.Getenv("TERM"); term == "" {
|
||||||
|
return false
|
||||||
|
} else if term == "dumb" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable will disable all colors and effects.
|
||||||
|
func Disable() {
|
||||||
|
BOLD = ""
|
||||||
|
DIM = ""
|
||||||
|
RESET = ""
|
||||||
|
RED = ""
|
||||||
|
GREEN = ""
|
||||||
|
BLUE = ""
|
||||||
|
YELLOW = ""
|
||||||
|
FOREBLACK = ""
|
||||||
|
FOREWHITE = ""
|
||||||
|
BACKDARKGRAY = ""
|
||||||
|
BACKRED = ""
|
||||||
|
BACKGREEN = ""
|
||||||
|
BACKYELLOW = ""
|
||||||
|
BACKLIGHTBLUE = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasEffect returns true if the string has any shell control codes in it.
|
||||||
|
func HasEffect(s string) bool {
|
||||||
|
for _, ch := range ctrl {
|
||||||
|
if strings.Contains(s, ch) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wrap wraps a string with an effect or color and appends a reset control code.
|
||||||
|
func Wrap(e, s string) string {
|
||||||
|
return e + s + RESET
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bold makes the string Bold.
|
||||||
|
func Bold(s string) string {
|
||||||
|
return Wrap(BOLD, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dim makes the string Diminished.
|
||||||
|
func Dim(s string) string {
|
||||||
|
return Wrap(DIM, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Red makes the string Red.
|
||||||
|
func Red(s string) string {
|
||||||
|
return Wrap(RED, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Green makes the string Green.
|
||||||
|
func Green(s string) string {
|
||||||
|
return Wrap(GREEN, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Blue makes the string Green.
|
||||||
|
func Blue(s string) string {
|
||||||
|
return Wrap(BLUE, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Yellow makes the string Green.
|
||||||
|
func Yellow(s string) string {
|
||||||
|
return Wrap(YELLOW, s)
|
||||||
|
}
|
3
vendor/github.com/evilsocket/islazy/tui/doc.go
generated
vendored
Normal file
3
vendor/github.com/evilsocket/islazy/tui/doc.go
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
// Package tui contains a set of helper objects and functions for terminal
|
||||||
|
// based user interfaces.
|
||||||
|
package tui
|
27
core/table.go → vendor/github.com/evilsocket/islazy/tui/table.go
generated
vendored
27
core/table.go → vendor/github.com/evilsocket/islazy/tui/table.go
generated
vendored
|
@ -1,4 +1,4 @@
|
||||||
package core
|
package tui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -28,22 +28,22 @@ func maxLen(strings []string) int {
|
||||||
return maxLen
|
return maxLen
|
||||||
}
|
}
|
||||||
|
|
||||||
type Alignment int
|
type alignment int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
AlignLeft = Alignment(0)
|
alignLeft = alignment(0)
|
||||||
AlignCenter = Alignment(1)
|
alignCenter = alignment(1)
|
||||||
AlignRight = Alignment(2)
|
alignRight = alignment(2)
|
||||||
)
|
)
|
||||||
|
|
||||||
func getPads(s string, maxLen int, align Alignment) (lPad int, rPad int) {
|
func getPads(s string, maxLen int, align alignment) (lPad int, rPad int) {
|
||||||
len := viewLen(s)
|
len := viewLen(s)
|
||||||
diff := maxLen - len
|
diff := maxLen - len
|
||||||
|
|
||||||
if align == AlignLeft {
|
if align == alignLeft {
|
||||||
lPad = 0
|
lPad = 0
|
||||||
rPad = diff - lPad + 1
|
rPad = diff - lPad + 1
|
||||||
} else if align == AlignCenter {
|
} else if align == alignCenter {
|
||||||
lPad = diff / 2
|
lPad = diff / 2
|
||||||
rPad = diff - lPad + 1
|
rPad = diff - lPad + 1
|
||||||
} /* else {
|
} /* else {
|
||||||
|
@ -53,12 +53,15 @@ func getPads(s string, maxLen int, align Alignment) (lPad int, rPad int) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func padded(s string, maxLen int, align Alignment) string {
|
func padded(s string, maxLen int, align alignment) string {
|
||||||
lPad, rPad := getPads(s, maxLen, align)
|
lPad, rPad := getPads(s, maxLen, align)
|
||||||
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 AsTable(w io.Writer, columns []string, rows [][]string) {
|
// 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.
|
||||||
|
func Table(w io.Writer, columns []string, rows [][]string) {
|
||||||
for i, col := range columns {
|
for i, col := range columns {
|
||||||
columns[i] = fmt.Sprintf(" %s ", col)
|
columns[i] = fmt.Sprintf(" %s ", col)
|
||||||
}
|
}
|
||||||
|
@ -87,7 +90,7 @@ func AsTable(w io.Writer, columns []string, rows [][]string) {
|
||||||
// header
|
// header
|
||||||
table += fmt.Sprintf("%s\n", lineSep)
|
table += fmt.Sprintf("%s\n", lineSep)
|
||||||
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", lineSep)
|
||||||
|
@ -95,7 +98,7 @@ func AsTable(w io.Writer, columns []string, rows [][]string) {
|
||||||
// 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")
|
||||||
}
|
}
|
2
vendor/github.com/evilsocket/islazy/zip/doc.go
generated
vendored
Normal file
2
vendor/github.com/evilsocket/islazy/zip/doc.go
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
// Package zip contains zip and unzip utilities.
|
||||||
|
package zip
|
55
vendor/github.com/evilsocket/islazy/zip/unzip.go
generated
vendored
Normal file
55
vendor/github.com/evilsocket/islazy/zip/unzip.go
generated
vendored
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
package zip
|
||||||
|
|
||||||
|
import (
|
||||||
|
"archive/zip"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Unzip will decompress a zip archive, moving all files and folders
|
||||||
|
// within the zip file (parameter 1) to an output directory (parameter 2).
|
||||||
|
// Credits to https://golangcode.com/unzip-files-in-go/
|
||||||
|
func Unzip(src string, dest string) ([]string, error) {
|
||||||
|
var filenames []string
|
||||||
|
|
||||||
|
r, err := zip.OpenReader(src)
|
||||||
|
if err != nil {
|
||||||
|
return filenames, err
|
||||||
|
}
|
||||||
|
defer r.Close()
|
||||||
|
|
||||||
|
for _, f := range r.File {
|
||||||
|
rc, err := f.Open()
|
||||||
|
if err != nil {
|
||||||
|
return filenames, err
|
||||||
|
}
|
||||||
|
defer rc.Close()
|
||||||
|
|
||||||
|
// Store filename/path for returning and using later on
|
||||||
|
fpath := filepath.Join(dest, f.Name)
|
||||||
|
|
||||||
|
// Check for ZipSlip. More Info: https://snyk.io/research/zip-slip-vulnerability#go
|
||||||
|
if !strings.HasPrefix(fpath, filepath.Clean(dest)+string(os.PathSeparator)) {
|
||||||
|
return filenames, fmt.Errorf("%s: illegal file path", fpath)
|
||||||
|
}
|
||||||
|
|
||||||
|
filenames = append(filenames, fpath)
|
||||||
|
if f.FileInfo().IsDir() {
|
||||||
|
os.MkdirAll(fpath, os.ModePerm)
|
||||||
|
} else if err = os.MkdirAll(filepath.Dir(fpath), os.ModePerm); err != nil {
|
||||||
|
return filenames, err
|
||||||
|
} else if outFile, err := os.OpenFile(fpath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode()); err != nil {
|
||||||
|
return filenames, err
|
||||||
|
} else {
|
||||||
|
defer outFile.Close()
|
||||||
|
if _, err = io.Copy(outFile, rc); err != nil {
|
||||||
|
return filenames, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return filenames, nil
|
||||||
|
}
|
10
vendor/github.com/gobwas/glob/readme.md
generated
vendored
10
vendor/github.com/gobwas/glob/readme.md
generated
vendored
|
@ -126,10 +126,10 @@ Pattern | Fixture | Match | Speed (ns/op)
|
||||||
`^[a-z][^a-x].*cat.*[h][^b].*eyes.*$` | `my dog has very bright eyes` | `false` | 1383
|
`^[a-z][^a-x].*cat.*[h][^b].*eyes.*$` | `my dog has very bright eyes` | `false` | 1383
|
||||||
`^https:\/\/.*\.google\..*$` | `https://account.google.com` | `true` | 1205
|
`^https:\/\/.*\.google\..*$` | `https://account.google.com` | `true` | 1205
|
||||||
`^https:\/\/.*\.google\..*$` | `https://google.com` | `false` | 767
|
`^https:\/\/.*\.google\..*$` | `https://google.com` | `false` | 767
|
||||||
`^(https:\/\/.*\.google\..*|.*yandex\..*|.*yahoo\..*|.*mail\.ru)$` | `http://yahoo.com` | `true` | 1435
|
`^(https:\/\/.*\.google\..*\|.*yandex\..*\|.*yahoo\..*\|.*mail\.ru)$` | `http://yahoo.com` | `true` | 1435
|
||||||
`^(https:\/\/.*\.google\..*|.*yandex\..*|.*yahoo\..*|.*mail\.ru)$` | `http://google.com` | `false` | 1674
|
`^(https:\/\/.*\.google\..*\|.*yandex\..*\|.*yahoo\..*\|.*mail\.ru)$` | `http://google.com` | `false` | 1674
|
||||||
`^(https:\/\/.*gobwas\.com|http://exclude.gobwas.com)$` | `https://safe.gobwas.com` | `true` | 1039
|
`^(https:\/\/.*gobwas\.com\|http://exclude.gobwas.com)$` | `https://safe.gobwas.com` | `true` | 1039
|
||||||
`^(https:\/\/.*gobwas\.com|http://exclude.gobwas.com)$` | `http://safe.gobwas.com` | `false` | 272
|
`^(https:\/\/.*gobwas\.com\|http://exclude.gobwas.com)$` | `http://safe.gobwas.com` | `false` | 272
|
||||||
`^abc.*$` | `abcdef` | `true` | 237
|
`^abc.*$` | `abcdef` | `true` | 237
|
||||||
`^abc.*$` | `af` | `false` | 100
|
`^abc.*$` | `af` | `false` | 100
|
||||||
`^.*def$` | `abcdef` | `true` | 464
|
`^.*def$` | `abcdef` | `true` | 464
|
||||||
|
@ -145,4 +145,4 @@ Pattern | Fixture | Match | Speed (ns/op)
|
||||||
## Syntax
|
## Syntax
|
||||||
|
|
||||||
Syntax is inspired by [standard wildcards](http://tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm),
|
Syntax is inspired by [standard wildcards](http://tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm),
|
||||||
except that `**` is aka super-asterisk, that do not sensitive for separators.
|
except that `**` is aka super-asterisk, that do not sensitive for separators.
|
||||||
|
|
9
vendor/github.com/google/gopacket/.travis.golint.sh
generated
vendored
9
vendor/github.com/google/gopacket/.travis.golint.sh
generated
vendored
|
@ -3,7 +3,7 @@
|
||||||
cd "$(dirname $0)"
|
cd "$(dirname $0)"
|
||||||
|
|
||||||
go get github.com/golang/lint/golint
|
go get github.com/golang/lint/golint
|
||||||
DIRS=". tcpassembly tcpassembly/tcpreader ip4defrag reassembly macs pcapgo pcap afpacket pfring routing"
|
DIRS=". tcpassembly tcpassembly/tcpreader ip4defrag reassembly macs pcapgo pcap afpacket pfring routing defrag/lcmdefrag"
|
||||||
# Add subdirectories here as we clean up golint on each.
|
# Add subdirectories here as we clean up golint on each.
|
||||||
for subdir in $DIRS; do
|
for subdir in $DIRS; do
|
||||||
pushd $subdir
|
pushd $subdir
|
||||||
|
@ -17,8 +17,11 @@ for subdir in $DIRS; do
|
||||||
done
|
done
|
||||||
|
|
||||||
pushd layers
|
pushd layers
|
||||||
for file in $(cat .linted); do
|
for file in *.go; do
|
||||||
if golint $file | grep .; then
|
if cat .lint_blacklist | grep -q $file; then
|
||||||
|
echo "Skipping lint of $file due to .lint_blacklist"
|
||||||
|
elif golint $file | grep .; then
|
||||||
|
echo "Lint error in file $file"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
2
vendor/github.com/google/gopacket/.travis.govet.sh
generated
vendored
2
vendor/github.com/google/gopacket/.travis.govet.sh
generated
vendored
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
cd "$(dirname $0)"
|
cd "$(dirname $0)"
|
||||||
DIRS=". layers pcap pcapgo pfring tcpassembly tcpassembly/tcpreader routing ip4defrag bytediff macs"
|
DIRS=". layers pcap pcapgo tcpassembly tcpassembly/tcpreader routing ip4defrag bytediff macs defrag/lcmdefrag"
|
||||||
set -e
|
set -e
|
||||||
for subdir in $DIRS; do
|
for subdir in $DIRS; do
|
||||||
pushd $subdir
|
pushd $subdir
|
||||||
|
|
4
vendor/github.com/google/gopacket/.travis.yml
generated
vendored
4
vendor/github.com/google/gopacket/.travis.yml
generated
vendored
|
@ -1,12 +1,16 @@
|
||||||
language: go
|
language: go
|
||||||
|
before_install:
|
||||||
|
- sudo apt-get install libpcap-dev
|
||||||
install:
|
install:
|
||||||
- go get github.com/google/gopacket
|
- go get github.com/google/gopacket
|
||||||
- go get github.com/google/gopacket/layers
|
- go get github.com/google/gopacket/layers
|
||||||
|
- go get github.com/google/gopacket/pcapgo
|
||||||
- go get github.com/google/gopacket/tcpassembly
|
- go get github.com/google/gopacket/tcpassembly
|
||||||
- go get github.com/google/gopacket/reassembly
|
- go get github.com/google/gopacket/reassembly
|
||||||
script:
|
script:
|
||||||
- go test github.com/google/gopacket
|
- go test github.com/google/gopacket
|
||||||
- go test github.com/google/gopacket/layers
|
- go test github.com/google/gopacket/layers
|
||||||
|
- go test github.com/google/gopacket/pcapgo
|
||||||
- go test github.com/google/gopacket/tcpassembly
|
- go test github.com/google/gopacket/tcpassembly
|
||||||
- go test github.com/google/gopacket/reassembly
|
- go test github.com/google/gopacket/reassembly
|
||||||
- ./.travis.gofmt.sh
|
- ./.travis.gofmt.sh
|
||||||
|
|
2
vendor/github.com/google/gopacket/doc.go
generated
vendored
2
vendor/github.com/google/gopacket/doc.go
generated
vendored
|
@ -329,7 +329,7 @@ the following manner:
|
||||||
}
|
}
|
||||||
buf := gopacket.NewSerializeBuffer()
|
buf := gopacket.NewSerializeBuffer()
|
||||||
opts := gopacket.SerializeOptions{} // See SerializeOptions for more details.
|
opts := gopacket.SerializeOptions{} // See SerializeOptions for more details.
|
||||||
err := ip.SerializeTo(&buf, opts)
|
err := ip.SerializeTo(buf, opts)
|
||||||
if err != nil { panic(err) }
|
if err != nil { panic(err) }
|
||||||
fmt.Println(buf.Bytes()) // prints out a byte slice containing the serialized IPv4 layer.
|
fmt.Println(buf.Bytes()) // prints out a byte slice containing the serialized IPv4 layer.
|
||||||
|
|
||||||
|
|
10
vendor/github.com/google/gopacket/gc
generated
vendored
10
vendor/github.com/google/gopacket/gc
generated
vendored
|
@ -106,6 +106,7 @@ if [ ! -z "$GEN" ]; then
|
||||||
popd
|
popd
|
||||||
pushd layers
|
pushd layers
|
||||||
go run gen.go | gofmt > iana_ports.go
|
go run gen.go | gofmt > iana_ports.go
|
||||||
|
go run gen2.go | gofmt > enums_generated.go
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -126,6 +127,9 @@ if [ -f /usr/include/pcap.h ]; then
|
||||||
Root pcap_tester --mode=filtered
|
Root pcap_tester --mode=filtered
|
||||||
Root pcap_tester --mode=timestamp || echo "You might not support timestamp sources"
|
Root pcap_tester --mode=timestamp || echo "You might not support timestamp sources"
|
||||||
popd
|
popd
|
||||||
|
pushd examples/afpacket
|
||||||
|
go build
|
||||||
|
popd
|
||||||
pushd examples/pcapdump
|
pushd examples/pcapdump
|
||||||
go build
|
go build
|
||||||
popd
|
popd
|
||||||
|
@ -182,6 +186,12 @@ if [ -f /usr/include/pfring.h ]; then
|
||||||
go build
|
go build
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
pushd ip4defrag
|
||||||
|
go test ./...
|
||||||
|
popd
|
||||||
|
pushd defrag
|
||||||
|
go test ./...
|
||||||
|
popd
|
||||||
|
|
||||||
for travis_script in `ls .travis.*.sh`; do
|
for travis_script in `ls .travis.*.sh`; do
|
||||||
./$travis_script
|
./$travis_script
|
||||||
|
|
33
vendor/github.com/google/gopacket/layers/.lint_blacklist
generated
vendored
Normal file
33
vendor/github.com/google/gopacket/layers/.lint_blacklist
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
dot11.go
|
||||||
|
eap.go
|
||||||
|
endpoints.go
|
||||||
|
enums_generated.go
|
||||||
|
enums.go
|
||||||
|
ethernet.go
|
||||||
|
geneve.go
|
||||||
|
icmp4.go
|
||||||
|
icmp6.go
|
||||||
|
igmp.go
|
||||||
|
ip4.go
|
||||||
|
ip6.go
|
||||||
|
layertypes.go
|
||||||
|
linux_sll.go
|
||||||
|
llc.go
|
||||||
|
lldp.go
|
||||||
|
mpls.go
|
||||||
|
ndp.go
|
||||||
|
ntp.go
|
||||||
|
ospf.go
|
||||||
|
pflog.go
|
||||||
|
pppoe.go
|
||||||
|
prism.go
|
||||||
|
radiotap.go
|
||||||
|
rudp.go
|
||||||
|
sctp.go
|
||||||
|
sflow.go
|
||||||
|
tcp.go
|
||||||
|
tcpip.go
|
||||||
|
udp.go
|
||||||
|
udplite.go
|
||||||
|
usb.go
|
||||||
|
vrrp.go
|
40
vendor/github.com/google/gopacket/layers/.linted
generated
vendored
40
vendor/github.com/google/gopacket/layers/.linted
generated
vendored
|
@ -1,40 +0,0 @@
|
||||||
arp.go
|
|
||||||
base.go
|
|
||||||
base_test.go
|
|
||||||
cdp.go
|
|
||||||
ctp.go
|
|
||||||
decode_test.go
|
|
||||||
dhcp_test.go
|
|
||||||
dhcpv4.go
|
|
||||||
dns.go
|
|
||||||
dns_test.go
|
|
||||||
doc.go
|
|
||||||
dot11_test.go
|
|
||||||
dot1q.go
|
|
||||||
dot1q_test.go
|
|
||||||
eapol.go
|
|
||||||
etherip.go
|
|
||||||
fddi.go
|
|
||||||
gen.go
|
|
||||||
gre.go
|
|
||||||
gre_test.go
|
|
||||||
iana_ports.go
|
|
||||||
icmp6_test.go
|
|
||||||
igmp_test.go
|
|
||||||
ip4_test.go
|
|
||||||
ipsec.go
|
|
||||||
ipsec_test.go
|
|
||||||
loopback.go
|
|
||||||
mpls_test.go
|
|
||||||
ntp_test.go
|
|
||||||
ports.go
|
|
||||||
ppp.go
|
|
||||||
prism_test.go
|
|
||||||
radiotap_test.go
|
|
||||||
sflow_test.go
|
|
||||||
tcp_test.go
|
|
||||||
udp_test.go
|
|
||||||
usb_test.go
|
|
||||||
vrrp_test.go
|
|
||||||
vxlan.go
|
|
||||||
vxlan_test.go
|
|
481
vendor/github.com/google/gopacket/layers/bfd.go
generated
vendored
Normal file
481
vendor/github.com/google/gopacket/layers/bfd.go
generated
vendored
Normal file
|
@ -0,0 +1,481 @@
|
||||||
|
// Copyright 2017 Google, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style license
|
||||||
|
// that can be found in the LICENSE file in the root of the source
|
||||||
|
// tree.
|
||||||
|
//
|
||||||
|
|
||||||
|
package layers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/binary"
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/google/gopacket"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BFD Control Packet Format
|
||||||
|
// -------------------------
|
||||||
|
// The current version of BFD's RFC (RFC 5880) contains the following
|
||||||
|
// diagram for the BFD Control packet format:
|
||||||
|
//
|
||||||
|
// 0 1 2 3
|
||||||
|
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
// |Vers | Diag |Sta|P|F|C|A|D|M| Detect Mult | Length |
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
// | My Discriminator |
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
// | Your Discriminator |
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
// | Desired Min TX Interval |
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
// | Required Min RX Interval |
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
// | Required Min Echo RX Interval |
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
//
|
||||||
|
// An optional Authentication Section MAY be present:
|
||||||
|
//
|
||||||
|
// 0 1 2 3
|
||||||
|
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
// | Auth Type | Auth Len | Authentication Data... |
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Simple Password Authentication Section Format
|
||||||
|
// ---------------------------------------------
|
||||||
|
// 0 1 2 3
|
||||||
|
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
// | Auth Type | Auth Len | Auth Key ID | Password... |
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
// | ... |
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Keyed MD5 and Meticulous Keyed MD5 Authentication Section Format
|
||||||
|
// ----------------------------------------------------------------
|
||||||
|
// 0 1 2 3
|
||||||
|
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
// | Auth Type | Auth Len | Auth Key ID | Reserved |
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
// | Sequence Number |
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
// | Auth Key/Digest... |
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
// | ... |
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Keyed SHA1 and Meticulous Keyed SHA1 Authentication Section Format
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// 0 1 2 3
|
||||||
|
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
// | Auth Type | Auth Len | Auth Key ID | Reserved |
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
// | Sequence Number |
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
// | Auth Key/Hash... |
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
// | ... |
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
//
|
||||||
|
// From https://tools.ietf.org/rfc/rfc5880.txt
|
||||||
|
const bfdMinimumRecordSizeInBytes int = 24
|
||||||
|
|
||||||
|
// BFDVersion represents the version as decoded from the BFD control message
|
||||||
|
type BFDVersion uint8
|
||||||
|
|
||||||
|
// BFDDiagnostic represents diagnostic infomation about a BFD session
|
||||||
|
type BFDDiagnostic uint8
|
||||||
|
|
||||||
|
// constants that define BFDDiagnostic flags
|
||||||
|
const (
|
||||||
|
BFDDiagnosticNone BFDDiagnostic = 0 // No Diagnostic
|
||||||
|
BFDDiagnosticTimeExpired BFDDiagnostic = 1 // Control Detection Time Expired
|
||||||
|
BFDDiagnosticEchoFailed BFDDiagnostic = 2 // Echo Function Failed
|
||||||
|
BFDDiagnosticNeighborSignalDown BFDDiagnostic = 3 // Neighbor Signaled Session Down
|
||||||
|
BFDDiagnosticForwardPlaneReset BFDDiagnostic = 4 // Forwarding Plane Reset
|
||||||
|
BFDDiagnosticPathDown BFDDiagnostic = 5 // Path Down
|
||||||
|
BFDDiagnosticConcatPathDown BFDDiagnostic = 6 // Concatenated Path Down
|
||||||
|
BFDDiagnosticAdminDown BFDDiagnostic = 7 // Administratively Down
|
||||||
|
BFDDiagnosticRevConcatPathDown BFDDiagnostic = 8 // Reverse Concatenated Path Dow
|
||||||
|
)
|
||||||
|
|
||||||
|
// String returns a string version of BFDDiagnostic
|
||||||
|
func (bd BFDDiagnostic) String() string {
|
||||||
|
switch bd {
|
||||||
|
default:
|
||||||
|
return "Unknown"
|
||||||
|
case BFDDiagnosticNone:
|
||||||
|
return "None"
|
||||||
|
case BFDDiagnosticTimeExpired:
|
||||||
|
return "Control Detection Time Expired"
|
||||||
|
case BFDDiagnosticEchoFailed:
|
||||||
|
return "Echo Function Failed"
|
||||||
|
case BFDDiagnosticNeighborSignalDown:
|
||||||
|
return "Neighbor Signaled Session Down"
|
||||||
|
case BFDDiagnosticForwardPlaneReset:
|
||||||
|
return "Forwarding Plane Reset"
|
||||||
|
case BFDDiagnosticPathDown:
|
||||||
|
return "Path Down"
|
||||||
|
case BFDDiagnosticConcatPathDown:
|
||||||
|
return "Concatenated Path Down"
|
||||||
|
case BFDDiagnosticAdminDown:
|
||||||
|
return "Administratively Down"
|
||||||
|
case BFDDiagnosticRevConcatPathDown:
|
||||||
|
return "Reverse Concatenated Path Down"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// BFDState represents the state of a BFD session
|
||||||
|
type BFDState uint8
|
||||||
|
|
||||||
|
// constants that define BFDState
|
||||||
|
const (
|
||||||
|
BFDStateAdminDown BFDState = 0
|
||||||
|
BFDStateDown BFDState = 1
|
||||||
|
BFDStateInit BFDState = 2
|
||||||
|
BFDStateUp BFDState = 3
|
||||||
|
)
|
||||||
|
|
||||||
|
// String returns a string version of BFDState
|
||||||
|
func (s BFDState) String() string {
|
||||||
|
switch s {
|
||||||
|
default:
|
||||||
|
return "Unknown"
|
||||||
|
case BFDStateAdminDown:
|
||||||
|
return "Admin Down"
|
||||||
|
case BFDStateDown:
|
||||||
|
return "Down"
|
||||||
|
case BFDStateInit:
|
||||||
|
return "Init"
|
||||||
|
case BFDStateUp:
|
||||||
|
return "Up"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// BFDDetectMultiplier represents the negotiated transmit interval,
|
||||||
|
// multiplied by this value, provides the Detection Time for the
|
||||||
|
// receiving system in Asynchronous mode.
|
||||||
|
type BFDDetectMultiplier uint8
|
||||||
|
|
||||||
|
// BFDDiscriminator is a unique, nonzero discriminator value used
|
||||||
|
// to demultiplex multiple BFD sessions between the same pair of systems.
|
||||||
|
type BFDDiscriminator uint32
|
||||||
|
|
||||||
|
// BFDTimeInterval represents a time interval in microseconds
|
||||||
|
type BFDTimeInterval uint32
|
||||||
|
|
||||||
|
// BFDAuthType represents the authentication used in the BFD session
|
||||||
|
type BFDAuthType uint8
|
||||||
|
|
||||||
|
// constants that define the BFDAuthType
|
||||||
|
const (
|
||||||
|
BFDAuthTypeNone BFDAuthType = 0 // No Auth
|
||||||
|
BFDAuthTypePassword BFDAuthType = 1 // Simple Password
|
||||||
|
BFDAuthTypeKeyedMD5 BFDAuthType = 2 // Keyed MD5
|
||||||
|
BFDAuthTypeMeticulousKeyedMD5 BFDAuthType = 3 // Meticulous Keyed MD5
|
||||||
|
BFDAuthTypeKeyedSHA1 BFDAuthType = 4 // Keyed SHA1
|
||||||
|
BFDAuthTypeMeticulousKeyedSHA1 BFDAuthType = 5 // Meticulous Keyed SHA1
|
||||||
|
)
|
||||||
|
|
||||||
|
// String returns a string version of BFDAuthType
|
||||||
|
func (at BFDAuthType) String() string {
|
||||||
|
switch at {
|
||||||
|
default:
|
||||||
|
return "Unknown"
|
||||||
|
case BFDAuthTypeNone:
|
||||||
|
return "No Authentication"
|
||||||
|
case BFDAuthTypePassword:
|
||||||
|
return "Simple Password"
|
||||||
|
case BFDAuthTypeKeyedMD5:
|
||||||
|
return "Keyed MD5"
|
||||||
|
case BFDAuthTypeMeticulousKeyedMD5:
|
||||||
|
return "Meticulous Keyed MD5"
|
||||||
|
case BFDAuthTypeKeyedSHA1:
|
||||||
|
return "Keyed SHA1"
|
||||||
|
case BFDAuthTypeMeticulousKeyedSHA1:
|
||||||
|
return "Meticulous Keyed SHA1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// BFDAuthKeyID represents the authentication key ID in use for
|
||||||
|
// this packet. This allows multiple keys to be active simultaneously.
|
||||||
|
type BFDAuthKeyID uint8
|
||||||
|
|
||||||
|
// BFDAuthSequenceNumber represents the sequence number for this packet.
|
||||||
|
// For Keyed Authentication, this value is incremented occasionally. For
|
||||||
|
// Meticulous Keyed Authentication, this value is incremented for each
|
||||||
|
// successive packet transmitted for a session. This provides protection
|
||||||
|
// against replay attacks.
|
||||||
|
type BFDAuthSequenceNumber uint32
|
||||||
|
|
||||||
|
// BFDAuthData represents the authentication key or digest
|
||||||
|
type BFDAuthData []byte
|
||||||
|
|
||||||
|
// BFDAuthHeader represents authentication data used in the BFD session
|
||||||
|
type BFDAuthHeader struct {
|
||||||
|
AuthType BFDAuthType
|
||||||
|
KeyID BFDAuthKeyID
|
||||||
|
SequenceNumber BFDAuthSequenceNumber
|
||||||
|
Data BFDAuthData
|
||||||
|
}
|
||||||
|
|
||||||
|
// Length returns the data length of the BFDAuthHeader based on the
|
||||||
|
// authentication type
|
||||||
|
func (h *BFDAuthHeader) Length() int {
|
||||||
|
switch h.AuthType {
|
||||||
|
case BFDAuthTypePassword:
|
||||||
|
return 3 + len(h.Data)
|
||||||
|
case BFDAuthTypeKeyedMD5, BFDAuthTypeMeticulousKeyedMD5:
|
||||||
|
return 8 + len(h.Data)
|
||||||
|
case BFDAuthTypeKeyedSHA1, BFDAuthTypeMeticulousKeyedSHA1:
|
||||||
|
return 8 + len(h.Data)
|
||||||
|
default:
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// BFD represents a BFD control message packet whose payload contains
|
||||||
|
// the control information required to for a BFD session.
|
||||||
|
//
|
||||||
|
// References
|
||||||
|
// ----------
|
||||||
|
//
|
||||||
|
// Wikipedia's BFD entry:
|
||||||
|
// https://en.wikipedia.org/wiki/Bidirectional_Forwarding_Detection
|
||||||
|
// This is the best place to get an overview of BFD.
|
||||||
|
//
|
||||||
|
// RFC 5880 "Bidirectional Forwarding Detection (BFD)" (2010)
|
||||||
|
// https://tools.ietf.org/html/rfc5880
|
||||||
|
// This is the original BFD specification.
|
||||||
|
//
|
||||||
|
// RFC 5881 "Bidirectional Forwarding Detection (BFD) for IPv4 and IPv6 (Single Hop)" (2010)
|
||||||
|
// https://tools.ietf.org/html/rfc5881
|
||||||
|
// Describes the use of the Bidirectional Forwarding Detection (BFD)
|
||||||
|
// protocol over IPv4 and IPv6 for single IP hops.
|
||||||
|
type BFD struct {
|
||||||
|
BaseLayer // Stores the packet bytes and payload bytes.
|
||||||
|
|
||||||
|
Version BFDVersion // Version of the BFD protocol.
|
||||||
|
Diagnostic BFDDiagnostic // Diagnostic code for last state change
|
||||||
|
State BFDState // Current state
|
||||||
|
Poll bool // Requesting verification
|
||||||
|
Final bool // Responding to a received BFD Control packet that had the Poll (P) bit set.
|
||||||
|
ControlPlaneIndependent bool // BFD implementation does not share fate with its control plane
|
||||||
|
AuthPresent bool // Authentication Section is present and the session is to be authenticated
|
||||||
|
Demand bool // Demand mode is active
|
||||||
|
Multipoint bool // For future point-to-multipoint extensions. Must always be zero
|
||||||
|
DetectMultiplier BFDDetectMultiplier // Detection time multiplier
|
||||||
|
MyDiscriminator BFDDiscriminator // A unique, nonzero discriminator value
|
||||||
|
YourDiscriminator BFDDiscriminator // discriminator received from the remote system.
|
||||||
|
DesiredMinTxInterval BFDTimeInterval // Minimum interval, in microseconds, the local system would like to use when transmitting BFD Control packets
|
||||||
|
RequiredMinRxInterval BFDTimeInterval // Minimum interval, in microseconds, between received BFD Control packets that this system is capable of supporting
|
||||||
|
RequiredMinEchoRxInterval BFDTimeInterval // Minimum interval, in microseconds, between received BFD Echo packets that this system is capable of supporting
|
||||||
|
AuthHeader *BFDAuthHeader // Authentication data, variable length.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Length returns the data length of a BFD Control message which
|
||||||
|
// changes based on the presence and type of authentication
|
||||||
|
// contained in the message
|
||||||
|
func (d *BFD) Length() int {
|
||||||
|
if d.AuthPresent && (d.AuthHeader != nil) {
|
||||||
|
return bfdMinimumRecordSizeInBytes + d.AuthHeader.Length()
|
||||||
|
}
|
||||||
|
|
||||||
|
return bfdMinimumRecordSizeInBytes
|
||||||
|
}
|
||||||
|
|
||||||
|
// LayerType returns the layer type of the BFD object, which is LayerTypeBFD.
|
||||||
|
func (d *BFD) LayerType() gopacket.LayerType {
|
||||||
|
return LayerTypeBFD
|
||||||
|
}
|
||||||
|
|
||||||
|
// decodeBFD analyses a byte slice and attempts to decode it as a BFD
|
||||||
|
// control packet
|
||||||
|
//
|
||||||
|
// If it succeeds, it loads p with information about the packet and returns nil.
|
||||||
|
// If it fails, it returns an error (non nil).
|
||||||
|
//
|
||||||
|
// This function is employed in layertypes.go to register the BFD layer.
|
||||||
|
func decodeBFD(data []byte, p gopacket.PacketBuilder) error {
|
||||||
|
|
||||||
|
// Attempt to decode the byte slice.
|
||||||
|
d := &BFD{}
|
||||||
|
err := d.DecodeFromBytes(data, p)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the decoding worked, add the layer to the packet and set it
|
||||||
|
// as the application layer too, if there isn't already one.
|
||||||
|
p.AddLayer(d)
|
||||||
|
p.SetApplicationLayer(d)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DecodeFromBytes analyses a byte slice and attempts to decode it as a BFD
|
||||||
|
// control packet.
|
||||||
|
//
|
||||||
|
// Upon succeeds, it loads the BFD object with information about the packet
|
||||||
|
// and returns nil.
|
||||||
|
// Upon failure, it returns an error (non nil).
|
||||||
|
func (d *BFD) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
|
||||||
|
|
||||||
|
// If the data block is too short to be a BFD record, then return an error.
|
||||||
|
if len(data) < bfdMinimumRecordSizeInBytes {
|
||||||
|
df.SetTruncated()
|
||||||
|
return errors.New("BFD packet too short")
|
||||||
|
}
|
||||||
|
|
||||||
|
pLen := uint8(data[3])
|
||||||
|
if len(data) != int(pLen) {
|
||||||
|
return errors.New("BFD packet length does not match")
|
||||||
|
}
|
||||||
|
|
||||||
|
// BFD type embeds type BaseLayer which contains two fields:
|
||||||
|
// Contents is supposed to contain the bytes of the data at this level.
|
||||||
|
// Payload is supposed to contain the payload of this level.
|
||||||
|
// Here we set the baselayer to be the bytes of the BFD record.
|
||||||
|
d.BaseLayer = BaseLayer{Contents: data[:len(data)]}
|
||||||
|
|
||||||
|
// Extract the fields from the block of bytes.
|
||||||
|
// To make sense of this, refer to the packet diagram
|
||||||
|
// above and the section on endian conventions.
|
||||||
|
|
||||||
|
// The first few fields are all packed into the first 32 bits. Unpack them.
|
||||||
|
d.Version = BFDVersion(((data[0] & 0xE0) >> 5))
|
||||||
|
d.Diagnostic = BFDDiagnostic(data[0] & 0x1F)
|
||||||
|
data = data[1:]
|
||||||
|
|
||||||
|
d.State = BFDState((data[0] & 0xC0) >> 6)
|
||||||
|
d.Poll = data[0]&0x20 != 0
|
||||||
|
d.Final = data[0]&0x10 != 0
|
||||||
|
d.ControlPlaneIndependent = data[0]&0x08 != 0
|
||||||
|
d.AuthPresent = data[0]&0x04 != 0
|
||||||
|
d.Demand = data[0]&0x02 != 0
|
||||||
|
d.Multipoint = data[0]&0x01 != 0
|
||||||
|
data = data[1:]
|
||||||
|
|
||||||
|
data, d.DetectMultiplier = data[1:], BFDDetectMultiplier(data[0])
|
||||||
|
data, _ = data[1:], uint8(data[0]) // Consume length
|
||||||
|
|
||||||
|
// The remaining fields can just be copied in big endian order.
|
||||||
|
data, d.MyDiscriminator = data[4:], BFDDiscriminator(binary.BigEndian.Uint32(data[:4]))
|
||||||
|
data, d.YourDiscriminator = data[4:], BFDDiscriminator(binary.BigEndian.Uint32(data[:4]))
|
||||||
|
data, d.DesiredMinTxInterval = data[4:], BFDTimeInterval(binary.BigEndian.Uint32(data[:4]))
|
||||||
|
data, d.RequiredMinRxInterval = data[4:], BFDTimeInterval(binary.BigEndian.Uint32(data[:4]))
|
||||||
|
data, d.RequiredMinEchoRxInterval = data[4:], BFDTimeInterval(binary.BigEndian.Uint32(data[:4]))
|
||||||
|
|
||||||
|
if d.AuthPresent && (len(data) > 2) {
|
||||||
|
d.AuthHeader = &BFDAuthHeader{}
|
||||||
|
data, d.AuthHeader.AuthType = data[1:], BFDAuthType(data[0])
|
||||||
|
data, _ = data[1:], uint8(data[0]) // Consume length
|
||||||
|
data, d.AuthHeader.KeyID = data[1:], BFDAuthKeyID(data[0])
|
||||||
|
|
||||||
|
switch d.AuthHeader.AuthType {
|
||||||
|
case BFDAuthTypePassword:
|
||||||
|
d.AuthHeader.Data = BFDAuthData(data)
|
||||||
|
case BFDAuthTypeKeyedMD5, BFDAuthTypeMeticulousKeyedMD5:
|
||||||
|
// Skipped reserved byte
|
||||||
|
data, d.AuthHeader.SequenceNumber = data[5:], BFDAuthSequenceNumber(binary.BigEndian.Uint32(data[1:5]))
|
||||||
|
d.AuthHeader.Data = BFDAuthData(data)
|
||||||
|
case BFDAuthTypeKeyedSHA1, BFDAuthTypeMeticulousKeyedSHA1:
|
||||||
|
// Skipped reserved byte
|
||||||
|
data, d.AuthHeader.SequenceNumber = data[5:], BFDAuthSequenceNumber(binary.BigEndian.Uint32(data[1:5]))
|
||||||
|
d.AuthHeader.Data = BFDAuthData(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SerializeTo writes the serialized form of this layer into the
|
||||||
|
// SerializationBuffer, implementing gopacket.SerializableLayer.
|
||||||
|
// See the docs for gopacket.SerializableLayer for more info.
|
||||||
|
func (d *BFD) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
|
||||||
|
data, err := b.PrependBytes(bfdMinimumRecordSizeInBytes)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pack the first few fields into the first 32 bits.
|
||||||
|
data[0] = byte(byte(d.Version<<5) | byte(d.Diagnostic))
|
||||||
|
h := uint8(0)
|
||||||
|
h |= (uint8(d.State) << 6)
|
||||||
|
h |= (uint8(bool2uint8(d.Poll)) << 5)
|
||||||
|
h |= (uint8(bool2uint8(d.Final)) << 4)
|
||||||
|
h |= (uint8(bool2uint8(d.ControlPlaneIndependent)) << 3)
|
||||||
|
h |= (uint8(bool2uint8(d.AuthPresent)) << 2)
|
||||||
|
h |= (uint8(bool2uint8(d.Demand)) << 1)
|
||||||
|
h |= uint8(bool2uint8(d.Multipoint))
|
||||||
|
data[1] = byte(h)
|
||||||
|
data[2] = byte(d.DetectMultiplier)
|
||||||
|
data[3] = byte(d.Length())
|
||||||
|
|
||||||
|
// The remaining fields can just be copied in big endian order.
|
||||||
|
binary.BigEndian.PutUint32(data[4:], uint32(d.MyDiscriminator))
|
||||||
|
binary.BigEndian.PutUint32(data[8:], uint32(d.YourDiscriminator))
|
||||||
|
binary.BigEndian.PutUint32(data[12:], uint32(d.DesiredMinTxInterval))
|
||||||
|
binary.BigEndian.PutUint32(data[16:], uint32(d.RequiredMinRxInterval))
|
||||||
|
binary.BigEndian.PutUint32(data[20:], uint32(d.RequiredMinEchoRxInterval))
|
||||||
|
|
||||||
|
if d.AuthPresent && (d.AuthHeader != nil) {
|
||||||
|
auth, err := b.AppendBytes(int(d.AuthHeader.Length()))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
auth[0] = byte(d.AuthHeader.AuthType)
|
||||||
|
auth[1] = byte(d.AuthHeader.Length())
|
||||||
|
auth[2] = byte(d.AuthHeader.KeyID)
|
||||||
|
|
||||||
|
switch d.AuthHeader.AuthType {
|
||||||
|
case BFDAuthTypePassword:
|
||||||
|
copy(auth[3:], d.AuthHeader.Data)
|
||||||
|
case BFDAuthTypeKeyedMD5, BFDAuthTypeMeticulousKeyedMD5:
|
||||||
|
auth[3] = byte(0)
|
||||||
|
binary.BigEndian.PutUint32(auth[4:], uint32(d.AuthHeader.SequenceNumber))
|
||||||
|
copy(auth[8:], d.AuthHeader.Data)
|
||||||
|
case BFDAuthTypeKeyedSHA1, BFDAuthTypeMeticulousKeyedSHA1:
|
||||||
|
auth[3] = byte(0)
|
||||||
|
binary.BigEndian.PutUint32(auth[4:], uint32(d.AuthHeader.SequenceNumber))
|
||||||
|
copy(auth[8:], d.AuthHeader.Data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CanDecode returns a set of layers that BFD objects can decode.
|
||||||
|
// As BFD objects can only decide the BFD layer, we can return just that layer.
|
||||||
|
// Apparently a single layer type implements LayerClass.
|
||||||
|
func (d *BFD) CanDecode() gopacket.LayerClass {
|
||||||
|
return LayerTypeBFD
|
||||||
|
}
|
||||||
|
|
||||||
|
// NextLayerType specifies the next layer that GoPacket should attempt to
|
||||||
|
// analyse after this (BFD) layer. As BFD packets do not contain any payload
|
||||||
|
// bytes, there are no further layers to analyse.
|
||||||
|
func (d *BFD) NextLayerType() gopacket.LayerType {
|
||||||
|
return gopacket.LayerTypeZero
|
||||||
|
}
|
||||||
|
|
||||||
|
// Payload returns an empty byte slice as BFD packets do not carry a payload
|
||||||
|
func (d *BFD) Payload() []byte {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// bool2uint8 converts a bool to uint8
|
||||||
|
func bool2uint8(b bool) uint8 {
|
||||||
|
if b {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
36
vendor/github.com/google/gopacket/layers/dhcpv4.go
generated
vendored
36
vendor/github.com/google/gopacket/layers/dhcpv4.go
generated
vendored
|
@ -9,7 +9,6 @@ package layers
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
|
@ -125,6 +124,7 @@ func (d *DHCPv4) LayerType() gopacket.LayerType { return LayerTypeDHCPv4 }
|
||||||
|
|
||||||
// DecodeFromBytes decodes the given bytes into this layer.
|
// DecodeFromBytes decodes the given bytes into this layer.
|
||||||
func (d *DHCPv4) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
|
func (d *DHCPv4) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
|
||||||
|
d.Options = d.Options[:0]
|
||||||
d.Operation = DHCPOp(data[0])
|
d.Operation = DHCPOp(data[0])
|
||||||
d.HardwareType = LinkType(data[1])
|
d.HardwareType = LinkType(data[1])
|
||||||
d.HardwareLen = data[2]
|
d.HardwareLen = data[2]
|
||||||
|
@ -140,7 +140,7 @@ func (d *DHCPv4) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error
|
||||||
d.ServerName = data[44:108]
|
d.ServerName = data[44:108]
|
||||||
d.File = data[108:236]
|
d.File = data[108:236]
|
||||||
if binary.BigEndian.Uint32(data[236:240]) != DHCPMagic {
|
if binary.BigEndian.Uint32(data[236:240]) != DHCPMagic {
|
||||||
return errors.New("Bad DHCP header")
|
return InvalidMagicCookie
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(data) <= 240 {
|
if len(data) <= 240 {
|
||||||
|
@ -538,9 +538,6 @@ func (o *DHCPOption) encode(b []byte) error {
|
||||||
case DHCPOptPad, DHCPOptEnd:
|
case DHCPOptPad, DHCPOptEnd:
|
||||||
b[0] = byte(o.Type)
|
b[0] = byte(o.Type)
|
||||||
default:
|
default:
|
||||||
if o.Length > 253 {
|
|
||||||
return errors.New("data too long to encode")
|
|
||||||
}
|
|
||||||
b[0] = byte(o.Type)
|
b[0] = byte(o.Type)
|
||||||
b[1] = o.Length
|
b[1] = o.Length
|
||||||
copy(b[2:], o.Data)
|
copy(b[2:], o.Data)
|
||||||
|
@ -551,21 +548,38 @@ func (o *DHCPOption) encode(b []byte) error {
|
||||||
func (o *DHCPOption) decode(data []byte) error {
|
func (o *DHCPOption) decode(data []byte) error {
|
||||||
if len(data) < 1 {
|
if len(data) < 1 {
|
||||||
// Pad/End have a length of 1
|
// Pad/End have a length of 1
|
||||||
return errors.New("Not enough data to decode")
|
return DecOptionNotEnoughData
|
||||||
}
|
}
|
||||||
o.Type = DHCPOpt(data[0])
|
o.Type = DHCPOpt(data[0])
|
||||||
switch o.Type {
|
switch o.Type {
|
||||||
case DHCPOptPad, DHCPOptEnd:
|
case DHCPOptPad, DHCPOptEnd:
|
||||||
o.Data = nil
|
o.Data = nil
|
||||||
default:
|
default:
|
||||||
if len(data) < 3 {
|
if len(data) < 2 {
|
||||||
return errors.New("Not enough data to decode")
|
return DecOptionNotEnoughData
|
||||||
}
|
}
|
||||||
o.Length = data[1]
|
o.Length = data[1]
|
||||||
if o.Length > 253 {
|
if int(o.Length) > len(data[2:]) {
|
||||||
return errors.New("data too long to decode")
|
return DecOptionMalformed
|
||||||
}
|
}
|
||||||
o.Data = data[2 : 2+o.Length]
|
o.Data = data[2 : 2+int(o.Length)]
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DHCPv4Error is used for constant errors for DHCPv4. It is needed for test asserts.
|
||||||
|
type DHCPv4Error string
|
||||||
|
|
||||||
|
// DHCPv4Error implements error interface.
|
||||||
|
func (d DHCPv4Error) Error() string {
|
||||||
|
return string(d)
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
// DecOptionNotEnoughData is returned when there is not enough data during option's decode process
|
||||||
|
DecOptionNotEnoughData = DHCPv4Error("Not enough data to decode")
|
||||||
|
// DecOptionMalformed is returned when the option is malformed
|
||||||
|
DecOptionMalformed = DHCPv4Error("Option is malformed")
|
||||||
|
// InvalidMagicCookie is returned when Magic cookie is missing into BOOTP header
|
||||||
|
InvalidMagicCookie = DHCPv4Error("Bad DHCP header")
|
||||||
|
)
|
||||||
|
|
495
vendor/github.com/google/gopacket/layers/dhcpv6.go
generated
vendored
Normal file
495
vendor/github.com/google/gopacket/layers/dhcpv6.go
generated
vendored
Normal file
|
@ -0,0 +1,495 @@
|
||||||
|
// Copyright 2018 Google, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style license
|
||||||
|
// that can be found in the LICENSE file in the root of the source
|
||||||
|
// tree.
|
||||||
|
|
||||||
|
package layers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/binary"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"net"
|
||||||
|
|
||||||
|
"github.com/google/gopacket"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DHCPv6MsgType represents a DHCPv6 operation
|
||||||
|
type DHCPv6MsgType byte
|
||||||
|
|
||||||
|
// Constants that represent DHCP operations
|
||||||
|
const (
|
||||||
|
DHCPv6MsgTypeUnspecified DHCPv6MsgType = iota
|
||||||
|
DHCPv6MsgTypeSolicit
|
||||||
|
DHCPv6MsgTypeAdverstise
|
||||||
|
DHCPv6MsgTypeRequest
|
||||||
|
DHCPv6MsgTypeConfirm
|
||||||
|
DHCPv6MsgTypeRenew
|
||||||
|
DHCPv6MsgTypeRebind
|
||||||
|
DHCPv6MsgTypeReply
|
||||||
|
DHCPv6MsgTypeRelease
|
||||||
|
DHCPv6MsgTypeDecline
|
||||||
|
DHCPv6MsgTypeReconfigure
|
||||||
|
DHCPv6MsgTypeInformationRequest
|
||||||
|
DHCPv6MsgTypeRelayForward
|
||||||
|
DHCPv6MsgTypeRelayReply
|
||||||
|
)
|
||||||
|
|
||||||
|
// String returns a string version of a DHCPv6MsgType.
|
||||||
|
func (o DHCPv6MsgType) String() string {
|
||||||
|
switch o {
|
||||||
|
case DHCPv6MsgTypeUnspecified:
|
||||||
|
return "Unspecified"
|
||||||
|
case DHCPv6MsgTypeSolicit:
|
||||||
|
return "Solicit"
|
||||||
|
case DHCPv6MsgTypeAdverstise:
|
||||||
|
return "Adverstise"
|
||||||
|
case DHCPv6MsgTypeRequest:
|
||||||
|
return "Request"
|
||||||
|
case DHCPv6MsgTypeConfirm:
|
||||||
|
return "Confirm"
|
||||||
|
case DHCPv6MsgTypeRenew:
|
||||||
|
return "Renew"
|
||||||
|
case DHCPv6MsgTypeRebind:
|
||||||
|
return "Rebind"
|
||||||
|
case DHCPv6MsgTypeReply:
|
||||||
|
return "Reply"
|
||||||
|
case DHCPv6MsgTypeRelease:
|
||||||
|
return "Release"
|
||||||
|
case DHCPv6MsgTypeDecline:
|
||||||
|
return "Decline"
|
||||||
|
case DHCPv6MsgTypeReconfigure:
|
||||||
|
return "Reconfigure"
|
||||||
|
case DHCPv6MsgTypeInformationRequest:
|
||||||
|
return "InformationRequest"
|
||||||
|
case DHCPv6MsgTypeRelayForward:
|
||||||
|
return "RelayForward"
|
||||||
|
case DHCPv6MsgTypeRelayReply:
|
||||||
|
return "RelayReply"
|
||||||
|
default:
|
||||||
|
return "Unknown"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DHCPv6 contains data for a single DHCP packet.
|
||||||
|
type DHCPv6 struct {
|
||||||
|
BaseLayer
|
||||||
|
MsgType DHCPv6MsgType
|
||||||
|
HopCount uint8
|
||||||
|
LinkAddr net.IP
|
||||||
|
PeerAddr net.IP
|
||||||
|
TransactionID []byte
|
||||||
|
Options DHCPv6Options
|
||||||
|
}
|
||||||
|
|
||||||
|
// LayerType returns gopacket.LayerTypeDHCPv6
|
||||||
|
func (d *DHCPv6) LayerType() gopacket.LayerType { return LayerTypeDHCPv6 }
|
||||||
|
|
||||||
|
// DecodeFromBytes decodes the given bytes into this layer.
|
||||||
|
func (d *DHCPv6) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
|
||||||
|
d.BaseLayer = BaseLayer{Contents: data}
|
||||||
|
d.Options = d.Options[:0]
|
||||||
|
d.MsgType = DHCPv6MsgType(data[0])
|
||||||
|
|
||||||
|
offset := 0
|
||||||
|
if d.MsgType == DHCPv6MsgTypeRelayForward || d.MsgType == DHCPv6MsgTypeRelayReply {
|
||||||
|
d.HopCount = data[1]
|
||||||
|
d.LinkAddr = net.IP(data[2:18])
|
||||||
|
d.PeerAddr = net.IP(data[18:34])
|
||||||
|
offset = 34
|
||||||
|
} else {
|
||||||
|
d.TransactionID = data[1:4]
|
||||||
|
offset = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
stop := len(data)
|
||||||
|
for offset < stop {
|
||||||
|
o := DHCPv6Option{}
|
||||||
|
if err := o.decode(data[offset:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
d.Options = append(d.Options, o)
|
||||||
|
offset += int(o.Length) + 4 // 2 from option code, 2 from option length
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Len returns the length of a DHCPv6 packet.
|
||||||
|
func (d *DHCPv6) Len() int {
|
||||||
|
n := 1
|
||||||
|
if d.MsgType == DHCPv6MsgTypeRelayForward || d.MsgType == DHCPv6MsgTypeRelayReply {
|
||||||
|
n += 33
|
||||||
|
} else {
|
||||||
|
n += 3
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, o := range d.Options {
|
||||||
|
n += int(o.Length) + 4 // 2 from option code, 2 from option length
|
||||||
|
}
|
||||||
|
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
// SerializeTo writes the serialized form of this layer into the
|
||||||
|
// SerializationBuffer, implementing gopacket.SerializableLayer.
|
||||||
|
// See the docs for gopacket.SerializableLayer for more info.
|
||||||
|
func (d *DHCPv6) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
|
||||||
|
plen := int(d.Len())
|
||||||
|
|
||||||
|
data, err := b.PrependBytes(plen)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
offset := 0
|
||||||
|
data[0] = byte(d.MsgType)
|
||||||
|
if d.MsgType == DHCPv6MsgTypeRelayForward || d.MsgType == DHCPv6MsgTypeRelayReply {
|
||||||
|
data[1] = byte(d.HopCount)
|
||||||
|
copy(data[2:18], d.LinkAddr.To16())
|
||||||
|
copy(data[18:34], d.PeerAddr.To16())
|
||||||
|
offset = 34
|
||||||
|
} else {
|
||||||
|
copy(data[1:4], d.TransactionID)
|
||||||
|
offset = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(d.Options) > 0 {
|
||||||
|
for _, o := range d.Options {
|
||||||
|
if err := o.encode(data[offset:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
offset += int(o.Length) + 4 // 2 from option code, 2 from option length
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CanDecode returns the set of layer types that this DecodingLayer can decode.
|
||||||
|
func (d *DHCPv6) CanDecode() gopacket.LayerClass {
|
||||||
|
return LayerTypeDHCPv6
|
||||||
|
}
|
||||||
|
|
||||||
|
// NextLayerType returns the layer type contained by this DecodingLayer.
|
||||||
|
func (d *DHCPv6) NextLayerType() gopacket.LayerType {
|
||||||
|
return gopacket.LayerTypePayload
|
||||||
|
}
|
||||||
|
|
||||||
|
func decodeDHCPv6(data []byte, p gopacket.PacketBuilder) error {
|
||||||
|
dhcp := &DHCPv6{}
|
||||||
|
err := dhcp.DecodeFromBytes(data, p)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
p.AddLayer(dhcp)
|
||||||
|
return p.NextDecoder(gopacket.LayerTypePayload)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DHCPv6StatusCode represents a DHCP status code - RFC-3315
|
||||||
|
type DHCPv6StatusCode byte
|
||||||
|
|
||||||
|
// Constants for the DHCPv6StatusCode.
|
||||||
|
const (
|
||||||
|
DHCPv6StatusCodeSuccess DHCPv6StatusCode = iota
|
||||||
|
DHCPv6StatusCodeUnspecFail
|
||||||
|
DHCPv6StatusCodeNoAddrsAvail
|
||||||
|
DHCPv6StatusCodeNoBinding
|
||||||
|
DHCPv6StatusCodeNotOnLink
|
||||||
|
DHCPv6StatusCodeUseMulticast
|
||||||
|
)
|
||||||
|
|
||||||
|
// String returns a string version of a DHCPv6StatusCode.
|
||||||
|
func (o DHCPv6StatusCode) String() string {
|
||||||
|
switch o {
|
||||||
|
case DHCPv6StatusCodeSuccess:
|
||||||
|
return "Success"
|
||||||
|
case DHCPv6StatusCodeUnspecFail:
|
||||||
|
return "UnspecifiedFailure"
|
||||||
|
case DHCPv6StatusCodeNoAddrsAvail:
|
||||||
|
return "NoAddressAvailable"
|
||||||
|
case DHCPv6StatusCodeNoBinding:
|
||||||
|
return "NoBinding"
|
||||||
|
case DHCPv6StatusCodeNotOnLink:
|
||||||
|
return "NotOnLink"
|
||||||
|
case DHCPv6StatusCodeUseMulticast:
|
||||||
|
return "UseMulticast"
|
||||||
|
default:
|
||||||
|
return "Unknown"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DHCPv6Opt represents a DHCP option or parameter from RFC-3315
|
||||||
|
type DHCPv6Opt uint16
|
||||||
|
|
||||||
|
// Constants for the DHCPv6Opt options.
|
||||||
|
const (
|
||||||
|
DHCPv6OptClientID DHCPv6Opt = 1
|
||||||
|
DHCPv6OptServerID DHCPv6Opt = 2
|
||||||
|
DHCPv6OptIANA DHCPv6Opt = 3
|
||||||
|
DHCPv6OptIATA DHCPv6Opt = 4
|
||||||
|
DHCPv6OptIAAddr DHCPv6Opt = 5
|
||||||
|
DHCPv6OptOro DHCPv6Opt = 6
|
||||||
|
DHCPv6OptPreference DHCPv6Opt = 7
|
||||||
|
DHCPv6OptElapsedTime DHCPv6Opt = 8
|
||||||
|
DHCPv6OptRelayMessage DHCPv6Opt = 9
|
||||||
|
DHCPv6OptAuth DHCPv6Opt = 11
|
||||||
|
DHCPv6OptUnicast DHCPv6Opt = 12
|
||||||
|
DHCPv6OptStatusCode DHCPv6Opt = 13
|
||||||
|
DHCPv6OptRapidCommit DHCPv6Opt = 14
|
||||||
|
DHCPv6OptUserClass DHCPv6Opt = 15
|
||||||
|
DHCPv6OptVendorClass DHCPv6Opt = 16
|
||||||
|
DHCPv6OptVendorOpts DHCPv6Opt = 17
|
||||||
|
DHCPv6OptInterfaceID DHCPv6Opt = 18
|
||||||
|
DHCPv6OptReconfigureMessage DHCPv6Opt = 19
|
||||||
|
DHCPv6OptReconfigureAccept DHCPv6Opt = 20
|
||||||
|
)
|
||||||
|
|
||||||
|
// String returns a string version of a DHCPv6Opt.
|
||||||
|
func (o DHCPv6Opt) String() string {
|
||||||
|
switch o {
|
||||||
|
case DHCPv6OptClientID:
|
||||||
|
return "ClientID"
|
||||||
|
case DHCPv6OptServerID:
|
||||||
|
return "ServerID"
|
||||||
|
case DHCPv6OptIANA:
|
||||||
|
return "IA_NA"
|
||||||
|
case DHCPv6OptIATA:
|
||||||
|
return "IA_TA"
|
||||||
|
case DHCPv6OptIAAddr:
|
||||||
|
return "IAAddr"
|
||||||
|
case DHCPv6OptOro:
|
||||||
|
return "Oro"
|
||||||
|
case DHCPv6OptPreference:
|
||||||
|
return "Preference"
|
||||||
|
case DHCPv6OptElapsedTime:
|
||||||
|
return "ElapsedTime"
|
||||||
|
case DHCPv6OptRelayMessage:
|
||||||
|
return "RelayMessage"
|
||||||
|
case DHCPv6OptAuth:
|
||||||
|
return "Auth"
|
||||||
|
case DHCPv6OptUnicast:
|
||||||
|
return "Unicast"
|
||||||
|
case DHCPv6OptStatusCode:
|
||||||
|
return "StatusCode"
|
||||||
|
case DHCPv6OptRapidCommit:
|
||||||
|
return "RapidCommit"
|
||||||
|
case DHCPv6OptUserClass:
|
||||||
|
return "UserClass"
|
||||||
|
case DHCPv6OptVendorClass:
|
||||||
|
return "VendorClass"
|
||||||
|
case DHCPv6OptVendorOpts:
|
||||||
|
return "VendorOpts"
|
||||||
|
case DHCPv6OptInterfaceID:
|
||||||
|
return "InterfaceID"
|
||||||
|
case DHCPv6OptReconfigureMessage:
|
||||||
|
return "ReconfigureMessage"
|
||||||
|
case DHCPv6OptReconfigureAccept:
|
||||||
|
return "ReconfigureAccept"
|
||||||
|
default:
|
||||||
|
return "Unknown"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DHCPv6Options is used to get nicely printed option lists which would normally
|
||||||
|
// be cut off after 5 options.
|
||||||
|
type DHCPv6Options []DHCPv6Option
|
||||||
|
|
||||||
|
// String returns a string version of the options list.
|
||||||
|
func (o DHCPv6Options) String() string {
|
||||||
|
buf := &bytes.Buffer{}
|
||||||
|
buf.WriteByte('[')
|
||||||
|
for i, opt := range o {
|
||||||
|
buf.WriteString(opt.String())
|
||||||
|
if i+1 != len(o) {
|
||||||
|
buf.WriteString(", ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buf.WriteByte(']')
|
||||||
|
return buf.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// DHCPv6Option rerpresents a DHCP option.
|
||||||
|
type DHCPv6Option struct {
|
||||||
|
Code DHCPv6Opt
|
||||||
|
Length uint16
|
||||||
|
Data []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// String returns a string version of a DHCP Option.
|
||||||
|
func (o DHCPv6Option) String() string {
|
||||||
|
switch o.Code {
|
||||||
|
case DHCPv6OptClientID, DHCPv6OptServerID:
|
||||||
|
duid, err := decodeDHCPv6DUID(o.Data)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Sprintf("Option(%s:INVALID)", o.Code)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("Option(%s:[%s])", o.Code, duid.String())
|
||||||
|
case DHCPv6OptOro:
|
||||||
|
options := ""
|
||||||
|
for i := 0; i < int(o.Length); i += 2 {
|
||||||
|
if options != "" {
|
||||||
|
options += ","
|
||||||
|
}
|
||||||
|
option := DHCPv6Opt(binary.BigEndian.Uint16(o.Data[i : i+2]))
|
||||||
|
options += option.String()
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("Option(%s:[%s])", o.Code, options)
|
||||||
|
default:
|
||||||
|
return fmt.Sprintf("Option(%s:%v)", o.Code, o.Data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewDHCPv6Option constructs a new DHCPv6Option with a given type and data.
|
||||||
|
func NewDHCPv6Option(code DHCPv6Opt, data []byte) DHCPv6Option {
|
||||||
|
o := DHCPv6Option{Code: code}
|
||||||
|
if data != nil {
|
||||||
|
o.Data = data
|
||||||
|
o.Length = uint16(len(data))
|
||||||
|
}
|
||||||
|
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *DHCPv6Option) encode(b []byte) error {
|
||||||
|
binary.BigEndian.PutUint16(b[0:2], uint16(o.Code))
|
||||||
|
binary.BigEndian.PutUint16(b[2:4], o.Length)
|
||||||
|
copy(b[4:], o.Data)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *DHCPv6Option) decode(data []byte) error {
|
||||||
|
if len(data) < 2 {
|
||||||
|
return errors.New("Not enough data to decode")
|
||||||
|
}
|
||||||
|
o.Code = DHCPv6Opt(binary.BigEndian.Uint16(data[0:2]))
|
||||||
|
if len(data) < 3 {
|
||||||
|
return errors.New("Not enough data to decode")
|
||||||
|
}
|
||||||
|
o.Length = binary.BigEndian.Uint16(data[2:4])
|
||||||
|
o.Data = data[4 : 4+o.Length]
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DHCPv6DUIDType represents a DHCP DUID - RFC-3315
|
||||||
|
type DHCPv6DUIDType uint16
|
||||||
|
|
||||||
|
// Constants for the DHCPv6DUIDType.
|
||||||
|
const (
|
||||||
|
DHCPv6DUIDTypeLLT DHCPv6DUIDType = iota + 1
|
||||||
|
DHCPv6DUIDTypeEN
|
||||||
|
DHCPv6DUIDTypeLL
|
||||||
|
)
|
||||||
|
|
||||||
|
// String returns a string version of a DHCPv6DUIDType.
|
||||||
|
func (o DHCPv6DUIDType) String() string {
|
||||||
|
switch o {
|
||||||
|
case DHCPv6DUIDTypeLLT:
|
||||||
|
return "LLT"
|
||||||
|
case DHCPv6DUIDTypeEN:
|
||||||
|
return "EN"
|
||||||
|
case DHCPv6DUIDTypeLL:
|
||||||
|
return "LL"
|
||||||
|
default:
|
||||||
|
return "Unknown"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DHCPv6DUID means DHCP Unique Identifier as stated in RFC 3315, section 9 (https://tools.ietf.org/html/rfc3315#page-19)
|
||||||
|
type DHCPv6DUID struct {
|
||||||
|
Type DHCPv6DUIDType
|
||||||
|
// LLT, LL
|
||||||
|
HardwareType []byte
|
||||||
|
// EN
|
||||||
|
EnterpriseNumber []byte
|
||||||
|
// LLT
|
||||||
|
Time []byte
|
||||||
|
// LLT, LL
|
||||||
|
LinkLayerAddress net.HardwareAddr
|
||||||
|
// EN
|
||||||
|
Identifier []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// DecodeFromBytes decodes the given bytes into a DHCPv6DUID
|
||||||
|
func (d *DHCPv6DUID) DecodeFromBytes(data []byte) error {
|
||||||
|
if len(data) < 2 {
|
||||||
|
return errors.New("Not enough bytes to decode: " + string(len(data)))
|
||||||
|
}
|
||||||
|
|
||||||
|
d.Type = DHCPv6DUIDType(binary.BigEndian.Uint16(data[:2]))
|
||||||
|
if d.Type == DHCPv6DUIDTypeLLT || d.Type == DHCPv6DUIDTypeLL {
|
||||||
|
d.HardwareType = data[2:4]
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.Type == DHCPv6DUIDTypeLLT {
|
||||||
|
d.Time = data[4:8]
|
||||||
|
d.LinkLayerAddress = net.HardwareAddr(data[8:])
|
||||||
|
} else if d.Type == DHCPv6DUIDTypeEN {
|
||||||
|
d.EnterpriseNumber = data[2:6]
|
||||||
|
d.Identifier = data[6:]
|
||||||
|
} else { // DHCPv6DUIDTypeLL
|
||||||
|
d.LinkLayerAddress = net.HardwareAddr(data[4:])
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encode encodes the DHCPv6DUID in a slice of bytes
|
||||||
|
func (d *DHCPv6DUID) Encode() []byte {
|
||||||
|
length := d.Len()
|
||||||
|
data := make([]byte, length)
|
||||||
|
binary.BigEndian.PutUint16(data[0:2], uint16(d.Type))
|
||||||
|
|
||||||
|
if d.Type == DHCPv6DUIDTypeLLT || d.Type == DHCPv6DUIDTypeLL {
|
||||||
|
copy(data[2:4], d.HardwareType)
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.Type == DHCPv6DUIDTypeLLT {
|
||||||
|
copy(data[4:8], d.Time)
|
||||||
|
copy(data[8:], d.LinkLayerAddress)
|
||||||
|
} else if d.Type == DHCPv6DUIDTypeEN {
|
||||||
|
copy(data[2:6], d.EnterpriseNumber)
|
||||||
|
copy(data[6:], d.Identifier)
|
||||||
|
} else {
|
||||||
|
copy(data[4:], d.LinkLayerAddress)
|
||||||
|
}
|
||||||
|
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
// Len returns the length of the DHCPv6DUID, respecting the type
|
||||||
|
func (d *DHCPv6DUID) Len() int {
|
||||||
|
length := 2 // d.Type
|
||||||
|
if d.Type == DHCPv6DUIDTypeLLT {
|
||||||
|
length += 2 /*HardwareType*/ + 4 /*d.Time*/ + len(d.LinkLayerAddress)
|
||||||
|
} else if d.Type == DHCPv6DUIDTypeEN {
|
||||||
|
length += 4 /*d.EnterpriseNumber*/ + len(d.Identifier)
|
||||||
|
} else { // LL
|
||||||
|
length += 2 /*d.HardwareType*/ + len(d.LinkLayerAddress)
|
||||||
|
}
|
||||||
|
|
||||||
|
return length
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DHCPv6DUID) String() string {
|
||||||
|
duid := "Type: " + d.Type.String() + ", "
|
||||||
|
if d.Type == DHCPv6DUIDTypeLLT {
|
||||||
|
duid += fmt.Sprintf("HardwareType: %v, Time: %v, LinkLayerAddress: %v", d.HardwareType, d.Time, d.LinkLayerAddress)
|
||||||
|
} else if d.Type == DHCPv6DUIDTypeEN {
|
||||||
|
duid += fmt.Sprintf("EnterpriseNumber: %v, Identifier: %v", d.EnterpriseNumber, d.Identifier)
|
||||||
|
} else { // DHCPv6DUIDTypeLL
|
||||||
|
duid += fmt.Sprintf("HardwareType: %v, LinkLayerAddress: %v", d.HardwareType, d.LinkLayerAddress)
|
||||||
|
}
|
||||||
|
return duid
|
||||||
|
}
|
||||||
|
|
||||||
|
func decodeDHCPv6DUID(data []byte) (*DHCPv6DUID, error) {
|
||||||
|
duid := &DHCPv6DUID{}
|
||||||
|
err := duid.DecodeFromBytes(data)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return duid, nil
|
||||||
|
}
|
4
vendor/github.com/google/gopacket/layers/dns.go
generated
vendored
4
vendor/github.com/google/gopacket/layers/dns.go
generated
vendored
|
@ -254,7 +254,7 @@ type DNS struct {
|
||||||
TC bool // Truncated
|
TC bool // Truncated
|
||||||
RD bool // Recursion desired
|
RD bool // Recursion desired
|
||||||
RA bool // Recursion available
|
RA bool // Recursion available
|
||||||
Z uint8 // Resrved for future use
|
Z uint8 // Reserved for future use
|
||||||
|
|
||||||
ResponseCode DNSResponseCode
|
ResponseCode DNSResponseCode
|
||||||
QDCount uint16 // Number of questions to expect
|
QDCount uint16 // Number of questions to expect
|
||||||
|
@ -431,7 +431,7 @@ func recSize(rr *DNSResourceRecord) int {
|
||||||
func computeSize(recs []DNSResourceRecord) int {
|
func computeSize(recs []DNSResourceRecord) int {
|
||||||
sz := 0
|
sz := 0
|
||||||
for _, rr := range recs {
|
for _, rr := range recs {
|
||||||
sz += len(rr.Name) + 14
|
sz += len(rr.Name) + 12
|
||||||
sz += recSize(&rr)
|
sz += recSize(&rr)
|
||||||
}
|
}
|
||||||
return sz
|
return sz
|
||||||
|
|
771
vendor/github.com/google/gopacket/layers/dot11.go
generated
vendored
771
vendor/github.com/google/gopacket/layers/dot11.go
generated
vendored
|
@ -240,24 +240,172 @@ func (a Dot11Algorithm) String() string {
|
||||||
|
|
||||||
type Dot11InformationElementID uint8
|
type Dot11InformationElementID uint8
|
||||||
|
|
||||||
// TODO: Verify these element ids, and append more ids if more.
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Dot11InformationElementIDSSID Dot11InformationElementID = 0
|
Dot11InformationElementIDSSID Dot11InformationElementID = 0
|
||||||
Dot11InformationElementIDRates Dot11InformationElementID = 1
|
Dot11InformationElementIDRates Dot11InformationElementID = 1
|
||||||
Dot11InformationElementIDFHSet Dot11InformationElementID = 2
|
Dot11InformationElementIDFHSet Dot11InformationElementID = 2
|
||||||
Dot11InformationElementIDDSSet Dot11InformationElementID = 3
|
Dot11InformationElementIDDSSet Dot11InformationElementID = 3
|
||||||
Dot11InformationElementIDCFSet Dot11InformationElementID = 4
|
Dot11InformationElementIDCFSet Dot11InformationElementID = 4
|
||||||
Dot11InformationElementIDTIM Dot11InformationElementID = 5
|
Dot11InformationElementIDTIM Dot11InformationElementID = 5
|
||||||
Dot11InformationElementIDIBSSSet Dot11InformationElementID = 6
|
Dot11InformationElementIDIBSSSet Dot11InformationElementID = 6
|
||||||
Dot11InformationElementIDChallenge Dot11InformationElementID = 16
|
Dot11InformationElementIDCountryInfo Dot11InformationElementID = 7
|
||||||
Dot11InformationElementIDERPInfo Dot11InformationElementID = 42
|
Dot11InformationElementIDHoppingPatternParam Dot11InformationElementID = 8
|
||||||
Dot11InformationElementIDQOSCapability Dot11InformationElementID = 46
|
Dot11InformationElementIDHoppingPatternTable Dot11InformationElementID = 9
|
||||||
Dot11InformationElementIDERPInfo2 Dot11InformationElementID = 47
|
Dot11InformationElementIDRequest Dot11InformationElementID = 10
|
||||||
Dot11InformationElementIDRSNInfo Dot11InformationElementID = 48
|
Dot11InformationElementIDQBSSLoadElem Dot11InformationElementID = 11
|
||||||
Dot11InformationElementIDESRates Dot11InformationElementID = 50
|
Dot11InformationElementIDEDCAParamSet Dot11InformationElementID = 12
|
||||||
Dot11InformationElementIDVendor Dot11InformationElementID = 221
|
Dot11InformationElementIDTrafficSpec Dot11InformationElementID = 13
|
||||||
Dot11InformationElementIDReserved Dot11InformationElementID = 68
|
Dot11InformationElementIDTrafficClass Dot11InformationElementID = 14
|
||||||
|
Dot11InformationElementIDSchedule Dot11InformationElementID = 15
|
||||||
|
Dot11InformationElementIDChallenge Dot11InformationElementID = 16
|
||||||
|
Dot11InformationElementIDPowerConst Dot11InformationElementID = 32
|
||||||
|
Dot11InformationElementIDPowerCapability Dot11InformationElementID = 33
|
||||||
|
Dot11InformationElementIDTPCRequest Dot11InformationElementID = 34
|
||||||
|
Dot11InformationElementIDTPCReport Dot11InformationElementID = 35
|
||||||
|
Dot11InformationElementIDSupportedChannels Dot11InformationElementID = 36
|
||||||
|
Dot11InformationElementIDSwitchChannelAnnounce Dot11InformationElementID = 37
|
||||||
|
Dot11InformationElementIDMeasureRequest Dot11InformationElementID = 38
|
||||||
|
Dot11InformationElementIDMeasureReport Dot11InformationElementID = 39
|
||||||
|
Dot11InformationElementIDQuiet Dot11InformationElementID = 40
|
||||||
|
Dot11InformationElementIDIBSSDFS Dot11InformationElementID = 41
|
||||||
|
Dot11InformationElementIDERPInfo Dot11InformationElementID = 42
|
||||||
|
Dot11InformationElementIDTSDelay Dot11InformationElementID = 43
|
||||||
|
Dot11InformationElementIDTCLASProcessing Dot11InformationElementID = 44
|
||||||
|
Dot11InformationElementIDHTCapabilities Dot11InformationElementID = 45
|
||||||
|
Dot11InformationElementIDQOSCapability Dot11InformationElementID = 46
|
||||||
|
Dot11InformationElementIDERPInfo2 Dot11InformationElementID = 47
|
||||||
|
Dot11InformationElementIDRSNInfo Dot11InformationElementID = 48
|
||||||
|
Dot11InformationElementIDESRates Dot11InformationElementID = 50
|
||||||
|
Dot11InformationElementIDAPChannelReport Dot11InformationElementID = 51
|
||||||
|
Dot11InformationElementIDNeighborReport Dot11InformationElementID = 52
|
||||||
|
Dot11InformationElementIDRCPI Dot11InformationElementID = 53
|
||||||
|
Dot11InformationElementIDMobilityDomain Dot11InformationElementID = 54
|
||||||
|
Dot11InformationElementIDFastBSSTrans Dot11InformationElementID = 55
|
||||||
|
Dot11InformationElementIDTimeoutInt Dot11InformationElementID = 56
|
||||||
|
Dot11InformationElementIDRICData Dot11InformationElementID = 57
|
||||||
|
Dot11InformationElementIDDSERegisteredLoc Dot11InformationElementID = 58
|
||||||
|
Dot11InformationElementIDSuppOperatingClass Dot11InformationElementID = 59
|
||||||
|
Dot11InformationElementIDExtChanSwitchAnnounce Dot11InformationElementID = 60
|
||||||
|
Dot11InformationElementIDHTInfo Dot11InformationElementID = 61
|
||||||
|
Dot11InformationElementIDSecChanOffset Dot11InformationElementID = 62
|
||||||
|
Dot11InformationElementIDBSSAverageAccessDelay Dot11InformationElementID = 63
|
||||||
|
Dot11InformationElementIDAntenna Dot11InformationElementID = 64
|
||||||
|
Dot11InformationElementIDRSNI Dot11InformationElementID = 65
|
||||||
|
Dot11InformationElementIDMeasurePilotTrans Dot11InformationElementID = 66
|
||||||
|
Dot11InformationElementIDBSSAvailAdmCapacity Dot11InformationElementID = 67
|
||||||
|
Dot11InformationElementIDBSSACAccDelayWAPIParam Dot11InformationElementID = 68
|
||||||
|
Dot11InformationElementIDTimeAdvertisement Dot11InformationElementID = 69
|
||||||
|
Dot11InformationElementIDRMEnabledCapabilities Dot11InformationElementID = 70
|
||||||
|
Dot11InformationElementIDMultipleBSSID Dot11InformationElementID = 71
|
||||||
|
Dot11InformationElementID2040BSSCoExist Dot11InformationElementID = 72
|
||||||
|
Dot11InformationElementID2040BSSIntChanReport Dot11InformationElementID = 73
|
||||||
|
Dot11InformationElementIDOverlapBSSScanParam Dot11InformationElementID = 74
|
||||||
|
Dot11InformationElementIDRICDescriptor Dot11InformationElementID = 75
|
||||||
|
Dot11InformationElementIDManagementMIC Dot11InformationElementID = 76
|
||||||
|
Dot11InformationElementIDEventRequest Dot11InformationElementID = 78
|
||||||
|
Dot11InformationElementIDEventReport Dot11InformationElementID = 79
|
||||||
|
Dot11InformationElementIDDiagnosticRequest Dot11InformationElementID = 80
|
||||||
|
Dot11InformationElementIDDiagnosticReport Dot11InformationElementID = 81
|
||||||
|
Dot11InformationElementIDLocationParam Dot11InformationElementID = 82
|
||||||
|
Dot11InformationElementIDNonTransBSSIDCapability Dot11InformationElementID = 83
|
||||||
|
Dot11InformationElementIDSSIDList Dot11InformationElementID = 84
|
||||||
|
Dot11InformationElementIDMultipleBSSIDIndex Dot11InformationElementID = 85
|
||||||
|
Dot11InformationElementIDFMSDescriptor Dot11InformationElementID = 86
|
||||||
|
Dot11InformationElementIDFMSRequest Dot11InformationElementID = 87
|
||||||
|
Dot11InformationElementIDFMSResponse Dot11InformationElementID = 88
|
||||||
|
Dot11InformationElementIDQOSTrafficCapability Dot11InformationElementID = 89
|
||||||
|
Dot11InformationElementIDBSSMaxIdlePeriod Dot11InformationElementID = 90
|
||||||
|
Dot11InformationElementIDTFSRequest Dot11InformationElementID = 91
|
||||||
|
Dot11InformationElementIDTFSResponse Dot11InformationElementID = 92
|
||||||
|
Dot11InformationElementIDWNMSleepMode Dot11InformationElementID = 93
|
||||||
|
Dot11InformationElementIDTIMBroadcastRequest Dot11InformationElementID = 94
|
||||||
|
Dot11InformationElementIDTIMBroadcastResponse Dot11InformationElementID = 95
|
||||||
|
Dot11InformationElementIDCollInterferenceReport Dot11InformationElementID = 96
|
||||||
|
Dot11InformationElementIDChannelUsage Dot11InformationElementID = 97
|
||||||
|
Dot11InformationElementIDTimeZone Dot11InformationElementID = 98
|
||||||
|
Dot11InformationElementIDDMSRequest Dot11InformationElementID = 99
|
||||||
|
Dot11InformationElementIDDMSResponse Dot11InformationElementID = 100
|
||||||
|
Dot11InformationElementIDLinkIdentifier Dot11InformationElementID = 101
|
||||||
|
Dot11InformationElementIDWakeupSchedule Dot11InformationElementID = 102
|
||||||
|
Dot11InformationElementIDChannelSwitchTiming Dot11InformationElementID = 104
|
||||||
|
Dot11InformationElementIDPTIControl Dot11InformationElementID = 105
|
||||||
|
Dot11InformationElementIDPUBufferStatus Dot11InformationElementID = 106
|
||||||
|
Dot11InformationElementIDInterworking Dot11InformationElementID = 107
|
||||||
|
Dot11InformationElementIDAdvertisementProtocol Dot11InformationElementID = 108
|
||||||
|
Dot11InformationElementIDExpBWRequest Dot11InformationElementID = 109
|
||||||
|
Dot11InformationElementIDQOSMapSet Dot11InformationElementID = 110
|
||||||
|
Dot11InformationElementIDRoamingConsortium Dot11InformationElementID = 111
|
||||||
|
Dot11InformationElementIDEmergencyAlertIdentifier Dot11InformationElementID = 112
|
||||||
|
Dot11InformationElementIDMeshConfiguration Dot11InformationElementID = 113
|
||||||
|
Dot11InformationElementIDMeshID Dot11InformationElementID = 114
|
||||||
|
Dot11InformationElementIDMeshLinkMetricReport Dot11InformationElementID = 115
|
||||||
|
Dot11InformationElementIDCongestionNotification Dot11InformationElementID = 116
|
||||||
|
Dot11InformationElementIDMeshPeeringManagement Dot11InformationElementID = 117
|
||||||
|
Dot11InformationElementIDMeshChannelSwitchParam Dot11InformationElementID = 118
|
||||||
|
Dot11InformationElementIDMeshAwakeWindows Dot11InformationElementID = 119
|
||||||
|
Dot11InformationElementIDBeaconTiming Dot11InformationElementID = 120
|
||||||
|
Dot11InformationElementIDMCCAOPSetupRequest Dot11InformationElementID = 121
|
||||||
|
Dot11InformationElementIDMCCAOPSetupReply Dot11InformationElementID = 122
|
||||||
|
Dot11InformationElementIDMCCAOPAdvertisement Dot11InformationElementID = 123
|
||||||
|
Dot11InformationElementIDMCCAOPTeardown Dot11InformationElementID = 124
|
||||||
|
Dot11InformationElementIDGateAnnouncement Dot11InformationElementID = 125
|
||||||
|
Dot11InformationElementIDRootAnnouncement Dot11InformationElementID = 126
|
||||||
|
Dot11InformationElementIDExtCapability Dot11InformationElementID = 127
|
||||||
|
Dot11InformationElementIDAgereProprietary Dot11InformationElementID = 128
|
||||||
|
Dot11InformationElementIDPathRequest Dot11InformationElementID = 130
|
||||||
|
Dot11InformationElementIDPathReply Dot11InformationElementID = 131
|
||||||
|
Dot11InformationElementIDPathError Dot11InformationElementID = 132
|
||||||
|
Dot11InformationElementIDCiscoCCX1CKIPDeviceName Dot11InformationElementID = 133
|
||||||
|
Dot11InformationElementIDCiscoCCX2 Dot11InformationElementID = 136
|
||||||
|
Dot11InformationElementIDProxyUpdate Dot11InformationElementID = 137
|
||||||
|
Dot11InformationElementIDProxyUpdateConfirmation Dot11InformationElementID = 138
|
||||||
|
Dot11InformationElementIDAuthMeshPerringExch Dot11InformationElementID = 139
|
||||||
|
Dot11InformationElementIDMIC Dot11InformationElementID = 140
|
||||||
|
Dot11InformationElementIDDestinationURI Dot11InformationElementID = 141
|
||||||
|
Dot11InformationElementIDUAPSDCoexistence Dot11InformationElementID = 142
|
||||||
|
Dot11InformationElementIDWakeupSchedule80211ad Dot11InformationElementID = 143
|
||||||
|
Dot11InformationElementIDExtendedSchedule Dot11InformationElementID = 144
|
||||||
|
Dot11InformationElementIDSTAAvailability Dot11InformationElementID = 145
|
||||||
|
Dot11InformationElementIDDMGTSPEC Dot11InformationElementID = 146
|
||||||
|
Dot11InformationElementIDNextDMGATI Dot11InformationElementID = 147
|
||||||
|
Dot11InformationElementIDDMSCapabilities Dot11InformationElementID = 148
|
||||||
|
Dot11InformationElementIDCiscoUnknown95 Dot11InformationElementID = 149
|
||||||
|
Dot11InformationElementIDVendor2 Dot11InformationElementID = 150
|
||||||
|
Dot11InformationElementIDDMGOperating Dot11InformationElementID = 151
|
||||||
|
Dot11InformationElementIDDMGBSSParamChange Dot11InformationElementID = 152
|
||||||
|
Dot11InformationElementIDDMGBeamRefinement Dot11InformationElementID = 153
|
||||||
|
Dot11InformationElementIDChannelMeasFeedback Dot11InformationElementID = 154
|
||||||
|
Dot11InformationElementIDAwakeWindow Dot11InformationElementID = 157
|
||||||
|
Dot11InformationElementIDMultiBand Dot11InformationElementID = 158
|
||||||
|
Dot11InformationElementIDADDBAExtension Dot11InformationElementID = 159
|
||||||
|
Dot11InformationElementIDNEXTPCPList Dot11InformationElementID = 160
|
||||||
|
Dot11InformationElementIDPCPHandover Dot11InformationElementID = 161
|
||||||
|
Dot11InformationElementIDDMGLinkMargin Dot11InformationElementID = 162
|
||||||
|
Dot11InformationElementIDSwitchingStream Dot11InformationElementID = 163
|
||||||
|
Dot11InformationElementIDSessionTransmission Dot11InformationElementID = 164
|
||||||
|
Dot11InformationElementIDDynamicTonePairReport Dot11InformationElementID = 165
|
||||||
|
Dot11InformationElementIDClusterReport Dot11InformationElementID = 166
|
||||||
|
Dot11InformationElementIDRelayCapabilities Dot11InformationElementID = 167
|
||||||
|
Dot11InformationElementIDRelayTransferParameter Dot11InformationElementID = 168
|
||||||
|
Dot11InformationElementIDBeamlinkMaintenance Dot11InformationElementID = 169
|
||||||
|
Dot11InformationElementIDMultipleMacSublayers Dot11InformationElementID = 170
|
||||||
|
Dot11InformationElementIDUPID Dot11InformationElementID = 171
|
||||||
|
Dot11InformationElementIDDMGLinkAdaptionAck Dot11InformationElementID = 172
|
||||||
|
Dot11InformationElementIDSymbolProprietary Dot11InformationElementID = 173
|
||||||
|
Dot11InformationElementIDMCCAOPAdvertOverview Dot11InformationElementID = 174
|
||||||
|
Dot11InformationElementIDQuietPeriodRequest Dot11InformationElementID = 175
|
||||||
|
Dot11InformationElementIDQuietPeriodResponse Dot11InformationElementID = 177
|
||||||
|
Dot11InformationElementIDECPACPolicy Dot11InformationElementID = 182
|
||||||
|
Dot11InformationElementIDClusterTimeOffset Dot11InformationElementID = 183
|
||||||
|
Dot11InformationElementIDAntennaSectorID Dot11InformationElementID = 190
|
||||||
|
Dot11InformationElementIDVHTCapabilities Dot11InformationElementID = 191
|
||||||
|
Dot11InformationElementIDVHTOperation Dot11InformationElementID = 192
|
||||||
|
Dot11InformationElementIDExtendedBSSLoad Dot11InformationElementID = 193
|
||||||
|
Dot11InformationElementIDWideBWChannelSwitch Dot11InformationElementID = 194
|
||||||
|
Dot11InformationElementIDVHTTxPowerEnvelope Dot11InformationElementID = 195
|
||||||
|
Dot11InformationElementIDChannelSwitchWrapper Dot11InformationElementID = 196
|
||||||
|
Dot11InformationElementIDOperatingModeNotification Dot11InformationElementID = 199
|
||||||
|
Dot11InformationElementIDVendor Dot11InformationElementID = 221
|
||||||
)
|
)
|
||||||
|
|
||||||
// String provides a human readable string for Dot11InformationElementID.
|
// String provides a human readable string for Dot11InformationElementID.
|
||||||
|
@ -267,35 +415,335 @@ const (
|
||||||
func (a Dot11InformationElementID) String() string {
|
func (a Dot11InformationElementID) String() string {
|
||||||
switch a {
|
switch a {
|
||||||
case Dot11InformationElementIDSSID:
|
case Dot11InformationElementIDSSID:
|
||||||
return "SSID"
|
return "SSID parameter set"
|
||||||
case Dot11InformationElementIDRates:
|
case Dot11InformationElementIDRates:
|
||||||
return "Rates"
|
return "Supported Rates"
|
||||||
case Dot11InformationElementIDFHSet:
|
case Dot11InformationElementIDFHSet:
|
||||||
return "FHset"
|
return "FH Parameter set"
|
||||||
case Dot11InformationElementIDDSSet:
|
case Dot11InformationElementIDDSSet:
|
||||||
return "DSset"
|
return "DS Parameter set"
|
||||||
case Dot11InformationElementIDCFSet:
|
case Dot11InformationElementIDCFSet:
|
||||||
return "CFset"
|
return "CF Parameter set"
|
||||||
case Dot11InformationElementIDTIM:
|
case Dot11InformationElementIDTIM:
|
||||||
return "TIM"
|
return "Traffic Indication Map (TIM)"
|
||||||
case Dot11InformationElementIDIBSSSet:
|
case Dot11InformationElementIDIBSSSet:
|
||||||
return "IBSSset"
|
return "IBSS Parameter set"
|
||||||
|
case Dot11InformationElementIDCountryInfo:
|
||||||
|
return "Country Information"
|
||||||
|
case Dot11InformationElementIDHoppingPatternParam:
|
||||||
|
return "Hopping Pattern Parameters"
|
||||||
|
case Dot11InformationElementIDHoppingPatternTable:
|
||||||
|
return "Hopping Pattern Table"
|
||||||
|
case Dot11InformationElementIDRequest:
|
||||||
|
return "Request"
|
||||||
|
case Dot11InformationElementIDQBSSLoadElem:
|
||||||
|
return "QBSS Load Element"
|
||||||
|
case Dot11InformationElementIDEDCAParamSet:
|
||||||
|
return "EDCA Parameter Set"
|
||||||
|
case Dot11InformationElementIDTrafficSpec:
|
||||||
|
return "Traffic Specification"
|
||||||
|
case Dot11InformationElementIDTrafficClass:
|
||||||
|
return "Traffic Classification"
|
||||||
|
case Dot11InformationElementIDSchedule:
|
||||||
|
return "Schedule"
|
||||||
case Dot11InformationElementIDChallenge:
|
case Dot11InformationElementIDChallenge:
|
||||||
return "Challenge"
|
return "Challenge text"
|
||||||
|
case Dot11InformationElementIDPowerConst:
|
||||||
|
return "Power Constraint"
|
||||||
|
case Dot11InformationElementIDPowerCapability:
|
||||||
|
return "Power Capability"
|
||||||
|
case Dot11InformationElementIDTPCRequest:
|
||||||
|
return "TPC Request"
|
||||||
|
case Dot11InformationElementIDTPCReport:
|
||||||
|
return "TPC Report"
|
||||||
|
case Dot11InformationElementIDSupportedChannels:
|
||||||
|
return "Supported Channels"
|
||||||
|
case Dot11InformationElementIDSwitchChannelAnnounce:
|
||||||
|
return "Channel Switch Announcement"
|
||||||
|
case Dot11InformationElementIDMeasureRequest:
|
||||||
|
return "Measurement Request"
|
||||||
|
case Dot11InformationElementIDMeasureReport:
|
||||||
|
return "Measurement Report"
|
||||||
|
case Dot11InformationElementIDQuiet:
|
||||||
|
return "Quiet"
|
||||||
|
case Dot11InformationElementIDIBSSDFS:
|
||||||
|
return "IBSS DFS"
|
||||||
case Dot11InformationElementIDERPInfo:
|
case Dot11InformationElementIDERPInfo:
|
||||||
return "ERPinfo"
|
return "ERP Information"
|
||||||
|
case Dot11InformationElementIDTSDelay:
|
||||||
|
return "TS Delay"
|
||||||
|
case Dot11InformationElementIDTCLASProcessing:
|
||||||
|
return "TCLAS Processing"
|
||||||
|
case Dot11InformationElementIDHTCapabilities:
|
||||||
|
return "HT Capabilities (802.11n D1.10)"
|
||||||
case Dot11InformationElementIDQOSCapability:
|
case Dot11InformationElementIDQOSCapability:
|
||||||
return "QOS capability"
|
return "QOS Capability"
|
||||||
case Dot11InformationElementIDERPInfo2:
|
case Dot11InformationElementIDERPInfo2:
|
||||||
return "ERPinfo2"
|
return "ERP Information-2"
|
||||||
case Dot11InformationElementIDRSNInfo:
|
case Dot11InformationElementIDRSNInfo:
|
||||||
return "RSNinfo"
|
return "RSN Information"
|
||||||
case Dot11InformationElementIDESRates:
|
case Dot11InformationElementIDESRates:
|
||||||
return "ESrates"
|
return "Extended Supported Rates"
|
||||||
|
case Dot11InformationElementIDAPChannelReport:
|
||||||
|
return "AP Channel Report"
|
||||||
|
case Dot11InformationElementIDNeighborReport:
|
||||||
|
return "Neighbor Report"
|
||||||
|
case Dot11InformationElementIDRCPI:
|
||||||
|
return "RCPI"
|
||||||
|
case Dot11InformationElementIDMobilityDomain:
|
||||||
|
return "Mobility Domain"
|
||||||
|
case Dot11InformationElementIDFastBSSTrans:
|
||||||
|
return "Fast BSS Transition"
|
||||||
|
case Dot11InformationElementIDTimeoutInt:
|
||||||
|
return "Timeout Interval"
|
||||||
|
case Dot11InformationElementIDRICData:
|
||||||
|
return "RIC Data"
|
||||||
|
case Dot11InformationElementIDDSERegisteredLoc:
|
||||||
|
return "DSE Registered Location"
|
||||||
|
case Dot11InformationElementIDSuppOperatingClass:
|
||||||
|
return "Supported Operating Classes"
|
||||||
|
case Dot11InformationElementIDExtChanSwitchAnnounce:
|
||||||
|
return "Extended Channel Switch Announcement"
|
||||||
|
case Dot11InformationElementIDHTInfo:
|
||||||
|
return "HT Information (802.11n D1.10)"
|
||||||
|
case Dot11InformationElementIDSecChanOffset:
|
||||||
|
return "Secondary Channel Offset (802.11n D1.10)"
|
||||||
|
case Dot11InformationElementIDBSSAverageAccessDelay:
|
||||||
|
return "BSS Average Access Delay"
|
||||||
|
case Dot11InformationElementIDAntenna:
|
||||||
|
return "Antenna"
|
||||||
|
case Dot11InformationElementIDRSNI:
|
||||||
|
return "RSNI"
|
||||||
|
case Dot11InformationElementIDMeasurePilotTrans:
|
||||||
|
return "Measurement Pilot Transmission"
|
||||||
|
case Dot11InformationElementIDBSSAvailAdmCapacity:
|
||||||
|
return "BSS Available Admission Capacity"
|
||||||
|
case Dot11InformationElementIDBSSACAccDelayWAPIParam:
|
||||||
|
return "BSS AC Access Delay/WAPI Parameter Set"
|
||||||
|
case Dot11InformationElementIDTimeAdvertisement:
|
||||||
|
return "Time Advertisement"
|
||||||
|
case Dot11InformationElementIDRMEnabledCapabilities:
|
||||||
|
return "RM Enabled Capabilities"
|
||||||
|
case Dot11InformationElementIDMultipleBSSID:
|
||||||
|
return "Multiple BSSID"
|
||||||
|
case Dot11InformationElementID2040BSSCoExist:
|
||||||
|
return "20/40 BSS Coexistence"
|
||||||
|
case Dot11InformationElementID2040BSSIntChanReport:
|
||||||
|
return "20/40 BSS Intolerant Channel Report"
|
||||||
|
case Dot11InformationElementIDOverlapBSSScanParam:
|
||||||
|
return "Overlapping BSS Scan Parameters"
|
||||||
|
case Dot11InformationElementIDRICDescriptor:
|
||||||
|
return "RIC Descriptor"
|
||||||
|
case Dot11InformationElementIDManagementMIC:
|
||||||
|
return "Management MIC"
|
||||||
|
case Dot11InformationElementIDEventRequest:
|
||||||
|
return "Event Request"
|
||||||
|
case Dot11InformationElementIDEventReport:
|
||||||
|
return "Event Report"
|
||||||
|
case Dot11InformationElementIDDiagnosticRequest:
|
||||||
|
return "Diagnostic Request"
|
||||||
|
case Dot11InformationElementIDDiagnosticReport:
|
||||||
|
return "Diagnostic Report"
|
||||||
|
case Dot11InformationElementIDLocationParam:
|
||||||
|
return "Location Parameters"
|
||||||
|
case Dot11InformationElementIDNonTransBSSIDCapability:
|
||||||
|
return "Non Transmitted BSSID Capability"
|
||||||
|
case Dot11InformationElementIDSSIDList:
|
||||||
|
return "SSID List"
|
||||||
|
case Dot11InformationElementIDMultipleBSSIDIndex:
|
||||||
|
return "Multiple BSSID Index"
|
||||||
|
case Dot11InformationElementIDFMSDescriptor:
|
||||||
|
return "FMS Descriptor"
|
||||||
|
case Dot11InformationElementIDFMSRequest:
|
||||||
|
return "FMS Request"
|
||||||
|
case Dot11InformationElementIDFMSResponse:
|
||||||
|
return "FMS Response"
|
||||||
|
case Dot11InformationElementIDQOSTrafficCapability:
|
||||||
|
return "QoS Traffic Capability"
|
||||||
|
case Dot11InformationElementIDBSSMaxIdlePeriod:
|
||||||
|
return "BSS Max Idle Period"
|
||||||
|
case Dot11InformationElementIDTFSRequest:
|
||||||
|
return "TFS Request"
|
||||||
|
case Dot11InformationElementIDTFSResponse:
|
||||||
|
return "TFS Response"
|
||||||
|
case Dot11InformationElementIDWNMSleepMode:
|
||||||
|
return "WNM-Sleep Mode"
|
||||||
|
case Dot11InformationElementIDTIMBroadcastRequest:
|
||||||
|
return "TIM Broadcast Request"
|
||||||
|
case Dot11InformationElementIDTIMBroadcastResponse:
|
||||||
|
return "TIM Broadcast Response"
|
||||||
|
case Dot11InformationElementIDCollInterferenceReport:
|
||||||
|
return "Collocated Interference Report"
|
||||||
|
case Dot11InformationElementIDChannelUsage:
|
||||||
|
return "Channel Usage"
|
||||||
|
case Dot11InformationElementIDTimeZone:
|
||||||
|
return "Time Zone"
|
||||||
|
case Dot11InformationElementIDDMSRequest:
|
||||||
|
return "DMS Request"
|
||||||
|
case Dot11InformationElementIDDMSResponse:
|
||||||
|
return "DMS Response"
|
||||||
|
case Dot11InformationElementIDLinkIdentifier:
|
||||||
|
return "Link Identifier"
|
||||||
|
case Dot11InformationElementIDWakeupSchedule:
|
||||||
|
return "Wakeup Schedule"
|
||||||
|
case Dot11InformationElementIDChannelSwitchTiming:
|
||||||
|
return "Channel Switch Timing"
|
||||||
|
case Dot11InformationElementIDPTIControl:
|
||||||
|
return "PTI Control"
|
||||||
|
case Dot11InformationElementIDPUBufferStatus:
|
||||||
|
return "PU Buffer Status"
|
||||||
|
case Dot11InformationElementIDInterworking:
|
||||||
|
return "Interworking"
|
||||||
|
case Dot11InformationElementIDAdvertisementProtocol:
|
||||||
|
return "Advertisement Protocol"
|
||||||
|
case Dot11InformationElementIDExpBWRequest:
|
||||||
|
return "Expedited Bandwidth Request"
|
||||||
|
case Dot11InformationElementIDQOSMapSet:
|
||||||
|
return "QoS Map Set"
|
||||||
|
case Dot11InformationElementIDRoamingConsortium:
|
||||||
|
return "Roaming Consortium"
|
||||||
|
case Dot11InformationElementIDEmergencyAlertIdentifier:
|
||||||
|
return "Emergency Alert Identifier"
|
||||||
|
case Dot11InformationElementIDMeshConfiguration:
|
||||||
|
return "Mesh Configuration"
|
||||||
|
case Dot11InformationElementIDMeshID:
|
||||||
|
return "Mesh ID"
|
||||||
|
case Dot11InformationElementIDMeshLinkMetricReport:
|
||||||
|
return "Mesh Link Metric Report"
|
||||||
|
case Dot11InformationElementIDCongestionNotification:
|
||||||
|
return "Congestion Notification"
|
||||||
|
case Dot11InformationElementIDMeshPeeringManagement:
|
||||||
|
return "Mesh Peering Management"
|
||||||
|
case Dot11InformationElementIDMeshChannelSwitchParam:
|
||||||
|
return "Mesh Channel Switch Parameters"
|
||||||
|
case Dot11InformationElementIDMeshAwakeWindows:
|
||||||
|
return "Mesh Awake Windows"
|
||||||
|
case Dot11InformationElementIDBeaconTiming:
|
||||||
|
return "Beacon Timing"
|
||||||
|
case Dot11InformationElementIDMCCAOPSetupRequest:
|
||||||
|
return "MCCAOP Setup Request"
|
||||||
|
case Dot11InformationElementIDMCCAOPSetupReply:
|
||||||
|
return "MCCAOP SETUP Reply"
|
||||||
|
case Dot11InformationElementIDMCCAOPAdvertisement:
|
||||||
|
return "MCCAOP Advertisement"
|
||||||
|
case Dot11InformationElementIDMCCAOPTeardown:
|
||||||
|
return "MCCAOP Teardown"
|
||||||
|
case Dot11InformationElementIDGateAnnouncement:
|
||||||
|
return "Gate Announcement"
|
||||||
|
case Dot11InformationElementIDRootAnnouncement:
|
||||||
|
return "Root Announcement"
|
||||||
|
case Dot11InformationElementIDExtCapability:
|
||||||
|
return "Extended Capabilities"
|
||||||
|
case Dot11InformationElementIDAgereProprietary:
|
||||||
|
return "Agere Proprietary"
|
||||||
|
case Dot11InformationElementIDPathRequest:
|
||||||
|
return "Path Request"
|
||||||
|
case Dot11InformationElementIDPathReply:
|
||||||
|
return "Path Reply"
|
||||||
|
case Dot11InformationElementIDPathError:
|
||||||
|
return "Path Error"
|
||||||
|
case Dot11InformationElementIDCiscoCCX1CKIPDeviceName:
|
||||||
|
return "Cisco CCX1 CKIP + Device Name"
|
||||||
|
case Dot11InformationElementIDCiscoCCX2:
|
||||||
|
return "Cisco CCX2"
|
||||||
|
case Dot11InformationElementIDProxyUpdate:
|
||||||
|
return "Proxy Update"
|
||||||
|
case Dot11InformationElementIDProxyUpdateConfirmation:
|
||||||
|
return "Proxy Update Confirmation"
|
||||||
|
case Dot11InformationElementIDAuthMeshPerringExch:
|
||||||
|
return "Auhenticated Mesh Perring Exchange"
|
||||||
|
case Dot11InformationElementIDMIC:
|
||||||
|
return "MIC (Message Integrity Code)"
|
||||||
|
case Dot11InformationElementIDDestinationURI:
|
||||||
|
return "Destination URI"
|
||||||
|
case Dot11InformationElementIDUAPSDCoexistence:
|
||||||
|
return "U-APSD Coexistence"
|
||||||
|
case Dot11InformationElementIDWakeupSchedule80211ad:
|
||||||
|
return "Wakeup Schedule 802.11ad"
|
||||||
|
case Dot11InformationElementIDExtendedSchedule:
|
||||||
|
return "Extended Schedule"
|
||||||
|
case Dot11InformationElementIDSTAAvailability:
|
||||||
|
return "STA Availability"
|
||||||
|
case Dot11InformationElementIDDMGTSPEC:
|
||||||
|
return "DMG TSPEC"
|
||||||
|
case Dot11InformationElementIDNextDMGATI:
|
||||||
|
return "Next DMG ATI"
|
||||||
|
case Dot11InformationElementIDDMSCapabilities:
|
||||||
|
return "DMG Capabilities"
|
||||||
|
case Dot11InformationElementIDCiscoUnknown95:
|
||||||
|
return "Cisco Unknown 95"
|
||||||
|
case Dot11InformationElementIDVendor2:
|
||||||
|
return "Vendor Specific"
|
||||||
|
case Dot11InformationElementIDDMGOperating:
|
||||||
|
return "DMG Operating"
|
||||||
|
case Dot11InformationElementIDDMGBSSParamChange:
|
||||||
|
return "DMG BSS Parameter Change"
|
||||||
|
case Dot11InformationElementIDDMGBeamRefinement:
|
||||||
|
return "DMG Beam Refinement"
|
||||||
|
case Dot11InformationElementIDChannelMeasFeedback:
|
||||||
|
return "Channel Measurement Feedback"
|
||||||
|
case Dot11InformationElementIDAwakeWindow:
|
||||||
|
return "Awake Window"
|
||||||
|
case Dot11InformationElementIDMultiBand:
|
||||||
|
return "Multi Band"
|
||||||
|
case Dot11InformationElementIDADDBAExtension:
|
||||||
|
return "ADDBA Extension"
|
||||||
|
case Dot11InformationElementIDNEXTPCPList:
|
||||||
|
return "NEXTPCP List"
|
||||||
|
case Dot11InformationElementIDPCPHandover:
|
||||||
|
return "PCP Handover"
|
||||||
|
case Dot11InformationElementIDDMGLinkMargin:
|
||||||
|
return "DMG Link Margin"
|
||||||
|
case Dot11InformationElementIDSwitchingStream:
|
||||||
|
return "Switching Stream"
|
||||||
|
case Dot11InformationElementIDSessionTransmission:
|
||||||
|
return "Session Transmission"
|
||||||
|
case Dot11InformationElementIDDynamicTonePairReport:
|
||||||
|
return "Dynamic Tone Pairing Report"
|
||||||
|
case Dot11InformationElementIDClusterReport:
|
||||||
|
return "Cluster Report"
|
||||||
|
case Dot11InformationElementIDRelayCapabilities:
|
||||||
|
return "Relay Capabilities"
|
||||||
|
case Dot11InformationElementIDRelayTransferParameter:
|
||||||
|
return "Relay Transfer Parameter"
|
||||||
|
case Dot11InformationElementIDBeamlinkMaintenance:
|
||||||
|
return "Beamlink Maintenance"
|
||||||
|
case Dot11InformationElementIDMultipleMacSublayers:
|
||||||
|
return "Multiple MAC Sublayers"
|
||||||
|
case Dot11InformationElementIDUPID:
|
||||||
|
return "U-PID"
|
||||||
|
case Dot11InformationElementIDDMGLinkAdaptionAck:
|
||||||
|
return "DMG Link Adaption Acknowledgment"
|
||||||
|
case Dot11InformationElementIDSymbolProprietary:
|
||||||
|
return "Symbol Proprietary"
|
||||||
|
case Dot11InformationElementIDMCCAOPAdvertOverview:
|
||||||
|
return "MCCAOP Advertisement Overview"
|
||||||
|
case Dot11InformationElementIDQuietPeriodRequest:
|
||||||
|
return "Quiet Period Request"
|
||||||
|
case Dot11InformationElementIDQuietPeriodResponse:
|
||||||
|
return "Quiet Period Response"
|
||||||
|
case Dot11InformationElementIDECPACPolicy:
|
||||||
|
return "ECPAC Policy"
|
||||||
|
case Dot11InformationElementIDClusterTimeOffset:
|
||||||
|
return "Cluster Time Offset"
|
||||||
|
case Dot11InformationElementIDAntennaSectorID:
|
||||||
|
return "Antenna Sector ID"
|
||||||
|
case Dot11InformationElementIDVHTCapabilities:
|
||||||
|
return "VHT Capabilities (IEEE Std 802.11ac/D3.1)"
|
||||||
|
case Dot11InformationElementIDVHTOperation:
|
||||||
|
return "VHT Operation (IEEE Std 802.11ac/D3.1)"
|
||||||
|
case Dot11InformationElementIDExtendedBSSLoad:
|
||||||
|
return "Extended BSS Load"
|
||||||
|
case Dot11InformationElementIDWideBWChannelSwitch:
|
||||||
|
return "Wide Bandwidth Channel Switch"
|
||||||
|
case Dot11InformationElementIDVHTTxPowerEnvelope:
|
||||||
|
return "VHT Tx Power Envelope (IEEE Std 802.11ac/D5.0)"
|
||||||
|
case Dot11InformationElementIDChannelSwitchWrapper:
|
||||||
|
return "Channel Switch Wrapper"
|
||||||
|
case Dot11InformationElementIDOperatingModeNotification:
|
||||||
|
return "Operating Mode Notification"
|
||||||
case Dot11InformationElementIDVendor:
|
case Dot11InformationElementIDVendor:
|
||||||
return "Vendor"
|
return "Vendor"
|
||||||
case Dot11InformationElementIDReserved:
|
|
||||||
return "Reserved"
|
|
||||||
default:
|
default:
|
||||||
return "Unknown information element id"
|
return "Unknown information element id"
|
||||||
}
|
}
|
||||||
|
@ -303,7 +751,7 @@ func (a Dot11InformationElementID) String() string {
|
||||||
|
|
||||||
// Dot11 provides an IEEE 802.11 base packet header.
|
// Dot11 provides an IEEE 802.11 base packet header.
|
||||||
// See http://standards.ieee.org/findstds/standard/802.11-2012.html
|
// See http://standards.ieee.org/findstds/standard/802.11-2012.html
|
||||||
// for excrutiating detail.
|
// for excruciating detail.
|
||||||
type Dot11 struct {
|
type Dot11 struct {
|
||||||
BaseLayer
|
BaseLayer
|
||||||
Type Dot11Type
|
Type Dot11Type
|
||||||
|
@ -317,23 +765,138 @@ type Dot11 struct {
|
||||||
SequenceNumber uint16
|
SequenceNumber uint16
|
||||||
FragmentNumber uint16
|
FragmentNumber uint16
|
||||||
Checksum uint32
|
Checksum uint32
|
||||||
|
QOS *Dot11QOS
|
||||||
|
HTControl *Dot11HTControl
|
||||||
|
DataLayer gopacket.Layer
|
||||||
|
}
|
||||||
|
|
||||||
|
type Dot11QOS struct {
|
||||||
|
TID uint8 /* Traffic IDentifier */
|
||||||
|
EOSP bool /* End of service period */
|
||||||
|
AckPolicy Dot11AckPolicy
|
||||||
|
TXOP uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type Dot11HTControl struct {
|
||||||
|
ACConstraint bool
|
||||||
|
RDGMorePPDU bool
|
||||||
|
|
||||||
|
VHT *Dot11HTControlVHT
|
||||||
|
HT *Dot11HTControlHT
|
||||||
|
}
|
||||||
|
|
||||||
|
type Dot11HTControlHT struct {
|
||||||
|
LinkAdapationControl *Dot11LinkAdapationControl
|
||||||
|
CalibrationPosition uint8
|
||||||
|
CalibrationSequence uint8
|
||||||
|
CSISteering uint8
|
||||||
|
NDPAnnouncement bool
|
||||||
|
DEI bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type Dot11HTControlVHT struct {
|
||||||
|
MRQ bool
|
||||||
|
UnsolicitedMFB bool
|
||||||
|
MSI *uint8
|
||||||
|
MFB Dot11HTControlMFB
|
||||||
|
CompressedMSI *uint8
|
||||||
|
STBCIndication bool
|
||||||
|
MFSI *uint8
|
||||||
|
GID *uint8
|
||||||
|
CodingType *Dot11CodingType
|
||||||
|
FbTXBeamformed bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type Dot11HTControlMFB struct {
|
||||||
|
NumSTS uint8
|
||||||
|
VHTMCS uint8
|
||||||
|
BW uint8
|
||||||
|
SNR int8
|
||||||
|
}
|
||||||
|
|
||||||
|
type Dot11LinkAdapationControl struct {
|
||||||
|
TRQ bool
|
||||||
|
MRQ bool
|
||||||
|
MSI uint8
|
||||||
|
MFSI uint8
|
||||||
|
ASEL *Dot11ASEL
|
||||||
|
MFB *uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type Dot11ASEL struct {
|
||||||
|
Command uint8
|
||||||
|
Data uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type Dot11CodingType uint8
|
||||||
|
|
||||||
|
const (
|
||||||
|
Dot11CodingTypeBCC = 0
|
||||||
|
Dot11CodingTypeLDPC = 1
|
||||||
|
)
|
||||||
|
|
||||||
|
func (a Dot11CodingType) String() string {
|
||||||
|
switch a {
|
||||||
|
case Dot11CodingTypeBCC:
|
||||||
|
return "BCC"
|
||||||
|
case Dot11CodingTypeLDPC:
|
||||||
|
return "LDPC"
|
||||||
|
default:
|
||||||
|
return "Unknown coding type"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Dot11HTControlMFB) NoFeedBackPresent() bool {
|
||||||
|
return m.VHTMCS == 15 && m.NumSTS == 7
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeDot11(data []byte, p gopacket.PacketBuilder) error {
|
func decodeDot11(data []byte, p gopacket.PacketBuilder) error {
|
||||||
d := &Dot11{}
|
d := &Dot11{}
|
||||||
return decodingLayerDecoder(d, data, p)
|
err := d.DecodeFromBytes(data, p)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
p.AddLayer(d)
|
||||||
|
if d.DataLayer != nil {
|
||||||
|
p.AddLayer(d.DataLayer)
|
||||||
|
}
|
||||||
|
return p.NextDecoder(d.NextLayerType())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Dot11) LayerType() gopacket.LayerType { return LayerTypeDot11 }
|
func (m *Dot11) LayerType() gopacket.LayerType { return LayerTypeDot11 }
|
||||||
func (m *Dot11) CanDecode() gopacket.LayerClass { return LayerTypeDot11 }
|
func (m *Dot11) CanDecode() gopacket.LayerClass { return LayerTypeDot11 }
|
||||||
func (m *Dot11) NextLayerType() gopacket.LayerType {
|
func (m *Dot11) NextLayerType() gopacket.LayerType {
|
||||||
if m.Flags.WEP() {
|
if m.DataLayer != nil {
|
||||||
return (LayerTypeDot11WEP)
|
if m.Flags.WEP() {
|
||||||
|
return LayerTypeDot11WEP
|
||||||
|
}
|
||||||
|
return m.DataLayer.(gopacket.DecodingLayer).NextLayerType()
|
||||||
}
|
}
|
||||||
|
|
||||||
return m.Type.LayerType()
|
return m.Type.LayerType()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func createU8(x uint8) *uint8 {
|
||||||
|
return &x
|
||||||
|
}
|
||||||
|
|
||||||
|
var dataDecodeMap = map[Dot11Type]func() gopacket.DecodingLayer{
|
||||||
|
Dot11TypeData: func() gopacket.DecodingLayer { return &Dot11Data{} },
|
||||||
|
Dot11TypeDataCFAck: func() gopacket.DecodingLayer { return &Dot11DataCFAck{} },
|
||||||
|
Dot11TypeDataCFPoll: func() gopacket.DecodingLayer { return &Dot11DataCFPoll{} },
|
||||||
|
Dot11TypeDataCFAckPoll: func() gopacket.DecodingLayer { return &Dot11DataCFAckPoll{} },
|
||||||
|
Dot11TypeDataNull: func() gopacket.DecodingLayer { return &Dot11DataNull{} },
|
||||||
|
Dot11TypeDataCFAckNoData: func() gopacket.DecodingLayer { return &Dot11DataCFAckNoData{} },
|
||||||
|
Dot11TypeDataCFPollNoData: func() gopacket.DecodingLayer { return &Dot11DataCFPollNoData{} },
|
||||||
|
Dot11TypeDataCFAckPollNoData: func() gopacket.DecodingLayer { return &Dot11DataCFAckPollNoData{} },
|
||||||
|
Dot11TypeDataQOSData: func() gopacket.DecodingLayer { return &Dot11DataQOSData{} },
|
||||||
|
Dot11TypeDataQOSDataCFAck: func() gopacket.DecodingLayer { return &Dot11DataQOSDataCFAck{} },
|
||||||
|
Dot11TypeDataQOSDataCFPoll: func() gopacket.DecodingLayer { return &Dot11DataQOSDataCFPoll{} },
|
||||||
|
Dot11TypeDataQOSDataCFAckPoll: func() gopacket.DecodingLayer { return &Dot11DataQOSDataCFAckPoll{} },
|
||||||
|
Dot11TypeDataQOSNull: func() gopacket.DecodingLayer { return &Dot11DataQOSNull{} },
|
||||||
|
Dot11TypeDataQOSCFPollNoData: func() gopacket.DecodingLayer { return &Dot11DataQOSCFPollNoData{} },
|
||||||
|
Dot11TypeDataQOSCFAckPollNoData: func() gopacket.DecodingLayer { return &Dot11DataQOSCFAckPollNoData{} },
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Dot11) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
|
func (m *Dot11) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
|
||||||
if len(data) < 10 {
|
if len(data) < 10 {
|
||||||
df.SetTruncated()
|
df.SetTruncated()
|
||||||
|
@ -385,7 +948,112 @@ func (m *Dot11) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
|
||||||
offset += 6
|
offset += 6
|
||||||
}
|
}
|
||||||
|
|
||||||
m.BaseLayer = BaseLayer{Contents: data[0:offset], Payload: data[offset : len(data)-4]}
|
if m.Type.QOS() {
|
||||||
|
if len(data) < offset+2 {
|
||||||
|
df.SetTruncated()
|
||||||
|
return fmt.Errorf("Dot11 length %v too short, %v required", len(data), offset+6)
|
||||||
|
}
|
||||||
|
m.QOS = &Dot11QOS{
|
||||||
|
TID: (uint8(data[offset]) & 0x0F),
|
||||||
|
EOSP: (uint8(data[offset]) & 0x10) == 0x10,
|
||||||
|
AckPolicy: Dot11AckPolicy((uint8(data[offset]) & 0x60) >> 5),
|
||||||
|
TXOP: uint8(data[offset+1]),
|
||||||
|
}
|
||||||
|
offset += 2
|
||||||
|
}
|
||||||
|
if m.Flags.Order() && (m.Type.QOS() || mainType == Dot11TypeMgmt) {
|
||||||
|
if len(data) < offset+4 {
|
||||||
|
df.SetTruncated()
|
||||||
|
return fmt.Errorf("Dot11 length %v too short, %v required", len(data), offset+6)
|
||||||
|
}
|
||||||
|
|
||||||
|
htc := &Dot11HTControl{
|
||||||
|
ACConstraint: data[offset+3]&0x40 != 0,
|
||||||
|
RDGMorePPDU: data[offset+3]&0x80 != 0,
|
||||||
|
}
|
||||||
|
m.HTControl = htc
|
||||||
|
|
||||||
|
if data[offset]&0x1 != 0 { // VHT Variant
|
||||||
|
vht := &Dot11HTControlVHT{}
|
||||||
|
htc.VHT = vht
|
||||||
|
vht.MRQ = data[offset]&0x4 != 0
|
||||||
|
vht.UnsolicitedMFB = data[offset+3]&0x20 != 0
|
||||||
|
vht.MFB = Dot11HTControlMFB{
|
||||||
|
NumSTS: uint8(data[offset+1] >> 1 & 0x7),
|
||||||
|
VHTMCS: uint8(data[offset+1] >> 4 & 0xF),
|
||||||
|
BW: uint8(data[offset+2] & 0x3),
|
||||||
|
SNR: int8((-(data[offset+2] >> 2 & 0x20))+data[offset+2]>>2&0x1F) + 22,
|
||||||
|
}
|
||||||
|
|
||||||
|
if vht.UnsolicitedMFB {
|
||||||
|
if !vht.MFB.NoFeedBackPresent() {
|
||||||
|
vht.CompressedMSI = createU8(data[offset] >> 3 & 0x3)
|
||||||
|
vht.STBCIndication = data[offset]&0x20 != 0
|
||||||
|
vht.CodingType = (*Dot11CodingType)(createU8(data[offset+3] >> 3 & 0x1))
|
||||||
|
vht.FbTXBeamformed = data[offset+3]&0x10 != 0
|
||||||
|
vht.GID = createU8(
|
||||||
|
data[offset]>>6 +
|
||||||
|
(data[offset+1] & 0x1 << 2) +
|
||||||
|
data[offset+3]&0x7<<3)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if vht.MRQ {
|
||||||
|
vht.MSI = createU8((data[offset] >> 3) & 0x07)
|
||||||
|
}
|
||||||
|
vht.MFSI = createU8(data[offset]>>6 + (data[offset+1] & 0x1 << 2))
|
||||||
|
}
|
||||||
|
|
||||||
|
} else { // HT Variant
|
||||||
|
ht := &Dot11HTControlHT{}
|
||||||
|
htc.HT = ht
|
||||||
|
|
||||||
|
lac := &Dot11LinkAdapationControl{}
|
||||||
|
ht.LinkAdapationControl = lac
|
||||||
|
lac.TRQ = data[offset]&0x2 != 0
|
||||||
|
lac.MFSI = data[offset]>>6&0x3 + data[offset+1]&0x1<<3
|
||||||
|
if data[offset]&0x3C == 0x38 { // ASEL
|
||||||
|
lac.ASEL = &Dot11ASEL{
|
||||||
|
Command: data[offset+1] >> 1 & 0x7,
|
||||||
|
Data: data[offset+1] >> 4 & 0xF,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lac.MRQ = data[offset]&0x4 != 0
|
||||||
|
if lac.MRQ {
|
||||||
|
lac.MSI = data[offset] >> 3 & 0x7
|
||||||
|
}
|
||||||
|
lac.MFB = createU8(data[offset+1] >> 1)
|
||||||
|
}
|
||||||
|
ht.CalibrationPosition = data[offset+2] & 0x3
|
||||||
|
ht.CalibrationSequence = data[offset+2] >> 2 & 0x3
|
||||||
|
ht.CSISteering = data[offset+2] >> 6 & 0x3
|
||||||
|
ht.NDPAnnouncement = data[offset+3]&0x1 != 0
|
||||||
|
if mainType != Dot11TypeMgmt {
|
||||||
|
ht.DEI = data[offset+3]&0x20 != 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
offset += 4
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(data) < offset+4 {
|
||||||
|
df.SetTruncated()
|
||||||
|
return fmt.Errorf("Dot11 length %v too short, %v required", len(data), offset+4)
|
||||||
|
}
|
||||||
|
|
||||||
|
m.BaseLayer = BaseLayer{
|
||||||
|
Contents: data[0:offset],
|
||||||
|
Payload: data[offset : len(data)-4],
|
||||||
|
}
|
||||||
|
|
||||||
|
if mainType == Dot11TypeData {
|
||||||
|
l := dataDecodeMap[m.Type]()
|
||||||
|
err := l.DecodeFromBytes(m.BaseLayer.Payload, df)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
m.DataLayer = l.(gopacket.Layer)
|
||||||
|
}
|
||||||
|
|
||||||
m.Checksum = binary.LittleEndian.Uint32(data[len(data)-4 : len(data)])
|
m.Checksum = binary.LittleEndian.Uint32(data[len(data)-4 : len(data)])
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -474,7 +1142,7 @@ type Dot11WEP struct {
|
||||||
BaseLayer
|
BaseLayer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Dot11WEP) NextLayerType() gopacket.LayerType { return LayerTypeLLC }
|
func (m *Dot11WEP) NextLayerType() gopacket.LayerType { return gopacket.LayerTypePayload }
|
||||||
|
|
||||||
func (m *Dot11WEP) LayerType() gopacket.LayerType { return LayerTypeDot11WEP }
|
func (m *Dot11WEP) LayerType() gopacket.LayerType { return LayerTypeDot11WEP }
|
||||||
func (m *Dot11WEP) CanDecode() gopacket.LayerClass { return LayerTypeDot11WEP }
|
func (m *Dot11WEP) CanDecode() gopacket.LayerClass { return LayerTypeDot11WEP }
|
||||||
|
@ -493,7 +1161,9 @@ type Dot11Data struct {
|
||||||
BaseLayer
|
BaseLayer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Dot11Data) NextLayerType() gopacket.LayerType { return LayerTypeLLC }
|
func (m *Dot11Data) NextLayerType() gopacket.LayerType {
|
||||||
|
return LayerTypeLLC
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Dot11Data) LayerType() gopacket.LayerType { return LayerTypeDot11Data }
|
func (m *Dot11Data) LayerType() gopacket.LayerType { return LayerTypeDot11Data }
|
||||||
func (m *Dot11Data) CanDecode() gopacket.LayerClass { return LayerTypeDot11Data }
|
func (m *Dot11Data) CanDecode() gopacket.LayerClass { return LayerTypeDot11Data }
|
||||||
|
@ -618,23 +1288,10 @@ func (m *Dot11DataCFAckPollNoData) DecodeFromBytes(data []byte, df gopacket.Deco
|
||||||
|
|
||||||
type Dot11DataQOS struct {
|
type Dot11DataQOS struct {
|
||||||
Dot11Ctrl
|
Dot11Ctrl
|
||||||
TID uint8 /* Traffic IDentifier */
|
|
||||||
EOSP bool /* End of service period */
|
|
||||||
AckPolicy Dot11AckPolicy
|
|
||||||
TXOP uint8
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Dot11DataQOS) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
|
func (m *Dot11DataQOS) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
|
||||||
if len(data) < 4 {
|
m.BaseLayer = BaseLayer{Payload: data}
|
||||||
df.SetTruncated()
|
|
||||||
return fmt.Errorf("Dot11DataQOS length %v too short, %v required", len(data), 4)
|
|
||||||
}
|
|
||||||
m.TID = (uint8(data[0]) & 0x0F)
|
|
||||||
m.EOSP = (uint8(data[0]) & 0x10) == 0x10
|
|
||||||
m.AckPolicy = Dot11AckPolicy((uint8(data[0]) & 0x60) >> 5)
|
|
||||||
m.TXOP = uint8(data[1])
|
|
||||||
// TODO: Mesh Control bytes 2:4
|
|
||||||
m.BaseLayer = BaseLayer{Contents: data[0:4], Payload: data[4:]}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -802,7 +1459,7 @@ func (m *Dot11InformationElement) DecodeFromBytes(data []byte, df gopacket.Decod
|
||||||
|
|
||||||
func (d *Dot11InformationElement) String() string {
|
func (d *Dot11InformationElement) String() string {
|
||||||
if d.ID == 0 {
|
if d.ID == 0 {
|
||||||
return fmt.Sprintf("802.11 Information Element (SSID: %v)", string(d.Info))
|
return fmt.Sprintf("802.11 Information Element (ID: %v, Length: %v, SSID: %v)", d.ID, d.Length, string(d.Info))
|
||||||
} else if d.ID == 1 {
|
} else if d.ID == 1 {
|
||||||
rates := ""
|
rates := ""
|
||||||
for i := 0; i < len(d.Info); i++ {
|
for i := 0; i < len(d.Info); i++ {
|
||||||
|
@ -812,9 +1469,9 @@ func (d *Dot11InformationElement) String() string {
|
||||||
rates += fmt.Sprintf("%.1f* ", float32(d.Info[i]&0x7F)*0.5)
|
rates += fmt.Sprintf("%.1f* ", float32(d.Info[i]&0x7F)*0.5)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("802.11 Information Element (Rates: %s Mbit)", rates)
|
return fmt.Sprintf("802.11 Information Element (ID: %v, Length: %v, Rates: %s Mbit)", d.ID, d.Length, rates)
|
||||||
} else if d.ID == 221 {
|
} else if d.ID == 221 {
|
||||||
return fmt.Sprintf("802.11 Information Element (Vendor: ID: %v, Length: %v, OUI: %X, Info: %X)", d.ID, d.Length, d.OUI, d.Info)
|
return fmt.Sprintf("802.11 Information Element (ID: %v, Length: %v, OUI: %X, Info: %X)", d.ID, d.Length, d.OUI, d.Info)
|
||||||
} else {
|
} else {
|
||||||
return fmt.Sprintf("802.11 Information Element (ID: %v, Length: %v, Info: %X)", d.ID, d.Length, d.Info)
|
return fmt.Sprintf("802.11 Information Element (ID: %v, Length: %v, Info: %X)", d.ID, d.Length, d.Info)
|
||||||
}
|
}
|
||||||
|
|
236
vendor/github.com/google/gopacket/layers/eapol.go
generated
vendored
236
vendor/github.com/google/gopacket/layers/eapol.go
generated
vendored
|
@ -8,6 +8,7 @@ package layers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -55,3 +56,238 @@ func decodeEAPOL(data []byte, p gopacket.PacketBuilder) error {
|
||||||
e := &EAPOL{}
|
e := &EAPOL{}
|
||||||
return decodingLayerDecoder(e, data, p)
|
return decodingLayerDecoder(e, data, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EAPOLKeyDescriptorType is an enumeration of key descriptor types
|
||||||
|
// as specified by 802.1x in the EAPOL-Key frame
|
||||||
|
type EAPOLKeyDescriptorType uint8
|
||||||
|
|
||||||
|
// Enumeration of EAPOLKeyDescriptorType
|
||||||
|
const (
|
||||||
|
EAPOLKeyDescriptorTypeRC4 EAPOLKeyDescriptorType = 1
|
||||||
|
EAPOLKeyDescriptorTypeDot11 EAPOLKeyDescriptorType = 2
|
||||||
|
EAPOLKeyDescriptorTypeWPA EAPOLKeyDescriptorType = 254
|
||||||
|
)
|
||||||
|
|
||||||
|
func (kdt EAPOLKeyDescriptorType) String() string {
|
||||||
|
switch kdt {
|
||||||
|
case EAPOLKeyDescriptorTypeRC4:
|
||||||
|
return "RC4"
|
||||||
|
case EAPOLKeyDescriptorTypeDot11:
|
||||||
|
return "802.11"
|
||||||
|
case EAPOLKeyDescriptorTypeWPA:
|
||||||
|
return "WPA"
|
||||||
|
default:
|
||||||
|
return fmt.Sprintf("unknown descriptor type %d", kdt)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// EAPOLKeyDescriptorVersion is an enumeration of versions specifying the
|
||||||
|
// encryption algorithm for the key data and the authentication for the
|
||||||
|
// message integrity code (MIC)
|
||||||
|
type EAPOLKeyDescriptorVersion uint8
|
||||||
|
|
||||||
|
// Enumeration of EAPOLKeyDescriptorVersion
|
||||||
|
const (
|
||||||
|
EAPOLKeyDescriptorVersionOther EAPOLKeyDescriptorVersion = 0
|
||||||
|
EAPOLKeyDescriptorVersionRC4HMACMD5 EAPOLKeyDescriptorVersion = 1
|
||||||
|
EAPOLKeyDescriptorVersionAESHMACSHA1 EAPOLKeyDescriptorVersion = 2
|
||||||
|
EAPOLKeyDescriptorVersionAES128CMAC EAPOLKeyDescriptorVersion = 3
|
||||||
|
)
|
||||||
|
|
||||||
|
func (v EAPOLKeyDescriptorVersion) String() string {
|
||||||
|
switch v {
|
||||||
|
case EAPOLKeyDescriptorVersionOther:
|
||||||
|
return "Other"
|
||||||
|
case EAPOLKeyDescriptorVersionRC4HMACMD5:
|
||||||
|
return "RC4-HMAC-MD5"
|
||||||
|
case EAPOLKeyDescriptorVersionAESHMACSHA1:
|
||||||
|
return "AES-HMAC-SHA1-128"
|
||||||
|
case EAPOLKeyDescriptorVersionAES128CMAC:
|
||||||
|
return "AES-128-CMAC"
|
||||||
|
default:
|
||||||
|
return fmt.Sprintf("unknown version %d", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// EAPOLKeyType is an enumeration of key derivation types describing
|
||||||
|
// the purpose of the keys being derived.
|
||||||
|
type EAPOLKeyType uint8
|
||||||
|
|
||||||
|
// Enumeration of EAPOLKeyType
|
||||||
|
const (
|
||||||
|
EAPOLKeyTypeGroupSMK EAPOLKeyType = 0
|
||||||
|
EAPOLKeyTypePairwise EAPOLKeyType = 1
|
||||||
|
)
|
||||||
|
|
||||||
|
func (kt EAPOLKeyType) String() string {
|
||||||
|
switch kt {
|
||||||
|
case EAPOLKeyTypeGroupSMK:
|
||||||
|
return "Group/SMK"
|
||||||
|
case EAPOLKeyTypePairwise:
|
||||||
|
return "Pairwise"
|
||||||
|
default:
|
||||||
|
return fmt.Sprintf("unknown key type %d", kt)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// EAPOLKey defines an EAPOL-Key frame for 802.1x authentication
|
||||||
|
type EAPOLKey struct {
|
||||||
|
BaseLayer
|
||||||
|
KeyDescriptorType EAPOLKeyDescriptorType
|
||||||
|
KeyDescriptorVersion EAPOLKeyDescriptorVersion
|
||||||
|
KeyType EAPOLKeyType
|
||||||
|
KeyIndex uint8
|
||||||
|
Install bool
|
||||||
|
KeyACK bool
|
||||||
|
KeyMIC bool
|
||||||
|
Secure bool
|
||||||
|
MICError bool
|
||||||
|
Request bool
|
||||||
|
HasEncryptedKeyData bool
|
||||||
|
SMKMessage bool
|
||||||
|
KeyLength uint16
|
||||||
|
ReplayCounter uint64
|
||||||
|
Nonce []byte
|
||||||
|
IV []byte
|
||||||
|
RSC uint64
|
||||||
|
ID uint64
|
||||||
|
MIC []byte
|
||||||
|
KeyDataLength uint16
|
||||||
|
EncryptedKeyData []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// LayerType returns LayerTypeEAPOLKey.
|
||||||
|
func (ek *EAPOLKey) LayerType() gopacket.LayerType {
|
||||||
|
return LayerTypeEAPOLKey
|
||||||
|
}
|
||||||
|
|
||||||
|
// NextLayerType returns layers.LayerTypeDot11InformationElement if the key
|
||||||
|
// data exists and is unencrypted, otherwise it does not expect a next layer.
|
||||||
|
func (ek *EAPOLKey) NextLayerType() gopacket.LayerType {
|
||||||
|
if !ek.HasEncryptedKeyData && ek.KeyDataLength > 0 {
|
||||||
|
return LayerTypeDot11InformationElement
|
||||||
|
}
|
||||||
|
return gopacket.LayerTypePayload
|
||||||
|
}
|
||||||
|
|
||||||
|
const eapolKeyFrameLen = 95
|
||||||
|
|
||||||
|
// DecodeFromBytes decodes the given bytes into this layer.
|
||||||
|
func (ek *EAPOLKey) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
|
||||||
|
if len(data) < eapolKeyFrameLen {
|
||||||
|
df.SetTruncated()
|
||||||
|
return fmt.Errorf("EAPOLKey length %v too short, %v required",
|
||||||
|
len(data), eapolKeyFrameLen)
|
||||||
|
}
|
||||||
|
|
||||||
|
ek.KeyDescriptorType = EAPOLKeyDescriptorType(data[0])
|
||||||
|
|
||||||
|
info := binary.BigEndian.Uint16(data[1:3])
|
||||||
|
ek.KeyDescriptorVersion = EAPOLKeyDescriptorVersion(info & 0x0007)
|
||||||
|
ek.KeyType = EAPOLKeyType((info & 0x0008) >> 3)
|
||||||
|
ek.KeyIndex = uint8((info & 0x0030) >> 4)
|
||||||
|
ek.Install = (info & 0x0040) != 0
|
||||||
|
ek.KeyACK = (info & 0x0080) != 0
|
||||||
|
ek.KeyMIC = (info & 0x0100) != 0
|
||||||
|
ek.Secure = (info & 0x0200) != 0
|
||||||
|
ek.MICError = (info & 0x0400) != 0
|
||||||
|
ek.Request = (info & 0x0800) != 0
|
||||||
|
ek.HasEncryptedKeyData = (info & 0x1000) != 0
|
||||||
|
ek.SMKMessage = (info & 0x2000) != 0
|
||||||
|
|
||||||
|
ek.KeyLength = binary.BigEndian.Uint16(data[3:5])
|
||||||
|
ek.ReplayCounter = binary.BigEndian.Uint64(data[5:13])
|
||||||
|
|
||||||
|
ek.Nonce = data[13:45]
|
||||||
|
ek.IV = data[45:61]
|
||||||
|
ek.RSC = binary.BigEndian.Uint64(data[61:69])
|
||||||
|
ek.ID = binary.BigEndian.Uint64(data[69:77])
|
||||||
|
ek.MIC = data[77:93]
|
||||||
|
|
||||||
|
ek.KeyDataLength = binary.BigEndian.Uint16(data[93:95])
|
||||||
|
|
||||||
|
totalLength := eapolKeyFrameLen + int(ek.KeyDataLength)
|
||||||
|
if len(data) < totalLength {
|
||||||
|
df.SetTruncated()
|
||||||
|
return fmt.Errorf("EAPOLKey data length %d too short, %d required",
|
||||||
|
len(data)-eapolKeyFrameLen, ek.KeyDataLength)
|
||||||
|
}
|
||||||
|
|
||||||
|
if ek.HasEncryptedKeyData {
|
||||||
|
ek.EncryptedKeyData = data[eapolKeyFrameLen:totalLength]
|
||||||
|
ek.BaseLayer = BaseLayer{
|
||||||
|
Contents: data[:totalLength],
|
||||||
|
Payload: data[totalLength:],
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ek.BaseLayer = BaseLayer{
|
||||||
|
Contents: data[:eapolKeyFrameLen],
|
||||||
|
Payload: data[eapolKeyFrameLen:],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SerializeTo writes the serialized form of this layer into the
|
||||||
|
// SerializationBuffer, implementing gopacket.SerializableLayer.
|
||||||
|
// See the docs for gopacket.SerializableLayer for more info.
|
||||||
|
func (ek *EAPOLKey) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
|
||||||
|
buf, err := b.PrependBytes(eapolKeyFrameLen + len(ek.EncryptedKeyData))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
buf[0] = byte(ek.KeyDescriptorType)
|
||||||
|
|
||||||
|
var info uint16
|
||||||
|
info |= uint16(ek.KeyDescriptorVersion)
|
||||||
|
info |= uint16(ek.KeyType) << 3
|
||||||
|
info |= uint16(ek.KeyIndex) << 4
|
||||||
|
if ek.Install {
|
||||||
|
info |= 0x0040
|
||||||
|
}
|
||||||
|
if ek.KeyACK {
|
||||||
|
info |= 0x0080
|
||||||
|
}
|
||||||
|
if ek.KeyMIC {
|
||||||
|
info |= 0x0100
|
||||||
|
}
|
||||||
|
if ek.Secure {
|
||||||
|
info |= 0x0200
|
||||||
|
}
|
||||||
|
if ek.MICError {
|
||||||
|
info |= 0x0400
|
||||||
|
}
|
||||||
|
if ek.Request {
|
||||||
|
info |= 0x0800
|
||||||
|
}
|
||||||
|
if ek.HasEncryptedKeyData {
|
||||||
|
info |= 0x1000
|
||||||
|
}
|
||||||
|
if ek.SMKMessage {
|
||||||
|
info |= 0x2000
|
||||||
|
}
|
||||||
|
binary.BigEndian.PutUint16(buf[1:3], info)
|
||||||
|
|
||||||
|
binary.BigEndian.PutUint16(buf[3:5], ek.KeyLength)
|
||||||
|
binary.BigEndian.PutUint64(buf[5:13], ek.ReplayCounter)
|
||||||
|
|
||||||
|
copy(buf[13:45], ek.Nonce)
|
||||||
|
copy(buf[45:61], ek.IV)
|
||||||
|
binary.BigEndian.PutUint64(buf[61:69], ek.RSC)
|
||||||
|
binary.BigEndian.PutUint64(buf[69:77], ek.ID)
|
||||||
|
copy(buf[77:93], ek.MIC)
|
||||||
|
|
||||||
|
binary.BigEndian.PutUint16(buf[93:95], ek.KeyDataLength)
|
||||||
|
if len(ek.EncryptedKeyData) > 0 {
|
||||||
|
copy(buf[95:95+len(ek.EncryptedKeyData)], ek.EncryptedKeyData)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func decodeEAPOLKey(data []byte, p gopacket.PacketBuilder) error {
|
||||||
|
ek := &EAPOLKey{}
|
||||||
|
return decodingLayerDecoder(ek, data, p)
|
||||||
|
}
|
||||||
|
|
176
vendor/github.com/google/gopacket/layers/enums.go
generated
vendored
176
vendor/github.com/google/gopacket/layers/enums.go
generated
vendored
|
@ -80,6 +80,7 @@ const (
|
||||||
IPProtocolICMPv6 IPProtocol = 58
|
IPProtocolICMPv6 IPProtocol = 58
|
||||||
IPProtocolNoNextHeader IPProtocol = 59
|
IPProtocolNoNextHeader IPProtocol = 59
|
||||||
IPProtocolIPv6Destination IPProtocol = 60
|
IPProtocolIPv6Destination IPProtocol = 60
|
||||||
|
IPProtocolOSPF IPProtocol = 89
|
||||||
IPProtocolIPIP IPProtocol = 94
|
IPProtocolIPIP IPProtocol = 94
|
||||||
IPProtocolEtherIP IPProtocol = 97
|
IPProtocolEtherIP IPProtocol = 97
|
||||||
IPProtocolVRRP IPProtocol = 112
|
IPProtocolVRRP IPProtocol = 112
|
||||||
|
@ -218,12 +219,17 @@ func (d Dot11Type) MainType() Dot11Type {
|
||||||
return d & dot11TypeMask
|
return d & dot11TypeMask
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d Dot11Type) QOS() bool {
|
||||||
|
return d&dot11QOSMask == Dot11TypeDataQOSData
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Dot11TypeMgmt Dot11Type = 0x00
|
Dot11TypeMgmt Dot11Type = 0x00
|
||||||
Dot11TypeCtrl Dot11Type = 0x01
|
Dot11TypeCtrl Dot11Type = 0x01
|
||||||
Dot11TypeData Dot11Type = 0x02
|
Dot11TypeData Dot11Type = 0x02
|
||||||
Dot11TypeReserved Dot11Type = 0x03
|
Dot11TypeReserved Dot11Type = 0x03
|
||||||
dot11TypeMask = 0x03
|
dot11TypeMask = 0x03
|
||||||
|
dot11QOSMask = 0x23
|
||||||
|
|
||||||
// The following are type/subtype conglomerations.
|
// The following are type/subtype conglomerations.
|
||||||
|
|
||||||
|
@ -271,107 +277,6 @@ const (
|
||||||
Dot11TypeDataQOSCFAckPollNoData Dot11Type = 0x3e
|
Dot11TypeDataQOSCFAckPollNoData Dot11Type = 0x3e
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
// Each of the following arrays contains mappings of how to handle enum
|
|
||||||
// values for various enum types in gopacket/layers.
|
|
||||||
//
|
|
||||||
// So, EthernetTypeMetadata[2] contains information on how to handle EthernetType
|
|
||||||
// 2, including which name to give it and which decoder to use to decode
|
|
||||||
// packet data of that type. These arrays are filled by default with all of the
|
|
||||||
// protocols gopacket/layers knows how to handle, but users of the library can
|
|
||||||
// add new decoders or override existing ones. For example, if you write a better
|
|
||||||
// TCP decoder, you can override IPProtocolMetadata[IPProtocolTCP].DecodeWith
|
|
||||||
// with your new decoder, and all gopacket/layers decoding will use your new
|
|
||||||
// decoder whenever they encounter that IPProtocol.
|
|
||||||
EthernetTypeMetadata [65536]EnumMetadata
|
|
||||||
IPProtocolMetadata [256]EnumMetadata
|
|
||||||
SCTPChunkTypeMetadata [256]EnumMetadata
|
|
||||||
PPPTypeMetadata [65536]EnumMetadata
|
|
||||||
PPPoECodeMetadata [256]EnumMetadata
|
|
||||||
LinkTypeMetadata [256]EnumMetadata
|
|
||||||
FDDIFrameControlMetadata [256]EnumMetadata
|
|
||||||
EAPOLTypeMetadata [256]EnumMetadata
|
|
||||||
ProtocolFamilyMetadata [256]EnumMetadata
|
|
||||||
Dot11TypeMetadata [256]EnumMetadata
|
|
||||||
USBTypeMetadata [256]EnumMetadata
|
|
||||||
)
|
|
||||||
|
|
||||||
func (a EthernetType) Decode(data []byte, p gopacket.PacketBuilder) error {
|
|
||||||
return EthernetTypeMetadata[a].DecodeWith.Decode(data, p)
|
|
||||||
}
|
|
||||||
func (a EthernetType) String() string {
|
|
||||||
return EthernetTypeMetadata[a].Name
|
|
||||||
}
|
|
||||||
func (a EthernetType) LayerType() gopacket.LayerType {
|
|
||||||
return EthernetTypeMetadata[a].LayerType
|
|
||||||
}
|
|
||||||
func (a IPProtocol) Decode(data []byte, p gopacket.PacketBuilder) error {
|
|
||||||
return IPProtocolMetadata[a].DecodeWith.Decode(data, p)
|
|
||||||
}
|
|
||||||
func (a IPProtocol) String() string {
|
|
||||||
return IPProtocolMetadata[a].Name
|
|
||||||
}
|
|
||||||
func (a IPProtocol) LayerType() gopacket.LayerType {
|
|
||||||
return IPProtocolMetadata[a].LayerType
|
|
||||||
}
|
|
||||||
func (a SCTPChunkType) Decode(data []byte, p gopacket.PacketBuilder) error {
|
|
||||||
return SCTPChunkTypeMetadata[a].DecodeWith.Decode(data, p)
|
|
||||||
}
|
|
||||||
func (a SCTPChunkType) String() string {
|
|
||||||
return SCTPChunkTypeMetadata[a].Name
|
|
||||||
}
|
|
||||||
func (a PPPType) Decode(data []byte, p gopacket.PacketBuilder) error {
|
|
||||||
return PPPTypeMetadata[a].DecodeWith.Decode(data, p)
|
|
||||||
}
|
|
||||||
func (a PPPType) String() string {
|
|
||||||
return PPPTypeMetadata[a].Name
|
|
||||||
}
|
|
||||||
func (a LinkType) Decode(data []byte, p gopacket.PacketBuilder) error {
|
|
||||||
return LinkTypeMetadata[a].DecodeWith.Decode(data, p)
|
|
||||||
}
|
|
||||||
func (a LinkType) String() string {
|
|
||||||
return LinkTypeMetadata[a].Name
|
|
||||||
}
|
|
||||||
func (a PPPoECode) Decode(data []byte, p gopacket.PacketBuilder) error {
|
|
||||||
return PPPoECodeMetadata[a].DecodeWith.Decode(data, p)
|
|
||||||
}
|
|
||||||
func (a PPPoECode) String() string {
|
|
||||||
return PPPoECodeMetadata[a].Name
|
|
||||||
}
|
|
||||||
func (a FDDIFrameControl) Decode(data []byte, p gopacket.PacketBuilder) error {
|
|
||||||
return FDDIFrameControlMetadata[a].DecodeWith.Decode(data, p)
|
|
||||||
}
|
|
||||||
func (a FDDIFrameControl) String() string {
|
|
||||||
return FDDIFrameControlMetadata[a].Name
|
|
||||||
}
|
|
||||||
func (a EAPOLType) Decode(data []byte, p gopacket.PacketBuilder) error {
|
|
||||||
return EAPOLTypeMetadata[a].DecodeWith.Decode(data, p)
|
|
||||||
}
|
|
||||||
func (a EAPOLType) String() string {
|
|
||||||
return EAPOLTypeMetadata[a].Name
|
|
||||||
}
|
|
||||||
func (a EAPOLType) LayerType() gopacket.LayerType {
|
|
||||||
return EAPOLTypeMetadata[a].LayerType
|
|
||||||
}
|
|
||||||
func (a ProtocolFamily) Decode(data []byte, p gopacket.PacketBuilder) error {
|
|
||||||
return ProtocolFamilyMetadata[a].DecodeWith.Decode(data, p)
|
|
||||||
}
|
|
||||||
func (a ProtocolFamily) String() string {
|
|
||||||
return ProtocolFamilyMetadata[a].Name
|
|
||||||
}
|
|
||||||
func (a ProtocolFamily) LayerType() gopacket.LayerType {
|
|
||||||
return ProtocolFamilyMetadata[a].LayerType
|
|
||||||
}
|
|
||||||
func (a Dot11Type) Decode(data []byte, p gopacket.PacketBuilder) error {
|
|
||||||
return Dot11TypeMetadata[a].DecodeWith.Decode(data, p)
|
|
||||||
}
|
|
||||||
func (a Dot11Type) String() string {
|
|
||||||
return Dot11TypeMetadata[a].Name
|
|
||||||
}
|
|
||||||
func (a Dot11Type) LayerType() gopacket.LayerType {
|
|
||||||
return Dot11TypeMetadata[a].LayerType
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode a raw v4 or v6 IP packet.
|
// Decode a raw v4 or v6 IP packet.
|
||||||
func decodeIPv4or6(data []byte, p gopacket.PacketBuilder) error {
|
func decodeIPv4or6(data []byte, p gopacket.PacketBuilder) error {
|
||||||
version := data[0] >> 4
|
version := data[0] >> 4
|
||||||
|
@ -384,53 +289,22 @@ func decodeIPv4or6(data []byte, p gopacket.PacketBuilder) error {
|
||||||
return fmt.Errorf("Invalid IP packet version %v", version)
|
return fmt.Errorf("Invalid IP packet version %v", version)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func initActualTypeData() {
|
||||||
// Here we link up all enumerations with their respective names and decoders.
|
// Each of the XXXTypeMetadata arrays contains mappings of how to handle enum
|
||||||
for i := 0; i < 65536; i++ {
|
// values for various enum types in gopacket/layers.
|
||||||
EthernetTypeMetadata[i] = EnumMetadata{
|
// These arrays are actually created by gen2.go and stored in
|
||||||
DecodeWith: errorFunc(fmt.Sprintf("Unable to decode ethernet type %d", i)),
|
// enums_generated.go.
|
||||||
Name: fmt.Sprintf("UnknownEthernetType(%d)", i),
|
//
|
||||||
}
|
// So, EthernetTypeMetadata[2] contains information on how to handle EthernetType
|
||||||
PPPTypeMetadata[i] = EnumMetadata{
|
// 2, including which name to give it and which decoder to use to decode
|
||||||
DecodeWith: errorFunc(fmt.Sprintf("Unable to decode PPP type %d", i)),
|
// packet data of that type. These arrays are filled by default with all of the
|
||||||
Name: fmt.Sprintf("UnknownPPPType(%d)", i),
|
// protocols gopacket/layers knows how to handle, but users of the library can
|
||||||
}
|
// add new decoders or override existing ones. For example, if you write a better
|
||||||
}
|
// TCP decoder, you can override IPProtocolMetadata[IPProtocolTCP].DecodeWith
|
||||||
for i := 0; i < 256; i++ {
|
// with your new decoder, and all gopacket/layers decoding will use your new
|
||||||
IPProtocolMetadata[i] = EnumMetadata{
|
// decoder whenever they encounter that IPProtocol.
|
||||||
DecodeWith: errorFunc(fmt.Sprintf("Unable to decode IP protocol %d", i)),
|
|
||||||
Name: fmt.Sprintf("UnknownIPProtocol(%d)", i),
|
|
||||||
}
|
|
||||||
SCTPChunkTypeMetadata[i] = EnumMetadata{
|
|
||||||
DecodeWith: errorFunc(fmt.Sprintf("Unable to decode SCTP chunk type %d", i)),
|
|
||||||
Name: fmt.Sprintf("UnknownSCTPChunkType(%d)", i),
|
|
||||||
}
|
|
||||||
PPPoECodeMetadata[i] = EnumMetadata{
|
|
||||||
DecodeWith: errorFunc(fmt.Sprintf("Unable to decode PPPoE code %d", i)),
|
|
||||||
Name: fmt.Sprintf("UnknownPPPoECode(%d)", i),
|
|
||||||
}
|
|
||||||
LinkTypeMetadata[i] = EnumMetadata{
|
|
||||||
DecodeWith: errorFunc(fmt.Sprintf("Unable to decode link type %d", i)),
|
|
||||||
Name: fmt.Sprintf("UnknownLinkType(%d)", i),
|
|
||||||
}
|
|
||||||
FDDIFrameControlMetadata[i] = EnumMetadata{
|
|
||||||
DecodeWith: errorFunc(fmt.Sprintf("Unable to decode FDDI frame control %d", i)),
|
|
||||||
Name: fmt.Sprintf("UnknownFDDIFrameControl(%d)", i),
|
|
||||||
}
|
|
||||||
EAPOLTypeMetadata[i] = EnumMetadata{
|
|
||||||
DecodeWith: errorFunc(fmt.Sprintf("Unable to decode EAPOL type %d", i)),
|
|
||||||
Name: fmt.Sprintf("UnknownEAPOLType(%d)", i),
|
|
||||||
}
|
|
||||||
ProtocolFamilyMetadata[i] = EnumMetadata{
|
|
||||||
DecodeWith: errorFunc(fmt.Sprintf("Unable to decode protocol family %d", i)),
|
|
||||||
Name: fmt.Sprintf("UnknownProtocolFamily(%d)", i),
|
|
||||||
}
|
|
||||||
Dot11TypeMetadata[i] = EnumMetadata{
|
|
||||||
DecodeWith: errorFunc(fmt.Sprintf("Unable to decode Dot11 type %d", i)),
|
|
||||||
Name: fmt.Sprintf("UnknownDot11Type(%d)", i),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Here we link up all enumerations with their respective names and decoders.
|
||||||
EthernetTypeMetadata[EthernetTypeLLC] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLLC), Name: "LLC", LayerType: LayerTypeLLC}
|
EthernetTypeMetadata[EthernetTypeLLC] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLLC), Name: "LLC", LayerType: LayerTypeLLC}
|
||||||
EthernetTypeMetadata[EthernetTypeIPv4] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4), Name: "IPv4", LayerType: LayerTypeIPv4}
|
EthernetTypeMetadata[EthernetTypeIPv4] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4), Name: "IPv4", LayerType: LayerTypeIPv4}
|
||||||
EthernetTypeMetadata[EthernetTypeIPv6] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6", LayerType: LayerTypeIPv6}
|
EthernetTypeMetadata[EthernetTypeIPv6] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6", LayerType: LayerTypeIPv6}
|
||||||
|
@ -463,6 +337,7 @@ func init() {
|
||||||
IPProtocolMetadata[IPProtocolIPv6Routing] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6Routing), Name: "IPv6Routing", LayerType: LayerTypeIPv6Routing}
|
IPProtocolMetadata[IPProtocolIPv6Routing] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6Routing), Name: "IPv6Routing", LayerType: LayerTypeIPv6Routing}
|
||||||
IPProtocolMetadata[IPProtocolIPv6Fragment] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6Fragment), Name: "IPv6Fragment", LayerType: LayerTypeIPv6Fragment}
|
IPProtocolMetadata[IPProtocolIPv6Fragment] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6Fragment), Name: "IPv6Fragment", LayerType: LayerTypeIPv6Fragment}
|
||||||
IPProtocolMetadata[IPProtocolIPv6Destination] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6Destination), Name: "IPv6Destination", LayerType: LayerTypeIPv6Destination}
|
IPProtocolMetadata[IPProtocolIPv6Destination] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6Destination), Name: "IPv6Destination", LayerType: LayerTypeIPv6Destination}
|
||||||
|
IPProtocolMetadata[IPProtocolOSPF] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeOSPF), Name: "OSPF", LayerType: LayerTypeOSPF}
|
||||||
IPProtocolMetadata[IPProtocolAH] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPSecAH), Name: "IPSecAH", LayerType: LayerTypeIPSecAH}
|
IPProtocolMetadata[IPProtocolAH] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPSecAH), Name: "IPSecAH", LayerType: LayerTypeIPSecAH}
|
||||||
IPProtocolMetadata[IPProtocolESP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPSecESP), Name: "IPSecESP", LayerType: LayerTypeIPSecESP}
|
IPProtocolMetadata[IPProtocolESP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPSecESP), Name: "IPSecESP", LayerType: LayerTypeIPSecESP}
|
||||||
IPProtocolMetadata[IPProtocolUDPLite] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUDPLite), Name: "UDPLite", LayerType: LayerTypeUDPLite}
|
IPProtocolMetadata[IPProtocolUDPLite] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUDPLite), Name: "UDPLite", LayerType: LayerTypeUDPLite}
|
||||||
|
@ -509,6 +384,7 @@ func init() {
|
||||||
FDDIFrameControlMetadata[FDDIFrameControlLLC] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLLC), Name: "LLC"}
|
FDDIFrameControlMetadata[FDDIFrameControlLLC] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLLC), Name: "LLC"}
|
||||||
|
|
||||||
EAPOLTypeMetadata[EAPOLTypeEAP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEAP), Name: "EAP", LayerType: LayerTypeEAP}
|
EAPOLTypeMetadata[EAPOLTypeEAP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEAP), Name: "EAP", LayerType: LayerTypeEAP}
|
||||||
|
EAPOLTypeMetadata[EAPOLTypeKey] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEAPOLKey), Name: "EAPOLKey", LayerType: LayerTypeEAPOLKey}
|
||||||
|
|
||||||
ProtocolFamilyMetadata[ProtocolFamilyIPv4] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4), Name: "IPv4", LayerType: LayerTypeIPv4}
|
ProtocolFamilyMetadata[ProtocolFamilyIPv4] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4), Name: "IPv4", LayerType: LayerTypeIPv4}
|
||||||
ProtocolFamilyMetadata[ProtocolFamilyIPv6BSD] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6", LayerType: LayerTypeIPv6}
|
ProtocolFamilyMetadata[ProtocolFamilyIPv6BSD] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6", LayerType: LayerTypeIPv6}
|
||||||
|
@ -556,7 +432,7 @@ func init() {
|
||||||
Dot11TypeMetadata[Dot11TypeDataQOSCFPollNoData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataQOSCFPollNoData), Name: "DataQOSCFPollNoData", LayerType: LayerTypeDot11DataQOSCFPollNoData}
|
Dot11TypeMetadata[Dot11TypeDataQOSCFPollNoData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataQOSCFPollNoData), Name: "DataQOSCFPollNoData", LayerType: LayerTypeDot11DataQOSCFPollNoData}
|
||||||
Dot11TypeMetadata[Dot11TypeDataQOSCFAckPollNoData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataQOSCFAckPollNoData), Name: "DataQOSCFAckPollNoData", LayerType: LayerTypeDot11DataQOSCFAckPollNoData}
|
Dot11TypeMetadata[Dot11TypeDataQOSCFAckPollNoData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataQOSCFAckPollNoData), Name: "DataQOSCFAckPollNoData", LayerType: LayerTypeDot11DataQOSCFAckPollNoData}
|
||||||
|
|
||||||
USBTypeMetadata[USBTransportTypeInterrupt] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUSBInterrupt), Name: "Interrupt", LayerType: LayerTypeUSBInterrupt}
|
USBTransportTypeMetadata[USBTransportTypeInterrupt] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUSBInterrupt), Name: "Interrupt", LayerType: LayerTypeUSBInterrupt}
|
||||||
USBTypeMetadata[USBTransportTypeControl] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUSBControl), Name: "Control", LayerType: LayerTypeUSBControl}
|
USBTransportTypeMetadata[USBTransportTypeControl] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUSBControl), Name: "Control", LayerType: LayerTypeUSBControl}
|
||||||
USBTypeMetadata[USBTransportTypeBulk] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUSBBulk), Name: "Bulk", LayerType: LayerTypeUSBBulk}
|
USBTransportTypeMetadata[USBTransportTypeBulk] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUSBBulk), Name: "Bulk", LayerType: LayerTypeUSBBulk}
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue