MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / export_report

Function export_report

webapp_modern.py:6315–6475  ·  view source on GitHub ↗

Generate and download a self-contained HTML scan report

()

Source from the content-addressed store, hash-verified

6313 except (socket.herror, socket.gaierror):
6314 return ''
6315 except Exception as e:
6316 logger.debug(f"Hostname resolution failed for {ip}: {e}")
6317 return ''
6318
6319
6320def update_vulnerability_output(ip, hostname, mac, is_alive):
6321 """Create or update vulnerability scan results file for discovered host"""
6322 try:
6323 # Ensure vulnerabilities output directory exists
6324 vuln_output_dir = os.path.join('data', 'output', 'vulnerabilities')
6325 os.makedirs(vuln_output_dir, exist_ok=True)
6326
6327 # Create or update vulnerability scan results file for this IP
6328 vuln_file = os.path.join(vuln_output_dir, f'scan_{ip.replace(".", "_")}.txt')
6329
6330 with open(vuln_file, 'w') as f:
6331 f.write(f"# Vulnerability scan results for {ip}\n")
6332 f.write(f"# Hostname: {hostname}\n")
6333 f.write(f"# MAC: {mac}\n")
6334 f.write(f"# Status: {'alive' if is_alive else 'dead'}\n")
6335 f.write(f"# Last updated: {datetime.now().isoformat()}\n")
6336 f.write(f"# Discovered via: ARP/Nmap network scanning\n\n")
6337
6338 if is_alive:
6339 f.write(f"Host {ip} is alive and responding\n")
6340 f.write(f"MAC Address: {mac}\n")
6341 f.write(f"Hostname: {hostname}\n")
6342 f.write(f"Status: ACTIVE\n\n")
6343 f.write(f"=== NETWORK DISCOVERY RESULTS ===\n")
6344 f.write(f"Host discovered through network scanning\n")
6345 f.write(f"Further vulnerability scanning recommended\n")
6346 else:
6347 f.write(f"Host {ip} is not responding\n")
6348 f.write(f"Status: INACTIVE\n")
6349
6350 except Exception as e:
6351 logger.error(f"Error updating vulnerability output for {ip}: {e}")
6352
6353
6354def update_netkb_entry(ip, hostname, mac, is_alive):
6355 try:
6356 # Update vulnerability output files
6357 update_vulnerability_output(ip, hostname, mac, is_alive)
6358
6359 netkb_path = shared_data.netkbfile
6360 os.makedirs(os.path.dirname(netkb_path), exist_ok=True)
6361
6362 rows = []
6363 headers: list[str] = []
6364 updated_row = None
6365
6366 if os.path.exists(netkb_path) and os.path.getsize(netkb_path) > 0:
6367 with open(netkb_path, 'r', encoding='utf-8', errors='ignore') as f:
6368 reader = csv.DictReader(f)
6369 headers = list(reader.fieldnames) if reader.fieldnames else []
6370 for row in reader:
6371 rows.append(row)
6372 else:

Callers

nothing calls this directly

Calls 9

get_all_hostsMethod · 0.80
get_all_credentialsMethod · 0.80
appendMethod · 0.80
extendMethod · 0.80
sortMethod · 0.80
errorMethod · 0.80
eFunction · 0.70
itemsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected