-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrand
executable file
·90 lines (90 loc) · 1.39 KB
/
rand
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
VERSION=10
NUM=0
LEN=0
MODE=0
LN=0
ALLOW=""
for Y in $@
do
if [ $Y = "-n" ]
then
MODE=1
ALLOW=$ALLOW"0-9"
elif [ $Y = "-s" ]
then
MODE=5
ALLOW=$ALLOW'!@#$%^&*()-_=+'
elif [ $Y = "-l" ]
then
MODE=2
ALLOW=$ALLOW"a-z"
elif [ $Y = "-u" ]
then
MODE=3
ALLOW=$ALLOW"A-Z"
elif [ $Y = "-c" ]
then
ALLOW="0-9A-F"
LEN=6
elif [ $Y = "-X" ]
then
ALLOW='0-9A-Za-z!@#$%^&**()-_=+'
elif [ $Y = "-S" ]
then
ALLOW='0-9A-Za-z'
elif [ $Y = "-B" ]
then
ALLOW='01'
LEN=8
elif [ $Y = "-x" ]
then
ALLOW='0-9A-Fa-f!-.'
elif [[ "$Y" =~ ^[0-9]+$ ]] && [[ LEN -eq 0 ]]
then
LEN=$Y
elif [[ "$Y" =~ ^[0-9]+$ ]] && [[ LEN -gt 0 ]]
then
NUM=$Y
elif [ $Y = "-b" ]
then
MODE=0
elif [ $Y = "-N" ]
then
LN=1
elif [ $Y = "-v" ]
then
echo $VERSION
exit
elif [ $Y = "-D" ]
then
echo $(curl -s "https://www.dinopass.com/password/simple")
exit
else
echo "rand [arg] [length] [number]"
echo "Arguements"
echo -e "rand v$VERSION 2019-05-21\n-b\tbasic\n-X\tcomplex\n-x\treduced complex\n-n\tnumber\n-l\tlowercase\n-u\tuppercase\n-s\tsymbols\n-c\tcolor\n-D\tdinopass\n-B\tbinary\n-S\tSimple"
exit
fi
done
if [ $LEN -eq 0 ]
then
LEN=10
fi
if [ $NUM -eq 0 ]
then
NUM=1
fi
if [ x$ALLOW = "x" ]
then
ALLOW="A-Za-z0-9"
fi
X=0
while [ $X -lt $NUM ]
do
if [ $LN -eq 1 ]
then
printf "%0${#NUM}g: " "$(($X+1))"
fi
</dev/urandom tr -dc $ALLOW | head -c$LEN;echo
let "X++"
done