This commit is contained in:
caschick221 2024-05-02 14:37:00 -04:00
parent e512edcde5
commit 0d7fad8a15

View File

@ -33,6 +33,8 @@ On Windows, the native WebAuthn API will be used.
""" """
import time import time
import pickle
import fido2.webauthn import fido2.webauthn
from fido2.hid import CtapHidDevice from fido2.hid import CtapHidDevice
from fido2.client import Fido2Client, WindowsClient, UserInteraction from fido2.client import Fido2Client, WindowsClient, UserInteraction
@ -132,6 +134,7 @@ while True:
pk__1 = auth_data.credential_data.public_key.get(-1) pk__1 = auth_data.credential_data.public_key.get(-1)
pk__2 = auth_data.credential_data.public_key.get(-2) pk__2 = auth_data.credential_data.public_key.get(-2)
pk__3 = auth_data.credential_data.public_key.get(-3) pk__3 = auth_data.credential_data.public_key.get(-3)
pickled = pickle.dumps(credentials)
import psycopg2 import psycopg2
@ -152,12 +155,12 @@ while True:
cur = conn.cursor() cur = conn.cursor()
# Define the SQL query for inserting data # Define the SQL query for inserting data
insert_query = ''' insert_query = '''
INSERT INTO credential_data ("AAGUID", "credential_id", "pk_algo", "pk_1", "pk_3", "pk_neg1", "pk_neg2", "pk_neg3") INSERT INTO credential_data ("AAGUID", "credential_id", "pk_algo", "pk_1", "pk_3", "pk_neg1", "pk_neg2", "pk_neg3", "pickled")
VALUES (%s, %s, %s, %s, %s, %s, %s, %s); VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s);
''' '''
# Execute the SQL query # Execute the SQL query
cur.execute(insert_query, (aaguid, cred_id, pk_algo, pk_1, pk_3, pk__1, pk__2, pk__3)) cur.execute(insert_query, (aaguid, cred_id, pk_algo, pk_1, pk_3, pk__1, pk__2, pk__3, pickled))
# Commit the changes # Commit the changes
conn.commit() conn.commit()
@ -192,6 +195,7 @@ while True:
print("CREDENTIAL DATA:", auth_data.credential_data) print("CREDENTIAL DATA:", auth_data.credential_data)
else: else:
try:
server = Fido2Server({"id": "example.com", "name": "Example RP"}, attestation="direct") server = Fido2Server({"id": "example.com", "name": "Example RP"}, attestation="direct")
uv = "discouraged" uv = "discouraged"
@ -208,7 +212,7 @@ while True:
# Define the SQL query for retrieving data # Define the SQL query for retrieving data
select_query = ''' select_query = '''
SELECT "AAGUID", credential_id, pk_algo, pk_1, pk_3, pk_neg1, pk_neg2, pk_neg3 SELECT "AAGUID", credential_id, pk_algo, pk_1, pk_3, pk_neg1, pk_neg2, pk_neg3, pickled
FROM credential_data FROM credential_data
WHERE "AAGUID" = %s; WHERE "AAGUID" = %s;
''' '''
@ -236,7 +240,8 @@ while True:
"pk_3": result[4], "pk_3": result[4],
"pk_neg1": result[5], "pk_neg1": result[5],
"pk_neg2": result[6], "pk_neg2": result[6],
"pk_neg3": result[7] "pk_neg3": result[7],
"pickled": result[8]
} }
return data return data
else: else:
@ -265,17 +270,10 @@ while True:
pk_neg1 = aaguid_data["pk_neg1"] pk_neg1 = aaguid_data["pk_neg1"]
pk_neg2 = aaguid_data["pk_neg2"] pk_neg2 = aaguid_data["pk_neg2"]
pk_neg3 = aaguid_data["pk_neg3"] pk_neg3 = aaguid_data["pk_neg3"]
auth_data = fido2.webauthn.AttestedCredentialData(testa, cred_id, pk_algo) pickled = aaguid_data["pickled"]
# auth_data.aaguid = AAGUID
# auth_data.credential_id = cred_id
# auth_data.public_key.ALGORITHM= pk_algo
# auth_data.public_key.setdefault(1, pk_1)
# auth_data.public_key.setdefault(3, pk_3)
# auth_data.public_key.setdefault(-1, pk__1)
# auth_data.public_key.setdefault(-2, pk__2)
# auth_data.public_key.setdefault(-3,pk__3)
credentials = [auth_data]
credentials = pickle.loads(pickled)
# Prepare parameters for getAssertion # Prepare parameters for getAssertion
@ -303,3 +301,5 @@ while True:
print("CLIENT DATA:", result.client_data) print("CLIENT DATA:", result.client_data)
print() print()
print("AUTH DATA:", result.authenticator_data) print("AUTH DATA:", result.authenticator_data)
except Exception as e:
pass