Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save system123/b8582b0f13543c0770d0078055066df4 to your computer and use it in GitHub Desktop.
Save system123/b8582b0f13543c0770d0078055066df4 to your computer and use it in GitHub Desktop.
Fun Python & Scapy script that will answer 'SYN ACK' to any TCP 'SYN' packet received on any port

Python - Scapy - Show all your ports as open

#!/usr/local/bin/python2
from scapy.all import *
os.system("iptables -A OUTPUT -p tcp -o eth0 --sport 1:65535 --tcp-flags RST RST -j DROP")
def packet(pkt):
    if pkt[TCP].flags == 2:
        print('SYN packet detected port : ' + str(pkt[TCP].sport) + ' from IP Src : ' + pkt[IP].src)
        send(IP(dst=pkt[IP].src, src=pkt[IP].dst)/TCP(dport=pkt[TCP].sport, sport=pkt[TCP].dport,ack=pkt[TCP].seq + 1, flags='SA'))
sniff(iface="eth0", prn=packet, filter="tcp[0xd]&18=2",count=100)
os.system("iptables -D OUTPUT -p tcp -o eth0 --sport 1:65535 --tcp-flags RST RST -j DROP")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment