#!/usr/bin/env python import sys from scapy.all import * def synscan(host): ports = range(1000) ip = IP(dst=host) tcp = TCP(dport=ports,flags="S") ans,unans = sr(ip/tcp) for sent,rcvd in ans: if rcvd.haslayer(TCP): # if rcvd.getlayer(TCP).flags & 2: if rcvd.sprintf("%TCP.flags%") == 'SA': print sent.dport synscan("192.168.0.1")