• Diniz Martins

Python | Subnet Ping

This script will ping and display status of all hosts in a subnet we provide.

import subprocess
import ipaddress
from subprocess import Popen, PIPE
subnet = input("Please enter the network: ")
network = ipaddress.ip_network(subnet)
for i in network.hosts():
    i=str(i)
    toping = subprocess.Popen(['ping', '-c', '3', i], stdout=PIPE)
    output = toping.communicate()[0]
    hostalive = toping.returncode
    if hostalive == 0:
        print(i,'is ' + '\033[92m' + 'reachable' + '\033[0m')
    else:
        print(i,'is ' + '\033[91m' + 'unreachable' + '\033[0m')

That's what the script works:

drm@STENGE % python3 ping-subnet.py
Please enter the network: 192.168.0.0/29
192.168.0.1 is reachable
192.168.0.2 is unreachable
192.168.0.3 is reachable
192.168.0.4 is reachable
192.168.0.5 is reachable
192.168.0.6 is reachable
drm@STENGE % 


49 views0 comments

Recent Posts

See All

BF | Brainfuck

Brainfuck is an esoteric programming language created in 1993 by Urban Müller. Notable for its extreme minimalism, the language consists of only eight simple commands and an instruction pointer. While

Admin-Scanner

This tool is design to find Admin Panel of any website by using custom wordlist or default wordlist easily. Grab the result and paste to your web browser: How to install: Usages: -site <url of website

BAP – Basic Auth Pot | HoneyPot

What is a honeypot? A honeypot is a computer or computer system intended to mimic likely targets of cyberattacks. It can be used to detect attacks or deflect them from a legitimate target. It can also