make changes to IP and gateway
This commit is contained in:
parent
31e07852cf
commit
465de0f6b0
@ -1181,7 +1181,7 @@ namespace EduNetworkBuilder
|
|||||||
case HowToBreak.DeviceChangeGW:
|
case HowToBreak.DeviceChangeGW:
|
||||||
return TraversalTechnology.gateway;
|
return TraversalTechnology.gateway;
|
||||||
case HowToBreak.DeviceChangeIP:
|
case HowToBreak.DeviceChangeIP:
|
||||||
return TraversalTechnology.ip_address;
|
return TraversalTechnology.network_interface;
|
||||||
case HowToBreak.EthernetBreak:
|
case HowToBreak.EthernetBreak:
|
||||||
case HowToBreak.EthernetCorrupt:
|
case HowToBreak.EthernetCorrupt:
|
||||||
return TraversalTechnology.ethernet;
|
return TraversalTechnology.ethernet;
|
||||||
|
@ -1949,9 +1949,13 @@ namespace EduNetworkBuilder
|
|||||||
break;
|
break;
|
||||||
case HowToBreak.DeviceChangeGW:
|
case HowToBreak.DeviceChangeGW:
|
||||||
//Change the IP of the gateway
|
//Change the IP of the gateway
|
||||||
|
if (tDevice.BreakGateway())
|
||||||
|
didit = 2;
|
||||||
break;
|
break;
|
||||||
case HowToBreak.DeviceChangeIP:
|
case HowToBreak.DeviceChangeIP:
|
||||||
//Change the IP on the outbound nic
|
//Change the IP on the outbound nic
|
||||||
|
if (tDevice.BreakIPAddress(Data))
|
||||||
|
didit = 2;
|
||||||
break;
|
break;
|
||||||
case HowToBreak.EthernetBreak:
|
case HowToBreak.EthernetBreak:
|
||||||
//break the link itself
|
//break the link itself
|
||||||
@ -1994,6 +1998,8 @@ namespace EduNetworkBuilder
|
|||||||
didit = 2;
|
didit = 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (didit > 0) Console.WriteLine("Broke it:" + What.hostname + " : " + How + " : " + Data);
|
||||||
|
if (didit == 0) Console.WriteLine("Did not break it:" + What.hostname + " : " + How + " : " + Data);
|
||||||
return didit;
|
return didit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2171,7 +2171,8 @@ namespace EduNetworkBuilder
|
|||||||
TraversalCollection.Sort((a, b) => b.Count.CompareTo(a.Count));
|
TraversalCollection.Sort((a, b) => b.Count.CompareTo(a.Count));
|
||||||
|
|
||||||
List<HowToBreak> BreakList = new List<HowToBreak>() { HowToBreak.PowerOff, HowToBreak.EthernetBreak,
|
List<HowToBreak> BreakList = new List<HowToBreak>() { HowToBreak.PowerOff, HowToBreak.EthernetBreak,
|
||||||
HowToBreak.LockOutSwitch, HowToBreak.WirelessBreakKey, HowToBreak.WirelessBreakSSID, HowToBreak.VPNChangeKey };
|
HowToBreak.LockOutSwitch, HowToBreak.WirelessBreakKey, HowToBreak.WirelessBreakSSID, HowToBreak.VPNChangeKey,
|
||||||
|
HowToBreak.DeviceChangeIP, HowToBreak.DeviceChangeGW};
|
||||||
//foreach (HowToBreak one in Enum.GetValues(typeof(HowToBreak)))
|
//foreach (HowToBreak one in Enum.GetValues(typeof(HowToBreak)))
|
||||||
// BreakList.Add(one);
|
// BreakList.Add(one);
|
||||||
count = 0;
|
count = 0;
|
||||||
@ -2189,12 +2190,12 @@ namespace EduNetworkBuilder
|
|||||||
TraversalIndex = 0; //loop back to the beginning
|
TraversalIndex = 0; //loop back to the beginning
|
||||||
}
|
}
|
||||||
|
|
||||||
//for(int i=0; i< TraversalCollection.Count; i++)
|
//for (int i = 0; i < TraversalCollection.Count; i++)
|
||||||
//{
|
//{
|
||||||
// Console.WriteLine(i + " " + TraversalCollection[i].Source());
|
// Console.WriteLine(i + " " + TraversalCollection[i].Source());
|
||||||
// Console.WriteLine(i + " " + TraversalCollection[i].Destination());
|
// Console.WriteLine(i + " " + TraversalCollection[i].Destination());
|
||||||
//}
|
//}
|
||||||
//if(TraversalCollection.Count>0)
|
//if (TraversalCollection.Count > 0)
|
||||||
//{
|
//{
|
||||||
// TraversalCollection[0].DumpPath();
|
// TraversalCollection[0].DumpPath();
|
||||||
//}
|
//}
|
||||||
|
@ -3111,6 +3111,78 @@ namespace EduNetworkBuilder
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool BreakIPAddress(string nicname)
|
||||||
|
{
|
||||||
|
NetworkCard nic = NicFromName(nicname);
|
||||||
|
if (nic == null) return false;
|
||||||
|
NetworkInterface nif = nic.InterfaceFromName(nicname);
|
||||||
|
if (nif == null) return false;
|
||||||
|
IPAddress newaddress = new IPAddress("0.0.0.0");
|
||||||
|
Random rnd = NB.GetRandom();
|
||||||
|
|
||||||
|
switch(rnd.Next(8))
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
newaddress = nif.myIP.BreakIPAddress32();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
newaddress = nif.myIP.BreakIPAddressMangle();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
newaddress = nif.myIP.BreakIPAddressRandom();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
newaddress = nif.myIP.BreakIPAddressZero();
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
newaddress = nif.myIP.BreakIPNetmask32();
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
newaddress = nif.myIP.BreakIPNetmaskMangle();
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
newaddress = nif.myIP.BreakIPNetmaskRandom();
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
newaddress = nif.myIP.BreakIPNetmaskZero();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(nif.myIP != newaddress)
|
||||||
|
{
|
||||||
|
nif.myIP = newaddress;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool BreakGateway()
|
||||||
|
{
|
||||||
|
IPAddress newaddress = new IPAddress("0.0.0.0");
|
||||||
|
Random rnd = NB.GetRandom();
|
||||||
|
|
||||||
|
switch (rnd.Next(8))
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
newaddress = DefaultGW.BreakIPAddress32();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
newaddress = DefaultGW.BreakIPAddressMangle();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
newaddress = DefaultGW.BreakIPAddressRandom();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
newaddress = DefaultGW.BreakIPAddressZero();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (DefaultGW != newaddress)
|
||||||
|
{
|
||||||
|
DefaultGW = newaddress;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user