-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathwlm.sh
executable file
·2771 lines (2671 loc) · 82.6 KB
/
wlm.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# Word List Manipulator (wlm)
# Version 0.9 last edit 13-05-2013 23:00
# Build: 0905
# Credits to ;
# ============
# Gitsnik, because he's awesome :)
# Pureh@te as used and learned a lot from his wordlist_tool script.
# Members at unix.com, have always received expert help there.
# http://cfajohnson.com/shell/ssr/08-The-Dating-Game.shtml for datelist updates.
# Google ;)
# =============
# Google code source: http://code.google.com/p/wordlist-manipulator/source/browse/wlm
#
#FIXED SETTINGS
RED=$(tput setaf 1 && tput bold)
GREEN=$(tput setaf 2 && tput bold)
STAND=$(tput sgr0)
BLUE=$(tput setaf 6 && tput bold)
CURR_VERS=$(sed -n 3p $0 | cut -c 11-13)
CURR_BUILD=$(sed -n 4p $0 | cut -c 10-13)
#
#Check if running as root
if [[ $UID -ne 0 ]]; then
echo "$GREEN$0$STAND should be run as root for best / most stable results."
echo -ne "Continue anyway ? y/n "
read proceed
if [[ "$proceed" == "y" || "$proceed" == "Y" ]] ; then
echo
else
exit 1
fi
fi
#
#
#--------------
# MENU ITEM 1
#==============
# CASE OPTIONS
###############
function f_case {
clear
echo $STAND"Wordlist Manipulator"
echo $BLUE"Case options"
echo $STAND"--------------------"
echo "1 Change case of first letter
2 Change case of last letter
3 Change all lower case to upper case
4 Change all upper case to lower case
5 Invert case (lower to upper, upper to lower)
Q Back to menu
"
echo -ne $STAND"Enter choice from above menu: "$GREEN
read case_menu
if [ "$case_menu" == "q" ] || [ "$case_menu" == "Q" ] ; then
echo $STAND""
f_menu
elif [[ "$case_menu" != [1-5] ]]; then
echo $RED"must be an entry from the above menu $STAND"
sleep 1
f_case
fi
#
# Option 1
# Changing first letter to lower or upper case
# --------------------------------------------
if [ $case_menu = "1" ] ; then
echo ""
echo $BLUE"Change first letter to lower case or upper case"$STAND
echo $STAND""
f_inout
echo -ne $STAND"Change all first letters to upper case or lower case ? U / L "$GREEN
read first_letter
until [[ "$first_letter" == "u" ]] || [[ "$first_letter" == "l" ]] || [[ "$first_letter" == "U" ]] || [[ "$first_letter" == "L" ]] ; do
echo -ne $RED"Please enter either U or L for upper or lower case$STAND U / L "$GREEN
read first_letter
done
echo $STAND"Working .."
if [ "$first_letter" == "l" ] || [ "$first_letter" == "L" ] ; then
sudo sed 's/^./\l&/' $wlm_infile > $wlm_outfile
elif [ "$first_letter" == "u" ] || [ "$first_letter" == "U" ] ; then
sudo sed 's/^./\u&/' $wlm_infile > $wlm_outfile
fi
echo $STAND""
f_complete
#
# Option 2
# Changing last letter to lower or upper case
# -------------------------------------------
elif [ $case_menu = "2" ] ; then
echo ""
echo $BLUE"Change last letter to lower case or upper case"$STAND
echo $STAND""
f_inout
echo -ne $STAND"Change all last letters to upper case or lower case ? U / L "$GREEN
read last_letter
until [[ "$last_letter" == "u" ]] || [[ "$last_letter" == "l" ]] || [[ "$last_letter" == "U" ]] || [[ "$last_letter" == "L" ]] ; do
echo -ne $RED"Please enter either U or L for upper or lower case$STAND U / L "$GREEN
read last_letter
done
echo $STAND"Working .."
if [ "$last_letter" == "l" ] || [ "$last_letter" == "L" ] ; then
sudo sed 's/.$/\l&/' $wlm_infile > $wlm_outfile
elif [ "$last_letter" == "u" ] || [ "$last_letter" == "U" ] ; then
sudo sed 's/.$/\u&/' $wlm_infile > $wlm_outfile
fi
echo $STAND""
f_complete
#
# Option 3
# Change all lower case to upper case
# -----------------------------------
elif [ $case_menu = "3" ] ; then
echo ""
echo $BLUE"Change all lower case to Upper case"$STAND
echo $STAND""
f_inout
echo $STAND"Working .."
sudo tr '[:lower:]' '[:upper:]' < $wlm_infile > $wlm_outfile
echo $STAND""
f_complete
#
# Option 4
# Change all upper case to lower case
# -----------------------------------
elif [ $case_menu = "4" ] ; then
echo ""
echo $BLUE"Change all Upper case to lower case"$STAND
echo $STAND""
f_inout
echo $STAND"Working .."
sudo tr '[:upper:]' '[:lower:]' < $wlm_infile > $wlm_outfile
echo $STAND""
f_complete
#
# Option 5
# Invert case from original input
# --------------------------------
elif [ $case_menu = "5" ] ; then
echo ""
echo $BLUE"Invert case from original input"$STAND
echo $STAND""
f_inout
echo $STAND"Working .."
sudo tr 'a-z A-Z' 'A-Z a-z' < $wlm_infile > $wlm_outfile
echo $STAND""
f_complete
fi
}
#
#
#--------------
# MENU ITEM 2
#==============
# COMBINATION OPTIONS
#####################
f_combine () {
clear
echo $STAND"Wordlist Manipulator"
echo $BLUE"Combination options"
echo $STAND"--------------------"
echo "1 Combine words from 1 list to each word in another list
2 Combine all wordlists in a directory to 1 wordlist
Q Return to menu
"
echo -ne $STAND"Enter choice from above menu: "$GREEN
read comb_menu
if [ "$comb_menu" == "q" ] || [ "$comb_menu" == "Q" ] ; then
echo $STAND""
f_menu
elif [[ "$comb_menu" != [1-2] ]]; then
echo $RED"must be an entry from the above menu $STAND"
sleep 1
f_combine
fi
#
# Option 1
# Combine words from 1 list to each word in another list
# ------------------------------------------------------
if [ "$comb_menu" == "1" ] ; then
echo ""
echo $BLUE"Combine words from one wordlist to all words in another wordlist"
echo $STAND""
echo -ne $STAND"Enter /path/to/wordlist to which you want words appended: "$GREEN
read comb_infile1
while [ ! -f $comb_infile1 ] ; do
echo -ne $RED"File does not exist, enter /path/to/file: "$GREEN
read comb_infile1
done
echo -ne $STAND"Enter /path/to/wordlist to append to $BLUE$comb_infile1$STAND: "$GREEN
read comb_infile2
while [ ! -f $comb_infile2 ] ; do
echo -ne $RED"File does not exist, enter /path/to/file: "$GREEN
read comb_infile2
done
echo -ne $STAND"Enter desired output file name: "$GREEN
read wlm_outfile
if [ -f $wlm_outfile ] ; then
echo -ne $RED"File already exists, overwrite ? y/n "$GREEN
read over
if [ "$over" == "y" ] || [ "$over" == "Y" ] ; then
echo $RED"Existing file $GREEN$wlm_outfile$RED will be overwritten"
sleep 1
else
echo $STAND"Process cancelled, returning to menu"
f_menu
fi
fi
echo $STAND"Working .."
sudo awk > $wlm_outfile 'NR == FNR {
l2[FNR] = $0
fnr = FNR; next
}
{
for (i = 0; ++i <= fnr;)
print $0 l2[i]
}' $comb_infile2 $comb_infile1
echo $STAND""
f_complete
#
# Option 2
# Combine all wordlists in a directory
# ------------------------------------
elif [ "$comb_menu" == "2" ] ; then
echo ""
echo $BLUE"Combine all wordlists in a directory to 1 wordlist."
echo $STAND""
echo -ne $STAND"Enter directory where the wordlists are stored \n(ie. /root/wordlists) : "$GREEN
read directory
while [ ! -d "$directory" ] || [ "$directory" == "" ] ; do
echo $RED"Directory does not exist or cannot be found"$STAND
echo -ne $STAND"Enter existing directory: "
read directory
done
ls $directory > files_temp
echo $STAND"! Note that ALL files in directory $GREEN$directory$STAND will be combined;"$BLUE
cat files_temp
echo $STAND""
echo -ne $STAND"Continue or Quit ? C / Q "$GREEN
read go_for_it
if [ "$go_for_it" == "c" ] || [ "$go_for_it" == "C" ] ; then
rm files_temp
echo $STAND ""
else
echo $STAND""
echo "Quitting .."
rm files_temp
sleep 0.5
exit
fi
echo -ne $STAND"Enter desired output file name: "$GREEN
read wlm_outfile
if [ -f $wlm_outfile ] ; then
echo -ne $RED"File already exists, add data to existing file ? y/n "$GREEN
read over
if [ "$over" == "y" ] || [ "$over" == "Y" ] ; then
echo $STAND"Working.."
sleep 1
else
echo $STAND"Process cancelled, returning to menu"
sleep 1
f_menu
fi
fi
sudo cat $directory/* >> "$wlm_outfile"
echo $STAND""
f_complete
fi
}
#
#
#--------------
# MENU ITEM 3
#============
# PREPENDING / PREFIXING OPTIONS
################################
f_prefix () {
clear
echo $STAND"Wordlist Manipulator"
echo $BLUE"Prefix options"
echo $STAND"--------------------"
echo "1 Prefix numeric values in sequence to a wordlist (ie. 0 - 99999)
2 Prefix fixed number of numeric values in sequence to a wordlist (ie. 00000 - 99999)
3 Prefix word / characters to a wordlist
Q Back to menu"
echo -ne $STAND"Enter choice from above menu: "$GREEN
read pref_menu
if [ "$pref_menu" == "q" ] || [ "$pref_menu" == "Q" ] ; then
echo $STAND""
f_menu
elif [[ "$pref_menu" != [1-3] ]]; then
echo $RED"must be an entry from the above menu $STAND"
sleep 1
f_prefix
fi
#
# Option 1
# Prefix numbers in sequence to a list
# ------------------------------------
if [ "$pref_menu" == "1" ] ; then
echo $STAND""
echo $BLUE"Prefix numeric values in sequence to a wordlist (ie. 0 - 99999)"
echo $STAND""
echo -ne $STAND"Enter /path/to/wordlist to prefix numbers to: "$GREEN
read pref_nums
while [ ! -f "$pref_nums" ] ; do
echo -ne $RED"File does not exist, enter /path/to/file: "$GREEN
read pref_nums
done
#Check if any '%' characters in the file which could cause errors
grep "%" $pref_nums > prefnums_errors
exist=$(sed -n '$=' prefnums_errors)
if [ "$exist" == "" ] ; then
rm prefnums_errors
elif [ "$exist" != "" ] ; then
echo $RED"Lines with '%' character exist in file which will not be processed"
echo -ne $STAND"View these lines ? y/n "$GREEN
read view
if [ "$view" == "y" ] || [ "$view" == "Y" ] ; then
cat prefnums_errors
else
echo $STAND""
fi
rm prefnums_errors
fi
#
#Enter output file to write the changes to
echo -ne $STAND"Enter desired output file name: "$GREEN
read pref_nums_out
if [ -f "$pref_nums_out" ] ; then
echo -ne $RED"File already exists, overwrite ? y/n "$GREEN
read over
if [ "$over" == "y" ] || [ "$over" == "Y" ] ; then
echo $RED"Existing file $GREEN$pref_nums_out$RED will be overwritten"$STAND
else
echo $STAND"Process cancelled, returning to menu"
sleep 1
f_menu
fi
fi
echo -ne $STAND"Enter how many numeric values you want to Prefix (max 5): "$GREEN
read numbs
echo $STAND"Working .."
if [ "$numbs" == 1 ] ; then
for i in $(cat $pref_nums); do seq -f "%01.0f$i" 0 9; done > "$pref_nums_out"
elif [ "$numbs" == 2 ] ; then
for i in $(cat $pref_nums); do seq -f "%01.0f$i" 0 99; done > "$pref_nums_out"
elif [ "$numbs" == 3 ] ; then
for i in $(cat $pref_nums); do seq -f "%01.0f$i" 0 999; done > "$pref_nums_out"
elif [ "$numbs" == 4 ] ; then
for i in $(cat $pref_nums); do seq -f "%01.0f$i" 0 9999; done > "$pref_nums_out"
elif [ "$numbs" == 5 ] ; then
for i in $(cat $pref_nums); do seq -f "%01.0f$i" 0 99999; done > "$pref_nums_out"
fi
echo $STAND""
echo "$GREEN$pref_nums_out$STAND has been created; "
head -n 3 $pref_nums_out
echo ".."
tail -n 3 $pref_nums_out
echo $STAND""
echo -ne $STAND"hit Enter to return to menu or q/Q to quit "$GREEN
read return
if [ "$return" == "" ] ; then
echo $STAND""
elif [ "$return" == "q" ] || [ "$return" == "Q" ]; then
echo $STAND""
exit
fi
#
# Option 2
# Prefix fixed number of numberic values to a list
# ------------------------------------------------
elif [ "$pref_menu" == "2" ] ; then
echo $STAND""
echo $BLUE"Prefix fixed number of numeric values in sequence to a wordlist (ie. 00000 - 99999)"
echo $STAND""
echo -ne $STAND"Enter /path/to/wordlist to prefix numbers to: "$GREEN
read pref_numf
while [ ! -f $pref_numf ] ; do
echo -ne $RED"File does not exist, enter /path/to/file: "$GREEN
read $pref_numf
done
#Check if any '%' characters in the file which could cause errors
grep "%" $pref_numf > prefnumf_errors
exist=$(sed -n '$=' prefnumf_errors)
if [ "$exist" == "" ] ; then
rm prefnumf_errors
elif [ "$exist" != "" ] ; then
echo $RED"Lines with '%' character exist in file which will not be processed"
echo -ne $STAND"View these lines ? y/n "$GREEN
read view
if [ "$view" == "y" ] || [ "$view" == "Y" ] ; then
cat prefnumf_errors
else
echo $STAND""
fi
rm prefnumf_errors
fi
#
#Enter output file to write the changes to
echo -ne $STAND"Enter desired output file name: "$GREEN
read pref_numf_out
if [ -f $pref_numf_out ] ; then
echo -ne $RED"File already exists, overwrite ? y/n "$GREEN
read over
if [ "$over" == "y" ] || [ "$over" == "Y" ] ; then
echo $RED"Existing file $GREEN$pref_numf_out$RED will be overwritten"$STAND
else
echo $STAND"Process cancelled, returning to menu "
sleep 1
f_menu
fi
fi
echo -ne $STAND"Enter how many numeric values you want to Prefix (max 5): "$GREEN
read numbf
echo $STAND"Working .."
if [ "$numbf" == 1 ] ; then
for i in $(cat $pref_numf); do seq -f "%0$numbf.0f$i" 0 9; done > "$pref_numf_out"
elif [ "$numbf" == 2 ] ; then
for i in $(cat $pref_numf); do seq -f "%0$numbf.0f$i" 0 99; done > "$pref_numf_out"
elif [ "$numbf" == 3 ] ; then
for i in $(cat $pref_numf); do seq -f "%0$numbf.0f$i" 0 999; done > "$pref_numf_out"
elif [ "$numbf" == 4 ] ; then
for i in $(cat $pref_numf); do seq -f "%0$numbf.0f$i" 0 9999; done > "$pref_numf_out"
elif [ "$numbf" == 5 ] ; then
for i in $(cat $pref_numf); do seq -f "%0$numbf.0f$i" 0 99999; done > "$pref_numf_out"
fi
echo $STAND""
echo "$GREEN$pref_numf_out$STAND has been created; "
head -n 3 $pref_numf_out
echo ".."
tail -n 3 $pref_numf_out
echo $STAND""
echo -ne $STAND"hit Enter to return to menu or q/Q to quit "$GREEN
read return
if [ "$return" == "" ] ; then
echo $STAND""
elif [ "$return" == "q" ] || [ "$return" == "Q" ]; then
echo $STAND""
exit
fi
#
# Option 3
# Prefix word / characters to a list
# ----------------------------------
elif [ "$pref_menu" == "3" ] ; then
echo $STAND""
echo $BLUE"Prefix word / characters to a wordlist"
echo $STAND""
f_inout
echo -ne $STAND"Enter word/characters you want prefixed: "$GREEN
read pref_char
echo $STAND"Working .."
sudo sed "s/^./"$pref_char"&/" "$wlm_infile" > "$wlm_outfile"
echo $STAND""
f_complete
fi
}
#
#
#------------
# MENU ITEM 4
#============
# APPENDING / SUFFIXING OPTIONS
###############################
f_suffix () {
clear
echo $STAND"Wordlist Manipulator"
echo $BLUE"Suffix options"
echo $STAND"--------------------"
echo "1 Suffix numeric values in sequence to a wordlist (ie. 0 - 99999)
2 Suffix fixed number of numeric values in sequence to a wordlist (ie. 00000 - 99999)
3 Suffix word / characters to a wordlist
Q Back to menu
"
echo -ne $STAND"Enter choice from above menu: "$GREEN
read suf_menu
if [ "$suf_menu" == "q" ] || [ "$suf_menu" == "Q" ] ; then
echo $STAND""
f_menu
elif [[ "$suf_menu" != [1-3] ]]; then
echo $RED"must be an entry from the above menu $STAND"
sleep 1
f_suffix
fi
#
# Option 1
# Suffix numbers in sequence to a list
# ------------------------------------
if [ "$suf_menu" == "1" ] ; then
echo $STAND""
echo $BLUE"Suffix numeric values in sequence to a wordlist (ie. 0 - 99999)"
echo $STAND""
echo -ne $STAND"Enter /path/to/wordlist to suffix numbers to: "$GREEN
read suf_nums
while [ ! -f $suf_nums ] ; do
echo -ne $RED"File does not exist, enter /path/to/file: "$GREEN
read suf_nums
done
#Check if any '%' characters in the file which could cause errors
grep "%" $suf_nums > sufnums_errors
exist=$(sed -n '$=' sufnums_errors)
if [[ "$exist" == "" ]] ; then
rm sufnums_errors
elif [ "$exist" != "" ] ; then
echo $RED"Lines with '%' character exist in file which will not be processed"
echo -ne $STAND"View these lines ? y/n "$GREEN
read view
if [ "$view" == "y" ] || [ "$view" == "Y" ] ; then
cat sufnums_errors
else
echo $STAND""
fi
rm sufnums_errors
fi
#Enter output file to write the changes to
echo -ne $STAND"Enter desired output file name: "$GREEN
read suf_nums_out
if [ -f $suf_nums_out ] ; then
echo -ne $RED"File already exists, overwrite ? y/n "$GREEN
read over
if [ "$over" == "y" ] || [ "$over" == "Y" ] ; then
echo $RED"Existing file $GREEN$suf_nums_out$RED will be overwritten"$STAND
else
echo $STAND"Process cancelled, returning to menu"
sleep 1
f_menu
fi
fi
echo -ne $STAND"Enter how many numeric values you want to suffix (max 5): "$GREEN
read numbs
echo $STAND"Working .."
if [ "$numbs" == 1 ] ; then
for i in $(cat $suf_nums); do seq -f "$i%01.0f" 0 9; done > "$suf_nums_out"
elif [ "$numbs" == 2 ] ; then
for i in $(cat $suf_nums); do seq -f "$i%01.0f" 0 99; done > "$suf_nums_out"
elif [ "$numbs" == 3 ] ; then
for i in $(cat $suf_nums); do seq -f "$i%01.0f" 0 999; done > "$suf_nums_out"
elif [ "$numbs" == 4 ] ; then
for i in $(cat $suf_nums); do seq -f "$i%01.0f" 0 9999; done > "$suf_nums_out"
elif [ "$numbs" == 5 ] ; then
for i in $(cat $suf_nums); do seq -f "$i%01.0f" 0 99999; done > "$suf_nums_out"
fi
echo $STAND""
echo "$GREEN$suf_nums_out$STAND has been created; "
head -n 3 $suf_nums_out
echo ".."
tail -n 3 $suf_nums_out
echo $STAND""
echo -ne $STAND"hit Enter to return to menu or q/Q to quit "$GREEN
read return
if [ "$return" == "" ] ; then
echo $STAND""
elif [ "$return" == "q" ] || [ "$return" == "Q" ]; then
echo $STAND""
exit
fi
#
# Option 2
# Suffix fixed number of numberic values to a list
# ------------------------------------------------
elif [ "$suf_menu" == "2" ] ; then
echo $STAND""
echo $BLUE"Suffix fixed number of numeric values in sequence to a wordlist (ie. 00000 - 99999)"
echo $STAND""
echo -ne $STAND"Enter /path/to/wordlist to suffix numbers to: "$GREEN
read suf_numf
while [ ! -f $suf_numf ] ; do
echo -ne $RED"File does not exist, enter /path/to/file: "$GREEN
read suf_numf
done
#Check if any '%' characters in the file which could cause errors
grep "%" $suf_numf > sufnumf_errors
exist=$(sed -n '$=' sufnumf_errors)
if [ "$exist" == "" ] ; then
rm sufnumf_errors
elif [ "$exist" != "" ] ; then
echo $RED"Lines with '%' character exist in file which will not be processed"
echo -ne $STAND"View these lines ? y/n "$GREEN
read view
if [ "$view" == "y" ] || [ "$view" == "Y" ] ; then
cat sufnumf_errors
else
echo $STAND""
fi
rm sufnumf_errors
fi
#Enter output file to write the changes to
echo -ne $STAND"Enter desired output file name: "$GREEN
read suf_numf_out
if [ -f $suf_numf_out ] ; then
echo -ne $RED"File already exists, overwrite ? y/n "$GREEN
read over
if [ "$over" == "y" ] || [ "$over" == "Y" ] ; then
echo $RED"Existing file $GREEN$suf_numf_out$RED will be overwritten"$STAND
else
echo $STAND"Process cancelled, returning to menu"
sleep 1
f_menu
fi
fi
echo -ne $STAND"Enter how many numeric values you want to Suffix (max 5): "$GREEN
read numbf
echo $STAND"Working .."
if [ "$numbf" == 1 ] ; then
for i in $(cat $suf_numf); do seq -f "$i%0$numbf.0f" 0 9; done > "$suf_numf_out"
elif [ "$numbf" == 2 ] ; then
for i in $(cat $suf_numf); do seq -f "$i%0$numbf.0f" 0 99; done > "$suf_numf_out"
elif [ "$numbf" == 3 ] ; then
for i in $(cat $suf_numf); do seq -f "$i%0$numbf.0f" 0 999; done > "$suf_numf_out"
elif [ "$numbf" == 4 ] ; then
for i in $(cat $suf_numf); do seq -f "$i%0$numbf.0f" 0 9999; done > "$suf_numf_out"
elif [ "$numbf" == 5 ] ; then
for i in $(cat $suf_numf); do seq -f "$i%0$numbf.0f" 0 99999; done > "$suf_numf_out"
fi
echo $STAND""
echo "$GREEN$suf_numf_out$STAND has been created; "
head -n 3 $suf_numf_out
echo ".."
tail -n 3 $suf_numf_out
echo $STAND""
echo -ne $STAND"hit Enter to return to menu or q/Q to quit "$GREEN
read return
if [ "$return" == "" ] ; then
echo $STAND""
elif [ "$return" == "q" ] || [ "$return" == "Q" ]; then
echo $STAND""
exit
fi
#
# Option 3
# Suffix word / characters to a list
# ----------------------------------
elif [ "$suf_menu" == "3" ] ; then
echo $STAND""
echo $BLUE"Suffix word / characters to a wordlist"
echo $STAND""
f_inout
echo -ne $STAND"Enter word/characters you want suffixed: "$GREEN
read suf_char
echo $STAND"Working .."
sudo sed "s/.$/&"$suf_char"/" "$wlm_infile" > "$wlm_outfile"
echo $STAND""
f_complete
fi
}
#
#
#------------
# MENU ITEM 5
#============
# INCLUDING CHARACTERS /WORD
############################
f_inclu () {
clear
echo $STAND"Wordlist Manipulator"
echo $BLUE"Inclusion options"
echo $STAND"--------------------"
echo "1 Include characters/word as from a certain position from START of word.
2 Include characters as from a certain position from END of word.
Q Back to menu
"
echo -ne $STAND"Enter choice from above menu: "$GREEN
read incl_menu
if [ "$incl_menu" == "q" ] || [ "$incl_menu" == "Q" ] ; then
echo $STAND""
f_menu
elif [[ "$incl_menu" != [1-2] ]]; then
echo $RED"must be an entry from the above menu $STAND"
sleep 1
f_inclu
fi
#
# Option 1
# Include characters from start of word
# -------------------------------------
if [ "$incl_menu" == "1" ] ; then
echo $STAND""
echo $BLUE"Include characters/word as from a certain position from START of word"
echo $STAND""
f_inout
echo -ne $STAND"Enter the word/characters you want included in each word: "$GREEN
read inclu_char
echo -ne $STAND"Enter from what position (after how many characters)
the word/characters should be included: "$GREEN
read inclus_pos
echo $STAND"Working .."
sudo sed "s/^.\{$inclus_pos\}/&$inclu_char/" "$wlm_infile" > "$wlm_outfile"
echo $STAND""
f_complete
#
# Option 2
# Include Characters
# ------------------
elif [ "$incl_menu" == "2" ] ; then
echo $STAND""
echo $BLUE"Include characters as from a certain position from END of word"
echo $STAND
f_inout
echo -ne $STAND"Enter the word/characters you want included in each word: "$GREEN
read inclu_char
echo -ne $STAND"Enter before what position (before how many characters before end of word)
the word/characters should be included: "$GREEN
read inclus_pos
echo $STAND"Working .."
sudo sed "s/.\{$inclus_pos\}$/$inclu_char&/" "$wlm_infile" > "$wlm_outfile"
echo $STAND""
f_complete
fi
}
#
#
#------------
# MENU ITEM 6
#============
# SUBSTITION OPTIONS
####################
f_subs () {
clear
echo $STAND"Wordlist Manipulator"
echo $BLUE"Substitution options"
echo $STAND"--------------------"
echo "1 Substitute/Replace characters from START of word.
2 Substitute/Replace characters from END of word.
3 Substitute/Replace characters at a certain position.
Q Back to menu
"
echo -ne $STAND"Enter choice from above menu: "$GREEN
read subs_menu
if [ "$subs_menu" == "q" ] || [ "$subs_menu" == "Q" ] ; then
echo $STAND""
f_menu
elif [[ "$subs_menu" != [1-3] ]]; then
echo $RED"must be an entry from the above menu $STAND"
sleep 1
f_subs
fi
#
# Option 1
# Substitute characters from start of word
# ----------------------------------------
if [ "$subs_menu" == "1" ] ; then
echo $STAND""
echo $BLUE"Substitute/Replace characters from START of word"
echo $STAND""
f_inout
echo -ne $STAND"Enter the word/characters you want to replace substituted characters with: "$GREEN
read subs_char
echo -ne $STAND"Enter the number of characters from start of word to replace: "$GREEN
read subs_num
echo $STAND"Working .."
sudo sed "s/^.\{$subs_num\}/$subs_char/" "$wlm_infile" > "$wlm_outfile"
echo $STAND""
f_complete
#
# Option 2
# Substitute characters before end of word
# ----------------------------------------
elif [ "$subs_menu" == "2" ] ; then
echo $STAND""
echo $BLUE"Substitute/Replace characters from END of word"
echo $STAND""
f_inout
echo -ne $STAND"Enter the word/characters you want to replace the sustituted characters with: "$GREEN
read subs_char
echo -ne $STAND"Enter the number of characters at the end of word you want to replace: "$GREEN
read subs_num
echo $STAND"Working .."
sudo sed "s/.\{$subs_num\}$/$subs_char/" "$wlm_infile" > "$wlm_outfile"
echo $STAND""
f_complete
#
# Option 3
# Substitute / replace characters in a certain position
# -----------------------------------------------------
elif [ "$subs_menu" == "3" ] ; then
echo $STAND""
echo $BLUE"Substitute/Replace characters at a certain position"
echo $STAND""
f_inout
echo -ne $STAND"Enter the word/characters you want to replace the sustituted characters with: "$GREEN
read subs_char
echo -ne $STAND"Enter the start position of characters you want to replace (ie. 2)
(position 1 will start from 2nd character, position 4 will start from 5th character, etc): "$GREEN
read subs_poss
echo -ne $STAND"Enter how many characters after start position you want to replace (ie.2); "$GREEN
read subs_pose
echo $STAND"Working .."
sudo sed -r "s/^(.{$subs_poss})(.{$subs_pose})/\1$subs_char/" "$wlm_infile" > "$wlm_outfile"
echo $STAND""
f_complete
fi
}
#
#
#------------
# MENU ITEM 7
#============
# OPTIMIZATION OPTIONS
######################
f_tidy () {
clear
echo $STAND"Wordlist Manipulator"
echo $BLUE"Optimization options"
echo $STAND"--------------------"
echo "1 Full optimization of wordlist.
2 Optimize wordlist for WPA.
3 Sort wordlist on length of words.
Q Back to menu
"
echo -ne $STAND"Enter choice from above menu: "$GREEN
read tidy_menu
if [ "$tidy_menu" == "q" ] || [ "$tidy_menu" == "Q" ] ; then
echo $STAND""
f_menu
elif [[ "$tidy_menu" != [1-3] ]]; then
echo $RED"must be an entry from the above menu $STAND"
sleep 1
f_tidy
fi
#
# Option 1
# Full optimization of wordlist
# -----------------------------
if [ "$tidy_menu" == "1" ] ; then
echo $STAND""
echo $BLUE"Full optimization of wordlist"
echo $STAND""
f_inout
##full optimize##
echo -en $STAND"Enter a minimum password length: "$GREEN
read min
echo -en $STAND"Enter a maximum password length: "$GREEN
read max
echo $STAND""
echo -en $STAND"Hit return to start processing the file "$STAND
read return
if [ "$return" == "" ]; then
echo $GREEN">$STAND Removing duplicates from the file.."
cat $wlm_infile | uniq > working.tmp
echo $GREEN">$STAND Deleting words which do not meet length requirement.."
pw-inspector -i working.tmp -o working1.tmp -m $min -M $max
echo $GREEN">$STAND Removing all non ascii chars if they exist.."
tr -cd '\11\12\40-\176' < working1.tmp > working.tmp
echo $GREEN">$STAND Removing all comments.."
sed '1p; /^[[:blank:]]*#/d; s/[[:blank:]][[:blank:]]*#.*//' working.tmp > working1.tmp
echo $GREEN">$STAND Removing any leading white spaces, tabs and CRLF from the file.."
sed -e 's/^[ \t]*//' working1.tmp > working.tmp
dos2unix -f -q working.tmp
echo $GREEN">$STAND One more pass to sort and remove any duplicates.."
cat working.tmp | sort | uniq > working1.tmp
sudo mv working1.tmp $wlm_outfile
echo $GREEN">$STAND Cleaning up temporary files.."
rm -rf working*.tmp
fi
echo $STAND""
f_complete
#
# Option 2
# Optimization of wordlist for WPA
# --------------------------------
elif [ "$tidy_menu" == "2" ] ; then
echo $STAND""
echo $BLUE"Optimization of wordlist for WPA/WPA2"
echo $STAND""
f_inout
echo "Working .."
pw-inspector -i $wlm_infile -o /root/temp_outfile -m 8 -M 63
sudo cat /root/temp_outfile | sort | uniq > $wlm_outfile
rm -rf /root/temp_outfile
echo $STAND""
f_complete
#
# Option 3
# --------
elif [ "$tidy_menu" == "3" ] ; then
echo $STAND""
echo $BLUE"Sort wordlist based on wordsize/length"$STAND
echo "(can speed up cracking process with some programmes)"
echo $STAND""
f_inout
echo "Working .."
sudo awk '{ print length(), $0 | "sort -n" }' $wlm_infile | sed 's/[^ ]* //' > $wlm_outfile
f_complete
fi
}
#
#
#------------
# MENU ITEM 8
#============
# SPLIT FUNCTIONS
##################
f_split () {
clear
echo $STAND"Wordlist Manipulator"
echo $BLUE"Split wordlists"
echo $STAND"--------------------"
echo "1 Split wordlists into user defined max linecount per split file.
2 Split wordlists into user defined max sizes per split file.
Q Back to menu
"
echo -ne $STAND"Enter choice from above menu: "$GREEN
read split_menu
if [ "$split_menu" == "q" ] || [ "$split_menu" == "Q" ] ; then
echo $STAND""
f_menu
elif [[ "$split_menu" != [1-3] ]]; then
echo $RED"must be an entry from the above menu $STAND"
sleep 1
f_split
fi
#
# Option 1
# Split files by linecount
#-------------------------
if [ "$split_menu" == "1" ] ; then
echo $STAND""
echo $BLUE"Split wordlists into user defined max linecount per split file"
echo $STAND""
echo -ne $STAND"Enter /path/to/wordlist to split : "$GREEN
read split_in
while [ ! -f "$split_in" ] ; do
echo -ne $RED"File does not exist, enter /path/to/file: "$GREEN
read split_in
done
#Enter output file to write the changes to
echo -ne $STAND"Enter output files' prefix: "$GREEN
read split_out
echo $STAND""
#
# Test for existence of prefixed files in working directory
echo "Checking for existing files in working directory with same pre-fix.."
sleep 0.5
find $split_out* > exist_temp
exist=$(sed -n '$=' exist_temp)
if [ "$exist" == "" ] ; then
echo $GREEN"No files with same prefix found in working directory, proceding.."
rm exist_temp
echo $STAND""
elif [ "$exist" != "" ] ; then
echo $RED"Files with same prefix found in working directory; "$STAND
cat exist_temp
echo $STAND""
# Delete existing files with same prefix before starting so as
echo -ne $STAND"Delete above files before proceding ? y/n "$GREEN
read delete
if [ "$delete" == "y" ] || [ "$delete" == "Y" ] ; then
echo $STAND"deleting existing files.."
sleep 0.5
echo $STAND""
for line in $(cat exist_temp) ; do
rm $line
done
else
echo ""
echo $STAND"Returning to menu.."
rm exist_temp
sleep 1
f_split
fi
rm exist_temp
fi
#
#
B=$( stat -c %s $split_in )
KB=$( echo "scale=2;$B / 1024" | bc )
MB=$( echo "scale=2;($B/1024)/1024" | bc )
GB=$( echo "scale=2;(($B/1024)/1024)/1024" | bc )
echo -e $STAND"Wordlist $GREEN$split_in$STAND size: $KB KB$STAND $GREEN$MB MB$STAND $GB GB$STAND"
linecount=$(wc -l $split_in | cut -d " " -f 1)
echo "Wordlist $GREEN$split_in$STAND Linecount: $GREEN$linecount$STAND"
echo ""
echo -ne $STAND"Enter number of lines you want per each split file: "$GREEN
read lines_in
#Calculate the number of files resulting from user input
est_count=$(echo "scale=3;$linecount / $lines_in" | bc)
if [ "$est_count" != *.000 ] ; then
size=$(echo "$linecount/$lines_in+1" | bc)
elif [ "$est_count" == *.000 ] ; then
size=$(echo "$linecount/$lines_in" | bc)
fi