2022-03-05 13:17:15 +00:00
|
|
|
#! /bin/bash
|
|
|
|
|
2022-05-10 21:24:48 +00:00
|
|
|
# Docker sf-guest setup script (docker build)
|
|
|
|
|
2022-11-25 11:35:31 +00:00
|
|
|
CR="\e[1;31m" # red
|
|
|
|
CN="\e[0m" # none
|
|
|
|
|
|
|
|
WARN()
|
|
|
|
{
|
|
|
|
WARNS+=("$*")
|
|
|
|
}
|
|
|
|
|
|
|
|
# Fatal Error when any of the following commands fail
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# ZSH setup
|
|
|
|
sed 's/#\(.*\)prompt_symbol=/\1prompt_symbol=/g' -i /etc/skel/.zshrc
|
|
|
|
sed 's/\(\s*PROMPT=.*\)n└─\(.*\)/\1n%{%G└%}%{%G─%}\2/g' -i /etc/skel/.zshrc
|
|
|
|
sed '/\^P toggle_oneline_prompt/d' -i /etc/skel/.zshrc
|
|
|
|
echo '[[ -e /etc/shellrc ]] && source /etc/shellrc' >>/etc/skel/.zshrc
|
|
|
|
|
|
|
|
echo '[[ -e /etc/shellrc ]] && source /etc/shellrc' >>/etc/skel/.bashrc
|
|
|
|
sed 's/\(\s*\)set mouse=/"\1set mouse=/g' -i /usr/share/vim/vim90/defaults.vim
|
|
|
|
rm -f /etc/skel/.bashrc.original
|
|
|
|
rm -f /usr/bin/kali-motd /etc/motd
|
2022-03-05 13:17:15 +00:00
|
|
|
chsh -s /bin/zsh
|
2022-11-25 11:35:31 +00:00
|
|
|
useradd -s /bin/zsh user
|
|
|
|
ln -s openssh /usr/lib/ssh
|
|
|
|
sed 's/\/root/\/sec\/root/g' -i /etc/passwd
|
|
|
|
sed 's/\/home\//\/sec\/home\//g' -i /etc/passwd
|
|
|
|
|
2022-05-10 21:24:48 +00:00
|
|
|
# Docker depends on /root to exist or otherwise throws a:
|
|
|
|
# [process_linux.go:545: container init caused: mkdir /root: file exists: unknown]
|
2023-02-21 06:49:57 +00:00
|
|
|
# shellcheck disable=SC2114
|
2022-11-25 11:35:31 +00:00
|
|
|
rm -rf /root /home
|
|
|
|
mkdir -p /sec/root
|
|
|
|
ln -s /sec/root /root
|
|
|
|
ln -s /sec/home /home
|
2023-03-09 16:34:16 +00:00
|
|
|
cp -a /etc/skel/.* /sec/root
|
2022-11-25 11:35:31 +00:00
|
|
|
|
|
|
|
echo "NOT ENCRYPTED" >/sec/THIS-DIRECTORY-IS-NOT-ENCRYPTED--DO-NOT-USE.txt
|
|
|
|
|
2022-03-05 13:17:15 +00:00
|
|
|
# Need to set correct permission which may have gotten skewed when building
|
2022-07-31 13:51:59 +00:00
|
|
|
# docker inside vmbox from shared host drive. On VMBOX share all
|
2023-01-25 22:17:02 +00:00
|
|
|
# source files and directories are set to "rwxrwx--- root:vobxsf" :/
|
|
|
|
fixr()
|
|
|
|
{
|
|
|
|
local dir
|
|
|
|
dir=$1
|
|
|
|
[[ ! -d "$dir" ]] && return
|
|
|
|
|
|
|
|
find "$dir" -type f -exec chmod 644 {} \;
|
|
|
|
find "$dir" -type d -exec chmod 755 {} \;
|
|
|
|
}
|
2022-11-25 11:35:31 +00:00
|
|
|
ln -sf /sec/usr/etc/rc.local /etc/rc.local
|
|
|
|
chown root:root /etc /etc/profile.d /etc/profile.d/segfault.sh
|
2023-01-25 22:17:02 +00:00
|
|
|
chmod 755 /usr /usr/bin /usr/sbin /etc /etc/profile.d
|
2023-02-21 06:49:57 +00:00
|
|
|
chmod 755 /usr/bin/mosh-server-hook /usr/bin/xpra-hook /usr/bin/brave-browser-stable-hook /usr/share/code/code-hook /usr/share/code/bin/code-hook /usr/bin/xterm-dark /usr/sbin/halt
|
2022-11-25 11:35:31 +00:00
|
|
|
chmod 644 /etc/profile.d/segfault.sh
|
|
|
|
chmod 644 /etc/shellrc /etc/zsh_command_not_found /etc/zsh_profile
|
2023-01-25 22:17:02 +00:00
|
|
|
fixr /usr/share/www
|
|
|
|
fixr /usr/share/source-highlight
|
2022-11-25 11:35:31 +00:00
|
|
|
ln -s batcat /usr/bin/bat
|
2023-03-09 16:34:16 +00:00
|
|
|
[[ ! -e /usr/bin/cme ]] && ln -s crackmapexec /usr/bin/cme
|
2022-11-25 11:35:31 +00:00
|
|
|
ln -s /sf/bin/sf-motd.sh /usr/bin/motd
|
|
|
|
ln -s /sf/bin/sf-motd.sh /usr/bin/help
|
2023-02-19 17:15:42 +00:00
|
|
|
ln -s /sf/bin/sf-motd.sh /usr/bin/info
|
|
|
|
rm -f /usr/sbin/shutdown /usr/sbin/reboot
|
|
|
|
ln -s /usr/sbin/halt /usr/sbin/shutdown
|
|
|
|
ln -s /usr/sbin/halt /usr/sbin/reboot
|
2023-02-21 06:49:57 +00:00
|
|
|
[[ ! -e /usr/bin/vscode ]] && ln -sf /usr/bin/code /usr/bin/vscode
|
2023-02-19 17:15:42 +00:00
|
|
|
# No idea why /etc/firefox-esr does not work...
|
|
|
|
if [[ -e /usr/lib/firefox/defaults/pref/channel-prefs.js ]]; then
|
|
|
|
echo 'pref("network.dns.blockDotOnion", false);
|
|
|
|
pref("browser.tabs.inTitlebar", 1);
|
|
|
|
pref("browser.shell.checkDefaultBrowser", false);' >>/usr/lib/firefox/defaults/pref/channel-prefs.js
|
|
|
|
else
|
|
|
|
[[ -e /usr/bin/firefox ]] && WARN "Firefox config could not be updated."
|
|
|
|
fi
|
|
|
|
ln -s /usr/games/lolcat /usr/bin/lolcat
|
2022-11-25 11:35:31 +00:00
|
|
|
set +e
|
|
|
|
|
|
|
|
# Non-Fatal. WARN but continue if any of the following commands fail
|
2022-11-25 19:31:26 +00:00
|
|
|
sed 's/^TorAddress.*/TorAddress 172.20.0.111/' -i /etc/tor/torsocks.conf || WARN "Failed /etc/tor/torsocks.conf"
|
2023-03-06 18:22:50 +00:00
|
|
|
sed 's/^worker_processes.*/worker_processes 2;/' -i /etc/nginx/nginx.conf || WARN "Failed /etc/nginx/nginx.conf"
|
2022-11-25 11:35:31 +00:00
|
|
|
|
2023-02-19 17:15:42 +00:00
|
|
|
# Move "$1" to "$1".orig and link "$1" -> "$1"-hook
|
|
|
|
mk_hook()
|
|
|
|
{
|
|
|
|
local fn
|
|
|
|
fn="${1}/${2}"
|
|
|
|
[[ ! -e "$fn" ]] && return
|
|
|
|
( cd "${1}"
|
|
|
|
mv "$fn" "${fn}.orig"
|
|
|
|
ln -s "${fn}-hook" "$fn" )
|
|
|
|
}
|
|
|
|
mk_hook /usr/bin mosh-server
|
|
|
|
mk_hook /usr/bin xpra
|
|
|
|
mk_hook /usr/bin brave-browser-stable
|
|
|
|
mk_hook /usr/bin chromium
|
2023-02-21 06:49:57 +00:00
|
|
|
mk_hook /usr/share/code/bin code
|
2023-02-19 17:15:42 +00:00
|
|
|
mk_hook /usr/share/code code
|
2023-02-21 06:49:57 +00:00
|
|
|
[[ -f /usr/share/code/bin/code.orig ]] && sed 's/PATH\/code\"/PATH\/code.orig\"/' -i /usr/share/code/bin/code.orig
|
2023-01-12 10:43:33 +00:00
|
|
|
|
2022-11-25 11:35:31 +00:00
|
|
|
# Output warnings and wait (if there are any)
|
|
|
|
[[ ${#WARNS[@]} -gt 0 ]] && {
|
|
|
|
while [[ $i -lt ${#WARNS[@]} ]]; do
|
|
|
|
((i++))
|
2022-11-25 19:31:26 +00:00
|
|
|
echo -e "[${CR}WARN #$i${CN}] ${WARNS[$((i-1))]}"
|
2022-11-25 11:35:31 +00:00
|
|
|
done
|
|
|
|
echo "Continuing in 5 seconds..."
|
|
|
|
sleep 5
|
|
|
|
}
|
|
|
|
|
|
|
|
exit 0
|