mirror of
https://github.com/adulau/MalwareClassifier.git
synced 2024-12-22 08:46:04 +00:00
Generate graph relationship from Redis database
Output format is gexf
This commit is contained in:
parent
56a42333fa
commit
b27e7a4a74
1 changed files with 24 additions and 0 deletions
24
bin/graph.py
Normal file
24
bin/graph.py
Normal file
|
@ -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")
|
Loading…
Reference in a new issue