new: events.ignore and events.include now support tab completion

This commit is contained in:
evilsocket 2019-02-24 12:57:16 +01:00
commit 7e4cfbe57c
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
2 changed files with 68 additions and 4 deletions

View file

@ -88,17 +88,25 @@ func NewEventsStream(s *session.Session) *EventsStream {
return mod.startWaitingFor(tag, timeout) return mod.startWaitingFor(tag, timeout)
})) }))
mod.AddHandler(session.NewModuleHandler("events.ignore FILTER", "events.ignore ([^\\s]+)", ignore := session.NewModuleHandler("events.ignore FILTER", "events.ignore ([^\\s]+)",
"Events with an identifier matching this filter will not be shown (use multiple times to add more filters).", "Events with an identifier matching this filter will not be shown (use multiple times to add more filters).",
func(args []string) error { func(args []string) error {
return mod.ignoreList.Add(args[0]) return mod.ignoreList.Add(args[0])
})) })
mod.AddHandler(session.NewModuleHandler("events.include FILTER", "events.include ([^\\s]+)", ignore.Complete("events.ignore", s.EventsCompleter)
mod.AddHandler(ignore)
include := session.NewModuleHandler("events.include FILTER", "events.include ([^\\s]+)",
"Used to remove filters passed with the events.ignore command.", "Used to remove filters passed with the events.ignore command.",
func(args []string) error { func(args []string) error {
return mod.ignoreList.Remove(args[0]) return mod.ignoreList.Remove(args[0])
})) })
include.Complete("events.include", s.EventsCompleter)
mod.AddHandler(include)
mod.AddHandler(session.NewModuleHandler("events.filters", "", mod.AddHandler(session.NewModuleHandler("events.filters", "",
"Print the list of filters used to ignore events.", "Print the list of filters used to ignore events.",

View file

@ -210,6 +210,62 @@ func (s *Session) HIDCompleter(prefix string) []string {
return macs return macs
} }
func (s *Session) EventsCompleter(prefix string) []string {
events := []string{""}
all := []string{
"sys.log",
"session.started",
"session.closing",
"update.available",
"mod.started",
"mod.stopped",
"endpoint.new",
"endpoint.lost",
"wifi.client.lost",
"wifi.client.probe",
"wifi.client.new",
"wifi.client.handshake",
"wifi.ap.new",
"wifi.ap.lost",
"ble.device.service.discovered",
"ble.device.characteristic.discovered",
"ble.device.connected",
"ble.device.new",
"ble.device.lost",
"ble.connection.timeout",
"hid.device.new",
"hid.device.lost",
"http.spoofed-request",
"http.spoofed-response",
"https.spoofed-request",
"https.spoofed-response",
"syn.scan",
"net.sniff.mdns",
"net.sniff.mdns",
"net.sniff.dot11",
"net.sniff.tcp",
"net.sniff.upnp",
"net.sniff.ntlm",
"net.sniff.ftp",
"net.sniff.udp",
"net.sniff.krb5",
"net.sniff.dns",
"net.sniff.teamviewer",
"net.sniff.http.request",
"net.sniff.http.response",
"net.sniff.sni",
}
for _, e := range all {
if prefix == "" || strings.HasPrefix(e, prefix) {
events = append(events, e)
}
}
return events
}
func (s *Session) Module(name string) (err error, mod Module) { func (s *Session) Module(name string) (err error, mod Module) {
for _, m := range s.Modules { for _, m := range s.Modules {
if m.Name() == name { if m.Name() == name {