-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHunterSeeker.sh
822 lines (767 loc) · 27.2 KB
/
HunterSeeker.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
#!/usr/bin/env bash
#init
###################################################################
##/Coded/--/by/--/Bakeneko/--[10/2022]--/crunchCorps/--/JACURUTU/##
###################################################################
dirpath=$(pwd) #Current Location path.
VT=$(find . -name "vt" | head -n 1)
VTAPI=$(cat /home/$(echo ${SUDO_USER:-${USER}})/.vt.toml | cut -d"=" -f2 | cut -d"\"" -f2)
##### COLORS PALLETES #####
DGray='\033[38;5;244m' #Color Dark Gray
MGray='\033[1;38;5;247m' #Color Mid-Gray
Gray='\033[1;38;5;248m' #Color Gray
WGray='\033[38;5;253m' #Color White Gray
DGR='\033[0;32m' #Color DarkGreen.
LBlue='\033[1;34m' #Color Light Blue
LRed='\033[1;31m' #Color Light Red
LGreen='\033[1;32m' #Color Light Green
reset='\e[0m'
##### CHECK IF SCRIPT HAS PRIVILEGES #####
if ! [ $(stat HunterSeeker.sh | grep "Access: (" | cut -d '(' -f2 | cut -d '/' -f1) = 0777 ]; then
echo -e "${DGR}"
echo "The script need to be run as root." >&2
exit 1
# if ! [ $(id -u) = 0 ]; then
# echo -e "${DGR}"
# echo "The script need to be run as root." >&2
# exit 1
# fi
fi
#####TEST IF ROOT#####
if [ $SUDO_USER ];
then
real_user=$SUDO_USER
else
real_user=$(whoami)
fi
##### INSTALLIING PREQUISITES #####
###################################
##################
##### FIGLET #####
if ! command -v figlet &> /dev/null
then
echo -e ${WGray}"figlet could not be found."
echo -e "Installing."${MGray}
sudo apt-get install figlet
exit
fi
##################
##### TSHARK #####
if ! command -v tshark &> /dev/null
then
echo -e ${WGray}"tshark could not be found."
echo -e "Installing."${MGray}
sudo apt-get install tshark
exit
fi
#####SHORT HELP MENU#####
function HelpShort()
{
clear
tput setaf 196; figlet -f smslant Hunter-Seeker; tput sgr0
echo -e "${WGray}[ Jacurutu | https://github.com/RandomLinoge ]" | sed 's/^/ /'
echo -e -n "
${Gray}usage: ${MGray}Hunterseeker ${WGray}[-h] [-i] [-m FILENAME] [-b IP | ADDRESS]
[-o LOG OUTPUT DIRECTORY] [-v] [--live]
${LRed}Hunter-Seeker${MGray} is a tool used for basic analysis of URL links, IP addresses,
extracting and analysing suscpicous files and detect potential malware.
options:
-h Show this help message and exit.
--help Show an extended help options and exit.
--live Active Live-On Capture mode.
"
exit 1
}
#####FULL HELP MENU#####
function HelpFull()
{
clear
tput setaf 196; figlet -f slant Hunter-Seeker; tput sgr0
echo -e "${WGray}[ Jacurutu | https://github.com/RandomLinoge ]" | sed 's/^/ /'
echo -e -n "
${Gray}usage: ${MGray}Hunterseeker ${WGray}[-h] [-i] [-m FILENAME] [-b IP | ADDRESS]
[-o LOG OUTPUT DIRECTORY] [-v] [--live]
${LRed}Hunter-Seeker ${MGray}is a tool used for basic analysis of URL links, IP addresses,
extracting and analysing suscpicous files and detect potential malware.
${Gray}
options:
${DGray}
-i, --interactive Interactive menus with questions.
-m FILENAME List of servers and addresses to
attack, one entry per line, and
make some pwnsauce.
-b IP, -b ADDRESS Target an IP or a source address
to scan and detect for malicious
sauce.
-o DIRECTORY Directory to which log files will be
saved (Default is '<currentfold>/log
/<arb-name>-<currentdate:$(date +'%d-%m-%Y')>.
--live Active Live-On Capture mode.
-v, --version Show the version of this program.
${LRed}HUNTER-SEEKER ${Gray}is an Ixian technology. An assassination device that floats
in mid-air; kills by entering the body and following nerve pathways to vital
organs. ${DGray}Invented by ${WGray}Frank Herbert ${DGray}in ${WGray}Dune: ${DGray}\"From behind the headboard
slipped a tiny ${LRed}hunter-seeker ${DGray}no more than five centimeters long.\"
\"It was a ravening sliver of metal guided by some near-by hand and eye.\"
"
exit 1
}
#####MAIN MENU#####
function MainMenu()
{
clear
if [ -d $logpath ]; then
logpath=$dirpath/log
fi
tput setaf 196; figlet -f slant Hunter-Seeker; tput sgr0
echo -e "${WGray}[ Jacurutu | https://github.com/RandomLinoge ]" | sed 's/^/ /'
echo -e -n "${LRed}
Hunter-Seeker ${MGray}is a tool used for basic analysis of URL links, IP addresses,
extracting and analysing suscpicous files and detect potential malware.
"
echo -e "${WGray}Main Menu: "
echo -e "${Gray}1. Network Analysis"
echo -e "${Gray}2. File Analysis"
echo -e "${Gray}3. Live-On Mode"
echo -e "${Gray}x. Exit Program"
read -p "$(echo -e ${WGray}"Choose: ")" MainOptions
case $MainOptions in
1)
NetAn
;;
2)
FileAn
;;
3)
clear
echo -n -e "
$Gray[$LRed+$Gray] ${LRed}Hunter-Seeker ${WGray}started analysis: "${Gray}$(ip route | tail -1 | cut -d " " -f1)" ${WGray}[Press any key to break]
"
LiveOn
;;
x)
Exit
;;
*)
echo -e -n "$Gray
Incorret Option. Try Again.
"
sleep 1
MainMenu
;;
esac
}
#####MENU FOR FILE ANALYSIS#####
function FileAn()
{
if [ -z $VT ]
then
echo "Installing VirusTotal CLI"
wget https://github.com/VirusTotal/vt-cli/releases/download/0.10.4/Linux64.zip > /dev/null 2>&1
unzip Linux64.zip
rm Linux64.zip*
fi
clear
echo -e -n "
${Gray}Checking for an existing VirusTotal API..."
echo
sleep 2
echo
if [ -f "/home/$(echo ${SUDO_USER:-${USER}})/.vt.toml" ]; then
echo -e "${WGray}VirusTotal API found!"
sleep 2
VTHash=VTAPI
else
read -p "$(echo -e ${Gray}"Do you have a secret key to decrypt admin's VirusTotal API? (y/n): ${WGray}")" SecretYN
case $SecretYN in
y|Y)
read -s -p "$(echo -e ${Gray}"Enter your secret key to decrypt VirusTotal API: ${WGray}")" VTSecret
if [ -z $VTSecret ]
then
clear
echo -e "${Gray}You have not entered a secret key."
sleep 1
read -s -p "$(echo -e ${Gray}"Enter your VirusTotal API to activate VirusTotal CLI: ${WGray}")" VTHash
./vt init $VTHash 2>/dev/null
if [ -z $VTHash ]
then
echo
echo -e "${Gray}Register an API for VirusTotal to use this feature and try again."
sleep 3
MainMenu
fi
fi
;;
n|N)
clear
if [ -z $VTSecret ]
then
echo -e "${Gray}"; ./vt init 2>/dev/null
if [ -z $VTHash ]
then
echo
echo -e "${DGray}Register an API for VirusTotal to use this feature and try again."
sleep 3
MainMenu
fi
fi
;;
esac
fi
clear
tput setaf 196; figlet -f smslant Hunter-Seeker; tput sgr0
echo -e "${WGray}File Analysis Options:${reset}"
echo
echo -e "${Gray}1. Upload a potential malware hash of a file for analysis."
echo -e "${Gray}2. Upload a log file with multiple IP/URLs for analysis [addresses should be segregated line by line]."
echo -e "${Gray}3. Upload a batch file with multiple hashes for analysis."
echo -e "${Gray}x. Back to Main Menu"
read -p "$(echo -e ${WGray}"Choose: ")" FileAnOptions
clear
case $FileAnOptions in
1)
echo
read -p "$(echo -e ${Gray}"Enter a file hash to analyze [example: ${WGray}"76cdb2bad9582d23c1f6f4d868218d6c"${Gray}]:
"$WGray)" FileHash
echo
echo -e "${Gray}Analyzing file hash ${WGray}$(echo $FileHash | cut -d"/" -f2 2>/dev/null) ${Gray}for malicious code."
sleep 3
./vt file $FileHash > malfilechk
TotalVotes=$(./vt file $FileHash | grep "malici" | tail -n1 | cut -d":" -f2)
if [ -d "$logpath/" ]; then
if [ -f "$logpath/HuntSeek-MalFile-$(date +'%d-%m-%Y').log" ]; then
cat malfilechk >> $logpath/HuntSeek-MalFile-$(date +'%d-%m-%Y').log
else
cat malfilechk > $logpath/HuntSeek-MalFile-$(date +'%d-%m-%Y').log
fi
else
mkdir log 2>/dev/nul
cat malfilechk > $logpath/HuntSeek-MalFile-$(date +'%d-%m-%Y').log
fi
echo -e "${Gray}Analyzing malicious activity in ${WGray}$(echo $(cat malfilechk | grep "filename" | tail -n1))"
sleep 1
echo -e "${Gray}Log file saved - ${WGray}$logpath/HuntSeek-MalFile-$(date +'%d-%m-%Y').log"
sleep 3
echo
echo -e "${WGray}--Total Votes--${reset}"
sleep 1.5
echo -e "${LRed}Malicious: ${WGray}$TotalVotes"
sleep 4
MainMenu
;;
2)
echo
read -p "$(echo -e ${Gray}"Enter a file path to analyze: [usage: \"/../<filename.ext>\"]: "${WGray})" BatchName
echo -e "${Gray}Analyzing malicious activity in the IoC file provided -${WGray} $BatchName 2>/dev/null ${WGray}[Press any key to break]"
sudo awk 'BEGIN{ ORS="" } { for ( i=1; i<= NF ; i++){ print $i"\n" } }' $BatchName | sort -u --sort=n | sudo tee batchchk >/dev/nul
file=$(cat batchchk)
for line in $file
do
sleep 1
if [ -s malchk ];
then
sudo ./vt file $line --apikey $VTAPI | sudo tee malchk2 >/dev/null
ID=$(cat malchk2 | grep -i "_id" | head -n1 | cut -d":" -f2)
FileCreation=$(cat malchk2 | grep -i "creation" | head -n1 | cut -d"#" -f2)
FileType=$(cat malchk2 | grep "file_type" | cut -d":" -f2)
fi
if ! [ -s malchk ];
then
./vt url $line > malchk 2>/dev/null
ID=$(cat malchk | grep -i "url" | tail -n1 | cut -d"\"" -f2)
fi
echo -e "${MGray}[${WGray}ID:\033[38;5;132m"$ID"\033[38;5;253m]"
echo -e "${MGray}[${WGray}Creation: \033[38;5;132m$FileCreation\033[38;5;253m]"
echo -e "${MGray}[${WGray}Filetype: \033[38;5;132m\\n$FileType\033[38;5;253m]"
sudo cat malchk2 | grep "total_votes" -2 | grep malicious | head -n1 | cut -d":" -f2 | sudo tee malchk3 >/dev/null
sleep 1.5
sudo cat malchk2 | grep "malicious:" | sort -u | cut -d":" -f2 | sudo tee malchk3 >/dev/null
if [ $(cat malchk3 | grep "total_votes" -2 | grep malicious | head -n1 | cut -d":" -f2) = 0 ];
then
echo -e "${Wgray}[${LRed}Malicious code found"${WGray}]: ${LRed}$(cat malchk2 | grep "total_votes" -2 | grep malicious | head -n1 | cut -d":" -f2)
else
echo -e "${Wgray}[${LBlue}Malicious code found"${WGray}]: ${LGreen}$(cat malchk3 | grep "total_votes" -2 | grep malicious | head -n1 | cut -d":" -f2)
fi
sleep 2.5
read -n 1
read -t 0.1 -n 1000000
break
done
if [ -d "$logpath/" ]; then
if [ -f "$logpath/HuntSeek-MalMultifiles-$(date +'%d-%m-%Y').log" ]; then
cat malchk2 >> $logpath/HuntSeek-MalMultFiles-$(date +'%d-%m-%Y').log
else
cat malchk2 > $logpath/HuntSeek-MalMultFiles-$(date +'%d-%m-%Y').log
fi
else
mkdir $logpath 2>/dev/null
cat malchk2 > $logpath/HuntSeek-MalMultFiles-$(date +'%d-%m-%Y').log
fi
echo
echo -e "${Gray}Log file saved - ${WGray}$logpath/HuntSeek-MalMultFiles-$(date +'%d-%m-%Y').log"
sleep 1
echo
sleep 4
MainMenu
;;
3)
echo
read -p "$(echo -e ${Gray}"Enter a file path to analyze: [usage: \"/../<filename.ext>\"]: "${WGray})" BatchName
echo -e "${Gray}Analyzing malicious activity in the IoC file provided -${WGray} $BatchName ${WGray}[Press any key to break]"
sudo awk 'BEGIN{ ORS="" } { for ( i=1; i<= NF ; i++){ print $i"\n" } }' $BatchName | sort -u --sort=n | sudo tee batchchk >/dev/null
processFile() {
file="batchchk"
local IFS="\n"
while read -r line; do
sleep 1
sudo echo -E $line | sudo tee malchk >/dev/null
if [ -s malchk ];
then
sudo ./vt file $(cat malchk) --apikey $VTAPI | sudo tee malchk2 >/dev/null
ID=$(cat malchk2 | grep -i "_id" | head -n1 | cut -d":" -f2)
FileCreation=$(cat malchk2 | grep -i "creation" | head -n1 | cut -d"#" -f2)
FileType=$(cat malchk2 | grep "file_type" | cut -d":" -f2)
fi
echo -e "${MGray}[${WGray}ID:\033[38;5;132m"$ID"\033[38;5;253m]"
echo -e "${MGray}[${WGray}Creation: \033[38;5;132m$FileCreation\033[38;5;253m]"
echo -e "${MGray}[${WGray}Filetype: \033[38;5;132m\\n$FileType\033[38;5;253m]"
sudo rm malchk
sleep 1.5
cat malchk2 | grep last_analysis -n8 | awk '{ print $2,$3 }' | tail -n7 | sudo tee malchk3 >/dev/null
echo
if [ $(cat malchk2 | grep last_analysis -n8 | awk '{ print $2,$3 }' | tail -n7 | grep malicious | cut -d":" -f2) = 0 ]; then
echo -e "${Wgray}[${LRed}Malicious Analysis Found${WGray}]:{Gray}\\n$(cat malchk3 | awk -v ORS='\\n' 1) "
if [ -d "$logpath/" ]; then
if [ -f "$logpath/HuntSeek-MalMultifiles-$(date +'%d-%m-%Y').log" ]; then
cat malchk2 >> $logpath/HuntSeek-MalMultFiles-$(date +'%d-%m-%Y').log
else
cat malchk2 > $logpath/HuntSeek-MalMultFiles-$(date +'%d-%m-%Y').log
fi
else
mkdir $logpath 2>/dev/null
cat malchk2 > $logpath/HuntSeek-MalMultFiles-$(date +'%d-%m-%Y').log
fi
else
echo -e "${Wgray}[${LBlue}Analysis found${WGray}]:${LGreen}\\n$(cat malchk3 | awk -v ORS='\\n' 1)"
if [ -d "$logpath/" ]; then
if [ -f "$logpath/HuntSeek-MalMultifiles-$(date +'%d-%m-%Y').log" ]; then
cat malchk2 >> $logpath/HuntSeek-MalMultFiles-$(date +'%d-%m-%Y').log
else
cat malchk2 > $logpath/HuntSeek-MalMultFiles-$(date +'%d-%m-%Y').log
fi
else
mkdir $logpath 2>/dev/null
cat malchk2 > $logpath/HuntSeek-MalMultFiles-$(date +'%d-%m-%Y').log
fi
fi
sleep 2.5
read -n 1
read -t 0.1 -n 1000000
done < $file
}
processFile $(pwd)/batchchk
echo
echo -e "${Gray}Log file saved - ${WGray}$logpath/HuntSeek-MalMultFiles-$(date +'%d-%m-%Y').log"
sleep 1
echo
sleep 4
;;
x)
MainMenu
;;
esac
}
#####MENU FOR NETWORK ANALYSIS#####
function NetAn()
{
if [ -z $VT ]
then
echo "Installing VirusTotal CLI"
wget https://github.com/VirusTotal/vt-cli/releases/download/0.10.4/Linux64.zip > /dev/null 2>&1
unzip Linux64.zip
rm Linux64.zip*
fi
clear
echo -e -n "
${Gray}Checking for an existing VirusTotal API..."
echo
sleep 2
echo
if [ -f "/home/$(echo ${SUDO_USER:-${USER}})/.vt.toml" ]; then
echo -e "${WGray}VirusTotal API found!"
sleep 2
VTHash=VTAPI
else
read -p "$(echo -e ${Gray}"Do you have a secret key to decrypt admin's VirusTotal API? (y/n): ${WGray}")" SecretYN
case $SecretYN in
y|Y)
read -s -p "$(echo -e ${Gray}"Enter your secret key to decrypt VirusTotal API: ${WGray}")" VTSecret
if [ -z $VTSecret ]
then
clear
echo -e "${Gray}You have not entered a secret key."
sleep 1
read -s -p "$(echo -e ${Gray}"Enter your VirusTotal API to activate VirusTotal CLI: ${WGray}")" VTHash
./vt init $VTHash 2>/dev/null
if [ -z $VTHash ]
then
echo
echo -e "${Gray}Register an API for VirusTotal to use this feature and try again."
sleep 3
MainMenu
fi
fi
;;
n|N)
clear
if [ -z $VTSecret ]
then
echo -e "${Gray}"; ./vt init 2>/dev/null
if [ -z $VTHash ]
then
echo
echo -e "${DGray}Register an API for VirusTotal to use this feature and try again."
sleep 3
MainMenu
fi
fi
;;
esac
fi
clear
tput setaf 196; figlet -f smslant Hunter-Seeker; tput sgr0
echo -e "${WGray}Network Analysis Options:${reset}"
echo
echo -e "${Gray}1. Analyze a suspicious URL Address"
echo -e "${Gray}2. Analyze a suspicious IP Address"
echo -e "${Gray}x. Back to Main Menu"
read -p "$(echo -e ${WGray}"Choose: ")" NetAnOptions
clear
case $NetAnOptions in
1)
echo
read -p "$(echo -e ${Gray}"Enter an URL to analyze [example: ${WGray}www.google.com${Gray}]: ")" URL
./vt url $URL > malchk
TotalVotes=$(./vt url $URL | grep "malici" | tail -n1 | cut -d":" -f2)
if [ -d "$logpath/" ]; then
if [ -f "$logpath/HuntSeek-MalURL-$(date +'%d-%m-%Y').log" ]; then
cat malchk >> $logpath/HuntSeek-MalURL-$(date +'%d-%m-%Y').log
else
cat malchk > $logpath/HuntSeek-MalURL-$(date +'%d-%m-%Y').log
fi
else
mkdir $logpath 2>/dev/nul
cat malchk > $logpath/HuntSeek-MalURL-$(date +'%d-%m-%Y').log
fi
echo -e "${Gray}Analyzing malicious activity in URL Address - ${WGray}$URL"
echo -e "${Gray}Log file saved - ${WGray}$logpath/HuntSeek-MalURL-$(date +'%d-%m-%Y').log"
sleep 1
echo
echo -e "${WGray}--Total Votes--${reset}"
sleep 1.5
echo -e "${LRed}Malicious: ${WGray}$TotalVotes"
sleep 4
sudo rm malchk
MainMenu
;;
2)
echo
read -p "$(echo -e $Gray"Enter an IP to analyze: $WGray")" IP
./vt ip $IP > malchk
if [ -d "$logpath/" ]; then
if [ -f "$logpath/HuntSeek-MalIP-$(date +'%d-%m-%Y').log" ]; then
cat malchk >> $logpath/HuntSeek-MalIP-$(date +'%d-%m-%Y').log
else
cat malchk > $logpath/HuntSeek-MalIP-$(date +'%d-%m-%Y').log
fi
else
mkdir $logpath 2>/dev/nul
cat malchk > $logpath/HuntSeek-MalIP-$(date +'%d-%m-%Y').log
fi
TotalVotes=$(./vt ip $IP | grep "malici" | tail -n1 | cut -d":" -f2)
clear
echo -e "${Gray}Analyzing malicious activity in IP Address - ${WGray}$IP"
echo -e "${Gray}Log file saved - ${WGray}$logpath/HuntSeek-MalIP-$(date +'%d-%m-%Y').log"
sleep 1
echo
echo -e "${WGray}--Total Votes--${reset}"
sleep 1.5
echo -e "${LRed}Malicious: ${WGray}$TotalVotes"
sleep 4
sudo rm malchk
MainMenu
;;
x)
MainMenu
;;
esac
}
#####EXIT SCRIPT#####
function Exit()
{
echo -e -n "
"
echo -e "${MGray}Thank you for using ${LRed}Hunter-Seeker${MGray}." | sed 's/^/ /'
echo -e "${MGray}Goodbye!${reset}" | sed 's/^/ /'
echo -n "
"
sleep 0.5
sudo rm capture.txt capture2.txt mal* batchchk chk2 2>/dev/null
exit 1
}
#####IP OR ADDRESS BIND WITHOUT INTERACTIVE MENUS#####
function NetAnBind()
{
clear
echo -e "${MGray}Analyzing ${WGray}$(echo $BIND)${Gray} ..."
sleep 1
./vt ip $BIND > BindIPchk 2>/dev/null
if [ -f BindIPchk ]; then
if [ ! -s BindIPchk ]; then
./vt url $BIND > BindURLchk 2>/dev/null
echo -e -n "${Gray} [ID: ${WGray}"$(cat BindURLchk | grep -i "_id" | cut -d"\"" -f2)"${Gray}]"
cat BindURLchk | grep "total_votes" -2 | grep malicious | head -n1 | cut -d":" -f2 > malchk
if [ ! $(cat BindIPchk | grep -i "_id" | cut -d"\"" -f2) = "0" ]
then
echo -e "\033[38;5;39m -- ${Gray}[Malicious code found]: ${LGreen}"$(cat malchk) | sed 's/\(^ *\) \( [^ ]\)/\1-\2/'
else
echo -e "\033[38;5;39m -- ${Gray}[Malicious code found]: ${LRed}"$(cat malchk) | sed 's/\(^ *\) \( [^ ]\)/\1-\2/'
fi
fi
echo -e -n "${Gray} [ID: ${WGray}"$(cat BindIPchk | grep -i "_id" | cut -d"\"" -f2)"${Gray}]"
cat BindIPchk | grep malicious | tail -n1 | cut -d":" -f2 > malchk
if [ ! $(cat BindIPchk | grep -i "_id" | cut -d"\"" -f2) = "0" ];
then
echo -e "\033[38;5;39m -- ${Gray}[Malicious code found]: ${LGreen}"$(cat malchk) | sed 's/\(^ *\) \( [^ ]\)/\1-\2/'
else
echo -e "\033[38;5;39m -- ${Gray}[Malicious code found]: ${LRed}"$(cat malchk) | sed 's/\(^ *\) \( [^ ]\)/\1-\2/'
fi
fi
echo
sleep 2
if [ -d "$logpath/" ]; then
if [ -f "$logpath/HuntSeek-MalIP-$(date +'%d-%m-%Y').log" ]; then
cat malchk >> $logpath/HuntSeek-MalIP-$(date +'%d-%m-%Y').log
else
cat malchk > $logpath/HuntSeek-MalIP-$(date +'%d-%m-%Y').log
fi
if [ -f "$logpath/HuntSeek-MalURL-$(date +'%d-%m-%Y').log" ]; then
cat malchk >> $logpath/HuntSeek-MalURL-$(date +'%d-%m-%Y').log
else
cat malchk > $logpath/HuntSeek-MalURL-$(date +'%d-%m-%Y').log
fi
else
mkdir $logpath 2>/dev/null
if [ -f "$logpath/HuntSeek-MalIP-$(date +'%d-%m-%Y').log" ]; then
cat malchk > $logpath/HuntSeek-MalIP-$(date +'%d-%m-%Y').log
fi
if [ -f "$logpath/HuntSeek-MalURL-$(date +'%d-%m-%Y').log" ]; then
cat malchk > $logpath/HuntSeek-MalURL-$(date +'%d-%m-%Y').log
fi
fi
echo
echo -e "${Gray}Log file saved - ${WGray}$logpath/HuntSeek-MalLink-$(date +'%d-%m-%Y').log"
sleep 2
Exit
}
#####FILEBATCH BIND WITHOUT INTERACTIVE MENUS#####
function FileAnBind()
{
clear
echo -e "${Gray}Analyzing malicious activity in the IoC file provided -${WGray} $BIND ${WGray}[Press any key to break]"
sudo awk 'BEGIN{ ORS="" } { for ( i=1; i<= NF ; i++){ print $i"\n" } }' $BIND | sort -u --sort=n | sudo tee batchchk >/dev/null
processFile() {
file=$BIND
local IFS="\n"
while read -r line; do
sleep 1
sudo echo -E $line | sudo tee malchk >/dev/null
if [ -s malchk ];
then
sudo ./vt file $(cat malchk) --apikey $VTAPI | sudo tee malchk2 >/dev/null
ID=$(cat malchk2 | grep -i "_id" | head -n1 | cut -d":" -f2)
FileCreation=$(cat malchk2 | grep -i "creation" | head -n1 | cut -d"#" -f2)
FileType=$(cat malchk2 | grep "file_type" | cut -d":" -f2)
fi
echo -e "${MGray}[${WGray}ID:\033[38;5;132m"$ID"\033[38;5;253m]"
echo -e "${MGray}[${WGray}Creation: \033[38;5;132m$FileCreation\033[38;5;253m]"
echo -e "${MGray}[${WGray}Filetype: \033[38;5;132m\\n$FileType\033[38;5;253m]"
sudo rm malchk
sleep 1.5
cat malchk2 | grep last_analysis -n8 | awk '{ print $2,$3 }' | tail -n7 | sudo tee malchk3 >/dev/null
echo
if [[ $(cat malchk2 | grep last_analysis -n8 | awk '{ print $2,$3 }' | tail -n7 | grep malicious | cut -d":" -f2) == 0 ]]; then
echo -e "${Wgray}[${LRed}Malicious Analysis:${WGray}]{Gray}\\n$(cat malchk3 | awk -v ORS='\\n' 1) "
if [ -d "$logpath/" ]; then
if [ -f "$logpath/HuntSeek-MalMultifiles-$(date +'%d-%m-%Y').log" ]; then
cat malchk2 >> $logpath/HuntSeek-MalMultFiles-$(date +'%d-%m-%Y').log
else
cat malchk2 > $logpath/HuntSeek-MalMultFiles-$(date +'%d-%m-%Y').log
fi
else
mkdir $logpath 2>/dev/null
cat malchk2 > $logpath/HuntSeek-MalMultFiles-$(date +'%d-%m-%Y').log
fi
else
echo -e "${Wgray}[${LBlue}Analysis:${WGray}]${LGreen}\\n$(cat malchk3 | awk -v ORS='\\n' 1)"
if [ -d "$logpath/" ]; then
if [ -f "$logpath/HuntSeek-MalMultifiles-$(date +'%d-%m-%Y').log" ]; then
cat malchk2 >> $logpath/HuntSeek-MalMultFiles-$(date +'%d-%m-%Y').log
else
cat malchk2 > $logpath/HuntSeek-MalMultFiles-$(date +'%d-%m-%Y').log
fi
else
mkdir $logpath 2>/dev/null
cat malchk2 > $logpath/HuntSeek-MalMultFiles-$(date +'%d-%m-%Y').log
fi
fi
sleep 2.5
read -n 1
read -t 0.1 -n 1000000
done < $file
}
processFile $(pwd)/batchchk
echo
echo -n"
"
echo -e "${Gray}Log file saved - ${WGray}$logpath/HuntSeek-MalMultFiles-$(date +'%d-%m-%Y').log"
sleep 4
Exit
}
#####SCRIPT VERSION#####
function Version()
{
clear
tput setaf 196; figlet -f mini Hunter-Seeker| sed 's/^/ /'; tput sgr0
echo -e "${DGray}[ ${WGray}Jacurutu ${DGray}| ${WGray}https://github.com/RandomLinoge ${DGray}| ${WGray}v1.3.6]"
echo
sleep 1
}
#####LIVE ON CAPTURE#####
function LiveOn()
{
sudo tshark -i eth0 -t ad -n -T fields -e ip.src -e dns.qry.name -Y "dns.flags.response eq 0" -a duration:15 2>/dev/null | sudo tee capture.txt > /dev/null
sort capture.txt | column -t -s $'\t' > capture2.txt
if [ -s capture2.txt ]; then
for line in capture2.txt
do
cat $line | awk '{print "\033[0m[\033[38;5;132m"$1"\033[0m]","[\033[38;5;196m"$2"\033[0m]"}' | sed -r "s/\s/\ accessed /g" | xargs -L 1 echo -e `TZ="Asia/Jerusalem" date +'\033[0m[\033[38;5;250m%A, %b %d, %Y %H:%M:%S\033[0m]\033[38;5;39m'` --- $1 2>/dev/null > chk2
sleep 2
cat chk2
if [ -d "$logpath/" ]; then
if [ -f "$logpath/HuntSeek-LiveOn-$(date +'%d-%m-%Y').log" ]; then
cat chk2 >> $logpath/HuntSeek-LiveOn-$(date +'%d-%m-%Y').log
else
cat chk2 > $logpath/HuntSeek-LiveOn-$(date +'%d-%m-%Y').log
fi
else
mkdir $logpath 2>/dev/nul
cat chk2 > $logpath/HuntSeek-LiveOn-$(date +'%d-%m-%Y').log
fi
read -n 1
sudo pkill tshark #kill tshark
read -t 0.1 -n 1000000
echo
echo -e "${Gray}Log file saved - ${WGray}$logpath/HuntSeek-LiveOn-$(date +'%d-%m-%Y').log"
sleep 4
Exit
done
fi
LiveOn
}
#####BINDING ATTRIBUTES AND VARIABLES DESCRIBED IN FULL HELP MENU#####
if [ "$1" == "--live" ]; then
clear
echo -n -e "
${Gray}[${LRed}+${Gray}] ${LRed}Hunter-Seeker ${WGray}started analysis: "${Gray}$(ip route | tail -1 | cut -d " " -f1)" ${WGray}[Press any key to break]
"
LiveOn
fi
if [[ "$1" == "-b" && ! -z "$2" ]] && [[ "$3" == "-o" && ! -z "$4" ]]; then
clear
logpath=$4
BIND=$2
NetAnBind
fi
if [[ "$1" == "-b" && ! -z $2 ]] && [[ "$3" == "-o" && -z $4 ]]; then
echo
echo -e -n "${MGray}
Incorret use of program pre-options.
referring to help options - ${WGray}\"./Hunterseeker --help\"${MGray}.
Example of usage: ${WGray}\"./Hunterseeker -b [IP|Hostname] -o [Log output directory]\"
"
Exit
fi
if [[ "$1" == "-m" && ! -z "$2" ]] && [[ "$3" == "-o" && ! -z "$4" ]]; then
clear
logpath=$4
BIND=$2
FileAnBind
fi
if [[ "$1" == "-m" && ! -z "$2" ]] && [[ "$3" == "-o" && -z "$4" ]]; then
echo
echo -e -n "${MGray}
Incorret use of program pre-options.
referring to help options - ${WGray}\"./Hunterseeker --help\"${MGray}.
Example of usage: ${WGray}\"./Hunterseeker -m [Filename] -o [Log output directory]\"
"
Exit
fi
if [[ "$1" == "-m" && -z "$2" ]]; then
echo
echo -e -n "${MGray}
Incorret use of program pre-options.
referring to help options - ${WGray}\"./Hunterseeker --help\"${MGray}.
Example of usage: ${WGray}\"./Hunterseeker -m [Filename] -o [Log output directory]\"
"
Exit
fi
if [[ "$1" == "-m" && ! -z "$2" ]]; then
BIND=$2
FileAnBind
fi
if [ "$1" == "-o" ]; then
echo
echo -e -n "${MGray}
Incorret use of program pre-options.
referring to help options - ${WGray}\"./Hunterseeker --help\"${MGray}.
Example of usage: ${WGray}\"./Hunterseeker -i|--interactive -o [Log output directory]\"
"
Exit
fi
if [ -z "$1" ]; then
MainMenu
fi
if [[ $1 == "-i" || $1 == "--interactive" ]]; then
MainMenu
fi
if [ "$2" == "-o" ] && [ -d $3 ]; then
logpath=$3
fi
if [ "$2" == "-o" ] && [ ! -d $3 ]; then
echo
echo -e -n "${MGray}
Incorret use of program pre-options.
referring to help options - ${WGray}\"./Hunterseeker --help\"${MGray}.
Example of usage: ${WGray}\"./Hunterseeker -b [IP|Hostname] -o [Log output directory]\"
"
Exit
fi
if [[ "$1" == "-b" && -z $2 ]]; then
echo
echo -e -n "
${MGray}Incorret use of program pre-options.
referring to help options - ${WGray}\"./Hunterseeker --help\"${MGray}.
Example of usage: ${WGray}\"./Hunterseeker -b [IP|Hostname] -o [Log output directory]\"
"
Exit
fi
if [ "$1" == "-h" ]; then
HelpShort
fi
if [[ "$1" == "-v" || "$1" == "--version" ]]; then
Version
fi
if [ "$1" == "--help" ]; then
HelpFull
fi