From b27e7a4a747b1c5b372ecf43a472c26418b40e62 Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Sat, 10 Jan 2015 19:34:59 +0100 Subject: [PATCH] Generate graph relationship from Redis database Output format is gexf --- bin/graph.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 bin/graph.py diff --git a/bin/graph.py b/bin/graph.py new file mode 100644 index 0000000..55d2b27 --- /dev/null +++ b/bin/graph.py @@ -0,0 +1,24 @@ +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")