misc: small fix or general refactoring i did not bother commenting

This commit is contained in:
evilsocket 2018-08-25 11:50:23 +02:00
parent 4e7377d2a0
commit b57e329632
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
11 changed files with 28 additions and 28 deletions

View file

@ -149,8 +149,8 @@ func (api *RestAPI) Configure() error {
return err return err
} }
} else { } else {
log.Info("Loading TLS key from %s", api.keyFile) log.Info("loading TLS key from %s", api.keyFile)
log.Info("Loading TLS certificate from %s", api.certFile) log.Info("loading TLS certificate from %s", api.certFile)
} }
api.server.Addr = fmt.Sprintf("%s:%d", ip, port) api.server.Addr = fmt.Sprintf("%s:%d", ip, port)

View file

@ -154,7 +154,7 @@ func (p *ArpSpoofer) Start() error {
func (p *ArpSpoofer) unSpoof() error { func (p *ArpSpoofer) unSpoof() error {
nTargets := len(p.addresses) + len(p.macs) nTargets := len(p.addresses) + len(p.macs)
log.Info("Restoring ARP cache of %d targets.", nTargets) log.Info("restoring ARP cache of %d targets.", nTargets)
p.sendArp(p.Session.Gateway.IP, p.Session.Gateway.HW, false, false) p.sendArp(p.Session.Gateway.IP, p.Session.Gateway.HW, false, false)
if p.internal { if p.internal {
@ -174,7 +174,7 @@ func (p *ArpSpoofer) unSpoof() error {
func (p *ArpSpoofer) Stop() error { func (p *ArpSpoofer) Stop() error {
return p.SetRunning(false, func() { return p.SetRunning(false, func() {
log.Info("Waiting for ARP spoofer to stop ...") log.Info("waiting for ARP spoofer to stop ...")
p.unSpoof() p.unSpoof()
p.ban = false p.ban = false
p.waitGroup.Wait() p.waitGroup.Wait()

View file

@ -11,7 +11,7 @@ import (
) )
var ( var (
ErrEmptyExpression = errors.New("Expression can not be empty.") ErrEmptyExpression = errors.New("expression can not be empty")
) )
type IgnoreFilter string type IgnoreFilter string
@ -51,7 +51,7 @@ func (l *IgnoreList) Add(expr string) (err error) {
// first check for duplicates // first check for duplicates
for _, filter := range l.filters { for _, filter := range l.filters {
if filter.Matches(expr) { if filter.Matches(expr) {
return fmt.Errorf("Filter '%s' already matches the expression '%s'.", filter, expr) return fmt.Errorf("filter '%s' already matches the expression '%s'", filter, expr)
} }
} }
@ -79,7 +79,7 @@ func (l *IgnoreList) Remove(expr string) (err error) {
} }
if len(newList) == len(l.filters) { if len(newList) == len(l.filters) {
return fmt.Errorf("Expression '%s' did not match any filter.", expr) return fmt.Errorf("expression '%s' did not match any filter", expr)
} }
// swap // swap

View file

@ -162,7 +162,7 @@ func (s *EventsStream) Start() error {
if !s.ignoreList.Ignored(e) { if !s.ignoreList.Ignored(e) {
s.View(e, true) s.View(e, true)
} else { } else {
log.Debug("Skipping ignored event %v", e) log.Debug("skipping ignored event %v", e)
} }
case <-s.quit: case <-s.quit:
@ -197,9 +197,9 @@ func (s *EventsStream) Show(limit int) error {
func (s *EventsStream) startWaitingFor(tag string, timeout int) error { func (s *EventsStream) startWaitingFor(tag string, timeout int) error {
if timeout == 0 { if timeout == 0 {
log.Info("Waiting for event %s ...", core.Green(tag)) log.Info("waiting for event %s ...", core.Green(tag))
} else { } else {
log.Info("Waiting for event %s for %d seconds ...", core.Green(tag), timeout) log.Info("waiting for event %s for %d seconds ...", core.Green(tag), timeout)
go func() { go func() {
time.Sleep(time.Duration(timeout) * time.Second) time.Sleep(time.Duration(timeout) * time.Second)
s.waitFor = "" s.waitFor = ""
@ -213,7 +213,7 @@ func (s *EventsStream) startWaitingFor(tag string, timeout int) error {
if event == nil { if event == nil {
return fmt.Errorf("'events.waitFor %s %d' timed out.", tag, timeout) return fmt.Errorf("'events.waitFor %s %d' timed out.", tag, timeout)
} else { } else {
log.Debug("Got event: %v", event) log.Debug("got event: %v", event)
} }
return nil return nil

View file

@ -37,7 +37,7 @@ func (s *EventsStream) viewWiFiEvent(e session.Event) {
} }
if e.Tag == "wifi.ap.new" { if e.Tag == "wifi.ap.new" {
fmt.Fprintf(s.output, "[%s] [%s] WiFi access point %s%s detected as %s%s.\n", fmt.Fprintf(s.output, "[%s] [%s] wifi access point %s%s detected as %s%s.\n",
e.Time.Format(eventTimeFormat), e.Time.Format(eventTimeFormat),
core.Green(e.Tag), core.Green(e.Tag),
core.Bold(ap.ESSID()), core.Bold(ap.ESSID()),
@ -45,7 +45,7 @@ func (s *EventsStream) viewWiFiEvent(e session.Event) {
core.Green(ap.BSSID()), core.Green(ap.BSSID()),
core.Dim(vend)) core.Dim(vend))
} else if e.Tag == "wifi.ap.lost" { } else if e.Tag == "wifi.ap.lost" {
fmt.Fprintf(s.output, "[%s] [%s] WiFi access point %s (%s) lost.\n", fmt.Fprintf(s.output, "[%s] [%s] wifi access point %s (%s) lost.\n",
e.Time.Format(eventTimeFormat), e.Time.Format(eventTimeFormat),
core.Green(e.Tag), core.Green(e.Tag),
core.Red(ap.ESSID()), core.Red(ap.ESSID()),
@ -69,7 +69,7 @@ func (s *EventsStream) viewWiFiEvent(e session.Event) {
rssi = fmt.Sprintf(" (%d dBm)", probe.RSSI) rssi = fmt.Sprintf(" (%d dBm)", probe.RSSI)
} }
fmt.Fprintf(s.output, "[%s] [%s] Station %s%s is probing for SSID %s%s\n", fmt.Fprintf(s.output, "[%s] [%s] station %s%s is probing for SSID %s%s\n",
e.Time.Format(eventTimeFormat), e.Time.Format(eventTimeFormat),
core.Green(e.Tag), core.Green(e.Tag),
probe.FromAddr.String(), probe.FromAddr.String(),
@ -79,7 +79,7 @@ func (s *EventsStream) viewWiFiEvent(e session.Event) {
} }
} }
func (s *EventsStream) viewEndpointEvent(e session.Event) { func (s *EventsStream) viewendpointEvent(e session.Event) {
t := e.Data.(*network.Endpoint) t := e.Data.(*network.Endpoint)
vend := "" vend := ""
name := "" name := ""
@ -95,7 +95,7 @@ func (s *EventsStream) viewEndpointEvent(e session.Event) {
} }
if e.Tag == "endpoint.new" { if e.Tag == "endpoint.new" {
fmt.Fprintf(s.output, "[%s] [%s] Endpoint %s%s detected as %s%s.\n", fmt.Fprintf(s.output, "[%s] [%s] endpoint %s%s detected as %s%s.\n",
e.Time.Format(eventTimeFormat), e.Time.Format(eventTimeFormat),
core.Green(e.Tag), core.Green(e.Tag),
core.Bold(t.IpAddress), core.Bold(t.IpAddress),
@ -103,7 +103,7 @@ func (s *EventsStream) viewEndpointEvent(e session.Event) {
core.Green(t.HwAddress), core.Green(t.HwAddress),
core.Dim(vend)) core.Dim(vend))
} else if e.Tag == "endpoint.lost" { } else if e.Tag == "endpoint.lost" {
fmt.Fprintf(s.output, "[%s] [%s] Endpoint %s%s lost.\n", fmt.Fprintf(s.output, "[%s] [%s] endpoint %s%s lost.\n",
e.Time.Format(eventTimeFormat), e.Time.Format(eventTimeFormat),
core.Green(e.Tag), core.Green(e.Tag),
core.Red(t.IpAddress), core.Red(t.IpAddress),
@ -159,7 +159,7 @@ func (s *EventsStream) viewSnifferEvent(e session.Event) {
func (s *EventsStream) viewSynScanEvent(e session.Event) { func (s *EventsStream) viewSynScanEvent(e session.Event) {
se := e.Data.(SynScanEvent) se := e.Data.(SynScanEvent)
fmt.Fprintf(s.output, "[%s] [%s] Found open port %d for %s\n", fmt.Fprintf(s.output, "[%s] [%s] found open port %d for %s\n",
e.Time.Format(eventTimeFormat), e.Time.Format(eventTimeFormat),
core.Green(e.Tag), core.Green(e.Tag),
se.Port, se.Port,
@ -169,7 +169,7 @@ func (s *EventsStream) viewSynScanEvent(e session.Event) {
func (s *EventsStream) viewUpdateEvent(e session.Event) { func (s *EventsStream) viewUpdateEvent(e session.Event) {
update := e.Data.(*github.RepositoryRelease) update := e.Data.(*github.RepositoryRelease)
fmt.Fprintf(s.output, "[%s] [%s] An update to version %s is available at %s\n", fmt.Fprintf(s.output, "[%s] [%s] an update to version %s is available at %s\n",
e.Time.Format(eventTimeFormat), e.Time.Format(eventTimeFormat),
core.Bold(core.Yellow(e.Tag)), core.Bold(core.Yellow(e.Tag)),
core.Bold(*update.TagName), core.Bold(*update.TagName),
@ -180,7 +180,7 @@ func (s *EventsStream) View(e session.Event, refresh bool) {
if e.Tag == "sys.log" { if e.Tag == "sys.log" {
s.viewLogEvent(e) s.viewLogEvent(e)
} else if strings.HasPrefix(e.Tag, "endpoint.") { } else if strings.HasPrefix(e.Tag, "endpoint.") {
s.viewEndpointEvent(e) s.viewendpointEvent(e)
} else if strings.HasPrefix(e.Tag, "wifi.") { } else if strings.HasPrefix(e.Tag, "wifi.") {
s.viewWiFiEvent(e) s.viewWiFiEvent(e)
} else if strings.HasPrefix(e.Tag, "ble.") { } else if strings.HasPrefix(e.Tag, "ble.") {

View file

@ -23,7 +23,7 @@ func (s *EventsStream) viewBLEEvent(e session.Event) {
vend = fmt.Sprintf(" (%s)", core.Yellow(vend)) vend = fmt.Sprintf(" (%s)", core.Yellow(vend))
} }
fmt.Fprintf(s.output, "[%s] [%s] New BLE device%s detected as %s%s %s.\n", fmt.Fprintf(s.output, "[%s] [%s] new BLE device%s detected as %s%s %s.\n",
e.Time.Format(eventTimeFormat), e.Time.Format(eventTimeFormat),
core.Green(e.Tag), core.Green(e.Tag),
name, name,

View file

@ -58,7 +58,7 @@ func LoadHttpProxyScriptSource(path, source string, sess *session.Session) (err
} }
func LoadHttpProxyScript(path string, sess *session.Session) (err error, s *HttpProxyScript) { func LoadHttpProxyScript(path string, sess *session.Session) (err error, s *HttpProxyScript) {
log.Info("Loading proxy script %s ...", path) log.Info("loading proxy script %s ...", path)
raw, err := ioutil.ReadFile(path) raw, err := ioutil.ReadFile(path)
if err != nil { if err != nil {

View file

@ -145,8 +145,8 @@ func (httpd *HttpServer) Configure() error {
return err return err
} }
} else { } else {
log.Info("Loading server TLS key from %s", keyFile) log.Info("loading server TLS key from %s", keyFile)
log.Info("Loading server TLS certificate from %s", certFile) log.Info("loading server TLS certificate from %s", certFile)
} }
} }

View file

@ -132,8 +132,8 @@ func (p *HttpsProxy) Configure() error {
return err return err
} }
} else { } else {
log.Info("Loading proxy certification authority TLS key from %s", keyFile) log.Info("loading proxy certification authority TLS key from %s", keyFile)
log.Info("Loading proxy certification authority TLS certificate from %s", certFile) log.Info("loading proxy certification authority TLS certificate from %s", certFile)
} }
return p.proxy.ConfigureTLS(address, proxyPort, httpPort, scriptPath, certFile, keyFile, jsToInject, stripSSL) return p.proxy.ConfigureTLS(address, proxyPort, httpPort, scriptPath, certFile, keyFile, jsToInject, stripSSL)

View file

@ -146,7 +146,7 @@ func (pp *PacketProxy) Configure() (err error) {
return fmt.Errorf("%s does not exist.", pp.pluginPath) return fmt.Errorf("%s does not exist.", pp.pluginPath)
} }
log.Info("Loading packet proxy plugin from %s ...", pp.pluginPath) log.Info("loading packet proxy plugin from %s ...", pp.pluginPath)
var ok bool var ok bool
var sym plugin.Symbol var sym plugin.Symbol

View file

@ -39,7 +39,7 @@ func LoadTcpProxyScriptSource(path, source string, sess *session.Session) (err e
} }
func LoadTcpProxyScript(path string, sess *session.Session) (err error, s *TcpProxyScript) { func LoadTcpProxyScript(path string, sess *session.Session) (err error, s *TcpProxyScript) {
log.Info("Loading TCP proxy script %s ...", path) log.Info("loading TCP proxy script %s ...", path)
raw, err := ioutil.ReadFile(path) raw, err := ioutil.ReadFile(path)
if err != nil { if err != nil {