#!/bin/python from scapy.all import * ports = range(1,1000) ipdst = "10.0.0.2" for i in ports: pkt=IP(dst=ipdst)/TCP(dport=i, flags="PUF") a = sr1(pkt, verbose=False, timeout=0.1) if a is None: print '{} is open'.format(i)