mirror of
https://github.com/bettercap/bettercap
synced 2025-07-30 11:40:33 -07:00
new: implemented can.inject
This commit is contained in:
parent
5fe3ef3d52
commit
fd05df613e
3 changed files with 37 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
package can
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
|
||||
"github.com/bettercap/bettercap/session"
|
||||
|
@ -18,6 +19,7 @@ type CANModule struct {
|
|||
|
||||
conn net.Conn
|
||||
recv *socketcan.Receiver
|
||||
send *socketcan.Transmitter
|
||||
}
|
||||
|
||||
func NewCanModule(s *session.Session) *CANModule {
|
||||
|
@ -68,6 +70,15 @@ func NewCanModule(s *session.Session) *CANModule {
|
|||
return mod.Show()
|
||||
}))
|
||||
|
||||
mod.AddHandler(session.NewModuleHandler("can.inject FRAME_EXPRESSION", `(?i)^can\.inject\s+([a-fA-F0-9#R]+)$`,
|
||||
"Parse FRAME_EXPRESSION as 'id#data' and inject it as a CAN frame.",
|
||||
func(args []string) error {
|
||||
if !mod.Running() {
|
||||
return errors.New("can module not running")
|
||||
}
|
||||
return mod.Inject(args[0])
|
||||
}))
|
||||
|
||||
return mod
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue