Skip to content

Instantly share code, notes, and snippets.

@mnaberez
mnaberez / crack.py
Created April 6, 2018 16:32
Bruce force crack a VW Premium 4 or 5 radio with a Raspberry Pi and 5 relays
"""
This program uses a Raspberry Pi controlling 5 relays to brute force crack
a VW Premium 4 or 5 radio.
The radio allows two code entry attempts per hour. After each failed attempt,
it writes the attempt count its onboard EEPROM. After two failed attempts,
the radio displays "SAFE" and is locked out for an hour. The radio must
remain powered on for an hour to unlock, which gives two more attempts. If the
radio is powered off and then on again, it will read the attempt count from the
EEPROM and stay locked out for an hour. The radio seems to track attempts only
@mnaberez
mnaberez / bitdiffs.py
Created January 9, 2018 18:19
Show single bit differences between two files
#!/usr/bin/env python3 -u
import sys
def bitdiffs(a, b):
diffs = []
for bitnum, bitweight in enumerate([1, 2, 4, 8, 16, 32, 64, 128]):
if (a & bitweight) != (b & bitweight):
diffs.append(bitnum)
return diffs
@mnaberez
mnaberez / gpio-input.py
Last active August 8, 2017 21:52
Exercise GreatFET GPIO from the host
#!/usr/bin/env python
import sys
import time
from greatfet import GreatFET
from greatfet.peripherals.gpio import J1, J2, J7, Directions
port, pin = sys.argv[1].upper().strip().split('.')
line = getattr(globals()[port], pin)
@mnaberez
mnaberez / knightrider.py
Last active August 8, 2017 21:36
Display the Knight Rider pattern on the GreatFET onboard LEDs
import time
from greatfet import GreatFET
from greatfet.protocol import vendor_requests
from greatfet.peripherals.gpio import J1, Directions
LED1 = (3, 14)
LED2 = (2, 1)
LED3 = (3, 13)
LED4 = (3, 12)
@mnaberez
mnaberez / gpio-scu.py
Last active August 6, 2017 20:01
Generate a table mapping LPC 4330 GPIO registers to libopencm3 SCU pin constants
import re
with open("gpio-scu.txt") as f:
lines = f.read().splitlines()
D = {}
for i, line in enumerate(lines):
jp, lpc_pin, gpio, func = line.split()
gpio_port, gpio_pin = [ int(x) for x in re.findall(r'GPIO(\d)\[(\d+)\]', gpio)[0] ]
@mnaberez
mnaberez / reset.py
Last active August 8, 2017 22:05
Reset a GreatFET via another GreatFET and wait for NXP DFU bootloader
#!/usr/bin/env python
import os
import subprocess
import time
from greatfet import GreatFET
from greatfet.peripherals.gpio import J1, Directions
line = J1.P3
@mnaberez
mnaberez / build_asxxxx.txt
Last active January 27, 2019 21:55
Build ASXXXX with F2MC8L support on macOS Sierra
$ wget http://shop-pdp.net/_ftp/asxxxx/asxs5p30.zip
$ unzip asxs5p30.zip
$ cd asxv5pxx/asxmak/linux/build
$ make
$ ./asf2mc8
@mnaberez
mnaberez / Info.plist
Created September 10, 2016 22:41
Atmel-ICE on MacOS X
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Based on https://github.com/jakeh12/atmel-ice-mac-driver -->
<!-- This is a dummy driver which binds to Atmel ICE. It -->
<!-- contains no actual code; its only purpose is to -->
<!-- prevent Apple's USBHID driver from exclusively -->
<!-- opening the device. -->
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
@mnaberez
mnaberez / sony_mdx_c7900r_charset.py
Last active February 1, 2016 17:51
Sony MDX-C7900R Faceplate NEC µPD16432B ROM charset
#!/usr/bin/env python
_SONY_MDX_C7900R = '''
0x00: 0x01: 0x02: 0x03: 0x04: 0x05: 0x06: 0x07:
..... ..... ..... ..... ..... ..... ..... .....
..... ..... ..... ..... ..... ..... ..... .....
..... ..... ..... ..... ..... ..... ..... .....
..... ..... ..... ..... ..... ..... ..... .....
..... ..... ..... ..... ..... ..... ..... .....
..... ..... ..... ..... ..... ..... ..... .....
@mnaberez
mnaberez / 1571mode.sh
Created December 15, 2014 21:21
Put a 1571 into double-sided (1571) or single-sided (1541) mode using cbmctrl.
#!/bin/bash
#
# Put a 1571 into double-sided (1571) or single-sided (1541) mode
# using cbmctrl.
if [ $# -lt 1 ]; then
echo "Usage: $0 <unit number> <1541|1571>"
exit 2
fi