From 59fb5c611b2f5b58d838f4f7e41133006e6e2577 Mon Sep 17 00:00:00 2001 From: Tommy Date: Sun, 28 Apr 2024 13:41:30 -0700 Subject: [PATCH] Better handling for Parallels Signed-off-by: Tommy --- Fedora-Workstation-40.sh | 16 ++++++++++------ Kali-Linux.sh | 26 ++++++++++++++++++++++++++ Ubuntu-23.10-Desktop.sh | 28 ++++++++++++++++++++++++---- 3 files changed, 60 insertions(+), 10 deletions(-) diff --git a/Fedora-Workstation-40.sh b/Fedora-Workstation-40.sh index b036ca2..86452b6 100644 --- a/Fedora-Workstation-40.sh +++ b/Fedora-Workstation-40.sh @@ -39,6 +39,8 @@ install_options(){ esac } +install_options + # Increase compression level sudo sed -i 's/zstd:1/zstd:3/g' /etc/fstab @@ -55,11 +57,15 @@ echo 'umask 077' | sudo tee -a /etc/bashrc sudo chmod 700 /home/* # Setup NTS -sudo rm -rf /etc/chrony.conf -unpriv curl https://raw.githubusercontent.com/GrapheneOS/infrastructure/main/chrony.conf | sudo tee /etc/chrony.conf -unpriv curl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/sysconfig/chronyd | sudo tee /etc/sysconfig/chronyd +if [ "${parallels}" = "1" ]; then + sudo dnf -y remove chrony +else + sudo rm -rf /etc/chrony.conf + unpriv curl https://raw.githubusercontent.com/GrapheneOS/infrastructure/main/chrony.conf | sudo tee /etc/chrony.conf + unpriv curl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/sysconfig/chronyd | sudo tee /etc/sysconfig/chronyd -sudo systemctl restart chronyd + sudo systemctl restart chronyd +fi # Remove nullok sudo /usr/bin/sed -i 's/\s+nullok//g' /etc/pam.d/system-auth @@ -82,8 +88,6 @@ sudo chmod 644 /etc/sysctl.d/30_security-misc_kexec-disable.conf sudo dracut -f sudo sysctl -p -install_options - if [ -d /boot/loader ]; then if [ "${parallels}" = "1" ]; then sudo sed -i 's/quiet root/quiet mitigations=auto,nosmt spectre_v2=on spec_store_bypass_disable=on tsx=off kvm.nx_huge_pages=force nosmt=force l1d_flush=on spec_rstack_overflow=safe-ret random.trust_bootloader=off random.trust_cpu=off intel_iommu=on amd_iommu=force_isolation efi=disable_early_pci_dma iommu=force iommu.passthrough=0 iommu.strict=1 slab_nomerge init_on_alloc=1 init_on_free=1 pti=on vsyscall=none ia32_emulation=0 page_alloc.shuffle=1 randomize_kstack_offset=on debugfs=off root/g' /etc/kernel/cmdline diff --git a/Kali-Linux.sh b/Kali-Linux.sh index 5deb733..8385281 100644 --- a/Kali-Linux.sh +++ b/Kali-Linux.sh @@ -23,12 +23,38 @@ unpriv(){ sudo -u nobody "$@" } +install_options(){ + output "Are you using a Parallels Virtual Machine?" + output "[1] Yes" + output "[2] No" + read -r choice + case $choice in + 1 ) parallels=1 + ;; + 2 ) parallels=0 + ;; + * ) output "You did not enter a valid selection." + install_options + esac +} + +install_options + # Update Kali sudo apt full-upgrade -y # Install all tools sudo apt install kali-linux-everything -y +# Setup NTS +sudo systemctl mask systemd-timesyncd + +if [ "${parallels}" = "0" ]; then + sudo apt install -y chrony + unpriv curl https://raw.githubusercontent.com/GrapheneOS/infrastructure/main/chrony.conf | sudo tee /etc/chrony/chrony.conf + sudo systemctl restart chronyd +fi + # Kernel hardening unpriv curl https://raw.githubusercontent.com/Kicksecure/security-misc/master/etc/modprobe.d/30_security-misc.conf | sudo tee /etc/modprobe.d/30_security-misc.conf sudo chmod 644 /etc/modprobe.d/30_security-misc.conf diff --git a/Ubuntu-23.10-Desktop.sh b/Ubuntu-23.10-Desktop.sh index 515a0b9..1ceac56 100644 --- a/Ubuntu-23.10-Desktop.sh +++ b/Ubuntu-23.10-Desktop.sh @@ -24,6 +24,23 @@ unpriv(){ sudo -u nobody "$@" } +install_options(){ + output "Are you using a Parallels Virtual Machine?" + output "[1] Yes" + output "[2] No" + read -r choice + case $choice in + 1 ) parallels=1 + ;; + 2 ) parallels=0 + ;; + * ) output "You did not enter a valid selection." + install_options + esac +} + +install_options + # Compliance and updates sudo systemctl mask debug-shell.service @@ -47,10 +64,13 @@ sudo sed -i 's/USERGROUPS_ENAB yes/USERGROUPS_ENAB no/g' /etc/login.defs echo 'umask 077' | sudo tee --append /etc/profile # Setup NTS -sudo systemctl disable systemd-timesyncd -sudo apt install -y chrony -unpriv curl https://raw.githubusercontent.com/GrapheneOS/infrastructure/main/chrony.conf | sudo tee /etc/chrony/chrony.conf -sudo systemctl restart chronyd +sudo systemctl mask systemd-timesyncd + +if [ "${parallels}" = "0" ]; then + sudo apt install -y chrony + unpriv curl https://raw.githubusercontent.com/GrapheneOS/infrastructure/main/chrony.conf | sudo tee /etc/chrony/chrony.conf + sudo systemctl restart chronyd +fi # Harden SSH unpriv curl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/ssh/ssh_config.d/10-custom.conf | sudo tee /etc/ssh/ssh_config.d/10-custom.conf