{"id":481648,"date":"2026-05-29T20:31:00","date_gmt":"2026-05-29T20:31:00","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=481648"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=481648","title":{"rendered":"\u041a\u0430\u043a \u042f \u0441\u0434\u0435\u043b\u0430\u043b \u0421\u0432\u043e\u0435\u0433\u043e \u0411\u043e\u0442\u0430 \u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0414\u043b\u044f \u0421\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u041f\u043e\u0440\u0442\u043e\u0432 \u0418 IP \u0430\u0434\u0440\u0435\u0441\u043e\u0432"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043f\u043e\u0440\u0442\u043e\u0432 \u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u043d\u0430 \u0432\u0430\u0448\u0435\u043c \u0440\u043e\u0443\u0442\u0435\u0440\u0435 \u043d\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0435 \u0442\u0430 \u0435\u0449\u0435 \u0437\u0430\u0434\u0430\u0447\u0430, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 \u0440\u0443\u0442 \u043f\u0440\u0430\u0432. \u041d\u043e \u044d\u0442\u043e \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0435\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u0431\u043e\u0442\u0430. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \/scan \u0438 \u043f\u0435\u0440\u0432\u044b\u0435 \u0442\u0440\u0438 \u0446\u0438\u0444\u0440\u044b \u0432 \u043a\u043e\u043d\u0446\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432\u0430\u0448\u0435\u0433\u043e \u0430\u0439\u043f\u0438 \u0430\u0434\u0440\u0435\u0441\u0430 \u0438 \u043e\u043d \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u0448\u043b\u0435\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0438 \u043b\u043e\u0433-\u043b\u0438\u0441\u0442\u0430.<\/p>\n<h2>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0440\u0442\u043e\u0432, \u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043f\u043e\u0440\u0442\u043e\u0432.<\/h2>\n<pre><code class=\"python\">def scan_single_ip(ip):    ports_to_scan = [21, 22, 23, 53, 80, 443, 445, 631, 8080]    discovered_ports = []    device_type = \"\u041d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\"    for port in ports_to_scan:        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)        s.settimeout(0.3)        result = s.connect_ex((ip, port))        if result == 0:            discovered_ports.append(port)            if port in PORT_GUESSER:                device_type = PORT_GUESSER[port]        s.close()    if discovered_ports:        return {            \"ip\": ip,            \"ports\": discovered_ports,            \"type\": device_type        }    return Noneasync def run_network_scan(subnet):    ip_list = [f\"{subnet}{i}\" for i in range(1, 255)]    loop = asyncio.get_running_loop()<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<pre><code>with ThreadPoolExecutor(max_workers=50) as executor:    tasks = [loop.run_in_executor(executor, scan_single_ip, ip) for ip in ip_list]    results = await asyncio.gather(*tasks)return [r for r in results if r is not None]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h2>\u0410 \u044d\u0442\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0431\u043e\u0442\u0430 \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0447\u0442\u043e \u0445\u043e\u0442\u0438\u0442\u0435.<\/h2>\n<pre><code class=\"python\"># -*- coding: utf-8 -*-import asynciofrom aiogram import Bot, Dispatcher, typesfrom aiogram.filters import Commandfrom concurrent.futures import ThreadPoolExecutorimport threadingimport socketimport requestsAPI_TOKEN = '\u0412\u0430\u0448 \u0442\u043e\u043a\u0435\u043d \u043e\u0442 \u0431\u043e\u0442\u0444\u0430\u0437\u0435\u0440'bot = Bot(token=API_TOKEN)dp = Dispatcher()PORT_GUESSER = {    21: \"FTP-\u0441\u0435\u0440\u0432\u0435\u0440\",    22: \"\u041b\u0438\u043d\u0443\u043a\u0441-\u0434\u0435\u0432\u0430\u0439\u0441 (SSH)\",    23: \"Telnet-\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\",    53: \"DNS-\u0441\u0435\u0440\u0432\u0435\u0440 \/ \u0420\u043e\u0443\u0442\u0435\u0440\",    80: \"\u0412\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (\u0420\u043e\u0443\u0442\u0435\u0440\/\u041a\u0430\u043c\u0435\u0440\u0430)\",    443: \"\u0417\u0430\u0449\u0438\u0449\u0435\u043d\u043d\u044b\u0439 \u0432\u0435\u0431 (\u0420\u043e\u0443\u0442\u0435\u0440\/\u041f\u041a)\",    445: \"\u041a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u0441 Windows\",    631: \"\u0421\u0435\u0442\u0435\u0432\u043e\u0439 \u041f\u0440\u0438\u043d\u0442\u0435\u0440\",    8080: \"\u041f\u0440\u043e\u043a\u0441\u0438 \/ \u0412\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\"}def scan_single_ip(ip):    ports_to_scan = [21, 22, 23, 53, 80, 443, 445, 631, 8080]    discovered_ports = []    device_type = \"\u041d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\"    for port in ports_to_scan:        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)        s.settimeout(0.3)        result = s.connect_ex((ip, port))        if result == 0:            discovered_ports.append(port)            if port in PORT_GUESSER:                device_type = PORT_GUESSER[port]        s.close()    if discovered_ports:        return {            \"ip\": ip,            \"ports\": discovered_ports,            \"type\": device_type        }    return Noneasync def run_network_scan(subnet):    ip_list = [f\"{subnet}{i}\" for i in range(1, 255)]    loop = asyncio.get_running_loop()        with ThreadPoolExecutor(max_workers=50) as executor:        tasks = [loop.run_in_executor(executor, scan_single_ip, ip) for ip in ip_list]        results = await asyncio.gather(*tasks)        return [r for r in results if r is not None]@dp.message(Command(\"help\"))async def help_list(message: types.Message):    await message.answer(\"channel - \u043c\u043e\u0439 \u043a\u0430\u043d\u0430\u043b \u043d\u0430 \u0445\u0430\u0431\u0440\u0435, scan [\u0432\u0430\u0448 \u0430\u0439\u043f\u0438 3 \u0446\u0438\u0444\u0440\u044b] - \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0440\u0442\u043e\u0432\")@dp.message(Command(\"start\"))async def send_welcome(message: types.Message):    await message.answer(\"\u0411\u043e\u0442 \u0417\u0430\u043f\u0443\u0449\u0435\u043d! \u0421\u0435\u0440\u0432\u0435\u0440 \u0432 \u0440\u0430\u0431\u043e\u0447\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438! \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u0431\u043e\u0442 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043c\u043e\u0439 \u043d\u043e\u0443\u0442\u0431\u0443\u043a \u0432 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438.\")@dp.message(Command(\"channel\"))async def add_chanel(message: types.Message):    await message.answer(\"\u041c\u043e\u0439 \u0445\u0430\u0431\u0440: @dk_runkeevich\")    @dp.message(Command(\"scan\"))async def start_scan(message: types.Message):    args = message.text.split()    if len(args) &lt; 2:        await message.answer(\"\u041e\u0448\u0438\u0431\u043a\u0430. \u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0441\u0435\u0442\u044c, \u043f\u0440\u0438\u043c\u0435\u0440:\\n\/scan 192.168.1.\")        return    subnet = args[1]    await message.answer(f\"\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u044e \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u0441\u043a\u0430\u043d\u0435\u0440 \u0434\u043b\u044f {subnet}0\/24...\\n\u042d\u0442\u043e \u0437\u0430\u0439\u043c\u0435\u0442 \u043e\u043a\u043e\u043b\u043e 10 \u0441\u0435\u043a\u0443\u043d\u0434.\")    try:        devices = await run_network_scan(subnet)                if not devices:            await message.answer(\"\u0421\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e. \u0416\u0438\u0432\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c\u0438 \u043f\u043e\u0440\u0442\u0430\u043c\u0438 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e.\")            return        report = f\"\ud83d\udcca \u041e\u0422\u0427\u0415\u0422 \u041e \u0421\u041a\u0410\u041d \u0418\u0420\u041e\u0412\u0410\u041d\u0418\u0418 \u0421\u0415\u0422\u0418 {subnet}0\/24:\\n\\n\"        for dev in devices:            report += f\"\ud83c\udf10 IP: {dev['ip']}\\n\"            report += f\"\ud83d\udd0c \u041f\u043e\u0440\u0442\u044b: {', '.join(map(str, dev['ports']))}\\n\"            report += f\"\ud83d\udcdd \u0422\u0438\u043f: {dev['type']}\\n\"            report += \"\u2014\" * 20 + \"\\n\"        await message.answer(report)    except Exception as e:        await message.answer(f\"\u041f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438: {e}\")async def main():    await dp.start_polling(bot)if __name__ == \"__main__\":    asyncio.run(main())<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0430 \u043d\u0435 \u043a\u043e\u0434\u0435\u0440 \u0442\u043e \u0432\u043e\u0442 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0431\u043e\u0442\u0430: <a href=\"https:\/\/t.me\/dkrun_bot\" rel=\"noopener noreferrer nofollow\">https:\/\/t.me\/dkrun_bot<\/a> \u0418\u0437\u0432\u0438\u043d\u044f\u044e\u0441\u044c \u0447\u0442\u043e \u043d\u0435 \u0432\u044b\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 \u0433\u0438\u0442\u0445\u0430\u0431, \u044d\u0442\u043e \u0432\u0441\u0435 \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044f \u043d\u0435 \u0445\u043e\u0447\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0430\u0436\u0430\u0442\u044c \u043d\u0430 \u043a\u0430\u043a\u0443\u044e \u0442\u043e \u0441\u0441\u044b\u043b\u043a\u0443, \u0437\u0430\u0447\u0435\u043c \u0442\u0430\u043c \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u0434\u0435\u0441\u044c?<\/p>\n<p>p.p.s \u041c\u043e\u0439 \u0431\u043e\u0442 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 12 \u0447\u0430\u0441\u043e\u0432 \u043d\u043e\u0447\u0438. \u0423 \u043c\u0435\u043d\u044f \u043d\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043d\u043e\u0443\u0442.<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1041392\/\">https:\/\/habr.com\/ru\/articles\/1041392\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043f\u043e\u0440\u0442\u043e\u0432 \u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u043d\u0430 \u0432\u0430\u0448\u0435\u043c \u0440\u043e\u0443\u0442\u0435\u0440\u0435 \u043d\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0435 \u0442\u0430 \u0435\u0449\u0435 \u0437\u0430\u0434\u0430\u0447\u0430, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 \u0440\u0443\u0442 \u043f\u0440\u0430\u0432. \u041d\u043e \u044d\u0442\u043e \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0435\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u0431\u043e\u0442\u0430. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \/scan \u0438 \u043f\u0435\u0440\u0432\u044b\u0435 \u0442\u0440\u0438 \u0446\u0438\u0444\u0440\u044b \u0432 \u043a\u043e\u043d\u0446\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432\u0430\u0448\u0435\u0433\u043e \u0430\u0439\u043f\u0438 \u0430\u0434\u0440\u0435\u0441\u0430 \u0438 \u043e\u043d \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u0448\u043b\u0435\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0438 \u043b\u043e\u0433-\u043b\u0438\u0441\u0442\u0430.\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0440\u0442\u043e\u0432, \u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043f\u043e\u0440\u0442\u043e\u0432.def scan_single_ip(ip):    ports_to_scan = [21, 22, 23, 53, 80, 443, 445, 631, 8080]    discovered_ports = []    device_type = &#171;\u041d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e&#187;    for port in ports_to_scan:        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)        s.settimeout(0.3)        result = s.connect_ex((ip, port))        if result == 0:            discovered_ports.append(port)            if port in PORT_GUESSER:                device_type = PORT_GUESSER[port]        s.close()    if discovered_ports:        return {            &#171;ip&#187;: ip,            &#171;ports&#187;: discovered_ports,            &#171;type&#187;: device_type        }    return Noneasync def run_network_scan(subnet):    ip_list = [f&#187;{subnet}{i}&#187; for i in range(1, 255)]    loop = asyncio.get_running_loop()with ThreadPoolExecutor(max_workers=50) as executor:    tasks = [loop.run_in_executor(executor, scan_single_ip, ip) for ip in ip_list]    results = await asyncio.gather(*tasks)return [r for r in results if r is not None]\u0410 \u044d\u0442\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0431\u043e\u0442\u0430 \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0447\u0442\u043e \u0445\u043e\u0442\u0438\u0442\u0435.# -*- coding: utf-8 -*-import asynciofrom aiogram import Bot, Dispatcher, typesfrom aiogram.filters import Commandfrom concurrent.futures import ThreadPoolExecutorimport threadingimport socketimport requestsAPI_TOKEN = &#8216;\u0412\u0430\u0448 \u0442\u043e\u043a\u0435\u043d \u043e\u0442 \u0431\u043e\u0442\u0444\u0430\u0437\u0435\u0440&#8217;bot = Bot(token=API_TOKEN)dp = Dispatcher()PORT_GUESSER = {    21: &#171;FTP-\u0441\u0435\u0440\u0432\u0435\u0440&#187;,    22: &#171;\u041b\u0438\u043d\u0443\u043a\u0441-\u0434\u0435\u0432\u0430\u0439\u0441 (SSH)&#187;,    23: &#171;Telnet-\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e&#187;,    53: &#171;DNS-\u0441\u0435\u0440\u0432\u0435\u0440 \/ \u0420\u043e\u0443\u0442\u0435\u0440&#187;,    80: &#171;\u0412\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (\u0420\u043e\u0443\u0442\u0435\u0440\/\u041a\u0430\u043c\u0435\u0440\u0430)&#187;,    443: &#171;\u0417\u0430\u0449\u0438\u0449\u0435\u043d\u043d\u044b\u0439 \u0432\u0435\u0431 (\u0420\u043e\u0443\u0442\u0435\u0440\/\u041f\u041a)&#187;,    445: &#171;\u041a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u0441 Windows&#187;,    631: &#171;\u0421\u0435\u0442\u0435\u0432\u043e\u0439 \u041f\u0440\u0438\u043d\u0442\u0435\u0440&#187;,    8080: &#171;\u041f\u0440\u043e\u043a\u0441\u0438 \/ \u0412\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440&#187;}def scan_single_ip(ip):    ports_to_scan = [21, 22, 23, 53, 80, 443, 445, 631, 8080]    discovered_ports = []    device_type = &#171;\u041d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e&#187;    for port in ports_to_scan:        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)        s.settimeout(0.3)        result = s.connect_ex((ip, port))        if result == 0:            discovered_ports.append(port)            if port in PORT_GUESSER:                device_type = PORT_GUESSER[port]        s.close()    if discovered_ports:        return {            &#171;ip&#187;: ip,            &#171;ports&#187;: discovered_ports,            &#171;type&#187;: device_type        }    return Noneasync def run_network_scan(subnet):    ip_list = [f&#187;{subnet}{i}&#187; for i in range(1, 255)]    loop = asyncio.get_running_loop()        with ThreadPoolExecutor(max_workers=50) as executor:        tasks = [loop.run_in_executor(executor, scan_single_ip, ip) for ip in ip_list]        results = await asyncio.gather(*tasks)        return [r for r in results if r is not None]@dp.message(Command(&#171;help&#187;))async def help_list(message: types.Message):    await message.answer(&#171;channel &#8212; \u043c\u043e\u0439 \u043a\u0430\u043d\u0430\u043b \u043d\u0430 \u0445\u0430\u0431\u0440\u0435, scan [\u0432\u0430\u0448 \u0430\u0439\u043f\u0438 3 \u0446\u0438\u0444\u0440\u044b] &#8212; \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0440\u0442\u043e\u0432&#187;)@dp.message(Command(&#171;start&#187;))async def send_welcome(message: types.Message):    await message.answer(&#171;\u0411\u043e\u0442 \u0417\u0430\u043f\u0443\u0449\u0435\u043d! \u0421\u0435\u0440\u0432\u0435\u0440 \u0432 \u0440\u0430\u0431\u043e\u0447\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438! \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u0431\u043e\u0442 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043c\u043e\u0439 \u043d\u043e\u0443\u0442\u0431\u0443\u043a \u0432 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438.&#187;)@dp.message(Command(&#171;channel&#187;))async def add_chanel(message: types.Message):    await message.answer(&#171;\u041c\u043e\u0439 \u0445\u0430\u0431\u0440: @dk_runkeevich&#187;)    @dp.message(Command(&#171;scan&#187;))async def start_scan(message: types.Message):    args = message.text.split()    if len(args) &lt; 2:        await message.answer(&#171;\u041e\u0448\u0438\u0431\u043a\u0430. \u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0441\u0435\u0442\u044c, \u043f\u0440\u0438\u043c\u0435\u0440:\\n\/scan 192.168.1.&#187;)        return    subnet = args[1]    await message.answer(f&#187;\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u044e \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u0441\u043a\u0430\u043d\u0435\u0440 \u0434\u043b\u044f {subnet}0\/24&#8230;\\n\u042d\u0442\u043e \u0437\u0430\u0439\u043c\u0435\u0442 \u043e\u043a\u043e\u043b\u043e 10 \u0441\u0435\u043a\u0443\u043d\u0434.&#187;)    try:        devices = await run_network_scan(subnet)                if not devices:            await message.answer(&#171;\u0421\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e. \u0416\u0438\u0432\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c\u0438 \u043f\u043e\u0440\u0442\u0430\u043c\u0438 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e.&#187;)            return        report = f&#187;\ud83d\udcca \u041e\u0422\u0427\u0415\u0422 \u041e \u0421\u041a\u0410\u041d \u0418\u0420\u041e\u0412\u0410\u041d\u0418\u0418 \u0421\u0415\u0422\u0418 {subnet}0\/24:\\n\\n&#187;        for dev in devices:            report += f&#187;\ud83c\udf10 IP: {dev[&#8216;ip&#8217;]}\\n&#187;            report += f&#187;\ud83d\udd0c \u041f\u043e\u0440\u0442\u044b: {&#8216;, &#8216;.join(map(str, dev[&#8216;ports&#8217;]))}\\n&#187;            report += f&#187;\ud83d\udcdd \u0422\u0438\u043f: {dev[&#8216;type&#8217;]}\\n&#187;            report += &#171;\u2014&#187; * 20 + &#171;\\n&#187;        await message.answer(report)    except Exception as e:        await message.answer(f&#187;\u041f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438: {e}&#187;)async def main():    await dp.start_polling(bot)if __name__ == &#171;__main__&#187;:    asyncio.run(main())\u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0430 \u043d\u0435 \u043a\u043e\u0434\u0435\u0440 \u0442\u043e \u0432\u043e\u0442 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0431\u043e\u0442\u0430: https:\/\/t.me\/dkrun_bot \u0418\u0437\u0432\u0438\u043d\u044f\u044e\u0441\u044c \u0447\u0442\u043e \u043d\u0435 \u0432\u044b\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 \u0433\u0438\u0442\u0445\u0430\u0431, \u044d\u0442\u043e \u0432\u0441\u0435 \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044f \u043d\u0435 \u0445\u043e\u0447\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0430\u0436\u0430\u0442\u044c \u043d\u0430 \u043a\u0430\u043a\u0443\u044e \u0442\u043e \u0441\u0441\u044b\u043b\u043a\u0443, \u0437\u0430\u0447\u0435\u043c \u0442\u0430\u043c \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u0434\u0435\u0441\u044c?p.p.s \u041c\u043e\u0439 \u0431\u043e\u0442 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 12 \u0447\u0430\u0441\u043e\u0432 \u043d\u043e\u0447\u0438. \u0423 \u043c\u0435\u043d\u044f \u043d\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043d\u043e\u0443\u0442.\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 https:\/\/habr.com\/ru\/articles\/1041392\/<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-481648","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/481648","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=481648"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/481648\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=481648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=481648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=481648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}