Files
SwEdryG 5e45d7a005 Добавить PortScanner/IP_port_checker.cs
В следующем описании будет рецепт блинчиков. Вообще не советую относиться к этому всерьез по крайней мере к моим описаниям тут.
2026-06-10 23:17:50 +03:00

61 lines
2.0 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using IP_port_checker.Core;
using Spectre.Console;
using System.Net;
namespace IP_port_checker.PortScanner
{
internal class IP_port_check
{
public static async Task IP_check()
{
while (true)
{
bool isIPv4 = true;
Console.Write("Введите ip-адрес: ");
IPAddress ip = IPValidator.ValidateAndReadIPv4orIPv6(ref isIPv4);
int startport = InputValidator.StEnPort("Введите начальный порт: ");
int endport = InputValidator.StEnPort("Введите конечный порт: ");
int totalPorts = endport - startport + 1;
double estimatedSec = totalPorts / 7284.0;
if (estimatedSec < 0.5)
estimatedSec = 0.5;
string IPType = isIPv4 ? "IPv4" : "IPv6";
var panel = new Panel($"""
[cyan]IP:[/] {ip}
[cyan]Версия IP:[/] {IPType}
[cyan]Диапазон:[/] {startport}{endport}
[cyan]Тайм-аут:[/] 500 мс
[cyan]Всего портов:[/] {totalPorts}
[cyan]Ожидание:[/] {estimatedSec:F1} сек
""")
{
Header = new PanelHeader("[bold cyan]ИНФОРМАЦИЯ СКАНИРОВАНИЯ[/]"),
Border = BoxBorder.Double,
Padding = new Padding(2, 1, 2, 1)
};
AnsiConsole.Write(panel);
await TCPChecker.ScanPort(ip, startport, endport);
Console.WriteLine("Готово! Повторить еще раз? Y/N");
string? input = Console.ReadLine()?.ToLower() ?? "n";
bool exit = input?.ToLower() switch
{
"y" => false,
"n" => true,
_ => true
};
if (exit) break;
}
}
}
}