Open source vehicle security in a box!
AutoSecurityBox is a project that aims to enhance the security of classic and antique vehicles that lack transponder keys or keyless ignitions by switching the starter solenoid coil wire with a logic-level relay immediately after the ignition switch inside the steering column. The controller emulates the function of a transponder key by preventing cranking of the vehicle until a valid nfc tag (or your choice of input) is detected.
The driver presents a registered card to a hidden reader antenna, then ASB hashes the UID of the card and compares it to a stored hash. If they match the relay closes and the vehicle can then be started as normal. If the presented card does not match a valid record then the script will panic and lockout, preventing future attempts at starting the vehicle until you reset it.
- Do not wire in a way that prevents vehicle operation during emergencies.
- Follow automotive electrical safety standards: Disconnect the battery before installation/testing, fuse positive lines at source with correct values, and verify wiring before reconnecting the battery.
- This is not tamper-proof security; it simply dissuades potential thieves by increasing the complexity of the starter system.
- Freezing modules in
/libandkeys.jsonhash as bytecode in firmware greatly increases tamper resistance! - You are solely responsible for your safety and the functionality/warranty of your vehicle.
- For safety purposes I have programmed ASB with a built in "standby-mode".
- It is recommended to leave the vehicle in standby-mode during normal operation in case of engine stall so you can recover it without presenting a card.
- For this reason after a valid card is presented in auth-mode, by default the system automatically switches to standby-mode.
To get started, follow schema.png to wire board and modules. You may also refer to this page for detailed reader setup instructions.
After the board and external modules are assembled, choose an enclosure and mounting location. I chose to mount mine inside the steering column, positioning the reader in a manner so that cards could be read through the plastic column. Decide if you are using the Python modules as-is or if you are freezing them as bytecode in firmware. If you are using them as-is, place all modules in
/lib. Then placemain.pyin the/directory of the board using a USB cable and your choice of IDE. See dependencies.
On the initial run,
keys.jsonwill be generated in/automatically. Using Thonny or your preferred IDE, runmain.pyagain and wait for the reader to initialize (~7-10 seconds) and then scan the card you wish to register. The debug console will print the UID of the card. Copy it or write it down and then stopmain.py. Then editkeys.jsonand replace the JSON data keysk0,k1, andk2with the SHA256 hash of the UID of the cards you wish to register. Then add the hash toasb_cryptvariablekh. Now runmain.pyone more time and verify that scanning the card results in an "Access Granted!" print statement.
The goal of this project is to provide security for parked vehicles that lack native anti-theft systems. AutoSecurityBox implements a dual-mode approach to provide security when it is necessary and maintain simplicity and reliability when it is not, especially during active operation of the vehicle and while recovering from stalls.
- Standby Mode/Disarmed
- Auth Mode/Armed
By default
config.jsonis generated with the mode (data key m0) set to standby (int 1010). Whenasb.pyruns it checks this data key and if in standby mode, it closes the starter relay for a duration in seconds equal to the value of the data keydisarm_sleep. Then it opens the relay and initializes the reader for a duration ofreader_sleepxptickMaxseconds to allow the user to arm the system. Finally it exits, and if a valid card was scanned, overwrites data keym0with the string"auth".
When
asb.pyruns it checks this data key and if in auth/armed mode, initializes the reader for a duration equal to the value of the data keyreader_sleepxptickMaxseconds. If a valid card is scanned during this time, the system will close the starter relay forarm_sleepseconds, disarm and exit on "system-disarmed" and on the next power cycle it will return to standby-mode operation. If no card is scanned, it will exit on "routine-timeout".
For added security: If three read attempts are made with an invalid card, it overwrites the data key
m0with the string"panic"and then resets the board. This puts the program into a tertiary mode that will refuse to initialize the reader or actuate the starter relay; Instead exiting on "system-panic" untilm0is updated to either"auth"or"standby".
I've implemented SHA256 hashing of scanned card UIDs, stored UIDs, and the key file itsself. You will have to manually hash your UIDs before inputting them into keys.json. Then hash keys.json and input it into asb_crypt.py before freezing modules and compiling firmware.
The goal of this project is not government quality security. Instead, the hope is to increase the difficulty, time, and technical requirements for a potential thief to get away with the vehicle. In the future I plan to also control the fuel pump or ignition system. Though, this would require the board and relays to remain powered during operation of the vehicle.
Mode values are arbitrary and may be changed by the end user so long as each corresponding reference in
asb.pyis also changed to match its partner. They exist solely to act as a magic number so that the Microcontroller can track state changes between power cycles without a backup battery.
You may notice a diode on
5v+_Vsysinschema.png. I added it between the supply and the microcontroller to isolate the converter output from the debug cable's5v+to prevent backfeeding of the buck converter during programming.