nmap-pp.py 726 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/python
  2. import sys
  3. import json
  4. from rich.console import Console
  5. from rich.table import Table
  6. import fileinput
  7. console = Console()
  8. table = Table(show_header=True, header_style="bold blue")
  9. table.add_column("Host", style="dim")
  10. table.add_column("Port")
  11. table.add_column("Service")
  12. table.add_column("Version", justify="left")
  13. if len(sys.argv) == 2:
  14. with open(sys.argv[1], "r") as inp_file:
  15. hosts = json.loads(inp_file.read())
  16. else:
  17. hosts = json.loads(sys.stdin.read())
  18. for host in hosts:
  19. for port in host["ports"]:
  20. table.add_row(
  21. host["hostname"],
  22. str(port["port_number"]),
  23. port["service"],
  24. port["version"]
  25. )
  26. console.print(table)