11#!/usr/bin/env python3
22# encoding: utf-8
3- import json
3+ import json , re
44import requests
55import urllib
66import hashlib
@@ -102,7 +102,7 @@ def otx_query_file(self, data):
102102
103103 if ip_ ['analysis' ]['analysis' ]:
104104 # file has been analyzed before
105- self . report ( {
105+ result = {
106106 'pulse_count' : ip_ .get ('general' , {}).get ('pulse_info' , {}).get ('count' , "0" ),
107107 'pulses' : ip_ .get ('general' , {}).get ('pulse_info' , {}).get ('pulses' , "-" ),
108108 'malware' : ip_ .get ('analysis' , {}).get ('malware' , "-" ),
@@ -120,8 +120,22 @@ def otx_query_file(self, data):
120120 'filesize' : ip_ .get ('analysis' , {}).get ('analysis' , {}).get ('info' , {}).get ('results' , {}).get (
121121 'filesize' , "-" ),
122122 'ssdeep' : ip_ .get ('analysis' , {}).get ('analysis' , {}).get ('info' , {}).get ('results' , {}).get (
123- 'ssdeep' )
124- })
123+ 'ssdeep' ),
124+ 'combined_score' : ip_ .get ('analysis' , {}).get ('analysis' , {}).get ('plugins' , {}).get ('cuckoo' , {}).get (
125+ 'result' , {}).get ('info' , {}).get ('combined_score' )
126+ }
127+ alert_val = ip_ .get ('analysis' , {}).get ('analysis' , {}).get ('plugins' , {}).get ('cuckoo' , {}).get (
128+ 'result' , {}).get ('signatures' )
129+ if alert_val is not None and len (alert_val ) > 0 :
130+ result ['alerts' ] = alert_val
131+
132+ ids_detections_val = ip_ .get ('analysis' , {}).get ('analysis' , {}).get ('plugins' , {}).get ('cuckoo' , {}).get (
133+ 'result' , {}).get ('suricata' , {}).get ('rules' )
134+ if ids_detections_val is not None and len (ids_detections_val ) > 0 :
135+ result ['ids_detections' ] = ids_detections_val
136+
137+ self .report (result )
138+
125139 else :
126140 # file has not been analyzed before
127141 self .report ({
@@ -159,8 +173,27 @@ def summary(self, raw):
159173 level = "info"
160174 namespace = "OTX"
161175 predicate = "Pulses"
176+ pulses = dict ()
162177 value = "{}" .format (raw ["pulse_count" ])
163- taxonomies .append (self .build_taxonomy (level , namespace , predicate , value ))
178+ pulses = raw .get ("pulses" , 0 )
179+ malicious_count = 0
180+
181+ if "combined_score" in raw :
182+ combined_score = raw ['combined_score' ]
183+ if (combined_score < 3 ):
184+ level = "safe"
185+ elif (combined_score < 7 ):
186+ level = "suspicious"
187+ elif (combined_score >= 7 ):
188+ level = "malicious"
189+ taxonomies .append (self .build_taxonomy (level , namespace , predicate , value ))
190+ else :
191+ for pulse in pulses :
192+ for tag in pulse ["tags" ]:
193+ if re .match (r"Malicious" , tag , re .IGNORECASE ) is not None :
194+ malicious_count += 1
195+ value = "Number of pulses: " + value + ", Pulses that have a malicious tag: " + str (malicious_count )
196+ taxonomies .append (self .build_taxonomy (level , namespace , predicate , value ))
164197
165198 return {"taxonomies" : taxonomies }
166199
0 commit comments