charlysan / pyrfidhid

Python library to control Chinese USB HID 125Khz RFID Reader/Writer
MIT License
142 stars 36 forks source link

Is there any difference? #3

Closed moliata closed 5 years ago

moliata commented 6 years ago

I have just successfully purchased an RFID Reader/Writer (just like this one) on AliExpress: https://www.aliexpress.com/item/RFID-Copier-125KHz-EM4100-Cloner-Writer-Duplicator-Programmer-Reader-5-Pcs-EM4305-T5577-Rewritable-ID-Keyfobs/32721839667.html?spm=a2g0s.9042311.0.0.2b494c4d1v0Omv, interesting thing is that when I searched for IDRW V3 on Google Images, all photos contained the same reader but instead they all had following text on them: Microsoft Windows, FC and USB Reader. The only thing that his has is RFID Reader, should it work? Or I just purchased something not right?

charlysan commented 6 years ago

From the bottom diagram, it looks like it is not a USB HID device; it might be USB to Serial. Maybe you could ask the seller the name of the tool it uses? That might give you some clue.

moliata commented 6 years ago

I found this video using (from the look) same device https://youtu.be/vCaVs2aS1tQ, even though it's a different store, the bottom of the reader looks the same (USB-203, ID, USB, R/W). In the video, we can see that it acts as a USB Input Device as well, so I hope it should be same with this device. They also use IDRW tool, but I'm not sure if that is original and/or it's V2 or V1.

charlysan commented 6 years ago

I'm not sure if this device would be compatible with my library, but let me know when you have it; if it doesn't work we'll try to add support for it.

moliata commented 6 years ago

@charlysan Sure, I have also seen some RFID readers/writers like these in AliExpress which also showed a picture of IDRW V3 in use with it, so I am 90% confident it should work, if not, I'll try to reverse engineer the software they provide and look into the serial communication between the device and computer. I should get the device on August 28th - September 13th. I'll tell you whenever I get my hands on it. Fingers crossed.

moliata commented 6 years ago

Oh and also, this GitHub repository at https://github.com/merbanan/rfid_app, seems really interesting to me. RFID App is a really popular application which is used in these AliExpress products. You may want to take a look there.

charlysan commented 6 years ago

Yes, I've seen that app; it's great!

moliata commented 6 years ago

By the way, does this reader/writer work with HID ProxCards, AWID cards? EDIT: it doesn't...

charlysan commented 5 years ago

No HID/AWID cards support by this reader/writer. AFAIK, only EM4305 and T5577.

moliata commented 5 years ago

Yup! AFAIK EM4xxx and T55xx

vale5566 commented 5 years ago

Hello, I ordered this one: https://de.aliexpress.com/item/USB-125-khz-RFID-EM4305-T5567-Karte-Reader-Writer-Kopierer-Schriftsteller-Programmierer-Brenner-5-ID-Schl/32903931148.html and I received it today.

I try to use it with IDRW V3 but it doesn't work. It only give the UID as output over my keyboard anytime when i put one of my RFID Cards in the range. Also tried with your libary but I get an error from pyusb.

Initializing device... Traceback (most recent call last): File "read.py", line 76, in <module> main() File "read.py", line 48, in main rfid.init() File "/usr/lib/python3.6/site-packages/pyrfidhid-0.1-py3.6.egg/rfidhid/core.py", line 58, in init File "/usr/lib/python3.6/site-packages/usb/control.py", line 173, in get_descriptor data_or_wLength = desc_size) File "/usr/lib/python3.6/site-packages/usb/core.py", line 1043, in ctrl_transfer self.__get_timeout(timeout)) File "/usr/lib/python3.6/site-packages/usb/backend/libusb1.py", line 883, in ctrl_transfer timeout)) File "/usr/lib/python3.6/site-packages/usb/backend/libusb1.py", line 595, in _check raise USBError(_strerror(ret), ret, _libusb_errno[ret]) usb.core.USBError: [Errno 32] Pipe error

charlysan commented 5 years ago

@vale5566, that device might behave as a USB HID Keyboard. The one I have is different, it has a custom "protocol" with commands for reading and writing a tag. Have you tried merbanan rfid_app? One more thing, could you please paste your output for sudo lsusb -vd ffff:0035?

vale5566 commented 5 years ago

