From c6bee193ceb1c5b215a37c9fca96369e19ba58dd Mon Sep 17 00:00:00 2001 From: Tim Young Date: Sat, 26 Aug 2017 14:56:50 -0500 Subject: [PATCH] track additional information so we can tell which nic to break, which route to break, etc --- EduNetworkBuilder/NB.cs | 2 +- EduNetworkBuilder/Network.cs | 12 ++++++++++++ EduNetworkBuilder/NetworkDevice.cs | 12 ++++++------ EduNetworkBuilder/NetworkInterface.cs | 5 +++-- EduNetworkBuilder/TraversalClass.cs | 8 +++++--- 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/EduNetworkBuilder/NB.cs b/EduNetworkBuilder/NB.cs index 6ccd272..8a540f9 100644 --- a/EduNetworkBuilder/NB.cs +++ b/EduNetworkBuilder/NB.cs @@ -90,7 +90,7 @@ namespace EduNetworkBuilder packet_in=4, packet_out=8, packet_duplicate=16, all=63, dump=256, pause=512} public enum TraversalTechnology { any, none, gateway, static_route, vlan, ethernet, wireless, firewall, - vpn, vpn_encryption, vpn_decryption, ip_address, masquerade, forward, arrived} + vpn, vpn_encryption, vpn_decryption, ip_address, masquerade, forward, arrived, network_interface} public enum HowToBreak { PowerOff, EthernetBreak, EthernetCorrupt, LockOutSwitch, WirelessBreakSSID, WirelessBreakKey, DeviceChangeIP, DeviceChangeGW, StaticRouteClear, StaticRouteCorrupt, VLANChange, VPNChangeEndpoint, VPNChangeKey} diff --git a/EduNetworkBuilder/Network.cs b/EduNetworkBuilder/Network.cs index 2e923cd..fc8a0bb 100644 --- a/EduNetworkBuilder/Network.cs +++ b/EduNetworkBuilder/Network.cs @@ -1919,35 +1919,47 @@ namespace EduNetworkBuilder switch(How) { case HowToBreak.PowerOff: + //power the device off tDevice.PowerOff = true; didit = 1; break; case HowToBreak.DeviceChangeGW: + //Change the IP of the gateway break; case HowToBreak.DeviceChangeIP: + //Change the IP on the outbound nic break; case HowToBreak.EthernetBreak: + //break the link itself tLink.theLinkType = LinkType.broken; didit = 1; break; case HowToBreak.EthernetCorrupt: + //Add a flourescent light break; case HowToBreak.LockOutSwitch: //Lock it out break; case HowToBreak.StaticRouteClear: + //Clear out the static route(s) break; case HowToBreak.StaticRouteCorrupt: + //corrupt the static route(s) break; case HowToBreak.VLANChange: + //Change the vlan on the port we use. break; case HowToBreak.VPNChangeEndpoint: + //Change the ip-address on the VPN endpoint break; case HowToBreak.VPNChangeKey: + //change the key for the VPN encryption break; case HowToBreak.WirelessBreakKey: + //Change the wireless key break; case HowToBreak.WirelessBreakSSID: + //change the wireless ssid - have small list of bad keys to choose from break; } return didit; diff --git a/EduNetworkBuilder/NetworkDevice.cs b/EduNetworkBuilder/NetworkDevice.cs index 7e53498..04644f1 100644 --- a/EduNetworkBuilder/NetworkDevice.cs +++ b/EduNetworkBuilder/NetworkDevice.cs @@ -1504,7 +1504,7 @@ namespace EduNetworkBuilder tPacket.MyStatus = PacketStatus.finished_failed; return; } - tPacket.TraversalInformation.AddPath(this.hostname, TraversalTechnology.ip_address); //We will use an outbound ip. + tPacket.TraversalInformation.AddPath(this.hostname, TraversalTechnology.ip_address,""); //We will use an outbound ip. if (dest.GetIP == tPacket.destIP.GetIP) { //It is a local packet. Let it go out the interface it needs to go out @@ -1515,7 +1515,7 @@ namespace EduNetworkBuilder { //it needs to go to a gateway. Set the next destination is the GW tPacket.OutboundIP = dest; - tPacket.TraversalInformation.AddPath(this.hostname, TraversalTechnology.gateway); //We just used a gateway + tPacket.TraversalInformation.AddPath(this.hostname, TraversalTechnology.gateway,""); //We just used a gateway tPacket.TsourceIP = null; } else @@ -1636,7 +1636,7 @@ namespace EduNetworkBuilder //But if we do not know a dnic, send it out all of them (except the sNic) if (sNic != nic && (tdNic == null || (tdNic != null && tdNic.ConnectedLink == -1) || tdNic == nic)) { - tPacket.TraversalInformation.AddPath(hostname, TraversalTechnology.forward); + tPacket.TraversalInformation.AddPath(hostname, TraversalTechnology.forward,""); if (nic.SendPacketOutNIC(tPacket)) { count++; @@ -1778,7 +1778,7 @@ namespace EduNetworkBuilder } } } - tPacket.TraversalInformation.AddPath(hostname, TraversalTechnology.arrived); + tPacket.TraversalInformation.AddPath(hostname, TraversalTechnology.arrived,""); nPacket = new Packet(this, tPacket.sourceIP, "", PacketType.ping_answer, tPacket.packetID); nPacket.OriginalDestIP = tPacket.destIP; nPacket.isFresh = true; //So it starts from here @@ -1847,7 +1847,7 @@ namespace EduNetworkBuilder } else { - tPacket.TraversalInformation.AddPath(hostname, TraversalTechnology.arrived); + tPacket.TraversalInformation.AddPath(hostname, TraversalTechnology.arrived,""); tPacket.AddMessage(DebugLevel.info, NB.Translate("ND_ProcessArrival_PingReturn1")); tPacket.Tracking.Status = NB.LeftPad(hostname) + " " + string.Format(NB.Translate("ND_ProssArrSuccessStr"), tPacket.sourceIP.GetIP.ToIpString(), tPacket.destIP.GetIP.ToIpString()); tPacket.MyStatus = PacketStatus.finished_ok; @@ -1882,7 +1882,7 @@ namespace EduNetworkBuilder //Console.WriteLine("Tracert: " + tPacket.OrigTTL + " " + tPacket.sourceIP.GetIPString); //Console.WriteLine("Tracert: -- " + tPacket.sourceIP.GetIPString + " " + origStart.GetIPString); //If we had not landed on the actual dest... - tPacket.TraversalInformation.AddPath(hostname, TraversalTechnology.arrived); + tPacket.TraversalInformation.AddPath(hostname, TraversalTechnology.arrived,""); tracertmessages.Add(NB.Translate("ND_ProcessArrival_TracertReply") + " " + tPacket.sourceIP.GetIPString); diff --git a/EduNetworkBuilder/NetworkInterface.cs b/EduNetworkBuilder/NetworkInterface.cs index b043735..97128a0 100644 --- a/EduNetworkBuilder/NetworkInterface.cs +++ b/EduNetworkBuilder/NetworkInterface.cs @@ -206,6 +206,7 @@ namespace EduNetworkBuilder string hostname = HD.hostname; //added to fix the issue with vpns and pings - 11-09-2016 //Only do this on non-ports? + tPacket.TraversalInformation.AddPath(hostname, TraversalTechnology.network_interface, nic_name); NetworkCard nic = HD.NicFromID(AttachedToHostNic); if(nic != null && nic.GetNicType != NicType.port && nic.GetNicType != NicType.wport) tPacket.TsourceIP = myIP; @@ -334,8 +335,8 @@ namespace EduNetworkBuilder NetworkDevice ND = MyNet.GetDeviceFromID(AttachedToHostNic); tPacket.InboundInterface = this; - - if(isgood) + tPacket.TraversalInformation.AddPath(ND.hostname, TraversalTechnology.network_interface, nic_name); + if (isgood) { //anything we should do here? //Mainly vlan if we are a vlan. diff --git a/EduNetworkBuilder/TraversalClass.cs b/EduNetworkBuilder/TraversalClass.cs index 824db6a..292a7eb 100644 --- a/EduNetworkBuilder/TraversalClass.cs +++ b/EduNetworkBuilder/TraversalClass.cs @@ -12,11 +12,13 @@ namespace EduNetworkBuilder { public string host; public TraversalTechnology WhatUsed; + public string AdditionalData; - public TraversalRecord(string Host, TraversalTechnology what) + public TraversalRecord(string Host, TraversalTechnology what, string Data) { host = Host; WhatUsed = what; + AdditionalData = Data; } } @@ -41,9 +43,9 @@ namespace EduNetworkBuilder dest.PathTaken.AddRange(source.PathTaken); } - public void AddPath(string Host, TraversalTechnology WithWhat) + public void AddPath(string Host, TraversalTechnology WithWhat, string Data) { - PathTaken.Add(new TraversalRecord(Host, WithWhat)); + PathTaken.Add(new TraversalRecord(Host, WithWhat, Data)); } public void AddPath(TraversalClass OtherTraversal) {