Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Port Scanner HomeMade - Python Code Bank


Port Scanner HomeMade
Scan ports of PCs connected to your network. OS : Windows 7 Python Version : 2.7 Youl will find the results on ports.txt file
                # Made by Shakil
# Port Scanner Python
import urllib2
import socket
from urllib2 import URLError
import os

def cmd(x):
    os.system(x)

def echop(x):
    x="echo "+x+">>ports.txt"
    cmd(x)

read=raw_input


def prt1():
    print "Your IP should be start with http or ftp"
    x=read("Enter IP to scan port : ")
    if x[:6]=="ftp://":
        prt2(x)
    elif x[:7]=="http://":
        prt2(x)
    elif x[:8]=="https://":
        prt2(x)
    else:
        print "Sorry Dude"

def prt2(x):
    for i in range(65535):
        scanport(x,str(i))

def scanport(x,i):
    url=x+":"+i
    try:
        urllib2.urlopen(url, timeout=2)
        print url,": I am on"
        echop(url+": I am on")
    except urllib2.HTTPError, e:
        print url," No"
    except urllib2.URLError, e:
        print url," No"
    except socket.timeout as e:
        print url," No"
prt1()

            
Comments
Sorry but there are no comments to display