MalwareClassifier/bin/graph.py
2015-01-10 19:34:59 +01:00

24 lines
543 B
Python

import redis
import networkx as nx
import hashlib
r = redis.StrictRedis(host='localhost', port=6379, db=0)
g = nx.Graph()
for malware in r.smembers('processed'):
g.add_node(malware)
for fieldtype in r.smembers('type'):
g.add_node(fieldtype)
for v in r.smembers('e:'+fieldtype.decode('utf-8')):
g.add_node(v)
ehash = hashlib.md5()
ehash.update(v)
ehhex = ehash.hexdigest()
for m in r.smembers('v:'+ehhex):
print (m)
g.add_edge(v,m)
nx.write_gexf(g,"graph.gexf")