LudovicRousseau / pyscard

pyscard smartcard library for python
http://pyscard.sourceforge.net/
GNU Lesser General Public License v2.1
377 stars 108 forks source link

pyscard not finding my card #134

Closed beginnerslvl closed 1 year ago

beginnerslvl commented 2 years ago

kali linux python Python 2.7.18 (default, Mar 28 2022, 20:47:09)

sir i have ,been trying for more than three days to connect my ACR122U-A9to pyscard it is showing me errors please help i am using kali linux on my virtual machine i have uninstalled it 3 times changes its settings a thousand times read your blog still i am facing issues i am no expert but it has been 5 months using linux i am just trying to learn about nfc and credit cards etc  by using nfc-list i can see my card reader┌──(root kali)-[/home/…/pyscard/PCSC/CCID/PCSC] └─# nfc-list                         nfc-list uses libnfc 1.8.0 NFC device: ACS / ACR122U PICC Interface opened

but when i do pcsc_scan ┌──(root kali)-[/home/…/pyscard/PCSC/CCID/PCSC] └─# pcsc_scan Using reader plug'n play mechanism Scanning present readers...

i have tried many methods includinghttps://github.com/nfc-tools/ifdnfc/issues/6 installing ccidpcscdi was actually following salvador mendoza guide of card emulation and it took me three days only to resolve python not importing smartcard well somehow i resolved it by using python 3.10.4 now it cant get my card info PLEASE HELP

python                                                                                                                                                        255 ⨯ Python 3.10.4 (main, Mar 24 2022, 13:07:27) [GCC 11.2.0] on linux Type "help", "copyright", "credits" or "license" for more information.

import smartcard smartcard.System.readers() []                                

PLEASE PLEASE PLEASE HELP i know this issue have been done before but i tried that fix and nothing worked please help 

Steps for reproducing this issue:

1.clone pyscard 2.install all tools pcsc etc

  1. python import smart card
  2. not work
LudovicRousseau commented 2 years ago

What is the output of lsusb when the reader is connected?

beginnerslvl commented 2 years ago

┌──(root💀kali)-[/home/kali/pyscard] └─# lsusb Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 003: ID 072f:2200 Advanced Card Systems, Ltd ACR122U Bus 001 Device 002: ID 80ee:0021 VirtualBox USB Tablet Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

beginnerslvl commented 2 years ago

thankyou for replying sorry i incorrectly posted this two times i feel ashamed

beginnerslvl commented 2 years ago

could you please please control my computer from there and install this i also have mailed you maybe ssh or anydesk something PLEASE PLEASE

LudovicRousseau commented 2 years ago

Generate a log as documented in https://ccid.apdu.fr/#support

beginnerslvl commented 2 years ago

the log is stuck

beginnerslvl commented 2 years ago

