Open all PORTS

This multi threaded python script can be used to open a certain range of TCP port of a PC.
If you are conducting network security scans,then its very important to check if your ISP's firewall is filtering any packet/ports or not.Your scan result may contain false+ve if your ISP is blocking any malicious packets.
So you can use the script to open all ports of a sample target and probe the target with various crafted packets.(ex. Nmap,Nessus)
If the scan result returns the expected result,Then its fine,but if you get some ports are closed but,you know that its open then its a thing to worry for security scanning.
You have to change the 2nd last line to select the tcp PORT range.

Here is the python script:

import socket
import thread
from threading import *
def handler(clientsock,addr):
    while 1:
        data = clientsock.recv(BUFSIZ)
        if not data:
def openport(PORT):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    HOST = socket.gethostname()
    #PORT = 1234
    BUFSIZ = 1024
    print 'Listening on port :',PORT
    while 1:
        print 'Waiting for connection:'
        clientsock, addr = s.accept()
        print 'Connected with: ', addr
        thread.start_new_thread(handler, (clientsock, addr))
        for P in range(1,5):    #The port range to open
            thread.start_new_thread(openport, (P,))