-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter_packet_send.sh
executable file
·45 lines (41 loc) · 1.08 KB
/
filter_packet_send.sh
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
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
help()
{
echo "Syntax: packet_filtering_rules_clean [-h | -d dest. addr | | -p dest. port | -i interface | -s pkt. size]"
echo "options:"
echo "i Interface."
echo "p Destination Port."
echo "d Destination Address."
echo "s Packet Size."
echo "h Print Help."
echo
}
while getopts ":hi:p:d:s:" option; do
case $option in
h)
help
exit;;
i)
destination_ifce=$OPTARG
;;
p)
destination_port=$OPTARG
;;
d)
destination_addr=$OPTARG
;;
s)
generat_pkt_size=$OPTARG
;;
\?)
echo "error, invalid option"
exit;;
esac
done
if [ -z "$destination_port" ] || [ -z "$destination_addr" ] || [ -z "$generat_pkt_size" ] || [ -z "$destination_ifce" ]; then
echo 'missing -i or -s or -d or -p option' >&2
echo
help
exit 1
fi
sudo hping3 -I $destination_ifce --udp --rand-source --destport $destination_port -V -d $generat_pkt_size -i u1 $destination_addr