SLE4442 is a smart chip card with 256 bytes of memory and a write protect “passcode” feature. These have been around for quite some time, and were commonly used as stored value cards for copy machines and laundry machines. A three byte passcode protects the card from unauthorized writes.

After three incorrect passcode attempts the card is permanently locked to prevent brute force guessing the code. Data can be read without a passcode, the code is only necessary to write to the card (e.g. add more money for copy or laundry machines).

This insecure system should be avoided in new designs. Anyone with access to the machine that updates the card value can use a logic analyzer to capture the passcode. The passcode is sent in the clear, and can be easily captured and replayed.

🛒

Get Bus Pirate & Accessories

Connections

Common IC cards usually follow the ISO 7816-3 standard and have the same pinout and contact shape. Image source.

Bus PirateSLE4442Description
IO0/SDAC7 - I/OBidirectional data
IO1/SCLC3 - CLKClock
IO2/RSTC2 - RSTReset
VoutC1 - VCC5volt power supply
GNDC5 - GNDGround

Connect the Bus Pirate to the smart card as shown in the table above.

Card Identification

The card on the left with the smaller 6 pin contact area is a SLE4442. The card on the right with the larger 8 pin contact area is a 24C02 EEPROM card.

Smart IC Card and SIM card adapter

It’s possible to gently solder wires onto each pad of the chip, but a KF-011C (or similar) smart card socket is useful if you don’t want to destroy the card.

See it in action

Setup

Bus Pirate [/dev/ttyS0]
HiZ> m 2wire

Mode: 2WIRE
2WIRE speed
 1kHz to 1000kHz
 x. Exit
kHz (400kHz*) > 20
2WIRE> 

Bus Pirate 2-WIRE mode has a bi-directional data line and a clock line, it will play well with the SLE4442. SLE4442 (clones) generally have a maximum speed of 50kHz, but some are much happier at lower speeds so let’s use 20kHz.

  • m 2wire - Select 2-WIRE mode.
  • 20 - Configure 2-WIRE for 20kHz
Bus Pirate [/dev/ttyS0]
2WIRE> W 5
5.00V requested, closest value: 5.00V
300.0mA requested, closest value: 300.0mA

Power supply:Enabled
Vreg output: 5.0V, Vref/Vout pin: 5.0V, Current: 2.9mA

2WIRE> 

This is old tech - it needs a 5volt power supply.

Bus Pirate [/dev/ttyS0]
2WIRE> P
Pull-up resistors: Enabled (10K ohms @ 5.0V)

2WIRE> 

The bidirectional data line is an open collector bus, the Bus Pirate and the SLE4442 can only pull the line low to 0/ground. A pull-up resistor is needed to pull the line high to 1/5volts. The Bus Pirate has built-in pull-up resistors that can be enabled with the P command.

Bus Pirate [/dev/ttyS0]
2WIRE> L
Bitorder: LSB 0b00000001
2WIRE> 

SLE4442 commands and output are in the less-used Least Signification Bit (LSB) byte/word format. Enter L to set the Bus Pirate to LSB mode.

Answer To Reset (ATR)

Answer To Reset (ATR) is a command sequence sent to reset and initialize the SLE4442. This diagram on page 10 of the datasheet shows the ATR sequence.

  • After enabling power (VCC), the reset line (RST) low should start low.
  • RST is set to high
  • A single clock tick on the CLK line
  • RST is set to low
  • Provide 32 more clock ticks and read the 4 byte (32 bit) response on the IO line

The card returns 4 bytes that can be used to identify the card type and capabilities.

Bus Pirate [/dev/ttyS0]
2WIRE> } { ^ }  r:4 

RST LOW
RST HIGH
Tick clock: 1
RST LOW
RX: 0xA2 0x13 0x10 0x91 
2WIRE> 

Let’s send the ATR command via the Bus Pirate.

  • } - RST/reset line low to start
  • { - RST high to begin the ATR
  • ^ - One clock tick on the CLK/clock line
  • } - RST low completes the reset sequence
  • r:4 - Read the four byte ‘answer’ to the reset sequence

In the logic analyzer capture above, flag 0 marks after RESET is high and just before the single clock tick. RESET then goes low, and at flag 1 we clock out four bytes of data from the card on DIO.

The correct reply for the SLE4442 is 0xa2 0x13 0x10 0x91. This indicates the card is an SLE44xx series card, with 256 data units of 8 bits each (256 bytes). Wikipedia has a table that explains the meaning of each field in the ATR response, or see page 25 of the datasheet.

Bus Pirate [/dev/ttyS0]
2WIRE> sle4442
--SLE44xx decoder--
ATR: 0xa2 0x13 0x10 0x91
Protocol Type: S 10
Structure Identifier: General Purpose (Structure 1)
Read: Read to end
Data Units: 256
Data Units Bits: 8
Security memory: 0x07 0x00 0x00 0x00
Remaining attempts: 3 (0x7)

2WIRE> 

The sle4442 command automates the ATR and parses the output.

Read card memory

Now that the card is reset, we can interface it with a 2 wire protocol that has I2C-like START and STOP bits. Page 14 of the datasheet shows the protocol: each 3 byte command begins with a START bit and ends with a STOP bit. The Bus Pirate 2-WIRE mode sends START and STOP bits using the [/] commands.

Main memory is read with the 0x30 command. The next byte is the address to start reading from (0-255), and the last byte doesn’t matter for this command. The entire 256 byte contents of the card must be read before the card will accept another command.

Bus Pirate [/dev/ttyS0]
2WIRE> [ 0x30 0x00 0x00 ] r:256

I2C START
TX: 0x30 0x00 0x00 
I2C STOP
RX: 0xA2 0x13 0x10 0x91 0xFF 0xFF 0x81 0x15 
    0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 
    0xFF 0xFF 0xFF 0xFF 0xFF 0xD2 0x76 0x00 
    0x00 0x04 0x00 0xFF 0xFF 0xFF 0xFF 0xFF 
    0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 
...bytes removed...
    0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 
    
2WIRE> 

Let’s put that all together. Begin the command with a START bit, then send the command, address and dummy bytes, end with a STOP bit. Finally, read all 256 bytes from the card.

  • [ - I2C style START bit
  • 0x30 - Read memory command
  • 0x00 - Start reading from address 0x00
  • 0x00 - Dummy byte, no function in SLE4442
  • ] - I2C style STOP bit
  • r:256 - Read 256 bytes

The first 32 bytes or so include the ATR data and some other information about the card (depending on manufacturer). On a new card the rest of the memory will be 0xFF.

Unlock write access

The SLE4442 has a write protect feature that requires a 3 byte passcode to write to the card. After three incorrect passcode attempts the card is permanently locked to prevent brute force guessing of the code.

Read security memory

CommandControlAddressDataReadRemark
Read Security Memory31HNo effectNo effect4 bytesCheck Error Counter (byte 1)

A four byte security memory area contains the remaining unlock attempts, and the three byte passcode. The three passcode bytes will always read 0x00 when the card is locked. Read the security memory using the 0x31 command.

Bus Pirate [/dev/ttyS0]
2WIRE> [ 0x31 0x00 0x00 ] r:4

I2C START
TX: 0x31 0x00 0x00 
I2C STOP
RX: 0x07 0x00 0x00 0x00 
2WIRE> 

The command to read the security memory is similar to the command to read the main memory, but with a different command byte. The command is:

  • [ - I2C style START bit
  • 0x31 - Read security memory command
  • 0x00 - Start reading from address 0x00
  • 0x00 - Dummy byte, no function in SLE4442
  • ] - I2C style STOP bit
  • r:4 - Read 4 bytes

The first byte of the response (0x07) indicates the number of unlock attempts that remain. The remaining bytes are the passcode, which will always be 0x00 if the card is locked.

Bus Pirate [/dev/ttyS0]
2WIRE> = 0x07
 =0x07 =7 =0b00000111
2WIRE> 

Converting 0x07 to binary (0b111) indicates that 3 attempts remain on this card.

Send passcode

CommandControlAddressDataRemark
Compare Verification Data33H01H-03HPasscode bytes 1-3Send >256 clock ticks for processing
Update Security Memory39H00HError CounterWrite free bit in Error Counter: 0000 0ddd binary

Unlocking the card is a multiple step process:

  • Choose a remaining passcode attempt bit using the 0x39 command
  • Write each byte of the passcode using the 0x33 command
  • Reset the remaining passcode attempts using the 0x39 command
  • Read the security memory again to verify the passcode was accepted

Choose a remaining passcode attempt bit

Bus Pirate [/dev/ttyS0]
2WIRE> [ 0x39 0x00 0b110 ] ^:1000

I2C START
TX: 0x39 0x00 
TX: 0b00000110 
I2C STOP
Tick clock: 1000
2WIRE> 

