WEBVTT

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


00:00:05.445 --> 00:00:07.920 align:middle line:90%
[MUSIC PLAYING]

00:00:07.920 --> 00:00:10.410 align:middle line:90%


00:00:10.410 --> 00:00:12.360 align:middle line:90%
MySQL enumeration.

00:00:12.360 --> 00:00:14.700 align:middle line:84%
In this video, we're going
to be taking a look at how

00:00:14.700 --> 00:00:17.160 align:middle line:84%
to enumerate as much
information as possible

00:00:17.160 --> 00:00:21.690 align:middle line:84%
from a MySQL database server
with or by taking advantage

00:00:21.690 --> 00:00:24.060 align:middle line:84%
of various auxiliary
modules afforded

00:00:24.060 --> 00:00:26.680 align:middle line:84%
to us by the
Metasploit framework.

00:00:26.680 --> 00:00:29.790 align:middle line:84%
So first and foremost,
what is MySQL?

00:00:29.790 --> 00:00:33.570 align:middle line:84%
Well, MySQL is essentially an
open source relational database

00:00:33.570 --> 00:00:36.510 align:middle line:84%
management system
that's based on SQL.

00:00:36.510 --> 00:00:39.060 align:middle line:84%
SQL means the Structured
Query Language,

00:00:39.060 --> 00:00:41.250 align:middle line:84%
and it's typically
used to store records

00:00:41.250 --> 00:00:46.560 align:middle line:84%
like customer data and various
other types of data associated

00:00:46.560 --> 00:00:48.640 align:middle line:84%
with the operations
of a company.

00:00:48.640 --> 00:00:53.850 align:middle line:84%
So there are various deployment
use cases for MySQL, or rather,

00:00:53.850 --> 00:00:57.600 align:middle line:84%
any other type of relational
database management system,

00:00:57.600 --> 00:01:00.420 align:middle line:84%
but MySQL is typically
or commonly deployed

00:01:00.420 --> 00:01:02.230 align:middle line:90%
to store web application data.

00:01:02.230 --> 00:01:05.700 align:middle line:84%
So if you're setting up a web
application like WordPress,

00:01:05.700 --> 00:01:08.980 align:middle line:84%
WordPress requires a
database to store data.

00:01:08.980 --> 00:01:11.190 align:middle line:84%
And as a result,
you can either use

00:01:11.190 --> 00:01:14.880 align:middle line:84%
MySQL or any other type of
relational database management

00:01:14.880 --> 00:01:16.930 align:middle line:90%
system to store your data.

00:01:16.930 --> 00:01:20.940 align:middle line:84%
So you will typically find
MySQL deployed as a database

00:01:20.940 --> 00:01:23.520 align:middle line:84%
to store the web
application data.

00:01:23.520 --> 00:01:26.400 align:middle line:84%
And again, given
that is the fact,

00:01:26.400 --> 00:01:29.340 align:middle line:84%
exploiting or
performing enumeration

00:01:29.340 --> 00:01:34.650 align:middle line:84%
on a MySQL database server can
be vital in a penetration test.

00:01:34.650 --> 00:01:38.430 align:middle line:84%
And again, it really, really
is very, very important,

00:01:38.430 --> 00:01:40.710 align:middle line:84%
and you need to take
it into consideration

00:01:40.710 --> 00:01:42.960 align:middle line:84%
whenever you're performing
information gathering.

00:01:42.960 --> 00:01:48.040 align:middle line:84%
Now, MySQL utilizes TCP
port 3306 by default.

00:01:48.040 --> 00:01:50.190 align:middle line:84%
However, like any
other service, it

00:01:50.190 --> 00:01:53.520 align:middle line:84%
can be hosted or configured
to run on any other open TCP

00:01:53.520 --> 00:01:56.790 align:middle line:84%
port, which is something that
companies or organizations have

00:01:56.790 --> 00:01:59.130 align:middle line:84%
started doing in
order to avoid attacks

00:01:59.130 --> 00:02:00.550 align:middle line:90%
on their database servers.

00:02:00.550 --> 00:02:04.950 align:middle line:84%
So they'll typically change
the MySQL port from 3306

00:02:04.950 --> 00:02:09.060 align:middle line:84%
to something else in a way,
or rather as a technique

00:02:09.060 --> 00:02:11.140 align:middle line:90%
to avoid detection.

00:02:11.140 --> 00:02:12.990 align:middle line:84%
However, this again
is not really helpful,

00:02:12.990 --> 00:02:15.630 align:middle line:84%
because we can perform
a full port scan

00:02:15.630 --> 00:02:18.060 align:middle line:84%
and discover the
port that actually

00:02:18.060 --> 00:02:19.950 align:middle line:90%
has MySQL running on it.

00:02:19.950 --> 00:02:22.530 align:middle line:84%
Now, we can utilize
various auxiliary modules

00:02:22.530 --> 00:02:25.350 align:middle line:84%
to enumerate information
like the version of MySQL

00:02:25.350 --> 00:02:27.300 align:middle line:84%
that's running, and
that information can

00:02:27.300 --> 00:02:29.490 align:middle line:90%
be pertinent to exploitation.

00:02:29.490 --> 00:02:31.530 align:middle line:84%
We can also utilize
auxiliary modules

00:02:31.530 --> 00:02:34.960 align:middle line:84%
to perform brute force attacks
on the MySQL database server.

00:02:34.960 --> 00:02:37.710 align:middle line:84%
So we can, again, perform
these brute force attacks

00:02:37.710 --> 00:02:39.780 align:middle line:84%
to identify usernames
and passwords

00:02:39.780 --> 00:02:43.590 align:middle line:84%
and legitimate credentials
that we can authenticate with,

00:02:43.590 --> 00:02:47.490 align:middle line:84%
which will consequently give us
access to the database server.

00:02:47.490 --> 00:02:49.530 align:middle line:84%
After we've gained access
to a database server

00:02:49.530 --> 00:02:52.540 align:middle line:84%
or after we have credentials
to a database server,

00:02:52.540 --> 00:02:54.630 align:middle line:84%
we can use various
other auxiliary modules

00:02:54.630 --> 00:02:58.200 align:middle line:84%
to essentially
enumerate information

00:02:58.200 --> 00:03:02.040 align:middle line:84%
from the database server, like
the tables or the databases,

00:03:02.040 --> 00:03:05.860 align:middle line:84%
as well as execute
various SQL queries,

00:03:05.860 --> 00:03:08.320 align:middle line:84%
which we will be exploring
within the lab environment.

00:03:08.320 --> 00:03:12.270 align:middle line:84%
So let's actually switch over
to the lab environment now.

00:03:12.270 --> 00:03:15.970 align:middle line:84%
All right, so I am currently
within the lab environment.

00:03:15.970 --> 00:03:17.400 align:middle line:84%
And the first
thing we want to do

00:03:17.400 --> 00:03:20.880 align:middle line:84%
is, of course, identify the
target IP address, which we

00:03:20.880 --> 00:03:22.890 align:middle line:90%
can do by typing in ifconfig.

00:03:22.890 --> 00:03:25.320 align:middle line:84%
And we're looking for
the interface ethernet 1,

00:03:25.320 --> 00:03:28.060 align:middle line:84%
and of course, we identify
our IP address here.

00:03:28.060 --> 00:03:33.450 align:middle line:84%
So that is 192.143.6.2, which
means that the target IP

00:03:33.450 --> 00:03:37.278 align:middle line:90%
address will be 193.143.6.3.

00:03:37.278 --> 00:03:38.820 align:middle line:84%
And in your case,
again, all you need

00:03:38.820 --> 00:03:41.190 align:middle line:84%
to do is just
change the 2 to a 3,

00:03:41.190 --> 00:03:42.910 align:middle line:84%
and that's the
target IP address.

00:03:42.910 --> 00:03:44.880 align:middle line:90%
So I'm just going to copy that.

00:03:44.880 --> 00:03:48.670 align:middle line:84%
We then want to start up the
PostgreSQL database server.

00:03:48.670 --> 00:03:55.950 align:middle line:84%
So postgresql_start, that
should start it up for us.

00:03:55.950 --> 00:03:57.840 align:middle line:90%
So give that a few seconds.

00:03:57.840 --> 00:04:01.020 align:middle line:84%
MSF console, to start up the
Metasploit framework console.

00:04:01.020 --> 00:04:02.055 align:middle line:90%
Give that a few seconds.

00:04:02.055 --> 00:04:08.410 align:middle line:90%


00:04:08.410 --> 00:04:11.170 align:middle line:84%
All right, the next thing we
want to do is add a workspace.

00:04:11.170 --> 00:04:13.290 align:middle line:84%
So I'm going to say
workspace add, and we'll just

00:04:13.290 --> 00:04:17.820 align:middle line:84%
call this MySQL_enum,
right, and we'll hit Enter.

00:04:17.820 --> 00:04:19.829 align:middle line:84%
And that's currently
our workspace.

00:04:19.829 --> 00:04:21.779 align:middle line:84%
The next thing we
want to do to avoid

00:04:21.779 --> 00:04:25.440 align:middle line:84%
any inconvenience of setting
or actually constantly looking

00:04:25.440 --> 00:04:28.830 align:middle line:84%
up the target IP is to
set up the global variable

00:04:28.830 --> 00:04:30.973 align:middle line:90%
for the RHOSTS variable.

00:04:30.973 --> 00:04:32.640 align:middle line:84%
So we're going to set
that up, and we're

00:04:32.640 --> 00:04:35.010 align:middle line:84%
going to again paste
in the target IP,

00:04:35.010 --> 00:04:37.950 align:middle line:84%
change the 2 into
a 3, and we'll also

00:04:37.950 --> 00:04:41.490 align:middle line:84%
do this for the RHOST variable
in addition to RHOSTS.

00:04:41.490 --> 00:04:44.670 align:middle line:84%
So again, just hit Enter, and
that again should prevent us,

00:04:44.670 --> 00:04:48.450 align:middle line:84%
or again, will actually save
us from typing in the target IP

00:04:48.450 --> 00:04:50.400 align:middle line:84%
every time we want
to use a module.

00:04:50.400 --> 00:04:51.960 align:middle line:90%
All right, so let's get started.

00:04:51.960 --> 00:04:56.860 align:middle line:84%
Now, when it comes down to MySQL
enumeration and exploitation,

00:04:56.860 --> 00:04:58.350 align:middle line:84%
the first thing
that we need to do

00:04:58.350 --> 00:05:01.840 align:middle line:84%
is identify the version
of MySQL that's running.

00:05:01.840 --> 00:05:05.250 align:middle line:84%
So we can run a search
for the auxiliary modules

00:05:05.250 --> 00:05:07.770 align:middle line:84%
pertinent to MySQL
by typing in search,

00:05:07.770 --> 00:05:11.130 align:middle line:84%
and then we can specify
or use the type filter

00:05:11.130 --> 00:05:13.840 align:middle line:84%
to limit the results
to auxiliary modules.

00:05:13.840 --> 00:05:16.690 align:middle line:84%
And then we can enter a name,
which again, in this case,

00:05:16.690 --> 00:05:19.200 align:middle line:84%
we will type in
MySQL and hit Enter.

00:05:19.200 --> 00:05:21.660 align:middle line:84%
And as you can see, we
have quite a few modules.

00:05:21.660 --> 00:05:24.810 align:middle line:84%
The one we're starting off
with is the MySQL version

00:05:24.810 --> 00:05:28.170 align:middle line:84%
module, which I'll just copy
here, and we will say use.

00:05:28.170 --> 00:05:29.698 align:middle line:90%
We're going to then hit Enter.

00:05:29.698 --> 00:05:30.240 align:middle line:90%
There we are.

00:05:30.240 --> 00:05:31.800 align:middle line:90%
So it's loaded and active.

00:05:31.800 --> 00:05:33.330 align:middle line:84%
We're now going to
show the options

00:05:33.330 --> 00:05:34.560 align:middle line:90%
for this particular module.

00:05:34.560 --> 00:05:36.940 align:middle line:84%
And as you can see, the
options are fairly simple.

00:05:36.940 --> 00:05:38.560 align:middle line:84%
We need to provide
the target IP,

00:05:38.560 --> 00:05:41.520 align:middle line:84%
which is done through the global
variable that we just set.

