smartcard protocol sniffingbrf/media/2007-12-28_postcard-24c3-slides.pdf · this talk is about...

60
Introduction Logging the communication Re-engineering the protocol Creating a simulacrum Smartcard protocol sniffing Introduction to the theoretical and practical issues involved in cloning/simulating existing smartcards Bernd Fix, Marc-André Beck Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Upload: others

Post on 25-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Smartcard protocol sniffingIntroduction to the theoretical and practical issues involved

in cloning/simulating existing smartcards

Bernd Fix, Marc-André Beck

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 2: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Outline1 Introduction

Recap of last years lecture about the swiss PostcardThis talk is aboutWhat is a smartcard?Everyone can build its own

2 Logging the communicationHardware-based loggingRFID Relay / Logging AgentSoftware-based loggingComparison between methods

3 Re-engineering the protocolPrinciple of communication loggingHands on exampleData structure for a logging application

4 Creating a simulacrumBernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 3: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Recap of last years lecture about the swiss PostcardThis talk is aboutWhat is a smartcard?Everyone can build its own

Outline1 Introduction

Recap of last years lecture about the swiss PostcardThis talk is aboutWhat is a smartcard?Everyone can build its own

2 Logging the communicationHardware-based loggingRFID Relay / Logging AgentSoftware-based loggingComparison between methods

3 Re-engineering the protocolPrinciple of communication loggingHands on exampleData structure for a logging application

4 Creating a simulacrumBernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 4: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Recap of last years lecture about the swiss PostcardThis talk is aboutWhat is a smartcard?Everyone can build its own

Recap of last years lecture about the swiss Postcard I

1979 Start design of PIN protected memory card (Bull CP8)1983 French banking card with 320 bit RSA authentification1989 Introduction of french banking card (Carte Bleue)1998 Serge Humpich re-engineered the Carte Bleue

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 5: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Recap of last years lecture about the swiss PostcardThis talk is aboutWhat is a smartcard?Everyone can build its own

Recap of last years lecture about the swiss Postcard II

2002 Found that the security measures of the swiss Postcardwere similar

2006 Re-checked the security measures2006 Presentation of initial results at the 23C3:

A not so smart card2007 initiated academic response

eg. http://lis.fh-aargau.ch/ecsem/ECSeminar/SS07.htmllow impact, small media coverage

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 6: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Recap of last years lecture about the swiss PostcardThis talk is aboutWhat is a smartcard?Everyone can build its own

This talk is about

PostFinanceFlawed signatures not used in authentication schemeGoalBuild a working Postcard clone based on known factsFor an introduction into the design flaws take a look atpostcard-sicherheit.ch

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 7: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Recap of last years lecture about the swiss PostcardThis talk is aboutWhat is a smartcard?Everyone can build its own

This talk is about

PostFinanceFlawed signatures not used in authentication schemeGoalBuild a working Postcard clone based on known factsFor an introduction into the design flaws take a look atpostcard-sicherheit.ch

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 8: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Recap of last years lecture about the swiss PostcardThis talk is aboutWhat is a smartcard?Everyone can build its own

What is a smartcard?

External clock, ground andenergy sourceI/O (input - output), resetMicrocontroller with aninternal EEPROM

External EEPROM

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 9: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Recap of last years lecture about the swiss PostcardThis talk is aboutWhat is a smartcard?Everyone can build its own

What is a smartcard?

External clock, ground andenergy sourceI/O (input - output), resetMicrocontroller with aninternal EEPROM

External EEPROM

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 10: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Recap of last years lecture about the swiss PostcardThis talk is aboutWhat is a smartcard?Everyone can build its own

What is a smartcard?

External clock, ground andenergy sourceI/O (input - output), resetMicrocontroller with aninternal EEPROM

External EEPROM

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 11: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Recap of last years lecture about the swiss PostcardThis talk is aboutWhat is a smartcard?Everyone can build its own

What is a smartcard?

External clock, ground andenergy sourceI/O (input - output), resetMicrocontroller with aninternal EEPROM

External EEPROM

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 12: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Recap of last years lecture about the swiss PostcardThis talk is aboutWhat is a smartcard?Everyone can build its own

Everyone can build its own

Comparable to an old 8bit PC (but with fewer passiveelements).

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 13: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Hardware-based loggingRFID Relay / Logging AgentSoftware-based loggingComparison between methods

Outline1 Introduction

Recap of last years lecture about the swiss PostcardThis talk is aboutWhat is a smartcard?Everyone can build its own

