#7GERA #ENISA #NIS2 #CCDCOE #UkraineRussiaWar :
$BTC /
$ETH import networkx as nx import matplotlib.pyplot as plt import random # Định nghĩa đồ thị kiến trúc an ninh def build_security_graph(): G = nx.Graph() # Đỉnh: Các Quốc gia/Khu vực (tập trung vào Châu Âu + Ukraine, không có Mỹ) nodes = [ 'Ukraine', 'Poland', 'Germany', 'France', 'UK', 'Estonia', 'Romania', 'Bulgaria', 'Sweden', 'Finland', 'Turkey', 'Switzerland' # Trung lập cho dữ liệu ] G.add_nodes_from(nodes) # Cạnh: Liên minh/Ưu tiên (địa chính trị, kinh tế, mạng, thông tin) # Trọng số: Sức mạnh (1-10, cao hơn = liên kết mạnh hơn) edges = [ ('Ukraine', 'Poland', {'weight': 9, 'type': 'địa chính trị/kinh tế'}), ('Ukraine', 'Germany', {'weight': 8, 'type': 'kinh tế/mạng'}), ('Ukraine', 'France', {'weight': 7, 'type': 'thông tin/sức mạnh mềm'}), ('Ukraine', 'UK', {'weight': 8, 'type': 'quân sự/tình báo'}), ('Ukraine', 'Estonia', {'weight': 6, 'type': 'mạng'}), ('Ukraine', 'Romania', {'weight': 7, 'type': 'địa chính trị/biển đen'}), ('Poland', 'Germany', {'weight': 9, 'type': 'kinh tế'}), ('Germany', 'France', {'weight': 10, 'type': 'cốt lõi EU'}), ('France', 'UK', {'weight': 7, 'type': 'sau Brexit'}), ('Estonia', 'Sweden', {'weight': 8, 'type': 'mạng nordic'}), ('Sweden', 'Finland', {'weight': 9, 'type': 'nordic'}), ('Romania', 'Bulgaria', {'weight': 6, 'type': 'biển đen'}), ('Ukraine', 'Turkey', {'weight': 5, 'type': 'quân sự/drone'}), ('Switzerland', 'Germany', {'weight': 6, 'type': 'bảo vệ dữ liệu'}), ('Switzerland', 'Ukraine', {'weight': 4, 'type': 'trung tâm dữ liệu trung lập'}) ] G.add_edges_from(edges) return G # Mô phỏng sự lan truyền mối đe dọa hỗn hợp (ví dụ: tấn công mạng bắt đầu từ nút bên ngoài) def simulate_threat(G, start_node='External_Threat', target='Ukraine', steps=5): # Thêm nút mối đe dọa bên ngoài G.add_node(start_node) # Kết nối mối đe dọa với các cạnh dễ bị tổn thương (ví dụ: đến các nút đối mặt với Nga) G.add_edge(start_node, 'Ukraine', {'weight': 1, 'type': 'hỗn hợp'}) G.add_edge(start_node, 'Estonia', {'weight': 1, 'type': 'mạng'}) G.add_edge(start_node, 'Romania', {'weight': 1, 'type': 'thông tin'}) # Lan truyền đơn giản: Đi bộ ngẫu nhiên với kiểm tra độ bền current = start_node path = [current] resilience_scores = {node: random.uniform(0.7, 1.0) for node in G.nodes()} # Độ bền cao trong mạng for _ in range(steps): neighbors = list(G.neighbors(current)) if not neighbors: break next_node = random.choice(neighbors) edge_weight = G[current][next_node]['weight'] # Độ bền làm giảm sự lan truyền if random.random() > (edge_weight / 10) * resilience_scores[next_node]: print(f"Mối đe dọa bị chặn tại {next_node} do độ bền.") break current = next_node path.append(current) return path, resilience_scores[target] # Hiển thị đồ thị def visualize_graph(G): pos = nx.spring_layout(G) edge_labels = nx.get_edge_attributes(G, 'type') nx.draw(G, pos, with_labels=True, node_color='lightblue', node_size=500) nx.draw_networkx_edge_labels(G, pos, edge_labels=edge_labels) plt.title("Đồ thị Kiến trúc An ninh Châu Âu-Ukraine") plt.show() # Hoặc lưu dưới dạng hình ảnh: plt.savefig('security_arch.png') # Thực thi chính if __name__ == "__main__": G = build_security_graph() threat_path, ukraine_resilience = simulate_threat(G, steps=10) print(f"Đường đi Mối đe dọa Mô phỏng: {threat_path}") print(f"Điểm Độ bền của Ukraine: {ukraine_resilience:.2f}") visualize_graph(G) # Bình luận nếu không hiển thị; lưu thay vào đó cho hình ảnh