frankmorgner / vsmartcard

umbrella project for emulation of smart card readers or smart cards
http://frankmorgner.github.io/vsmartcard/
684 stars 197 forks source link

Windows: How to disable initial commands when card connect? #237

Closed Nick-The-Uncharted closed 1 year ago

Nick-The-Uncharted commented 1 year ago

Expected behaviour

Only reset command was sent to card.

Actual behaviour

A series of commands was sent to the virtual card. I searched project vpcd but can't found where did these commands came from.

Steps to reproduce

  1. start vpcd
  2. create a virtual card with VirtualICC(None, "iso7816", "localhost", 35963)
  3. run the virtual card

Logs

14.11.2022 10:48:20  [INFO] Command APDU (16 bytes):
  0000:  00 A4 04 00 0B A0 00 00 03 97 43 49 44 5F 01 00   ................
14.11.2022 10:48:20  [INFO] Response APDU (2 bytes):
  0000:  6A 82                                             ..
14.11.2022 10:48:20  [INFO] Command APDU (5 bytes):
  0000:  00 CA 7F 68 00                                    .....
14.11.2022 10:48:20  [INFO] Response APDU (2 bytes):
  0000:  6A 81                                             ..
14.11.2022 10:48:20  [INFO] Command APDU (14 bytes):
  0000:  00 A4 04 00 09 A0 00 00 03 08 00 00 10 00         ..............
14.11.2022 10:48:20  [INFO] Response APDU (2 bytes):
  0000:  6A 82                                             ..
14.11.2022 10:48:20  [INFO] Command APDU (14 bytes):
  0000:  00 A4 04 00 09 A0 00 00 03 97 42 54 46 59         ..............
14.11.2022 10:48:20  [INFO] Response APDU (2 bytes):
  0000:  6A 82                                             ..
14.11.2022 10:48:20  [INFO] Command APDU (14 bytes):
  0000:  00 A4 04 00 09 A0 00 00 03 08 00 00 10 00         ..............
14.11.2022 10:48:20  [INFO] Response APDU (2 bytes):
  0000:  6A 82                                             ..
14.11.2022 10:48:20  [INFO] Command APDU (7 bytes):
  0000:  00 A4 00 0C 02 3F FF                              .......
14.11.2022 10:48:20  [INFO] Response APDU (2 bytes):
  0000:  6A 82                                             ..
14.11.2022 10:48:20  [INFO] Command APDU (15 bytes):
  0000:  00 A4 04 04 09 A0 00 00 03 97 42 54 46 59 00      ...............
14.11.2022 10:48:20  [INFO] Response APDU (2 bytes):
  0000:  6A 82                                             ..
14.11.2022 10:48:20  [INFO] Command APDU (15 bytes):
  0000:  00 A4 04 00 09 A0 00 00 03 97 42 54 46 59 00      ...............
14.11.2022 10:48:20  [INFO] Response APDU (2 bytes):
  0000:  6A 82                                             ..
14.11.2022 10:48:20  [INFO] Command APDU (14 bytes):
  0000:  00 A4 04 00 09 A0 00 00 03 08 00 00 10 00         ..............
14.11.2022 10:48:20  [INFO] Response APDU (2 bytes):
  0000:  6A 82                                             ..
14.11.2022 10:48:20  [INFO] Command APDU (7 bytes):
  0000:  00 A4 00 0C 02 3F FF                              .......
14.11.2022 10:48:20  [INFO] Response APDU (2 bytes):
  0000:  6A 82                                             ..
14.11.2022 10:48:20  [INFO] Command APDU (15 bytes):
  0000:  00 A4 04 04 09 A0 00 00 03 97 42 54 46 59 00      ...............
14.11.2022 10:48:20  [INFO] Response APDU (2 bytes):
  0000:  6A 82                                             ..
14.11.2022 10:48:20  [INFO] Command APDU (15 bytes):
  0000:  00 A4 04 00 09 A0 00 00 03 97 42 54 46 59 00      ...............
14.11.2022 10:48:20  [INFO] Response APDU (2 bytes):
  0000:  6A 82                                             ..
14.11.2022 10:48:20  [INFO] Command APDU (14 bytes):
  0000:  00 A4 04 00 09 A0 00 00 03 08 00 00 10 00         ..............
14.11.2022 10:48:20  [INFO] Response APDU (2 bytes):
  0000:  6A 82                                             ..
14.11.2022 10:48:20  [INFO] Command APDU (7 bytes):
  0000:  00 A4 00 0C 02 3F FF                              .......
14.11.2022 10:48:20  [INFO] Response APDU (2 bytes):
  0000:  6A 82                                             ..
14.11.2022 10:48:20  [INFO] Command APDU (15 bytes):
  0000:  00 A4 04 04 09 A0 00 00 03 97 42 54 46 59 00      ...............
14.11.2022 10:48:20  [INFO] Response APDU (2 bytes):
  0000:  6A 82                                             ..
14.11.2022 10:48:20  [INFO] Command APDU (15 bytes):
  0000:  00 A4 04 00 09 A0 00 00 03 97 42 54 46 59 00      ...............
14.11.2022 10:48:20  [INFO] Response APDU (2 bytes):
  0000:  6A 82
Nick-The-Uncharted commented 1 year ago

And reset was sent there times:

14.11.2022 10:48:20  [INFO] Reset
14.11.2022 10:48:20  [INFO] Reset
14.11.2022 10:48:20  [INFO] Reset
frankmorgner commented 1 year ago

This is a Windows thing. Try this: https://learn.microsoft.com/en-us/windows/security/identity-protection/smart-cards/smart-card-group-policy-and-registry-settings#turn-on-smart-card-plug-and-play-service

Nick-The-Uncharted commented 1 year ago

@frankmorgner Thank you for your response, I set HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\ScPnP\EnableScPnP to 0 and rebooted, the commands received was less than before. If this is a system thing I guess will just leave that be.