{"id":20325851,"url":"https://github.com/grakic/apdu","last_synced_at":"2025-04-11T20:06:11.989Z","repository":{"id":20752748,"uuid":"24037255","full_name":"grakic/apdu","owner":"grakic","description":"APDU shell","archived":false,"fork":false,"pushed_at":"2016-01-29T00:11:25.000Z","size":19,"stargazers_count":36,"open_issues_count":0,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-11T20:06:09.811Z","etag":null,"topics":["apdu","iso7816","pcsc","smartcard"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grakic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-15T00:32:40.000Z","updated_at":"2024-10-25T15:19:59.000Z","dependencies_parsed_at":"2022-07-13T23:10:41.208Z","dependency_job_id":null,"html_url":"https://github.com/grakic/apdu","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grakic%2Fapdu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grakic%2Fapdu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grakic%2Fapdu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grakic%2Fapdu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grakic","download_url":"https://codeload.github.com/grakic/apdu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248473127,"owners_count":21109628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apdu","iso7816","pcsc","smartcard"],"created_at":"2024-11-14T19:42:02.164Z","updated_at":"2025-04-11T20:06:11.943Z","avatar_url":"https://github.com/grakic.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"APDU shell\n==========\n\nA quick smartcard APDU read-evaluate-print loop shell with readline support.\n\n![Screenshot](http://blog.goranrakic.com/archives/slike/apdu.png)\n\nBuilt with Python and [pyscard](http://pyscard.sourceforge.net/).\n\n## Select PC/SC reader\n\nRun \u003ctt\u003eapdu -l\u003c/tt\u003e to list all PC/SC readers.\n\nSelect a reader by partial name or index (starting at 0) with \u003ctt\u003eapdu -r Gemplus\u003c/tt\u003e or \u003ctt\u003eapdu -r 0\u003c/tt\u003e.\n\nOn a selected reader, card can be inserted / removed during the shell session.\n\n## Inside the shell\n### APDU input\nType APDU commands as hex strings like \u003ctt\u003e00 A4 0400 08 A000000003000000 00\u003c/tt\u003e. Spaces are ignored unless theya are separating single numbers. Hexstring input \u003ctt\u003e00 \u0026nbsp; 1 2 0304\u003c/tt\u003e is the same as \u003ctt\u003e00 01 02 03 04\u003c/tt\u003e.\n\n### Save data response to a file\nAppend \u003ctt\u003e\u003e \u0026lt;file name\u0026gt;\u003c/tt\u003e to save data output (response without sw1 and sw2 bytes) to a file.\n\nExample: \u003ctt\u003e00 A4 04 00 08 A0 00 00 00 18 43 4D 00   00 \u003e fci.bin\u003c/tt\u003e\n\n### Comments\nComments starts with a #.\n\n    # Select \"first\" aid\n    00 A4 04 00 00\n    00 A4 04 00  08 A0 00 00 00 03 00 00 00  00    # not found?\n\n\n### Passthru external commands\n\nExternal commands are supported with\u003ctt\u003eRUN \u0026lt;command\u0026gt;\u003c/tt\u003e.\n\nThis 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.\n\nFor example, I am using this with a command to do MIFARE Ultralight C authentication with \u003ctt\u003eRUN ultralightc_auth\u003c/tt\u003e. This program does 3DES with RndA and RndB like [shown here](https://code.google.com/p/libfreefare/source/browse/libfreefare/mifare_ultralight.c#247), 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.\n\n### Replay history and scripts\n\nUse \u003ctt\u003eSAVE \u0026lt;file name\u0026gt;\u003c/tt\u003e 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.\n\nThere is also a \u003ctt\u003eCLEAR\u003c/tt\u003e command to clear current history.\n\n## Alternatives\n- [cyberflex-shell](https://github.com/henryk/cyberflex-shell)\n- [pcsc-tools scriptor/gscriptor](http://ludovicrousseau.blogspot.com/2010/05/pcsc-sample-in-scriptor.html)\n- [OpenSCDP Smart Card Shell 3](http://www.openscdp.org/scsh3/)\n- [JSmartCardExplorer](http://www.primianotucci.com/os/smartcard-explorer)\n- Android APDU Sender: [Contact](https://play.google.com/store/apps/details?id=com.jmarroyo.apdusendercontact), [Contactless](https://play.google.com/store/apps/details?id=com.jmarroyo.apdusendercontactless)\n- [smacadu](http://www.literatecode.com/smacadu)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrakic%2Fapdu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrakic%2Fapdu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrakic%2Fapdu/lists"}