Reverse engineering smart cards



Similar documents
Smart Card Application Standard Draft

Functional Specification of the OpenPGP application on ISO Smart Card Operating Systems

MDG. MULTOS Developer's Guide. MAO-DOC-TEC-005 v MAOSCO Limited. MULTOS is a registered trademark of MULTOS Limited.

RVS Seminar Deployment and Performance Analysis of JavaCards in a Heterogenous Environment. Carolin Latze University of Berne

Introducing the Adafruit Bluefruit LE Sniffer

Introducing etoken. What is etoken?

ACR122 NFC Contactless Smart Card Reader

Using PIV Smart Cards on Linux for Authentication to Windows Active Directory

APPLICATION PROGRAMMING INTERFACE

Exercise 1: Set up the Environment

Smart Card APDU Analysis

An NFC Ticketing System with a new approach of an Inverse Reader Mode

Measurement and Analysis Introduction of ISO7816 (Smart Card)

How To Use A Cloud 2700 R Smart Card Reader On A Pc Or Mac Or Ipad (For Microsoft) With A Microsoft Power Card (For Pc) With An Ipad Or Microsoft Memory Card (Microsoft)

Smart Card Deployment in the Data Center: Best Practices for Integrating Smart Card Authentication in a Secure KVM Environment

CardWerk SmartCard API (Professional)

AN2598 Application note

Smart Card Technology Capabilities

EMV (Chip and PIN) Project. EMV card

Smart cards basic principles

2-FACTOR AUTHENTICATION WITH OPENLDAP, OATH-HOTP AND YUBIKEY. Axel Hoffmann

JavaCard. Java Card - old vs new

SIM CARD PROTOCOLS. This paper attempts in broad strokes to outline the construction of these protocols and how they are used.

MUSCLE Cryptographic Card Edge Definition for Java 1 Enabled Smartcards

Mifare DESFire Specification

CHAPTER 5 SMART CARD TECHNOLOGY

Java Card. Smartcards. Demos. . p.1/30

Government Smart Card Interoperability Specification

73S1215F, 73S1217F Device Firmware Upgrade Host Driver/Application Development User s Guide April 27, 2009 Rev UG_12xxF_029

Universal Serial Bus. Device Class: Smart Card CCID. Specification for Integrated Circuit(s) Cards Interface Devices

EMV (Chip-and-PIN) Protocol

AN2284 APPLICATION NOTE

Installing Java (Windows) and Writing your First Program

Smart Card Certificate Authentication with VMware View 4.5 and Above WHITE PAPER

SOSSE. Matthias Brüstle Simple Operating System for Smartcard Education. Kommunikationsnetz Franken e.v.

YubiKey OSX Login. yubico. Via Yubico-PAM Challenge-Response. Version 1.6. October 24, 2015

Technical Terms and Conditions

Smart Card HOWTO. Tolga KILIÇLI. Copyright 2001 by Tolga KILIÇLI

Getting to know your card: Reverse-Engineering the Smart-Card Application Protocol Data Unit for PKCS#11 Functions

Advanced Authentication

AN1305. MIFARE Classic as NFC Type MIFARE Classic Tag. Application note COMPANY PUBLIC. Rev October Document information

jcardsim Java Card is simple!

OPERATING SYSTEM SERVICES

Application Note Gemalto.NET 2.0 Smart Card Certificate Enrollment using Microsoft Certificate Services on Windows 2008

Crash Dive into Python

