WEBVTT

00:00:00.000 --> 00:00:03.395 align:middle line:90%


00:00:03.395 --> 00:00:07.760 align:middle line:90%
[ELECTRONIC MUSIC]

00:00:07.760 --> 00:00:10.200 align:middle line:90%


00:00:10.200 --> 00:00:12.060 align:middle line:90%
Meterpreter fundamentals.

00:00:12.060 --> 00:00:14.190 align:middle line:84%
In this video, we are
going to be exploring

00:00:14.190 --> 00:00:16.379 align:middle line:84%
the process of utilizing
the Meterpreter

00:00:16.379 --> 00:00:18.540 align:middle line:84%
shell, or the
Meterpreter session,

00:00:18.540 --> 00:00:22.080 align:middle line:84%
as it's also known as, to
essentially navigate around

00:00:22.080 --> 00:00:24.960 align:middle line:84%
the target system,
perform a few commands--

00:00:24.960 --> 00:00:28.500 align:middle line:84%
or execute a few commands,
and of course just get

00:00:28.500 --> 00:00:31.740 align:middle line:84%
an understanding of how
to utilize a Meterpreter

00:00:31.740 --> 00:00:35.910 align:middle line:84%
session as well as how to manage
your Meterpreter sessions.

00:00:35.910 --> 00:00:38.280 align:middle line:84%
So before we actually
get started with that,

00:00:38.280 --> 00:00:41.490 align:middle line:84%
we are currently within the
post-exploitation section

00:00:41.490 --> 00:00:42.610 align:middle line:90%
of this course.

00:00:42.610 --> 00:00:45.690 align:middle line:84%
So if we take a look at the
graph that we highlighted

00:00:45.690 --> 00:00:50.220 align:middle line:84%
or that we explored during
the introductory section

00:00:50.220 --> 00:00:52.470 align:middle line:84%
to this course, you
can see that we've

00:00:52.470 --> 00:00:55.740 align:middle line:84%
completed information
gathering, enumeration, as well

00:00:55.740 --> 00:00:57.300 align:middle line:90%
as vulnerability scanning.

00:00:57.300 --> 00:01:00.390 align:middle line:84%
And we've also explored
exploitation on both Windows

00:01:00.390 --> 00:01:01.770 align:middle line:90%
and Linux systems.

00:01:01.770 --> 00:01:04.420 align:middle line:84%
We are now at the
post-exploitation phase,

00:01:04.420 --> 00:01:07.230 align:middle line:84%
which also consists
of its own sub-phases.

00:01:07.230 --> 00:01:10.500 align:middle line:84%
And, again, as an introduction
to post-exploitation,

00:01:10.500 --> 00:01:12.810 align:middle line:84%
post-exploitation
essentially refers

00:01:12.810 --> 00:01:15.210 align:middle line:84%
to the actions performed
on a target system

00:01:15.210 --> 00:01:17.190 align:middle line:84%
after initial access
has been obtained,

00:01:17.190 --> 00:01:20.580 align:middle line:84%
or after you've successfully
been able to exploit the target

00:01:20.580 --> 00:01:21.420 align:middle line:90%
system.

00:01:21.420 --> 00:01:24.360 align:middle line:84%
Now, the post-exploitation
phase of a penetration test

00:01:24.360 --> 00:01:26.130 align:middle line:84%
will consist of
various techniques,

00:01:26.130 --> 00:01:27.990 align:middle line:90%
like local enumeration.

00:01:27.990 --> 00:01:30.750 align:middle line:84%
So that's essentially
enumerating as much information

00:01:30.750 --> 00:01:32.890 align:middle line:84%
as possible from
the target system

00:01:32.890 --> 00:01:34.420 align:middle line:90%
once you have access to it.

00:01:34.420 --> 00:01:37.050 align:middle line:84%
So this is different from
performing enumeration

00:01:37.050 --> 00:01:40.140 align:middle line:84%
externally on the services
that are running on a target.

00:01:40.140 --> 00:01:42.480 align:middle line:84%
Given the fact that we now
have access to the target,

00:01:42.480 --> 00:01:44.640 align:middle line:84%
we can get more
important information

00:01:44.640 --> 00:01:47.820 align:middle line:84%
regarding the target, like
the operating system version,

00:01:47.820 --> 00:01:49.500 align:middle line:84%
the distribution
release version,

00:01:49.500 --> 00:01:52.050 align:middle line:84%
what users are currently
on the system, what

00:01:52.050 --> 00:01:55.500 align:middle line:84%
groups are currently on
the system, et cetera.

00:01:55.500 --> 00:01:58.020 align:middle line:84%
We can also perform
privilege escalation

00:01:58.020 --> 00:02:01.530 align:middle line:84%
if our current Meterpreter
session is not elevated.

00:02:01.530 --> 00:02:04.950 align:middle line:84%
We can then perform the process
of dumping hashes or dumping

00:02:04.950 --> 00:02:06.810 align:middle line:90%
credentials from memory.

00:02:06.810 --> 00:02:09.300 align:middle line:84%
We'll also take a
look at the process

00:02:09.300 --> 00:02:12.070 align:middle line:84%
of establishing persistence
on the target system,

00:02:12.070 --> 00:02:15.510 align:middle line:84%
so that if the system
is changed or shut down

00:02:15.510 --> 00:02:18.600 align:middle line:84%
in any way or shape
or form, we can always

00:02:18.600 --> 00:02:20.610 align:middle line:84%
establish persistence
without having

00:02:20.610 --> 00:02:24.270 align:middle line:84%
to go through the entire
exploitation process again.

00:02:24.270 --> 00:02:26.350 align:middle line:84%
We'll also take a look
at clearing your tracks.

00:02:26.350 --> 00:02:28.360 align:middle line:84%
So once you're
done on the system

00:02:28.360 --> 00:02:31.020 align:middle line:84%
and once you've essentially
got what you wanted,

00:02:31.020 --> 00:02:33.600 align:middle line:84%
you also need to learn how to
clear your tracks on the target

00:02:33.600 --> 00:02:34.350 align:middle line:90%
system.

00:02:34.350 --> 00:02:36.540 align:middle line:84%
And then we'll also
explore pivoting

00:02:36.540 --> 00:02:39.240 align:middle line:84%
and how that can be facilitated
through the Metasploit

00:02:39.240 --> 00:02:40.330 align:middle line:90%
framework.

00:02:40.330 --> 00:02:40.830 align:middle line:90%
All right.

00:02:40.830 --> 00:02:43.350 align:middle line:84%
Now, we've already explored
what Meterpreter is,

00:02:43.350 --> 00:02:45.690 align:middle line:84%
and we've taken a look at
how to gain a Meterpreter

00:02:45.690 --> 00:02:49.020 align:middle line:84%
session by either performing
a client-side attack

00:02:49.020 --> 00:02:52.170 align:middle line:84%
or through service-based
exploitation on both Windows

00:02:52.170 --> 00:02:53.040 align:middle line:90%
and Linux.

00:02:53.040 --> 00:02:55.290 align:middle line:84%
However, let me just
give you an introduction

00:02:55.290 --> 00:02:56.460 align:middle line:90%
to Meterpreter again.

00:02:56.460 --> 00:02:59.730 align:middle line:84%
So Meterpreter stands
for Meta-Interpreter.

00:02:59.730 --> 00:03:00.990 align:middle line:90%
It is a payload--

00:03:00.990 --> 00:03:03.090 align:middle line:84%
or an advanced
multifunctional payload

00:03:03.090 --> 00:03:07.050 align:middle line:84%
that operates via DLL injection,
and is executed in memory

00:03:07.050 --> 00:03:09.720 align:middle line:84%
on the target system, which,
again, consequently makes

00:03:09.720 --> 00:03:13.180 align:middle line:84%
it very difficult to
detect, because the payload,

00:03:13.180 --> 00:03:16.200 align:middle line:84%
if you go through the typical
service exploitation route,

00:03:16.200 --> 00:03:18.780 align:middle line:84%
the payload is never
stored on disk.

00:03:18.780 --> 00:03:21.060 align:middle line:84%
And it's always
executed in memory

00:03:21.060 --> 00:03:23.410 align:middle line:84%
once you pair it with
an exploit module.

00:03:23.410 --> 00:03:23.910 align:middle line:90%
All right.

00:03:23.910 --> 00:03:26.820 align:middle line:84%
So the way it works is that
it communicates over a stager

00:03:26.820 --> 00:03:28.470 align:middle line:84%
socket, and then
provides an attacker

00:03:28.470 --> 00:03:31.350 align:middle line:84%
with an interactive command
interpreter on the target

00:03:31.350 --> 00:03:33.210 align:middle line:84%
system, that, again,
can facilitate

00:03:33.210 --> 00:03:35.760 align:middle line:84%
the execution of system
commands, file system

00:03:35.760 --> 00:03:38.860 align:middle line:84%
navigation, key
logging, and much more.

00:03:38.860 --> 00:03:41.880 align:middle line:84%
Now, Meterpreter also allows
us to load custom scripts

00:03:41.880 --> 00:03:43.860 align:middle line:84%
and plug-ins dynamically,
and that's something

00:03:43.860 --> 00:03:45.930 align:middle line:84%
that we'll explore
as we progress

00:03:45.930 --> 00:03:48.430 align:middle line:84%
through the
post-exploitation section.

00:03:48.430 --> 00:03:50.400 align:middle line:84%
And, again, the
Metasploit framework

00:03:50.400 --> 00:03:52.860 align:middle line:84%
provides us with various
types of Meterpreter payloads

00:03:52.860 --> 00:03:55.020 align:middle line:84%
that can be used based
on the target environment

00:03:55.020 --> 00:03:57.900 align:middle line:84%
and operating system
architecture, which we already

00:03:57.900 --> 00:04:00.240 align:middle line:84%
explored during the
client-side section,

00:04:00.240 --> 00:04:02.100 align:middle line:84%
or the client-side
attack section, where

00:04:02.100 --> 00:04:04.500 align:middle line:84%
we took a look at how
to generate payloads

00:04:04.500 --> 00:04:08.460 align:middle line:84%
for both Windows and Linux, as
well as both operating system

00:04:08.460 --> 00:04:11.970 align:middle line:84%
architectures, either
64-bit or 32-bit.

00:04:11.970 --> 00:04:14.315 align:middle line:84%
Now, one important thing
that you need to remember

00:04:14.315 --> 00:04:15.690 align:middle line:84%
and that you need
to keep in mind

00:04:15.690 --> 00:04:19.019 align:middle line:84%
is that Meterpreter
works different on Linux

00:04:19.019 --> 00:04:20.820 align:middle line:84%
and it works
different on Windows

00:04:20.820 --> 00:04:24.450 align:middle line:84%
in regards to advanced
features or functionality.

00:04:24.450 --> 00:04:26.520 align:middle line:84%
And, of course, that
will become very clear

00:04:26.520 --> 00:04:29.400 align:middle line:84%
when we move to the Windows
post-exploitation section,

00:04:29.400 --> 00:04:31.440 align:middle line:84%
and then, consequently,
to the Linux

00:04:31.440 --> 00:04:32.980 align:middle line:90%
post-exploitation section.

00:04:32.980 --> 00:04:34.620 align:middle line:84%
So, again, just
keep that in mind.

00:04:34.620 --> 00:04:37.290 align:middle line:84%
As I said, we'll be utilizing
Meterpreter throughout,

00:04:37.290 --> 00:04:40.590 align:middle line:84%
and you'll learn more and
more about how to utilize it

00:04:40.590 --> 00:04:42.550 align:middle line:90%
throughout this entire section.

00:04:42.550 --> 00:04:43.050 align:middle line:90%
All right.

00:04:43.050 --> 00:04:45.120 align:middle line:84%
So let's get started
with the lab environment.

00:04:45.120 --> 00:04:46.740 align:middle line:84%
You can start up
your lab environment,

00:04:46.740 --> 00:04:49.870 align:middle line:84%
and I'll also join you
in-- or join in with you,

00:04:49.870 --> 00:04:53.260 align:middle line:84%
so we can begin taking a look
at how to utilize Meterpreter.

00:04:53.260 --> 00:04:56.090 align:middle line:90%
So I'll see you there.

00:04:56.090 --> 00:04:56.590 align:middle line:90%
All right.

00:04:56.590 --> 00:04:59.120 align:middle line:84%
So I'm back within
the lab environment.

00:04:59.120 --> 00:05:01.390 align:middle line:84%
And the first step
that we want to perform

00:05:01.390 --> 00:05:04.120 align:middle line:84%
is of course
obtaining-- or involves

00:05:04.120 --> 00:05:06.400 align:middle line:84%
obtaining the target
IP address, which can

00:05:06.400 --> 00:05:08.650 align:middle line:90%
be done by typing in ifconfig.

00:05:08.650 --> 00:05:12.100 align:middle line:84%
And we want to take a look
at the interface ethernet 1,

00:05:12.100 --> 00:05:16.030 align:middle line:84%
as the target IP is going to be
on the same subnet as our Kali

00:05:16.030 --> 00:05:17.270 align:middle line:90%
Linux instance.

00:05:17.270 --> 00:05:20.110 align:middle line:84%
So, again, in your case,
the subnet will change.

00:05:20.110 --> 00:05:22.930 align:middle line:84%
However, the target IP
or the target server

00:05:22.930 --> 00:05:25.900 align:middle line:84%
is running on the third
IP address, or the next IP

00:05:25.900 --> 00:05:27.140 align:middle line:90%
address on this subnet.

00:05:27.140 --> 00:05:30.040 align:middle line:84%
So all you need to do is
just change the 2 to a 3,

00:05:30.040 --> 00:05:31.270 align:middle line:90%
and that's the target IP.

00:05:31.270 --> 00:05:33.300 align:middle line:84%
So I'm just going
to copy this here.

00:05:33.300 --> 00:05:36.370 align:middle line:84%
We're then going to start up
the PostgreSQL database service

00:05:36.370 --> 00:05:39.040 align:middle line:84%
so that we can essentially
interact with the Metasploit

00:05:39.040 --> 00:05:40.010 align:middle line:90%
framework database.

00:05:40.010 --> 00:05:43.000 align:middle line:84%
So I'm going to say,
service postgresql start,

00:05:43.000 --> 00:05:44.050 align:middle line:90%
and hit Enter.

00:05:44.050 --> 00:05:45.730 align:middle line:84%
That will just
take a few seconds.

00:05:45.730 --> 00:05:46.400 align:middle line:90%
There we are.

00:05:46.400 --> 00:05:49.840 align:middle line:84%
And we can then launch the
Metasploit framework console.

00:05:49.840 --> 00:05:51.820 align:middle line:84%
That will take another
couple of seconds.

00:05:51.820 --> 00:05:58.230 align:middle line:90%


00:05:58.230 --> 00:05:58.730 align:middle line:90%
All right.

00:05:58.730 --> 00:05:59.750 align:middle line:90%
That is started up.

00:05:59.750 --> 00:06:03.152 align:middle line:84%
So we can now create a
workspace for all our activity.

00:06:03.152 --> 00:06:04.610 align:middle line:84%
So I'm going to
create a workspace,

00:06:04.610 --> 00:06:08.530 align:middle line:84%
and I'm just going to
call it meterpreter.

00:06:08.530 --> 00:06:12.310 align:middle line:84%
And we are now going to
set up the global variable

00:06:12.310 --> 00:06:15.400 align:middle line:84%
for the RHOSTS option, which
will essentially save us

00:06:15.400 --> 00:06:19.000 align:middle line:84%
from having to type the
target IP address whenever

00:06:19.000 --> 00:06:20.860 align:middle line:90%
we want to utilize a module.

00:06:20.860 --> 00:06:23.050 align:middle line:84%
So setting the global
variable will essentially

00:06:23.050 --> 00:06:26.050 align:middle line:84%
set the RHOSTS value,
or the IP that we

00:06:26.050 --> 00:06:29.960 align:middle line:84%
specify for the RHOSTS option,
whenever we load a module.

00:06:29.960 --> 00:06:32.500 align:middle line:84%
So I'm going to paste
in the IP address here.

00:06:32.500 --> 00:06:35.380 align:middle line:84%
And, of course, we're just
going to change that to a 3.

00:06:35.380 --> 00:06:36.610 align:middle line:90%
Hit Enter.

00:06:36.610 --> 00:06:41.080 align:middle line:84%
And now we actually need
to perform an nmap scan

00:06:41.080 --> 00:06:43.990 align:middle line:84%
on the target system in order
to identify the services that

00:06:43.990 --> 00:06:46.990 align:middle line:84%
are currently running on
it that we can exploit,

00:06:46.990 --> 00:06:49.300 align:middle line:84%
to essentially gain
access, and, consequently,

00:06:49.300 --> 00:06:51.975 align:middle line:90%
obtain a Meterpreter session.

00:06:51.975 --> 00:06:53.350 align:middle line:84%
So, again, we need
to gain access

00:06:53.350 --> 00:06:56.930 align:middle line:84%
before we can start exploring
how to utilize Meterpreter.

00:06:56.930 --> 00:07:00.340 align:middle line:84%
So I'm just going to
use the db_nmap command

00:07:00.340 --> 00:07:03.100 align:middle line:84%
to perform an nmap scan from
within the Metasploit framework

00:07:03.100 --> 00:07:04.030 align:middle line:90%
console.

00:07:04.030 --> 00:07:07.330 align:middle line:84%
And I'll say I want to perform a
quick service version detection

00:07:07.330 --> 00:07:09.370 align:middle line:90%
scan based in the IP there.

00:07:09.370 --> 00:07:11.120 align:middle line:90%
And we change that to a 3.

00:07:11.120 --> 00:07:11.620 align:middle line:90%
All right.

00:07:11.620 --> 00:07:13.270 align:middle line:90%
So the db_nmap scan--

00:07:13.270 --> 00:07:16.540 align:middle line:84%
or the db_nmap command will
essentially run the nmap scan,

00:07:16.540 --> 00:07:19.030 align:middle line:84%
and will consequently
save the scan results

00:07:19.030 --> 00:07:21.250 align:middle line:84%
into the Metasploit
framework database

00:07:21.250 --> 00:07:23.710 align:middle line:84%
within the current workspace
that we are currently

00:07:23.710 --> 00:07:26.080 align:middle line:84%
working in, which is the
meterpreter workspace.

00:07:26.080 --> 00:07:28.570 align:middle line:84%
So I'm just going to
hit Enter, and we're

00:07:28.570 --> 00:07:32.860 align:middle line:84%
going to give that a couple of
seconds to actually complete.