2 Logging the communicationHardware-based loggingRFID Relay / Logging AgentSoftware-based loggingComparison between methods

3 Re-engineering the protocolPrinciple of communication loggingHands on exampleData structure for a logging application

4 Creating a simulacrumBernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 14: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Hardware-based loggingRFID Relay / Logging AgentSoftware-based loggingComparison between methods

Protocol is mostly known

Most cards use ISO-7816 protocol to communicate withterminalISO-7816 defines all aspects (physical/logical specs)Compatibility leads to tolerance (timing less relevant ifwithin range)Still necessary even if protocol is published (like EMV) ?

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 15: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Hardware-based loggingRFID Relay / Logging AgentSoftware-based loggingComparison between methods

Hardware-based logging

MEIER MUSTER

25132756

60-134597-1 03/12

Terminal

Orginal

PCPro Capture the

communication on physicallevel (timing)

Con Not feasable outdoors

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 16: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Hardware-based loggingRFID Relay / Logging AgentSoftware-based loggingComparison between methods

RFID Relay / Logging AgentM

EIER

MU

STER

25

13

27

56

60

-13

45

97

-1

0

3/1

2

MEIER MUSTER

25132756

60-134597-1 03/12

Original

Terminal

PC

RFID Pro Full processing power andcomfort

Con No known implementationyet

Communicate with inserted card via RFID form notebook.

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 17: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Hardware-based loggingRFID Relay / Logging AgentSoftware-based loggingComparison between methods

Software-based loggingM

EIER

MU

STER

25

13

27

56

60

-13

45

97

-1

0

3/1

2

MEIER MUSTER

25132756

60-134597-1 03/12

CloneMEIER MUSTER

25132756

60-134597-1 03/12

Original

Terminal

Clone

PC

Pro (Quite) easy to programand use (secrecy)

Con Step-by-step approach(time consuming)

Use programmable smartcards to capture communication.

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 18: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Hardware-based loggingRFID Relay / Logging AgentSoftware-based loggingComparison between methods

Javacard / Processorcard

Javacard

Pro No special programmerneeded

Con Can’t log direct conventionor T1

Processorcard

Pro Can be customized to anysort of communication

Con Needs special programmer(Money)

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 19: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Hardware-based loggingRFID Relay / Logging AgentSoftware-based loggingComparison between methods

Comparison between methods

Property HW JC PC

Capture timing XT1 protocol X XDirect convention X XIndirect convention X X XEase of use lo hi med*Secrecy lo hi hiSpecial hardware X X

*Increase with ISO-7816/T0 library

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 20: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Hardware-based loggingRFID Relay / Logging AgentSoftware-based loggingComparison between methods

Comparison between methods

Property HW JC PC

Capture timing XT1 protocol X XDirect convention X XIndirect convention X X XEase of use lo hi med*Secrecy lo hi hiSpecial hardware X X

*Increase with ISO-7816/T0 library

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 21: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Hardware-based loggingRFID Relay / Logging AgentSoftware-based loggingComparison between methods

Comparison between methods

Property HW JC PC

Capture timing XT1 protocol X XDirect convention X XIndirect convention X X XEase of use lo hi med*Secrecy lo hi hiSpecial hardware X X

*Increase with ISO-7816/T0 library

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 22: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Hardware-based loggingRFID Relay / Logging AgentSoftware-based loggingComparison between methods

Comparison between methods

Property HW JC PC

Capture timing XT1 protocol X XDirect convention X XIndirect convention X X XEase of use lo hi med*Secrecy lo hi hiSpecial hardware X X

*Increase with ISO-7816/T0 library

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 23: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Hardware-based loggingRFID Relay / Logging AgentSoftware-based loggingComparison between methods

Comparison between methods

Property HW JC PC

Capture timing XT1 protocol X XDirect convention X XIndirect convention X X XEase of use lo hi med*Secrecy lo hi hiSpecial hardware X X

*Increase with ISO-7816/T0 library

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 24: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Hardware-based loggingRFID Relay / Logging AgentSoftware-based loggingComparison between methods

Comparison between methods

Property HW JC PC

Capture timing XT1 protocol X XDirect convention X XIndirect convention X X XEase of use lo hi med*Secrecy lo hi hiSpecial hardware X X

*Increase with ISO-7816/T0 library

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 25: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Hardware-based loggingRFID Relay / Logging AgentSoftware-based loggingComparison between methods

Comparison between methods

Property HW JC PC

