Z-Wave S0: network key
Hotel door locks operate on a Z-Wave network. While the service technician was adding a lock to the network, a radio sniffer was running nearby. The recording captured two different Z-Wave networks (two Home IDs): zwave.csv.
File columns: frame,time_ms,home_id,src,dst,rssi_dbm,payload_hex. payload_hex — the application layer payload of the Z-Wave frame (the first byte = command class). The device of interest: node 10 (a door lock), the controller — node 1. Other networks and other nodes are decoys.
Security (S0, command class 0x98) in brief: 0x40 Nonce Get; 0x80 Nonce Report (an 8-byte nonce, whose first byte is the nonce ID); 0x81 / 0xC1 Message Encapsulation (C1 — also requests a new nonce at the same time). Structure: 98 cmd | senderNonce(8) | shifrlangan | receiverNonceID(1) | MAC(8). Keys: Kenc = AES(K, 0xAA*16), Kauth = AES(K, 0x55*16). Encryption — AES-OFB, IV = senderNonce || receiverNonce. MAC — AES-CBC-MAC (with Kauth): the initial state = AES(Kauth, IV), followed by the cmd | sender | receiver | uzunlik(shifrlanganning) | shifrlangan blocks (zero-padded up to a 16-byte block); MAC = the first 8 bytes of the last block. Plaintext: 1 byte sequence (bit 4 = sequenced, bit 5 = second fragment, lower 4 bits = counter) + the command.
The Network Key Set (98 06) command that delivers the network key was sent when there was no network key yet, so it is protected with a temporary key consisting of 16 zero bytes. After that, Door Lock (0x62) and User Code (0x63: 63 01 userID status kod..., status 1 = active, 0 = disabled) commands were sent to the lock. A long code was sent split into two S0 frames.
Task: the long user code (ASCII) that is active at the end of the recording on the node 10 lock is the flag: BAYROQ{...} (the last 16 characters are lowercase hex). Temporarily disabled codes are not the flag.