-
Notifications
You must be signed in to change notification settings - Fork 6
/
passgen.sh
197 lines (176 loc) · 4.89 KB
/
passgen.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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/bin/bash
# Password generator with wordlist
name="Passgen.sh"
ver="0.2.1"
author="Gianni 'guelfoweb' Amato"
#
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# [email protected] wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return Gianni 'guelfoweb' Amato
# ----------------------------------------------------------------------------
#
CONFIG="passgen.cfg"
wordlist=`grep "^wordlist=" $CONFIG | cut -d"=" -f2`
newwordlist=`grep "^newwordlist=" $CONFIG | cut -d"=" -f2`
usage(){
echo "$name v.$ver by $author"
echo "https://github.com/guelfoweb/passgen/"
echo
echo "Password generator through a simple wordlist. You can use this tool to create a new wordlist with numbers and special characters."
echo
echo "You must to configure the parameters of the file [passgen.cfg]"
echo
echo "USAGE"
echo " $0"
echo " $0 -i <file input> -o <file output> "
echo
echo "OPTION"
echo " -h this help"
echo " -i file input"
echo " -o file output"
exit
}
ARGC=$#
if [ "$ARGC" -eq 1 ] || [ "$ARGC" -gt 4 ]; then
usage
fi
if [ "$ARGC" -eq 2 ] && [ "$1" == "-i" ]; then
wordlist="$2"
fi
if [ "$ARGC" -eq 2 ] && [ "$1" == "-o" ]; then
newwordlist="$2"
fi
if [ "$ARGC" -eq 4 ] && [ "$1" == "-i" ] && [ "$3" == "-o" ]; then
wordlist="$2"
newwordlist="$4"
fi
if [ "$ARGC" -eq 4 ] && [ "$1" == "-o" ] && [ "$3" == "-i" ]; then
wordlist="$4"
newwordlist="$2"
fi
if [ ! -f "$wordlist" ]; then
echo "File not exist: $wordlist"
exit
fi
chars=`grep "^chars=" $CONFIG | cut -d"=" -f2`
u=`grep "^u=" $CONFIG | cut -d"=" -f2`
nstart=`grep "^nstart=" $CONFIG | cut -d"=" -f2`
nend=`grep "^nend=" $CONFIG | cut -d"=" -f2`
specialchar=(`grep "^specialchar\[[0-9]*\]=" $CONFIG | cut -d"=" -f2`)
format=`grep "^format=" $CONFIG | cut -d"=" -f2`
nelements=`grep "^.\{$chars\}$" "$wordlist" | grep -v "à\|è\|é\|ì\|ò\|ù\|'" | wc -l | cut -d " " -f1 | sed 's/ //'`
nspecials=`grep -c "^specialchar\[[0-9]*\]=" $CONFIG`
echo "[+] Ready for $(( $nelements * $nspecials * ($nend - $nstart + 1) )) passwords"
if $u; then u="."; else u="^"; fi
echo "[+] Password format: $format"
echo -n "[+] Password Type: "
case $format in
wns) head -n1 "$wordlist" | sed "s/\b\($u\)/\u\1/" | sed "s/$/$nstart/" | sed "s/$/$specialchar/" ;;
wsn) head -n1 "$wordlist" | sed "s/\b\($u\)/\u\1/" | sed "s/$/$specialchar/" | sed "s/$/$nstart/" ;;
nws) head -n1 "$wordlist" | sed "s/\b\($u\)/\u\1/" | sed "s/^/$nstart/" | sed "s/$/$specialchar/" ;;
swn) head -n1 "$wordlist" | sed "s/\b\($u\)/\u\1/" | sed "s/$/$nstart/" | sed "s/^/$specialchar/" ;;
nsw) head -n1 "$wordlist" | sed "s/\b\($u\)/\u\1/" | sed "s/^/$specialchar/" | sed "s/^/$nstart/" ;;
snw) head -n1 "$wordlist" | sed "s/\b\($u\)/\u\1/" | sed "s/^/$nstart/" | sed "s/^/$specialchar/" ;;
*) echo "error.."
exit
esac
echo "[+] File output: $newwordlist"
echo
read -p "Press [Enter] key to start or [Ctrl+C] key to stop..."
echo
# Initialize new wordlist
cat /dev/null > $newwordlist
wns(){
grep "^.\{$chars\}$" "$wordlist" | grep -v "à\|è\|é\|ì\|ò\|ù\|'" | sed "s/\b\($u\)/\u\1/" | sort | while read word;
do {
for n in $(seq $nstart $nend)
do
for s in "${specialchar[@]}"
do
echo $word$n$s >> $newwordlist
done
done
}
done
}
wsn(){
grep "^.\{$chars\}$" "$wordlist" | grep -v "à\|è\|é\|ì\|ò\|ù\|'" | sed "s/\b\($u\)/\u\1/" | sort | while read word;
do {
for n in $(seq $nstart $nend)
do
for s in "${specialchar[@]}"
do
echo $word$s$n >> $newwordlist
done
done
}
done
}
nws(){
grep "^.\{$chars\}$" "$wordlist" | grep -v "à\|è\|é\|ì\|ò\|ù\|'" | sed "s/\b\($u\)/\u\1/" | sort | while read word;
do {
for n in $(seq $nstart $nend)
do
for s in "${specialchar[@]}"
do
echo $n$word$s >> $newwordlist
done
done
}
done
}
swn(){
grep "^.\{$chars\}$" "$wordlist" | grep -v "à\|è\|é\|ì\|ò\|ù\|'" | sed "s/\b\($u\)/\u\1/" | sort | while read word;
do {
for n in $(seq $nstart $nend)
do
for s in "${specialchar[@]}"
do
echo $s$word$n >> $newwordlist
done
done
}
done
}
nsw(){
grep "^.\{$chars\}$" "$wordlist" | grep -v "à\|è\|é\|ì\|ò\|ù\|'" | sed "s/\b\($u\)/\u\1/" | sort | while read word;
do {
for n in $(seq $nstart $nend)
do
for s in "${specialchar[@]}"
do
echo $n$s$word >> $newwordlist
done
done
}
done
}
snw(){
grep "^.\{$chars\}$" "$wordlist" | grep -v "à\|è\|é\|ì\|ò\|ù\|'" | sed "s/\b\($u\)/\u\1/" | sort | while read word;
do {
for n in $(seq $nstart $nend)
do
for s in "${specialchar[@]}"
do
echo $s$n$word >> $newwordlist
done
done
}
done
}
started=`date`
echo "Started: $started"
case $format in
wns) wns ;;
wsn) wsn ;;
nws) nws ;;
swn) swn ;;
nsw) nsw ;;
snw) snw ;;
*) echo "error.."
exit
esac
stopped=`date`
echo "Stopped: $stopped"