Capture timing XT1 protocol X XDirect convention X XIndirect convention X X XEase of use lo hi med*Secrecy lo hi hiSpecial hardware X X

*Increase with ISO-7816/T0 library

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 26: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Hardware-based loggingRFID Relay / Logging AgentSoftware-based loggingComparison between methods

Comparison between methods

Property HW JC PC

Capture timing XT1 protocol X XDirect convention X XIndirect convention X X XEase of use lo hi med*Secrecy lo hi hiSpecial hardware X X

*Increase with ISO-7816/T0 library

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 27: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Outline1 Introduction

Recap of last years lecture about the swiss PostcardThis talk is aboutWhat is a smartcard?Everyone can build its own

2 Logging the communicationHardware-based loggingRFID Relay / Logging AgentSoftware-based loggingComparison between methods

3 Re-engineering the protocolPrinciple of communication loggingHands on exampleData structure for a logging application

4 Creating a simulacrumBernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 28: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Principle of communication logging

Terminal Logger Smartcard

request −→ Lookup inrequest list

←− Found: Sendassociated response

←− Unknown: Send okStart logging

repeat

Replay −→

Save ←− response

restart

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 29: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Principle of communication logging

Terminal Logger Smartcard

request −→ Lookup inrequest list

←− Found: Sendassociated response

←− Unknown: Send okStart logging

repeat

Replay −→

Save ←− response

restart

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 30: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Principle of communication logging

Terminal Logger Smartcard

request −→ Lookup inrequest list

←− Found: Sendassociated response

←− Unknown: Send okStart logging

repeat

Replay −→

Save ←− response

restart

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 31: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Principle of communication logging

Terminal Logger Smartcard

request −→ Lookup inrequest list

←− Found: Sendassociated response

←− Unknown: Send okStart logging

repeat

Replay −→

Save ←− response

restart

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 32: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Principle of communication logging

Terminal Logger Smartcard

request −→ Lookup inrequest list

←− Found: Sendassociated response

←− Unknown: Send okStart logging

repeat

Replay −→

Save ←− response

restart

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 33: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Principle of communication logging

Terminal Logger Smartcard

request −→ Lookup inrequest list

←− Found: Sendassociated response

←− Unknown: Send okStart logging

repeat

Replay −→

Save ←− response

restart

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 34: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Principle of communication logging

Terminal Logger Smartcard

request −→ Lookup inrequest list

←− Found: Sendassociated response

←− Unknown: Send okStart logging

repeat

Replay −→

Save ←− response

restart

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 35: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Communication

Terminal Smartcard

(Power on) 3B:65:00:00:02:04:6C:90:00BC:B0:09:C0:1C 08:4D:FF:FF:23:9F:0B:EB:... [9000]BC:B0:09:F8:04 3E:AC:9F:CC [9000]BC:B0:08:E0:1C 2E:03:30:33:3X:XX:XX:XX:... [9000]BC:B0:09:18:1C 3X:XX:XX:XX:3X:XX:XX:XX:... [9000]

BC:B0:08:B0:04 [6A81]BC:20:00:00:04:XX:XX:XX:XX[9000]BC:40:00:00:00 [9000]BC:B0:08:B0:04 75:XX:XX:XX [9000]

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 36: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Sending the ATR

Terminal Smartcard

(Power on) ATR - Answer To Reset3F:65:35:10:02:04:6C:90:00

TS Initial Character 3F: indirect convention

T0 Format Character 65: TB1, TC1 and 5 historicals

TB1 35 Programming voltage 5.3 V

TC1 10 Extra guardtime 10 * 104 µs

HS Historicals

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 37: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Sending the ATR

Terminal Smartcard

(Power on) ATR - Answer To Reset3F:65:35:10:02:04:6C:90:00

TS Initial Character 3F: indirect convention

T0 Format Character 65: TB1, TC1 and 5 historicals

TB1 35 Programming voltage 5.3 V

TC1 10 Extra guardtime 10 * 104 µs

HS Historicals

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 38: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Sending the ATR

Terminal Smartcard

(Power on) ATR - Answer To Reset3F:65:35:10:02:04:6C:90:00

TS Initial Character 3F: indirect convention

T0 Format Character 65: TB1, TC1 and 5 historicals

TB1 35 Programming voltage 5.3 V

TC1 10 Extra guardtime 10 * 104 µs

HS Historicals

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 39: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Sending the ATR

Terminal Smartcard

