From 0816a93efe73e9b92171e4060a05544b251172ff Mon Sep 17 00:00:00 2001 From: Terrtia Date: Wed, 24 Apr 2019 10:21:03 +0200 Subject: [PATCH] chg: [worker2 ja3] add debug --- .../meta_types_modules/ja3-jl/ja3-jl.py | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/server/workers/workers_2/meta_types_modules/ja3-jl/ja3-jl.py b/server/workers/workers_2/meta_types_modules/ja3-jl/ja3-jl.py index 0048ee7..12089e2 100755 --- a/server/workers/workers_2/meta_types_modules/ja3-jl/ja3-jl.py +++ b/server/workers/workers_2/meta_types_modules/ja3-jl/ja3-jl.py @@ -38,27 +38,29 @@ class TypeHandler(MetaTypesDefault): # Extract certificates from json try: mtjson = json.loads(decoded_data) + res = True except Exception as e: print(decoded_data) - continue - #mtjson = json.loads(decoded_data) - for certificate in mtjson["Certificates"] or []: - cert = binascii.a2b_base64(certificate["Raw"]) - # one could also load this cert with - # xcert = x509.load_der_x509_certificate(cert, default_backend()) - m = hashlib.sha1() - m.update(cert) - cert_path = os.path.join(cert_save_dir, m.hexdigest()+'.crt') - # write unique certificate der file to disk - with open(cert_path, 'w+b') as c: - c.write(cert) + res = False + if res: + #mtjson = json.loads(decoded_data) + for certificate in mtjson["Certificates"] or []: + cert = binascii.a2b_base64(certificate["Raw"]) + # one could also load this cert with + # xcert = x509.load_der_x509_certificate(cert, default_backend()) + m = hashlib.sha1() + m.update(cert) + cert_path = os.path.join(cert_save_dir, m.hexdigest()+'.crt') + # write unique certificate der file to disk + with open(cert_path, 'w+b') as c: + c.write(cert) - # write json file to disk - jsons_path = os.path.join(jsons_save_dir, mtjson["Timestamp"]+'.json') - with open(jsons_path, 'w') as j: - j.write(decoded_data) - # Send data to Analyszer - self.send_to_analyzers(jsons_path) + # write json file to disk + jsons_path = os.path.join(jsons_save_dir, mtjson["Timestamp"]+'.json') + with open(jsons_path, 'w') as j: + j.write(decoded_data) + # Send data to Analyszer + self.send_to_analyzers(jsons_path) def test(self):