PYTHON PORT  SCANNER:

Get free port list in your computer or your friend's computer.... just for fun   PYTHON PORT SCANNER 


  1. import subprocess
  2. from socket import *
  3. busyportlist = []
  4. freeportlist =[]
  5. initport = 0
  6. exitport = 50
  7. for i in range(initport,exitport):
  8.     try:
  9.         soc = socket(AF_INET, SOCK_STREAM)
  10.         result = soc.connect_ex(("hostname/ IP address", i))
  11.         if(result == 0):
  12.             busyportlist.append(i)
  13.             soc.close()
  14.     except :
  15.         print "ERROR:Failed to scan in range specified"
  16. print "BUSY PORT LIST = ",busyportlist
  17. for currport in range(initport,exitport):
  18.     if currport not in busyportlist:
  19.          freeportlist.append(currport)
  20. print "FREE PORT LIST = ",freeportlist
  21. print "SCANNING OVER :)"