Skip to content

jakka351/j2534

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

J2534 on Linux

Trying this code out on a Raspberry Pi. Heres what happened.
Run the python command to attempt connecting and sending a message.
sudo python3 j2534_send.py --protocol can --baud 500000 --id 0x7DF --data 02 01 00 --wait 1000 image

Testing with Mongoose Pro J2534 on Kali Linux

Build and Compilation steps

This is test code for setting up a Mongoose Pro J2534 device on Kali Linux, it is still a work in progresss

Enter the src directory
cd ~/j2534/src

Install the necessary packages
sudo apt install -y build-essential pkg-config libusb-1.0-0-dev

Compile with gcc
gcc -Wall -Wextra -o test_mongoose test_mongoose.c mongoose_backend.c $(pkg-config --cflags --libs libusb-1.0)

List test_mongoose
ls -l test_mongoose || true

Remove test_mongoose
sudo rm -f test_mongoose

Change Owner sudo chown "$USER":"$USER"

Fiaal Compile
gcc -Wall -Wextra -o test_mongoose test_mongoose.c mongoose_backend.c $(pkg-config --cflags --libs libusb-1.0)

Test Mongoose
./test_mongoose

Expected output

Mongoose opened: in_ep=0x81 out_ep=0x02 iface=0
No data (timeout) — expected until we implement protocol handshake.

Drewtech's USB Protocol

Using Wireshark to sniff USB and J2534 API calls

Install wireshark as normal, making sure to install the addin package for USB PCAP Sniffing as well. Run Wireshark and select the USB Capture interface.

Sniffing

  1. Plug in the J2534 device to USB.
  2. Send Passthru Load library/Passthru Connect/Passthru Open requests via the J2534 API
  3. Send Passthru Disconnect/Passthru Cose requests via the J2534 API
  4. unplug the USB device
  5. Save the PCAP log (see saved log here saved in repo)

Next Steps

Analyse the data within the USB protocol. We are going to use the USB packets to talk to the J2534 device in Kali Linux. Raw Bytes:

0000   1c 00 60 2a 2d ea 05 99 ff ff 00 00 00 00 08 00
0010   00 01 00 08 00 00 02 08 00 00 00 00 40 db 01 00
0020   00 00 00 00

With a bit of help from ChatGPT, 572 Enhanced Packet Blocks were extracted from the USBPCAP log as binary files and matching hex files. We then created a Shim file that will replay the packets from Host -> Device.

Because of this we know that:
-The Mongoose protocol is proprietary. The only reliable way to implement a Linux backend is to replay/translate the exact request/response frames we see the official Windows driver use.
-The pcap log gave us those frames — they were extracted and packaged into a first-pass shim they can be tested on the live device and iterate.

Releases

No releases published

Packages

No packages published

Languages

  • C 83.0%
  • Python 9.0%
  • PowerShell 6.9%
  • Other 1.1%