Today, sadly, might be the last episode of DIY pentest dropbox tips for a while because I found (well, ChatGPT did actually) the missing link to 100% automate a Kali Linux install! Check episode #449 for more info on building your Kali preseed file, but essentially the last line in my file runs a script to download/install all the pentest tools I want. The “missing link” part is I figured out how to get Kali to reboot and then run a script one time to complete all the post-install stuff. So at the bottom of my is this:

sudo wget https://somesite/ -O /opt/
sudo chmod +x /opt/
sudo touch /flag
sudo wget https://somesite/docker.service -O /etc/systemd/system/mydocker.service
sudo systemctl daemon-reload
sudo systemctl enable mydocker.service


The contents of docker.service are:

Description=Docker install




The beginning and end snippets of are:

if [ -e "$flag_file" ]; then
# get bbot
sudo docker run -it blacklanternsecurity/bbot:stable --help
# Do a bunch of other install things...
rm "$flag_file"

echo "Script already ran before. Exiting"

So essentially the work flow is: runs, downloads and installs, and also installs a service that runs on each reboot. But when runs, it checks for the presence of a file called /flag. If /flag exists, all the post-install commands will run. If it does not exist, those commands won’t run. Simple, yet genius I think!

Tags: ,

Written by: Brian Johnson

Share on socials: