text
stringlengths
1
93.6k
stats=stats,
use_partial_update=True
)
logger.log(f"[INFO] Attempting to connect to SSID: {ssid} (Attempt {attempt + 1}/3)")
if wifi_manager.connect_to_wifi(ssid, password):
logger.log(f"[SUCCESS] Connected to SSID: {ssid}")
connected_ssid = ssid
break
else:
logger.log(f"[WARNING] Failed to connect to SSID: {ssid}.")
update_display_state(
display,
state_manager,
"fallback",
current_ssid=ssid,
current_status="Connection failed. Retrying next...",
stats=stats,
use_partial_update=True
)
continue
# Run Nmap scan
logger.log(f"[INFO] Running nmap scan for network: {ssid}")
update_display_state(
display,
state_manager,
"analyzing",
current_ssid=ssid,
current_status="Scanning the network",
stats=stats,
use_partial_update=True
)
scan_result = run_nmap_scan("192.168.1.0/24", logger=logger)
stats["targets"] += len(scan_result["discovered_ips"]) # Increment Targets
html_logger.save_scan_result_to_json(ssid, scan_result["raw_output"])
# Recon Phase
recon = Recon(logger=logger)
parsed_devices = [] # List to store structured device data
for ip in scan_result["discovered_ips"]:
update_display_state(
display,
state_manager,
"reconnaissance",
current_ssid=ssid,
current_status=f"Scanning IP {ip}",
stats=stats,
use_partial_update=True
)
# Detect OS during reconnaissance
os_detected = recon.detect_os(ip)
if "timed out" in scan_result.get("raw_output", "") or os_detected is None:
logger.log(f"[ERROR] OS detection returned None for IP {ip}. Defaulting to 'Unknown'.")
os_type = "Timeout"
else:
os_type = os_detected
# Parse devices from raw Nmap result
for line in scan_result["raw_output"].split("\n"):
if f"Nmap scan report for {ip}" in line:
# Extract MAC address, vendor, and IP
mac_address = "Unknown"
vendor = "Unknown"
next_lines = scan_result["raw_output"].split("\n")
for next_line in next_lines:
if "MAC Address" in next_line:
mac_address = next_line.split(" ")[2].strip()
vendor = " ".join(next_line.split(" ")[3:]).strip("()")
break
# Append structured data
parsed_devices.append({
"ip": ip,
"mac": mac_address,
"vendor": vendor,
"os_version": os_type
})
# Save parsed devices to the JSON file
scan_result["devices"] = parsed_devices
html_logger.save_scan_result_to_json(ssid, scan_result)
# Vulnerability Scan Phase
vuln_scanner = VulnerabilityScanner(logger=logger)
vulnerabilities = {}
for ip in scan_result["discovered_ips"]:
update_display_state(
display,
state_manager,
"investigating",
current_ssid=ssid,
current_status="Running vulnerability scan",
stats=stats,
use_partial_update=True
)
vuln_results = vuln_scanner.run_scan(ip, ssid=ssid, html_logger=html_logger)
if vuln_results:
stats["vulns"] += len(vuln_results)