Just a basic script
Morten Hansen • March 19, 2021
Just a basic script
Today I watched a YouTube-video from The Cyber Mentor (link below) about creating a simple bash script in order to perform some website enumeration. Some hours later I was working with a machine at HackTheBox and it occured to me.
Whenever I take a go at a new machine, I always create the same folders. How about I create a script that would do it for me? I gave it a go and ended up with something like this.
#!/bin/bash
if [ $# -gt 1 ]; then
echo "Usage: ./makdir.sh <machine name>"
echo "Example: ./makdir.sh easyLinux"
echo "Only takes one argument"
exit 1
fi
if [ ! -d $1 ]; then
mkdir $1
mkdir $1/NMAP
mkdir $1/enum
mkdir $1/nikto
mkdir $1/CVE
mkdir $1/search
mkdir $1/notes
echo "Directory structure created!"
echo "Goodbye..."
else
echo "Error: Directory exsists"
echo "Try another name or delete existing directory (check the content of the folder before deleting)"
fi
The script takes one argument and produces a folder with the same name, before it produces the subfolders I have put in the code.
I have not written that many scripts in bash so it was a result of trial and error. At the end I managed to create something useful and time-saving. I tought it was a cool and practical way to implement some new learning.
Link to the YouTube video: The Cyber Mentor
Best regards
M.