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

New upstream version 2.19

parent 31fed94d
......@@ -83,7 +83,7 @@
revision = "2ce16c963a8ac5bd6af851d4877e38701346983f"
[[projects]]
digest = "1:cbae049ade5f135f52da4cc6e3fd6aca532dffbde65160ad1510dee6c3e8dc4f"
digest = "1:a5fab5a807cac4da733996f46b917283fe43aac5fd32798a3c9279a44eb5156c"
name = "github.com/evilsocket/islazy"
packages = [
"data",
......@@ -96,8 +96,8 @@
"zip",
]
pruneopts = "UT"
revision = "949884336bbf7e535e4e0e6a3f75af89091488e5"
version = "v1.10.1"
revision = "e6f5e33089826f0d17eaab3c8c3603048d615a0e"
version = "v1.10.2"
[[projects]]
branch = "master"
......@@ -193,20 +193,20 @@
version = "v0.9.0"
[[projects]]
digest = "1:0f96ec4151a24d7bfd4298fc13cc320a000e31b4e5431cf88e3ffc961db846fd"
digest = "1:2fa7b0155cd54479a755c629de26f888a918e13f8857a2c442205d825368e084"
name = "github.com/mattn/go-colorable"
packages = ["."]
pruneopts = "UT"
revision = "efa589957cd060542a26d2dd7832fd6a6c6c3ade"
version = "v0.1.0"
revision = "3a70a971f94a22f2fa562ffcc7a0eb45f5daf045"
version = "v0.1.1"
[[projects]]
digest = "1:0981502f9816113c9c8c4ac301583841855c8cf4da8c72f696b3ebedf6d0e4e5"
digest = "1:3bb9c8451d199650bfd303e0068d86f135952fead374ad87c09a9b8a2cc4bd7c"
name = "github.com/mattn/go-isatty"
packages = ["."]
pruneopts = "UT"
revision = "6ca4dbf54d38eea1a992b3c722a76a5d1c4cb25c"
version = "v0.0.4"
revision = "369ecd8cea9851e459abb67eb171853e3986591e"
version = "v0.0.6"
[[projects]]
branch = "master"
......@@ -282,15 +282,15 @@
name = "golang.org/x/net"
packages = ["bpf"]
pruneopts = "UT"
revision = "3a22650c66bd7f4fb6d1e8072ffd7b75c8a27898"
revision = "16b79f2e4e95ea23b2bf9903c9809ff7b013ce85"
[[projects]]
branch = "master"
digest = "1:7a8067e267a25694dd7bdde6e5016053a3f61bb7141448bf8e0025a84eb7d11c"
digest = "1:a2bc6cb1f4e1d0b512e1d47d392ead580006b5bdade6ffde16271759fe609b34"
name = "golang.org/x/sys"
packages = ["unix"]
pruneopts = "UT"
revision = "a9d3bda3a223baa6bba6ef412cb273f0fd163c05"
revision = "b6889370fb1098ed892bd3400d189bb6a3355813"
[[projects]]
digest = "1:9935525a8c49b8434a0b0a54e1980e94a6fae73aaff45c5d33ba8dff69de123e"
......
......@@ -11,7 +11,7 @@ Please, before creating this issue make sure that you read the [README](https://
Please provide:
* Bettercap version you are using.
* Bettercap version you are using ( `bettercap -version` ).
* OS version and architecture you are using.
* Go version if building from sources.
* Command line arguments you are using.
......
#!/bin/bash
BUILD_FOLDER=build
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=$1
......@@ -33,154 +32,18 @@ create_archive() {
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() {
echo "@ Building linux/amd64 ..."
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() {
host_dep 'osxvm'
DIR=/Users/evilsocket/gocode/src/github.com/bettercap/bettercap
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 ..."
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() {
DIR=c:/Users/evilsocket/gopath/src/github.com/bettercap/bettercap
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 ..."
ssh winvm "cd $DIR && go build -o bettercap.exe ." > /dev/null
......@@ -204,14 +67,18 @@ build_windows_amd64() {
build_android_arm() {
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 ..."
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 ..."
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 ..."
scp -C -P 8022 root@shield:$DIR/bettercap .
......@@ -221,17 +88,29 @@ rm -rf $BUILD_FOLDER
mkdir $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
echo
......@@ -239,5 +118,3 @@ echo
du -sh *
cd --
......@@ -2,7 +2,7 @@ package core
const (
Name = "bettercap"
Version = "2.18"
Version = "2.19"
Author = "Simone 'evilsocket' Margaritelli"
Website = "https://bettercap.org/"
)
......@@ -11,6 +11,7 @@ type Options struct {
Silent *bool
NoColors *bool
NoHistory *bool
PrintVersion *bool
EnvFile *string
Commands *string
CpuProfile *string
......@@ -24,6 +25,7 @@ func ParseOptions() (Options, error) {
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."),
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."),
NoColors: flag.Bool("no-colors", false, "Disable output color effects."),
NoHistory: flag.Bool("no-history", false, "Disable interactive session history file."),
......
......@@ -6,6 +6,8 @@ import (
"os"
"strings"
"runtime"
"github.com/bettercap/bettercap/core"
"github.com/bettercap/bettercap/log"
"github.com/bettercap/bettercap/modules"
......@@ -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)
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
modules.LoadModules(sess)
......
......@@ -25,6 +25,7 @@ type rotation struct {
type EventsStream struct {
session.SessionModule
timeFormat string
outputName string
output *os.File
rotation rotation
......@@ -42,6 +43,7 @@ func NewEventsStream(s *session.Session) *EventsStream {
mod := &EventsStream{
SessionModule: session.NewSessionModule("events.stream", s),
output: os.Stdout,
timeFormat: "15:04:05",
quit: make(chan bool),
waitChan: make(chan *session.Event),
waitFor: "",
......@@ -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."))
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",
"true",
"If true will enable log rotation."))
......@@ -235,6 +242,8 @@ func (mod *EventsStream) Configure() (err error) {
if err, mod.rotation.Enabled = mod.BoolParam("events.stream.output.rotate"); err != nil {
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 {
return err
} else if err, mod.rotation.Format = mod.StringParam("events.stream.output.rotate.format"); err != nil {
......
......@@ -18,11 +18,9 @@ import (
"github.com/evilsocket/islazy/zip"
)
const eventTimeFormat = "15:04:05"
func (mod *EventsStream) viewLogEvent(e session.Event) {
fmt.Fprintf(mod.output, "[%s] [%s] [%s] %s\n",
e.Time.Format(eventTimeFormat),
e.Time.Format(mod.timeFormat),
tui.Green(e.Tag),
e.Label(),
e.Data.(session.LogMessage).Message)
......@@ -45,7 +43,7 @@ func (mod *EventsStream) viewEndpointEvent(e session.Event) {
if e.Tag == "endpoint.new" {
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.Bold(t.IpAddress),
tui.Dim(name),
......@@ -53,7 +51,7 @@ func (mod *EventsStream) viewEndpointEvent(e session.Event) {
tui.Dim(vend))
} else if e.Tag == "endpoint.lost" {
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.Red(t.IpAddress),
tui.Dim(name),
......@@ -61,7 +59,7 @@ func (mod *EventsStream) viewEndpointEvent(e session.Event) {
tui.Dim(vend))
} else {
fmt.Fprintf(mod.output, "[%s] [%s] %s\n",
e.Time.Format(eventTimeFormat),
e.Time.Format(mod.timeFormat),
tui.Green(e.Tag),
t.String())
}
......@@ -69,7 +67,7 @@ func (mod *EventsStream) viewEndpointEvent(e session.Event) {
func (mod *EventsStream) viewModuleEvent(e session.Event) {
fmt.Fprintf(mod.output, "[%s] [%s] %s\n",
e.Time.Format(eventTimeFormat),
e.Time.Format(mod.timeFormat),
tui.Green(e.Tag),
e.Data)
}
......@@ -79,7 +77,7 @@ func (mod *EventsStream) viewSnifferEvent(e session.Event) {
mod.viewHttpEvent(e)
} else {
fmt.Fprintf(mod.output, "[%s] [%s] %s\n",
e.Time.Format(eventTimeFormat),
e.Time.Format(mod.timeFormat),
tui.Green(e.Tag),
e.Data.(net_sniff.SnifferEvent).Message)
}
......@@ -88,7 +86,7 @@ func (mod *EventsStream) viewSnifferEvent(e session.Event) {
func (mod *EventsStream) viewSynScanEvent(e session.Event) {
se := e.Data.(syn_scan.SynScanEvent)
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),
se.Port,
tui.Bold(se.Address))
......@@ -98,7 +96,7 @@ func (mod *EventsStream) viewUpdateEvent(e session.Event) {
update := e.Data.(*github.RepositoryRelease)
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(*update.TagName),
*update.HTMLURL)
......@@ -152,6 +150,12 @@ func (mod *EventsStream) doRotation() {
}
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" {
mod.viewLogEvent(e)
} else if strings.HasPrefix(e.Tag, "endpoint.") {
......@@ -171,7 +175,7 @@ func (mod *EventsStream) View(e session.Event, refresh bool) {
} else if e.Tag == "update.available" {
mod.viewUpdateEvent(e)
} 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 {
......
......@@ -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",
e.Time.Format(eventTimeFormat),
e.Time.Format(mod.timeFormat),
tui.Green(e.Tag),
name,
dev.Device.ID(),
......@@ -43,14 +43,14 @@ func (mod *EventsStream) viewBLEEvent(e session.Event) {
}
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),
name,
dev.Device.ID(),
vend)
} /* else {
fmt.Fprintf(s.output,"[%s] [%s]\n",
e.Time.Format(eventTimeFormat),
e.Time.Format(mod.timeFormat),
tui.Green(e.Tag))
} */
}
......@@ -13,13 +13,13 @@ func (mod *EventsStream) viewHIDEvent(e session.Event) {
dev := e.Data.(*network.HIDDevice)
if e.Tag == "hid.device.new" {
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.Bold(dev.Address),
dev.Channels())
} else if e.Tag == "hid.device.lost" {
fmt.Fprintf(mod.output, "[%s] [%s] HID device %s lost.\n",
e.Time.Format(eventTimeFormat),
e.Time.Format(mod.timeFormat),
tui.Green(e.Tag),
tui.Red(dev.Address))
}
......
......@@ -124,7 +124,7 @@ func (mod *EventsStream) viewHttpRequest(e session.Event) {
req := se.Data.(net_sniff.HTTPRequest)
fmt.Fprintf(mod.output, "[%s] [%s] %s\n",
e.Time.Format(eventTimeFormat),
e.Time.Format(mod.timeFormat),
tui.Green(e.Tag),
se.Message)
......@@ -162,7 +162,7 @@ func (mod *EventsStream) viewHttpResponse(e session.Event) {
res := se.Data.(net_sniff.HTTPResponse)
fmt.Fprintf(mod.output, "[%s] [%s] %s\n",
e.Time.Format(eventTimeFormat),
e.Time.Format(mod.timeFormat),
tui.Green(e.Tag),
se.Message)
......
......@@ -24,7 +24,7 @@ func (mod *EventsStream) viewWiFiApEvent(e session.Event) {
if e.Tag == "wifi.ap.new" {
fmt.Fprintf(mod.output, "[%s] [%s] wifi access point %s%s detected as %s%s.\n",
e.Time.Format(eventTimeFormat),
e.Time.Format(mod.timeFormat),
tui.Green(e.Tag),
tui.Bold(ap.ESSID()),
tui.Dim(tui.Yellow(rssi)),
......@@ -32,13 +32,13 @@ func (mod *EventsStream) viewWiFiApEvent(e session.Event) {
tui.Dim(vend))
} else if e.Tag == "wifi.ap.lost" {
fmt.Fprintf(mod.output, "[%s] [%s] wifi access point %s (%s) lost.\n",
e.Time.Format(eventTimeFormat),
e.Time.Format(mod.timeFormat),
tui.Green(e.Tag),
tui.Red(ap.ESSID()),
ap.BSSID())
} else {
fmt.Fprintf(mod.output, "[%s] [%s] %s\n",
e.Time.Format(eventTimeFormat),
e.Time.Format(mod.timeFormat),
tui.Green(e.Tag),
ap.String())
}
......@@ -58,7 +58,7 @@ func (mod *EventsStream) viewWiFiClientProbeEvent(e session.Event) {
}
fmt.Fprintf(mod.output, "[%s] [%s] station %s%s is probing for SSID %s%s\n",
e.Time.Format(eventTimeFormat),
e.Time.Format(mod.timeFormat),
tui.Green(e.Tag),
probe.FromAddr.String(),
tui.Dim(desc),
......@@ -83,7 +83,7 @@ func (mod *EventsStream) viewWiFiHandshakeEvent(e session.Event) {
}
fmt.Fprintf(mod.output, "[%s] [%s] captured %s -> %s %s to %s\n",
e.Time.Format(eventTimeFormat),
e.Time.Format(mod.timeFormat),
tui.Green(e.Tag),
from,
to,
......@@ -98,14 +98,14 @@ func (mod *EventsStream) viewWiFiClientEvent(e session.Event) {
if e.Tag == "wifi.client.new" {
fmt.Fprintf(mod.output, "[%s] [%s] new station %s detected for %s (%s)\n",
e.Time.Format(eventTimeFormat),
e.Time.Format(mod.timeFormat),
tui.Green(e.Tag),
ce.Client.String(),
tui.Bold(ce.AP.ESSID()),
tui.Dim(ce.AP.BSSID()))
} else if e.Tag == "wifi.client.lost" {
fmt.Fprintf(mod.output, "[%s] [%s] station %s disconnected from %s (%s)\n",
e.Time.Format(eventTimeFormat),
e.Time.Format(mod.timeFormat),
tui.Green(e.Tag),
ce.Client.String(),
tui.Bold(ce.AP.ESSID()),
......@@ -123,6 +123,6 @@ func (mod *EventsStream) viewWiFiEvent(e session.Event) {
} else if e.Tag == "wifi.client.new" || e.Tag == "wifi.client.lost" {
mod.viewWiFiClientEvent(e)
} 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)
}
}
......@@ -124,7 +124,6 @@ func (mod *GPS) Start() error {
}
return mod.SetRunning(true, func() {
defer mod.serial.Close()
for mod.Running() {
......@@ -132,7 +131,21 @@ func (mod *GPS) Start() error {
if s, err := nmea.Parse(line); err == nil {
// http://aprs.gids.nl/nmea/#gga
if m, ok := s.(nmea.GNGGA); ok {
mod.Session.GPS = m
mod.Session.GPS.Latitude = m.Latitude
mod.Session.GPS.Longitude = m.Longitude
mod.Session.GPS.FixQuality = m.FixQuality
mod.Session.GPS.NumSatellites = m.NumSatellites
mod.Session.GPS.HDOP = m.HDOP
mod.Session.GPS.Altitude = m.Altitude
mod.Session.GPS.Separation = m.Separation
} else if m, ok := s.(nmea.GPGGA); ok {
mod.Session.GPS.Latitude = m.Latitude
mod.Session.GPS.Longitude = m.Longitude
mod.Session.GPS.FixQuality = m.FixQuality
mod.Session.GPS.NumSatellites = m.NumSatellites
mod.Session.GPS.HDOP = m.HDOP
mod.Session.GPS.Altitude = m.Altitude
mod.Session.GPS.Separation = m.Separation
}
} else {
mod.Debug("error parsing line '%s': %s", line, err)
......
......@@ -35,6 +35,10 @@ func (b MicrosoftBuilder) frameFor(template []byte, cmd *Command) []byte {
}
func (b MicrosoftBuilder) BuildFrames(dev *network.HIDDevice, commands []*Command) error {
if dev == nil {
return fmt.Errorf("the microsoft frame injection requires the device to be visible")
}
tpl := ([]byte)(nil)
dev.EachPayload(func(p []byte) bool {
if len(p) == 19 {
......
......@@ -15,3 +15,22 @@ var FrameBuilders = map[network.HIDType]FrameBuilder{
network.HIDTypeAmazon: AmazonBuilder{},
network.HIDTypeMicrosoft: MicrosoftBuilder{},
}
func availBuilders() []string {
return []string{
"logitech",
"amazon",
"microsoft",
}
}
func builderFromName(name string) FrameBuilder {
switch name {
case "amazon":
return AmazonBuilder{}
case "microsoft":
return MicrosoftBuilder{}
default:
return LogitechBuilder{}
}
}
......@@ -107,7 +107,7 @@ func (p DuckyParser) Parse(kmap KeyMap, path string) (cmds []*Command, err error
}
cmds = make([]*Command, 0)
for lineno, line := range source {
for _, line := range source {
cmd := &Command{}
if p.lineIs(line, "CTRL", "CONTROL") {
if cmd, err = p.parseModifier(line, kmap, 1); err != nil {
......@@ -177,8 +177,8 @@ func (p DuckyParser) Parse(kmap KeyMap, path string) (cmds []*Command, err error
}
continue
} else {
err = fmt.Errorf("can't parse line %d ('%s') of %s", lineno+1, line, path)
} else if cmd, err = p.parseLiteral(line, kmap); err != nil {
err = fmt.Errorf("error parsing '%s': %s", line, err)
return
}