Skip to content

pcsc-for-php/apdu

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

APDU shell

A quick smartcard APDU read-evaluate-print loop shell with readline support.

Screenshot

Built with Python and pyscard.

Select PC/SC reader

Run apdu -l to list all PC/SC readers.

Select a reader by partial name or index (starting at 0) with apdu -r Gemplus or apdu -r 0.

On a selected reader, card can be inserted / removed during the shell session.

Inside the shell

APDU input

Type APDU commands as hex strings like 00 A4 0400 08 A000000003000000 00. Spaces are ignored unless theya are separating single numbers. Hexstring input 00   1 2 0304 is the same as 00 01 02 03 04.

Save data response to a file

Append > <file name> to save data output (response without sw1 and sw2 bytes) to a file.

Example: 00 A4 04 00 08 A0 00 00 00 18 43 4D 00 00 > fci.bin

Comments

Comments starts with a #.

# Select "first" aid
00 A4 04 00 00
00 A4 04 00  08 A0 00 00 00 03 00 00 00  00    # not found?

Passthru external commands

External commands are supported withRUN <command>.

This will execute APDUs printed on command's standard output as hex strings, line by line, passing full response hex string (including sw1 and sw2 bytes) to command's standard input. External commands are useful to make mini scripts that depend on input/output sequence.

For example, I am using this with a command to do MIFARE Ultralight C authentication with RUN ultralightc_auth. This program does 3DES with RndA and RndB like shown here, modified to just read APDUs from standard input and write them to standard output in a frame required by PC/SC driver for the SCM SCL011 reader that I am using. Running this inside the APDU shell will create an authenticated session with the card.

Replay history and scripts

Use SAVE <file name> to save command history with comments to the file. Pipe this file to the shell to replay. Script file format is very simple, it is just a series of commands in plain text, one command per line. Blank lines are ignored.

There is also a CLEAR command to clear current history.

Alternatives

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%