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

Class PortScannerHostDict

pager_lib/nmap/nmap.py:966–1167  ·  view source on GitHub ↗

Special dictionnary class for storing and accessing host scan result

Source from the content-addressed store, hash-verified

964
965
966class PortScannerHostDict(dict):
967 """
968 Special dictionnary class for storing and accessing host scan result
969
970 """
971
972 def hostnames(self):
973 """
974 :returns: list of hostnames
975
976 """
977 return self["hostnames"]
978
979 def hostname(self):
980 """
981 For compatibility purpose...
982 :returns: try to return the user record or the first hostname of the list hostnames
983
984 """
985 hostname = ""
986 for h in self["hostnames"]:
987 if h["type"] == "user":
988 return h["name"]
989 else:
990 if len(self["hostnames"]) > 0 and "name" in self["hostnames"][0]:
991 return self["hostnames"][0]["name"]
992 else:
993 return ""
994
995 return hostname
996
997 def state(self):
998 """
999 :returns: host state
1000
1001 """
1002 return self["status"]["state"]
1003
1004 def uptime(self):
1005 """
1006 :returns: host state
1007
1008 """
1009 return self["uptime"]
1010
1011 def all_protocols(self):
1012 """
1013 :returns: a list of all scanned protocols
1014
1015 """
1016
1017 def _proto_filter(x):
1018 return x in ["ip", "tcp", "udp", "sctp"]
1019
1020 lp = list(filter(_proto_filter, list(self.keys())))
1021 lp.sort()
1022 return lp
1023

Callers 1

analyse_nmap_xml_scanMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected