diff --git a/go.mod b/go.mod index d9643041..77b9c5fc 100644 --- a/go.mod +++ b/go.mod @@ -32,26 +32,18 @@ require ( github.com/jpillora/go-tld v1.1.1 github.com/koppacetic/go-gpsd v0.4.0 github.com/kr/binarydist v0.1.0 // indirect - github.com/kr/text v0.2.0 // indirect github.com/malfunkt/iprange v0.9.0 - github.com/mattn/go-colorable v0.1.8 // indirect github.com/mdlayher/dhcp6 v0.0.0-20190311162359-2a67805d7d0b - github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect - github.com/mgutz/logxi v0.0.0-20161027140823-aebf8a7d67ab // indirect github.com/miekg/dns v1.1.41 github.com/mitchellh/go-homedir v1.1.0 github.com/pkg/errors v0.9.1 // indirect github.com/robertkrimen/otto v0.0.0-20200922221731-ef014fd054ac - github.com/stretchr/testify v1.7.0 // indirect github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07 github.com/thoj/go-ircevent v0.0.0-20190807115034-8e7ce4b5a1eb golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1 - golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect - gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/sourcemap.v1 v1.0.5 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect honnef.co/go/tools v0.0.0-2019.2.1 // indirect ) diff --git a/modules/events_stream/events_view.go b/modules/events_stream/events_view.go index ce9479f2..37e84771 100644 --- a/modules/events_stream/events_view.go +++ b/modules/events_stream/events_view.go @@ -2,12 +2,13 @@ package events_stream import ( "fmt" - "github.com/bettercap/bettercap/network" - "github.com/bettercap/bettercap/session" "io" "os" "strings" + "github.com/bettercap/bettercap/network" + "github.com/bettercap/bettercap/session" + "github.com/bettercap/bettercap/modules/net_sniff" "github.com/bettercap/bettercap/modules/syn_scan" @@ -119,6 +120,8 @@ func (mod *EventsStream) Render(output io.Writer, e session.Event) { mod.viewBLEEvent(output, e) } else if strings.HasPrefix(e.Tag, "hid.") { mod.viewHIDEvent(output, e) + } else if strings.HasPrefix(e.Tag, "gps.") { + mod.viewGPSEvent(output, e) } else if strings.HasPrefix(e.Tag, "mod.") { mod.viewModuleEvent(output, e) } else if strings.HasPrefix(e.Tag, "net.sniff.") { diff --git a/modules/events_stream/events_view_gps.go b/modules/events_stream/events_view_gps.go new file mode 100644 index 00000000..7e2285b8 --- /dev/null +++ b/modules/events_stream/events_view_gps.go @@ -0,0 +1,24 @@ +package events_stream + +import ( + "fmt" + "io" + + "github.com/bettercap/bettercap/session" + "github.com/evilsocket/islazy/tui" +) + +func (mod *EventsStream) viewGPSEvent(output io.Writer, e session.Event) { + if e.Tag == "gps.new" { + gps := e.Data.(session.GPS) + + fmt.Fprintf(output, "[%s] [%s] latitude:%f longitude:%f quality:%s satellites:%d altitude:%f\n", + e.Time.Format(mod.timeFormat), + tui.Green(e.Tag), + gps.Latitude, + gps.Longitude, + gps.FixQuality, + gps.NumSatellites, + gps.Altitude) + } +} diff --git a/modules/gps/gps.go b/modules/gps/gps.go index c4c757aa..7017b082 100644 --- a/modules/gps/gps.go +++ b/modules/gps/gps.go @@ -138,16 +138,7 @@ func (mod *GPS) readFromSerial() { if line, err := mod.readLine(); err == nil { if s, err := nmea.Parse(line); err == nil { // http://aprs.gids.nl/nmea/#gga - if m, ok := s.(nmea.GNGGA); ok { - mod.Session.GPS.Updated = time.Now() - 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 { + if m, ok := s.(nmea.GGA); ok { mod.Session.GPS.Updated = time.Now() mod.Session.GPS.Latitude = m.Latitude mod.Session.GPS.Longitude = m.Longitude @@ -156,6 +147,8 @@ func (mod *GPS) readFromSerial() { mod.Session.GPS.HDOP = m.HDOP mod.Session.GPS.Altitude = m.Altitude mod.Session.GPS.Separation = m.Separation + + mod.Session.Events.Add("gps.new", mod.Session.GPS) } } else { mod.Debug("error parsing line '%s': %s", line, err) @@ -173,6 +166,8 @@ func (mod *GPS) runFromGPSD() { mod.Session.GPS.Longitude = report.Lon mod.Session.GPS.FixQuality = ModeInfo[report.Mode] mod.Session.GPS.Altitude = report.Alt + + mod.Session.Events.Add("gps.new", mod.Session.GPS) }) mod.gpsd.Subscribe("SKY", func(r interface{}) {