00:05:41.520 --> 00:05:44.610 align:middle line:84%
You then have the RPORT
option, which is the port

00:05:44.610 --> 00:05:46.690 align:middle line:84%
that MySQL is running
on the target.

00:05:46.690 --> 00:05:49.890 align:middle line:84%
And in this case, it is
running on port 3306.

00:05:49.890 --> 00:05:52.410 align:middle line:84%
We can, of course, confirm
that-- we can actually confirm

00:05:52.410 --> 00:05:54.460 align:middle line:90%
this by performing a port scan.

00:05:54.460 --> 00:05:55.950 align:middle line:84%
So again, if I just
search for port

00:05:55.950 --> 00:06:00.060 align:middle line:84%
scan, and we use the default
TCP port scan module,

00:06:00.060 --> 00:06:03.400 align:middle line:84%
as we did during the
port scanning video.

00:06:03.400 --> 00:06:05.740 align:middle line:84%
We can then, again,
show the options here.

00:06:05.740 --> 00:06:08.010 align:middle line:84%
And then just hit Run,
because the target IP

00:06:08.010 --> 00:06:09.300 align:middle line:90%
has been specified.

00:06:09.300 --> 00:06:13.740 align:middle line:84%
And once we hit Run, you
should see that the open port

00:06:13.740 --> 00:06:16.230 align:middle line:90%
is port 3306, as you can see.

00:06:16.230 --> 00:06:19.230 align:middle line:84%
So that is the port that is
actually hosting the MySQL

00:06:19.230 --> 00:06:20.110 align:middle line:90%
database server.

00:06:20.110 --> 00:06:21.900 align:middle line:84%
So now that we know
or have confirmed

00:06:21.900 --> 00:06:23.730 align:middle line:84%
that that is the
case, we can now

00:06:23.730 --> 00:06:27.630 align:middle line:84%
use the MySQL module,
the MySQL version.

00:06:27.630 --> 00:06:29.310 align:middle line:90%
So, we're going to Enter again.

00:06:29.310 --> 00:06:32.165 align:middle line:84%
And again, we just
show the options here.

00:06:32.165 --> 00:06:33.540 align:middle line:84%
So we have everything
configured,

00:06:33.540 --> 00:06:36.600 align:middle line:84%
and we can now hit Run to
enumerate the version of MySQL

00:06:36.600 --> 00:06:37.803 align:middle line:90%
running on the target.

00:06:37.803 --> 00:06:40.470 align:middle line:84%
And in this case, you can see it
says that the target is running

00:06:40.470 --> 00:06:44.880 align:middle line:84%
MySQL all version
5.5.61, and we can also

00:06:44.880 --> 00:06:48.580 align:middle line:84%
get the version of Ubuntu
running, which in this case,

00:06:48.580 --> 00:06:52.840 align:middle line:84%
it actually tells us that the
target is running Ubuntu 14.04.

00:06:52.840 --> 00:06:55.260 align:middle line:84%
So we've been able to
get the version of MySQL

00:06:55.260 --> 00:06:58.030 align:middle line:84%
and the distribution
that's currently running,

00:06:58.030 --> 00:07:01.590 align:middle line:84%
which in this case
is Ubuntu 14.04.

00:07:01.590 --> 00:07:03.300 align:middle line:84%
This information
can be very useful

00:07:03.300 --> 00:07:06.090 align:middle line:84%
during the exploitation and
post-exploitation phases.

00:07:06.090 --> 00:07:08.880 align:middle line:84%
So again, it is
all very pertinent.

00:07:08.880 --> 00:07:13.050 align:middle line:84%
Now, when it comes down to
further enumeration of MySQL,

00:07:13.050 --> 00:07:16.180 align:middle line:84%
we actually need some access
to the database server.

00:07:16.180 --> 00:07:17.970 align:middle line:84%
And in order to
obtain that access,

00:07:17.970 --> 00:07:21.600 align:middle line:84%
we can either find an exploit
for this version of MySQL--

00:07:21.600 --> 00:07:23.970 align:middle line:84%
however, there isn't
any active exploit

00:07:23.970 --> 00:07:26.680 align:middle line:84%
that can allow us to,
again, target this version.

00:07:26.680 --> 00:07:29.730 align:middle line:84%
So what we'll need to do
is perform a brute force

00:07:29.730 --> 00:07:32.010 align:middle line:84%
in order to see or
identify whether we

00:07:32.010 --> 00:07:35.010 align:middle line:84%
can find any legitimate
credentials that can provide us

00:07:35.010 --> 00:07:39.660 align:middle line:84%
with some form of access to
the MySQL database server.

00:07:39.660 --> 00:07:42.060 align:middle line:84%
The module we can
use to do that is one

00:07:42.060 --> 00:07:46.993 align:middle line:84%
called MySQL login, so I'm
just going to search for it.

00:07:46.993 --> 00:07:48.160 align:middle line:90%
And that's the module there.

00:07:48.160 --> 00:07:50.320 align:middle line:90%
So it's the MySQL login utility.

00:07:50.320 --> 00:07:55.090 align:middle line:84%
And similar to the FTP SMB
and the web server enumeration

00:07:55.090 --> 00:07:57.820 align:middle line:84%
videos, this can
allow or this can be

00:07:57.820 --> 00:07:59.540 align:middle line:90%
used to perform a brute force.

00:07:59.540 --> 00:08:01.720 align:middle line:84%
So again, we'll just
show the options here.

00:08:01.720 --> 00:08:03.910 align:middle line:84%
And the options
that we need to set

00:08:03.910 --> 00:08:05.500 align:middle line:84%
are number 1, the
brute force speed,

00:08:05.500 --> 00:08:07.240 align:middle line:84%
which is currently
set to the highest.

00:08:07.240 --> 00:08:09.910 align:middle line:84%
We also need to configure
the target IP, which is done,

00:08:09.910 --> 00:08:11.710 align:middle line:90%
and the target port.

00:08:11.710 --> 00:08:15.460 align:middle line:84%
We then can specify the
username and the user file,

00:08:15.460 --> 00:08:18.490 align:middle line:84%
et cetera, all the information
pertinent to a brute force

00:08:18.490 --> 00:08:19.120 align:middle line:90%
attack.

