eik00d / cantoolz Goto Github PK
View Code? Open in Web Editor NEWThis project forked from cantoolz/cantoolz
CANToolz - framework for black-box CAN network analysis
Home Page: https://asintsov.blogspot.de/
License: Other
This project forked from cantoolz/cantoolz
CANToolz - framework for black-box CAN network analysis
Home Page: https://asintsov.blogspot.de/
License: Other
Hi there,
I've encountered an issue when using a kvaser equipment with CANToolz using the hw_CANSocket module. I've tried using a custom fuzzing module with the hw_CANSocket that blasts packets without any delay and the hw_CANSocket module threw the exception [Errorno 105] No buffer space available
instantly from line 112.
Adding a dummy delay before that fixed the issue, with something like:
def do_write(self, can_msg):
if can_msg.CANData:
idf = can_msg.CANFrame.frame_id
if can_msg.CANFrame.frame_ext:
idf |= 0x80000000
data = struct.pack("I", idf) + struct.pack("B", can_msg.CANFrame.frame_length)+ b"\xff\xff\xff" + can_msg.CANFrame.frame_raw_data[0:can_msg.CANFrame.frame_length] + b"0"*(8-can_msg.CANFrame.frame_length)
# Adding delay to prevent congestion
time.sleep(.05)
self.socket.send(data)
self.dprint(2, "WRITE: " + self.get_hex(data))
return can_msg
The modification above is not the proper fix obviously, and I believe that I should add a delay option in the custom fuzzing module. However, I think that the hw_CANSocket module should have a delay option that could be specified in the configuration file with a default value set to something like 50 milliseconds, which could then be overridden by the user.
Hi there,
Nothing urgent there, only a first-time user experience I wanted to share with you.
When sending empty or invalid CAN frame, the web interface doesn't show any error. The exception is fully shown in the console (which is good IMO) but the web interface should at least display a generic error message.
Sending an empty frame will raise an exception in cantoolz
:
Traceback (most recent call last):
File "cantoolz.py", line 110, in do_POST
text = self.can_engine.call_module(self.can_engine.find_module(str(path_parts[3])), str(paramz))
File "/home/pop/can/CANToolz/cantoolz/engine.py", line 97, in call_module
ret = self._enabledList[x][1].raw_write(params)
File "/home/pop/can/CANToolz/cantoolz/module.py", line 60, in raw_write
ret = cmd[3](cmd[5])
TypeError: dev_write() missing 1 required positional argument: 'data'
Sending a malformed frame like aa
will raise:
Traceback (most recent call last):
File "cantoolz.py", line 110, in do_POST
text = self.can_engine.call_module(self.can_engine.find_module(str(path_parts[3])), str(paramz))
File "/home/pop/can/CANToolz/cantoolz/engine.py", line 97, in call_module
ret = self._enabledList[x][1].raw_write(params)
File "/home/pop/can/CANToolz/cantoolz/module.py", line 58, in raw_write
ret = cmd[3](cmd[5], lost_cmd)
File "/home/pop/can/CANToolz/cantoolz/modules/hw_CANSocket.py", line 39, in dev_write
idf, dataf = data.strip().split('#')
ValueError: not enough values to unpack (expected 2, got 1)
Sending a malformed frame like a#a
will raise:
Traceback (most recent call last):
File "cantoolz.py", line 110, in do_POST
text = self.can_engine.call_module(self.can_engine.find_module(str(path_parts[3])), str(paramz))
File "/home/pop/can/CANToolz/cantoolz/engine.py", line 97, in call_module
ret = self._enabledList[x][1].raw_write(params)
File "/home/pop/can/CANToolz/cantoolz/module.py", line 58, in raw_write
ret = cmd[3](cmd[5], lost_cmd)
File "/home/pop/can/CANToolz/cantoolz/modules/hw_CANSocket.py", line 40, in dev_write
dataf = bytes.fromhex(dataf)
ValueError: non-hexadecimal number found in fromhex() arg at position 0
Hi there,
Nothing urgent there, only a first-time user experience I wanted to share with you.
Trying out with the hw_CANSocket
module, I noticed that the exceptions raised during errors were only shown in the console but not in the interface. For instance, with the following broken configuration:
load_modules = {
'hw_CANSocket': {'iface':'vcanINVALID', 'speed': 500},
'mod_stat': {}
}
actions = [
{'hw_CANSocket': {'action': 'read','pipe': 1}}
{'mod_stat': {'action': 'read', 'pipe': 1}}
]
Clicking on Start/Stop
will show the following exception in the console:
$ python3 cantoolz.py -g w -c can_socket.py
_____ _ _ _______ _
/ ____| /\ | \ | |__ __| | |
| | / \ | \| | | | ___ ___ | |____
| | / /\ \ | . ` | | |/ _ \ / _ \| |_ /
| |____ / ____ \| |\ | | | (_) | (_) | |/ /
\_____/_/ \_\_| \_| |_|\___/ \___/|_/___|
('CANtoolz WEB started at port: ', 4444)
To exit CTRL-C...
[*] HTTPD: Received connection from 127.0.0.1
[*] HTTPD: Received connection from 127.0.0.1
[*] HTTPD: Received connection from 127.0.0.1
[*] HTTPD: Received connection from 127.0.0.1
[*] HTTPD: Received connection from 127.0.0.1
127.0.0.1 - - [12/Mar/2017 17:46:31] "GET /api/status HTTP/1.1" 200 -
127.0.0.1 - - [12/Mar/2017 17:46:31] "GET /api/status HTTP/1.1" 200 -
127.0.0.1 - - [12/Mar/2017 17:46:31] "GET /api/status HTTP/1.1" 200 -
127.0.0.1 - - [12/Mar/2017 17:46:31] "GET /api/status HTTP/1.1" 200 -
127.0.0.1 - - [12/Mar/2017 17:46:31] "GET /api/status HTTP/1.1" 200 -
127.0.0.1 - - [12/Mar/2017 17:46:31] "GET /api/status HTTP/1.1" 200 -
hw_CANSocket: ERROR: [Errno 19] No such device
127.0.0.1 - - [12/Mar/2017 17:46:31] "GET /api/status HTTP/1.1" 200 -
127.0.0.1 - - [12/Mar/2017 17:46:31] "GET /api/start HTTP/1.1" 200 -
127.0.0.1 - - [12/Mar/2017 17:46:31] "GET /api/start HTTP/1.1" 200 -
127.0.0.1 - - [12/Mar/2017 17:46:31] "GET /api/status HTTP/1.1" 200 -
127.0.0.1 - - [12/Mar/2017 17:46:32] "GET /api/status HTTP/1.1" 200 -
^CPlease wait... (do not press ctr-c again!)
gg bb
pop@debian:~/can/CANToolz$
But nothing on the web interface. Checking the module status, it shows Current status: True
but nothing more.
It would be more pertinent to have:
To reproduce, simply run cantoolz
with the configuration above and click on Start/Stop
in the web interface.
In the Wiki example https://github.com/eik00d/CANToolz/wiki/uds_scan, the CANToolz configuration contains an error (I suppose the code was updated since the configuration was first created).
Having sub
set to None
will trigger an exception in the module gen_ping
.
Using:
{'gen_ping': { # Generate UDS requests
'pipe': 2,
'delay': 0.06,
'range': [1, 2047], # ID range (from 1790 to 1794)
'services':[{'service': 0x10, 'sub': 0x01},
{'service': 0x3E, 'sub': None},
{'service': 0x3E, 'sub': 0x01}],
'mode':'UDS'}
},
Will raise the following exception:
Traceback (most recent call last):
File "cantoolz.py", line 172, in do_GET
modz = self.can_engine.start_loop()
File "/CANToolz/cantoolz/engine.py", line 114, in start_loop
module.do_start(params)
File "/CANToolz/cantoolz/modules/gen_ping.py", line 106, in do_start
for sb in sub:
TypeError: 'NoneType' object is not iterable
@eik00d It seems that you merged #86 but you didn't configure the github repository to actually use Travis. Not sure if that was intentional and you were going to do it soon or if you forgot.
So this issue is more of a reminder in case you forgot (see: https://travis-ci.org/eik00d/CANToolz)
Let me know if I'm missing something and sorry if I'm a pain :/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.