"""HTTP Probing Module"""
from typing import Dict, List
from src.utils.helpers import run_command, get_timestamp
async def probe_http(
targets: List[str],
check_title: bool = True,
check_status: bool = True,
check_tech: bool = True,
threads: int = 50
) -> Dict:
"""
Probe HTTP/HTTPS services
Args:
targets: List of targets
check_title: Extract titles
check_status: Check status codes
check_tech: Detect technologies
threads: Concurrent threads
Returns:
Dictionary with live hosts
"""
results = {
"timestamp": get_timestamp(),
"total_targets": len(targets),
"live_hosts": []
}
# Create temp file with targets
import tempfile
with tempfile.NamedTemporaryFile(mode='w', delete=False) as f:
f.write('\n'.join(targets))
target_file = f.name
cmd = f"httpx -l {target_file} -silent -threads {threads}"
if check_title:
cmd += " -title"
if check_status:
cmd += " -status-code"
if check_tech:
cmd += " -tech-detect"
result = await run_command(cmd, timeout=300)
if result['success']:
results['live_hosts'] = [line.strip() for line in result['stdout'].split('\n') if line.strip()]
results['live_count'] = len(results['live_hosts'])
# Cleanup
import os
os.unlink(target_file)
return results