예제 #1
0
 private void item_OnScanHit(ScanItemEventArgs args)
 {
     if (this.OnAddressScanHit != null && this.ScanIsRunning)
     {
         this.OnAddressScanHit(args);
     }
 }
 void item_OnScanHit(ScanItemEventArgs args)
 {
     OpenPorts.Add(args.NetworkScanItem);
     if (OnScanHit != null && scan)
     {
         OnScanHit(args);
     }
 }
 void item_OnScanMiss(ScanItemEventArgs args)
 {
     ClosedPorts.Add(args.NetworkScanItem);
     if (OnScanMiss != null && scan)
     {
         OnScanMiss(args);
     }
 }
예제 #4
0
 private void FireOnScanHit(Int32 port, string serviceName)
 {
     if (this.OnScanHit != null)
     {
         ScanItemEventArgs args = this.CreateNewEventArguments(port, serviceName);
         this.OnScanHit(args);
     }
 }
        private void AttemptConnect(IAsyncResult result)
        {
            System.Net.Sockets.TcpClient client = (System.Net.Sockets.TcpClient)result.AsyncState;

            if (client.Client != null && client.Connected)
            {
                if (OnScanHit != null)
                {
                    ScanItemEventArgs args = new ScanItemEventArgs();
                    if (Port == Connections.ConnectionManager.VNCVMRCPort)
                    {
                        IsVMRC = !IsPortVNC();
                    }
                    args.DateTime        = DateTime.Now;
                    args.NetworkScanItem = this;
                    try {
                        if (KnownHostNames.ContainsKey(args.NetworkScanItem.IPAddress))
                        {
                            args.NetworkScanItem.HostName = KnownHostNames[args.NetworkScanItem.IPAddress];
                        }
                        else
                        {
                            System.Net.IPHostEntry entry = System.Net.Dns.Resolve(args.NetworkScanItem.IPAddress);
                            args.NetworkScanItem.HostName = entry.HostName;
                            if (!KnownHostNames.ContainsKey(args.NetworkScanItem.IPAddress))
                            {
                                KnownHostNames.Add(args.NetworkScanItem.IPAddress, args.NetworkScanItem.HostName);
                            }
                        }
                    } catch (Exception exc) {
                        Terminals.Logging.Log.Info("", exc);
                        args.NetworkScanItem.HostName = args.NetworkScanItem.IPAddress;
                        if (!KnownHostNames.ContainsKey(args.NetworkScanItem.IPAddress))
                        {
                            KnownHostNames.Add(args.NetworkScanItem.IPAddress, args.NetworkScanItem.IPAddress);
                        }
                    }
                    this.IsOpen = true;
                    OnScanHit(args);
                }
            }
            else
            {
                if (OnScanMiss != null)
                {
                    ScanItemEventArgs args = new ScanItemEventArgs();
                    args.DateTime        = DateTime.Now;
                    args.NetworkScanItem = this;
                    OnScanMiss(args);
                }
            }
        }
예제 #6
0
        private ScanItemEventArgs CreateNewEventArguments(int port = 0, string serviceName = "")
        {
            var args = new ScanItemEventArgs();

            args.DateTime   = DateTime.Now;
            args.ScanResult = new NetworkScanResult
            {
                HostName    = this.HostName,
                IPAddress   = this.iPAddress,
                Port        = port,
                ServiceName = serviceName
            };

            return(args);
        }