00:08:19.120 --> 00:08:23.260 align:middle line:84%
Now, when we talk about
MySQL and the credentials

00:08:23.260 --> 00:08:25.480 align:middle line:84%
that we are pretty
much going to be after,

00:08:25.480 --> 00:08:27.760 align:middle line:84%
that is going to be the
root credentials, right?

00:08:27.760 --> 00:08:30.880 align:middle line:84%
Because the root user on
any system essentially

00:08:30.880 --> 00:08:32.169 align:middle line:90%
has all privileges.

00:08:32.169 --> 00:08:35.020 align:middle line:84%
And so instead of performing
a brute force for usernames,

00:08:35.020 --> 00:08:37.000 align:middle line:84%
we can automatically
set the username

00:08:37.000 --> 00:08:38.919 align:middle line:84%
to root and then try
and see whether we

00:08:38.919 --> 00:08:41.240 align:middle line:84%
can find any passwords
for the root user.

00:08:41.240 --> 00:08:47.130 align:middle line:84%
So I'm going to set the
username value to root,

00:08:47.130 --> 00:08:51.030 align:middle line:84%
and we are then going to set
the password list to-- or rather

00:08:51.030 --> 00:08:55.990 align:middle line:84%
the password file to
the following word list.

00:08:55.990 --> 00:08:57.870 align:middle line:90%
So we will utilize--

00:08:57.870 --> 00:09:01.030 align:middle line:90%
so let's set up pass file here.

00:09:01.030 --> 00:09:03.930 align:middle line:84%
And we are going to use the
Metasploit framework word

00:09:03.930 --> 00:09:07.140 align:middle line:84%
list so user share
Metasploit framework.

00:09:07.140 --> 00:09:09.630 align:middle line:84%
And under data
and word lists, we

00:09:09.630 --> 00:09:13.440 align:middle line:84%
are looking for
unixpasswords.txt,

00:09:13.440 --> 00:09:14.520 align:middle line:90%
and we hit Enter.

00:09:14.520 --> 00:09:17.760 align:middle line:84%
We can also disable
verbosity or set it to false,

00:09:17.760 --> 00:09:21.210 align:middle line:84%
to only again print out
the successful attempts.

00:09:21.210 --> 00:09:25.510 align:middle line:84%
And we can also specify
the stop on success value,

00:09:25.510 --> 00:09:29.430 align:middle line:84%
which will stop whenever we
obtain legitimate credentials.

00:09:29.430 --> 00:09:32.830 align:middle line:84%
So we will set the
verbose option to false.

00:09:32.830 --> 00:09:34.840 align:middle line:84%
And of course, this
is a Boolean value.

00:09:34.840 --> 00:09:38.340 align:middle line:84%
And once we are ready to go,
all we need to type in is run,

00:09:38.340 --> 00:09:40.170 align:middle line:84%
and that is going to
begin the brute force.

00:09:40.170 --> 00:09:43.050 align:middle line:84%
So let's see whether we can
identify any credentials

00:09:43.050 --> 00:09:46.550 align:middle line:90%
for the MySQL database server.

00:09:46.550 --> 00:09:49.230 align:middle line:84%
As you can see, that is
completed relatively quickly.

00:09:49.230 --> 00:09:51.980 align:middle line:84%
And we were able to find
credentials, or rather

00:09:51.980 --> 00:09:54.410 align:middle line:84%
a password for the root
user, which is excellent.

00:09:54.410 --> 00:09:57.770 align:middle line:84%
That means we can now access
the MySQL database server

00:09:57.770 --> 00:09:59.850 align:middle line:84%
and pretty much do
whatever we want with it.

00:09:59.850 --> 00:10:03.150 align:middle line:84%
So we've been rather lucky,
if I can call it that.

00:10:03.150 --> 00:10:05.480 align:middle line:84%
So now that we have
obtained the credentials,

00:10:05.480 --> 00:10:08.270 align:middle line:84%
you can see that the
password for the root user

00:10:08.270 --> 00:10:11.420 align:middle line:84%
is twinkle, which is
not a very good security

00:10:11.420 --> 00:10:14.960 align:middle line:84%
practice on the side of
the systems administrator

00:10:14.960 --> 00:10:16.740 align:middle line:90%
on the target system.

00:10:16.740 --> 00:10:20.240 align:middle line:84%
The next step will be pretty
much to perform some MySQL

00:10:20.240 --> 00:10:21.050 align:middle line:90%
enumeration.

00:10:21.050 --> 00:10:25.310 align:middle line:84%
And this can be done through
the use of a module called MySQL

00:10:25.310 --> 00:10:26.600 align:middle line:90%
enum.

00:10:26.600 --> 00:10:28.440 align:middle line:84%
So again, I'll just
search for it here.

00:10:28.440 --> 00:10:33.943 align:middle line:84%
So I'm going to say
search mysql_enum,

00:10:33.943 --> 00:10:35.110 align:middle line:90%
and this is the module here.

00:10:35.110 --> 00:10:39.010 align:middle line:84%
As you can see, it falls
under the Admin subdirectory

00:10:39.010 --> 00:10:42.040 align:middle line:84%
under auxiliary modules,
which means in order to use it

00:10:42.040 --> 00:10:46.000 align:middle line:84%
or in order to utilize it,
we require credentials, which

00:10:46.000 --> 00:10:47.390 align:middle line:90%
in this case, we already have.

00:10:47.390 --> 00:10:48.910 align:middle line:84%
So I'm going to
copy that, and we're

00:10:48.910 --> 00:10:50.480 align:middle line:90%
going to paste that in there.

00:10:50.480 --> 00:10:52.550 align:middle line:84%
And if you want to learn
more about this module,

00:10:52.550 --> 00:10:53.650 align:middle line:90%
you can type in info.

00:10:53.650 --> 00:10:55.510 align:middle line:84%
And as you can see,
it says this module

00:10:55.510 --> 00:10:59.260 align:middle line:84%
allows for simple enumeration
of a MySQL database server,

00:10:59.260 --> 00:11:02.210 align:middle line:84%
provided proper credentials
to connect remotely.

00:11:02.210 --> 00:11:04.090 align:middle line:84%
So let's set up the
username and password.