┌──(kali㉿kali)-[~] └─$ sudo LIBCCID_ifdLogLevel=0x000F pcscd --foreground --debug --apdu --color | tee log.txt [sudo] password for kali: 00000000 debuglog.c:297:DebugLogSetLevel() debug level=debug 00000223 debuglog.c:318:DebugLogSetCategory() Debug options: APDU 00000046 [139815858650112] pcscdaemon.c:356:main() Force colored logs 00001803 [139815858650112] configfile.l:293:DBGetReaderListDir() Parsing conf directory: /usr/local/etc/reader.conf.d 00000801 [139815858650112] configfile.l:329:DBGetReaderListDir() Skipping non regular file: . 00000006 [139815858650112] configfile.l:329:DBGetReaderListDir() Skipping non regular file: .. 00000001 [139815858650112] configfile.l:369:DBGetReaderList() Parsing conf file: /usr/local/etc/reader.conf.d/libccidtwin 00000677 [139815858650112] pcscdaemon.c:666:main() pcsc-lite 1.9.7 daemon ready. 00006704 [139815858650112] hotplug_libudev.c:300:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0002, path: /dev/bus/usb/001/001 00000257 [139815858650112] hotplug_libudev.c:300:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0002, path: /dev/bus/usb/001/001 00000200 [139815858650112] hotplug_libudev.c:300:get_driver() Looking for a driver for VID: 0x80EE, PID: 0x0021, path: /dev/bus/usb/001/002 00000113 [139815858650112] hotplug_libudev.c:300:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0002, path: /dev/bus/usb/001/001 00000095 [139815858650112] hotplug_libudev.c:300:get_driver() Looking for a driver for VID: 0x072F, PID: 0x2200, path: /dev/bus/usb/001/003 00000024 [139815858650112] hotplug_libudev.c:421:HPAddDevice() Adding USB device: ACS ACR122U PICC Interface 00000040 [139815858650112] readerfactory.c:1093:RFInitializeReader() Attempting startup of ACS ACR122U PICC Interface 00 00 using /usr/local/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Linux/libccid.so 00002676 [139815858650112] readerfactory.c:968:RFBindFunctions() Loading IFD Handler 3.0 00000106 [139815858650112] ifdhandler.c:2071:init_driver() Driver version: 1.5.0 00000376 [139815858650112] ifdhandler.c:2088:init_driver() LogLevel: 0x0003 00000022 [139815858650112] ifdhandler.c:2099:init_driver() DriverOptions: 0x0000 00000178 [139815858650112] ifdhandler.c:2112:init_driver() LogLevel from LIBCCID_ifdLogLevel: 0x000F 00000031 [139815858650112] ifdhandler.c:110:CreateChannelByNameOrChannel() Lun: 0, device: usb:072f/2200:libudev:0:/dev/bus/usb/001/003 00000025 [139815858650112] ccid_usb.c:252:OpenUSBByName() Reader index: 0, Device: usb:072f/2200:libudev:0:/dev/bus/usb/001/003 00000024 [139815858650112] ccid_usb.c:284:OpenUSBByName() interface_number: 0 00000018 [139815858650112] ccid_usb.c:285:OpenUSBByName() usb bus/device: 1/3 00000023 [139815858650112] ccid_usb.c:317:OpenUSBByName() Using: /usr/local/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Info.plist 00000366 [139815858650112] ccid_usb.c:335:OpenUSBByName() ifdManufacturerString: Ludovic Rousseau (ludovic.rousseau@free.fr) 00000026 [139815858650112] ccid_usb.c:336:OpenUSBByName() ifdProductString: Generic CCID driver 00000018 [139815858650112] ccid_usb.c:337:OpenUSBByName() Copyright: This driver is protected by terms of the GNU Lesser General Public License version 2.1, or (at your option) any later version. 00001128 [139815858650112] ccid_usb.c:421:OpenUSBByName() Try device: 1/3 00000038 [139815858650112] ccid_usb.c:431:OpenUSBByName() vid/pid : 072F/2200 00000049 [139815858650112] ccid_usb.c:502:OpenUSBByName() Checking device: 1/3 00000024 [139815858650112] ccid_usb.c:573:OpenUSBByName() Trying to open USB bus/device: 1/3 00113953 [139815858650112] ccid_usb.c:679:OpenUSBByName() Found Vendor/Product: 072F/2200 (ACS ACR122U PICC Interface) 00000010 [139815858650112] ccid_usb.c:681:OpenUSBByName() Using USB bus/device: 1/3 00000002 [139815858650112] ccid_usb.c:744:OpenUSBByName() bNumDataRatesSupported is 0 00001351 [139815858650112] ccid_usb.c:1473:InterruptRead() before (0), timeout: 100 ms 00018090 [139815858650112] ccid_usb.c:1519:InterruptRead() after (0) (0) 00000014 [139815858650112] NotifySlotChange: 50 03 00000089 [139815858650112] -> 000000 65 00 00 00 00 00 00 00 00 00 00016151 [139815858650112] <- 000000 81 00 00 00 00 00 00 00 81 00 00000011 [139815858650112] -> 000000 65 00 00 00 00 00 01 00 00 00 00050166 [139815858650112] <- 000000 81 00 00 00 00 00 01 00 81 00 00000020 [139815858650112] ifdhandler.c:388:IFDHGetCapabilities() tag: 0xFB3, usb:072f/2200:libudev:0:/dev/bus/usb/001/003 (lun: 0) 00000002 [139815858650112] readerfactory.c:398:RFAddReader() Using the reader polling thread 00000002 [139815858650112] ifdhandler.c:1925:IFDHICCPresence() usb:072f/2200:libudev:0:/dev/bus/usb/001/003 (lun: 0) 00000002 [139815858650112] -> 000000 65 00 00 00 00 00 02 00 00 00 00000690 [139815858650112] <- 000000 81 00 00 00 00 00 02 00 81 00 00000008 [139815858650112] ifdhandler.c:2051:IFDHICCPresence() Card present 00000061 [139815858650112] ifdhandler.c:388:IFDHGetCapabilities() tag: 0xFAE, usb:072f/2200:libudev:0:/dev/bus/usb/001/003 (lun: 0) 00000002 [139815858650112] ifdhandler.c:484:IFDHGetCapabilities() Reader supports 1 slot(s) 00000266 [139815858650112] hotplug_libudev.c:300:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0003, path: /dev/bus/usb/002/001 00000056 [139815858650112] readerfactory.c:1436:RFWaitForReaderInit() Waiting init for reader: ACS ACR122U PICC Interface 00 00 00000181 [139815841605184] ifdhandler.c:1925:IFDHICCPresence() usb:072f/2200:libudev:0:/dev/bus/usb/001/003 (lun: 0) 00000042 [139815841605184] -> 000000 65 00 00 00 00 00 03 00 00 00 00001024 [139815841605184] <- 000000 81 00 00 00 00 00 03 00 81 00 00000075 [139815841605184] ifdhandler.c:2051:IFDHICCPresence() Card present 00000046 [139815841605184] ifdhandler.c:1925:IFDHICCPresence() usb:072f/2200:libudev:0:/dev/bus/usb/001/003 (lun: 0) 00000037 [139815841605184] -> 000000 65 00 00 00 00 00 04 00 00 00 00001003 [139815841605184] <- 000000 81 00 00 00 00 00 04 00 81 00 00000100 [139815841605184] ifdhandler.c:2051:IFDHICCPresence() Card present 00000042 [139815841605184] ifdhandler.c:1216:IFDHPowerICC() action: PowerUp, usb:072f/2200:libudev:0:/dev/bus/usb/001/003 (lun: 0) 00000042 [139815841605184] -> 000000 62 00 00 00 00 00 05 01 00 00 00000844 [139815841605184] <- 000000 80 02 00 00 00 00 05 00 81 00 3B 00 00000095 [139815841605184] eventhandler.c:289:EHStatusHandlerThread() powerState: POWER_STATE_POWERED 00000043 [139815841605184] Card ATR: 3B 00 00000033 [139815841605184] ifdhandler.c:1925:IFDHICCPresence() usb:072f/2200:libudev:0:/dev/bus/usb/001/003 (lun: 0) 00000032 [139815841605184] -> 000000 65 00 00 00 00 00 06 00 00 00 00000899 [139815841605184] <- 000000 81 00 00 00 00 00 06 00 81 00 00000082 [139815841605184] ifdhandler.c:2051:IFDHICCPresence() Card present 00000035 [139815841605184] ifdhandler.c:317:IFDHPolling() usb:072f/2200:libudev:0:/dev/bus/usb/001/003 (lun: 0) 5000 ms 00000040 [139815841605184] ccid_usb.c:1473:InterruptRead() before (0), timeout: 5000 ms 05002028 [139815841605184] ccid_usb.c:1519:InterruptRead() after (0) (2) 00000023 [139815841605184] ifdhandler.c:1925:IFDHICCPresence() usb:072f/2200:libudev:0:/dev/bus/usb/001/003 (lun: 0) 00000006 [139815841605184] -> 000000 65 00 00 00 00 00 07 00 00 00 00001624 [139815841605184] <- 000000 81 00 00 00 00 00 07 00 81 00 00000016 [139815841605184] ifdhandler.c:2051:IFDHICCPresence() Card present 00000005 [139815841605184] ifdhandler.c:1216:IFDHPowerICC() action: PowerDown, usb:072f/2200:libudev:0:/dev/bus/usb/001/003 (lun: 0) 00000005 [139815841605184] -> 000000 63 00 00 00 00 00 08 00 00 00 00001137 [139815841605184] <- 000000 81 00 00 00 00 00 08 00 81 00 00000016 [139815841605184] -> 000000 63 00 00 00 00 00 09 00 00 00 00001138 [139815841605184] <- 000000 81 00 00 00 00 00 09 00 81 00 00000016 [139815841605184] eventhandler.c:482:EHStatusHandlerThread() powerState: POWER_STATE_UNPOWERED 00000006 [139815841605184] ifdhandler.c:1925:IFDHICCPresence() usb:072f/2200:libudev:0:/dev/bus/usb/001/003 (lun: 0) 00000005 [139815841605184] -> 000000 65 00 00 00 00 00 0A 00 00 00 00000756 [139815841605184] <- 000000 81 00 00 00 00 00 0A 00 81 00 00000011 [139815841605184] ifdhandler.c:2051:IFDHICCPresence() Card present 00000005 [139815841605184] ifdhandler.c:317:IFDHPolling() usb:072f/2200:libudev:0:/dev/bus/usb/001/003 (lun: 0) 600000 ms 00000004 [139815841605184] ccid_usb.c:1473:InterruptRead() before (0), timeout: 600000 ms

