TheAlgorithms/C-Sharp

Invasor de rede

Esk-C opened this issue · 1 comments

using System;
using System.Net;
using System.Net.Sockets;

class Program
{
static void Main()
{
string ipAddress = "192.168.1.1"; // Endereço IP da rede que você deseja escanear
int startPort = 1;
int endPort = 1024;

    Console.WriteLine($"Scanning {ipAddress} from port {startPort} to {endPort}");

    for (int port = startPort; port <= endPort; port++)
    {
        using (TcpClient tcpClient = new TcpClient())
        {
            try
            {
                tcpClient.Connect(ipAddress, port);
                Console.WriteLine($"Port {port} is open.");
            }
            catch (Exception)
            {
                // Porta fechada ou inacessível
            }
        }
    }

    Console.WriteLine("Scan complete.");
}

}

Please open a pull request in English with a good explanation and references for the algorithm