00:11:04.090 --> 00:11:06.580 align:middle line:84%
As you can see, the target
IP has been set, as well as

00:11:06.580 --> 00:11:07.730 align:middle line:90%
the target port.

00:11:07.730 --> 00:11:10.660 align:middle line:84%
So I'm going to set the
password value to twinkle, which

00:11:10.660 --> 00:11:12.130 align:middle line:90%
is what we were able to find.

00:11:12.130 --> 00:11:19.930 align:middle line:84%
So twinkle, and set
the username to root.

00:11:19.930 --> 00:11:23.980 align:middle line:84%
And all we need to do
now is just hit Run.

00:11:23.980 --> 00:11:26.230 align:middle line:84%
And as you can see, it's
enumerated quite a bit

00:11:26.230 --> 00:11:27.340 align:middle line:90%
of information, right?

00:11:27.340 --> 00:11:28.960 align:middle line:84%
Now, let's go through
the information

00:11:28.960 --> 00:11:30.820 align:middle line:90%
that it's enumerated.

00:11:30.820 --> 00:11:34.180 align:middle line:84%
All right, so as we can see, it
enumerates the MySQL version,

00:11:34.180 --> 00:11:35.290 align:middle line:90%
which we already know.

00:11:35.290 --> 00:11:37.900 align:middle line:84%
It also tells us that
this version of MySQL

00:11:37.900 --> 00:11:41.560 align:middle line:84%
was compiled for Debian
Linux GNU, or rather, Linux.

00:11:41.560 --> 00:11:43.960 align:middle line:84%
The architecture of
the target system

00:11:43.960 --> 00:11:46.850 align:middle line:90%
could be 32-bit or 64-bit.

00:11:46.850 --> 00:11:48.700 align:middle line:84%
We also get the
server hostname, so we

00:11:48.700 --> 00:11:52.210 align:middle line:84%
know that this particular
system is called Victim 1.

00:11:52.210 --> 00:11:55.570 align:middle line:84%
As for the other options that
are pertinent or important

00:11:55.570 --> 00:11:59.210 align:middle line:84%
to us, that is going to fall
under the accounts section.

00:11:59.210 --> 00:12:01.780 align:middle line:84%
So it will essentially
enumerate a list of accounts

00:12:01.780 --> 00:12:03.760 align:middle line:84%
with their password
hashes, and this

00:12:03.760 --> 00:12:07.760 align:middle line:84%
is referring to accounts for
the MySQL database server.

00:12:07.760 --> 00:12:10.120 align:middle line:84%
So we already have
the root credentials,

00:12:10.120 --> 00:12:14.800 align:middle line:84%
so we already have the root,
the user root and its password,

00:12:14.800 --> 00:12:16.520 align:middle line:84%
but it will print
out the hashes.

00:12:16.520 --> 00:12:19.300 align:middle line:84%
Now, whenever you
have hashes, hashes

00:12:19.300 --> 00:12:22.120 align:middle line:84%
need to be cracked in order to
obtain a clear text password,

00:12:22.120 --> 00:12:24.950 align:middle line:84%
but we're really not going to be
focusing on that in this video.

00:12:24.950 --> 00:12:28.965 align:middle line:84%
We also are able to find out
the other MySQL database users.

00:12:28.965 --> 00:12:31.090 align:middle line:84%
And in this case, you can
see we have a user called

00:12:31.090 --> 00:12:33.610 align:middle line:90%
sysadmin backup gofer.

00:12:33.610 --> 00:12:37.280 align:middle line:84%
We also get the guest host
account and a few others here.

00:12:37.280 --> 00:12:41.200 align:middle line:84%
So we are able to enumerate
the other MySQL database users.

00:12:41.200 --> 00:12:43.540 align:middle line:84%
We also get the
other information

00:12:43.540 --> 00:12:45.340 align:middle line:84%
pertinent to
privileges, so we can

00:12:45.340 --> 00:12:48.560 align:middle line:84%
see that the following
users have grant privilege.

00:12:48.560 --> 00:12:50.690 align:middle line:84%
And if we take a
look at the users,

00:12:50.690 --> 00:12:52.330 align:middle line:84%
we can see they're
the only user who

00:12:52.330 --> 00:12:54.490 align:middle line:84%
has these privileges
is the root user.

00:12:54.490 --> 00:12:57.470 align:middle line:84%
And in our case, we already
have access to the root user,

00:12:57.470 --> 00:12:59.480 align:middle line:84%
so we don't need
to do much here.

00:12:59.480 --> 00:13:01.240 align:middle line:84%
So this module is
essentially used

00:13:01.240 --> 00:13:03.340 align:middle line:84%
to enumerate
additional information.

00:13:03.340 --> 00:13:05.210 align:middle line:84%
And of course, in
order to do that,

00:13:05.210 --> 00:13:07.310 align:middle line:84%
it requires access
through credentials.

00:13:07.310 --> 00:13:10.300 align:middle line:84%
Now, if we had obtained
access via another user,

00:13:10.300 --> 00:13:13.360 align:middle line:84%
then of course, the
information displayed here,

00:13:13.360 --> 00:13:16.780 align:middle line:84%
like the root user hash,
would be very, very important,

00:13:16.780 --> 00:13:19.510 align:middle line:84%
because we could then take
it and crack it and then

00:13:19.510 --> 00:13:23.120 align:middle line:84%
be able to get root access
on the MySQL database server.

00:13:23.120 --> 00:13:26.860 align:middle line:84%
So now that we have enumerated
or performed some basic MySQL

00:13:26.860 --> 00:13:30.370 align:middle line:84%
enumeration, we can now
move on to the next module.

00:13:30.370 --> 00:13:33.640 align:middle line:84%
The next module is arguably one
of the most important modules

00:13:33.640 --> 00:13:35.770 align:middle line:84%
when it comes down
to MySQL enumeration

00:13:35.770 --> 00:13:40.690 align:middle line:84%
with the Metasploit framework,
and that is the MySQL SQL

00:13:40.690 --> 00:13:41.240 align:middle line:90%
module.

00:13:41.240 --> 00:13:42.860 align:middle line:84%
So if we search
for that right now,

00:13:42.860 --> 00:13:45.550 align:middle line:90%
I'm just going to say MySQL SQL.