How To Run A Password Manager On A 32 Bit Computer (For 64 Bit) On A 64 Bit Computer With A Password Logger (For 32 Bit) (For Linux) ( For 64 Bit (Foramd64) (Amd64 (For Pc

SEEK project - Access to Secure Elements on Android. Frank Schäfer

Services and Data Definitions

RPLIDAR. Low Cost 360 degree 2D Laser Scanner (LIDAR) System Development Kit User Manual Rev.1

EXPLORING SMARTCARDS: AN INDEPENDENT LOOK TO TECHNOLOGIES AND MARKET

Leveraging the Android Accessory Protocol

Modbus and ION Technology

NEO Manager Quick Start Guide

BLUETOOTH SERIAL PORT PROFILE. iwrap APPLICATION NOTE

Java Applet and Terminal Application for Financial transactions

Smart Card. Smart Card applications

SupverVAG K+CAN User Manual

HP Service Manager. Software Version: 9.40 For the supported Windows and Linux operating systems. Application Setup help topics for printing

Open Mobile API Test Specification for Transport API

TT-RFID platform - Introduction

Smart Cards a(s) Safety Critical Systems

Using RFID Techniques for a Universal Identification Device

ACR122U USB NFC Reader

SPROG DCC Decoder Programmer

Kerberos: Single Sign On for BS2000

An Open Source eid Simulator Open Identity Summit 9th -11th September 2013

Hacking Mifare Classic Cards. Márcio Almeida

ENTTEC Pixie Driver API Specification

User Manual. SmartWi Toolbox. Date: Version: Firmware: >

Driver Installation and Hyperterminal Operation of iload Digital USB Sensors

The Advanced JTAG Bridge. Nathan Yawn 05/12/09

Security Classification: EIDA ID Card Toolkit v2.7. Developer s Guide

Global network of innovation. Svein Arne Lindøe Arnfinn Strand Security Competence Center Scandic Siemens Business Services (Norway)

Network Security: Workshop

SIMtrace Usermanual i. SIMtrace Usermanual

Development of complex KNX Devices

SLE66CX322P or SLE66CX642P / CardOS V4.2B FIPS with Application for Digital Signature

3GPP TS V ( )

Smart Card Setup Guide

Prox DU & Prox SU. Dual interface USB smart card reader. Installation Guide. Installation Guide. Prox DU & Prox SU. DOC118570D Public Use Page 1/34

1. Product Overview 2. Product Feature 3. Product Value 4. Development Environment 5. Software Development Kit 6. Product Application 7.

Functional Specification of the OpenPGP application on ISO Smart Card Operating Systems. Version Author: Achim Pietig

SCM Microsystems. Reference Manual version 1.3. SCL010 Multiprotocol contactless stationary reader

PMOD Installation on Linux Systems

The SmartLogic Tool: Analysing and Testing Smart Card Protocols

Deploying a Virtual Machine (Instance) using a Template via CloudStack UI in v4.5.x (procedure valid until Oct 2015)

How do Users and Processes interact with the Operating System? Services for Processes. OS Structure with Services. Services for the OS Itself

Overview of Data Security Methods: Passwords, Encryption, and Erase

Driver s License Camera Scanner Installation Guide!

EC313 - VHDL State Machine Example

Tera Term Telnet. Introduction

Java Card TM Open Platform for Smart Cards

Apache Server Implementation Guide

ANZ TRANSACTIVE GETTING STARTED GUIDE AUSTRALIA & NEW ZEALAND

ETSI TS V8.1.0 ( ) Technical Specification. Smart Cards; Secure channel between a UICC and an end-point terminal (Release 8)

Table of Contents. User s guide 2

Strong Authentication in details

Agent Languages. Overview. Requirements. Java. Tcl/Tk. Telescript. Evaluation. Artificial Intelligence Intelligent Agents

New Technology Introduction: Android Studio with PushBot

Secure web transactions system

Transcription:

Reverse engineering smart cards Christian M. Amsüss linuxwochen@christian.amsuess.com http://christian.amsuess.com/ 2010-05-06

Overview objective understand smart card communication based on sniffable communication hardware standard card reader software something that can talk to the smart card (typically in emulator), cat /dev/usbmon0, some own tools Smart card basics Practical examples

Smart card basics Practical examples

Common cards and readers

Low level shape and contacts defined in ISO 7816-1 and -2 contacts for ground, power, reset, clock, and I/O serial communication ATR: answer to reset (up to 33 byte) protocol T=1 for sending and receiving byte string messages

High level 1 > 00 a4 00 00 02 01 02 2 < 90 00 3 > 00 b0 00 00 00 4 < 00 00 02 14 90 00 command/response dialogue command = APDU, consisting of CLA (usually 00, other values indicate proprietary commands or RFU) INS (instruction, eg. a4 = Select File ) P1, P2 (arguments, eg 04 00 = Select by DF ) length and data, depending on INS response, consisting of data, depending on INS SW1, SW2 (return code, eg 90 00 = OK )

Interfaces and drivers CCID standard for USB card readers PC/SC Windows API for smart cards PCSC-Lite the same interface on Linux and OS X OpenSC library focused on crypto (PKCS#x), brings some own drivers libchipcard library focused on not blocking unused devices carddecoders my tools and example programs for smart card reverse engineering, based on Python PCSC bindings (http://christian.amsuess.com/tools/carddecoders/)

Smart card basics Practical examples

Trying it out: pcsc-tools pcsc scan (g)scriptor

Sniffing on Linux Software that talks to the card can run in a VM (eg. ActiveX applet) Linux lets you sniff USB communication using /dev/usbmon0; output is CCID inside usbmon s binary logging format Workflow: sudo cat /dev/usbmon0 > sniffing run 1.out Do something with the card Stop cat with ^C logdecoder -r sniffing run 1.out (from carddecoders) 1 > 00 a4 00 00 02 01 02 2 < 90 00 3 > 00 b0 00 00 00 4 < 00 00 02 14 90 00

Interpreting returned data: Encodings Look for numbers known to be read Big Endian: 02 00 = 512 1 > 00 a4 00 00 02 01 02 2 < 90 00 3 > 00 b0 00 00 00 4 < 00 00 02 14 90 00 e 5.32

Interpreting returned data: Encodings Look for numbers known to be read Big Endian: 02 00 = 512 Binary Coded Decimal: 12 34 = 1 234 1 > 00 a4 00 00 02 3 f 00 2 < 90 00 3 > 00 a4 00 00 02 00 02 4 < 90 00 5 > 00 b0 00 00 08 6 < 09 6 f 06 70 00 2 1 20 00 90 00 BLZ 12000

Interpreting returned data: Encodings Look for numbers known to be read Big Endian: 02 00 = 512 Binary Coded Decimal: 12 34 = 1 234 ASCII: 31 32 33 34 = 1234

Interpreting returned data: Encodings Look for numbers known to be read Big Endian: 02 00 = 512 Binary Coded Decimal: 12 34 = 1 234 ASCII: 31 32 33 34 = 1234 Other creative encodings for dates etc. 1 > 00 b2 01 04 00 2 < [... ] 90 00 01 00 05 10 46 01 00 [... ] 3 > 00 b2 02 04 00 4 < [... ] 90 00 00 93 44 13 31 00 00 [... ] 5 > 00 b2 03 04 00 6 < [... ] 90 00 00 93 44 13 31 00 00 [... ] 2010-01-05, 10:46 local time (day 5 of the year 010) 2009-12-10, 13:31 local time (day 344 of the year 009)

Exploring commands Some commands can be bent. 1 > 00 b0 00 00 08 2 < 09 6 f 06 70 00 21 20 00 90 00 According to ISO 7816, the last byte gives the number of bytes to read. Let s assume it works like POSIX s read: 1 > 00 b0 00 00 00 2 < 09 6 f [... ] 95 01 23 66 02 00 [... ] 01 90 00

Exploring commands Some commands can be bent. Others can be bruteforced. 1 > 00 a4 00 00 02 d f 01 2 < 90 00 This was known to work... Let s try this: 1 > 00 a4 00 00 02 d f 08 2 < 6a 00 No... One more? 1 > 00 a4 00 00 02 d f 09 2 < 6 f 14 84 07 a0 00 [... ] 54 52 4 f 90 00 This works, and even sends data immediately.

Card state Smart card directory structure: / 3f 00...master file (MF) 00 02... single file: Read Binary df 01... dedicated file (DF) 01 01 01 03... fixed records: Read Record(n) df 09 00 01. variable records: Read Record(n) File selection seems rather safe for experimenting More card state: authentication, challenge/response (limited tries!)

Tools provided by carddecoders logdecoder Decodes usbmon output to 1 > 00 a4 00 00 02 00 02 2 < 90 00 3 > 00 b0 00 00 08 4 < 09 6 f 06 70 00 21 20 00 90 00... And generates Python code from it: 1 card. t r a n s m i t ( S e l e c t F i l e ( [ 0 x00, 0 x02 ] ) ) 2 # OK 3 card. t r a n s m i t ( ReadBinary ( l e n g t h =8)) 4 # 09 6 f 06 70 00 21 20 0 0, OK

Tools provided by carddecoders logdecoder carddecoders.reverse helpers Find numbers in various encodings: 1 >>> c o n t a i n s n u m b e r ( B y t e S t r i n g ( 2 09 6 f 06 70 00 21 20 00 ), 12000) 3 number found i n BCD at o f f s e t 5. 5 b y t e s 4 >>> c o n t a i n s n u m b e r ( B y t e S t r i n g ( 5 09 6 f 06 70 00 21 20 00 ), 1648) 6 number found i n b i g e n d i a n e ncoding ending 7 at 4. 0 b y t e s Find length indicators: 1 >>> b a c k w a r d l e n g t h ( B y t e S t r i n g ( 2 70 3 c 5 f [... ] 5 f 28 02 00 40 ) ) 3 i n d e x 1 : 60 r e m a i n i n g 4 i n d e x 5 9 : 2 r e m a i n i n g

Further reading Introduction to Smart Cards http://www.smartcard.co.uk/tutorials/sct-itsc.pdf Overview over ISO 7816 http://www.cardwerk.com/smartcards/smartcard_standard_iso7816.aspx Smartcard protocol sniffing (hardware side) http://events.ccc.de/congress/2007/fahrplan/events/2364.en.html