Exemplo n.º 1
0
        private void ScanMachine(object machine)
        {
            try
            {
                TcpSynScanner scanner;
                scanner               = new TcpSynScanner(new IPEndPoint(_endPointAddress, 0));
                scanner.PortReply    += new TcpPortReplyHandler(Scanner_PortReply);
                scanner.ScanComplete += new TcpPortScanComplete(Scanner_ScanComplete);

                IPAddress address = (IPAddress)machine;
                _scannerList.Add(scanner);
                scanner.StartScan(address, this.connectionManager.SupportedPorts(), 1000, 100, true);
                _scannerCount++;
            }
            catch (Exception)
            {
                //its safe to ignore exceptions here as well
                //Terminals.Logging.Log.Info("", e);
                lock (_uiElementsLock)
                {
                    _pendingRequests = _pendingRequests - 5;
                }
            }

            if (!this.IsDisposed)
            {
                this.Invoke(_miv);
            }

            Application.DoEvents();
        }
Exemplo n.º 2
0
        private void ScanMachine(object state)
        {
            try
            {
                object[]  states  = (object[])state;
                IPAddress address = (IPAddress)states[0];
                ushort[]  ports   = (ushort[])states[1];

                TcpSynScanner scanner = new TcpSynScanner(new IPEndPoint(this.endPointAddress, 0));
                scanner.PortReply    += new TcpPortReplyHandler(this.Scanner_PortReply);
                scanner.ScanComplete += new TcpPortScanComplete(this.Scanner_ScanComplete);
                scanners.Add(scanner);
                scanner.StartScan(address, ports, 1000, 100, true);
                this.counter = this.counter + ports.Length;
            }
            catch (NotSupportedException) // thrown by constructor of packet sniffer
            {
                MessageBox.Show("Port scanner requires administrative priviledges to run!", "Terminals - port scanner",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (Exception exception)
            {
                Logging.Info("Scanner caught an exception", exception);
            }
            if (!this.IsDisposed)
            {
                this.Invoke(this.updateConnections);
            }
            Application.DoEvents();
        }
Exemplo n.º 3
0
        private void ScanMachine(object state)
        {
            try
            {
                object[]  states  = (object[])state;
                IPAddress address = (IPAddress)states[0];
                ushort[]  ports   = (ushort[])states[1];

                TcpSynScanner scanner = new TcpSynScanner(new IPEndPoint(this.endPointAddress, 0));
                scanner.PortReply    += this.scanner_PortReply;
                scanner.ScanComplete += this.scanner_ScanComplete;
                this.scanners.Add(scanner);
                scanner.StartScan(address, ports, 1000, 100, true);
                this.Counter = this.Counter + ports.Length;
            }
            catch (Exception ex)
            {
                Log.Warn("Error occured while trying to scan the target machine.", ex);
                MessageBox.Show("Error occured while trying to scan the target machine." + Environment.NewLine + ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if (!this.IsDisposed)
            {
                this.Invoke(this.miv);
            }
        }
        private void ScanMachine(object machine)
        {
            try
            {
                TcpSynScanner scanner = new TcpSynScanner(new IPEndPoint(this._endPointAddress, 0));
                scanner.PortReply    += this.Scanner_PortReply;
                scanner.ScanComplete += this.Scanner_ScanComplete;

                IPAddress address = (IPAddress)machine;
                this._scannerList.Add(scanner);
                scanner.StartScan(address, ConnectionManager.GetPorts(), 1000, 100, true);
                this._scannerCount++;
            }
            catch (Exception)
            {
                lock (this._uiElementsLock)
                {
                    this._pendingRequests = this._pendingRequests - 5;
                }
            }

            if (!this.IsDisposed)
            {
                this.Invoke(this._miv);
            }

            Application.DoEvents();
        }