From 421a6b1a5927e5c20a0b4679005b5e9f8878f2f4 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Wed, 4 Apr 2018 16:42:32 +0300 Subject: [PATCH] trigger multiple spray packets even after the packet is done. --- EduNetworkBuilder/NB.cs | 2 ++ EduNetworkBuilder/Network.cs | 15 +++++++++++++++ EduNetworkBuilder/NetworkCard.cs | 3 +++ EduNetworkBuilder/NetworkDevice.cs | 10 ++++++++++ 4 files changed, 30 insertions(+) diff --git a/EduNetworkBuilder/NB.cs b/EduNetworkBuilder/NB.cs index ac0c0fd..6208f3b 100644 --- a/EduNetworkBuilder/NB.cs +++ b/EduNetworkBuilder/NB.cs @@ -373,6 +373,8 @@ namespace EduNetworkBuilder public static int NormalRotation = 5; public static int PacketDamageDistance = 25; + public static int NumBadPackets = 3; //the number of packets to spray out + public static string AllowedPasswordCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-=!~@#$%^&*()_+{}[]/?<>,."; public static string AllowedUsernameCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890._"; /// diff --git a/EduNetworkBuilder/Network.cs b/EduNetworkBuilder/Network.cs index df07663..91019a0 100644 --- a/EduNetworkBuilder/Network.cs +++ b/EduNetworkBuilder/Network.cs @@ -60,6 +60,7 @@ namespace EduNetworkBuilder public bool PuzzleIsSolved = true; //only set to false if we load a puzzle public List SuggestedReadings = new List(); private DateTime NetworkStartTime = DateTime.Now; + private DateTime NextSprayTime = DateTime.Now; private bool AlreadyChosenTimeout = false; private int DefaultTimeout = 10; private int NumberOfSecondsForTimeout = 10; @@ -1603,6 +1604,20 @@ namespace EduNetworkBuilder { if (Animations[i].AnimationDone) Animations.RemoveAt(i); } + if(DateTime.Now > NextSprayTime) + { + Random myRnd = NB.GetRandom(); + int ms = (myRnd.Next(10) + 2) * 250; + NextSprayTime = DateTime.Now.AddMilliseconds(ms); + foreach(NetworkComponent NC in NetComponents) + { + if(NC is NetworkDevice) + { + NetworkDevice ND = (NetworkDevice)NC; + ND.BadPacketIfIShould(); + } + } + } } //if (myPackets.Count > 50) //Console.WriteLine("Packets: " + myPackets.Count.ToString()); diff --git a/EduNetworkBuilder/NetworkCard.cs b/EduNetworkBuilder/NetworkCard.cs index fd5a309..44aa662 100644 --- a/EduNetworkBuilder/NetworkCard.cs +++ b/EduNetworkBuilder/NetworkCard.cs @@ -486,6 +486,7 @@ namespace EduNetworkBuilder tPacket.Tracking.Status = NB.Translate("N_ProssShouldContinTime"); tPacket.MyStatus = PacketStatus.finished_failed; //Then, we make a bad packet go out from here + WhereFrom.BadSprayCount = NB.NumBadPackets; WhereFrom.BadPacketFromHere(); return false; } @@ -773,6 +774,8 @@ namespace EduNetworkBuilder tPacket.MyStatus = PacketStatus.finished_failed; //Then, we make a bad packet go out from here nd.BadPacketFromHere(); + nd.BadSprayCount = NB.NumBadPackets; + } if (mynet.ItemHasTest(nd.hostname,NetTestType.DeviceIsFrozen)) { diff --git a/EduNetworkBuilder/NetworkDevice.cs b/EduNetworkBuilder/NetworkDevice.cs index 4970b2a..bb63bf0 100644 --- a/EduNetworkBuilder/NetworkDevice.cs +++ b/EduNetworkBuilder/NetworkDevice.cs @@ -38,6 +38,7 @@ namespace EduNetworkBuilder public List FirewallRules = new List(); public bool PowerOff = false; private List tracertmessages = new List(); + public int BadSprayCount = 0; public NetworkDevice(NetworkComponentType what, string tHostname, Point tLocation, NicType firstNic = NicType.eth) { @@ -1594,6 +1595,15 @@ namespace EduNetworkBuilder myNet.addPacket(BadPacket); } + public void BadPacketIfIShould() + { + if(BadSprayCount > 0) + { + BadPacketFromHere(); + BadSprayCount--; + } + } + public void TracerouteFromHere(NB_IPAddress Destination) { //We need to create a traceroute packet - start with 1 TTL