Pyvit Python help

Hey all,
Been a member for a while but haven’t posted anything yet as life has been nuts. I’m starting to do some fuzzing of my car network. Don’t worry I know the dangers and am developing on a test bench a CANable, and a Raspberry Pi. I’ve written some simple scripts using can-utils and Python. I was looking around the webs and found a Python library called “pyvit” and it seemed a bit better than running 'system.os(cansend can0 message) each time.

I’m running into an issue though with my PoC code:


I’ve ran multiple variants of the code and examples of this code are available on several sites which are identical. However I can not get passed this issue. I’ve emailed the CANable site but got no response. Hoping someone here might have some insight?

Thanks in advance!

I think dev.start(‘can0’) should be dev.start()

And maybe this too at the top
from pyvit.hw.socketcan import SocketCanDev
from pyvit import can

You are missing the shebang. Either add a shebang, or start the script with the python interpreter.

python ./parrot.py

1 Like

So I was able to figure this one out and it ended up having a few issues.

I had to move the script into the pyvit folder (I wonder if putting pyvit into /usr/bin/ would fix this??)

I had to add the environment shebang as bolav stated

I had to set the alias of python to use python3. (I could have done this using the shebang I’ve found, but setting the standard to python3 is fine for my own usage

#! /usr/bin/python

import threading, time, os
import pyvit.can as can
from pyvit.hw import socketcan

dev = socketcan.SocketCanDev(‘can0’)
dev.start()

frame = can.Frame (0x123, [1, 2, 3, 4, 5, 6, 7, 8])

while True:
dev.send(frame)
time.sleep(.001)
t = threading.Thread(args=())
t.start()

Have fun DoS’ing your CAN network :stuck_out_tongue: