-
Notifications
You must be signed in to change notification settings - Fork 0
/
knockd_otp.sh
executable file
·60 lines (49 loc) · 902 Bytes
/
knockd_otp.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
IFS=$'\n'
function random() {
echo -ne $(((RANDOM % $1)+1))
}
function random_range() {
r=$(random $2)
while (($r < $1));
do
r=$(random $2)
done
echo -ne $r
}
function random_port() {
echo -ne $(random_range 1024 65535)
}
function random_seq_length() {
echo -ne $(random_range 3 4)
}
#trap '' TERM INT
function usage () {
echo "Generate a knockd one time sequences list"
echo "Usage: `basename $0` -n rows"
echo "-n number of sequences to be generated"
exit 0
}
n_specified=0
# parse command-line arguments
while getopts ":n:" opt
do
case $opt in
n ) n_specified=1
rows=$OPTARG ;;
\?) usage ;;
esac
done
if [ $n_specified -eq 0 ]
then
usage
fi
for (( r=1; r<=$rows; r++ ))
do
echo -ne " "
for (( p=1; p<$(random_seq_length); p++ ))
do
echo -ne $(random_port),
done
echo $(random_port)
done