00:13:45.550 --> 00:13:46.510 align:middle line:90%
We hit Enter.

00:13:46.510 --> 00:13:50.620 align:middle line:84%
As you can see, this also falls
under the Admin subdirectory

00:13:50.620 --> 00:13:53.530 align:middle line:84%
under auxiliary modules, which
means we require credentials

00:13:53.530 --> 00:13:54.580 align:middle line:90%
in order to run it.

00:13:54.580 --> 00:13:57.370 align:middle line:84%
What this module allows
us to do is actually

00:13:57.370 --> 00:14:01.540 align:middle line:84%
execute SQL queries, which
means we can now interact

00:14:01.540 --> 00:14:03.710 align:middle line:90%
with the MySQL database server.

00:14:03.710 --> 00:14:07.930 align:middle line:84%
So if I copy this and I say
use and paste this in here,

00:14:07.930 --> 00:14:11.760 align:middle line:84%
we show the options, you can
see that the target IP has been

00:14:11.760 --> 00:14:13.350 align:middle line:90%
set, the target port is set.

00:14:13.350 --> 00:14:15.700 align:middle line:84%
We need to set the
password and the username,

00:14:15.700 --> 00:14:19.530 align:middle line:84%
so let's do that really quickly,
so set the password to twinkle

00:14:19.530 --> 00:14:26.590 align:middle line:84%
and we're going to set
the username to root.

00:14:26.590 --> 00:14:28.260 align:middle line:84%
The next option we
need to configure

00:14:28.260 --> 00:14:30.120 align:middle line:90%
is the SQL query, right?

00:14:30.120 --> 00:14:33.330 align:middle line:84%
So when we're talking
about a MySQL database,

00:14:33.330 --> 00:14:37.200 align:middle line:84%
in order to essentially
extract information from it,

00:14:37.200 --> 00:14:39.250 align:middle line:84%
or rather, in order
to interact with it,

00:14:39.250 --> 00:14:41.460 align:middle line:84%
we interact with
a MySQL database

00:14:41.460 --> 00:14:44.760 align:middle line:84%
through the SQL, or
Structured Query Language.

00:14:44.760 --> 00:14:48.780 align:middle line:84%
And for example, if we wanted
to get the version of MySQL,

00:14:48.780 --> 00:14:50.880 align:middle line:84%
we would type in
select version, which

00:14:50.880 --> 00:14:52.450 align:middle line:90%
is already added for us here.

00:14:52.450 --> 00:14:54.510 align:middle line:84%
So let's just use
this sample command,

00:14:54.510 --> 00:14:57.180 align:middle line:84%
and I'll also take you
through various other queries

00:14:57.180 --> 00:14:58.210 align:middle line:90%
that you can run.

00:14:58.210 --> 00:15:02.370 align:middle line:84%
So if I hit Run, you can see
that it sends the query here,

00:15:02.370 --> 00:15:07.560 align:middle line:84%
and it tells us that it's
MySQL version 5.5.61,

00:15:07.560 --> 00:15:09.990 align:middle line:84%
and it also gives us the
operating system version.

00:15:09.990 --> 00:15:13.020 align:middle line:84%
But we already know this
information, and given the fact

00:15:13.020 --> 00:15:15.690 align:middle line:84%
that we have root
access, what we can do

00:15:15.690 --> 00:15:18.780 align:middle line:90%
is run another SQL query.

00:15:18.780 --> 00:15:22.780 align:middle line:84%
And that is going to be we
can set the SQL option here.

00:15:22.780 --> 00:15:26.612 align:middle line:84%
And what we can do is run a
query called show databases.

00:15:26.612 --> 00:15:28.320 align:middle line:84%
And what this will do
is it will actually

00:15:28.320 --> 00:15:31.290 align:middle line:84%
display a list of all
databases that are currently

00:15:31.290 --> 00:15:33.310 align:middle line:90%
on the MySQL database server.

00:15:33.310 --> 00:15:35.580 align:middle line:84%
So this will tell us what
databases are currently

00:15:35.580 --> 00:15:38.490 align:middle line:84%
on there, and it'll give us
an idea of what applications

00:15:38.490 --> 00:15:41.110 align:middle line:84%
are using the MySQL
database server.

00:15:41.110 --> 00:15:43.380 align:middle line:84%
So I'll set SQL
to show databases.

00:15:43.380 --> 00:15:45.480 align:middle line:84%
And of course, the
Structured Query Language

00:15:45.480 --> 00:15:48.160 align:middle line:84%
requires a semicolon
after every command,

00:15:48.160 --> 00:15:49.530 align:middle line:90%
so I'm going to hit Enter.

00:15:49.530 --> 00:15:52.650 align:middle line:84%
And then if I hit
Run, you can see

00:15:52.650 --> 00:15:54.060 align:middle line:84%
it's going to send
the statement,

00:15:54.060 --> 00:15:57.220 align:middle line:84%
and then it displays a list
of databases available.

00:15:57.220 --> 00:16:00.090 align:middle line:84%
So you can see we have the
default MySQL database.

00:16:00.090 --> 00:16:02.040 align:middle line:84%
We have a database
called upload.

00:16:02.040 --> 00:16:05.040 align:middle line:84%
We have a database called
vendors, videos, warehouse,

00:16:05.040 --> 00:16:05.760 align:middle line:90%
et cetera.

00:16:05.760 --> 00:16:09.660 align:middle line:84%
So for example, if we wanted
to use one of these databases,

00:16:09.660 --> 00:16:15.030 align:middle line:84%
we could change the SQL setting
to instead of show databases,

00:16:15.030 --> 00:16:18.760 align:middle line:84%
we could say use maybe
the videos database.

00:16:18.760 --> 00:16:22.410 align:middle line:84%
So if we say use videos and
then semicolon and then hit Run,

00:16:22.410 --> 00:16:24.297 align:middle line:84%
this will again
send that statement

00:16:24.297 --> 00:16:25.380 align:middle line:90%
and it's going to execute.

00:16:25.380 --> 00:16:26.755 align:middle line:84%
But it doesn't
give us an output,

00:16:26.755 --> 00:16:28.890 align:middle line:84%
because again, this
particular command

00:16:28.890 --> 00:16:30.780 align:middle line:90%
is used to select a database.