예제 #7
0
        private void item_OnScanFinished(ScanItemEventArgs args)
        {
            Debug.WriteLine("Scan finished: {0}", args.ScanResult);

            this.DoneAddressScans++;

            if (this.OnAddressScanFinished != null && this.ScanIsRunning)
            {
                this.OnAddressScanFinished(args);
            }

            if (this.PendingAddressesToScan <= 0)
            {
                this.StopScan();
            }
        }
 public void StartScan()
 {
     openPorts   = new List <NetworkScanItem>();
     closedPorts = new List <NetworkScanItem>();
     Scan        = true;
     foreach (NetworkScanItem item in scanItems)
     {
         if (!Scan)
         {
             break;
         }
         item.OnScanHit  += new NetworkScanItem.ScanHitHandler(item_OnScanHit);
         item.OnScanMiss += new NetworkScanItem.ScanMissHandler(item_OnScanMiss);
         ScanItemEventArgs args = new ScanItemEventArgs();
         args.NetworkScanItem = item;
         if (OnScanStart != null)
         {
             OnScanStart(args);
         }
         System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(item.Scan), null);
     }
 }
        private void AttemptConnect(IAsyncResult result)
        {
            System.Net.Sockets.TcpClient client = (System.Net.Sockets.TcpClient)result.AsyncState;

            if (client.Client!=null && client.Connected) {
                if (OnScanHit != null) {

                    ScanItemEventArgs args = new ScanItemEventArgs();
                    if (Port == Connections.ConnectionManager.VNCVMRCPort) {
                        IsVMRC = !IsPortVNC();
                    }
                    args.DateTime = DateTime.Now;
                    args.NetworkScanItem = this;
                    try {
                        if (KnownHostNames.ContainsKey(args.NetworkScanItem.IPAddress)) {
                            args.NetworkScanItem.HostName = KnownHostNames[args.NetworkScanItem.IPAddress];
                        } else {
                            System.Net.IPHostEntry entry = System.Net.Dns.Resolve(args.NetworkScanItem.IPAddress);
                            args.NetworkScanItem.HostName = entry.HostName;
                            if (!KnownHostNames.ContainsKey(args.NetworkScanItem.IPAddress)) KnownHostNames.Add(args.NetworkScanItem.IPAddress, args.NetworkScanItem.HostName);
                        }

                    } catch (Exception exc) {
                        Terminals.Logging.Log.Info("", exc);
                        args.NetworkScanItem.HostName = args.NetworkScanItem.IPAddress;
                        if(!KnownHostNames.ContainsKey(args.NetworkScanItem.IPAddress)) KnownHostNames.Add(args.NetworkScanItem.IPAddress, args.NetworkScanItem.IPAddress);
                    }
                    this.IsOpen = true;
                    OnScanHit(args);
                }
            } else {
                if (OnScanMiss != null) {
                    ScanItemEventArgs args = new ScanItemEventArgs();
                    args.DateTime = DateTime.Now;
                    args.NetworkScanItem = this;
                    OnScanMiss(args);
                }
            }
        }
 void item_OnScanHit(ScanItemEventArgs args)
 {
     OpenPorts.Add(args.NetworkScanItem);
     if (OnScanHit != null && scan) OnScanHit(args);
 }
 private void item_OnScanHit(ScanItemEventArgs args)
 {
     if (this.OnAddressScanHit != null && this.ScanIsRunning)
         this.OnAddressScanHit(args);
 }
예제 #12
0
        private ScanItemEventArgs CreateNewEventArguments(Int32 port = 0, Boolean isVMRC = false)
        {
            ScanItemEventArgs args = new ScanItemEventArgs();
            args.DateTime = DateTime.Now;
            args.ScanResult = new NetworkScanResult
                {
                    HostName = this.HostName,
                    IPAddress = this.iPAddress,
                    Port = port,
                    IsVMRC = isVMRC
                };

            return args;
        }
예제 #13
0
 private void manager_OnScanHit(ScanItemEventArgs args)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new NetworkScanHandler(manager_OnScanHit), new object[] { args });
     }
     else
     {
         this.bsScanResults.Add(args.ScanResult);
         this.gridScanResults.Refresh();
     }
 }
예제 #14
0
 private void manager_OnAddresScanFinished(ScanItemEventArgs args)
 {
     this.Invoke(new MethodInvoker(UpdateScanStatus));
 }
 void item_OnScanMiss(ScanItemEventArgs args)
 {
     ClosedPorts.Add(args.NetworkScanItem);
     if (OnScanMiss != null && scan) OnScanMiss(args);
 }
 public void StartScan()
 {
     openPorts = new List<NetworkScanItem>();
     closedPorts = new List<NetworkScanItem>();
     Scan = true;
     foreach (NetworkScanItem item in scanItems) {
         if (!Scan) break;
         item.OnScanHit += new NetworkScanItem.ScanHitHandler(item_OnScanHit);
         item.OnScanMiss += new NetworkScanItem.ScanMissHandler(item_OnScanMiss);
         ScanItemEventArgs args = new ScanItemEventArgs();
         args.NetworkScanItem = item;
         if (OnScanStart != null) OnScanStart(args);
         System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(item.Scan), null);
     }
 }
        private void item_OnScanFinished(ScanItemEventArgs args)
        {
            Debug.WriteLine(String.Format("Scan finished: {0}", args.ScanResult));

            this.DoneAddressScans++;

            if (this.OnAddressScanFinished != null && this.ScanIsRunning)
                this.OnAddressScanFinished(args);

            if (this.PendingAddressesToScan <= 0)
                this.StopScan();
        }