add [worker 2] add new save mode: save all datas in same directory

pull/23/head
Terrtia 2019-03-19 14:10:43 +01:00
parent 3bc20df5da
commit e70904ab20
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
2 changed files with 13 additions and 10 deletions

View File

@ -187,9 +187,12 @@ class MetaTypesDefault:
data_directory_uuid_type = os.path.join('../../data', self.get_uuid(), str(TYPE)) data_directory_uuid_type = os.path.join('../../data', self.get_uuid(), str(TYPE))
return os.path.join(data_directory_uuid_type, self.get_last_saved_year(), self.get_last_saved_month(), self.get_last_saved_day() , self.type_name) return os.path.join(data_directory_uuid_type, self.get_last_saved_year(), self.get_last_saved_month(), self.get_last_saved_day() , self.type_name)
# # TODO: save global type dir ??? # data save in the same directory
if self.is_file_saved_on_disk(): else:
pass save_dir os.path.join('../../data/data', self.get_type_name())
if not os.path.isdir(save_dir):
os.makedirs(cert_save_dir)
return save_dir
def get_save_path(self): def get_save_path(self):
return self.save_path return self.save_path

View File

@ -16,28 +16,28 @@ 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)
self.set_rotate_file(True) self.set_rotate_file(False)
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):
self.set_last_time_saved(time.time()) self.set_last_time_saved(time.time())
self.set_last_saved_date(datetime.datetime.now().strftime("%Y%m%d%H%M%S")) self.set_last_saved_date(datetime.datetime.now().strftime("%Y%m%d%H%M%S"))
# Create folders # Create folders
cert_save_dir = os.path.join(self.get_save_dir(), 'certs') cert_save_dir = os.path.join(self.get_save_dir(), 'certs')
jsons_save_dir = os.path.join(self.get_save_dir(), 'jsons') jsons_save_dir = os.path.join(self.get_save_dir(), 'jsons')
if not os.path.exists(cert_save_dir): if not os.path.isdir(cert_save_dir):
os.makedirs(cert_save_dir) os.makedirs(cert_save_dir)
if not os.path.exists(jsons_save_dir): if not os.path.isdir(jsons_save_dir):
os.makedirs(jsons_save_dir) os.makedirs(jsons_save_dir)
# Extract certificates from json # Extract certificates from json
mtjson = json.loads(data.decode()) mtjson = json.loads(data.decode())
for certificate in mtjson["Certificates"] or []: for certificate in mtjson["Certificates"] or []:
cert = binascii.a2b_base64(certificate["Raw"]) cert = binascii.a2b_base64(certificate["Raw"])
# one could also load this cert with # one could also load this cert with
# xcert = x509.load_der_x509_certificate(cert, default_backend()) # xcert = x509.load_der_x509_certificate(cert, default_backend())
m = hashlib.sha256() m = hashlib.sha256()
m.update(cert) m.update(cert)
@ -52,4 +52,4 @@ class TypeHandler(MetaTypesDefault):
j.write(data.decode()) j.write(data.decode())
def test(self): def test(self):
print('Class: ja3-jl') print('Class: ja3-jl')