diff --git a/modules/events_stream.go b/modules/events_stream.go index 05ac6d34..7ae38828 100644 --- a/modules/events_stream.go +++ b/modules/events_stream.go @@ -84,7 +84,7 @@ func (s *EventsStream) Start() error { var e session.Event select { case e = <-s.Session.Events.NewEvents: - s.view(e) + s.View(e, true) break case <-s.quit: @@ -98,9 +98,11 @@ func (s *EventsStream) Start() error { func (s *EventsStream) Show() error { for _, e := range s.Session.Events.Sorted() { - s.view(e) + s.View(e, false) } + s.Session.Refresh() + return nil } diff --git a/modules/events_view.go b/modules/events_view.go index 593e7334..6baeeea2 100644 --- a/modules/events_view.go +++ b/modules/events_view.go @@ -28,7 +28,7 @@ func (s EventsStream) viewSnifferEvent(e session.Event) { se.Data) } -func (s *EventsStream) view(e session.Event) { +func (s *EventsStream) View(e session.Event, refresh bool) { if s.filter == "" || strings.Contains(e.Tag, s.filter) { if e.Tag == "sys.log" { s.viewLogEvent(e) @@ -38,6 +38,8 @@ func (s *EventsStream) view(e session.Event) { fmt.Printf("[%s] [%s] %v\n", e.Time.Format(eventTimeFormat), core.Green(e.Tag), e) } - s.Session.Refresh() + if refresh { + s.Session.Refresh() + } } } diff --git a/modules/net_recon_show.go b/modules/net_recon_show.go index 892dccec..371fe4c8 100644 --- a/modules/net_recon_show.go +++ b/modules/net_recon_show.go @@ -144,30 +144,55 @@ func (d *Discovery) Show(by string) error { d.showTable([]string{"IP", "MAC", "Name", "Vendor", "Sent", "Recvd", "Last Seen"}, rows) - rows = [][]string{{ + fmt.Printf("\n%s %s / %s %s / %d pkts / %d errs\n\n", + core.Red("↑"), humanize.Bytes(d.Session.Queue.Sent), + core.Green("↓"), humanize.Bytes(d.Session.Queue.Received), - fmt.Sprintf("%d", d.Session.Queue.PktReceived), - fmt.Sprintf("%d", d.Session.Queue.Errors), - }} + d.Session.Queue.PktReceived, + d.Session.Queue.Errors) - d.showTable([]string{"Sent", "Sniffed", "# Packets", "Errors"}, rows) + s := EventsStream{} + events := d.Session.Events.Sorted() + size := len(events) - rows = make([][]string, 0) - protos, maxPackets := rankByProtoHits(d.Session.Queue.Protos) - maxBarWidth := 70 - - for _, p := range protos { - width := int(float32(maxBarWidth) * (float32(p.Hits) / float32(maxPackets))) - bar := "" - for i := 0; i < width; i++ { - bar += "▇" + if size > 0 { + max := 20 + if size > max { + from := size - max + size = max + events = events[from:] } - rows = append(rows, []string{p.Protocol, fmt.Sprintf("%s %d", bar, p.Hits)}) + fmt.Printf("Last %d events:\n\n", size) + + for _, e := range events { + s.View(e, false) + } + + fmt.Println() } - d.showTable([]string{"Proto", "# Packets"}, rows) + /* + Last events are more useful than this histogram and vertical scroll + isn't infinite :) + + rows = make([][]string, 0) + protos, maxPackets := rankByProtoHits(d.Session.Queue.Protos) + maxBarWidth := 70 + + for _, p := range protos { + width := int(float32(maxBarWidth) * (float32(p.Hits) / float32(maxPackets))) + bar := "" + for i := 0; i < width; i++ { + bar += "▇" + } + + rows = append(rows, []string{p.Protocol, fmt.Sprintf("%s %d", bar, p.Hits)}) + } + + d.showTable([]string{"Proto", "# Packets"}, rows) + */ d.Session.Refresh() diff --git a/session/session_core_handlers.go b/session/session_core_handlers.go index dc4047c4..2e076be9 100644 --- a/session/session_core_handlers.go +++ b/session/session_core_handlers.go @@ -160,7 +160,7 @@ func (s *Session) clsHandler(args []string, sess *Session) error { // fixes a weird bug which causes the screen not to be fully // cleared if a "clear; net.show" commands chain is executed // in the interactive session. - for i := 0; i < 80; i++ { + for i := 0; i < 180; i++ { fmt.Println() } readline.ClearScreen(s.Input.Stdout())