(Power on) ATR - Answer To Reset3F:65:35:10:02:04:6C:90:00

TS Initial Character 3F: indirect convention

T0 Format Character 65: TB1, TC1 and 5 historicals

TB1 35 Programming voltage 5.3 V

TC1 10 Extra guardtime 10 * 104 µs

HS Historicals

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 40: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Sending the ATR

Terminal Smartcard

(Power on) ATR - Answer To Reset3F:65:35:10:02:04:6C:90:00

TS Initial Character 3F: indirect convention

T0 Format Character 65: TB1, TC1 and 5 historicals

TB1 35 Programming voltage 5.3 V

TC1 10 Extra guardtime 10 * 104 µs

HS Historicals

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 41: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Sending the APDU

Terminal Smartcard

(Power on) 3B:65:00:00:02:04:6C:90:00BC:B0:09:C0:1C

CLA BC Banking cards.

INS B0 Read data

ADDR at address 09:C0

LC and return 1C bytes.

* APDU - Application Protocol Data Unit.

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 42: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Sending the APDU

Terminal Smartcard

(Power on) 3B:65:00:00:02:04:6C:90:00BC:B0:09:C0:1C

CLA BC Banking cards.

INS B0 Read data

ADDR at address 09:C0

LC and return 1C bytes.

* APDU - Application Protocol Data Unit.

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 43: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Sending the APDU

Terminal Smartcard

(Power on) 3B:65:00:00:02:04:6C:90:00BC:B0:09:C0:1C

CLA BC Banking cards.

INS B0 Read data

ADDR at address 09:C0

LC and return 1C bytes.

* APDU - Application Protocol Data Unit.

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 44: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Sending the APDU

Terminal Smartcard

(Power on) 3B:65:00:00:02:04:6C:90:00BC:B0:09:C0:1C

CLA BC Banking cards.

INS B0 Read data

ADDR at address 09:C0

LC and return 1C bytes.

* APDU - Application Protocol Data Unit.

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 45: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Sending the APDU

Terminal Smartcard

(Power on) 3B:65:00:00:02:04:6C:90:00BC:B0:09:C0:1C

CLA BC Banking cards.

INS B0 Read data

ADDR at address 09:C0

LC and return 1C bytes.

* APDU - Application Protocol Data Unit.

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 46: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Stateful lookup

Terminal Smartcard

(Power on) (ATR) 3B:65:00:00:02:04:6C:90:00BC:B0:09:C0:1C 08:4D:FF:FF:23:9F:0B:EB:... [9000]BC:B0:09:F8:04 3E:AC:9F:CC [9000]BC:B0:08:E0:1C 2E:03:30:33:3X:XX:XX:XX:... [9000]BC:B0:09:18:1C 3X:XX:XX:XX:3X:XX:XX:XX:... [9000]

BC:B0:08:B0:04 [6A81]BC:20:00:00:04:XX:XX:XX:XX[9000]BC:40:00:00:00 [9000]BC:B0:08:B0:04 75:XX:XX:XX [9000]

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 47: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Stateful lookup

Terminal Smartcard

(Power on) (ATR) 3B:65:00:00:02:04:6C:90:00BC:B0:09:C0:1C 08:4D:FF:FF:23:9F:0B:EB:... [9000]BC:B0:09:F8:04 3E:AC:9F:CC [9000]BC:B0:08:E0:1C 2E:03:30:33:3X:XX:XX:XX:... [9000]BC:B0:09:18:1C 3X:XX:XX:XX:3X:XX:XX:XX:... [9000]

BC:B0:08:B0:04 [6A81]BC:20:00:00:04:XX:XX:XX:XX[9000]BC:40:00:00:00 [9000]BC:B0:08:B0:04 75:XX:XX:XX [9000]

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 48: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Stateful lookup

Terminal Smartcard

(Power on) (ATR) 3B:65:00:00:02:04:6C:90:00BC:B0:09:C0:1C 08:4D:FF:FF:23:9F:0B:EB:... [9000]BC:B0:09:F8:04 3E:AC:9F:CC [9000]BC:B0:08:E0:1C 2E:03:30:33:3X:XX:XX:XX:... [9000]BC:B0:09:18:1C 3X:XX:XX:XX:3X:XX:XX:XX:... [9000]

BC:B0:08:B0:04 [6A81]BC:20:00:00:04:XX:XX:XX:XX[9000]BC:40:00:00:00 [9000]BC:B0:08:B0:04 75:XX:XX:XX [9000]

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 49: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Stateful lookup