The first byte in the security memory is 0x07 (0b111). This means that three passcode attempts remain. We need to choose a ‘1’ bit to use for the next passcode attempt. If we enter the wrong passcode, this bit will be set to 0 and two attempts will remain.

  • [ - I2C style START bit
  • 0x39 - Update security memory command
  • 0x00 - Security memory address to write
  • 0b110 - Choose a remaining passcode attempt bit, we’re using bit 0 (0b110), but any bit with a ‘1’ will work (0b011, 0b101)
  • ] - I2C style STOP bit
  • ^:1000 - Send 1000 clock ticks to complete the command

Write passcode bytes

Bus Pirate [/dev/ttyS0]
2WIRE> [0x33 0x01 0xff] ^:1000

I2C START
TX: 0x33 0x01 0xFF 
I2C STOP
Tick clock: 1000
2WIRE> [0x33 0x02 0xff] ^:1000

I2C START
TX: 0x33 0x02 0xFF 
I2C STOP
Tick clock: 1000
2WIRE> [0x33 0x03 0xff] ^:1000

I2C START
TX: 0x33 0x03 0xFF 
I2C STOP
Tick clock: 1000
2WIRE> 

The passcode is written to the security memory in three steps. Each byte is written with the 0x33 command to addresses 0x01, 0x02, and 0x03. The default passcode is generally 0xff 0xff 0xff for new SLE4442 cards.

  • [0x33 0x01 0xff] ^:1000 - Write 0xff to security memory address 0x01
  • [0x33 0x02 0xff] ^:1000 - Write 0xff to security memory address 0x02
  • [0x33 0x03 0xff] ^:1000 - Write 0xff to security memory address 0x03

Reset passcode attempts

Bus Pirate [/dev/ttyS0]
2WIRE> [0x39 0x00 0xff] ^:1000

I2C START
TX: 0x39 0x00 0xFF 
I2C STOP
Tick clock: 1000
2WIRE> 

The remaining passcode attempts are reset to 0x07 (0b111) after the passcode is accepted. This is done with the 0x39 command to address 0x00 with the data 0xff.

  • [0x39 0x00 0xff] ^:1000 - Reset the remaining passcode attempts to 0x07

Verify card is unlocked

Bus Pirate [/dev/ttyS0]
2WIRE> [0x31 0x00 0x00] r:4

I2C START
TX: 0x31 0x00 0x00 
I2C STOP
RX: 0x07 0xFF 0xFF 0xFF 
2WIRE> 

If the card was successfully unlocked, the remaining passcode attempts will be reset to 0x07 (0b111). We can verify this by reading the security memory again.

  • [0x31 0x00 0x00] r:4 - Read the security memory

The remaining passcode attempts are 0x07 (0b111), meaning the card is unlocked. We can now see that the passcode bytes are 0xff 0xff 0xff.

Write card memory

CommandControlAddressData
UPDATE MAIN MEMORYB7…B0A7…A0D7…D0
Hexadecimal38H00H…FFHInput data

The SLE4442 has 256 bytes of memory that can be written with the 0x38 command. Only one byte of data can be written per command at the location indicated by the address byte.

Bus Pirate [/dev/ttyS0]
2WIRE> [0x38 255 0x55 ] ^:1000

I2C START
TX: 0x38 
TX: 255 
TX: 0x55 
I2C STOP
Tick clock: 1000
2WIRE> 

Let’s write 0x55 to address 255 (0xff) in the main memory.

  • [ - I2C style START bit
  • 0x38 - Write memory command
  • 255 - Write at address 255 (0xff)
  • 0x55 - Write 0x55 to address 255
  • ] - I2C style STOP bit
  • ^:1000 - Send 1000 clock ticks to complete the command
Bus Pirate [/dev/ttyS0]
2WIRE> [0x30 0 0] r:256

I2C START
TX: 0x30 
TX: 0 0 
I2C STOP
RX: 0xA2 0x13 0x10 0x91 0xFF 0xFF 0x81 0x15 
...lines removed...
    0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x55 
    
2WIRE> 

Now, let’s verify that the data was written correctly by reading the memory again.

  • [0x30 0 0] r:256 - Read 256 bytes

The last byte of the memory is now 0x55, the write was successful.

Change passcode

CommandControlAddressData
UPDATE SECURITY MEMORYB7…B0A7…A0D7…D0
Hexadecimal39H00H…03HInput data

For our final act, let’s update the passcode so intrepid hackers can’t break in using the default.

The new passcode is written to the security memory in three steps. Each byte is written with the 0x39 command to addresses 0x01, 0x02, and 0x03.