00:16:30.780 --> 00:16:32.790 align:middle line:84%
After we have
selected a database,

00:16:32.790 --> 00:16:35.490 align:middle line:84%
we can then again show the
tables, et cetera, et cetera.

00:16:35.490 --> 00:16:37.530 align:middle line:84%
So this is a very
important module

00:16:37.530 --> 00:16:39.150 align:middle line:84%
when it comes down
to enumerating

00:16:39.150 --> 00:16:41.550 align:middle line:84%
as much information
as possible regarding

00:16:41.550 --> 00:16:45.790 align:middle line:84%
the databases that are currently
on a MySQL database server.

00:16:45.790 --> 00:16:49.530 align:middle line:84%
Now, if we wanted to learn more
information about the schema,

00:16:49.530 --> 00:16:51.450 align:middle line:84%
the MySQL database
schema, we can

00:16:51.450 --> 00:16:55.800 align:middle line:84%
use another module
called MySQL schema dump.

00:16:55.800 --> 00:16:57.300 align:middle line:84%
So I'm just going
to clear that out,

00:16:57.300 --> 00:16:58.885 align:middle line:84%
and we're going
to run the search.

00:16:58.885 --> 00:17:00.510 align:middle line:84%
And what this will
do is it'll actually

00:17:00.510 --> 00:17:03.930 align:middle line:84%
display all the
databases and the tables

00:17:03.930 --> 00:17:06.569 align:middle line:84%
that fall under the
databases, which again, we

00:17:06.569 --> 00:17:07.780 align:middle line:90%
can do with this module.

00:17:07.780 --> 00:17:09.270 align:middle line:84%
But again, this
particular module

00:17:09.270 --> 00:17:10.960 align:middle line:90%
does it for us automatically.

00:17:10.960 --> 00:17:15.150 align:middle line:84%
So we can say search MySQL,
and let's just say schema,

00:17:15.150 --> 00:17:17.560 align:middle line:90%
and this is the module here.

00:17:17.560 --> 00:17:20.400 align:middle line:84%
And as you can see, it is
a MySQL schema dump module.

00:17:20.400 --> 00:17:23.220 align:middle line:84%
So I'm going to say use,
paste that in there,

00:17:23.220 --> 00:17:26.127 align:middle line:90%
show the options.

00:17:26.127 --> 00:17:27.210 align:middle line:90%
Let me just do that again.

00:17:27.210 --> 00:17:27.780 align:middle line:90%
There we are.

00:17:27.780 --> 00:17:29.870 align:middle line:84%
And you can see
the first option we

00:17:29.870 --> 00:17:32.840 align:middle line:84%
can set is the display results
option, which essentially

00:17:32.840 --> 00:17:34.400 align:middle line:84%
displays the results
to the screen.

00:17:34.400 --> 00:17:35.780 align:middle line:90%
We obviously want that.

00:17:35.780 --> 00:17:38.960 align:middle line:84%
We then need to specify
the username and password.

00:17:38.960 --> 00:17:41.073 align:middle line:84%
We've already specified
the target IP and port,

00:17:41.073 --> 00:17:42.240 align:middle line:90%
so we don't need to do that.

00:17:42.240 --> 00:17:44.270 align:middle line:84%
So I'm going to set
the password value here

00:17:44.270 --> 00:17:47.900 align:middle line:84%
to the credentials we were able
to get through the brute force.

00:17:47.900 --> 00:17:49.940 align:middle line:84%
So the password is
twinkle, and then we're

00:17:49.940 --> 00:17:54.260 align:middle line:84%
going to set the
username to root.

00:17:54.260 --> 00:17:56.900 align:middle line:84%
And once that is done,
we can just hit Run.

00:17:56.900 --> 00:17:59.270 align:middle line:84%
And as you can
see, it essentially

00:17:59.270 --> 00:18:01.310 align:middle line:84%
brings out or
displays the schema.

00:18:01.310 --> 00:18:04.820 align:middle line:84%
And in this case, you can see
that for all the databases,

00:18:04.820 --> 00:18:06.870 align:middle line:84%
they don't have any
tables under them.

00:18:06.870 --> 00:18:09.110 align:middle line:84%
So again, as I said,
this lab environment

00:18:09.110 --> 00:18:11.250 align:middle line:84%
is set up for the
purpose of demonstration.

00:18:11.250 --> 00:18:14.970 align:middle line:84%
So we really don't have any
data within this database.

00:18:14.970 --> 00:18:16.520 align:middle line:84%
However, if we did,
it would actually

00:18:16.520 --> 00:18:19.730 align:middle line:84%
display the tables that
fall under the databases.

00:18:19.730 --> 00:18:22.970 align:middle line:84%
And then of course, we would
have an idea of what to target

00:18:22.970 --> 00:18:24.860 align:middle line:84%
and we could use
the previous module

00:18:24.860 --> 00:18:29.720 align:middle line:84%
that allowed us to essentially
execute various SQL queries.

00:18:29.720 --> 00:18:32.840 align:middle line:84%
So, so far, we've been able to
get quite a lot of information.

00:18:32.840 --> 00:18:35.900 align:middle line:84%
We've actually been able to get
access to the database server.

00:18:35.900 --> 00:18:38.090 align:middle line:84%
We've been able to
enumerate the schema,

00:18:38.090 --> 00:18:40.220 align:middle line:84%
get an idea of the
databases that are currently

00:18:40.220 --> 00:18:42.420 align:middle line:90%
on the MySQL database server.

00:18:42.420 --> 00:18:46.700 align:middle line:84%
Now, we can also log in
using the MySQL utility

00:18:46.700 --> 00:18:48.830 align:middle line:84%
through the command line,
and that's not a part

00:18:48.830 --> 00:18:50.180 align:middle line:90%
of the Metasploit framework.

00:18:50.180 --> 00:18:53.360 align:middle line:84%
And that will essentially give
you a full control or access

00:18:53.360 --> 00:18:56.060 align:middle line:84%
to the MySQL database
server, because we already

00:18:56.060 --> 00:18:57.630 align:middle line:90%
have the credentials.

00:18:57.630 --> 00:18:59.270 align:middle line:84%
So if we take a look
at the information

