-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-kali.sh
182 lines (150 loc) · 6.09 KB
/
setup-kali.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
#!/bin/bash
# Setup Kali from installation
# Tested 2020-05-25 with Kali 2020.2 installer, x64, in VirtualBox.
# $ git clone https://github.com/benhunter/scripts; chmod +x ./scripts/setup-kali.sh; ./scripts/setup-kali.sh
# Update repo in place
# https://stackoverflow.com/questions/1125968/how-do-i-force-git-pull-to-overwrite-local-files
# git reset --hard HEAD; git pull
# Pause for debugging if needed:
# read -p "Press Enter key to continue." # TODO remove
# Prompt for sudo if not root.
if [[ $EUID != 0 ]]; then
echo $?
sudo "$0" "$@"
exit $?
fi
echo "Running as root."
CWD=$(pwd) # store working directory to cleanly return to it later
echo '$SUDO_USER' $SUDO_USER
HOME_DIR=$(eval echo ~`logname`) # Home directory of the user running the script.
echo '$HOME_DIR' $HOME_DIR
# Get path to script that is running.
# https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
echo '$SCRIPT_DIR' $SCRIPT_DIR
# echo '~' ~
# update-apt.sh must be in the same directory
if [[ -e $SCRIPT_DIR/update-apt.sh ]]; then
echo "Running update-apt.sh"
chmod +x $SCRIPT_DIR/update-apt.sh
$SCRIPT_DIR/update-apt.sh
else
echo "Could not find update-apt.sh. Exiting."
exit
fi
# Install more apt packages
echo "Installing apt packages..."
# VirtualBox guest additions are auto-installed?
apt -y install kali-linux-everything # https://tools.kali.org/kali-metapackages
# More packages.
# Htop, tree, gobuster
# Python pip3, pip for virtual environments
# ssss - Shamir's secret sharing scheme
# ExifTool https://github.com/exiftool/exiftool
# Hex editor for GNOME https://wiki.gnome.org/Apps/Ghex
apt -y install htop tree gobuster python3-venv python-pip ssss libimage-exiftool-perl ghex jq powerline fonts-powerline joplin
# Install special software
# Snap (for VSCode)
echo "Installing and enabling snap..."
apt -y install snapd # Install snapcraft.io store
# Additionally, enable and start both the snapd and the snapd.apparmor services with the following command:
systemctl enable --now snapd apparmor
# To test your system, install the hello-world snap and make sure it runs correctly:
# $ snap install hello-world
# $ hello-world 6.3 from Canonical✓ installed
# $ hello-world
# Hello World!
# Install Snap Store App
# $ sudo snap install snap-store
# Add snap to path and update .bash_profile
# https://github.com/thoughtbot/til/blob/master/bash/bash_profile_vs_bashrc.md
# if [[ -e ~/.bash_profile ]]; then
echo "Updating ~/.bash_profile..."
echo 'export PATH=$PATH:/snap/bin' >> $HOME_DIR/.bash_profile
chown $SUDO_USER:$SUDO_USER $HOME_DIR/.bash_profile
# fi
# Visual Studio Code / VSCode
# TODO check out VSCodium https://vscodium.com/
# https://snapcraft.io/docs/installing-snap-on-kali
echo "Installing VSCode..."
snap install --classic code
# To execute:
# snap run code
# code # if '/snap/bin' is in $PATH
# TODO How to add a shortcut to the start menu?
# Install Zsteg
# https://0xrick.github.io/lists/stego/
# sudo gem install zsteg
# Ghidra
cd $HOME_DIR/Downloads
# curl -s https://api.github.com/repos/NationalSecurityAgency/ghidra/tags | grep -m1 zip | cut -d '"' -f 4 | wget -qi -
# GHIDRA_GITHUB=`curl -s https://api.github.com/repos/NationalSecurityAgency/ghidra/tags`
# GHIDRA_ZIP=`echo $GHIDRA_GITHUB | jq '.[0].name'`
# GHIDRA_ZIP_URL=`echo $GHIDRA_GITHUB | jq '.[0].zipball_url'`
# wget $GHIDRA_ZIP_URL
GHIDRA_VERSION=9.1.2
GHIDRA_ZIP=ghidra_9.1.2_PUBLIC_20200212.zip
wget "https://ghidra-sre.org/$GHIDRA_ZIP"
chown $SUDO_USER:$SUDO_USER $GHIDRA_ZIP
unzip $GHIDRA_ZIP
chown -R $SUDO_USER:$SUDO_USER ghidra_"$GHIDRA_VERSION"_PUBLIC
mv ghidra_"$GHIDRA_VERSION"_PUBLIC /opt/
cd $HOME_DIR
# Download git repos
# RSA CTF Tool
mkdir $HOME_DIR/GitHub
cd $HOME_DIR/GitHub
git clone https://github.com/Ganapati/RsaCtfTool
if [[ -d ./RsaCtfTool ]]; then
cd ./RsaCtfTool
python3 -m venv --system-site-packages venv
source ./venv/bin/activate
sudo apt -y install libmpc-dev # and libmpfr-dev ?
pip install -r requirements.txt
# SageMath package was removed from kali apt...
deactivate # exit virtual environment
chown -R $SUDO_USER:$SUDO_USER $HOME_DIR/GitHub
cd $HOME_DIR
else
echo "FAILED: git clone https://github.com/Ganapati/RsaCtfTool"
exit
fi
# Install Python Packages
pip3 install pwntools
# Output:
# WARNING: The scripts asm, checksec, common, constgrep, cyclic, debug, disablenx, disasm, elfdiff, elfpa
# tch, errno, hex, main, phd, pwn, pwnstrip, scramble, shellcraft, template, unhex and update are installed
# in '/home/kali/.local/bin' which is not on PATH.
# Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script
# -location.
# config anything else
echo 'alias ll="ls -lahF"' >> $HOME_DIR/.bash_aliases
echo 'alias tt="tree -lahfs"' >> $HOME_DIR/.bash_aliases
chown $SUDO_USER:$SUDO_USER $HOME_DIR/.bash_aliases
# Unpack RockYou.txt wordlist
gunzip /usr/share/wordlists/rockyou.txt.gz
# TODO check owner of rockyou
# Firefox Addons
# sshd
# Powerline for Bash
# apt -y install powerline fonts-powerline # already executed
echo >> $HOME_DIR/.bashrc
echo '# Powerline' >> $HOME_DIR/.bashrc
echo '# config goes in ~/.confg/powerline/config.json' >> $HOME_DIR/.bashrc
echo 'if [ -f `which powerline-daemon` ]; then' >> $HOME_DIR/.bashrc
echo ' powerline-daemon -q' >> $HOME_DIR/.bashrc
echo ' POWERLINE_BASH_CONTINUATION=1' >> $HOME_DIR/.bashrc
echo ' POWERLINE_BASH_SELECT=1' >> $HOME_DIR/.bashrc
echo ' . /usr/share/powerline/bindings/bash/powerline.sh' >> $HOME_DIR/.bashrc
echo 'fi' >> $HOME_DIR/.bashrc
echo >> $HOME_DIR/.bashrc
# Powerline for tmux
echo 'source "/usr/share/powerline/bindings/tmux/powerline.conf"' >> $HOME_DIR/.tmux.conf
echo >> $HOME_DIR/.tmux.conf
chown $SUDO_USER:$SUDO_USER $HOME_DIR/.tmux.conf
echo >> $HOME_DIR/.bash_profile
echo '. ~/.bashrc' >> $HOME_DIR/.bash_profile
echo >> $HOME_DIR/.bash_profile
# Cleanup
cd $CWD # Go back to the directory where the script started.
echo "Please reboot (snapshot if needed)..."