yeah i should have done this before, i know

This commit is contained in:
evilsocket 2017-11-17 14:49:59 +01:00
commit 0091ffdbb3
33 changed files with 25678 additions and 0 deletions

8
core/banner.go Normal file
View file

@ -0,0 +1,8 @@
package core
const (
Name = "bettercap"
Version = "2.0.0a"
Author = "Simone 'evilsocket' Margaritelli"
Website = "https://bettercap.org/"
)

4
core/build.go Normal file
View file

@ -0,0 +1,4 @@
package core
const (
BuildDate = "2017-11-16 19:24"
)

25
core/core.go Normal file
View file

@ -0,0 +1,25 @@
package core
import (
"github.com/op/go-logging"
"os/exec"
"strings"
)
var log = logging.MustGetLogger("mitm")
func Exec(executable string, args []string) (string, error) {
path, err := exec.LookPath(executable)
if err != nil {
return "", err
}
log.Debugf(DIM+"Exec( '%s %s' )"+RESET+"\n", path, strings.Join(args, " "))
raw, err := exec.Command(path, args...).CombinedOutput()
if err != nil {
log.Errorf(" err=%s out='%s'\n", err, raw)
return "", err
} else {
return strings.Trim(string(raw), "\r\n\t "), nil
}
}

25
core/options.go Normal file
View file

@ -0,0 +1,25 @@
package core
import "flag"
type Options struct {
InterfaceName *string
Caplet *string
Debug *bool
Silent *bool
NoHistory *bool
}
func ParseOptions() (Options, error) {
o := Options{
InterfaceName: flag.String("iface", "", "Network interface to bind to."),
Caplet: flag.String("caplet", "", "Read commands from this file instead of goin into interactive mode."),
Debug: flag.Bool("debug", false, "Print debug messages."),
Silent: flag.Bool("silent", false, "Suppress all logs which are not errors."),
NoHistory: flag.Bool("no-history", false, "Disable history file."),
}
flag.Parse()
return o, nil
}

36
core/swag.go Normal file
View file

@ -0,0 +1,36 @@
package core
// https://misc.flogisoft.com/bash/tip_colors_and_formatting
const (
BOLD = "\033[1m"
DIM = "\033[2m"
RED = "\033[31m"
GREEN = "\033[32m"
YELLOW = "\033[33m"
RESET = "\033[0m"
)
const ON = GREEN + "✔" + RESET
const OFF = RED + "✘" + RESET
func Bold(s string) string {
return BOLD + s + RESET
}
func Dim(s string) string {
return DIM + s + RESET
}
func Red(s string) string {
return RED + s + RESET
}
func Green(s string) string {
return GREEN + s + RESET
}
func Yellow(s string) string {
return YELLOW + s + RESET
}