mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
new: implemented can.dup and can.dump.inject to read a candump log file
This commit is contained in:
parent
840f819484
commit
7702207ee9
4 changed files with 108 additions and 14 deletions
|
@ -2,6 +2,7 @@ package can
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/bettercap/bettercap/v2/session"
|
||||
|
@ -13,6 +14,8 @@ type CANModule struct {
|
|||
session.SessionModule
|
||||
|
||||
deviceName string
|
||||
dumpName string
|
||||
dumpInject bool
|
||||
transport string
|
||||
filter string
|
||||
filterExpr *bexpr.Evaluator
|
||||
|
@ -30,6 +33,8 @@ func NewCanModule(s *session.Session) *CANModule {
|
|||
filterExpr: nil,
|
||||
transport: "can",
|
||||
deviceName: "can0",
|
||||
dumpName: "",
|
||||
dumpInject: false,
|
||||
}
|
||||
|
||||
mod.AddParam(session.NewStringParameter("can.device",
|
||||
|
@ -37,6 +42,15 @@ func NewCanModule(s *session.Session) *CANModule {
|
|||
"",
|
||||
"CAN-bus device."))
|
||||
|
||||
mod.AddParam(session.NewStringParameter("can.dump",
|
||||
mod.dumpName,
|
||||
"",
|
||||
"Load CAN traffic from this candump log file."))
|
||||
|
||||
mod.AddParam(session.NewBoolParameter("can.dump.inject",
|
||||
fmt.Sprintf("%v", mod.dumpInject),
|
||||
"Write CAN traffic read form the candump log file to the selected can.device."))
|
||||
|
||||
mod.AddParam(session.NewStringParameter("can.transport",
|
||||
mod.transport,
|
||||
"",
|
||||
|
@ -53,18 +67,6 @@ func NewCanModule(s *session.Session) *CANModule {
|
|||
return mod.Start()
|
||||
}))
|
||||
|
||||
mod.AddHandler(session.NewModuleHandler("can.load_dbc PATH", "",
|
||||
"Start CAN-bus discovery.",
|
||||
func(args []string) error {
|
||||
return mod.Start()
|
||||
}))
|
||||
|
||||
mod.AddHandler(session.NewModuleHandler("can.dbc.load NAME", "can.dbc.load (.+)",
|
||||
"Load a DBC file from the list of available ones or from disk.",
|
||||
func(args []string) error {
|
||||
return mod.dbcLoad(args[0])
|
||||
}))
|
||||
|
||||
mod.AddHandler(session.NewModuleHandler("can.recon off", "",
|
||||
"Stop CAN-bus discovery.",
|
||||
func(args []string) error {
|
||||
|
@ -84,6 +86,12 @@ func NewCanModule(s *session.Session) *CANModule {
|
|||
return mod.Show()
|
||||
}))
|
||||
|
||||
mod.AddHandler(session.NewModuleHandler("can.dbc.load NAME", "can.dbc.load (.+)",
|
||||
"Load a DBC file from the list of available ones or from disk.",
|
||||
func(args []string) error {
|
||||
return mod.dbcLoad(args[0])
|
||||
}))
|
||||
|
||||
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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue