Solving the Volkswagen CAN Checksum Challenge
π οΈ Solving the Volkswagen CAN Checksum Challenge (CRC8 AUTOSAR Style)
This challenge explores the calculation of a CRC8 checksum used in Volkswagen CAN messages. Specifically, it uses the AUTOSAR CRC8 with polynomial 0x2Fβa common checksum mechanism in automotive software stacks.
π― Challenge Statement
Compute the correct one-byte checksum
XX
for the CAN message with payloadXX0f0300
.
The flag format isCTF{XX}
.
Youβre provided with 15 CAN messages in the format:
<checksum><payload>
For example:
74000300
c1010300
31020300
...
The checksum is calculated over a 4-byte payload, where:
- The last byte is a βsecretβ byte
- The secret byte is derived from the CAN arbitration ID, which is not directly given
The checksum process includes:
- Appending the secret byte to the actual payload (3 bytes)
- Applying CRC8-AUTOSAR (Polynomial =
0x2F
, Init =0xFF
, Non-reversed) - XORing the result with
0xFF
π Step-by-Step Solution
Step 1: CRC Function Setup
import crcmod
# Setup AUTOSAR CRC8 with polynomial 0x2F
crc = crcmod.mkCrcFun(poly=0x12F, initCrc=0xFF, rev=False)
Step 2: Deduce the Secret Byte
We reverse-engineer the secret byte by iterating over all possible 0-255 values.
# Known payload from one message, excluding checksum
payload = b' ' # corresponds to '000300'
for secret in range(256):
test_data = payload + secret.to_bytes(1, 'big')
computed_checksum = crc(test_data) ^ 0xFF
if computed_checksum == 0x74: # from '74000300'
print(f"Secret byte found: {hex(secret)}")
β
This reveals the secret byte is 0xC3
Step 3: Solve the CTF Payload
With the secret byte found, apply it to the new payload.
new_payload = b' ' + b'Γ'
checksum = crc(new_payload) ^ 0xFF
print(f"CTF flag: CTF}")
β
Output: CTF{35}
β Final Answer
CTF{35}
π Summary
Step | Action |
---|---|
1οΈβ£ | Set up AUTOSAR CRC8 function |
2οΈβ£ | Brute force to find the secret byte using sample messages |
3οΈβ£ | Use found byte to calculate checksum for new payload |
π References
Stay secure and happy reversing! π
Published by Kartheek Lade