Python/PHP with ZK fingerprint attendance machines

biometric-attendance-machine-156954

If you are developing for Linux environment and If you have a task related to pulling data from a zk fingerprint attendance machine / biometric device the hair pulling phase may start 1 hour – 3 hours of hopeless search.

Downloading windows SDK and reverse engineering them isn’t the solution. wireshark isn’t the solution and connecting the the shared .mdb file isn’t also a solution the right solution is to connect to the machine using UDP port 4370.

0- Backup your attendance machine data.(You may use zktimes for this step.)

1- clone this repo:

For Python: [email protected]:dnaextrim/python_zklib.git

For PHP: https://github.com/dnaextrim/php_zklib

2- Login to the attendance machine as admin

and set the communication key (aka communication password to 0 or empty).

3- Set the IP address to some IP (say 192.168.1.201) this is the default one.

4-Connect the attendance machine to the network (ethernet most commonly)

5-Change IP:

zk = zklib.ZKLib(“192.168.1.201”, 4370)

6- Comment this (dangerous line that clears admin):

print Pesan Clear Admin:, zk.clearAdmin()

Now, try to run the script with the machine connected to your local network.

./zktest.py

I’ve just saved your life.

Check the file capability it should be very easy for any python programmer from here on.

Note: you may find very strange messages like “Pesan Koneksi” or use my safe English translated fork.

Enjoy!

Join the Conversation

22 Comments

  1. I must say it was hard to find your website in google.
    You write awesome content but you should rank your website higher in search engines.
    If you don’t know how to do it search on youtube:
    how to rank a website Marcel’s way

  2. Is there any way to access it while the comm key is set to something like 123? In short, is there a way to pass the comm key in the connect function? Is that an available parameter?

    1. I don’t think you can in real time but you can constantly pull the data and see if there’s any change.

  3. Hi,

    Thank you for sharing AlSayedGamal/python_zklib,this has helped us a lot. We would like to know if you have any upgrades or any solution for python 3. The above version works for python 2.7. We are currently using odoo 11 and this does not work any more.It works fine for odoo 10. Please let us know how you could support us on this.

    Thank you !

    Regards

    Dharmakantha

    1. I don’t maintain this repo any more but upgrading to python 3.0 can be a great addition I’ll see if I can make it next weekend.
      I strongly recommend that you add it as an issue to the repo.
      Sorry for late reply :O

  4. Good afternoon, I need to communicate with zkteco device using TCP protocol but your code is using UDP. How do i do that using TCP protocol ? Thank you

    1. I’m not aware of any other technique to TCP communication other than the HTTP protocol web interface they have in some versions but I don’t think that this will work for all versions.

  5. Hi AlSayedGamal, I’m trying out the python code but having errors regarding the unicodeDecoder. And also the code was not able to display the attendance. Pls advice.

    1. Can you please, your issue on the repo I’ll be glad to check it and let you know what’s wrong with it.

  6. Hi,
    Thanks for nice work,
    I am trying to use your php script, I am connected successfully, but i cannot get the user and their attendance, could you please guide me how to troubleshoot and what to change to get the users records?

  7. لو ممكن حضرتك تقارح عليا اسم مودل معين بيدعم المكتبة دى عشان اشتريه واستخدمه مع الليبرارى بدون مشاكل

  8. I have application that i write in PHP Language and MYSQL as database can connect to attendance machine and use the cloud feature in the machine to get attendance data in real time. With real time you don’t need operator to pull data in weekly period or monthly period. All data can pulled automatically and save into your server in database. So you cloud save your time and your money just to pull attendance data in periodically. My Application can be installed in hosting so you can centralize your attendance data to one server and it most efficient and easy to get report of your presence employee. If you interest with my application that i have made, you can call me at +6281348021778 with WA available.

    1. features application:
      1. Realtime
      2. Support many machine brands, and one server can accommodate up to dozens of machines (Only machine that has adms/cloud server in firmware)
      3. Upload the user to the desired machine
      4. Upload fingerprint templates to the desired machine
      5. Delete Transactions on the machine
      6. Remove fingerprints on the machine
      7. Pull machine information (Number of transactions, number of fingerprints and machine settings)
      8. Can know the status of the machine online or offline
      9. Reboot the engine
      10. Pull the user’s attendance and fingerprint data manually
      11. Automatically pull the absent ID and user name on the machine
      12. Can upload and download fingerprint template from the machine to the server
      Contact me at +6281348021778 (WA Available)

  9. I have application that i write in PHP Language and MYSQL as database can connect to attendance machine and use the cloud feature menu in the machine to get attendance data in real time. With real time you don’t need operator to pull data in weekly periods or monthly periods. All data can pulled automatically and save into your server in database. So you could save your time and your money just to pull attendance data in periodically. My Application can be installed in hosting so you can centralize your attendance data to one server and it most efficient and easy to get report of your presence employee. If you interest with my application that i have made, you can call me at +6281348021778 with WA available.

    Feature Application :
    1. Realtime
    2. Support many machine brands, and one server can accommodate up to dozens of machines (Only machine that has adms/cloud server in firmware)
    3. Upload the user to the desired machine
    4. Upload fingerprint templates to the desired machine
    5. Delete Transactions on the machine
    6. Remove fingerprints on the machine
    7. Pull machine information (Number of transactions, number of fingerprints and machine settings)
    8. Can know the status of the machine online or offline
    9. Reboot the engine
    10. Pull the user’s attendance and fingerprint data manually
    11. Automatically pull the absent ID and user name on the machine
    12. Can upload and download fingerprint template from the machine to the server
    13. Source Code is open you can build your own cloud service of time attendance
    14. Can installed in hosting or local network

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.