Skip to content

Instantly share code, notes, and snippets.

@fsjorgeluis
Created September 9, 2021 13:48
Show Gist options
  • Save fsjorgeluis/8cc344f1e3f6f6001a83f24dd0a52919 to your computer and use it in GitHub Desktop.
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)
#!/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