Commit 0a36f3e6 authored by Sophie Brun's avatar Sophie Brun

New upstream version 2.19

parent 31fed94d
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
revision = "2ce16c963a8ac5bd6af851d4877e38701346983f" revision = "2ce16c963a8ac5bd6af851d4877e38701346983f"
[[projects]] [[projects]]
digest = "1:cbae049ade5f135f52da4cc6e3fd6aca532dffbde65160ad1510dee6c3e8dc4f" digest = "1:a5fab5a807cac4da733996f46b917283fe43aac5fd32798a3c9279a44eb5156c"
name = "github.com/evilsocket/islazy" name = "github.com/evilsocket/islazy"
packages = [ packages = [
"data", "data",
...@@ -96,8 +96,8 @@ ...@@ -96,8 +96,8 @@
"zip", "zip",
] ]
pruneopts = "UT" pruneopts = "UT"
revision = "949884336bbf7e535e4e0e6a3f75af89091488e5" revision = "e6f5e33089826f0d17eaab3c8c3603048d615a0e"
version = "v1.10.1" version = "v1.10.2"
[[projects]] [[projects]]
branch = "master" branch = "master"
...@@ -193,20 +193,20 @@ ...@@ -193,20 +193,20 @@
version = "v0.9.0" version = "v0.9.0"
[[projects]] [[projects]]
digest = "1:0f96ec4151a24d7bfd4298fc13cc320a000e31b4e5431cf88e3ffc961db846fd" digest = "1:2fa7b0155cd54479a755c629de26f888a918e13f8857a2c442205d825368e084"
name = "github.com/mattn/go-colorable" name = "github.com/mattn/go-colorable"
packages = ["."] packages = ["."]
pruneopts = "UT" pruneopts = "UT"
revision = "efa589957cd060542a26d2dd7832fd6a6c6c3ade" revision = "3a70a971f94a22f2fa562ffcc7a0eb45f5daf045"
version = "v0.1.0" version = "v0.1.1"
[[projects]] [[projects]]
digest = "1:0981502f9816113c9c8c4ac301583841855c8cf4da8c72f696b3ebedf6d0e4e5" digest = "1:3bb9c8451d199650bfd303e0068d86f135952fead374ad87c09a9b8a2cc4bd7c"
name = "github.com/mattn/go-isatty" name = "github.com/mattn/go-isatty"
packages = ["."] packages = ["."]
pruneopts = "UT" pruneopts = "UT"
revision = "6ca4dbf54d38eea1a992b3c722a76a5d1c4cb25c" revision = "369ecd8cea9851e459abb67eb171853e3986591e"
version = "v0.0.4" version = "v0.0.6"
[[projects]] [[projects]]
branch = "master" branch = "master"
...@@ -282,15 +282,15 @@ ...@@ -282,15 +282,15 @@
name = "golang.org/x/net" name = "golang.org/x/net"
packages = ["bpf"] packages = ["bpf"]
pruneopts = "UT" pruneopts = "UT"
revision = "3a22650c66bd7f4fb6d1e8072ffd7b75c8a27898" revision = "16b79f2e4e95ea23b2bf9903c9809ff7b013ce85"
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:7a8067e267a25694dd7bdde6e5016053a3f61bb7141448bf8e0025a84eb7d11c" digest = "1:a2bc6cb1f4e1d0b512e1d47d392ead580006b5bdade6ffde16271759fe609b34"
name = "golang.org/x/sys" name = "golang.org/x/sys"
packages = ["unix"] packages = ["unix"]
pruneopts = "UT" pruneopts = "UT"
revision = "a9d3bda3a223baa6bba6ef412cb273f0fd163c05" revision = "b6889370fb1098ed892bd3400d189bb6a3355813"
[[projects]] [[projects]]
digest = "1:9935525a8c49b8434a0b0a54e1980e94a6fae73aaff45c5d33ba8dff69de123e" digest = "1:9935525a8c49b8434a0b0a54e1980e94a6fae73aaff45c5d33ba8dff69de123e"
......
...@@ -11,7 +11,7 @@ Please, before creating this issue make sure that you read the [README](https:// ...@@ -11,7 +11,7 @@ Please, before creating this issue make sure that you read the [README](https://
Please provide: Please provide:
* Bettercap version you are using. * Bettercap version you are using ( `bettercap -version` ).
* OS version and architecture you are using. * OS version and architecture you are using.
* Go version if building from sources. * Go version if building from sources.
* Command line arguments you are using. * Command line arguments you are using.
......
#!/bin/bash #!/bin/bash
BUILD_FOLDER=build BUILD_FOLDER=build
VERSION=$(cat core/banner.go | grep Version | cut -d '"' -f 2) VERSION=$(cat core/banner.go | grep Version | cut -d '"' -f 2)
CROSS_LIB="-L/tmp/libpcap-1.8.1/ -L/tmp/libusb-1.0.22/"
bin_dep() { bin_dep() {
BIN=$1 BIN=$1
...@@ -33,154 +32,18 @@ create_archive() { ...@@ -33,154 +32,18 @@ create_archive() {
rm -rf bettercap bettercap.exe rm -rf bettercap bettercap.exe
} }
download_pcap() {
bin_dep 'wget'
bin_dep 'tar'
cd /tmp
rm -rf libpcap-1.8.1
if [ ! -f /tmp/libpcap-1.8.1.tar.gz ]; then
echo "@ Downloading https://www.tcpdump.org/release/libpcap-1.8.1.tar.gz ..."
wget -q https://www.tcpdump.org/release/libpcap-1.8.1.tar.gz -O /tmp/libpcap-1.8.1.tar.gz
fi
tar xf libpcap-1.8.1.tar.gz
}
download_libusb() {
bin_dep 'wget'
bin_dep 'tar'
cd /tmp
rm -rf libusb-1.0.22.tar.bz2
if [ ! -f /tmp/libusb-1.0.22.tar.bz2 ]; then
echo "@ Downloading https://github.com/libusb/libusb/releases/download/v1.0.22/libusb-1.0.22.tar.bz2 ..."
wget -q https://github.com/libusb/libusb/releases/download/v1.0.22/libusb-1.0.22.tar.bz2 -O /tmp/libusb-1.0.22.tar.bz2
fi
tar xf libusb-1.0.22.tar.bz2
}
xcompile_pcap() {
ARCH=$1
HOST=$2
COMPILER=$3
bin_dep 'make'
bin_dep 'yacc'
bin_dep 'flex'
bin_dep "$COMPILER"
echo "@ Cross compiling libpcap for $ARCH with $COMPILER ..."
cd /tmp/libpcap-1.8.1
export CC=$COMPILER
./configure --host=$HOST --with-pcap=linux > /dev/null
make CFLAGS='-w' -j4 > /dev/null
}
xcompile_libusb() {
ARCH=$1
HOST=$2
COMPILER=$3
bin_dep 'make'
bin_dep "$COMPILER"
echo "@ Cross compiling libusb for $ARCH with $COMPILER ..."
cd /tmp/libusb-1.0.22
export CC=$COMPILER
./configure --host=$HOST > /dev/null
make CFLAGS='-w' -j4 > /dev/null
}
build_linux_amd64() { build_linux_amd64() {
echo "@ Building linux/amd64 ..." echo "@ Building linux/amd64 ..."
go build -o bettercap .. go build -o bettercap ..
} }
build_linux_arm7_static() {
OLD=$(pwd)
download_pcap
xcompile_pcap 'arm' 'arm-linux-gnueabi' 'arm-linux-gnueabi-gcc'
download_libusb
xcompile_libusb 'arm' 'arm-linux-gnueabi' 'arm-linux-gnueabi-gcc'
echo "@ Building linux/arm7 ..."
cd "$OLD"
env CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CGO_LDFLAGS="$CROSS_LIB" go build -o bettercap ..
}
build_linux_arm7hf_static() {
OLD=$(pwd)
download_pcap
xcompile_pcap 'arm' 'arm-linux-gnueabihf' 'arm-linux-gnueabihf-gcc'
download_libusb
xcompile_libusb 'arm' 'arm-linux-gnueabihf' 'arm-linux-gnueabihf-gcc'
echo "@ Building linux/arm7hf ..."
cd "$OLD"
env CC=arm-linux-gnueabihf-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CGO_LDFLAGS="$CROSS_LIB" go build -o bettercap ..
}
build_linux_mips_static() {
OLD=$(pwd)
download_pcap
xcompile_pcap 'mips' 'mips-linux-gnu' 'mips-linux-gnu-gcc'
download_libusb
xcompile_libusb 'mips' 'mips-linux-gnu' 'mips-linux-gnu-gcc'
echo "@ Building linux/mips ..."
cd "$OLD"
env CC=mips-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=mips CGO_LDFLAGS="$CROSS_LIB" go build -o bettercap ..
}
build_linux_mipsle_static() {
OLD=$(pwd)
download_pcap
xcompile_pcap 'mipsel' 'mipsel-linux-gnu' 'mipsel-linux-gnu-gcc'
download_libusb
xcompile_libusb 'mipsel' 'mipsel-linux-gnu' 'mipsel-linux-gnu-gcc'
echo "@ Building linux/mipsle ..."
cd "$OLD"
env CC=mipsel-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=mipsle CGO_LDFLAGS="$CROSS_LIB" go build -o bettercap ..
}
build_linux_mips64_static() {
OLD=$(pwd)
download_pcap
xcompile_pcap 'mips64' 'mips64-linux-gnuabi64' 'mips64-linux-gnuabi64-gcc'
download_libusb
xcompile_libusb 'mips64' 'mips64-linux-gnuabi64' 'mips64-linux-gnuabi64-gcc'
echo "@ Building linux/mips64 ..."
cd "$OLD"
env CC=mips64-linux-gnuabi64-gcc CGO_ENABLED=1 GOOS=linux GOARCH=mips64 CGO_LDFLAGS="$CROSS_LIB" go build -o bettercap ..
}
build_linux_mips64le_static() {
OLD=$(pwd)
download_pcap
xcompile_pcap 'mips64el' 'mips64el-linux-gnuabi64' 'mips64el-linux-gnuabi64-gcc'
download_libusb
xcompile_libusb 'mips64el' 'mips64el-linux-gnuabi64' 'mips64el-linux-gnuabi64-gcc'
echo "@ Building linux/mips64le ..."
cd "$OLD"
env CC=mips64el-linux-gnuabi64-gcc CGO_ENABLED=1 GOOS=linux GOARCH=mips64le CGO_LDFLAGS="$CROSS_LIB" go build -o bettercap ..
}
build_macos_amd64() { build_macos_amd64() {
host_dep 'osxvm' host_dep 'osxvm'
DIR=/Users/evilsocket/gocode/src/github.com/bettercap/bettercap DIR=/Users/evilsocket/gocode/src/github.com/bettercap/bettercap
echo "@ Updating repo on MacOS VM ..." echo "@ Updating repo on MacOS VM ..."
ssh osxvm "cd $DIR && rm -rf '$OUTPUT' && git pull" > /dev/null ssh osxvm "cd $DIR && rm -rf '$OUTPUT' && git checkout . && git checkout master && git pull" > /dev/null
echo "@ Building darwin/amd64 ..." echo "@ Building darwin/amd64 ..."
ssh osxvm "export GOPATH=/Users/evilsocket/gocode && cd '$DIR' && PATH=$PATH:/usr/local/bin && go get ./... && go build -o bettercap ." > /dev/null ssh osxvm "export GOPATH=/Users/evilsocket/gocode && cd '$DIR' && PATH=$PATH:/usr/local/bin && go get ./... && go build -o bettercap ." > /dev/null
...@@ -194,7 +57,7 @@ build_windows_amd64() { ...@@ -194,7 +57,7 @@ build_windows_amd64() {
DIR=c:/Users/evilsocket/gopath/src/github.com/bettercap/bettercap DIR=c:/Users/evilsocket/gopath/src/github.com/bettercap/bettercap
echo "@ Updating repo on Windows VM ..." echo "@ Updating repo on Windows VM ..."
ssh winvm "cd $DIR && git pull && go get ./..." > /dev/null ssh winvm "cd $DIR && git checkout . && git checkout master && git pull && go get ./..." > /dev/null
echo "@ Building windows/amd64 ..." echo "@ Building windows/amd64 ..."
ssh winvm "cd $DIR && go build -o bettercap.exe ." > /dev/null ssh winvm "cd $DIR && go build -o bettercap.exe ." > /dev/null
...@@ -204,14 +67,18 @@ build_windows_amd64() { ...@@ -204,14 +67,18 @@ build_windows_amd64() {
build_android_arm() { build_android_arm() {
host_dep 'shield' host_dep 'shield'
DIR=/data/data/com.termux/files/home/go/src/github.com/bettercap/bettercap BASE=/data/data/com.termux/files
THEPATH="$BASE/usr/bin:$BASE/usr/bin/applets:/system/xbin:/system/bin"
LPATH="$BASE/usr/lib"
GPATH=$BASE/home/go
DIR=$GPATH/src/github.com/bettercap/bettercap
echo "@ Updating repo on Android host ..." echo "@ Updating repo on Android host ..."
ssh -p 8022 root@shield "cd "$DIR" && rm -rf bettercap* && git pull && go get ./..." ssh -p 8022 root@shield "su -c 'export PATH=$THEPATH && export LD_LIBRARY_PATH="$LPATH" && cd "$DIR" && rm -rf bettercap* && git pull && export GOPATH=$GPATH && go get ./...'"
echo "@ Building android/arm ..." echo "@ Building android/arm ..."
ssh -p 8022 root@shield "cd $DIR && go build -o bettercap ." ssh -p 8022 root@shield "su -c 'export PATH=$THEPATH && export LD_LIBRARY_PATH="$LPATH" && cd "$DIR" && export GOPATH=$GPATH && go build -o bettercap . && setenforce 0'"
echo "@ Downloading bettercap ..." echo "@ Downloading bettercap ..."
scp -C -P 8022 root@shield:$DIR/bettercap . scp -C -P 8022 root@shield:$DIR/bettercap .
...@@ -221,17 +88,29 @@ rm -rf $BUILD_FOLDER ...@@ -221,17 +88,29 @@ rm -rf $BUILD_FOLDER
mkdir $BUILD_FOLDER mkdir $BUILD_FOLDER
cd $BUILD_FOLDER cd $BUILD_FOLDER
if [ -z "$1" ]
then
WHAT=all
else
WHAT="$1"
fi
printf "@ Building for $WHAT ...\n\n"
case "$WHAT" in
all|linux)
build_linux_amd64 && create_archive bettercap_linux_amd64_$VERSION.zip
;;
all|osx|mac|macos)
build_macos_amd64 && create_archive bettercap_macos_amd64_$VERSION.zip
;;
all|windows|win)
build_windows_amd64 && create_exe_archive bettercap_windows_amd64_$VERSION.zip
;;
all|android)
build_android_arm && create_archive bettercap_android_arm_$VERSION.zip
esac
build_linux_amd64 && create_archive bettercap_linux_amd64_$VERSION.zip
build_macos_amd64 && create_archive bettercap_macos_amd64_$VERSION.zip
build_windows_amd64 && create_exe_archive bettercap_windows_amd64_$VERSION.zip
#build_android_arm && create_archive bettercap_android_arm_$VERSION.zip
#build_linux_arm7_static && create_archive bettercap_linux_arm7_$VERSION.zip
#build_linux_arm7hf_static && create_archive bettercap_linux_arm7hf_$VERSION.zip
#build_linux_mips_static && create_archive bettercap_linux_mips_$VERSION.zip
#build_linux_mipsle_static && create_archive bettercap_linux_mipsle_$VERSION.zip
#build_linux_mips64_static && create_archive bettercap_linux_mips64_$VERSION.zip
#build_linux_mips64le_static && create_archive bettercap_linux_mips64le_$VERSION.zip
sha256sum * > checksums.txt sha256sum * > checksums.txt
echo echo
...@@ -239,5 +118,3 @@ echo ...@@ -239,5 +118,3 @@ echo
du -sh * du -sh *
cd -- cd --
...@@ -2,7 +2,7 @@ package core ...@@ -2,7 +2,7 @@ package core
const ( const (
Name = "bettercap" Name = "bettercap"
Version = "2.18" Version = "2.19"
Author = "Simone 'evilsocket' Margaritelli" Author = "Simone 'evilsocket' Margaritelli"
Website = "https://bettercap.org/" Website = "https://bettercap.org/"
) )
...@@ -11,6 +11,7 @@ type Options struct { ...@@ -11,6 +11,7 @@ type Options struct {
Silent *bool Silent *bool
NoColors *bool NoColors *bool
NoHistory *bool NoHistory *bool
PrintVersion *bool
EnvFile *string EnvFile *string
Commands *string Commands *string
CpuProfile *string CpuProfile *string
...@@ -24,6 +25,7 @@ func ParseOptions() (Options, error) { ...@@ -24,6 +25,7 @@ func ParseOptions() (Options, error) {
AutoStart: flag.String("autostart", "events.stream, net.recon", "Comma separated list of modules to auto start."), AutoStart: flag.String("autostart", "events.stream, net.recon", "Comma separated list of modules to auto start."),
Caplet: flag.String("caplet", "", "Read commands from this file and execute them in the interactive session."), Caplet: flag.String("caplet", "", "Read commands from this file and execute them in the interactive session."),
Debug: flag.Bool("debug", false, "Print debug messages."), Debug: flag.Bool("debug", false, "Print debug messages."),
PrintVersion: flag.Bool("version", false, "Print the version and exit."),
Silent: flag.Bool("silent", false, "Suppress all logs which are not errors."), Silent: flag.Bool("silent", false, "Suppress all logs which are not errors."),
NoColors: flag.Bool("no-colors", false, "Disable output color effects."), NoColors: flag.Bool("no-colors", false, "Disable output color effects."),
NoHistory: flag.Bool("no-history", false, "Disable interactive session history file."), NoHistory: flag.Bool("no-history", false, "Disable interactive session history file."),
......
...@@ -6,6 +6,8 @@ import ( ...@@ -6,6 +6,8 @@ import (
"os" "os"
"strings" "strings"
"runtime"
"github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/core"
"github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/log"
"github.com/bettercap/bettercap/modules" "github.com/bettercap/bettercap/modules"
...@@ -31,9 +33,15 @@ func main() { ...@@ -31,9 +33,15 @@ func main() {
} }
} }
if *sess.Options.PrintVersion {
fmt.Printf("%s v%s (built for %s %s with %s)\n", core.Name, core.Version, runtime.GOOS, runtime.GOARCH, runtime.Version())
return
}
appName := fmt.Sprintf("%s v%s", core.Name, core.Version) appName := fmt.Sprintf("%s v%s", core.Name, core.Version)
appBuild := fmt.Sprintf("(built for %s %s with %s)", runtime.GOOS, runtime.GOARCH, runtime.Version())
fmt.Printf("%s (type '%s' for a list of commands)\n\n", tui.Bold(appName), tui.Bold("help")) fmt.Printf("%s %s [type '%s' for a list of commands]\n\n", tui.Bold(appName), tui.Dim(appBuild), tui.Bold("help"))
// Load all modules // Load all modules
modules.LoadModules(sess) modules.LoadModules(sess)
......
...@@ -25,6 +25,7 @@ type rotation struct { ...@@ -25,6 +25,7 @@ type rotation struct {
type EventsStream struct { type EventsStream struct {
session.SessionModule session.SessionModule
timeFormat string
outputName string outputName string
output *os.File output *os.File
rotation rotation rotation rotation
...@@ -42,6 +43,7 @@ func NewEventsStream(s *session.Session) *EventsStream { ...@@ -42,6 +43,7 @@ func NewEventsStream(s *session.Session) *EventsStream {
mod := &EventsStream{ mod := &EventsStream{
SessionModule: session.NewSessionModule("events.stream", s), SessionModule: session.NewSessionModule("events.stream", s),
output: os.Stdout, output: os.Stdout,
timeFormat: "15:04:05",
quit: make(chan bool), quit: make(chan bool),
waitChan: make(chan *session.Event), waitChan: make(chan *session.Event),
waitFor: "", waitFor: "",
...@@ -177,6 +179,11 @@ func NewEventsStream(s *session.Session) *EventsStream { ...@@ -177,6 +179,11 @@ func NewEventsStream(s *session.Session) *EventsStream {
"", "",
"If not empty, events will be written to this file instead of the standard output.")) "If not empty, events will be written to this file instead of the standard output."))
mod.AddParam(session.NewStringParameter("events.stream.time.format",
mod.timeFormat,
"",
"Date and time format to use for events reporting."))
mod.AddParam(session.NewBoolParameter("events.stream.output.rotate", mod.AddParam(session.NewBoolParameter("events.stream.output.rotate",
"true", "true",
"If true will enable log rotation.")) "If true will enable log rotation."))
...@@ -235,6 +242,8 @@ func (mod *EventsStream) Configure() (err error) { ...@@ -235,6 +242,8 @@ func (mod *EventsStream) Configure() (err error) {
if err, mod.rotation.Enabled = mod.BoolParam("events.stream.output.rotate"); err != nil { if err, mod.rotation.Enabled = mod.BoolParam("events.stream.output.rotate"); err != nil {
return err return err
} else if err, mod.timeFormat = mod.StringParam("events.stream.time.format"); err != nil {
return err
} else if err, mod.rotation.Compress = mod.BoolParam("events.stream.output.rotate.compress"); err != nil { } else if err, mod.rotation.Compress = mod.BoolParam("events.stream.output.rotate.compress"); err != nil {
return err return err
} else if err, mod.rotation.Format = mod.StringParam("events.stream.output.rotate.format"); err != nil { } else if err, mod.rotation.Format = mod.StringParam("events.stream.output.rotate.format"); err != nil {
......
...@@ -18,11 +18,9 @@ import ( ...@@ -18,11 +18,9 @@ import (
"github.com/evilsocket/islazy/zip" "github.com/evilsocket/islazy/zip"
) )
const eventTimeFormat = "15:04:05"
func (mod *EventsStream) viewLogEvent(e session.Event) { func (mod *EventsStream) viewLogEvent(e session.Event) {
fmt.Fprintf(mod.output, "[%s] [%s] [%s] %s\n", fmt.Fprintf(mod.output, "[%s] [%s] [%s] %s\n",
e.Time.Format(eventTimeFormat), e.Time.Format(mod.timeFormat),
tui.Green(e.Tag), tui.Green(e.Tag),
e.Label(), e.Label(),
e.Data.(session.LogMessage).Message) e.Data.(session.LogMessage).Message)
...@@ -45,7 +43,7 @@ func (mod *EventsStream) viewEndpointEvent(e session.Event) { ...@@ -45,7 +43,7 @@ func (mod *EventsStream) viewEndpointEvent(e session.Event) {
if e.Tag == "endpoint.new" { if e.Tag == "endpoint.new" {
fmt.Fprintf(mod.output, "[%s] [%s] endpoint %s%s detected as %s%s.\n", fmt.Fprintf(mod.output, "[%s] [%s] endpoint %s%s detected as %s%s.\n",
e.Time.Format(eventTimeFormat), e.Time.Format(mod.timeFormat),
tui.Green(e.Tag), tui.Green(e.Tag),
tui.Bold(t.IpAddress), tui.Bold(t.IpAddress),
tui.Dim(name), tui.Dim(name),
...@@ -53,7 +51,7 @@ func (mod *EventsStream) viewEndpointEvent(e session.Event) { ...@@ -53,7 +51,7 @@ func (mod *EventsStream) viewEndpointEvent(e session.Event) {
tui.Dim(vend)) tui.Dim(vend))
} else if e.Tag == "endpoint.lost" { } else if e.Tag == "endpoint.lost" {
fmt.Fprintf(mod.output, "[%s] [%s] endpoint %s%s %s%s lost.\n", fmt.Fprintf(mod.output, "[%s] [%s] endpoint %s%s %s%s lost.\n",
e.Time.Format(eventTimeFormat), e.Time.Format(mod.timeFormat),
tui.Green(e.Tag), tui.Green(e.Tag),
tui.Red(t.IpAddress), tui.Red(t.IpAddress),
tui.Dim(name), tui.Dim(name),
...@@ -61,7 +59,7 @@ func (mod *EventsStream) viewEndpointEvent(e session.Event) { ...@@ -61,7 +59,7 @@ func (mod *EventsStream) viewEndpointEvent(e session.Event) {
tui.Dim(vend)) tui.Dim(vend))
} else { } else {
fmt.Fprintf(mod.output, "[%s] [%s] %s\n", fmt.Fprintf(mod.output, "[%s] [%s] %s\n",
e.Time.Format(eventTimeFormat), e.Time.Format(mod.timeFormat),
tui.Green(e.Tag), tui.Green(e.Tag),
t.String()) t.String())
} }
...@@ -69,7 +67,7 @@ func (mod *EventsStream) viewEndpointEvent(e session.Event) { ...@@ -69,7 +67,7 @@ func (mod *EventsStream) viewEndpointEvent(e session.Event) {
func (mod *EventsStream) viewModuleEvent(e session.Event) { func (mod *EventsStream) viewModuleEvent(e session.Event) {
fmt.Fprintf(mod.output, "[%s] [%s] %s\n", fmt.Fprintf(mod.output, "[%s] [%s] %s\n",
e.Time.Format(eventTimeFormat), e.Time.Format(mod.timeFormat),
tui.Green(e.Tag), tui.Green(e.Tag),
e.Data) e.Data)
} }
...@@ -79,7 +77,7 @@ func (mod *EventsStream) viewSnifferEvent(e session.Event) { ...@@ -79,7 +77,7 @@ func (mod *EventsStream) viewSnifferEvent(e session.Event) {
mod.viewHttpEvent(e) mod.viewHttpEvent(e)
} else { } else {
fmt.Fprintf(mod.output, "[%s] [%s] %s\n", fmt.Fprintf(mod.output, "[%s] [%s] %s\n",
e.Time.Format(eventTimeFormat), e.Time.Format(mod.timeFormat),
tui.Green(e.Tag), tui.Green(e.Tag),
e.Data.(net_sniff.SnifferEvent).Message) e.Data.(net_sniff.SnifferEvent).Message)
} }
...@@ -88,7 +86,7 @@ func (mod *EventsStream) viewSnifferEvent(e session.Event) { ...@@ -88,7 +86,7 @@ func (mod *EventsStream) viewSnifferEvent(e session.Event) {
func (mod *EventsStream) viewSynScanEvent(e session.Event) { func (mod *EventsStream) viewSynScanEvent(e session.Event) {
se := e.Data.(syn_scan.SynScanEvent) se := e.Data.(syn_scan.SynScanEvent)
fmt.Fprintf(mod.output, "[%s] [%s] found open port %d for %s\n", fmt.Fprintf(mod.output, "[%s] [%s] found open port %d for %s\n",
e.Time.Format(eventTimeFormat), e.Time.Format(mod.timeFormat),
tui.Green(e.Tag), tui.Green(e.Tag),
se.Port, se.Port,
tui.Bold(se.Address)) tui.Bold(se.Address))
...@@ -98,7 +96,7 @@ func (mod *EventsStream) viewUpdateEvent(e session.Event) { ...@@ -98,7 +96,7 @@ func (mod *EventsStream) viewUpdateEvent(e session.Event) {
update := e.Data.(*github.RepositoryRelease) update := e.Data.(*github.RepositoryRelease)
fmt.Fprintf(mod.output, "[%s] [%s] an update to version %s is available at %s\n", fmt.Fprintf(mod.output, "[%s] [%s] an update to version %s is available at %s\n",
e.Time.Format(eventTimeFormat), e.Time.Format(mod.timeFormat),
tui.Bold(tui.Yellow(e.Tag)), tui.Bold(tui.Yellow(e.Tag)),
tui.Bold(*update.TagName), tui.Bold(*update.TagName),
*update.HTMLURL) *update.HTMLURL)
...@@ -152,6 +150,12 @@ func (mod *EventsStream) doRotation() { ...@@ -152,6 +150,12 @@ func (mod *EventsStream) doRotation() {
} }
func (mod *EventsStream) View(e session.Event, refresh bool) { func (mod *EventsStream) View(e session.Event, refresh bool) {
var err error
if err, mod.timeFormat = mod.StringParam("events.stream.time.format"); err != nil {
fmt.Fprintf(mod.output, "%v", err)
mod.timeFormat = "15:04:05"
}
if e.Tag == "sys.log" { if e.Tag == "sys.log" {
mod.viewLogEvent(e) mod.viewLogEvent(e)
} else if strings.HasPrefix(e.Tag, "endpoint.") { } else if strings.HasPrefix(e.Tag, "endpoint.") {
...@@ -171,7 +175,7 @@ func (mod *EventsStream) View(e session.Event, refresh bool) { ...@@ -171,7 +175,7 @@ func (mod *EventsStream) View(e session.Event, refresh bool) {
} else if e.Tag == "update.available" { } else if e.Tag == "update.available" {
mod.viewUpdateEvent(e) mod.viewUpdateEvent(e)
} else { } else {
fmt.Fprintf(mod.output, "[%s] [%s] %v\n", e.Time.Format(eventTimeFormat), tui.Green(e.Tag), e) fmt.Fprintf(mod.output, "[%s] [%s] %v\n", e.Time.Format(mod.timeFormat), tui.Green(e.Tag), e)
} }
if refresh && mod.output == os.Stdout { if refresh && mod.output == os.Stdout {
......
...@@ -25,7 +25,7 @@ func (mod *EventsStream) viewBLEEvent(e session.Event) { ...@@ -25,7 +25,7 @@ func (mod *EventsStream) viewBLEEvent(e session.Event) {
} }
fmt.Fprintf(mod.output, "[%s] [%s] new BLE device%s detected as %s%s %s.\n", fmt.Fprintf(mod.output, "[%s] [%s] new BLE device%s detected as %s%s %s.\n",
e.Time.Format(eventTimeFormat), e.Time.Format(mod.timeFormat),
tui.Green(e.Tag), tui.Green(e.Tag),
name, name,
dev.Device.ID(), dev.Device.ID(),
...@@ -43,14 +43,14 @@ func (mod *EventsStream) viewBLEEvent(e session.Event) { ...@@ -43,14 +43,14 @@ func (mod *EventsStream) viewBLEEvent(e session.Event) {
} }
fmt.Fprintf(mod.output, "[%s] [%s] BLE device%s %s%s lost.\n", fmt.Fprintf(mod.output, "[%s] [%s] BLE device%s %s%s lost.\n",
e.Time.Format(eventTimeFormat), e.Time.Format(mod.timeFormat),
tui.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(mod.timeFormat),
tui.Green(e.Tag)) tui.Green(e.Tag))
} */ } */
} }
...@@ -13,13 +13,13 @@ func (mod *EventsStream) viewHIDEvent(e session.Event) { ...@@ -13,13 +13,13 @@ func (mod *EventsStream) viewHIDEvent(e session.Event) {
dev := e.Data.(*network.HIDDevice) dev := e.Data.(*network.HIDDevice)
if e.Tag == "hid.device.new" { if e.Tag == "hid.device.new" {
fmt.Fprintf(mod.output, "[%s] [%s] new HID device %s detected on channel %s.\n", fmt.Fprintf(mod.output, "[%s] [%s] new HID device %s detected on channel %s.\n",
e.Time.Format(eventTimeFormat), e.Time.Format(mod.timeFormat),
tui.Green(e.Tag), tui.Green(e.Tag),
tui.Bold(dev.Address), tui.Bold(dev.Address),
dev.Channels()) dev.Channels())
} else if e.Tag == "hid.device.lost" { } else if e.Tag == "hid.device.lost" {
fmt.Fprintf(mod.output, "[%s] [%s] HID device %s lost.\n", fmt.Fprintf(mod.output, "[%s] [%s] HID device %s lost.\n",
e.Time.Format(eventTimeFormat), e.Time.Format(mod.timeFormat),