mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 13:09:49 -07:00
fix: can.fuzz now expects an hexadecimal frame id (thanks musafir)
This commit is contained in:
parent
4c7599566c
commit
1c56622cde
2 changed files with 5 additions and 4 deletions
|
@ -102,7 +102,7 @@ func NewCanModule(s *session.Session) *CANModule {
|
||||||
}))
|
}))
|
||||||
|
|
||||||
mod.AddHandler(session.NewModuleHandler("can.fuzz ID_OR_NODE_NAME", `(?i)^can\.fuzz\s+(.+)$`,
|
mod.AddHandler(session.NewModuleHandler("can.fuzz ID_OR_NODE_NAME", `(?i)^can\.fuzz\s+(.+)$`,
|
||||||
"If an integer frame ID is specified, create a randomized version of it and inject it. If a node name is specified, a random message for the given node will be instead used.",
|
"If an hexadecimal frame ID is specified, create a randomized version of it and inject it. If a node name is specified, a random message for the given node will be instead used.",
|
||||||
func(args []string) error {
|
func(args []string) error {
|
||||||
if !mod.Running() {
|
if !mod.Running() {
|
||||||
return errors.New("can module not running")
|
return errors.New("can module not running")
|
||||||
|
|
|
@ -16,8 +16,9 @@ func (mod *CANModule) Fuzz(id string) error {
|
||||||
rncSource := rand.NewSource(time.Now().Unix())
|
rncSource := rand.NewSource(time.Now().Unix())
|
||||||
rng := rand.New(rncSource)
|
rng := rand.New(rncSource)
|
||||||
|
|
||||||
// let's try as number first
|
// let's try as an hex number first
|
||||||
frameID, err := strconv.Atoi(id)
|
// frameID, err := strconv.Atoi(id)
|
||||||
|
frameID, err := strconv.ParseUint(id, 16, 32)
|
||||||
dataLen := 0
|
dataLen := 0
|
||||||
frameData := ([]byte)(nil)
|
frameData := ([]byte)(nil)
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ func (mod *CANModule) Fuzz(id string) error {
|
||||||
idx := rng.Intn(len(fromSender))
|
idx := rng.Intn(len(fromSender))
|
||||||
selected := fromSender[idx]
|
selected := fromSender[idx]
|
||||||
mod.Info("selected %s > (%d) %s", id, selected.ID, selected.Name)
|
mod.Info("selected %s > (%d) %s", id, selected.ID, selected.Name)
|
||||||
frameID = int(selected.ID)
|
frameID = uint64(selected.ID)
|
||||||
} else {
|
} else {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue