Skip to content

Commit 8805334

Browse files
committed
user tweaks: only install nvim+pwndbg for 'student'
+ also install zsh/tmux/fzf tweaks for 'hacker' and 'admin'
1 parent cb111a8 commit 8805334

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

labvm/scripts/full-snippets.d/41-user-tweaks.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
function _install_home_config() {
77
set -e
88
# install labvm-dotfiles:
9-
"$ISC_SRC/files/labvm-dotfiles/install.sh"
9+
COMPONENTS=()
10+
if [[ "$USER" == "root" ]]; then COMPONENTS+=(-nvim); fi
11+
"$ISC_SRC/files/labvm-dotfiles/install.sh" "${COMPONENTS[@]}"
1012

11-
# pwndbg!
13+
# pwndbg (only for 'student' user)
14+
if [[ "$USER" != "student" ]]; then return 0; fi
1215
[[ -d "$HOME/.pwndbg" ]] || git clone https://github.com/pwndbg/pwndbg "$HOME/.pwndbg"
1316
(
1417
cd "$HOME/.pwndbg";
@@ -19,6 +22,7 @@ function _install_home_config() {
1922
# upgrade pip itself
2023
${PYTHON} -m pip install --upgrade pip uv
2124
${PWNDBG_VENV_PATH}/bin/uv sync --extra gdb --quiet
25+
${PWNDBG_VENV_PATH}/bin/uv cache clean
2226
echo "source $PWD/gdbinit.py" > "$HOME/.gdbinit"
2327
)
2428
}

labvm/scripts/full-snippets.d/42-admin-user.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,13 @@ echo 'admin ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/admin
1414
# Note: this will be changed in private cloud VMs
1515
echo "admin:admin1337" | chpasswd
1616

17+
# install labvm-dotfiles for 'admin' user, too
18+
function _install_admin_config() {
19+
set -e
20+
# no need for nvim config
21+
"$ISC_SRC/files/labvm-dotfiles/install.sh" -nvim
22+
}
23+
_exported_script="$(declare -p ISC_SRC); $(declare -f _install_admin_config)"
24+
chsh -s /usr/bin/zsh "admin"
25+
echo "$_exported_script; _install_admin_config" | su -c bash "admin"
26+

labvm/scripts/full-snippets.d/55-network-attacks.sh

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@
22
# A simple guest account-based attack-defense scenario for the networking lab
33

44
# add "hacker" (our guest) account
5-
id -g hacker 1>/dev/null 2>/dev/null || groupadd -g 1337 hacker
6-
id -u hacker 1>/dev/null 2>/dev/null || useradd -m -u 1337 -g 1337 -s /usr/bin/bash hacker
7-
usermod -L -e 1 hacker
8-
echo "hacker:student" | chpasswd
5+
sh_create_user hacker 1337
6+
usermod -e -1 hacker
7+
echo "hacker:student31337" | chpasswd
98

10-
if [[ -n "$DEBUG" && "$DEBUG" -gt 0 ]]; then
11-
# unlock the user!
12-
usermod -e -1 -U hacker
13-
fi
9+
# install labvm-dotfiles for 'hacker' user, too
10+
function _install_hacker_config() {
11+
set -e
12+
# hackers use vanilla vim!
13+
"$ISC_SRC/files/labvm-dotfiles/install.sh" -nvim
14+
}
15+
_exported_script="$(declare -p ISC_SRC); $(declare -f _install_hacker_config)"
16+
chsh -s /usr/bin/zsh "hacker"
17+
echo "$_exported_script; _install_hacker_config" | su -c bash "hacker"
1418

1519
# make ssh-ing to guest possible only from inside the OpenStack network
1620
cat <<EOF >"/etc/ssh/sshd_config.d/30-hacker.conf"
@@ -22,3 +26,10 @@ Match User "hacker"
2226
PasswordAuthentication yes
2327
EOF
2428

29+
# finally, lock & expire password for hacker to make in un-loggable for now
30+
usermod -L -e 1 hacker
31+
if [[ -n "$DEBUG" && "$DEBUG" -gt 0 ]]; then
32+
# unlock the user!
33+
usermod -e -1 -U hacker
34+
fi
35+

0 commit comments

Comments
 (0)