官网 https://pypi.org/project/python-nmap/

{'nmap': {'command_line': 'nmap -oX - -n -sP -PE 192.168.1.0/24', 'scaninfo': {}, 'scanstats': {'timestr': 'Wed Oct 23 17:29:13 2019', 'elapsed': '1.07', 'uphosts': '15', 'downhosts': '241', 'totalhosts': '256'}}, 'scan': {'192.168.1.1': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.1'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.43': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.43'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.50': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.50'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.72': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.72'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.74': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.74'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.77': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.77'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.80': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.80'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.103': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.103'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.203': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.203'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.204': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.204'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.211': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.211'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.222': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.222'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.243': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.243'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.245': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.245'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.255': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.255'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}}}
>>> nm.all_hosts()
['192.168.1.1', '192.168.1.103', '192.168.1.203', '192.168.1.204', '192.168.1.211', '192.168.1.222', '192.168.1.243', '192.168.1.245', '192.168.1.255', '192.168.1.43', '192.168.1.50', '192.168.1.72', '192.168.1.74', '192.168.1.77', '192.168.1.80']

相关文章: