fix: fixed verbose gousb logging (fixes #969)

This commit is contained in:
Simone Margaritelli 2024-08-09 18:28:01 +02:00
parent 2659a559c9
commit 9d5c38c693

View file

@ -2,12 +2,14 @@ package hid
import ( import (
"fmt" "fmt"
golog "log"
"strings" "strings"
"sync" "sync"
"time" "time"
"github.com/bettercap/bettercap/v2/modules/utils" "github.com/bettercap/bettercap/v2/modules/utils"
"github.com/bettercap/bettercap/v2/session" "github.com/bettercap/bettercap/v2/session"
"github.com/evilsocket/islazy/str"
"github.com/bettercap/nrf24" "github.com/bettercap/nrf24"
) )
@ -164,6 +166,15 @@ func (mod HIDRecon) Author() string {
return "Simone Margaritelli <evilsocket@gmail.com> (this module and the nrf24 client library), Bastille Research (the rfstorm firmware and original research), phikshun and infamy for JackIt." return "Simone Margaritelli <evilsocket@gmail.com> (this module and the nrf24 client library), Bastille Research (the rfstorm firmware and original research), phikshun and infamy for JackIt."
} }
type dummyWriter struct {
mod *HIDRecon
}
func (w dummyWriter) Write(p []byte) (n int, err error) {
w.mod.Debug("[hid.log] %s", str.Trim(string(p)))
return len(p), nil
}
func (mod *HIDRecon) Configure() error { func (mod *HIDRecon) Configure() error {
var err error var err error
var n int var n int
@ -198,6 +209,9 @@ func (mod *HIDRecon) Configure() error {
mod.sniffPeriod = time.Duration(n) * time.Millisecond mod.sniffPeriod = time.Duration(n) * time.Millisecond
} }
golog.SetFlags(0)
golog.SetOutput(dummyWriter{mod})
if mod.dongle, err = nrf24.Open(); err != nil { if mod.dongle, err = nrf24.Open(); err != nil {
return fmt.Errorf("make sure that a nRF24LU1+ based USB dongle is connected and running the rfstorm firmware: %s", err) return fmt.Errorf("make sure that a nRF24LU1+ based USB dongle is connected and running the rfstorm firmware: %s", err)
} }