I have a dictionary in Python, that describes some kinds of binaries running on various hosts. Some of them are connected each to other. The question is – how can I construct chains from them? If input and output are the same, then binaries are connected.
For example:
{"binary1": "bin1", "input": "127.0.0.1:2222", "output": "127.0.0.2:3333", "other_stuff": "....1111..."}
{"binary2": "bin2", "input": "127.0.0.2:3333", "output": "", "other_stuff": "....2222..."}
{"binary3": "bin3", "input": "128.0.0.1:5555", "output": "127.0.0.2:7777", "other_stuff": "....3333..."}
{"binary4": "bin4", "input": "127.0.0.2:8888", "output": "127.0.0.2:4444", "other_stuff": "....4444..."}
{"binary5": "bin5", "input": "127.0.0.1:9999", "output": "127.0.0.2:8888", "other_stuff": "....5555..."}
{"binary6": "bin6", "input": "127.0.0.5:1111", "output": "127.0.0.9:1234", "other_stuff": "....6666..."}
{"binary7": "bin7", "input": "", "output": "127.0.0.1:9999", "other_stuff": "....7777..."}
{"binary8": "bin8", "input": "127.0.0.1:2222", "output": "127.0.0.2:3333", "other_stuff": "....8888..."}
{"binary9": "bin9", "input": "", "output": "127.0.0.5:1111", "other_stuff": "....9999..."}
{"binary0": "bin0", "input": "", "output": "", "other_stuff": "....0000..."}
expected output:
bin1 -> bin2
bin7 -> bin5 -> bin4
bin9 -> bin6
Inputs and outputs are not necessary for each binary.
Finally I will need to make list of chains and to draw them, but it’s a bonus 🙂 Does exist some python module that will help to extract sequences and do it fast enough? (Data size is about 10 thousands of binaries).
Thanks in advance!
P.S. Actually I need links to python modules that will help me to solve it (not algorithm), that’s all
Writing custom code to do what you ask would be quite simple, but since you specified you want “links to python modules”, then my suggestion would be to look into python-graphs. From the look of it, your problem seems equivalent to build directed graphs…
EDIT: This also answers your bonus question about plotting the drawing. See this example.