-
Notifications
You must be signed in to change notification settings - Fork 1
/
cros-fp.py
executable file
·56 lines (49 loc) · 1.55 KB
/
cros-fp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
import os
import sys
import subprocess
from urllib.request import urlopen, urlretrieve
from pathlib import Path
def ec_command(command):
result = subprocess.check_output(f"./ectool --name=cros_fp {command}", shell=True, text=True)
return result
def download_ectool():
if not Path("./ectool").exists():
urlretrieve(url="https://tree123.org/chrultrabook/utils/ectool", filename="./ectool")
os.system("chmod +x ./ectool")
def set_seed():
ec_command("fpseed aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
print("Seed set")
def enroll():
ec_command("fpmode reset")
ec_command("fpmode enroll")
print("Press your finger to the sensor")
ecmode = ""
while "(0x0)" not in ecmode:
ecmode = ec_command("fpmode")
#print(ecmode)
if "(0x10)" in ecmode:
print("Press your finger to the sensor")
ec_command("fpmode enroll")
print("Enrolled!")
def match():
ec_command("fpmode reset")
ec_command("fpmode match")
print("Press an enrolled finger to the sensor")
ecmode = ""
while "(0x0)" not in ecmode:
ecmode = ec_command("fpmode")
stats = ec_command("fpstats")
match = stats.split("\n")[2].split(" ")[6]
print(f"Fingerprint matched: {match[0]}")
return match
def dl_temp():
ec_command("fpmode reset")
temp = input("Which fingerprint would you like to download?: ")
os.system(f"./ectool --name=cros_fp fptemplate {temp}")
if __name__ == "__main__":
download_ectool()
set_seed()
enroll()
match()
dl_temp()