Bus Pirate [/dev/ttyS0]
2WIRE> [0x39 0x01 0x12] ^:1000

I2C START
TX: 0x39 0x01 0x12 
I2C STOP
Tick clock: 1000
2WIRE> [0x39 0x02 0x34] ^:1000

I2C START
TX: 0x39 0x02 0x34 
I2C STOP
Tick clock: 1000
2WIRE> [0x39 0x03 0x56] ^:1000

I2C START
TX: 0x39 0x03 0x56 
I2C STOP
Tick clock: 1000
2WIRE> 

Let’s set the passcode to 0x12 0x34 0x56.

  • [0x39 0x01 0x12] ^:1000 - Write 0x12 to security memory address 0x01
  • [0x39 0x02 0x34] ^:1000 - Write 0x34 to security memory address 0x02
  • [0x39 0x03 0x56] ^:1000 - Write 0x56 to security memory address 0x03

Verify passcode update

Bus Pirate [/dev/ttyS0]
2WIRE> [0x31 0x00 0x00] r:4

I2C START
TX: 0x31 0x00 0x00 
I2C STOP
RX: 0x07 0x12 0x34 0x56 
2WIRE> 

The passcode is now 0x12 0x34 0x56. Let’s verify the passcode was updated by reading the security memory again.

  • [0x31 0x00 0x00] r:4 - Read the security memory

Three passcode attempts remain (0x07), and the passcode is now 0x12 0x34 0x56.

Variants

SLE4428 is similar to the SLE4442, but with a few notable differences. SLE4428 is a 1024 byte EEPROM card, and it does not have the passcode write protection feature of the SLE4442. If you’re looking for a bigger card for a new project, check out 24Cxx EEPROM cards. 24Cxx cards come in larger sizes up to 64K, and have a standard I2C interface.

If you can’t help but deal with an SLE4428 card, it should work similar to the SLE4442 with a 2 byte address field.

sle4442 command

The sle4442 command in the Bus Pirate 2-WIRE mode automates the process of reading, writing and unlocking a SLE4442 smart card.

Bus Pirate [/dev/ttyS0]
2WIRE> sle4442 init
--SLE44xx decoder--
ATR: 0xa2 0x13 0x10 0x91
Protocol Type: S 10
Structure Identifier: General Purpose (Structure 1)
Read: Read to end
Data Units: 256
Data Units Bits: 8
Security memory: 0x07 0x00 0x00 0x00
Remaining attempts: 3 (0x7)

Perform Answer To Reset (ATR) and decode the response.

Bus Pirate [/dev/ttyS0]
2WIRE> sle4442 dump
--SLE44xx decoder--
ATR: 0xa2 0x13 0x10 0x91
Protocol Type: S 10
Structure Identifier: General Purpose (Structure 1)
Read: Read to end
Data Units: 256
Data Units Bits: 8
Security memory: 0x07 0x00 0x00 0x00
Remaining attempts: 3 (0x7)
Protection memory: 0xff 0xff 0xff 0xff
Memory:
0xa2 0x13 0x10 0x91 0xff 0xff 0x81 0x15 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xd2 0x76 0x00 0x00 0x04 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 

Read the card memory, and more. See the 2-Wire mode documentation for more information.

Bus Pirate [/dev/ttyS0]
2WIRE> sle4442 -h
usage:
sle4442 [init|dump|unlock|write|erase|psc]
	[-a <address>] [-v <value>] [-p <current psc>] [-n <new psc>] [-f <dump file>] [-h(elp)]
Initialize and probe: sle4442 init
Dump contents: sle4442 dump
Unlock card: sle4442 unlock -p 0xffffff
Write a value: sle4442 write -a 0xff -v 0x55
Erase memory: sle4442 erase
Update PSC: sle4442 psc -p 0xffffff -n 0x000000
Dump contents to file: sle4442 dump -f dump.bin
Dump format: DATA[0:255],SECMEM[256:259],PRTMEM[260:263]

SLE4442 smart card interface
init	Initialize card with ISO7816-3 ATR. Default action
dump	Display main, security and protect memory
unlock	Unlock card with Programmable Security Code (PSC)
write	Write data to card (requires unlock)
erase	Erase data from range 0x32-0x255 (requires unlock)
psc	Change Programmable Security Code (PSC)
-a	Write address flag
-v	Write value flag
-p	Current Programmable Security Code (PSC) flag
-n	New Programmable Security Code (PSC) flag
-f	Dump file name flag

2WIRE> 

Get a Bus Pirate

🛒

Get Bus Pirate & Accessories

Community