#!/usr/bin/python import sys import json from rich.console import Console from rich.table import Table import fileinput console = Console() table = Table(show_header=True, header_style="bold blue") table.add_column("Host", style="dim") table.add_column("Port") table.add_column("Service") table.add_column("Version", justify="left") if len(sys.argv) == 2: with open(sys.argv[1], "r") as inp_file: hosts = json.loads(inp_file.read()) else: hosts = json.loads(sys.stdin.read()) for host in hosts: for port in host["ports"]: table.add_row( host["hostname"], str(port["port_number"]), port["service"], port["version"] ) console.print(table)