blob: 4921df1365c2d1b233d8d42438337d7d9b49a348 (
plain)
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
|
#/usr/bin/env python
import sys
import socket
def do_flood(host, num):
try:
socket.inet_aton(host)
is_ip4 = True
except socket.error:
try:
socket.inet_pton(socket.AF_INET6, host)
is_ip4 = False
except socket.error:
raise Exception('Invlid ip4/6 address!')
family = socket.AF_INET if is_ip4 else socket.AF_INET6
for port in range(num):
sock = socket.socket(family, socket.SOCK_DGRAM)
sock.sendto('test', (host, port + 1))
if __name__ == '__main__':
if len(sys.argv) < 2:
raise Exception('IP and packet count expected!')
do_flood(sys.argv[1], int(sys.argv[2]))
|