Author: slac3dork
Site: http://snippet.c0de.me
Summary: Host checker using Ping command. Tested on Linux.
Usage: python muhcot.py <ipaddress> <common-netmask>
#!/usr/bin/python
#
# _________ .__ .____ _______
# / _____/ ____ |__|_____ | | \ _ \ ____
# \_____ \ / \| \____ \| | / /_\ \ / ___\
# / \ | \ | |_> > |__\ \_/ \/ /_/ >
#/_______ /___| /__| __/|_______ \_____ /\___ /
# \/ \/ |__| \/ \//_____/
# http://snippet.c0de.me
# slac3dork[at]gmail[dot]com
import threading
import commands
import sys
from time import sleep
class Checker(threading.Thread):
def __init__(self, host, count=1):
threading.Thread.__init__(self)
self.host = host
self.count = count
self.output = -1
def run(self):
cmd = "ping %s -c%d" %(self.host, self.count)
self.output = commands.getstatusoutput(cmd)
class Address:
def __init__(self, ip, netmask):
self.ip = ip
self.netmask = netmask
def getNetworkAddress(self):
netmask_range = self.netmask.split(".",4)
totalZero = 0
for octet in netmask_range:
if octet == "0":
totalZero += 1
networkAddress = self.ip.rsplit(".",totalZero)
return networkAddress[0]
def welcomeBro():
print "--------------------------"
print "[+] muhcot.py"
print "[+] Multiple host checker tool"
print "[+] by slac3dork"
print "--------------------------\n"
sleep(2)
def errorMessage(netmaskStatus):
print "------------------------------------------------------------"
print "[-]your netmask:",netmaskStatus
print "[-]common netmask class A: 255.0.0.0"
print "[-]common netmask class B: 255.255.0.0"
print "[-]common netmask class C: 255.255.255.0"
print "\n[-]Usage: python muhcot.py <ipaddress> <common-netmask>\n"
print "------------------------------------------------------------"
sys.exit(1)
def checkNetmask(nm):
if (nm == "255.0.0.0") or (nm == "255.255.0.0") or (nm == "255.255.255.0"):
status = 1
if (__name__ == "__main__"):
try:
netmaskStatus = 1
checkNetmask(sys.argv[2])
except:
netmaskStatus = 0
if (len(sys.argv) != 3) or (netmaskStatus == 0):
errorMessage(netmaskStatus)
welcomeBro()
threads = []
ip = sys.argv[1]
netmask = sys.argv[2]
net = Address(ip,netmask)
print "[+]Checking..."
if (netmask == "255.0.0.0"):
for octet2 in range(1,254):
for octet3 in range(1,254):
for octet4 in range(1,254):
host = "%s.%d.%d.%d" %(net.getNetworkAddress(), octet2, octet3, octet4)
thread = Checker(host)
threads.append(thread)
thread.start()
elif (netmask == "255.255.0.0"):
for octet3 in range(1,254):
for octet4 in range(1,254):
host = "%s.%d.%d" %(net.getNetworkAddress(), octet3, octet4)
thread = Checker(host)
threads.append(thread)
thread.start()
elif (netmask == "255.255.255.0"):
for octet4 in range(1,254):
host = "%s.%d" %(net.getNetworkAddress(), octet4)
thread = Checker(host)
threads.append(thread)
thread.start()
for thread in threads:
thread.join()
if (thread.output[0] == 0):
status = "connected"
print "[-]ping %s: %s" %(thread.host, status)
print "[+]done"



