MCPcopy
hub / github.com/srixivas/PcapXray / __init__

Method __init__

Source/Module/plot_lan_network.py:31–75  ·  view source on GitHub ↗
(self, filename, path, option="Tor", to_ip="All", from_ip="All")

Source from the content-addressed store, hash-verified

29class PlotLan:
30
31 def __init__(self, filename, path, option="Tor", to_ip="All", from_ip="All"):
32 log.info("plotLan init: option=%s to=%s from=%s", option, to_ip, from_ip)
33 self.directory = os.path.join(path, "Report")
34 if not os.path.exists(self.directory):
35 os.makedirs(self.directory)
36 options = option + "_" + to_ip.replace(".", "-") + "_" + from_ip.replace(".", "-")
37 self.filename = os.path.join(self.directory, filename+"_"+options)
38
39 self.styles = {
40 'graph': {
41 'label': 'PcapGraph',
42 'fontsize': '16',
43 'fontcolor': 'black',
44 'bgcolor': 'grey',
45 'rankdir': 'LR',
46 'dpi': '150',
47 # No size/ratio/overlap — graphviz chooses natural layout dimensions.
48 # PIL fits the result to the canvas preserving aspect ratio.
49 },
50 'nodes': {
51 'fontname': 'DejaVu Sans',
52 'fontsize': '14',
53 'shape': 'ellipse',
54 'fontcolor': 'black',
55 'color': 'black',
56 'style': 'filled',
57 'fillcolor': 'yellow',
58 # No fixedsize — nodes auto-size to fit their label text.
59 }
60 }
61
62 self.sessions = list(memory.packet_db.keys())
63 log.info("plotLan: %d sessions in packet_db", len(self.sessions))
64 #device_details_fetch.fetchDeviceDetails("ieee").fetch_info()
65 if option == "Malicious" or option == "All":
66 log.info("Running malicious traffic identification")
67 self.mal_identify = malicious_traffic_identifier.MaliciousTrafficIdentifier()
68 log.info("Malicious traffic identification done")
69 if option == "Tor" or option == "All":
70 log.info("Running Tor traffic detection")
71 self.tor_identify = tor_traffic_handle.TorTrafficHandle().tor_traffic_detection()
72 log.info("Tor traffic detection done")
73 log.info("Calling draw_graph")
74 self.draw_graph(option, to_ip, from_ip)
75 log.info("draw_graph complete")
76
77 def apply_styles(self, graph, styles):
78 graph.graph_attr.update(

Callers

nothing calls this directly

Calls 2

draw_graphMethod · 0.95
tor_traffic_detectionMethod · 0.80

Tested by

no test coverage detected