Python Ip Scanner – part 1

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

Download Script

import platform
import os
from datetime import datetime
import threading
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()
       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")
def threader(net2,ping1):
while True:
worker = q.get()
def main_Ip_Scanner(net,st1,en1):

    net1= net.split('.')

    a = '.'

    net2 = net1[0] + a + net1[1] + a + net1[2] + 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 =

    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):
     #wait until the thread terminates.
     t2 =
     total = t2 - t1
     print ("Scanning completed in: ",total)
q = Queue()

Leave a Reply

Back to top button