00:07:32.860 --> 00:07:34.690 align:middle line:90%
All right, so that completes.

00:07:34.690 --> 00:07:37.180 align:middle line:84%
And, as you can see here,
we have two services

00:07:37.180 --> 00:07:38.470 align:middle line:90%
running on the target system.

00:07:38.470 --> 00:07:40.850 align:middle line:84%
We have a web server
running on port 80.

00:07:40.850 --> 00:07:42.640 align:middle line:90%
So no SSL certificate.

00:07:42.640 --> 00:07:46.480 align:middle line:84%
And the service version
is Apache httpd 2.4.7.

00:07:46.480 --> 00:07:48.490 align:middle line:84%
We also get the
banner, which tells us

00:07:48.490 --> 00:07:52.120 align:middle line:84%
that the target server is
running Ubuntu, or Linux.

00:07:52.120 --> 00:07:55.180 align:middle line:84%
The target server is also
running a MySQL database

00:07:55.180 --> 00:07:57.190 align:middle line:90%
server on port 3306.

00:07:57.190 --> 00:08:01.630 align:middle line:84%
And, of course, that's
running MySQL version 5.5.4.7.

00:08:01.630 --> 00:08:04.480 align:middle line:84%
In this case, we are going
to be targeting or exploiting

00:08:04.480 --> 00:08:07.090 align:middle line:84%
the web application that's
currently running on the Apache

00:08:07.090 --> 00:08:08.180 align:middle line:90%
web server.

00:08:08.180 --> 00:08:11.350 align:middle line:84%
And in this case, we
actually don't have a browser

00:08:11.350 --> 00:08:14.770 align:middle line:84%
that we can utilize to access
the actual website or the web

00:08:14.770 --> 00:08:17.090 align:middle line:84%
application being hosted
on the web server.

00:08:17.090 --> 00:08:19.360 align:middle line:84%
So we can utilize
the curl utility

00:08:19.360 --> 00:08:23.675 align:middle line:84%
to essentially download the
home page of the actual website

00:08:23.675 --> 00:08:26.050 align:middle line:84%
or the web application that
we're going to be exploiting.

00:08:26.050 --> 00:08:29.290 align:middle line:84%
So I'll just copy the target
IP, and we'll say curl.

00:08:29.290 --> 00:08:32.370 align:middle line:84%
And we can then download it by
specifying the actual address

00:08:32.370 --> 00:08:32.870 align:middle line:90%
here.

00:08:32.870 --> 00:08:35.559 align:middle line:84%
So we just specify
the IP, hit Enter.

00:08:35.559 --> 00:08:37.030 align:middle line:84%
That will download
the home page.

00:08:37.030 --> 00:08:40.659 align:middle line:84%
And in this case, you can
see that the web application

00:08:40.659 --> 00:08:43.750 align:middle line:84%
in this particular
scenario is XODA,

00:08:43.750 --> 00:08:47.260 align:middle line:84%
and we can exploit XODA,
as an exploit module

00:08:47.260 --> 00:08:50.450 align:middle line:84%
for this specific version of
XODA is currently available.

00:08:50.450 --> 00:08:53.710 align:middle line:84%
So we can say search, and
specify the actual web

00:08:53.710 --> 00:08:54.400 align:middle line:90%
application.

00:08:54.400 --> 00:08:56.050 align:middle line:90%
In this case, it is xoda.

00:08:56.050 --> 00:08:57.190 align:middle line:90%
And we hit Enter.

00:08:57.190 --> 00:09:01.390 align:middle line:84%
And that is the exploit
module that we want to use.

00:09:01.390 --> 00:09:04.380 align:middle line:84%
So I'm going to say use, paste
in the actual exploit module

00:09:04.380 --> 00:09:05.340 align:middle line:90%
here.

00:09:05.340 --> 00:09:08.520 align:middle line:84%
And we can show the options for
this particular exploit module.

00:09:08.520 --> 00:09:11.790 align:middle line:84%
As you can see, the RHOSTS
option has already been set.

00:09:11.790 --> 00:09:15.040 align:middle line:84%
The RPORT option is configured
to port 80, which is fine.

00:09:15.040 --> 00:09:17.500 align:middle line:84%
And in this case, we don't
have an SSL certificate,

00:09:17.500 --> 00:09:20.160 align:middle line:84%
so we don't need to set
the SSL option to true.

00:09:20.160 --> 00:09:23.610 align:middle line:84%
The TARGETURI option is
currently set at xoda.

00:09:23.610 --> 00:09:25.860 align:middle line:84%
We need to change that
because xoda is currently

00:09:25.860 --> 00:09:27.840 align:middle line:84%
running on the root
of the web server

00:09:27.840 --> 00:09:32.500 align:middle line:84%
and not within a subdirectory or
a directory on the web server.

00:09:32.500 --> 00:09:37.380 align:middle line:84%
So we are going to
say, set TARGETURI,

00:09:37.380 --> 00:09:39.930 align:middle line:84%
and we're going to set that
to the root of the web server.

00:09:39.930 --> 00:09:42.900 align:middle line:84%
In this case, this particular
exploit module already

00:09:42.900 --> 00:09:45.030 align:middle line:84%
has a Meterpreter
payload configured,

00:09:45.030 --> 00:09:47.520 align:middle line:84%
so we actually do not need
to set the payload here.

00:09:47.520 --> 00:09:48.470 align:middle line:90%
We can just here run.

00:09:48.470 --> 00:09:52.768 align:middle line:90%


00:09:52.768 --> 00:09:53.310 align:middle line:90%
There we are.

00:09:53.310 --> 00:09:55.543 align:middle line:84%
As you can see, we get
a Meterpreter session.

00:09:55.543 --> 00:09:57.960 align:middle line:84%
So we're going to give that a
few seconds to actually open

00:09:57.960 --> 00:09:59.710 align:middle line:90%
up.

00:09:59.710 --> 00:10:00.210 align:middle line:90%
All right.

00:10:00.210 --> 00:10:03.120 align:middle line:84%
So we eventually get
a Meterpreter session,

00:10:03.120 --> 00:10:05.160 align:middle line:84%
and we can just
clear out our screen.

00:10:05.160 --> 00:10:06.000 align:middle line:90%
There we are.

00:10:06.000 --> 00:10:09.690 align:middle line:84%
So, as I mentioned previously,
a Meterpreter session

00:10:09.690 --> 00:10:12.900 align:middle line:84%
is essentially an advanced
version of the Linux terminal

00:10:12.900 --> 00:10:15.240 align:middle line:84%
if you have access
on a Linux target,

00:10:15.240 --> 00:10:18.210 align:middle line:84%
or an advanced version
of the Windows command

00:10:18.210 --> 00:10:20.980 align:middle line:84%
prompt if you have access
to a Windows target.

00:10:20.980 --> 00:10:23.190 align:middle line:84%
So the first commands
that I would typically

00:10:23.190 --> 00:10:26.340 align:middle line:84%
recommend running is
the sysinfo command,

00:10:26.340 --> 00:10:29.560 align:middle line:84%
which will give you an idea
as to what operating system.

00:10:29.560 --> 00:10:32.610 align:middle line:84%
And in this case, we
can see that the target

00:10:32.610 --> 00:10:33.600 align:middle line:90%
is running Ubuntu.

00:10:33.600 --> 00:10:36.690 align:middle line:84%
And we also get the
kernel version here.

00:10:36.690 --> 00:10:39.840 align:middle line:84%
And, again, in this case, the
computer name is victim-1,

00:10:39.840 --> 00:10:43.260 align:middle line:84%
and the Meterpreter payload,
or the actual session--

00:10:43.260 --> 00:10:47.040 align:middle line:84%
the type of session that we
have is a php/linux Meterpreter

00:10:47.040 --> 00:10:49.600 align:middle line:84%
session, which is
perfectly fine.

00:10:49.600 --> 00:10:51.330 align:middle line:84%
So that gives us
information regarding

00:10:51.330 --> 00:10:52.810 align:middle line:90%
the actual system itself.

00:10:52.810 --> 00:10:54.570 align:middle line:84%
The next step, or
the next command,

00:10:54.570 --> 00:10:58.170 align:middle line:84%
is the getuid command, which
will essentially tell us what

00:10:58.170 --> 00:10:59.950 align:middle line:90%
our permissions currently are.

00:10:59.950 --> 00:11:03.330 align:middle line:84%
So if I type in getuid,
you can see that the user

00:11:03.330 --> 00:11:05.070 align:middle line:90%
that we currently have access--

00:11:05.070 --> 00:11:08.490 align:middle line:84%
that we currently have access
to via the Meterpreter session

00:11:08.490 --> 00:11:11.280 align:middle line:84%
is the www-data
service account, right?

00:11:11.280 --> 00:11:14.460 align:middle line:84%
And that makes sense, because
we exploited a web server,

00:11:14.460 --> 00:11:17.760 align:middle line:84%
so we will consequently get
the permissions associated

00:11:17.760 --> 00:11:20.580 align:middle line:84%
with the service account
responsible for managing

00:11:20.580 --> 00:11:22.530 align:middle line:84%
the web server, which
in the case of Linux

00:11:22.530 --> 00:11:24.640 align:middle line:90%
is always going to www-data.

00:11:24.640 --> 00:11:25.140 align:middle line:90%
All right.

00:11:25.140 --> 00:11:27.030 align:middle line:84%
So we have an
unprivileged session,

