mirror of https://github.com/D4-project/d4-core
wip - write raw certs to disk
parent
bbb87418b9
commit
d8a1bfd74f
|
@ -5,6 +5,11 @@ import sys
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
import redis
|
import redis
|
||||||
|
import datetime
|
||||||
|
import hashlib
|
||||||
|
from cryptography import x509
|
||||||
|
from cryptography.hazmat.backends import default_backend
|
||||||
|
import pdb
|
||||||
|
|
||||||
from meta_types_modules.MetaTypesDefault import MetaTypesDefault
|
from meta_types_modules.MetaTypesDefault import MetaTypesDefault
|
||||||
|
|
||||||
|
@ -12,13 +17,26 @@ class TypeHandler(MetaTypesDefault):
|
||||||
|
|
||||||
def __init__(self, uuid, json_file):
|
def __init__(self, uuid, json_file):
|
||||||
super().__init__(uuid, json_file)
|
super().__init__(uuid, json_file)
|
||||||
print('init_spec')
|
self.set_rotate_file(True)
|
||||||
|
|
||||||
def process_data(self, data):
|
def process_data(self, data):
|
||||||
self.reconstruct_data(data)
|
self.reconstruct_data(data)
|
||||||
|
|
||||||
def handle_reconstructed_data(self, data):
|
def handle_reconstructed_data(self, data):
|
||||||
print(data)
|
self.set_last_time_saved(time.time())
|
||||||
|
self.set_last_saved_date(datetime.datetime.now().strftime("%Y%m%d%H%M%S"))
|
||||||
|
# update save path
|
||||||
|
cert_save_dir = os.path.join(self.get_save_dir(), 'certs')
|
||||||
|
# Extract certificates from json
|
||||||
|
mtjson = json.loads(data)
|
||||||
|
for certificate in mtjson["Certificates"]:
|
||||||
|
# cert = x509.load_der_x509_certificate(certificate["Raw"].encode(), default_backend())
|
||||||
|
m = hashlib.sha256()
|
||||||
|
m.update(certificate["Raw"].encode())
|
||||||
|
pdb.set_trace()
|
||||||
|
certpath = os.path.join(cert_save_dir, m.hexdigest()+'.crt')
|
||||||
|
with open(certpath, 'wb') as c:
|
||||||
|
c.write(cert)
|
||||||
|
|
||||||
def test(self):
|
def test(self):
|
||||||
print('Class: ja3-jl')
|
print('Class: ja3-jl')
|
||||||
|
|
Loading…
Reference in New Issue