-
Notifications
You must be signed in to change notification settings - Fork 344
/
pimpmykali.sh
executable file
·2842 lines (2389 loc) · 110 KB
/
pimpmykali.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
#
# pimpmykali.sh Author: Dewalt
# git clone https://github.com/Dewalt-arch/pimpmykali
# Usage: sudo ./pimpmykali.sh ( defaults to the menu system )
# command line arguments are valid
#
# Full Revision history can be found in changelog.txt
# Standard Disclaimer: Author assumes no liability for any damage
# revision var
revision="2.0.0"
# prompt colors
red=$'\e[1;31m'
green=$'\e[1;32m'
blue=$'\e[1;34m'
magenta=$'\e[1;35m'
cyan=$'\e[1;36m'
yellow=$'\e[1;93m'
white=$'\e[0m'
bold=$'\e[1m'
norm=$'\e[21m'
reset=$'\e[0m'
spaces=' '
# status indicators
greenplus='\e[1;33m[++]\e[0m'
greenminus='\e[1;33m[--]\e[0m'
redminus='\e[1;31m[--]\e[0m'
redexclaim='\e[1;31m[!!]\e[0m'
redstar='\e[1;31m[**]\e[0m'
blinkexclaim='\e[1;31m[\e[5;31m!!\e[0m\e[1;31m]\e[0m'
fourblinkexclaim='\e[1;31m[\e[5;31m!!!!\e[0m\e[1;31m]\e[0m'
# variables needed in the script
force=0
check=""
section=""
type=""
menu=""
pipnowarn="--no-python-version-warning"
export PYTHONWARNINGS="ignore"
nessusd_service_active=0
# variables moved from local to global
finduser=$(logname)
detected_env=""
menuinput=""
pyver=$(python3 --version | awk '{print$2}' | cut -d "." -f1-2)
archtype=$(uname -m)
if [ "$archtype" == "aarch64" ];
then
arch="arm64"
fi
if [ "$archtype" == "x86_64" ];
then
arch="amd64"
fi
# logging
LOG_FILE=pimpmykali.log
exec > >(tee ${LOG_FILE}) 2>&1
# silent mode
silent='' # uncomment to see all output
#silent='>/dev/null 2>&1' # uncomment to hide all output
export DEBIAN_FRONTEND=noninteractive
export PYTHONWARNINGS=ignore
# minimize apt updates
APT_UPDATE_RAN=0
# Variables used with --auto, --autonoroot and make_rootgreatagain functions
SPEEDRUN=0
ENABLE_ROOT=0
check_distro() {
distro=$(uname -a | grep -i -c "kali") # distro check
if [ $distro -ne 1 ]
then echo -e "\n ${redexclaim} Kali Linux Not Detected - WSL/WSL2/Anything else is unsupported ${redexclaim} \n"; exit
fi
# check for tracelabs osint vm, if found exit
findhostname=$(hostname)
findrelease=$(cat /etc/os-release | grep -i -c -m1 "2022.1")
if [[ "$finduser" == "osint" ]] && [[ "$findhostname" == "osint" ]] && [[ $findrelease -ge 1 ]]
then
echo -e "\n ${redexclaim} Tracelabs Osint VM Detected, exiting"
exit
fi
}
check_for_root() {
if [ "$EUID" -ne 0 ]
then echo -e "\n\n Script must be run with sudo ./pimpmykali.sh or as root \n"
exit
else
# Remove any prior hold on metasploit-framework at startup
eval apt-mark unhold metasploit-framework >/dev/null 2>&1
fi
}
clean_vars() {
APP=""
EXIT_STATUS=""
FUNCTYPE=""
}
check_exit_status() {
case ${EXIT_STATUS} in
0) ;;
1) echo -e "\n${spaces}${redexclaim} ${APP} ${FUNCTYPE} General Error Exit Status: ${EXIT_STATUS}\n"; exit 1;;
2) echo -e "\n${spaces}${redexclaim} ${APP} ${FUNCTYPE} Misuse of Shell commands, Exit Status: ${EXIT_STATUS}\n"; exit 2;;
100) echo -e "\n${spaces}${redexclaim} ${APP} ${FUNCTYPE} Mirror sync in progress try again later, Exit Status: ${EXIT_STATUS}\n"; exit 100;;
126) echo -e "\n${spaces}${redexclaim} ${APP} ${FUNCTYPE} Command Invoked Cannot Execute, Exit Status ${EXIT_STATUS}\n"; exit 126;;
127) echo -e "\n${spaces}${redexclaim} ${APP} ${FUNCTYPE} Command Not Found, Exit Staus: ${EXIT_STATUS}\n"; exit 127;;
128) echo -e "\n${spaces}${redexclaim} ${APP} ${FUNCTYPE} Invalid Arguement to Exit, Exit Status: ${EXIT_STATUS}\n"; exit 128;;
255) echo -e "\n${spaces}${redexclaim} ${APP} ${FUNCTYPE} Exit status out of range, Exit Status: ${EXIT_STATUS}\n"; exit 255;;
*) echo -e "\n${spaces}${redexclaim} Exit Status ${EXIT_STATUS} for ${APP} ${FUNCTYPE} status: failed\n";;
esac
}
is_installed() {
app="$@"
for each_app in ${app}
do
echo -e "\n ${greenplus} Checking if ${each_app} is installed"
is_app_installed=$(apt-cache policy ${each_app} | grep -i -c "Installed: (none)")
if [[ $is_app_installed -ge 1 ]]
then
clean_vars
APP="apt"
FUNCTYPE="install ${each_app}"
echo -e "${spaces}${greenplus} Installing ${each_app}"
apt-get --quiet install -y ${each_app} >/dev/null 2>&1
EXIT_STATUS="$?"
check_exit_status ${APP} ${FUNCTYPE} ${EXIT_STATUS}
else
echo -e "${spaces}${greenplus} $each_app is installed"
fi
done
}
is_installed_remove() {
app="$@"
for each_app in ${app}
do
echo -e "\n ${greenplus} Checking if ${each_app} is installed"
is_app_installed=$(apt-cache policy ${each_app} | grep -i -c "100 \/var\/lib\/dpkg\/status")
if [[ $is_app_installed -ge 1 ]]
then
clean_vars
APP="apt"
FUNCTYPE="remove ${each_app}"
echo -e "${spaces}${greenplus} Removing ${each_app} \n"
apt remove -y ${each_app} >/dev/null 2>&1
EXIT_STATUS="$?"
check_exit_status ${APP} ${FUNCTYPE} ${EXIT_STATUS}
else
echo -e "${spaces}${greenminus} ${each_app} is not installed \n"
fi
done
}
is_installed_reinstall() {
app="$@"
for each_app in ${app}
do
echo -e "\n ${greenplus} Checking if ${each_app} is installed"
is_app_installed=$(apt-cache policy ${each_app} | grep -i -c "100 \/var\/lib\/dpkg\/status")
if [[ $is_app_installed -ge 1 ]]
then
clean_vars
APP="apt"
FUNCTYPE="reinstall ${each_app}" >/dev/null 2>&1
echo -e "${spaces}${greenplus} Reinstalling ${each_app}"
apt reinstall -y ${each_app} >/dev/null 2>&1
EXIT_STATUS="$?"
check_exit_status ${APP} ${FUNCTYPE} ${EXIT_STATUS}
else
echo -e "${spaces}${greenminus} ${each_app} is already installed \n"
fi
done
}
apt_update() {
echo -e "\n ${greenplus} running: apt update \n"
APP="apt"
FUNCTYPE="update"
eval apt -y update
EXIT_STATUS="$?"
check_exit_status ${APP} ${FUNCTYPE} ${EXIT_STATUS}
clean_vars
export APT_UPDATE_RAN=1
}
apt_upgrade() {
echo -e "\n ${greenplus} running: apt upgrade \n"
APP="apt"
FUNCTYPE="upgrade"
eval apt -y upgrade
EXIT_STATUS="$?"
check_exit_status ${APP} ${FUNCTYPE} ${EXIT_STATUS}
clean_vars
}
apt_autoremove() {
echo -e "\n ${greenplus} running: apt autoremove \n"
APP="apt"
FUNCTYPE="autoremove"
eval apt -y autoremove
EXIT_STATUS="$?"
check_exit_status ${APP} ${FUNCTYPE} ${EXIT_STATUS}
clean_vars
}
apt_fixbroken() {
APP="apt"
FUNCTYPE="--fix-broken install"
eval apt -y --fix-broken install >/dev/null 2>&1
EXIT_STATUS="$?"
check_exit_status ${APP} ${FUNCTYPE} ${EXIT_STATUS}
clean_vars
}
fix_missing() {
fix_kali_lightdm_theme_and_background
fix_sources
setup_binfmt_mount
fix_hushlogin
fix_grub
fix_smbconf
fix_libwacom
apt_autoremove
check_installed_linuxheaders
check_installed_dkms
install_pip2
install_pip3
fix_pip2_pip3
install_pipx
install_pip2_modules
install_pip3_modules
install_golang
eval apt -y remove kali-undercover >/dev/null 2>&1
is_installed "libu2f-udev virt-what neo4j dkms build-essential autogen automake python3-setuptools python$pyver-dev libguestfs-tools cifs-utils dbus-x11"
fix_gedit
fix_root_connectionrefused
fix_htop
fix_nmap
fix_rockyou
fix_theharvester
silence_pcbeep
disable_power_checkde
fix_spike
fix_set
fix_amass
fix_httprobe
fix_assetfinder
fix_chrome
fix_gowitness
fix_mitm6
fix_linwinpeas
fix_neo4j
fix_bloodhound
fix_proxychains
fix_sshuttle
fix_chisel
fix_cme
fix_netexec
fix_ssh_widecompat
fix_waybackurls
fix_dockercompose
fix_ghidra
fix_locate
fix_seclists
fix_flameshot
install_plumhound
install_enumforlinux_ng
install_enumforlinux
install_sqlmap
install_hydra
install_wfuzz
install_ffuf
install_gobuster
install_vscode
}
fix_all() {
make_rootgreatagain
fix_missing
apt_autoremove
apt_fixbroken
virt_what
check_vm
}
fix_dockercompose() {
DOCKERCOMPOSE_RELEASE_URL="https://github.com/docker/compose/releases/"
DOCKERCOMPOSE_RELEASE_HTML=$(curl -s "$DOCKERCOMPOSE_RELEASE_URL")
DOCKERCOMPOSE_LATEST_VERSION=$(echo "$DOCKERCOMPOSE_RELEASE_HTML" | grep -oP 'href="/docker/compose/releases/tag/v\K[0-9.]+(?=")' | head -n 1)
if [ -z "$DOCKERCOMPOSE_LATEST_VERSION" ]; then
echo -e "\n ${redexclaim} Error: Unable to find the latest Docker Compose version from Github"
exit 1
fi
DOCKERCOMPOSE_DOWNLOAD_URL="https://github.com/docker/compose/releases/download/v$DOCKERCOMPOSE_LATEST_VERSION/docker-compose-$(uname -s)-$(uname -m)"
if command -v docker-compose &> /dev/null;
then
SYSTEM_DOCKERCOMPOSE_VER=$(docker-compose --version | awk '{print $4}' | tr -d "v")
EXIT_STATUS="$?"
else
EXIT_STATUS="127"
fi
case ${EXIT_STATUS} in
0)
# exit code 0, docker compose is installed, compare versions and upgrade if newer is available
echo -e "\n\n ${greenplus} Local $(whereis docker-compose) found. Comparing versions..."
if [[ "$DOCKERCOMPOSE_LATEST_VERSION" > "$SYSTEM_DOCKERCOMPOSE_VER" ]]; then
echo -e "${spaces}${greenminus} Installed Docker Compose Ver = $SYSTEM_DOCKERCOMPOSE_VER"
echo -e "${spaces}${greenminus} Github Latest Docker Compose = $DOCKERCOMPOSE_LATEST_VERSION"
echo -e "${spaces}${greenplus} Installing latest DockerCompose \n"
is_installed "build-essential python3-dev docker.io python3-setuptools python3-wheel python3-wheel-common cython3 python3-pip python3-pip-whl"
echo -e "${spaces}${greenplus} Latest Docker Compose version: $DOCKERCOMPOSE_LATEST_VERSION"
echo -e "${spaces}${greenplus} Downloading Docker Compose: $DOCKERCOMPOSE_DOWNLOAD_URL to /usr/local/bin/docker-compose"
curl -L "$DOCKERCOMPOSE_DOWNLOAD_URL" -o /usr/local/bin/docker-compose
echo -e "${spaces}${greenplus} Making /usr/local/bin/docker-compose executable"
chmod +x /usr/local/bin/docker-compose
echo -e "${spaces}${greenplus} Docker Compose installed successfully $(docker-compose --version | awk {'print $4'})"
else
echo -e "${spaces}${greenminus} Installed Docker Compose Ver = $SYSTEM_DOCKERCOMPOSE_VER"
echo -e "${spaces}${greenminus} Github Latest Docker Compose = $DOCKERCOMPOSE_LATEST_VERSION"
echo -e "${spaces}${greenplus} Versions Match, exiting"
fi
;;
127)
# exit code 127 docker-compose is not found, install from
echo -e "\n\n ${redexclaim} Docker Compose command not found, installing..."
is_installed "build-essential python3-dev docker.io python3-setuptools python3-wheel python3-wheel-common cython3 python3-pip python3-pip-whl"
echo -e "\n ${greenplus} Latest Docker Compose version: $DOCKERCOMPOSE_LATEST_VERSION"
echo -e "${spaces}${greenplus} Downloading Docker Compose: $DOCKERCOMPOSE_DOWNLOAD_URL to /usr/local/bin/docker-compose\n"
curl -L "$DOCKERCOMPOSE_DOWNLOAD_URL" -o /usr/local/bin/docker-compose
echo -e "${spaces}${greenplus} Making /usr/local/bin/docker-compose executable"
chmod +x /usr/local/bin/docker-compose
echo -e "${spaces}${greenplus} Docker Compose installed successfully $(docker-compose --version | awk {'print $4'})"
;;
*)
# catch all other exit codes
echo -e "\n ${redexclaim} Unknown error code ${EXIT_STATUS}"
;;
esac
}
fix_kali_lightdm_theme_and_background () {
APP="sed"
FUNCTYPE="update lightdm-gtk-greeter.conf"
sed s:"Kali-Light":"Kali-Dark":g -i /etc/lightdm/lightdm-gtk-greeter.conf
EXIT_STATUS="$?"
check_exit_status ${APP} ${FUNCTYPE} ${EXIT_STATUS}
clean_vars
}
install_rustup() {
echo -e "\n ${greenminus} Installing Rust"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -sSf | sh -s -- -y
APP="rustup"
FUNCTYPE="install"
sudo -i -u $finduser curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -sSf | sh -s -- -y
EXIT_STATUS="$?"
check_exit_status ${APP} ${FUNCTYPE} ${EXIT_STATUS}
clean_vars
}
install_cargo() {
is_installed "cargo libssl-dev"
}
fix_libwacom() {
is_installed "libwacom-common"
}
fix_neo4j() {
is_installed "neo4j"
}
fix_bloodhound() {
is_installed "bloodhound"
}
fix_proxychains() {
is_installed "proxychains"
}
fix_sshuttle() {
is_installed "sshuttle"
}
fix_chisel() {
is_installed "chisel"
}
fix_cme() {
is_installed "crackmapexec"
}
fix_nxc_symlinks() {
findrealuser=$(logname)
getshell=$(echo $SHELL | cut -d "/" -f4)
nxcbin_path="$HOME/.local/share/pipx/venvs/netexec/bin/"
localbin_path="$HOME/.local/bin/"
nxc_symlink_array=( 'netexec' 'NetExec' 'nxc' 'nxcdb' )
for nxc_symlink_array_file in ${cme_symlink_array[@]}; do
echo $cme_symlink_array_file > /tmp/nxcsymlink.tmp
# sanity check
# runuser $findrealuser $getshell -c 'echo -e "\n $HOME/.local/share/pipx/venvs/crackmapexec/bin/$(cat /tmp/cmesymlink.tmp) $HOME/.local/bin/$(cat /tmp/cmesymlink.tmp)"'
echo -e "${spaces}${greenplus} Creating symlink for user $findrealuser to ~/.local/bin/$nxc_symlink_array_file "
runuser $findrealuser $getshell -c 'symlink_file=$(cat /tmp/nxcsymlink.tmp); ln -sf $HOME/.local/share/pipx/venvs/netexec/bin/$symlink_file $HOME/.local/bin/$symlink_file'
done
rm -f /tmp/nxcsymlink.tmp
}
fix_netexec() {
findrealuser=$(logname)
echo -e "\n ${greenplus} Installing Netexec (nxc)"
# root installation
if [[ $findrealuser == "root" ]];
then
echo -e "${spaces}${greenplus} Starting ${findrealuser} user installation"
is_installed "pipx python3-venv python3-poetry"
pipx install git+https://github.com/Pennyw0rth/NetExec --force
getshell=$(echo $SHELL | cut -d "/" -f4)
check_for_local_bin_path=$(cat "$HOME/.$getshell"rc | grep -i "PATH=" | grep -i "\$HOME\/\.local\/bin" -c)
if [[ $check_for_local_bin_path -eq 0 ]];
then
echo "export PATH=\$HOME/.local/bin:\$PATH" >> $HOME/.$getshell"rc"
else
echo "\n ${redexclaim} Path already exists for user ${findrealuser}"
fi
fix_nxc_symlinks
fi
# user installation
if [[ $findrealuser != "root" ]];
then
echo -e "${spaces}${greenplus} Starting $findrealuser user installation"
is_installed "pipx python3-venv python3-poetry"
sudo -i -u $findrealuser sh -c 'pipx install git+https://github.com/Pennyw0rth/NetExec --force'
getshell=$(echo $SHELL | cut -d "/" -f4)
subshell=$(runuser $findrealuser $getshell -c 'echo $SHELL | cut -d "/" -f4')
checkforlocalbinpath=$(cat /home/$findrealuser/.$subshell"rc" | grep -i PATH= | grep -i "\$HOME\/\.local\/bin:\$PATH" -c)
if [[ $checkforlocalbinpath -eq 0 ]]
then
runuser $findrealuser $getshell -c 'subshell=$(echo $SHELL | cut -d "/" -f4); echo "export PATH=\$HOME/.local/bin:\$PATH" >> $HOME/.$subshell"rc"'
runuser $findrealuser $getshell -c 'subshell=$(echo $SHELL | cut -d "/" -f4); source $HOME/.$subshell"rc"'
else
echo -e "\n $redexclaim Path already exists "
fi
fix_nxc_symlinks
fi
}
fix_assetfinder() {
is_installed "assetfinder"
}
fix_httprobe() {
is_installed "httprobe"
}
fix_amass() {
is_installed "amass"
}
fix_mitm6() {
is_installed "mitm6"
}
fix_gedit() {
is_installed "gedit"
}
fix_set() {
echo -e "\n ${greenplus} Installing Social Engineering Toolkit"
is_installed "libssl-dev set gcc-mingw-w64-x86-64-win32"
}
fix_ssh_widecompat() {
echo -e "\n ${greenplus} Setting SSH for wide compatibility"
eval cp -f /usr/share/kali-defaults/etc/ssh/ssh_config.d/kali-wide-compat.conf /etc/ssh/ssh_config.d/kali-wide-compat.conf
echo -e "${spaces}${greenplus} Restarting SSH service for wide compatibility"
APP="systemctl"
FUNCTYPE="restart ssh"
eval systemctl restart ssh
EXIT_STATUS="$?"
check_exit_status ${APP} ${FUNCTYPE} ${EXIT_STATUS}
clean_vars
}
fix_waybackurls() {
echo -e "\n ${greenplus} Installing waybackrust \n"
WAYBACKRUST_URL="https://github.com/Neolex-Security/WaybackRust/releases/download/v0.2.12/waybackrust-x86_64-unknown-linux-gnu.tar.gz"
WAYBACKRUST_DEST="/tmp/waybackrust-x86_64-unknown-linux-gnu.tar.gz"
if [ ! -f /usr/bin/waybackrust ]
then
APP="wget"
FUNCTYPE="download"
wget --quiet "$WAYBACKRUST_URL" -O $WAYBACKRUST_DEST
EXIT_STATUS="$?"
check_exit_status ${APP} ${FUNCTYPE} ${EXIT_STATUS}
clean_vars
fi
if [ -f $WAYBACKRUST_DEST ]
then
APP="tar"
FUNCTYPE="extract"
tar xvfz $WAYBACKRUST_DEST -C /usr/bin >/dev/null 2>&1
EXIT_STATUS="$?"
check_exit_status ${APP} ${FUNCTYPE} ${EXIT_STATUS}
clean_vars
fi
if [ -f /usr/bin/waybackrust ]
then
echo -e "${spaces}${greenplus} /usr/bin/waybackrust found, making executable"
chmod +x /usr/bin/waybackrust
echo -e "${spaces}${greenplus} $(waybackrust --version) installed"
else
echo -e "${spaces}${greenplus} /usr/bin/waybackrust not found"
fi
}
fix_linwinpeas() {
# get all the peas!!!
current_build=$(curl -s https://github.com/peass-ng/PEASS-ng/releases | grep -i "refs/heads/master" -m 1 | awk '{ print $5 }' | cut -d "<" -f1)
releases_url="https://github.com/peass-ng/PEASS-ng/releases/download/$current_build"
dest_linpeas="/opt/linpeas"
dest_winpeas="/opt/winpeas"
# linpeas to /opt/linpeas
echo -e "\n ${greenplus} Downloading all the linpeas from build $current_build"
[ ! -d $dest_linpeas ] && mkdir $dest_linpeas || echo > /dev/null
linpeas_arr=('linpeas.sh' 'linpeas_darwin_amd64' 'linpeas_darwin_arm64' 'linpeas_fat.sh' 'linpeas_linux_386' 'linpeas_linux_amd64' 'linpeas_linux_arm')
for linpeas_file in ${linpeas_arr[@]}; do
clean_vars
APP="download"
FUNCTYPE=$(echo ${linpeas_file})
echo -e "${spaces}${greenplus} Downloading $linpeas_file to $dest_linpeas/$linpeas_file"
wget -q $releases_url/$linpeas_file -O $dest_linpeas/$linpeas_file
EXIT_STATUS="$?"
check_exit_status ${APP} ${FUNCTYPE} ${EXIT_STATUS}
clean_vars
chmod +x $dest_linpeas/$linpeas_file
done
# winpeas to /opt/winpeas
echo -e "\n ${greenplus} Downloading all the winpeas from build $current_build"
[ ! -d $dest_winpeas ] && mkdir $dest_winpeas || echo > /dev/null
winpeas_arr=('winPEAS.bat' 'winPEASany.exe' 'winPEASany_ofs.exe' 'winPEASx64_ofs.exe' 'winPEASx86.exe' 'winPEASx86_ofs.exe')
for winpeas_file in ${winpeas_arr[@]}; do
clean_vars
APP="download"
FUNCTYPE=$(echo ${winpeas_file})
echo -e "${spaces}${greenplus} Downloading $winpeas_file to $dest_winpeas/$winpeas_file"
wget -q $releases_url/$winpeas_file -O $dest_winpeas/$winpeas_file
EXIT_STATUS="$?"
check_exit_status ${APP} ${FUNCTYPE} ${EXIT_STATUS}
clean_vars
chmod +x $dest_winpeas/$winpeas_file
done
}
fix_chrome() {
echo -e "\n ${greenplus} Checking if google-chrome is installed "
if [[ "$arch" == "arm64" ]];
then
echo -e "${spaces}${redexclaim} Google-Chrome is not available for this platform $arch -- skipping"
elif [[ "$arch" == "amd64" ]];
then
if [[ -f /usr/bin/google-chrome ]];
then
echo -e "${spaces}${greenminus} google-chrome already installed, skipping"
else
clean_vars
APP="google-chrome"
FUNCTYPE="download"
echo -e "\n ${greenplus} Gowitness dependancy google-chrome for $arch \n"
eval wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -O /tmp/google-chrome-stable_current_amd64.deb
EXIT_STATUS="$?"
check_exit_status ${APP} ${FUNCTYPE} ${EXIT_STATUS}
clean_vars
is_installed "libu2f-dev"
echo -e "${spaces}${greenplus} Installing Google-Chrome"
APP="dpkg"
FUNCTYPE="install google-chrome-stable_current_amd64.deb"
eval dpkg -i /tmp/google-chrome-stable_current_amd64.deb
EXIT_STATUS="$?"
check_exit_status ${APP} ${FUNCTYPE} ${EXIT_STATUS}
clean_vars
rm -f /tmp/google-chrome-stable_current_amd64.deb
fi
fi
}
fix_hushlogin() {
echo -e "\n ${greenplus} Checking for .hushlogin"
if [ $finduser = "root" ]
then
if [ -f /root/.hushlogin ]
then
echo -e "${spaces}${greenminus} /$finduser/.hushlogin exists - skipping"
else
echo -e "${spaces}${greenplus} Creating file /$finduser/.hushlogin"
touch /$finduser/.hushlogin
fi
else
if [ -f /home/$finduser/.hushlogin ]
then
echo -e "${spaces}${greenminus} /home/$finduser/.hushlogin exists - skipping"
else
echo -e "${spaces}${greenplus} Creating file /home/$finduser/.hushlogin"
touch /home/$finduser/.hushlogin
fi
fi
}
disable_power_gnome() {
# CODE CONTRIBUTION : pswalia2u - https://github.com/pswalia2u
fix_hushlogin
echo -e "\n ${greenplus} Gnome detected - Disabling Power Savings"
# ac power
sudo -i -u $finduser gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type nothing # Disables automatic suspend on charging)
echo -e " ${greenplus} org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type nothing"
sudo -i -u $finduser gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 0 # Disables Inactive AC Timeout
echo -e " ${greenplus} org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 0"
# battery power
sudo -i -u $finduser gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type nothing # Disables automatic suspend on battery)
echo -e " ${greenplus} org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type nothing"
sudo -i -u $finduser gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout 0 # Disables Inactive Battery Timeout
echo -e " ${greenplus} org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout 0"
# power button
sudo -i -u $finduser gsettings set org.gnome.settings-daemon.plugins.power power-button-action nothing # Power button does nothing
echo -e " ${greenplus} org.gnome.settings-daemon.plugins.power power-button-action nothing"
# idle brightness
sudo -i -u $finduser gsettings set org.gnome.settings-daemon.plugins.power idle-brightness 0 # Disables Idle Brightness
echo -e " ${greenplus} org.gnome.settings-daemon.plugins.power idle-brightness 0"
# screensaver activation
sudo -i -u $finduser gsettings set org.gnome.desktop.session idle-delay 0 # Disables Idle Activation of screensaver
echo -e " ${greenplus} org.gnome.desktop.session idle-delay 0"
# screensaver lock
sudo -i -u $finduser gsettings set org.gnome.desktop.screensaver lock-enabled false # Disables Locking
echo -e " ${greenplus} org.gnome.desktop.screensaver lock-enabled false\n"
}
disable_power_xfce() {
if [ $finduser = "root" ]
then
echo -e "\n ${greenplus} XFCE Detected - disabling xfce power management"
OUTPUT_FILE=/root/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-power-manager.xml
echo '<?xml version="1.0" encoding="UTF-8"?>' > $OUTPUT_FILE
echo '' >> $OUTPUT_FILE
echo '<channel name="xfce4-power-manager" version="1.0">' >> $OUTPUT_FILE
echo ' <property name="xfce4-power-manager" type="empty">' >> $OUTPUT_FILE
echo ' <property name="power-button-action" type="empty"/>' >> $OUTPUT_FILE
echo ' <property name="show-panel-label" type="empty"/>' >> $OUTPUT_FILE
echo ' <property name="show-tray-icon" type="bool" value="false"/>' >> $OUTPUT_FILE
echo ' <property name="lock-screen-suspend-hibernate" type="bool" value="false"/>' >> $OUTPUT_FILE
echo ' <property name="logind-handle-lid-switch" type="bool" value="false"/>' >> $OUTPUT_FILE
echo ' <property name="blank-on-ac" type="int" value="0"/>' >> $OUTPUT_FILE
echo ' <property name="dpms-on-ac-sleep" type="uint" value="0"/>' >> $OUTPUT_FILE
echo ' <property name="dpms-on-ac-off" type="uint" value="0"/>' >> $OUTPUT_FILE
echo ' <property name="dpms-enabled" type="bool" value="false"/>' >> $OUTPUT_FILE
echo ' </property>' >> $OUTPUT_FILE
echo '</channel>' >> $OUTPUT_FILE
echo -e "${spaces}${greenplus} XFCE power management disabled for user: $finduser"
else
echo -e "\n ${greenplus} XFCE Detected - disabling xfce power management"
OUTPUT_FILE=/home/$finduser/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-power-manager.xml
echo '<?xml version="1.0" encoding="UTF-8"?>' > $OUTPUT_FILE
echo '' >> $OUTPUT_FILE
echo '<channel name="xfce4-power-manager" version="1.0">' >> $OUTPUT_FILE
echo ' <property name="xfce4-power-manager" type="empty">' >> $OUTPUT_FILE
echo ' <property name="power-button-action" type="empty"/>' >> $OUTPUT_FILE
echo ' <property name="show-panel-label" type="empty"/>' >> $OUTPUT_FILE
echo ' <property name="show-tray-icon" type="bool" value="false"/>' >> $OUTPUT_FILE
echo ' <property name="lock-screen-suspend-hibernate" type="bool" value="false"/>' >> $OUTPUT_FILE
echo ' <property name="logind-handle-lid-switch" type="bool" value="false"/>' >> $OUTPUT_FILE
echo ' <property name="blank-on-ac" type="int" value="0"/>' >> $OUTPUT_FILE
echo ' <property name="dpms-on-ac-sleep" type="uint" value="0"/>' >> $OUTPUT_FILE
echo ' <property name="dpms-on-ac-off" type="uint" value="0"/>' >> $OUTPUT_FILE
echo ' <property name="dpms-enabled" type="bool" value="false"/>' >> $OUTPUT_FILE
echo ' </property>' >> $OUTPUT_FILE
echo '</channel>' >> $OUTPUT_FILE
chown $finduser:$finduser /home/$finduser/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-power-manager.xml
echo -e "${spaces}${greenplus} XFCE power management disabled for user: $finduser"
fi
}
# disable_power_kde() {
# # need to work up a kde power management solution before implementing
# }
disable_power_checkde() {
detect_xfce=$(ps -e | grep -c -E '^.* xfce4-session$')
detect_gnome=$(ps -e | grep -c -E '^.* gnome-session-*')
#detect_kde=$(ps -e | grep -c -E '^.* kded4$')
[ $detect_gnome -ne 0 ] && detected_env="GNOME"
[ $detect_xfce -ne 0 ] && detected_env="XFCE"
# [ $detect_kde -ne 0 ] && detected_env="KDE"
echo -e "\n ${greenplus} Detected Environment: $detected_env"
[ $detected_env = "GNOME" ] && disable_power_gnome
[ $detected_env = "XFCE" ] && disable_power_xfce
[ $detected_env = "" ] && echo -e "\n ${redexclaim} Unable to determine desktop environment"
# [ $detected_env = "KDE" ] && disable_power_kde
}
silence_pcbeep() {
echo -e "blacklist pcspkr" > /etc/modprobe.d/nobeep.conf
echo -e "\n ${greenplus} Terminal Beep Silenced! /etc/modprobe.d/nobeep.conf \n"
}
fix_spike() {
is_spike_hold=$(apt-mark showhold | grep -i -c "spike")
if [[ $is_spike_hold -eq 1 ]]
then
apt-mark unhold spike
fi
is_installed_remove "spike"
APP="wget"
FUNCTYPE="download spike_2.9-1kali6_${arch}.deb"
eval wget https://old.kali.org/kali/pool/main/s/spike/spike_2.9-1kali6_$arch.deb -O /tmp/spike_2.9-1kali6_$arch.deb
EXIT_STATUS="$?"
check_exit_status ${APP} ${FUNCTYPE} ${EXIT_STATUS}
clean_vars
APP="dpkg"
FUNCTYPE="install"
echo -e "\n ${greenplus} installing spike 2.9 for $arch ... \n"
eval dpkg -i /tmp/spike_2.9-1kali6_$arch.deb
EXIT_STATUS="$?"
check_exit_status ${APP} ${FUNCTYPE} ${EXIT_STATUS}
clean_vars
echo -e "${spaces}${greenplus} spike 2.9 installed \n"
rm -f /tmp/spike_2.9-1kali6_$arch.deb
eval apt-mark hold spike >/dev/null 2>&1
echo -e "${spaces}${greenplus} apt hold placed on spike package"
}
fix_liblibc() {
if [[ "$arch" == "amd64" ]]
then
if [[ ! -f /usr/lib/x86_64-linux-gnu/liblibc.a ]]
then
ln -sf /usr/lib/x86_64-linux-gnu/libc.a /usr/lib/x86_64-linux-gnu/liblibc.a
echo -e "\n ${greenplus} Fixing $arch liblibc.a symlink /usr/lib/x86_64-linux-gnu/liblibc.a"
fi
fi
if [[ "$arch" == "arm64" ]]
then
if [[ ! -f /usr/lib/aarch64-linux-gnu/liblibc.a ]]
then
ln -sf /usr/lib/aarch64-linux-gnu/libc.a /usr/lib/aarch64-linux-gnu/liblibc.a
echo -e "\n ${greenplus} Fixing $arch liblibc.a symlink.."
fi
fi
}
fix_gowitness() {
check_gowitness=$(apt-cache policy gowitness | grep -i -c "100 \/var\/lib\/dpkg\/status")
if [[ $check_gowitness -eq 0 ]]
then
REPO_URL="https://github.com/sensepost/gowitness/tags"
LATEST_VERSION=$(curl -s "$REPO_URL" | grep -oPm1 '/sensepost/gowitness/releases/tag/\K[\d.]+')
echo -e "\n ${greenplus} Installing gowitness $LATEST_VERSION for ${arch} from github"
[ -f /usr/bin/gowitness ] && rm -f /usr/bin/gowitness
APP="wget"
FUNCTYPE="download gowitness-${LATEST_VERSION}"
echo -e "${spaces}${greenplus} Downloading gowitness ${arch} binary...\n"
eval wget -q https://github.com/sensepost/gowitness/releases/download/${LATEST_VERSION}/gowitness-${LATEST_VERSION}-linux-$arch -O /usr/bin/gowitness
EXIT_STATUS="$?"
check_exit_status ${APP} ${FUNCTYPE} ${EXIT_STATUS}
clean_vars
chmod +x /usr/bin/gowitness
rm -f /tmp/releases.gowitness > /dev/null
else
echo -e "${spaces}${greenplus} Uninstalling Gowitness"
is_installed_remove "gowitness"
fix_gowitness
fi
}
fix_root_connectionrefused() {
echo -e "\n ${greenplus} Adding root to xhost for $finduser display"
eval sudo -i -u $finduser xhost +SI:localuser:root >/dev/null 2>&1
eval xhost +SI:localuser:root >/dev/null 2>&1
echo -e "${spaces}${greenplus} root added to xhost"
}
fix_rockyou() {
ROCKYOU_GZIP="/usr/share/wordlists/rockyou.txt.gz"
if [ -f ${ROCKYOU_GZIP} ];
then
APP="gzip"
FUNCTYPE="deflate"
cd /usr/share/wordlists
echo -e "${spaces}${greenplus} Decompressing ${ROCKYOU_GZIP}"
gzip -dqf ${ROCKYOU_GZIP}
EXIT_STATUS="$?"
check_exit_status ${APP} ${FUNCTYPE} ${EXIT_STATUS}
clean_vars
else
echo -e "${spaces}${greenminus} rockyou.txt already decompressed, skipping"
fi
}
fix_locate() {
is_installed "locate"
}
fix_htop() {
is_installed "htop"
}
fix_seclists() {
is_installed "seclists"
}
fix_flameshot() {
is_installed "flameshot"
}
fix_theharvester() {
is_installed "theharvester"
}
install_golang() {
is_installed "golang"
}
fix_go_path() {
echo -e "\n ${greenplus} Gopath Setup"
findrealuser=$(logname)
if [ "$findrealuser" == "root" ]
then
check_root_zshrc=$(cat /root/.zshrc | grep -c GOPATH)
[ -d /$findrealuser/go ] && echo -e "\n ${greenminus} go directories already exist in /$findrealuser" || echo -e "\n ${greenplus} creating directories /$findrealuser/go /$findrealuser/go/bin /$findrealuser/go/src"; mkdir -p /$findrealuser/go/{bin,src}
if [ $check_root_zshrc -ne 0 ]
then
echo -e "${spaces}${redminus} GOPATH Variables for $findrealuser already exist in /$findrealuser/.zshrc - Not changing"
else
echo -e "${spaces}${greenplus} Adding GOPATH Variables to /root/.zshrc"
eval echo -e 'export GOPATH=\$HOME/go' >> /root/.zshrc
eval echo -e 'export PATH=\$PATH:\$GOPATH/bin' >> /root/.zshrc
fi
check_root_bashrc=$(cat /root/.bashrc | grep -c GOPATH)
if [ $check_root_bashrc -ne 0 ]
then
echo -e "${spaces}${redminus} GOPATH Variables for $findrealuser already exist in /$findrealuser/.bashrc - Not changing"
else
echo -e "${spaces}${greenplus} Adding GOPATH Variables to /root/.bashrc"
eval echo -e 'export GOPATH=\$HOME/go' >> /root/.bashrc
eval echo -e 'export PATH=\$PATH:\$GOPATH/bin' >> /root/.bashrc
fi
else
check_user_zshrc=$(cat /home/$findrealuser/.zshrc | grep -c GOPATH)
[ -d /home/$findrealuser/go ] && echo -e "\n ${greenminus} go directories already exist in /home/$finduser" || echo -e "\n ${greenplus} creating directories /home/$findrealuser/go /home/$findrealuser/go/bin /home/$findrealuser/go/src"; mkdir -p /home/$findrealuser/go/{bin,src}; chown -R $findrealuser:$findrealuser /home/$findrealuser/go
if [ $check_user_zshrc -ne 0 ]
then
echo -e "${spaces}${redminus} GOPATH Variables for user $findrealuser already exist in /home/$findrealuser/.zshrc - Not Changing"
else
echo -e "${spaces}${greenplus} Adding GOPATH Variables to /home/$findrealuser/.zshrc"
eval echo -e 'export GOPATH=\$HOME/go' >> /home/$findrealuser/.zshrc
eval echo -e 'export PATH=\$PATH:\$GOPATH/bin' >> /home/$findrealuser/.zshrc
fi
check_user_bashrc=$(cat /home/$findrealuser/.bashrc | grep -c GOPATH)
if [ $check_user_bashrc -ne 0 ]
then
echo -e "${spaces}${redminus} GOPATH Variables for user $findrealuser already exist in /home/$findrealuser/.bashrc - Not Changing"
else
echo -e "${spaces}${greenplus} Adding GOPATH Variables to /home/$findrealuser/.bashrc"
eval echo -e 'export GOPATH=\$HOME/go' >> /home/$findrealuser/.bashrc
eval echo -e 'export PATH=\$PATH:\$GOPATH/bin' >> /home/$findrealuser/.bashrc
fi
fi
}
fix_nmap() {
# clam-av.nse
echo -e "\n ${greenplus} Updating clamav-exec.nse"
rm -f /usr/share/nmap/scripts/clamav-exec.nse
echo -e "${spaces}${redminus} /usr/share/nmap/scripts/clamav-exec.nse removed "
eval wget https://raw.githubusercontent.com/nmap/nmap/master/scripts/clamav-exec.nse -O /usr/share/nmap/scripts/clamav-exec.nse $silent
echo -e "${spaces}${greenplus} /usr/share/nmap/scripts/clamav-exec.nse replaced with working version"
# http-shellshock.nse
SHELLSHOCK_FIXED_NSE="./addons/fixed-http-shellshock.nse"
echo -e "\n ${greenplus} Updating http-shellshock.nse"
if [ -f ${SHELLSHOCK_FIXED_NSE} ]
then
cp -f ${SHELLSHOCK_FIXED_NSE} /usr/share/nmap/scripts/http-shellshock.nse $silent
else
eval wget https://raw.githubusercontent.com/Dewalt-arch/pimpmykali/master/fixed-http-shellshock.nse -O /usr/share/nmap/scripts/http-shellshock.nse $silent
fi
}
fix_smbconf() {
check_smb_min=$(cat /etc/samba/smb.conf | grep -c -i "client min protocol = LANMAN1")
if [ $check_smb_min -eq 1 ]
then
echo -e "\n ${greenplus} Checking /etc/samba/smb.conf "
echo -e "${spaces}${redminus} client min protocol is already set, skipping"
else