From 616a667c185951472fd787a6ad2a09cdf71d3e80 Mon Sep 17 00:00:00 2001 From: Viktor Dragomiretskyy Date: Sat, 21 Sep 2019 14:28:42 +1200 Subject: [PATCH] Add requirements.txt, update README --- README.md | 89 ++++++++++++++++++++++++++++++----------- pair.py | 2 + proto97/init_db.py | 4 +- proto97/upload_fwext.py | 3 -- requirements.txt | 4 ++ 5 files changed, 73 insertions(+), 29 deletions(-) create mode 100644 requirements.txt diff --git a/README.md b/README.md index b8ad78d..028d1e9 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,49 @@ Validity fingerprint sensor library. Originally designed to capture some of my findings for 138a:0097, but if you manage to get it working for some other Validity sensor - pull requests are welcome. +## Setting up +Use Wine to install official Lenovo device driver. The only reason you need to do this is to find 6_07f_lenovo_mis.xpfwext and copy it to +this project location. This file contains firmware and without it the pairing wont work. You will not need wine after this. + +To install Python dependencies run +``` +$ pip3 install -r requirements.txt +``` + +## Factory reset +If your device was previously paired with another OS or computer, you need to do a factory reset. +This will erase all fingers from the internal database and make the device ready for pairing. +``` +$ python3 factory-reset.py +$ +``` + +## Pairing +After performing a factory reset you need to pair your device with a host computer. +This must be done only once, before you can enroll/identify/verify fingers. +``` +$ python3 pair.py +Initializing flash... +Detected Flash IC: W25Q80B, 1048576 bytes +Clean slate +Uploading firmware... +Sensor: VSI 55E FM209-001 +Loaded FWExt version 1.1 (Sat Feb 3 05:07:30 2018), 8 modules +Calibrating... +Sensor: VSI 55E FM209-001 +FWExt version 1.1 (Sat Feb 3 05:07:30 2018), 8 modules +Calibration data loaded from the file. +Init database... +Creating a new user storage object +Creating a host machine GUID record +That's it, pairing's finished +$ +``` + ## Examples -Here are a couple of examples of how you can use this library. +Here is a couple of examples of how you can use this library. All examples assume that your device is already paired. + +### Initialize a session Before talking to a device you will need to open it and start a new TLS session ``` $ python3 @@ -25,29 +66,6 @@ Type "help", "copyright", "credits" or "license" for more information. >>> ``` -### Enable tracing -If you are curious you can enable tracing to see what flows in and out of device before and after encryption -``` ->>> tls.trace_enabled=True ->>> usb.trace_enabled=True ->>> db.dump_all() ->tls> 17: 4b00000b0053746757696e64736f7200 ->cmd> 1703030050c00a7ff1cf76e90f168141b4bc519ca9598eacb575ff01b7552a3707be8506b246d5272cb119e7b8b3eccd991cb7d8387245953ff1da62cebfb07fae7e47b9b536fb1a82185cc9399d30625ee3c1451f -tls> 17: 4a080000000000 ->cmd> 1703030040ef982e5d6c403ff636c44cd53e7d0f98c21f67ff3b5b80f53555e4547028bd4d17cf5b0539ac0489238f1f066b8ba849120380cf979088d6c63249c873868c95 -tls> 17: 4a0a0000000000 ->cmd> 1703030040b522c55b73480e0d71a322abf8b65d97c9b55e9930206c463f998886cda4410d1b00ab41ec5b213d2ac18bf3bf61ce817446f27d643f99aba5a1d4cb80d18461 ->> -``` ### Enroll a new user Note: 0xf5 == WINBIO_FINGER_UNSPECIFIED_POS_01 (see [ms docs](https://docs.microsoft.com/en-us/windows/desktop/SecBioMet/winbio-ansi-381-pos-fingerprint-constants)) ``` @@ -111,3 +129,26 @@ done ``` +## Debugging +If you are curious you can enable tracing to see what flows in and out of device before and after encryption +``` +>>> tls.trace_enabled=True +>>> usb.trace_enabled=True +>>> db.dump_all() +>tls> 17: 4b00000b0053746757696e64736f7200 +>cmd> 1703030050c00a7ff1cf76e90f168141b4bc519ca9598eacb575ff01b7552a3707be8506b246d5272cb119e7b8b3eccd991cb7d8387245953ff1da62cebfb07fae7e47b9b536fb1a82185cc9399d30625ee3c1451f +tls> 17: 4a080000000000 +>cmd> 1703030040ef982e5d6c403ff636c44cd53e7d0f98c21f67ff3b5b80f53555e4547028bd4d17cf5b0539ac0489238f1f066b8ba849120380cf979088d6c63249c873868c95 +tls> 17: 4a0a0000000000 +>cmd> 1703030040b522c55b73480e0d71a322abf8b65d97c9b55e9930206c463f998886cda4410d1b00ab41ec5b213d2ac18bf3bf61ce817446f27d643f99aba5a1d4cb80d18461 +>> +``` diff --git a/pair.py b/pair.py index 1617261..90e8612 100644 --- a/pair.py +++ b/pair.py @@ -9,6 +9,8 @@ from proto97.upload_fwext import upload_fwext from proto97.calibrate import calibrate from proto97.init_db import init_db +#usb.trace_enabled=True +#tls.trace_enabled=True def restart(): sleep(2) diff --git a/proto97/init_db.py b/proto97/init_db.py index c8c81ac..d5488f8 100644 --- a/proto97/init_db.py +++ b/proto97/init_db.py @@ -14,13 +14,13 @@ def machine_id_rec_value(b): def init_db(machine_guid='e7260876-58db-4d27-8c40-8d13110d6a71'): stg=db.get_user_storage(name='StgWindsor') if stg == None: - print('Creating new user storage object') + print('Creating a new user storage object') db.new_user_storate() rc = db.get_storage_data() if rc == []: - print('Creating host machine GUID record') + print('Creating a host machine GUID record') stg=db.get_user_storage(name='StgWindsor') db.new_record(stg.dbid, 0x8, stg.dbid, machine_id_rec_value(machine_guid)) rc = db.get_storage_data() diff --git a/proto97/upload_fwext.py b/proto97/upload_fwext.py index 78ebfc0..b9daff0 100644 --- a/proto97/upload_fwext.py +++ b/proto97/upload_fwext.py @@ -25,9 +25,6 @@ def upload_fwext(): fwext=fwext[fwext.index(b'\x1a')+1:] fwext, signature = fwext[:-0x100], fwext[-0x100:] - # get fwext header info - rsp=tls.cmd(unhexlify('4302')) # should fail 'cause no fwext uploaded yet - fwi=get_fw_info(2) if fwi != None: raise Exception('FW is already present (version %d.%d (%s))' % (fwi.major, fwi.minor, ctime(fwi.buildtime))) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f5a5eab --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +fastecdsa==1.7.4 +pycrypto==2.6.1 +pyusb==1.0.2 +