Terminal Smartcard

(Power on) (ATR) 3B:65:00:00:02:04:6C:90:00BC:B0:09:C0:1C 08:4D:FF:FF:23:9F:0B:EB:... [9000]BC:B0:09:F8:04 3E:AC:9F:CC [9000]BC:B0:08:E0:1C 2E:03:30:33:3X:XX:XX:XX:... [9000]BC:B0:09:18:1C 3X:XX:XX:XX:3X:XX:XX:XX:... [9000]

BC:B0:08:B0:04 [6A81]BC:20:00:00:04:XX:XX:XX:XX[9000]BC:40:00:00:00 [9000]BC:B0:08:B0:04 75:XX:XX:XX [9000]

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 50: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Stateful lookup

Terminal Smartcard

(Power on) (ATR) 3B:65:00:00:02:04:6C:90:00BC:B0:09:C0:1C 08:4D:FF:FF:23:9F:0B:EB:... [9000]BC:B0:09:F8:04 3E:AC:9F:CC [9000]BC:B0:08:E0:1C 2E:03:30:33:3X:XX:XX:XX:... [9000]BC:B0:09:18:1C 3X:XX:XX:XX:3X:XX:XX:XX:... [9000]

BC:B0:08:B0:04 [6A81]BC:20:00:00:04:XX:XX:XX:XX[9000]BC:40:00:00:00 [9000]BC:B0:08:B0:04 75:XX:XX:XX [9000]

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 51: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

A data structure for a logging application - requests

Requests

offset length field

00 01 Index (0 = End)01 01 Active State (0 = Any)02 01 Next State (FF = no change)03 01 Length of additional data (n)04 05 APDU09 n <Additional data>

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 52: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

A data structure for a logging application - responses

Responses

offset length field

00 01 Index (0 = End)01 01 Type (1 = SW, 2 = Data)02 02 SW / Length (n)04 n <Data>

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 53: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Treating the same card differently

Swisscom publicphone SBB ticket machine

BC:B0:09:C0:1C BC:B0:09:C0:18BC:B0:09:F8:04BC:B0:08:E0:1CBC:B0:09:18:1CBC:B0:09:50:1C BC:B0:09:48:1CBC:B0:09:88:1C

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 54: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Principle of communication loggingHands on exampleData structure for a logging application

Treating the same card differently

Swisscom publicphone SBB ticket machine

BC:B0:09:C0:1C BC:B0:09:C0:18BC:B0:09:F8:04BC:B0:08:E0:1CBC:B0:09:18:1CBC:B0:09:50:1C BC:B0:09:48:1CBC:B0:09:88:1C

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 55: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Outline1 Introduction

Recap of last years lecture about the swiss PostcardThis talk is aboutWhat is a smartcard?Everyone can build its own

2 Logging the communicationHardware-based loggingRFID Relay / Logging AgentSoftware-based loggingComparison between methods

3 Re-engineering the protocolPrinciple of communication loggingHands on exampleData structure for a logging application

4 Creating a simulacrumBernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 56: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

IntroductionLogging the communicationRe-engineering the protocol

Creating a simulacrum

Material you need

special readerhttp://www.infinityusb.comAsk for better Linux, BSD, Plan9, Solaris, OS/2 support!avr-gcchttp://www.nongnu.org/avr-libcISO-7816/T0 libraryhttp://postcard-sicherheit.ch/de/clone.html

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 57: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

AppendixFurther informationFurther readingQuestions?

Further information

postcard-sicherheit.chThe ultimate source for postcard security.

parodie.com/monetiqueReference of the Carte Bleue.

mbsks.franken.de/sosseSimple Operating System for Smartcard Education.

en.wikipedia.org/wiki/ISO_7816

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 58: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

AppendixFurther informationFurther readingQuestions?

Further reading

Rankl, Effing - Handbuch der ChipkartenReference.

Gueulle - Cartes à puceInformation about the french banking card.

Tavernier - Les cartes à puceHands on guide.

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 59: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

AppendixFurther informationFurther readingQuestions?

Questions?

Questions?

Bernd Fix, Marc-André Beck Smartcard protocol sniffing

Page 60: Smartcard protocol sniffingbrf/media/2007-12-28_Postcard-24C3-Slides.pdf · This talk is about What is a smartcard? Everyone can build its own 2 Logging the communication Hardware-based

AppendixFurther informationFurther readingQuestions?

Bernd Fix, Marc-André Beck Smartcard protocol sniffing