void item_OnScanHit(ScanItemEventArgs args) { OpenPorts.Add(args.NetworkScanItem); if (OnScanHit != null && scan) { OnScanHit(args); } }
public void HandleNetworkConection(PcapAnalyzer.NetworkConnection networkConnection) { // Create network nodes if needed. if (Connections.Add(networkConnection)) { if (!OpenPorts.ContainsKey(networkConnection.Source)) { OpenPorts[networkConnection.Source] = new HashSet <int>(); } if (!OpenPorts.ContainsKey(networkConnection.Destination)) { OpenPorts[networkConnection.Destination] = new HashSet <int>(); } } // Update open ports. OpenPorts[networkConnection.Source].Add(networkConnection.SrcPort); OpenPorts[networkConnection.Destination].Add(networkConnection.DestPort); }
/// <summary> /// Checks whether or nat a given port is open on the computer. /// </summary> /// <param name="port">The port number as <c>int</c></param> /// <returns><c>true</c> if the port is open, otherwise <c>false</c>.</returns> public bool CheckPortOpen(int port) => OpenPorts.Exists(x => x == port);