Skip to content

Instantly share code, notes, and snippets.

Created Aug 24, 2020
What would you like to do?
#!/usr/bin/env bash
# prep & organization script for hackthebox machines. Creates directories, searches and replaces
# ip address/name of of the box in common commands used in recon etc.
echo "Enter name of the box : "
read boxname
echo "Enter ip address of $boxname: "
read boxipad
# create directories
mkdir -p ~/hackthebox/$boxname/{wordlist,nmap,exploits,downloads,uploads} &&
# create file for taking notes
touch ~/hackthebox/$boxname/$ &&
# copy some files
cp ~/gelgit/shelly/ ~/hackthebox/$boxname/ &&
# search and replace array
declare -A srarray
[%%LOCAL_IP%%]=$(ip add | grep -A 1 'tun0' | grep inet | cut -d "/" -f 1 | awk '{$1=$1;print}' | cut -d " " -f 2)
# search and replace loop
sr() {
# Loop the config array
for i in "${!srarray[@]}"
sed -i "s/${search}/${replace}/g" ~/hackthebox/$boxname/
sr &&
# hosts file add ipaddress and boxname
echo "$boxipad $boxname" | sudo tee -a /etc/hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment