In this post we will speak about how create Ip Scanner in python 3
i will use threading to make scann faster , and Platform to check whitch Operating system is it and Os to exe Command .
First thing for every system Administrator or hacking make scan for network .
Today we will create first script in python to scan Network and found all ip Address
from datetime import datetime
from queue import Queue
net = input("Enter the IP address: ")
st1 = int(input("Enter the Starting Number: "))
en1 = int(input("Enter the Last Number: "))
def Ip_Scanner(host_ip,host,ping1): print_lock = threading.Lock() try: addr = host_ip + str(host) comm = ping1 + addr response = os.popen(comm) for line in response.readlines(): if (line.count("TTL") or line.count("ttl") ): print (addr, "--> Live") except: pass
worker = q.get()
def main_Ip_Scanner(net,st1,en1): net1= net.split('.') a = '.' net2 = net1 + a + net1 + a + net1 + a en1 = en1 + 1 oper = platform.system() if (oper == "Windows"): ping1 = "ping -n 1 " elif (oper == "Linux"): ping1 = "ping -c 1 " else : ping1 = "ping -c 1 " t1 = datetime.now() print ("\nScanning in Progress:\n") # how many threads are we going to allow for for x in range(100): t = threading.Thread(target=threader, args=(net2,ping1,)) # classifying as a daemon, so they will die when the main dies t.daemon = True
# begins, must come after daemon definition t.start()for worker in range(st1,en1): q.put(worker) #wait until the thread terminates. q.join() t2 = datetime.now() total = t2 - t1 print ("Scanning completed in: ",total)
q = Queue()