courses

#!/usr/bin/env zsh

echo "Updating software..."
sudo apt update
sudo apt full-upgrade -y

echo "Installing software..."
#install necessary tools
sudo apt -q -y install autojump\
    curl\
    git\
    build-essential libssl-dev zlib1g-dev \
    libbz2-dev libreadline-dev libsqlite3-dev curl git \
    libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \
    bat\
    zsh\
    tmux\
    emacs\
    gdb\
    python3-pip\
    kali-defaults\
    kali-root-login\
    xrdp\
    kali-linux-everything\
    eza\
    groff\
    bc\
    dc\
    lshw\
    shfmt\
    xml-twig-tools\
    rizin-cutter\
    cmake\
    lolcat\
    cowsay\
    figlet\
    filters\
    fortunes\
    bsdgames\
    dos2unix\
    fastfetch\
    asciinema\
    avahi-daemon\
    snapd\
    keychain\
    multitail\
    python3-pyx\
    squashfs-tools\
    squashfs-tools-ng\
    ghidra\
    rz-ghidra\
    zlib1g-dev\
    liblzma-dev\
    liblzo2-dev\
    docker.io\
    xfsprogs\
    libboost-all-dev\
    python3-rpyc\
    fontforge\
    doxygen\
    python3-scipy\
    python3-numpy\
    bpython\
    graphviz\
    ruby-dev\
    autojump\
    gdb-multiarch\
    gdbserver\
    gawk\
    python3-full\
    virtualenv\
    lldb\
    hexyl\
    sipcalc\
    kismet\
    gawk\
    direnv\
    tmuxinator\
    python3-scapy\
    python3-netifaces\
    fzf\
    wireshark\
    kali-grant-root\
    nvidia-driver-full\
    nvidia-cuda-dev\
    voltron\
    chafa

if [ $? -ne 0 ]; then
    echo "apt installation failure"
    echo "Please correct the error and run this script again"
    exit
fi


type colorls > /dev/null 2>&1
if [ $? -ne 0 ]; then
    sudo gem install colorls mdless
    if [ $? -ne 0 ]; then
        echo "gem installation failure"
        echo "Please correct the error and run this script again"
        exit
    fi
fi

mkdir -p $HOME/bin
mkdir -p $HOME/clones

#enable i386 and amd64 binary support (ONLY RUN ON ARM HOSTS!)
#uncomment if you desire this functionality
# sudo apt install -y qemu-user-static binfmt-support
# sudo dpkg --add-architecture amd64
# sudo dpkg --add-architecture i386
# sudo apt update
# sudo apt install libc6:amd64
# sudo apt install libc6:i386

# you can also enable arm binary support on amd64 hosts if you want to, for whatever reason
# sudo apt install -y qemu-user-static binfmt-support
# sudo dpkg --add-architecture aarch64
# sudo dpkg --add-architecture armhf
# sudo apt update
# sudo apt install libc6:aarch64
# sudo apt install libc6:armhf

#install a known version of python and use that as the default

type pyenv > /dev/null 2>&1
if [ $? -ne 0 ]; then
    curl https://pyenv.run | bash

    if [ $? -ne 0 ]; then
        echo "pyenv installation failure"
        echo "Please correct the error and run this script again"
        exit
    fi

    PYENV_ROOT="$HOME/.pyenv"
    PATH="$PYENV_ROOT/bin:$PATH"
    eval "$(pyenv init -)"
    eval "$(pyenv virtualenv-init -)"

    pyenv install 3.12.6
    pyenv global 3.12.6
fi

PYENV_ROOT="$HOME/.pyenv"
PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

pip install --upgrade pip requests python-dateutil scapy

#install gef
if [ ! -e .gef-*.py ]; then
    bash -c "$(curl -fsSL https://gef.blah.cat/sh)"
fi

if [ ! -d $HOME/.config/gef-extras ]; then
    curl -L -o - https://github.com/hugsy/gef/raw/main/scripts/gef-extras.sh | sh
    pip install -r $HOME/.config/gef-extras/requirements.txt
fi

