Added proxy integration: ProxyManager module with SOCKS5/HTTP support, proxy tab in GUI with fetch/test/rotate/on-off toggle, proxy routing for scanner connections and password spray
This commit is contained in:
31
scanner.py
31
scanner.py
@@ -1,12 +1,13 @@
|
||||
"""
|
||||
FastRDP-NG: Blazing-fast async RDP scanner.
|
||||
Connects to thousands of IPs concurrently to find live RDP hosts.
|
||||
Supports optional proxy routing via ProxyManager.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import time
|
||||
from typing import Set, Tuple, List
|
||||
from typing import Set, Tuple, List, Optional
|
||||
|
||||
logger = logging.getLogger("FastRDP-NG")
|
||||
|
||||
@@ -21,16 +22,23 @@ RDP_BANNER_SIG = b'\x03\x00'
|
||||
async def check_rdp_port(
|
||||
ip: str,
|
||||
port: int,
|
||||
timeout: float = 2.0
|
||||
timeout: float = 2.0,
|
||||
proxy_manager=None
|
||||
) -> Tuple[str, int, bool]:
|
||||
"""
|
||||
Rapid async TCP connect check.
|
||||
Supports optional proxy routing.
|
||||
|
||||
Returns (ip, port, is_open).
|
||||
No banner reading - pure connection speed.
|
||||
"""
|
||||
open_conn = asyncio.open_connection
|
||||
if proxy_manager and proxy_manager.enabled:
|
||||
open_conn = proxy_manager.open_connection
|
||||
|
||||
try:
|
||||
_, writer = await asyncio.wait_for(
|
||||
asyncio.open_connection(ip, port),
|
||||
open_conn(ip, port),
|
||||
timeout=timeout
|
||||
)
|
||||
writer.close()
|
||||
@@ -45,15 +53,21 @@ async def check_rdp_with_banner(
|
||||
ip: str,
|
||||
port: int,
|
||||
connect_timeout: float = 2.0,
|
||||
banner_timeout: float = 1.0
|
||||
banner_timeout: float = 1.0,
|
||||
proxy_manager=None
|
||||
) -> Tuple[str, int, bool]:
|
||||
"""
|
||||
Connect + read initial bytes to confirm it's actually RDP.
|
||||
Supports optional proxy routing.
|
||||
Slower but more accurate - catches non-RDP services on 3389.
|
||||
"""
|
||||
open_conn = asyncio.open_connection
|
||||
if proxy_manager and proxy_manager.enabled:
|
||||
open_conn = proxy_manager.open_connection
|
||||
|
||||
try:
|
||||
reader, writer = await asyncio.wait_for(
|
||||
asyncio.open_connection(ip, port),
|
||||
open_conn(ip, port),
|
||||
timeout=connect_timeout
|
||||
)
|
||||
try:
|
||||
@@ -81,7 +95,8 @@ async def scan_ips(
|
||||
connect_timeout: float = 2.0,
|
||||
banner_check: bool = False,
|
||||
progress_callback=None,
|
||||
live_callback=None
|
||||
live_callback=None,
|
||||
proxy_manager=None
|
||||
) -> Set[Tuple[str, int]]:
|
||||
"""
|
||||
Scan a list of IPs across given ports as fast as possible.
|
||||
@@ -89,6 +104,7 @@ async def scan_ips(
|
||||
|
||||
- progress_callback(checked, total, live_count, rate): called periodically
|
||||
- live_callback(ip, port): called IMMEDIATELY when a live host is found
|
||||
- proxy_manager: optional ProxyManager for routing through proxies
|
||||
|
||||
Returns set of (ip, port) tuples for live RDP hosts.
|
||||
"""
|
||||
@@ -106,7 +122,8 @@ async def scan_ips(
|
||||
async def check_one(ip: str, port: int):
|
||||
nonlocal checked
|
||||
async with sem:
|
||||
_, p, alive = await checker(ip, port, connect_timeout)
|
||||
_, p, alive = await checker(ip, port, connect_timeout,
|
||||
proxy_manager=proxy_manager)
|
||||
if alive:
|
||||
live_hosts.add((ip, p))
|
||||
# Notify immediately — spray can start right away
|
||||
|
||||
Reference in New Issue
Block a user