GithubHelp home page GithubHelp logo

eik00d / cantoolz Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cantoolz/cantoolz

304.0 46.0 14.0 1.91 MB

CANToolz - framework for black-box CAN network analysis

Home Page: https://asintsov.blogspot.de/

License: Other

Python 91.35% HTML 5.88% JavaScript 2.65% CSS 0.12%

cantoolz's Introduction

cantoolz's People

Contributors

bryant1410 avatar depierre avatar dukebarman avatar eik00d avatar kononencheg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cantoolz's Issues

hw_CANSocket errors could be shown in the web interface

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:

  • The full stack trace in the console (for troubleshooting purpose)
  • The exception name in the web interface (for user-friendliness)

To reproduce, simply run cantoolz with the configuration above and click on Start/Stop in the web interface.

Travis not enabled

@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 :/

hw_CANSocket exception when sending empty/malformed CAN frames

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

hw_CANSocket socket errorno 105

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.

TypeError: 'NoneType' object is not iterable in Wiki USD scan example

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.