00:11:27.030 --> 00:11:30.750 align:middle line:84%
or we essentially do not
have root privileges,

00:11:30.750 --> 00:11:33.720 align:middle line:84%
which means we cannot do
anything that requires root

00:11:33.720 --> 00:11:34.620 align:middle line:90%
privileges.

00:11:34.620 --> 00:11:37.650 align:middle line:84%
However, in this case we
are focused on Meterpreter.

00:11:37.650 --> 00:11:41.550 align:middle line:84%
So in order to open up the
documentation for Meterpreter,

00:11:41.550 --> 00:11:45.720 align:middle line:84%
you can type in the help
command, which will essentially

00:11:45.720 --> 00:11:47.430 align:middle line:90%
display a list of commands.

00:11:47.430 --> 00:11:49.200 align:middle line:84%
And they're sorted
based on category.

00:11:49.200 --> 00:11:52.210 align:middle line:84%
So you have your
core commands here.

00:11:52.210 --> 00:11:54.220 align:middle line:84%
You then have your
file system commands,

00:11:54.220 --> 00:11:56.350 align:middle line:84%
which essentially allow
you-- or provide you

00:11:56.350 --> 00:11:59.850 align:middle line:84%
with documentation in regards to
how to navigate around the file

00:11:59.850 --> 00:12:00.350 align:middle line:90%
system.

00:12:00.350 --> 00:12:01.810 align:middle line:84%
We'll take a look
at how to use all

00:12:01.810 --> 00:12:03.310 align:middle line:90%
of these commands in a second.

00:12:03.310 --> 00:12:05.080 align:middle line:84%
You then have your
networking commands,

00:12:05.080 --> 00:12:08.900 align:middle line:84%
and your system commands here,
as well as your audio output

00:12:08.900 --> 00:12:09.400 align:middle line:90%
commands.

00:12:09.400 --> 00:12:12.310 align:middle line:84%
Now, if you have a Meterpreter
session on a Windows target,

00:12:12.310 --> 00:12:15.220 align:middle line:84%
you're going to find that you
have a few more commands here

00:12:15.220 --> 00:12:20.110 align:middle line:84%
that allow you to perform key
logging, record the webcam,

00:12:20.110 --> 00:12:23.160 align:middle line:84%
try and elevate privileges
automatically, dump hashes,

00:12:23.160 --> 00:12:24.515 align:middle line:90%
so on and so forth.

00:12:24.515 --> 00:12:26.140 align:middle line:84%
But those are advanced
features that we

00:12:26.140 --> 00:12:29.290 align:middle line:84%
will be exploring when we reach
the Windows post-exploitation

00:12:29.290 --> 00:12:29.980 align:middle line:90%
section.

00:12:29.980 --> 00:12:32.990 align:middle line:84%
In this case, we are primarily
focused with how to, again,

00:12:32.990 --> 00:12:34.600 align:middle line:84%
manage our Meterpreter
session, how

00:12:34.600 --> 00:12:37.600 align:middle line:84%
to utilize it to navigate
around the file system,

00:12:37.600 --> 00:12:40.180 align:middle line:90%
migrate processes, et cetera.

00:12:40.180 --> 00:12:44.320 align:middle line:84%
So that is how to access
the actual documentation,

00:12:44.320 --> 00:12:46.930 align:middle line:84%
or the help menu
for Meterpreter.

00:12:46.930 --> 00:12:49.090 align:middle line:84%
Now let's talk a little
bit about sessions,

00:12:49.090 --> 00:12:53.920 align:middle line:84%
because a session is essentially
a session on a target system

00:12:53.920 --> 00:12:55.457 align:middle line:90%
that you have obtained.

00:12:55.457 --> 00:12:57.040 align:middle line:84%
And, of course, this
is in the context

00:12:57.040 --> 00:12:58.660 align:middle line:90%
of the Metasploit framework.

00:12:58.660 --> 00:13:02.080 align:middle line:84%
So we are currently working
within a Meterpreter session.

00:13:02.080 --> 00:13:04.270 align:middle line:84%
We can put this session
in the background

00:13:04.270 --> 00:13:05.750 align:middle line:90%
by typing in background.

00:13:05.750 --> 00:13:08.050 align:middle line:84%
We can also exit and
kill this session

00:13:08.050 --> 00:13:11.500 align:middle line:84%
by simply typing in exit, and
that will kill this Meterpreter

00:13:11.500 --> 00:13:12.688 align:middle line:90%
session.

00:13:12.688 --> 00:13:14.980 align:middle line:84%
In this case, let's put this
session in the background.

00:13:14.980 --> 00:13:16.870 align:middle line:84%
That can be done by
typing in background

00:13:16.870 --> 00:13:21.050 align:middle line:84%
or using the keyboard
combination Control and Z.

00:13:21.050 --> 00:13:21.550 align:middle line:90%
All right.

00:13:21.550 --> 00:13:23.110 align:middle line:90%
So we'll hit Enter.

00:13:23.110 --> 00:13:25.640 align:middle line:84%
That's going to say
Backgrounding session 1.

00:13:25.640 --> 00:13:26.140 align:middle line:90%
All right.

00:13:26.140 --> 00:13:29.170 align:middle line:84%
So we can list out our sessions
by typing in the sessions

00:13:29.170 --> 00:13:29.960 align:middle line:90%
command.

00:13:29.960 --> 00:13:32.020 align:middle line:84%
And in this case,
you can see that we

00:13:32.020 --> 00:13:35.260 align:middle line:84%
can have as many sessions that
we want on a target system,

00:13:35.260 --> 00:13:38.950 align:middle line:84%
and the sessions command allows
us to manage all our sessions,

00:13:38.950 --> 00:13:41.360 align:middle line:84%
our active sessions
on the target system.

00:13:41.360 --> 00:13:43.570 align:middle line:84%
So the way it's
sorted here is that it

00:13:43.570 --> 00:13:45.550 align:middle line:84%
will display the actual
session ID, which

00:13:45.550 --> 00:13:47.110 align:middle line:90%
is unique to every session.

00:13:47.110 --> 00:13:51.040 align:middle line:84%
So session ID 1 is unique
to this particular session

00:13:51.040 --> 00:13:53.590 align:middle line:90%
and none other.

00:13:53.590 --> 00:13:55.870 align:middle line:84%
You can then specify the
name of the session, which

00:13:55.870 --> 00:13:57.610 align:middle line:90%
I'll get to in a few seconds.

00:13:57.610 --> 00:13:59.380 align:middle line:84%
It will then tell you
the type of access

00:13:59.380 --> 00:14:01.970 align:middle line:84%
you have to the target
system, and in this case

00:14:01.970 --> 00:14:03.890 align:middle line:90%
we have an Meterpreter session.

00:14:03.890 --> 00:14:06.610 align:middle line:84%
If you had a command session, it
will tell you right over here.

00:14:06.610 --> 00:14:09.430 align:middle line:84%
It will then give you some
basic information regarding

00:14:09.430 --> 00:14:12.490 align:middle line:84%
the privileges or the current
user that you have access

00:14:12.490 --> 00:14:14.260 align:middle line:90%
to on the target system.

00:14:14.260 --> 00:14:17.140 align:middle line:84%
It will then highlight the
actual connection type,

00:14:17.140 --> 00:14:19.210 align:middle line:84%
or rather the IP
address and the port

00:14:19.210 --> 00:14:21.610 align:middle line:84%
that you're actually
using to get--

00:14:21.610 --> 00:14:23.920 align:middle line:84%
or to essentially
facilitate this session

00:14:23.920 --> 00:14:25.220 align:middle line:90%
or this connection.

00:14:25.220 --> 00:14:27.100 align:middle line:84%
So in this case, you
can see that we received

00:14:27.100 --> 00:14:31.390 align:middle line:84%
a reverse connection from the
target server on our Kali Linux

00:14:31.390 --> 00:14:36.130 align:middle line:84%
IP address on port 4444, which
we have already covered how

00:14:36.130 --> 00:14:37.910 align:middle line:90%
you can actually modify that.

00:14:37.910 --> 00:14:40.570 align:middle line:90%
So that is one session.

00:14:40.570 --> 00:14:44.080 align:middle line:84%
Now, we can open up the help
menu for the sessions command

00:14:44.080 --> 00:14:47.230 align:middle line:84%
by using the
sessions -h command.

00:14:47.230 --> 00:14:49.300 align:middle line:84%
And right over here,
you can see that we

00:14:49.300 --> 00:14:51.820 align:middle line:84%
can, first and foremost,
run a Meterpreter

00:14:51.820 --> 00:14:54.740 align:middle line:84%
command on the session
without interacting with it.

00:14:54.740 --> 00:14:57.640 align:middle line:84%
So if we wanted to run a
quick command on a session

00:14:57.640 --> 00:14:59.810 align:middle line:84%
without having to
actually interact with it,

00:14:59.810 --> 00:15:03.310 align:middle line:84%
we can say sessions,
and then specify the C,

00:15:03.310 --> 00:15:05.650 align:middle line:84%
and that is a capital
C. We can then

00:15:05.650 --> 00:15:08.230 align:middle line:84%
type in a Meterpreter
command, like sysinfo,

00:15:08.230 --> 00:15:12.130 align:middle line:84%
and then specify the session
ID using the i option, that

00:15:12.130 --> 00:15:15.580 align:middle line:84%
is, -i, and then specifying
the actual session ID.

00:15:15.580 --> 00:15:17.330 align:middle line:84%
So in this case, we
only have one session,

00:15:17.330 --> 00:15:18.700 align:middle line:90%
so I'm just going to type in 1.

00:15:18.700 --> 00:15:19.900 align:middle line:90%
We hit Enter.

00:15:19.900 --> 00:15:23.740 align:middle line:84%
As you can see, that command is
executed on Meterpreter session

00:15:23.740 --> 00:15:26.750 align:middle line:84%
1, and we get the output of
the command right over here.

00:15:26.750 --> 00:15:28.240 align:middle line:84%
However, if you
actually see, we're

00:15:28.240 --> 00:15:30.040 align:middle line:84%
not-- we currently
don't have a Meterpreter

00:15:30.040 --> 00:15:32.500 align:middle line:84%
session, because we didn't
interact with that session.

00:15:32.500 --> 00:15:34.850 align:middle line:90%
We only executed a command.

00:15:34.850 --> 00:15:38.740 align:middle line:84%
You can also terminate all
sessions using the -K option,

00:15:38.740 --> 00:15:43.100 align:middle line:84%
and that is an uppercase
K. You can also

00:15:43.100 --> 00:15:45.050 align:middle line:84%
interact with a
supplied session,

00:15:45.050 --> 00:15:48.020 align:middle line:84%
or simply open up a session
by typing in sessions,

00:15:48.020 --> 00:15:50.340 align:middle line:84%
and then providing
the actual ID.

00:15:50.340 --> 00:15:53.822 align:middle line:84%
So we can say sessions 1, and
we get the Meterpreter session

00:15:53.822 --> 00:15:54.530 align:middle line:90%
right over there.

00:15:54.530 --> 00:15:56.780 align:middle line:84%
So you can essentially
switch between your sessions

00:15:56.780 --> 00:15:57.630 align:middle line:90%
like that.

00:15:57.630 --> 00:16:00.290 align:middle line:84%
And, again, we can put this in
the background really quickly.

00:16:00.290 --> 00:16:05.480 align:middle line:84%
And let's open up the session's
help menu right over here.

00:16:05.480 --> 00:16:06.620 align:middle line:90%
OK.

00:16:06.620 --> 00:16:10.020 align:middle line:84%
We can also terminate
sessions via the session ID.

00:16:10.020 --> 00:16:13.280 align:middle line:84%
So I can say, for
example, sessions -k,

00:16:13.280 --> 00:16:15.470 align:middle line:90%
and then say kill session 1.

00:16:15.470 --> 00:16:17.750 align:middle line:90%
And that will kill session 1.

00:16:17.750 --> 00:16:19.490 align:middle line:84%
You can also list
your active sessions

00:16:19.490 --> 00:16:21.710 align:middle line:84%
by saying sessions
or sessions -l,

00:16:21.710 --> 00:16:24.068 align:middle line:84%
and that will list
your active sessions.

00:16:24.068 --> 00:16:25.610 align:middle line:84%
The other great
thing that you can do

00:16:25.610 --> 00:16:27.712 align:middle line:84%
is also provide a
name for your session.

00:16:27.712 --> 00:16:29.420 align:middle line:84%
So you can currently
see that our session

00:16:29.420 --> 00:16:30.420 align:middle line:90%
doesn't have a name.

00:16:30.420 --> 00:16:32.060 align:middle line:84%
So we can provide
it with the name

00:16:32.060 --> 00:16:35.970 align:middle line:84%
by essentially
saying sessions -n,

00:16:35.970 --> 00:16:38.470 align:middle line:84%
and then we provide the name
that we want to provide.

00:16:38.470 --> 00:16:40.680 align:middle line:84%
So in this case, we are
just going to say xoda.

00:16:40.680 --> 00:16:43.950 align:middle line:84%
And, of course, that's the web
application that we exploited.

00:16:43.950 --> 00:16:46.380 align:middle line:84%
And, of course, feel free
to rename your sessions

00:16:46.380 --> 00:16:48.130 align:middle line:84%
to whatever you're
comfortable with.

00:16:48.130 --> 00:16:50.760 align:middle line:84%
So I'm going to say
sessions -n xoda,

00:16:50.760 --> 00:16:53.580 align:middle line:84%
and I'm then going to
specify the session ID that I

00:16:53.580 --> 00:16:55.060 align:middle line:90%
want to provide this name to.

00:16:55.060 --> 00:16:56.340 align:middle line:90%
And in this case, it's 1.

00:16:56.340 --> 00:16:57.540 align:middle line:90%
So I hit Enter.

00:16:57.540 --> 00:17:00.720 align:middle line:84%
You can see it's going to tell
you, Session 1 named to xoda.

00:17:00.720 --> 00:17:02.430 align:middle line:84%
So if I list out
my sessions, you

00:17:02.430 --> 00:17:04.530 align:middle line:84%
can see that the
name is now xoda.

00:17:04.530 --> 00:17:08.190 align:middle line:84%
So I can now interact with it by
saying sessions and then saying

00:17:08.190 --> 00:17:11.220 align:middle line:84%
xoda or specifying
the actual ID.

00:17:11.220 --> 00:17:15.240 align:middle line:84%
So that's how to switch between
sessions, rename sessions, et

00:17:15.240 --> 00:17:16.319 align:middle line:90%
cetera, et cetera.

00:17:16.319 --> 00:17:17.040 align:middle line:90%
All right.

00:17:17.040 --> 00:17:18.717 align:middle line:84%
So that's pretty
much it in regards

00:17:18.717 --> 00:17:19.800 align:middle line:90%
to managing your sessions.

00:17:19.800 --> 00:17:21.175 align:middle line:84%
It's fairly simple
to understand.

00:17:21.175 --> 00:17:22.829 align:middle line:90%
You can kill sessions.

00:17:22.829 --> 00:17:25.020 align:middle line:90%
You can manage their names.

00:17:25.020 --> 00:17:26.460 align:middle line:90%
You can interact with a session.

00:17:26.460 --> 00:17:28.109 align:middle line:84%
You can specify a
command that you

00:17:28.109 --> 00:17:31.570 align:middle line:84%
want to run in a particular
session, et cetera, et cetera.

00:17:31.570 --> 00:17:35.120 align:middle line:84%
So let's head over
back to sessions 1,

00:17:35.120 --> 00:17:38.600 align:middle line:84%
and let's explore some of the
commands that I was interested

00:17:38.600 --> 00:17:40.200 align:middle line:84%
or that are very,
very important.

00:17:40.200 --> 00:17:43.340 align:middle line:84%
So given the fact that
we're running on Linux,

00:17:43.340 --> 00:17:46.250 align:middle line:90%
we can navigate or--

00:17:46.250 --> 00:17:48.390 align:middle line:84%
navigate and interact
with the file system

00:17:48.390 --> 00:17:51.980 align:middle line:84%
first and foremost by typing
in a command like ls, which

00:17:51.980 --> 00:17:55.250 align:middle line:84%
will essentially provide us
with the actual directory

00:17:55.250 --> 00:17:57.380 align:middle line:84%
listing for the
current directory

00:17:57.380 --> 00:17:58.560 align:middle line:90%
that we're working in.

00:17:58.560 --> 00:18:00.800 align:middle line:84%
If we want to learn what
directory we're currently

00:18:00.800 --> 00:18:02.900 align:middle line:84%
working in-- and, of
course, this is on Linux--

00:18:02.900 --> 00:18:04.670 align:middle line:90%
we can type in pwd.

00:18:04.670 --> 00:18:07.080 align:middle line:84%
And that will also work
on Windows, by the way.

00:18:07.080 --> 00:18:08.750 align:middle line:84%
So these commands
will essentially

00:18:08.750 --> 00:18:10.320 align:middle line:90%
work on both systems.

00:18:10.320 --> 00:18:13.050 align:middle line:84%
So it tells us we're
working within /app/files.

00:18:13.050 --> 00:18:16.010 align:middle line:84%
We can also navigate to
a particular directory

00:18:16.010 --> 00:18:19.610 align:middle line:84%
or take a step back
by saying cd dot dot.

00:18:19.610 --> 00:18:22.115 align:middle line:84%
If we list the files
within the app directory,

00:18:22.115 --> 00:18:23.990 align:middle line:84%
you can see that it will
actually provide you

00:18:23.990 --> 00:18:27.230 align:middle line:84%
with the permissions that that
particular file or directory

00:18:27.230 --> 00:18:30.230 align:middle line:84%
has, the size, the type,
when it was last modified,

00:18:30.230 --> 00:18:31.430 align:middle line:90%
and, of course, the name.

00:18:31.430 --> 00:18:33.950 align:middle line:84%
Now we are going to go
through a few challenges that

00:18:33.950 --> 00:18:37.580 align:middle line:84%
will highlight the fundamentals
of how to utilize Meterpreter.

00:18:37.580 --> 00:18:42.290 align:middle line:84%
So the first flag that we
want to actually get here

00:18:42.290 --> 00:18:45.120 align:middle line:84%
is the flag1 file
right over here.

00:18:45.120 --> 00:18:48.800 align:middle line:84%
So in order to get the flag,
and in order to display files--

00:18:48.800 --> 00:18:51.180 align:middle line:84%
or the contents of a
file within Meterpreter,

00:18:51.180 --> 00:18:52.470 align:middle line:90%
we can use the cat command.

00:18:52.470 --> 00:18:55.610 align:middle line:84%
So we can say cat
flag1, and that will

00:18:55.610 --> 00:18:56.893 align:middle line:90%
cat the content of the flag.

00:18:56.893 --> 00:18:57.560 align:middle line:90%
So there we are.

00:18:57.560 --> 00:18:59.550 align:middle line:84%
That's how to cat the
content of a file.

00:18:59.550 --> 00:19:03.260 align:middle line:84%
You can also edit a file
by saying edit flag1.

00:19:03.260 --> 00:19:06.690 align:middle line:84%
And that will open up the
actual file within vim.

00:19:06.690 --> 00:19:11.690 align:middle line:84%
And then I can exit by using the
q and e option, or just quit.

00:19:11.690 --> 00:19:14.260 align:middle line:90%
There we are.

00:19:14.260 --> 00:19:18.340 align:middle line:84%
So that is how to, again, cat
out the content of a file,

00:19:18.340 --> 00:19:20.870 align:middle line:90%
and also how to edit a file.

00:19:20.870 --> 00:19:22.990 align:middle line:84%
We can also navigate
into various directories,

00:19:22.990 --> 00:19:25.630 align:middle line:84%
like secret files, for
example, by saying cd.

00:19:25.630 --> 00:19:27.760 align:middle line:84%
And if it has spaces
within the file name,

00:19:27.760 --> 00:19:29.240 align:middle line:90%
we can put it in double quotes.

00:19:29.240 --> 00:19:34.330 align:middle line:84%
So we can say, I want to change
my directory into Secret Files.

00:19:34.330 --> 00:19:35.330 align:middle line:90%
And we hit Enter.

00:19:35.330 --> 00:19:37.060 align:middle line:84%
If we list the contents
of Secret Files,

00:19:37.060 --> 00:19:39.230 align:middle line:84%
you can see that
we have flag2 here.

00:19:39.230 --> 00:19:42.338 align:middle line:84%
So let's also cat out
the contents of flag2.

00:19:42.338 --> 00:19:42.880 align:middle line:90%
There we are.

00:19:42.880 --> 00:19:45.460 align:middle line:84%
So I'm going to say
cat flag2, and we

00:19:45.460 --> 00:19:46.930 align:middle line:90%
get the contents of flag2.

00:19:46.930 --> 00:19:47.620 align:middle line:90%
Fantastic.

00:19:47.620 --> 00:19:50.920 align:middle line:84%
I can take a step back to
the previous directory,

00:19:50.920 --> 00:19:54.440 align:middle line:84%
and we are back within the
actual app directory here.

00:19:54.440 --> 00:19:54.940 align:middle line:90%
All right.

00:19:54.940 --> 00:19:57.490 align:middle line:84%
So that is how to
navigate between--

00:19:57.490 --> 00:19:59.740 align:middle line:84%
or how to actually switch
between directories,

00:19:59.740 --> 00:20:02.920 align:middle line:84%
how to edit files, how
to cat the contents

00:20:02.920 --> 00:20:05.020 align:middle line:90%
of a file, et cetera.

00:20:05.020 --> 00:20:08.590 align:middle line:84%
Now, if we want to download
a file like flag5.zip,

00:20:08.590 --> 00:20:11.530 align:middle line:84%
we can do that by saying
download and then specifying

00:20:11.530 --> 00:20:14.470 align:middle line:90%
the file flag5.zip.

00:20:14.470 --> 00:20:17.320 align:middle line:84%
And this will download
it to our current--

00:20:17.320 --> 00:20:20.380 align:middle line:84%
to your current working
directory within the Kali Linux

00:20:20.380 --> 00:20:23.310 align:middle line:84%
system, or you can
specify a custom directory

00:20:23.310 --> 00:20:24.560 align:middle line:90%
where you want to download it.

00:20:24.560 --> 00:20:27.580 align:middle line:84%
In this case, we're just going
to say download flag5.zip.

00:20:27.580 --> 00:20:28.690 align:middle line:90%
Hit Enter.

00:20:28.690 --> 00:20:30.770 align:middle line:84%
And let's put this
in the background.

00:20:30.770 --> 00:20:33.067 align:middle line:84%
So I'm just going to say
Control-Z. That's going

00:20:33.067 --> 00:20:34.150 align:middle line:90%
to background the session.

00:20:34.150 --> 00:20:35.620 align:middle line:90%
And I'm going to hit Yes.

00:20:35.620 --> 00:20:38.803 align:middle line:84%
And if we list the actual files
within our current directory

00:20:38.803 --> 00:20:41.470 align:middle line:84%
here-- and, of course, we're not
interacting with the sessions--

00:20:41.470 --> 00:20:43.450 align:middle line:84%
you can see that
we have flag5.zip.

00:20:43.450 --> 00:20:46.990 align:middle line:84%
So we downloaded that
zip archive successfully.

00:20:46.990 --> 00:20:50.050 align:middle line:84%
We can then unzip
that flag archive.

00:20:50.050 --> 00:20:52.390 align:middle line:84%
So I'm going to say,
unzip flag5.zip.

00:20:52.390 --> 00:20:54.900 align:middle line:90%


00:20:54.900 --> 00:20:55.500 align:middle line:90%
There we are.

00:20:55.500 --> 00:20:58.720 align:middle line:90%


00:20:58.720 --> 00:20:59.920 align:middle line:90%
That is going to unzip it.

00:20:59.920 --> 00:21:02.050 align:middle line:84%
And then we can again
provide the password.

00:21:02.050 --> 00:21:04.090 align:middle line:84%
And in this case, within
the lab environment,

00:21:04.090 --> 00:21:08.200 align:middle line:90%
the password is 56784.

00:21:08.200 --> 00:21:09.790 align:middle line:90%
So I'm going to hit Enter.

00:21:09.790 --> 00:21:11.200 align:middle line:90%
We list out the contents there.

00:21:11.200 --> 00:21:16.000 align:middle line:84%
You can see that it should
have extracted the actual flag.

00:21:16.000 --> 00:21:17.458 align:middle line:90%
So let's see.

00:21:17.458 --> 00:21:18.250 align:middle line:90%
Yeah, there we are.

00:21:18.250 --> 00:21:20.180 align:middle line:84%
The file that was
extracted was list.

00:21:20.180 --> 00:21:22.580 align:middle line:84%
So we can cat out
the content of list.

00:21:22.580 --> 00:21:26.320 align:middle line:84%
And you can see that within
that particular file,

00:21:26.320 --> 00:21:31.220 align:middle line:84%
it says get the MD5 hash of
/bin/bash on the target system.

00:21:31.220 --> 00:21:34.220 align:middle line:84%
So let's head over
into sessions 1 again.

00:21:34.220 --> 00:21:38.710 align:middle line:84%
And in order to get the MD5 hash
of a particular binary, what

00:21:38.710 --> 00:21:44.000 align:middle line:84%
we can do is essentially,
again, utilize the md5 command.

00:21:44.000 --> 00:21:46.010 align:middle line:84%
So we can utilize
the checksum command.

00:21:46.010 --> 00:21:50.470 align:middle line:84%
So we can say checksum,
and then say md5,

00:21:50.470 --> 00:21:52.930 align:middle line:90%
and then say /bin/bash.

00:21:52.930 --> 00:21:55.670 align:middle line:84%
And that's essentially
the flag right over there.

00:21:55.670 --> 00:21:57.670 align:middle line:84%
Now, in terms of
Linux, we can also

00:21:57.670 --> 00:22:00.140 align:middle line:84%
get the current
environment variables.

00:22:00.140 --> 00:22:02.740 align:middle line:84%
So if we want to learn more
about how this particular Linux

00:22:02.740 --> 00:22:05.020 align:middle line:84%
system is configured
and, in specific,

00:22:05.020 --> 00:22:08.290 align:middle line:84%
how this particular user has
been configured, we can say--

00:22:08.290 --> 00:22:10.750 align:middle line:84%
we can use the get
environment variable,

00:22:10.750 --> 00:22:15.088 align:middle line:84%
and then we specify the
actual environment variable

00:22:15.088 --> 00:22:16.630 align:middle line:90%
that we want to enumerate.

00:22:16.630 --> 00:22:19.720 align:middle line:84%
So if we want to enumerate our
current path for this user,

00:22:19.720 --> 00:22:22.630 align:middle line:84%
we can say getenv PATH,
and this will provide you

00:22:22.630 --> 00:22:25.810 align:middle line:84%
with the actual variable
PATH and its value.

00:22:25.810 --> 00:22:29.260 align:middle line:84%
If we wanted to learn more
about the actual terminal that

00:22:29.260 --> 00:22:31.030 align:middle line:84%
has been assigned to
this particular user,

00:22:31.030 --> 00:22:33.530 align:middle line:84%
we can say get
environment variable TERM.

00:22:33.530 --> 00:22:37.480 align:middle line:84%
And in this case, it says None
of the specified environment

00:22:37.480 --> 00:22:40.390 align:middle line:84%
variables were found or
set, which makes sense,

00:22:40.390 --> 00:22:44.380 align:middle line:84%
because we currently have
access via the www-data service

00:22:44.380 --> 00:22:44.980 align:middle line:90%
account.

00:22:44.980 --> 00:22:49.660 align:middle line:84%
That is typically-- or that
cannot be accessed using

00:22:49.660 --> 00:22:51.310 align:middle line:90%
a terminal session.

00:22:51.310 --> 00:22:53.890 align:middle line:84%
So that's why it doesn't
have the environment

00:22:53.890 --> 00:22:56.320 align:middle line:90%
variable TERM set.

00:22:56.320 --> 00:22:59.920 align:middle line:84%
In terms of searching for files,
which is very, very important,

00:22:59.920 --> 00:23:02.290 align:middle line:84%
we can search for files
by saying search and then

00:23:02.290 --> 00:23:05.260 align:middle line:84%
specifying the actual
directory we want to search--

00:23:05.260 --> 00:23:07.210 align:middle line:84%
that we actually
want to search in.

00:23:07.210 --> 00:23:08.800 align:middle line:84%
Or you can just
perform a search,

00:23:08.800 --> 00:23:11.600 align:middle line:84%
and this will perform a search
within the entire system,

00:23:11.600 --> 00:23:14.860 align:middle line:84%
or, rather, within the
entire file system.

00:23:14.860 --> 00:23:17.770 align:middle line:84%
In this case, what
we are going to do

00:23:17.770 --> 00:23:23.780 align:middle line:84%
is we are going to
be searching for--

00:23:23.780 --> 00:23:26.400 align:middle line:84%
we're going to search within
the /usr/bin directory,

00:23:26.400 --> 00:23:28.190 align:middle line:84%
which is where
binaries are stored.

00:23:28.190 --> 00:23:30.950 align:middle line:90%
And we then want to limit--

00:23:30.950 --> 00:23:33.950 align:middle line:84%
or we actually want to find
a file with the following

00:23:33.950 --> 00:23:35.160 align:middle line:90%
parameters.

00:23:35.160 --> 00:23:40.640 align:middle line:84%
So we want to find a file
with the file name backdoor.

00:23:40.640 --> 00:23:43.730 align:middle line:84%
So I'm just going to
encapsulate that in an asterisk,

00:23:43.730 --> 00:23:45.350 align:middle line:90%
or in two asterisks there.

00:23:45.350 --> 00:23:46.550 align:middle line:90%
I'm going to hit Enter.

00:23:46.550 --> 00:23:48.890 align:middle line:84%
And as you can see,
under /usr/bin,

00:23:48.890 --> 00:23:51.920 align:middle line:84%
we get the actual
backdoor binary there.

00:23:51.920 --> 00:23:55.880 align:middle line:84%
We can also search for
specific file extensions.

00:23:55.880 --> 00:24:00.350 align:middle line:84%
So if I say search for file
extensions, and then I say--

00:24:00.350 --> 00:24:02.280 align:middle line:90%
we can use the wildcard again.

00:24:02.280 --> 00:24:05.280 align:middle line:84%
And we can say we're looking,
maybe, for jpg files.

00:24:05.280 --> 00:24:06.110 align:middle line:90%
So I can say--

00:24:06.110 --> 00:24:09.290 align:middle line:84%
if we're looking for jpg
files, we can run that.

00:24:09.290 --> 00:24:13.538 align:middle line:84%
We can also search
for, maybe, php files.

00:24:13.538 --> 00:24:14.080 align:middle line:90%
There we are.

00:24:14.080 --> 00:24:17.320 align:middle line:84%
And you can see it gets you all
the php files on the system.

00:24:17.320 --> 00:24:21.580 align:middle line:84%
So you can utilize the search
feature-- or the search command

00:24:21.580 --> 00:24:23.600 align:middle line:90%
to search for specific files.

00:24:23.600 --> 00:24:26.050 align:middle line:84%
You can also limit the
results or search for files

00:24:26.050 --> 00:24:28.100 align:middle line:90%
with specific extensions.

00:24:28.100 --> 00:24:28.600 align:middle line:90%
All right.

00:24:28.600 --> 00:24:32.560 align:middle line:84%
So that is essentially how
to navigate around the file

00:24:32.560 --> 00:24:33.250 align:middle line:90%
system.

00:24:33.250 --> 00:24:36.470 align:middle line:84%
As I said, you can also download
a file from the target system.

00:24:36.470 --> 00:24:39.100 align:middle line:84%
So if we want to download
the flag, or flag1,

00:24:39.100 --> 00:24:41.950 align:middle line:84%
we can essentially say,
download and then flag1.

00:24:41.950 --> 00:24:42.700 align:middle line:90%
Hit Enter.

00:24:42.700 --> 00:24:46.300 align:middle line:84%
That will download it onto your
system within the directory

00:24:46.300 --> 00:24:47.870 align:middle line:84%
that you're
currently working in.

00:24:47.870 --> 00:24:49.630 align:middle line:84%
So if I put this
in the background

00:24:49.630 --> 00:24:52.210 align:middle line:84%
and I list out the
current working directory,

00:24:52.210 --> 00:24:54.950 align:middle line:84%
you can see that we've
downloaded flag1 successfully.

00:24:54.950 --> 00:24:58.610 align:middle line:84%
So I'm going to say sessions
and go back into session 1.

00:24:58.610 --> 00:24:59.110 align:middle line:90%
All right.

00:24:59.110 --> 00:25:01.660 align:middle line:84%
So that is the file
system, generally speaking.

00:25:01.660 --> 00:25:04.240 align:middle line:84%
Now let's take a look at a
few other interesting commands

00:25:04.240 --> 00:25:06.370 align:middle line:84%
that we can utilize
with Meterpreter,

00:25:06.370 --> 00:25:09.560 align:middle line:84%
as they're going to be
very, very important.

00:25:09.560 --> 00:25:11.150 align:middle line:84%
The first one is
the shell command.

00:25:11.150 --> 00:25:14.148 align:middle line:84%
So if you want to pop a shell
on a target system-- so,

00:25:14.148 --> 00:25:15.940 align:middle line:84%
again, this, when I'm
referring to a shell,

00:25:15.940 --> 00:25:19.085 align:middle line:84%
I'm referring to the native
shell of the operating system.

00:25:19.085 --> 00:25:20.710 align:middle line:84%
So if you're working
on Windows and you

00:25:20.710 --> 00:25:24.430 align:middle line:84%
want to get a command prompt
session, you can say shell.

00:25:24.430 --> 00:25:25.930 align:middle line:84%
And if you're working
on Linux, this

00:25:25.930 --> 00:25:27.730 align:middle line:90%
will open up a terminal session.

00:25:27.730 --> 00:25:28.630 align:middle line:90%
So I hit shell.

00:25:28.630 --> 00:25:31.960 align:middle line:84%
As you can see, it will not
give us any output in regards

00:25:31.960 --> 00:25:32.590 align:middle line:90%
to a shell.

00:25:32.590 --> 00:25:35.290 align:middle line:84%
But if we type in ls,
that's being executed.

00:25:35.290 --> 00:25:39.310 align:middle line:84%
We can open up a bash session
by saying /bin/bash -i.

00:25:39.310 --> 00:25:40.130 align:middle line:90%
And there we are.

00:25:40.130 --> 00:25:43.330 align:middle line:84%
So we now have a native
Linux terminal session

00:25:43.330 --> 00:25:44.500 align:middle line:90%
on the target system.

00:25:44.500 --> 00:25:46.300 align:middle line:84%
This is not a
Meterpreter session.

00:25:46.300 --> 00:25:48.590 align:middle line:84%
It's a native Linux
terminal session.

00:25:48.590 --> 00:25:50.230 align:middle line:84%
And if you did the
same for Windows,

00:25:50.230 --> 00:25:52.280 align:middle line:84%
you would get a
command prompt session.

00:25:52.280 --> 00:25:55.930 align:middle line:84%
So, again, I can now perform or
run the native Linux commands,

00:25:55.930 --> 00:25:59.650 align:middle line:84%
like, for example, ps, which
will list of the process tree,

00:25:59.650 --> 00:26:01.060 align:middle line:90%
et cetera, et cetera.

00:26:01.060 --> 00:26:04.030 align:middle line:84%
So if I want to terminate
this particular shell session,

00:26:04.030 --> 00:26:06.980 align:middle line:84%
I can use Control
and C on my keyboard.

00:26:06.980 --> 00:26:08.573 align:middle line:84%
And that will tell
me-- or ask me

00:26:08.573 --> 00:26:10.240 align:middle line:84%
whether I want to
terminate the channel.

00:26:10.240 --> 00:26:11.440 align:middle line:90%
I want to hit Yes.

00:26:11.440 --> 00:26:13.750 align:middle line:84%
This will not terminate
the Meterpreter session.

00:26:13.750 --> 00:26:16.720 align:middle line:84%
It's going to terminate
the actual channel.

00:26:16.720 --> 00:26:17.530 align:middle line:90%
So there we are.

00:26:17.530 --> 00:26:20.500 align:middle line:84%
We are back to our
Meterpreter session.

00:26:20.500 --> 00:26:23.320 align:middle line:84%
The next command that I
want to explore here--

00:26:23.320 --> 00:26:26.710 align:middle line:84%
and this is going to be quite
important-- is the process

00:26:26.710 --> 00:26:28.270 align:middle line:90%
command, which is ps.

00:26:28.270 --> 00:26:30.280 align:middle line:84%
That will allow you to
list out the process

00:26:30.280 --> 00:26:32.230 align:middle line:84%
tree, or the processes
that are currently

00:26:32.230 --> 00:26:33.560 align:middle line:90%
running on the system.