beginnerslvl commented 2 years ago

could you please please control my computer from there and install this i also have mailed you maybe ssh or anydesk something PLEASE PLEASE

???????????????

beginnerslvl commented 2 years ago

oh sorry

log.txt

beginnerslvl commented 2 years ago

here is the log

LudovicRousseau commented 2 years ago

pcsc_scan should at least list the reader "ACS ACR122U PICC Interface 00 00" I see the pcscd logs.

I can also see the ATR in the log:

00000043 [139815841605184] Card ATR: 3B 00 

Your problem is not really with PySCard. But with a lower level layer.

beginnerslvl commented 2 years ago

could you help ??? like ssh or anydesk etc PLEASE

beginnerslvl commented 2 years ago

i have mailed you

beginnerslvl commented 2 years ago

kind sir please help my reader is connected and registered with nfc-list and lsusb but pyscard cannot detect

beginnerslvl commented 2 years ago

I have deleted my virtual machine, and started again installed pcscd pcsc-tools now pcscd can scan my reader but it cannot use it 

┌──(kali㉿kali)-[~] └─$ sudo service pcscd status ○ pcscd.service - PC/SC Smart Card Daemon      Loaded: loaded (/lib/systemd/system/pcscd.service; indirect; vendor preset: disabled)      Active: inactive (dead) since Mon 2022-06-20 04:55:06 EDT; 37s ago TriggeredBy: ● pcscd.socket        Docs: man:pcscd(8)     Process: 1201 ExecStart=/usr/sbin/pcscd --foreground --auto-exit $PCSCD_ARGS (code=exited, status=0/SUCCESS)    Main PID: 1201 (code=exited, status=0/SUCCESS)         CPU: 12ms

