Print scan results in a formatted way
(results)
| 151 | return results |
| 152 | |
| 153 | def print_results(results): |
| 154 | """Print scan results in a formatted way""" |
| 155 | print("\n" + "="*80) |
| 156 | print("SCAN RESULTS") |
| 157 | print("="*80) |
| 158 | |
| 159 | for device in results: |
| 160 | print(f"\nIP Address: {device['ip']}") |
| 161 | print(f"MAC Address: {device['mac']}") |
| 162 | print(f"Vendor: {device['vendor']}") |
| 163 | print(f"Hostname: {device['hostname']}") |
| 164 | |
| 165 | if device['open_ports']: |
| 166 | print("Open Ports:") |
| 167 | for port in device['open_ports']: |
| 168 | print(f" - {port['port']}/{port['protocol']}: {port['service']}") |
| 169 | else: |
| 170 | print("Open Ports: None found") |
| 171 | print("-" * 80) |
| 172 | |
| 173 | def save_results(results, filename='scan_results.json'): |
| 174 | """Save results to JSON file""" |