| 1931 | # ---------------- CLI ---------------- |
| 1932 | |
| 1933 | def parse_args(argv: Optional[List[str]] = None) -> argparse.Namespace: |
| 1934 | p = argparse.ArgumentParser( |
| 1935 | description="Bug Hunter (no-root) — authorized recon & misconfiguration scanner", |
| 1936 | formatter_class=argparse.ArgumentDefaultsHelpFormatter, |
| 1937 | ) |
| 1938 | p.add_argument("target", help="Target URL or hostname (https assumed if scheme omitted)") |
| 1939 | p.add_argument("-o", "--output", default="bughunter_out", help="Output directory") |
| 1940 | p.add_argument("--quick", action="store_true", help="Quick scan (lower depth, fewer probes)") |
| 1941 | p.add_argument("--full", action="store_true", help="Full scan (deeper crawl, more discovery)") |
| 1942 | p.add_argument("--timeout", type=float, default=12.0, help="HTTP/TCP timeout seconds") |
| 1943 | p.add_argument("-c", "--concurrency", type=int, default=30, help="Max concurrent tasks") |
| 1944 | p.add_argument("--rate", type=float, default=0.0, help="Optional rate limit (requests per second, 0=off)") |
| 1945 | p.add_argument("--live", action="store_true", help="Stream new findings in real time during scanning") |
| 1946 | p.add_argument("--stream-jsonl", action="store_true", help="Write live findings to findings.jsonl as they are discovered") |
| 1947 | p.add_argument("--live-min-severity", default="Info", help="Minimum severity to print in --live (Critical|High|Medium|Low|Info)") |
| 1948 | p.add_argument("--live-stats-interval", type=float, default=0.0, help="Print periodic live stats every N seconds (0=off)") |
| 1949 | p.add_argument("--checkpoint-every", type=int, default=0, help="Write report.partial.json every N new findings (0=off)") |
| 1950 | p.add_argument("--user-agent", default="BugHunter/4 (authorized-testing)", help="User-Agent header") |
| 1951 | p.add_argument("--no-port-scan", action="store_true", help="Disable connect-based port scan") |
| 1952 | p.add_argument("--ports", default="", help="Comma-separated ports to scan (blank=default set)") |
| 1953 | p.add_argument("--crawl-depth", type=int, default=2, help="Crawl depth (0 disables crawling)") |
| 1954 | p.add_argument("--max-pages", type=int, default=200, help="Max pages to crawl") |
| 1955 | p.add_argument("--no-js", action="store_true", help="Disable JS analysis") |
| 1956 | p.add_argument("--no-dns", action="store_true", help="Disable DNS checks") |
| 1957 | p.add_argument("--no-tls", action="store_true", help="Disable TLS checks") |
| 1958 | p.add_argument("--no-sensitive", action="store_true", help="Disable sensitive file checks") |
| 1959 | p.add_argument("--no-cors", action="store_true", help="Disable CORS check") |
| 1960 | p.add_argument("--no-methods", action="store_true", help="Disable HTTP methods check") |
| 1961 | # Enabled by default; use --no-dirb to disable. |
| 1962 | dirb_group = p.add_mutually_exclusive_group() |
| 1963 | dirb_group.add_argument("--dirb", dest="dirb", action="store_true", help="Enable directory brute-force") |
| 1964 | dirb_group.add_argument("--no-dirb", dest="dirb", action="store_false", help="Disable directory brute-force") |
| 1965 | p.add_argument("--dirb-wordlist", default="", help="Optional custom wordlist file for dirb") |
| 1966 | p.add_argument("--dirb-extensions", default="", help="Comma-separated extensions to probe (e.g. php,html,js). Default: built-in list") |
| 1967 | p.add_argument("--dirb-force-extensions", action="store_true", help="Append extensions to every wordlist entry (dirsearch -f style)") |
| 1968 | p.add_argument("--dirb-recursive", action="store_true", help="Recursively scan discovered directories") |
| 1969 | p.add_argument("--dirb-recursion-depth", type=int, default=2, help="Max recursion depth for --dirb-recursive") |
| 1970 | # Enabled by default; use --no-wayback to disable. |
| 1971 | wb_group = p.add_mutually_exclusive_group() |
| 1972 | wb_group.add_argument("--wayback", dest="wayback", action="store_true", help="Enable passive Wayback URL discovery (external service)") |
| 1973 | wb_group.add_argument("--no-wayback", dest="wayback", action="store_false", help="Disable Wayback URL discovery") |
| 1974 | |
| 1975 | # Active probes are enabled by default; use --safe-mode to disable. |
| 1976 | active_group = p.add_mutually_exclusive_group() |
| 1977 | active_group.add_argument("--unsafe-active-tests", dest="unsafe_active_tests", action="store_true", |
| 1978 | help="Enable active probes (dirb, risky method probing)") |
| 1979 | active_group.add_argument("--safe-mode", dest="unsafe_active_tests", action="store_false", |
| 1980 | help="Disable active probes (safer/passive behavior)") |
| 1981 | p.add_argument("--debug", action="store_true", help="Verbose debug logging") |
| 1982 | p.set_defaults(dirb=True, wayback=True, unsafe_active_tests=True) |
| 1983 | return p.parse_args(argv) |
| 1984 | |
| 1985 | |
| 1986 | def read_wordlist(path: str) -> List[str]: |