Black-Hat Bash scripting part 1
Before I begin, i am going with the premise that I have no scripting language whatsoever so kinda like a greenhorn. Building the foundation by using the book black hat bash as a resource in case you are curious. Excited to see what i can garner from this.
The first thing i took note of bash=linux.
What do i mean by this?
the commands you type on the linux command line are no different from the script you write that go line by line. A script just brings things to life and as a penetration tester you wanna ensure to not do tedious tasks e.g movies, trading A.I programs(trading bots), tv shows…you get the picture
What does a bash script contain?
Shebang- the most common characters that every script in a programming language starts with, without it..eh that script won’t come alive(#!) think of it this way it’s like serving Gordon Ramsay a Beef Wellington that is not cooked.
i could be wrong here remember i am a greenhorn so constructive positive criticism is appreciated,(don’t be a donkey hehe).
Comments- say it with me comments save time (#), you could write one of the best scripts in your journey and a few years pass and suddenly you see the script again or some poor developer chap sees your script and is trying to understand it and asks you for assistance, sadly you weren’t blessed with sheldon’s photographic mind so you are wondering what was your thinking process. Don’t worry just don’t be Dory.
execution of a script- a script won’t run without you giving it permission as follows: chmod u+x program.sh
Variables- bash variables are a bit different than your pal the snake where you are storing values and are case sensitive, while in bash they are untyped meaning character strings within context of course. Let’s see if i get this for a variable right:
card=”Texas hold ’em”
so i have created a variable card that has assigned the vlaue of the game texas hold’em to it.
so if i try this: echo “The name of the game is called ${card}. i should receive the output: The name of the game is Texas hold’em
something is not right
The following rules govern the naming of bash variables: They can include alphanumeric characters.
They cannot start with a numerical character.
They can contain an underscore (_).
They cannot contain whitespace.
This was fun, wonder if i can hack the pentagon now
Till next time
May you always be in a state of flow.