Jun 20 04:53:16 kali systemd[1]: Started PC/SC Smart Card Daemon. Jun 20 04:53:17 kali pcscd[1201]: 00000000 ccid_usb.c:993:ReadUSB() read failed (1/3): LIBUSB_ERROR_TIMEOUT Jun 20 04:53:17 kali pcscd[1201]: 00130762 ccid_usb.c:993:ReadUSB() read failed (1/3): LIBUSB_ERROR_TIMEOUT Jun 20 04:53:17 kali pcscd[1201]: 00000036 ifdhandler.c:202:CreateChannelByNameOrChannel() failed Jun 20 04:53:17 kali pcscd[1201]: 00000615 readerfactory.c:1134:RFInitializeReader() Open Port 0x200000 Failed (usb:072f/2200:libudev:0:/dev/bus/usb/001/003) Jun 20 04:53:17 kali pcscd[1201]: 00000012 readerfactory.c:378:RFAddReader() ACS ACR122U PICC Interface init failed. Jun 20 04:53:17 kali pcscd[1201]: 00000113 hotplug_libudev.c:518:HPAddDevice() Failed adding USB device: ACS ACR122U PICC Interface Jun 20 04:55:06 kali systemd[1]: pcscd.service: Deactivated successfully.                                                                                      

pcsc_scan                 Using reader plug'n play mechanism Scanning present readers... Waiting for the first reader...

PLEASE HELP

LudovicRousseau commented 1 year ago

It is not a PySCard issue.

ronie19 commented 6 months ago

pcsc_scan should at least list the reader "ACS ACR122U PICC Interface 00 00" I see the pcscd logs.

I can also see the ATR in the log:

00000043 [139815841605184] Card ATR: 3B 00 

Your problem is not really with PySCard. But with a lower level layer.

I am having issue with ATR response of IFDNFC which is limited only to 5 bytes, unlike complete as read by ACR122 reader. Where do you think might be the problem ? I am using raspberry pi