#install rust
if [ ! -d $HOME/.cargo ]; then
    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
fi

type atuin > /dev/null 2>&1
if [ $? -ne 0 ]; then
    curl -L https://raw.githubusercontent.com/atuinsh/atuin/main/install.sh | bash
fi

if [ ! -e $HOME/antigen.zsh ]; then
    curl -L git.io/antigen > $HOME/antigen.zsh
fi

if [ ! -d $HOME/clones/sunwait ]; then
    git clone https://github.com/risacher/sunwait.git $HOME/clones/sunwait
    cd $HOME/clones/sunwait
    make
    ln -s $HOME/clones/sunwait/sunwait $HOME/bin/sunwait
    cd $HOME
fi

if [ ! -d $HOME/clones/bat-extras ]; then
    git clone https://github.com/eth-p/bat-extras.git $HOME/clones/bat-extras
    cd $HOME/clones/bat-extras
    sudo ./build.sh --install
    cd $HOME
fi

if [ ! -d $HOME/clones/diff-so-fancy ]; then
    git clone https://github.com/so-fancy/diff-so-fancy.git $HOME/clones/diff-so-fancy
fi

if [ ! -d $HOME/.tmux/plugins/tpm ]; then
    mkdir -p $HOME/.tmux/plugins/tpm
    git clone https://github.com/tmux-plugins/tpm $HOME/.tmux/plugins/tpm
fi

if [ ! -d $HOME/.oh-my-zsh ]; then
    git clone https://github.com/ohmyzsh/ohmyzsh.git $HOME/.oh-my-zsh
fi

if [ ! -d $HOME/clones/nerd-fonts ]; then
    git clone --filter=blob:none --sparse https://github.com/ryanoasis/nerd-fonts.git $HOME/clones/nerd-fonts
    cd $HOME/clones/nerd-fonts
    git sparse-checkout add patched-fonts/Hack
    ./install.sh
    cd $HOME
fi

if [ ! -d $HOME/clones/astral ]; then
    git clone https://github.com/sffjunkie/astral.git $HOME/clones/astral
fi

if [ ! -e $HOME/bin/diff-so-fancy ]; then
    ln -s $HOME/clones/diff-so-fancy/diff-so-fancy $HOME/bin/diff-so-fancy
fi

sudo chsh -s $(which zsh) $(whoami)
sudo usermod -aG docker,kali-trusted,wireshark $(whoami)

if [ ! -e $HOME/.zshrc.local ]; then
    curl http://web.cecs.pdx.edu/~dmcgrath/setup.tar.bz2 | tar xjvf - -C ~/    
fi

sudo systemctl enable --now avahi-daemon
sudo systemctl enable --now snapd
sudo systemctl enable --now snapd.apparmor
sudo systemctl enable --now docker
sudo systemctl enable --now xrdp
sudo systemctl enable --now ssh


###############=====================################
###############= git configuration =################
git config unset --global user.name
#fill in and uncomment the next two lines!
#git config --global user.name ""
#git config --global user.email ""
git config get --global user.name > /dev/null
if [ $? -ne 0 ]; then
    echo "Please set your git user.name and user.email!"
    echo "You were prompted to do this, but you didn't!"
    echo "git config --global user.name \"Your Name Here\""
    echo "git config --global user.email \"ODIN@pdx.edu\""
fi


git config --global core.pager "diff-so-fancy | less --tabs=4 -RFX"
git config --global interactive.diffFilter "diff-so-fancy --patch"
git config --global color.ui true
git config --global color.diff-highlight.oldNormal    "red bold"
git config --global color.diff-highlight.oldHighlight "red bold 52"
git config --global color.diff-highlight.newNormal    "green bold"
git config --global color.diff-highlight.newHighlight "green bold 22"
git config --global color.diff.meta       "11"
git config --global color.diff.frag       "magenta bold"
git config --global color.diff.func       "146 bold"
git config --global color.diff.commit     "yellow bold"
git config --global color.diff.old        "red bold"
git config --global color.diff.new        "green bold"
git config --global color.diff.whitespace "red reverse"

exec zsh