@@ -2149,6 +2149,55 @@ def delete_cache_value(self, key, category=""):
21492149 def get_datastore_value (self , key , category = "" ):
21502150 return self .get_cache_value (key , category = category )
21512151
2152+ def get_ioc (self , ioc , data_type = "" ):
2153+ if len (data_type ) == 0 :
2154+ ioc_types = ["domains" , "urls" , "email_addresses" , "ipv4s" , "ipv6s" , "ipv4_cidrs" , "md5s" , "sha256s" , "sha1s" , "cves" ]
2155+
2156+ iocs = find_iocs (str (input_string ))
2157+ for key , value in iocs .items ():
2158+ for item in value :
2159+ if item .lower () == ioc .lower ():
2160+ print ("[DEBUG] Found IOC %s in type %s" % (ioc , key ))
2161+ data_type = key [:- 1 ]
2162+ break
2163+
2164+ if len (data_type ) > 0 :
2165+ break
2166+
2167+ org_id = self .full_execution ["workflow" ]["execution_org" ]["id" ]
2168+ url = "%s/api/v1/orgs/%s/get_cache" % (self .url , org_id )
2169+ data = {
2170+ "workflow_id" : self .full_execution ["workflow" ]["id" ],
2171+ "execution_id" : self .current_execution_id ,
2172+ "authorization" : self .authorization ,
2173+ "org_id" : org_id ,
2174+ "key" : str (key ),
2175+ "category" : "ioc_%s" % data_type .replace (" " , "_" ).lower (),
2176+ }
2177+
2178+ value = requests .post (url , json = data , verify = False )
2179+ try :
2180+ allvalues = value .json ()
2181+ allvalues ["key" ] = key
2182+
2183+ if allvalues ["success" ] == True and len (allvalues ["value" ]) > 0 :
2184+ allvalues ["found" ] = True
2185+ else :
2186+ allvalues ["success" ] = True
2187+ allvalues ["found" ] = False
2188+
2189+ try :
2190+ parsedvalue = json .loads (allvalues ["value" ])
2191+ allvalues ["value" ] = parsedvalue
2192+
2193+ except :
2194+ pass
2195+
2196+ return json .dumps (allvalues )
2197+ except :
2198+ self .logger .info ("Value couldn't be parsed, or json dump of value failed" )
2199+ return value .text
2200+
21522201 def get_cache_value (self , key , category = "" ):
21532202 org_id = self .full_execution ["workflow" ]["execution_org" ]["id" ]
21542203 url = "%s/api/v1/orgs/%s/get_cache" % (self .url , org_id )
@@ -2848,7 +2897,6 @@ def parse_ioc(self, input_string, input_type="all"):
28482897 print ("Invalid key: %s" % key )
28492898 continue
28502899
2851- print (key , value )
28522900 if len (value ) == 0 :
28532901 continue
28542902
0 commit comments