00:26:33.560 --> 00:26:34.280 align:middle line:90%
So there we are.

00:26:34.280 --> 00:26:37.720 align:middle line:84%
It will sort them by
process ID, name, the user,

00:26:37.720 --> 00:26:39.040 align:middle line:90%
as well as the path.

00:26:39.040 --> 00:26:41.560 align:middle line:90%
Now, why is this relevant?

00:26:41.560 --> 00:26:45.640 align:middle line:84%
Well, if we wanted to migrate
to any of these processes,

00:26:45.640 --> 00:26:47.860 align:middle line:84%
we could do that by typing
in migrate, and then

00:26:47.860 --> 00:26:51.920 align:middle line:84%
specifying the actual process
ID or the name of the process.

00:26:51.920 --> 00:26:54.160 align:middle line:84%
So in this case,
let's say we wanted

00:26:54.160 --> 00:26:58.710 align:middle line:84%
to migrate into this
process right over here.

00:26:58.710 --> 00:26:59.210 align:middle line:90%
All right.

00:26:59.210 --> 00:27:03.470 align:middle line:84%
So we can migrate to it by
specifying the process ID, 580.

00:27:03.470 --> 00:27:06.970 align:middle line:90%
So we can say migrate 580.

00:27:06.970 --> 00:27:07.840 align:middle line:90%
We hit Enter.

00:27:07.840 --> 00:27:11.870 align:middle line:84%
And in this case, you can see
that it's not going to work.

00:27:11.870 --> 00:27:13.870 align:middle line:90%
But, again, in many cases--

00:27:13.870 --> 00:27:16.630 align:middle line:84%
in this case, it has not worked
because we-- for some reason,

00:27:16.630 --> 00:27:18.700 align:middle line:84%
we cannot migrate
into this process.

00:27:18.700 --> 00:27:20.390 align:middle line:84%
And it comes down
to, in this case,

00:27:20.390 --> 00:27:24.190 align:middle line:84%
the lack of sufficient
privileges or permissions.

00:27:24.190 --> 00:27:26.380 align:middle line:84%
And, again, on Windows,
you can also do this.

00:27:26.380 --> 00:27:28.900 align:middle line:84%
You can migrate to a process
that you currently have

00:27:28.900 --> 00:27:30.640 align:middle line:90%
the permissions to migrate to.

00:27:30.640 --> 00:27:32.890 align:middle line:84%
In the case of Linux,
if I wanted to migrate--

00:27:32.890 --> 00:27:38.180 align:middle line:84%
maybe let's try and
migrate into the process--

00:27:38.180 --> 00:27:43.125 align:middle line:90%
let's see-- maybe process 868.

00:27:43.125 --> 00:27:44.110 align:middle line:90%
I can hit Enter.

00:27:44.110 --> 00:27:47.850 align:middle line:84%
And as you can see,
it's going to tell us

00:27:47.850 --> 00:27:50.550 align:middle line:84%
that we have an error here
with the Meterpreter session.

00:27:50.550 --> 00:27:51.763 align:middle line:90%
But don't worry about that.

00:27:51.763 --> 00:27:54.180 align:middle line:84%
Again, in this case, we're
just going through the commands

00:27:54.180 --> 00:27:54.680 align:middle line:90%
here.

00:27:54.680 --> 00:27:57.990 align:middle line:84%
We can migrate to a process
via the actual process name

00:27:57.990 --> 00:28:01.170 align:middle line:84%
by saying migrate -N, and
then saying maybe apache2

00:28:01.170 --> 00:28:02.380 align:middle line:90%
or any of the process.

00:28:02.380 --> 00:28:04.950 align:middle line:84%
And in this case, you can
see that that did not work,

00:28:04.950 --> 00:28:07.710 align:middle line:84%
because, for some reason, we
cannot migrate our processes

00:28:07.710 --> 00:28:11.020 align:middle line:84%
within this particular
Meterpreter session.

00:28:11.020 --> 00:28:11.520 align:middle line:90%
All right.

00:28:11.520 --> 00:28:15.450 align:middle line:84%
So that is how to
essentially utilize--

00:28:15.450 --> 00:28:17.400 align:middle line:90%
how to utilize Meterpreter.

00:28:17.400 --> 00:28:19.800 align:middle line:84%
As I said, you can also run
other networking commands,

00:28:19.800 --> 00:28:21.090 align:middle line:90%
like ifconfig.

00:28:21.090 --> 00:28:22.810 align:middle line:84%
And in this case,
it doesn't run.

00:28:22.810 --> 00:28:25.950 align:middle line:84%
So we can execute a command
on the target system

00:28:25.950 --> 00:28:29.640 align:middle line:84%
through Meterpreter by
saying execute -f, and then

00:28:29.640 --> 00:28:34.790 align:middle line:84%
either saying ifconfig-- so
we can say ifconfig right

00:28:34.790 --> 00:28:36.540 align:middle line:84%
over here, and that
will create a process,

00:28:36.540 --> 00:28:37.980 align:middle line:90%
and it will execute it directly.

00:28:37.980 --> 00:28:40.950 align:middle line:90%
But we can utilize all of that.

00:28:40.950 --> 00:28:43.470 align:middle line:84%
If we list out the
actual help menu here,

00:28:43.470 --> 00:28:46.170 align:middle line:84%
you can see, for networking,
in regards to Linux

00:28:46.170 --> 00:28:49.450 align:middle line:84%
we don't have much that
we can actually perform.

00:28:49.450 --> 00:28:52.150 align:middle line:84%
So that will not make much
sense at this particular point

00:28:52.150 --> 00:28:52.650 align:middle line:90%
in time.

00:28:52.650 --> 00:28:55.050 align:middle line:84%
But, yeah, you can pretty
much do what you typically

00:28:55.050 --> 00:28:57.930 align:middle line:84%
do if you had a terminal
session or a command

00:28:57.930 --> 00:28:59.115 align:middle line:90%
prompt on a target system.

00:28:59.115 --> 00:29:03.360 align:middle line:84%
So I can create a directory,
like I can say mkdir,

00:29:03.360 --> 00:29:04.890 align:middle line:90%
and we can say test.

00:29:04.890 --> 00:29:07.140 align:middle line:84%
I can list out the
directory or the contents

00:29:07.140 --> 00:29:08.670 align:middle line:84%
of this particular
folder, and you

00:29:08.670 --> 00:29:11.400 align:middle line:84%
can see that we have the
test directory created there.

00:29:11.400 --> 00:29:13.230 align:middle line:84%
I can remove this
particular directory

00:29:13.230 --> 00:29:15.540 align:middle line:84%
by saying remove
directory and test.

00:29:15.540 --> 00:29:16.680 align:middle line:90%
That will remove it.

00:29:16.680 --> 00:29:18.940 align:middle line:84%
It's fairly simple
to understand.

00:29:18.940 --> 00:29:19.440 align:middle line:90%
All right.

00:29:19.440 --> 00:29:22.530 align:middle line:84%
So that is really
the fundamentals

00:29:22.530 --> 00:29:24.180 align:middle line:90%
of utilizing Meterpreter.

00:29:24.180 --> 00:29:25.950 align:middle line:84%
As I said, we'll
be exploring more

00:29:25.950 --> 00:29:29.370 align:middle line:84%
as we progress through the
post-exploitation sections

00:29:29.370 --> 00:29:31.060 align:middle line:90%
for both Windows and Linux.

00:29:31.060 --> 00:29:34.350 align:middle line:84%
So don't worry about the
operating system specifics

00:29:34.350 --> 00:29:38.220 align:middle line:84%
in regards to Meterpreter and
what we can and cannot do based

00:29:38.220 --> 00:29:41.730 align:middle line:84%
on the target operating system
that we currently have access

00:29:41.730 --> 00:29:42.250 align:middle line:90%
to.

00:29:42.250 --> 00:29:42.750 align:middle line:90%
All right.

00:29:42.750 --> 00:29:45.000 align:middle line:84%
So go through the
actual exercises

00:29:45.000 --> 00:29:47.280 align:middle line:84%
here, and try and
download the flag, cat

00:29:47.280 --> 00:29:50.866 align:middle line:84%
out the contents of the
flag, unzip the flag,

00:29:50.866 --> 00:29:53.580 align:middle line:84%
essentially test out the
functionality of Meterpreter.

00:29:53.580 --> 00:29:55.950 align:middle line:84%
And get a good feel
for it because we'll

00:29:55.950 --> 00:29:57.760 align:middle line:90%
be utilizing it quite a bit.

00:29:57.760 --> 00:30:00.180 align:middle line:84%
That being said, that
is going to conclude

00:30:00.180 --> 00:30:05.230 align:middle line:84%
the practical demonstration
aspect or side of this video.

00:30:05.230 --> 00:30:05.820 align:middle line:90%
All right.

00:30:05.820 --> 00:30:08.040 align:middle line:84%
In the next video,
we will be exploring

00:30:08.040 --> 00:30:10.980 align:middle line:84%
the process of how to
upgrade a standard command

00:30:10.980 --> 00:30:14.910 align:middle line:84%
shell into a Meterpreter
session or a Meterpreter shell,

00:30:14.910 --> 00:30:16.980 align:middle line:84%
and we'll be exploring
two techniques

00:30:16.980 --> 00:30:19.120 align:middle line:90%
that we can utilize to do this.

00:30:19.120 --> 00:30:22.520 align:middle line:84%
So I'll see you
in the next video.