00:18:59.270 --> 00:19:01.145 align:middle line:84%
we've been able to
gather, so if I say hosts,

00:19:01.145 --> 00:19:02.810 align:middle line:84%
you can see we have
the hosts there.

00:19:02.810 --> 00:19:04.830 align:middle line:90%
If I say services, there we are.

00:19:04.830 --> 00:19:06.530 align:middle line:84%
And then of course,
if we type in loot,

00:19:06.530 --> 00:19:08.308 align:middle line:84%
that will display
the credentials

00:19:08.308 --> 00:19:09.350 align:middle line:90%
that we were able to get.

00:19:09.350 --> 00:19:11.670 align:middle line:90%
And in this case, it displays--

00:19:11.670 --> 00:19:14.690 align:middle line:84%
you can see the schema
that we were able to get.

00:19:14.690 --> 00:19:16.850 align:middle line:84%
If we type in the
creds command, this

00:19:16.850 --> 00:19:18.890 align:middle line:84%
will actually dump out
all the credentials

00:19:18.890 --> 00:19:25.610 align:middle line:84%
that we were able to gather
through the MySQL enumeration

00:19:25.610 --> 00:19:26.240 align:middle line:90%
module.

00:19:26.240 --> 00:19:28.520 align:middle line:84%
And again, this
is why I recommend

00:19:28.520 --> 00:19:30.680 align:middle line:84%
creating a workspace
for every assessment,

00:19:30.680 --> 00:19:33.210 align:middle line:84%
because you can then go through
all the information you were

00:19:33.210 --> 00:19:36.100 align:middle line:84%
able to gather, because the
Metasploit framework will store

00:19:36.100 --> 00:19:37.850 align:middle line:84%
all of this information,
so you can always

00:19:37.850 --> 00:19:41.280 align:middle line:84%
go back to it in the event that
you missed out on something.

00:19:41.280 --> 00:19:42.920 align:middle line:84%
So you can see we
have the credentials

00:19:42.920 --> 00:19:45.870 align:middle line:84%
here that we were able to get,
which is very, very useful.

00:19:45.870 --> 00:19:48.320 align:middle line:84%
So what we'll do now is
let's actually exit out

00:19:48.320 --> 00:19:50.270 align:middle line:84%
of the Metasploit
framework, and I'll

00:19:50.270 --> 00:19:52.730 align:middle line:84%
show you what a typical
penetration tester would

00:19:52.730 --> 00:19:54.500 align:middle line:90%
do once they got credentials.

00:19:54.500 --> 00:19:57.740 align:middle line:84%
And of course, you can do this
via the Metasploit framework

00:19:57.740 --> 00:19:58.860 align:middle line:90%
modules.

00:19:58.860 --> 00:20:01.250 align:middle line:84%
But what they would
typically do, then is, say,

00:20:01.250 --> 00:20:06.650 align:middle line:84%
MySQL paste in the IP and then
log in using the user root,

00:20:06.650 --> 00:20:08.940 align:middle line:84%
and then we can
provide the password.

00:20:08.940 --> 00:20:12.080 align:middle line:84%
So I'll type in the password,
which we know is twinkle, hit

00:20:12.080 --> 00:20:12.770 align:middle line:90%
Enter.

00:20:12.770 --> 00:20:15.420 align:middle line:84%
And it says we don't
have access through that.

00:20:15.420 --> 00:20:18.560 align:middle line:84%
So I'm just going to specify
the remote host option, which

00:20:18.560 --> 00:20:22.550 align:middle line:84%
is -h, type in the
password now, hit Enter,

00:20:22.550 --> 00:20:25.500 align:middle line:84%
and we have access to
the SQL database server.

00:20:25.500 --> 00:20:29.480 align:middle line:84%
So this prompt here allows
us to run any SQL queries.

00:20:29.480 --> 00:20:33.330 align:middle line:84%
So again, I can
say show databases

00:20:33.330 --> 00:20:35.662 align:middle line:84%
and then use the
semicolon, hit Enter.

00:20:35.662 --> 00:20:37.620 align:middle line:84%
And as you can see, we
get the same information

00:20:37.620 --> 00:20:40.540 align:middle line:84%
that we did through the
Metasploit auxiliary modules.

00:20:40.540 --> 00:20:43.140 align:middle line:84%
So you can see how powerful
the Metasploit framework

00:20:43.140 --> 00:20:46.770 align:middle line:84%
auxiliary modules are in regards
to enumerating information.

00:20:46.770 --> 00:20:49.710 align:middle line:84%
And you know I can then say
something like use videos

00:20:49.710 --> 00:20:51.360 align:middle line:90%
to select the videos database.

00:20:51.360 --> 00:20:53.340 align:middle line:84%
As you can see, it
says database changed.

00:20:53.340 --> 00:21:00.977 align:middle line:84%
I can then say show tables, show
tables for the videos database.

00:21:00.977 --> 00:21:02.560 align:middle line:84%
And as you can see,
it's an empty set.

00:21:02.560 --> 00:21:05.040 align:middle line:84%
So the Metasploit
auxiliary module

00:21:05.040 --> 00:21:08.610 align:middle line:84%
that actually dumped the schema,
or rather the database schema,

00:21:08.610 --> 00:21:11.520 align:middle line:84%
was actually accurate, because
none of these databases

00:21:11.520 --> 00:21:13.270 align:middle line:90%
here have any tables under them.

00:21:13.270 --> 00:21:16.050 align:middle line:84%
So we've been able to confirm
that the information we

00:21:16.050 --> 00:21:18.240 align:middle line:84%
got from the Metasploit
framework is accurate.

00:21:18.240 --> 00:21:21.760 align:middle line:84%
And as you can see, these
modules are extremely powerful.

00:21:21.760 --> 00:21:26.120 align:middle line:84%
So that is going to conclude
the practical demonstration.

00:21:26.120 --> 00:21:28.580 align:middle line:84%
In the next video, we are going
to be taking a look at how

00:21:28.580 --> 00:21:31.280 align:middle line:84%
to perform SSH enumeration
through the use

00:21:31.280 --> 00:21:32.630 align:middle line:90%
of auxiliary modules.

00:21:32.630 --> 00:21:35.050 align:middle line:90%
So I'll see you there.