output from sudo lsusb -vd ffff:0035: Bus 001 Device 006: ID ffff:0035 Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass 0 bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 8 idVendor 0xffff idProduct 0x0035 bcdDevice 1.00 iManufacturer 1 Sycreader iProduct 2 USB Reader iSerial 3 08FF20150112 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 0x0034 bNumInterfaces 2 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 3 Human Interface Device bInterfaceSubClass 1 Boot Interface Subclass bInterfaceProtocol 1 Keyboard iInterface 4 Keyboard HID Device Descriptor: bLength 9 bDescriptorType 33 bcdHID 1.10 bCountryCode 33 US bNumDescriptors 1 bDescriptorType 34 Report wDescriptorLength 65 Report Descriptors: ** UNAVAILABLE ** Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0008 1x 8 bytes bInterval 10 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 0 bNumEndpoints 0 bInterfaceClass 3 Human Interface Device bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 5 Vender Hid HID Device Descriptor: bLength 9 bDescriptorType 33 bcdHID 1.10 bCountryCode 33 US bNumDescriptors 1 bDescriptorType 34 Report wDescriptorLength 35 Report Descriptor: (length is 35) Item(Global): Usage Page, data= [ 0xa0 0xff ] 65440 (null) Item(Local ): Usage, data= [ 0x01 ] 1 (null) Item(Main ): Collection, data= [ 0x01 ] 1 Application Item(Global): Report ID, data= [ 0x01 ] 1 Item(Local ): Usage, data= [ 0x08 ] 8 (null) Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255 Item(Global): Logical Minimum, data= [ 0x00 ] 0 Item(Global): Report Size, data= [ 0x08 ] 8 Item(Global): Report Count, data= [ 0xff ] 255 Item(Main ): Feature, data= [ 0x02 ] 2 Data Variable Absolute No_Wrap Linear Preferred_State No_Null_Position Non_Volatile Bitfield Item(Global): Report ID, data= [ 0x02 ] 2 Item(Local ): Usage, data= [ 0x08 ] 8 (null) Item(Main ): Feature, data= [ 0x02 ] 2 Data Variable Absolute No_Wrap Linear Preferred_State No_Null_Position Non_Volatile Bitfield Item(Global): Report ID, data= [ 0x03 ] 3 Item(Local ): Usage, data= [ 0x08 ] 8 (null) Item(Main ): Feature, data= [ 0x02 ] 2 Data Variable Absolute No_Wrap Linear Preferred_State No_Null_Position Non_Volatile Bitfield Item(Main ): End Collection, data=none can't get debug descriptor: Resource temporarily unavailable cannot read device status, Resource temporarily unavailable (11) Yes I t tried the rfid_app I get the same error as this comment.

moliata commented 5 years ago

Does it work with preincluded software by the seller? If so, can you tell us the name of it.

vale5566 commented 5 years ago

There was no software included. I wrote the seller at Aliexpress but I don't think I get an helpful answer.

vale5566 commented 5 years ago

Okay I found the solution I disassembled the package and the chip can only read.

But thanks for your help!

charlysan commented 5 years ago

That makes sense @vale5566, as the device behaves as a Keyboard. Could you please share a picture of the back of the device? (it if has same labels). That information might be useful.

vale5566 commented 5 years ago

Sure, but there is no label. link to the photo: https://ittuberlin-my.sharepoint.com/:i:/g/personal/5146500509788880_msopseudo_tu-berlin_de/EXJ6PE3cLR9NuA3GF2ypa64B6wD8XdZsWpL5jWi-oI4Wew?e=nde7UX

moliata commented 5 years ago

@charlysan the HID option in my picture meant not Human Interface Device, but whether it supports HID Corporation cards such as HID ProxCard II

charlysan commented 5 years ago

True. Thanks for clarifying that @moliata.

moliata commented 5 years ago

@charlysan there are 2 RFID Reader/Writer versions. ffff:0035 version and 6688:6850 version. Your code works with the ffff:0035, but my device is the second version 6688:6850. It is also HID device, but with a different PID/VID and different commands. RFID APP repository worked for me, so we should take a look on how to implement it.

moliata commented 5 years ago

In the provided software the is a check box for enabling "Analog USB Keyboard" mode, when I enable it and click Read Card, it becomes a HID device. Then I am able to use Notepad and get all of the data. Pretty interesting.

charlysan commented 5 years ago

That's seems to be a more complex device than mine @moliata. Just in case, please try out v0.1.1 branch.

moliata commented 5 years ago

v0.1.1 branch uses ffff:0035 vid/pid. I'll try to rewrite the code under the 6688:6850 vid/pid with different commands. I'll post the update here, if everything works well, I'll create a PR under the master branch with a proposal.

moliata commented 5 years ago

Arghh... I am not able to send the data to the RFID reader because of the https://github.com/pyusb/pyusb/issues/208

charlysan commented 5 years ago

No need to rewrite code for your vid/pid, you can just pass any vid/pid to the constructor. ffff:0035 are just the default values @moliata

moliata commented 5 years ago

@charlysan yeah, but I am not able to run your code because of the insufficient permissions error on my Macbook.

charlysan commented 5 years ago

You can use a Linux VM until the guys from pyusb figure out out to solve that issue @moliata.

moliata commented 5 years ago

It seems the problem is with Mac computers security... The kernel driver is binded to a HID device, disallowing me to use it. I'll try it with my Ubuntu laptop, thanks!

charlysan commented 5 years ago

Strange @moliata. I can confirm that I can read and write tags using my Mac. I've just tried it out with success (MacOS HighSierra 10.13.6 (17G65)).

moliata commented 5 years ago

I am not able to use neither read neither write examples with 10.13.5 (MacBook Air Early 2015).