In this demonstration,
we're going to be automating attacks using Bash.
Now, this script will take a wordlist
and attempt to log into the FTP server
using each password in the wordlist.
So, we are going to demonstrate input and output management
as well as data manipulation.
As we're going through the script,
let's kind of understand what's going on here, right?
So first we have the input portion, right?
So the script starts by asking the user for two inputs:
target IP address and the path to the wordlist.
And this is done with the read command, okay?
So we're going to get the input here
and we're going to put in our target IP address.
And then we're going to also put in the wordlist, right?
So it's going to be stored in these variables.
It's going to create a prompt
once we actually run the script.
Next, we're going to read the wordlist.
The while IFS= read -r password
will loop through each password from the wordlist.
Once we input the path to the wordlist,
such as rockyou.txt file,
it will loop through each password.
Similar to how a brute-force tool like Hydra
or John the Ripper operates.
All right, so then we have the FTP command execution, okay?
So, the script runs the FTP command
and the non-interactive.
'Cause we're going to use a here document.
And so a here document is just a simple way
that a shell script provides multi-line input
directly into commands.
So basically anything between the EOF here
and the EOF there is part of the here document.
Okay?
And again, all it simply does is use any commands
in between the beginning and the end
and send it directly to the FTP command
as if it was typing it interactively.
Then we have the success check, right?
So down here we're going to use grep to go through
and search through the logs
to see if the log in attempt was successful.
So we're going to manipulate the data to a certain degree
by searching a log
and only taking the information that we need
and displaying it on the screen, right?
So what we will be displaying is if we found
the password to be successful. All right
so then we have the output just ending the script,
letting us know that it is finished running.
So again, this is going to be a simple script
to automate a brute-force attack against an FTP server,
but we're going to only use the FTP user username.
Okay?
So we're going to exit out of here.
Alright, so just like any other script,
we want to make sure we have the proper permissions
to execute this.
So we're going to do the list
and we're going to do this option.
All right, so we see we have execute permissions.
So the next thing we're going to do
is just simply run the script.
So to run the script, you simply use the dot forward slash
and then we're going to input the actual path to the script.
All right, so we have the first line, right?
So we're going to input the IP address,
we're going to use a local FTP server.
And then now we're going to use the path to the wordlist.
So I'm just going to copy and paste that in here.
And this is going to be the
user/share/wordlists/rockyou.txt,
a very common wordlist used for password cracking.
All right, so we see it's going to
display every time it's actually going.
Now this not as optimized as the other tools,
which are able to do things a lot faster.
But this is a basic example
just to get you to understand automating scripts.
So, we see that we found the password.
Okay, so the password is the word password
and the brute-force attack was complete.
All right, so again, this script is a simple example
of automating brute-force attacks using Bash.
It simply demonstrates basic input and output management
and data manipulation within the script.
I hope you enjoy this lesson
and I'll see you in the next one.