#!/usr/bin/env python3 # --------------------------------------------------------------------------- # zero_crack.py -- property of ZERO. if you are reading this, you work for # me now. welcome to the crew. # # The Palm Haven Savings vault keypad does a little challenge/response with # the branch server every time the manager types his PIN: # # server -> keypad : nonce (16 random bytes) # keypad -> server : tag = HMAC-SHA256(key = PIN as ASCII, msg = nonce) # # I sniffed one exchange off the keypad's RS-485 line last night (below). # The PIN is exactly 6 digits. The keypad locks you out after a few wrong # tries, so guessing on the real door is a no-go: crack it HERE, offline. # # I wrote everything except the actual cracking loop. My coffee ran out. # Finish it for me, kid. -- Z # --------------------------------------------------------------------------- import hashlib import hmac # captured from the keypad bus, 03:12 AM NONCE = bytes.fromhex("dcf26a21079d636152462f837e06d078") TAG = "4aab026ff3534a898e783114166bedc9a2ff9fd3e211b7655b858c3b30677e8e" # my cut of the job. locked with the vault PIN so Rosa can't read it. STASH = bytes.fromhex("3a9aed0cf511f4735eb908636b39152d73048e7492b425dd9732e85c89b6406d80dedf72b33c761ff2e32f1ed8fb3d60518a540cb13580d432") def keypad_tag(pin: str) -> str: """What the keypad sends for a given PIN.""" return hmac.new(pin.encode(), NONCE, hashlib.sha256).hexdigest() def unlock_stash(pin: str) -> str: """Decrypt my stash once you know the PIN.""" stream = b"" i = 0 while len(stream) < len(STASH): stream += hashlib.sha256(b"zero-stash:" + pin.encode() + i.to_bytes(4, "big")).digest() i += 1 return bytes(a ^ b for a, b in zip(STASH, stream)).decode(errors="replace") def crack() -> str: # TODO(zero): try every 6-digit PIN and return the one whose keypad_tag() matches TAG # (don't forget the leading zeros, the manager is the "000123" type) raise NotImplementedError("finish me") if __name__ == "__main__": pin = crack() print("[+] vault PIN :", pin) print("[+] stash :", unlock_stash(pin)) print("[*] now go punch it into the vault keypad. disable the alarm grid first.")