Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

& lt;script> Network Host scan (ping)

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

#! / usr/bin/env python#-*- coding: UTF-8-*-import platformimport sysimport osimport timeimport threaddef get_os (): # get os os = platform.system () if os = = "Windows": return "n" else: return "c" def ping_ip (ip_str): # ping ip cmd = ["ping", "- {op}" .format (op=get_os ()), "1" Ip_str] output = os.popen ("" .join (cmd)) .readlines () flag = False for line in list (output): if not line: continue if str (line) .upper () .find ("TTL") > = 0: flag = True break if flag: print "ip:% s is ok * *"% ip_strdef find_ip (ip_prefix): # find all ip of the net for i in range (1 Ip ='% s.% s'% (ip_prefix, I) thread.start_new_thread (ping_ip, (ip) ) time.sleep (0.3) if _ _ name__ = "_ _ main__": print "start time% s"% time.ctime () commandargs = sys.argv [1:] args = ".join (commandargs) ip_prefix = '.join (args.split ('.') [:-1]) find_ip (ip_prefix) print" end time% s "% time.ctime ()

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report