break more things

This commit is contained in:
Tim Young 2017-08-28 15:17:28 -05:00
parent 094f8cabf7
commit 537bb31835
4 changed files with 54 additions and 5 deletions

View File

@ -1933,7 +1933,7 @@ namespace EduNetworkBuilder
} }
} }
int BreakNetComponent(NetworkComponent What, HowToBreak How) int BreakNetComponent(NetworkComponent What, HowToBreak How, string Data)
{ {
int didit = 0; int didit = 0;
NetworkDevice tDevice = null; NetworkDevice tDevice = null;
@ -1964,6 +1964,7 @@ namespace EduNetworkBuilder
case HowToBreak.LockOutSwitch: case HowToBreak.LockOutSwitch:
//Lock it out //Lock it out
if (tDevice.DoesForwarding()) tDevice.LockUsOutOfDevice(); if (tDevice.DoesForwarding()) tDevice.LockUsOutOfDevice();
didit = 1;
break; break;
case HowToBreak.StaticRouteClear: case HowToBreak.StaticRouteClear:
//Clear out the static route(s) //Clear out the static route(s)
@ -1979,12 +1980,18 @@ namespace EduNetworkBuilder
break; break;
case HowToBreak.VPNChangeKey: case HowToBreak.VPNChangeKey:
//change the key for the VPN encryption //change the key for the VPN encryption
if (tDevice.BreakVPNKey(Data))
didit = 2;
break; break;
case HowToBreak.WirelessBreakKey: case HowToBreak.WirelessBreakKey:
//Change the wireless key //Change the wireless key
if (tDevice.BreakWirelessKey(Data))
didit = 2;
break; break;
case HowToBreak.WirelessBreakSSID: case HowToBreak.WirelessBreakSSID:
//change the wireless ssid - have small list of bad keys to choose from //change the wireless ssid - have small list of bad keys to choose from
if (tDevice.BreakSSID(Data))
didit = 2;
break; break;
} }
return didit; return didit;
@ -2014,13 +2021,14 @@ namespace EduNetworkBuilder
while(count < 3) while(count < 3)
{ {
string host = ThePath.HostnameFromTechnology(WhatNeeded); string host = ThePath.HostnameFromTechnology(WhatNeeded);
if(host != "") if (host != "")
{ {
string data = ThePath.DataFromTechnologyAndHost(WhatNeeded, host);
//We have a host, see if we can break it. //We have a host, see if we can break it.
NetworkComponent NC = ComponentFromName(host); NetworkComponent NC = ComponentFromName(host);
if(NC != null) if(NC != null)
{ {
int answer = BreakNetComponent(NC, How); int answer = BreakNetComponent(NC, How, data);
if (answer > 0) if (answer > 0)
{ {
if(!AlreadyHasPingTest(ThePath.Source(), ThePath.Destination())) if(!AlreadyHasPingTest(ThePath.Source(), ThePath.Destination()))

View File

@ -2170,7 +2170,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, HowToBreak.LockOutSwitch }; List<HowToBreak> BreakList = new List<HowToBreak>() { HowToBreak.PowerOff, HowToBreak.EthernetBreak,
HowToBreak.LockOutSwitch, HowToBreak.WirelessBreakKey, HowToBreak.WirelessBreakSSID, HowToBreak.VPNChangeKey };
//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;

View File

@ -3090,6 +3090,27 @@ namespace EduNetworkBuilder
return true; return true;
} }
public bool BreakVPNKey(string nicname)
{
//find the nic.
NetworkCard nic = NicFromName(nicname);
if (nic == null) return false; //we could not do it.
List<string> choices = new List<string>() { "Key", "Llave","ChangeMe",
"Password","key","default","admin",};
choices.Add(nic.EncryptionKey.ToUpper());
choices.Add(nic.EncryptionKey.ToLower());
if (nic.EncryptionKey.Length > 4)
choices.Add(nic.EncryptionKey.Substring(0, 2) + nic.EncryptionKey.Substring(2, 1).ToUpper() + nic.EncryptionKey.Substring(3));
choices = NB.Randomize<string>(choices);
string choice = choices[0]; //grab the first one
if (nic.WirelessKey == choice) return false;
nic.WirelessKey = choice; //change it
return true;
}
#endregion #endregion
} }
} }

View File

@ -99,5 +99,24 @@ namespace EduNetworkBuilder
} }
return ""; return "";
} }
public string DataFromTechnologyAndHost(TraversalTechnology What, string hostname)
{
//make a randomized copy of the list, and return the first item that has the technology
List<TraversalRecord> tPathTaken = NB.Randomize<TraversalRecord>(PathTaken);
if (What != TraversalTechnology.any)
{
foreach (TraversalRecord one in tPathTaken)
{
if (one.WhatUsed == What && hostname == one.host) return one.AdditionalData;
}
}
else
{
//We do not have any AdditionalData for a type of "any"
return "";
}
return "";
}
} }
} }