wsl下kali子系统添加socketcan模块支持

编译内核添加socketcan支持(其他内核编译也同理)

最近玩到车联网安全,其实虚拟机已经完全够了,但是我想着在自己主机能更加方便,就搞了个wsl下kali的子系统,但是wsl下的kali没有socketcan支持,就要重新编译内核添加支持

更新apt包

sudo apt update -y && sudo apt upgrade -y

把编译所需要的库装好

sudo apt-get install -y autoconf  bison build-essential flex libelf-dev libncurses-dev libssl-dev libtool libudev-dev bc

使用uname -r查看内核版本

然后使用wget下载对应的版本内核包

sudo wget https://github.com/microsoft/WSL2-Linux-Kernel/archive/refs/tags/linux-msft-wsl-5.15.90.1.tar.gz

使用tar解压缩

tar -zxf linux-msft-wsl-5.15.90.1.tar.gz

cd进入目录后,使用

sudo make menuconfig KCONFIG_CONFIG=Microsoft/config-wsl

其中KCONFIG_CONFIG=Microsoft/config-wsl是包里面自带的.config文件,实际上使用自动生成的.config文件也可以,但是还是使用包里面的靠谱。

然后选择Networking support->CAN BUS subsystem support开启所需要的相关CAN模块,保存的时候就会自动保存在Microsoft/config-wsl中。然后后续使用编译的时候加多一个KCONFIG_CONFIG=Microsoft/config-wsl就行。

接下来就是枯燥的make环节

sudo make prepare modules_prepare -j $(expr $(nproc) - 1) KCONFIG_CONFIG=Microsoft/config-wsl
sudo make modules -j $(expr $(nproc) - 1) KCONFIG_CONFIG=Microsoft/config-wsl
sudo make modules -j $(expr $(nproc) - 1) KCONFIG_CONFIG=Microsoft/config-wsl
sudo make install KCONFIG_CONFIG=Microsoft/config-wsl

复制vmlinux到本机Users目录下,这个目录可变,只要后面的.wslconfig里的路径kernel指向目录就行

# copy it to windows drive
cp vmlinux /mnt/c/Users/<yourwindowsloginname>/

创建.wslconfig

#create this file, change /<yourwindowsloginname> to your windows users directory name
vi /mnt/c/Users/<yourwindowsloginname>/.wslconfig

填上刚刚vmlinux移动的路径

#with these contents
[wsl2]
kernel=C:\\Users\\<yourwindowsloginname>\\vmlinux

保存后退出wsl

exit

退出后使用shutdown停止再启动

wsl --shutdown
wsl

然后就可以使用socketcan模块了~

sudo modprobe can
sudo modprobe vcan
sudo modprobe can_raw
sudo ip link add dev vcan0 type vcan
sudo ip link set up vcan0
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值