mirror of
https://github.com/yogeshojha/rengine.git
synced 2026-10-20 23:31:31 +02:00
Three tools took the scan's network config and dropped part of it. The banner prober spoke SOCKS5 to whatever proxy it was given. A scan context holding an http:// proxy made every handshake fail, and the stage reported "no banner returned by N ports" rather than a problem. It now speaks SOCKS5 or HTTP CONNECT by scheme (tools/banner/proxy.py, tested against a stub proxy), and refuses a scheme it cannot carry before any port is touched instead of dialling direct. naabu was handed the resolved URL whole. Its -proxy is socks5 only and takes no inline credentials, so http:// or any password quietly did not apply. proxy_args() renders -proxy host:port with -proxy-auth beside it, and names the reason when the proxy cannot be expressed, which port_scan and host_discovery report as partial. -passive is an HTTPS call to Shodan, so it goes through proxy_env instead, which passive_ports was not passing at all. wafw00f got the proxy but never the headers, so an authenticated surface was fingerprinted unauthenticated. It takes a file rather than a value, so the run writes one 0600 temp file and removes it after. proxy_env moves to shared/services/proxy_resolve.py now that naabu wants it too, and host_port() lands in shared/utils/net.py for the bracketed IPv6 authority CONNECT needs. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X5roHYDYzSPRNaTkn8hSkJ
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
import json
|
|
|
|
from shared.models.proxy import Proxy, ProxyEndpoint
|
|
from shared.utils.crypto import decrypt_stored
|
|
|
|
|
|
def load_proxy_endpoints(proxy: Proxy) -> list[ProxyEndpoint]:
|
|
raw = decrypt_stored(proxy.endpoints_encrypted or "", label=f"Proxy {proxy.name!r}")
|
|
if not raw:
|
|
return []
|
|
return [ProxyEndpoint(**e) for e in json.loads(raw)]
|
|
|
|
|
|
def proxy_env(proxy_url: str | None) -> dict[str, str] | None:
|
|
"""Proxy env vars honoured by Go HTTP clients that take no proxy flag."""
|
|
if not proxy_url:
|
|
return None
|
|
return {
|
|
"HTTP_PROXY": proxy_url,
|
|
"HTTPS_PROXY": proxy_url,
|
|
"ALL_PROXY": proxy_url,
|
|
}
|
|
|
|
|
|
def build_proxy_url(ep: ProxyEndpoint) -> str:
|
|
if ep.username:
|
|
cred = f"{ep.username}:{ep.password}@" if ep.password else f"{ep.username}@"
|
|
return f"{ep.scheme}://{cred}{ep.host}:{ep.port}"
|
|
return f"{ep.scheme}://{ep.host}:{ep.port}"
|
|
|
|
|
|
def resolve_proxy_url(proxy: Proxy | None) -> str | None:
|
|
if proxy is None or not proxy.is_active:
|
|
return None
|
|
endpoints = load_proxy_endpoints(proxy)
|
|
if not endpoints:
|
|
return None
|
|
return build_proxy_url(endpoints[0])
|