Created
September 9, 2021 13:48
-
-
Save fsjorgeluis/8cc344f1e3f6f6001a83f24dd0a52919 to your computer and use it in GitHub Desktop.
ping to array of ip, starting on 2 and finishing on 255, (customizable range)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import sys, subprocess | |
if len(sys.argv) != 2: | |
print ("ping_sweep.py 192.168.254.") | |
else : | |
cmdping = "ping -c 2 "+sys.argv[1] | |
for x in range(2,32): # 1, 255 | |
p = subprocess.Popen(cmdping+str(x), shell = True, stderr = subprocess.PIPE) | |
while True: | |
out = p.stderr.read(1) | |
if out == b'' and p.poll() != None: | |
break | |
if out != '': | |
sys.stdout.write(out.decode(sys.stdout.encoding)) | |
sys.stdout.flush() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment