CAN模拟器和CAN重放

环境准备

kali-linux-2022.1-vmware-amd64
apt-get install libsdl2-dev libsdl2-image-dev can-utils

https://github.com/zombieCraig/ICSim
https://github.com/zombieCraig/uds-server
https://github.com/CaringCaribou/caringcaribou

三个项目打包下载(包括修改好的caringcaribou):

https://download.kalipentest.cn/CAN.rar

启动仪表盘、遥控器、UDS服务环境

┌──(kali㉿kali)-[~/Desktop/ICSim]
└─$ ./icsim vcan0  
Using CAN interface vcan0


┌──(kali㉿kali)-[~/Desktop/ICSim]
└─$ ./controls vcan0                  
 Warning: No joysticks connected


┌──(kali㉿kali)-[~/Desktop/uds-server]
└─$ ./uds-server vcan0

修改caringcaribou项目

# 安装 python can 包
pip2 install python-can

# 切换到 tools 目录 
cd tool/lib
 
# 修改2个文件相关参数,否则会启动失败(分别是78行和41行)
sudo vim can_actions.py
self.bus = can.Bus(bustype='socketcan',channel=DEFAULT_INTERFACE)

sudo vim io15765_.py
self.bus = can.Bus(bustype='socketcan',channel=DEFAULT_INTERFACE)

UDS扫描

┌──(root㉿kali)-[/home/kali/Desktop/caringcaribou/tool]
└─# python2 cc.py -i vcan0 uds discovery

-------------------
CARING CARIBOU v0.3
-------------------

Loaded module 'uds'

Sending Diagnostic Session Control to 0x0710
  Verifying potential response from 0x0710
    Resending 0x710...  Success
Found diagnostics server listening at 0x0710, response at 0x077a
Sending Diagnostic Session Control to 0x07df
  Verifying potential response from 0x07df
    Resending 0x7df...  Success
Found diagnostics server listening at 0x07df, response at 0x077a
Sending Diagnostic Session Control to 0x07e0
  Verifying potential response from 0x07e0
    Resending 0x7e0...  Success
Found diagnostics server listening at 0x07e0, response at 0x077a
Sending Diagnostic Session Control to 0x07ff

Identified diagnostics:

+------------+------------+
| CLIENT ID  | SERVER ID  |
+------------+------------+
| 0x00000710 | 0x0000077a |
| 0x000007df | 0x0000077a |
| 0x000007e0 | 0x0000077a |
+------------+------------+

控制并准备录制

光标放在控制器界面上,就可以对模拟器进行操作:

功能	控制按钮
转向	键盘左右
速度	键盘上下
开/关左前车门	键盘右shift+A/键盘左shit+A
开/关右前车门	键盘右shift+B/键盘左shit+B
开/关左后车门	键盘右shift+X/键盘左shit+X
开/关右后车门	键盘右shift+Y/键盘左shit+Y
开启全部车门	键盘左shift+键盘右shift
关闭全部车门	键盘右shift+键盘左shift

CAN录制

┌──(root㉿kali)-[/home/kali/Desktop]
└─# candump vcan0 -l
Disabled standard output while logging.
Enabling Logfile 'candump-2023-02-24_162028.log'

CAN重放

┌──(root㉿kali)-[/home/kali/Desktop]
└─# canplayer -I candump-2023-02-24_145837.log

CAN单侦重放左转和右转

cat candump-2023-02-24_095642.log |grep 188#01000000 >left.log
cat candump-2023-02-24_095642.log |grep 188#02000000 >right.log

┌──(root㉿kali)-[/home/kali/Desktop]
└─# canplayer -I left.log                     

┌──(root㉿kali)-[/home/kali/Desktop]
└─# canplayer -I right.log 

参考

https://blog.csdn.net/weixin_34122028/article/details/113489839
https://www.cnblogs.com/Amalll/p/16349288.html
http://starvlab.qianxin.com/?p=590