WEBVTT

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


00:00:09.840 --> 00:00:13.230 align:middle line:84%
Targeting the MySQL
database server--

00:00:13.230 --> 00:00:15.240 align:middle line:84%
in this video, we'll
be taking a look

00:00:15.240 --> 00:00:17.340 align:middle line:84%
at how to exploit
or to gain access

00:00:17.340 --> 00:00:21.180 align:middle line:84%
to the MySQL database server
that is running on the target

00:00:21.180 --> 00:00:21.790 align:middle line:90%
system.

00:00:21.790 --> 00:00:24.280 align:middle line:84%
And furthermore, or
in addition to that,

00:00:24.280 --> 00:00:28.410 align:middle line:84%
we'll be taking a look at how
access to a MySQL database

00:00:28.410 --> 00:00:31.890 align:middle line:84%
server can provide you with
access to the web applications

00:00:31.890 --> 00:00:34.920 align:middle line:84%
that are currently
utilizing the MySQL database

00:00:34.920 --> 00:00:36.400 align:middle line:90%
server for storage.

00:00:36.400 --> 00:00:39.840 align:middle line:84%
And this is, arguably, one of
the most important services

00:00:39.840 --> 00:00:42.330 align:middle line:84%
to exploit when it comes
down to a penetration test

00:00:42.330 --> 00:00:44.640 align:middle line:84%
because any database
server is going

00:00:44.640 --> 00:00:46.720 align:middle line:90%
to be storing information.

00:00:46.720 --> 00:00:48.990 align:middle line:84%
And in the case
of a company that

00:00:48.990 --> 00:00:51.360 align:middle line:84%
has customer data,
if any of that data

00:00:51.360 --> 00:00:53.650 align:middle line:84%
is being stored on
a database server

00:00:53.650 --> 00:00:56.220 align:middle line:84%
and you gain access
to it, then that

00:00:56.220 --> 00:00:59.640 align:middle line:84%
is something that needs
to be taken seriously

00:00:59.640 --> 00:01:03.180 align:middle line:84%
in the context of the company's
organizational security

00:01:03.180 --> 00:01:06.340 align:middle line:84%
as well as their
digital infrastructure.

00:01:06.340 --> 00:01:09.270 align:middle line:90%
So again, we'll be utilizing--

00:01:09.270 --> 00:01:11.730 align:middle line:84%
we will primarily be
utilizing one technique.

00:01:11.730 --> 00:01:15.390 align:middle line:84%
But once we've gained access
to the MySQL database server,

00:01:15.390 --> 00:01:18.810 align:middle line:84%
you'll actually see for
yourself how this access can

00:01:18.810 --> 00:01:22.770 align:middle line:84%
be used to, essentially, gain
access to web applications

00:01:22.770 --> 00:01:25.780 align:middle line:84%
and how you can modify
data, so on and so forth.

00:01:25.780 --> 00:01:28.030 align:middle line:84%
So with that being
said, as I said,

00:01:28.030 --> 00:01:30.220 align:middle line:84%
we're going to be using
the same lab environment.

00:01:30.220 --> 00:01:31.290 align:middle line:90%
So just fire it up.

00:01:31.290 --> 00:01:35.130 align:middle line:84%
And remember to obtain the new
IP address of the target system

00:01:35.130 --> 00:01:38.950 align:middle line:84%
if you've terminated your
lab environment previously.

00:01:38.950 --> 00:01:41.670 align:middle line:84%
So I'll switch over
to my lab environment.

00:01:41.670 --> 00:01:44.190 align:middle line:84%
And we can take a look
at how we can gain access

00:01:44.190 --> 00:01:46.290 align:middle line:90%
to the MySQL database server.

00:01:46.290 --> 00:01:49.870 align:middle line:90%


00:01:49.870 --> 00:01:51.830 align:middle line:84%
So I'm back within
the lab environment.

00:01:51.830 --> 00:01:54.220 align:middle line:84%
And I've just performed a
service version detection

00:01:54.220 --> 00:01:58.580 align:middle line:84%
scan and a default Nmap script
scan on the target system

00:01:58.580 --> 00:02:01.100 align:middle line:84%
and, more specifically,
on the following port.

00:02:01.100 --> 00:02:04.780 align:middle line:84%
So 3306-- that's the
default MySQL port--

00:02:04.780 --> 00:02:08.560 align:middle line:84%
as well as port
8585, where we were

00:02:08.560 --> 00:02:11.170 align:middle line:84%
able to identify that
we have a WampServer

00:02:11.170 --> 00:02:16.840 align:middle line:84%
that is hosting a WordPress
site as well as phpMyAdmin.

00:02:16.840 --> 00:02:18.520 align:middle line:84%
However, if you
remember correctly,

00:02:18.520 --> 00:02:21.760 align:middle line:84%
we couldn't access
phpMyAdmin because access

00:02:21.760 --> 00:02:24.610 align:middle line:84%
had been restricted to
a specific IP, probably

00:02:24.610 --> 00:02:26.200 align:middle line:90%
the localhost.

00:02:26.200 --> 00:02:28.900 align:middle line:84%
With that information,
we can start off

00:02:28.900 --> 00:02:32.890 align:middle line:84%
by taking a look at various
techniques we can use to target

00:02:32.890 --> 00:02:34.880 align:middle line:90%
the MySQL database server.

00:02:34.880 --> 00:02:36.460 align:middle line:84%
The most important
thing to know is

00:02:36.460 --> 00:02:39.610 align:middle line:84%
that MySQL supports
authentication and can

00:02:39.610 --> 00:02:43.210 align:middle line:84%
be remotely authenticated
with or to if you have

00:02:43.210 --> 00:02:45.350 align:middle line:90%
the legitimate credentials.

00:02:45.350 --> 00:02:48.490 align:middle line:84%
Now, we can also utilize
or look for exploits

00:02:48.490 --> 00:02:51.910 align:middle line:84%
pertinent to this
specific version of MySQL

00:02:51.910 --> 00:02:52.780 align:middle line:90%
with SearchSploit.

00:02:52.780 --> 00:02:55.420 align:middle line:84%
So we can say
SearchSploit and MySQL.

00:02:55.420 --> 00:02:57.580 align:middle line:84%
And I can try and
identify any exploits

00:02:57.580 --> 00:03:01.390 align:middle line:84%
that can provide us with
access or maybe even access

00:03:01.390 --> 00:03:04.400 align:middle line:84%
to a specific set of user
accounts and their passwords.

00:03:04.400 --> 00:03:08.080 align:middle line:90%
So I can say MySQL 5.5.

00:03:08.080 --> 00:03:09.940 align:middle line:84%
And you can see there
isn't an exploit

00:03:09.940 --> 00:03:15.520 align:middle line:84%
for this specific version of
MySQL apart from the following,

00:03:15.520 --> 00:03:17.300 align:middle line:90%
these ones right over here.

00:03:17.300 --> 00:03:21.100 align:middle line:84%
However, these ones are pretty
much all privilege escalation

00:03:21.100 --> 00:03:22.940 align:middle line:90%
exploits right over here.

00:03:22.940 --> 00:03:25.730 align:middle line:84%
So the next best thing is
to perform a brute force.

00:03:25.730 --> 00:03:28.330 align:middle line:84%
So in the previous videos,
I performed a brute force

00:03:28.330 --> 00:03:30.250 align:middle line:90%
with Hydra.

00:03:30.250 --> 00:03:31.750 align:middle line:84%
However, in this
case, we can also

00:03:31.750 --> 00:03:34.810 align:middle line:84%
take a look at how to perform a
brute force with the Metasploit

00:03:34.810 --> 00:03:35.420 align:middle line:90%
Framework.

00:03:35.420 --> 00:03:41.460 align:middle line:84%
So I'll just open up MSF console
here and we can get started.

00:03:41.460 --> 00:03:43.140 align:middle line:90%
So MSF console is started.

00:03:43.140 --> 00:03:46.044 align:middle line:84%
And we can search for
the module mysql_login.

00:03:46.044 --> 00:03:49.240 align:middle line:90%


00:03:49.240 --> 00:03:51.920 align:middle line:84%
And we can use the
only module here.

00:03:51.920 --> 00:03:52.750 align:middle line:90%
So we'll say use.

00:03:52.750 --> 00:03:54.280 align:middle line:90%
That's an auxiliary module.

00:03:54.280 --> 00:03:57.580 align:middle line:84%
If we show the options, you
can see we have the ability

00:03:57.580 --> 00:04:00.580 align:middle line:84%
to set the user file, as
well as the password file,

00:04:00.580 --> 00:04:01.750 align:middle line:90%
for the brute force.

00:04:01.750 --> 00:04:04.660 align:middle line:84%
However, you can see a default
username has been specified.

00:04:04.660 --> 00:04:07.900 align:middle line:84%
And that is the root user,
which is, again, pretty much

00:04:07.900 --> 00:04:11.020 align:middle line:84%
the user account
that you need to

00:04:11.020 --> 00:04:15.010 align:middle line:84%
or that you should probably be
targeting for because if you

00:04:15.010 --> 00:04:16.779 align:middle line:90%
obtain the root--

00:04:16.779 --> 00:04:19.779 align:middle line:84%
if you actually obtain the root
account credentials for a MySQL

00:04:19.779 --> 00:04:21.730 align:middle line:84%
database server, then
that means that you

00:04:21.730 --> 00:04:23.350 align:middle line:84%
can make whatever
changes you want

00:04:23.350 --> 00:04:26.950 align:middle line:84%
to to any of the databases and
their consequent or respective

00:04:26.950 --> 00:04:29.130 align:middle line:90%
tables without any issues.

00:04:29.130 --> 00:04:31.600 align:middle line:84%
So we can, essentially,
perform a brute force

00:04:31.600 --> 00:04:33.970 align:middle line:90%
for the root user.

00:04:33.970 --> 00:04:35.920 align:middle line:84%
And let's see whether
we can identify

00:04:35.920 --> 00:04:37.880 align:middle line:90%
any legitimate passwords.

00:04:37.880 --> 00:04:41.840 align:middle line:84%
So we can specify a
password file if we want to.

00:04:41.840 --> 00:04:45.620 align:middle line:84%
And we can also set the RHOST
option, which is the target IP.

00:04:45.620 --> 00:04:49.180 align:middle line:84%
So I'll say set RHOSTS and
specify the target IP address

00:04:49.180 --> 00:04:50.960 align:middle line:90%
there.

00:04:50.960 --> 00:04:53.200 align:middle line:90%
And we can leave both as true.

00:04:53.200 --> 00:04:55.720 align:middle line:84%
That will show us
all the output--

00:04:55.720 --> 00:04:57.380 align:middle line:90%
all the attempts here.

00:04:57.380 --> 00:05:02.560 align:middle line:84%
So for the pass file, if
we say set PASS_FILE--

00:05:02.560 --> 00:05:03.978 align:middle line:90%
can I actually identify that?

00:05:03.978 --> 00:05:04.520 align:middle line:90%
There we are.

00:05:04.520 --> 00:05:06.160 align:middle line:90%
So that's PASS_FILE.

00:05:06.160 --> 00:05:10.070 align:middle line:84%
We can maybe use
user/share/wordlists.

00:05:10.070 --> 00:05:15.040 align:middle line:84%
And we can then say metasploit
and maybe unix_passwords.

00:05:15.040 --> 00:05:19.590 align:middle line:84%
And we can hit
Enter and then run.

00:05:19.590 --> 00:05:21.950 align:middle line:84%
So it looks like that
was relatively quickly.

00:05:21.950 --> 00:05:24.290 align:middle line:84%
It tells us the
version of MySQL.

00:05:24.290 --> 00:05:26.390 align:middle line:84%
And it says that we don't
have an active database.

00:05:26.390 --> 00:05:27.330 align:middle line:90%
That's fine.

00:05:27.330 --> 00:05:30.480 align:middle line:84%
And it looks like we've obtained
legitimate credentials here.

00:05:30.480 --> 00:05:32.270 align:middle line:84%
So it says the
username is "root."

00:05:32.270 --> 00:05:34.580 align:middle line:90%
And the password is "null."

00:05:34.580 --> 00:05:36.720 align:middle line:90%
So this is really, really bad.

00:05:36.720 --> 00:05:38.570 align:middle line:84%
It looks like the
administrator did not

00:05:38.570 --> 00:05:42.650 align:middle line:84%
set a password for the root
user of the MySQL database.

00:05:42.650 --> 00:05:44.630 align:middle line:84%
And that means that we
can essentially log in

00:05:44.630 --> 00:05:46.860 align:middle line:90%
without providing any password.

00:05:46.860 --> 00:05:51.450 align:middle line:84%
So what we'll do here
is I'll just exit.

00:05:51.450 --> 00:05:54.420 align:middle line:84%
And we can actually log into
the MySQL database server

00:05:54.420 --> 00:05:55.960 align:middle line:90%
using the following command.

00:05:55.960 --> 00:05:58.200 align:middle line:90%
So we say mysql user.

00:05:58.200 --> 00:05:59.190 align:middle line:90%
And that is "root."

00:05:59.190 --> 00:06:02.130 align:middle line:84%
And the password we
will specify upon login

00:06:02.130 --> 00:06:03.570 align:middle line:90%
or once we are prompted.

00:06:03.570 --> 00:06:06.690 align:middle line:84%
We then need to specify the
remote host or the IP address

00:06:06.690 --> 00:06:08.700 align:middle line:90%
of the target, which I'll do.

00:06:08.700 --> 00:06:09.690 align:middle line:90%
And I'll hit Enter.

00:06:09.690 --> 00:06:11.910 align:middle line:84%
And since the
password is "null,"

00:06:11.910 --> 00:06:13.500 align:middle line:90%
I'll just hit Enter there.

00:06:13.500 --> 00:06:18.690 align:middle line:84%
And voila, we have gained access
to the SQL database server.

00:06:18.690 --> 00:06:22.230 align:middle line:84%
So that essentially means
that we have root access

00:06:22.230 --> 00:06:24.960 align:middle line:84%
and that we can start
modifying data that's

00:06:24.960 --> 00:06:27.580 align:middle line:84%
stored within the
MySQL database server.

00:06:27.580 --> 00:06:32.020 align:middle line:84%
So if I say show databases,
for example, here--

00:06:32.020 --> 00:06:34.920 align:middle line:84%
so databases--
and hit Enter, you

00:06:34.920 --> 00:06:36.900 align:middle line:84%
can see we have the
following databases.

00:06:36.900 --> 00:06:39.450 align:middle line:84%
We have MySQL Test
and WordPress.

00:06:39.450 --> 00:06:41.460 align:middle line:84%
So that's really
what we're targeting.

00:06:41.460 --> 00:06:45.180 align:middle line:84%
Now, as I said, during the
scanning-- the port scanning

00:06:45.180 --> 00:06:47.340 align:middle line:84%
and enumeration
video, I-- we were

00:06:47.340 --> 00:06:49.950 align:middle line:84%
able to identify that we
have a WampServer running

00:06:49.950 --> 00:06:51.900 align:middle line:90%
on port 8585.

00:06:51.900 --> 00:06:55.380 align:middle line:84%
And it is actually hosting a
WordPress installation as well

00:06:55.380 --> 00:06:57.210 align:middle line:90%
as phpMyAdmin.

00:06:57.210 --> 00:07:00.600 align:middle line:84%
Now, we can gain access
to the WordPress site.

00:07:00.600 --> 00:07:03.720 align:middle line:84%
We can gain access to the
WordPress site via the admin

00:07:03.720 --> 00:07:07.020 align:middle line:84%
credentials because we have
access to the MySQL database.

00:07:07.020 --> 00:07:10.020 align:middle line:84%
And of course, in that case,
we will need to, essentially,

00:07:10.020 --> 00:07:12.540 align:middle line:84%
knew a lot of MySQL
syntax, which, again, I

00:07:12.540 --> 00:07:14.440 align:middle line:90%
don't want to bother you with.

00:07:14.440 --> 00:07:17.340 align:middle line:84%
So while we're at it, we
can also try and gain access

00:07:17.340 --> 00:07:18.880 align:middle line:90%
to phpMyAdmin.

00:07:18.880 --> 00:07:22.050 align:middle line:84%
So if we click on phpMyAdmin,
you can see it's forbidden.

00:07:22.050 --> 00:07:24.330 align:middle line:84%
Now, in the previous
video, we took a look

00:07:24.330 --> 00:07:28.140 align:middle line:84%
at how we can gain access to
the target system via SMB.

00:07:28.140 --> 00:07:30.150 align:middle line:84%
And why don't we
actually do that

00:07:30.150 --> 00:07:33.840 align:middle line:84%
so that we can modify the
phpMyAdmin configuration

00:07:33.840 --> 00:07:36.510 align:middle line:84%
file, consequently
allowing any user to access

00:07:36.510 --> 00:07:39.090 align:middle line:90%
phpMyAdmin via the browser?

00:07:39.090 --> 00:07:43.540 align:middle line:84%
So I'll just open up
a new terminal here.

00:07:43.540 --> 00:07:46.898 align:middle line:84%
And let me just zoom
in slightly if I can.

00:07:46.898 --> 00:07:47.440 align:middle line:90%
There we are.

00:07:47.440 --> 00:07:49.920 align:middle line:90%
So I'll say msfconsole.

00:07:49.920 --> 00:07:51.870 align:middle line:84%
And then we'll give this
a couple of seconds.

00:07:51.870 --> 00:07:55.150 align:middle line:84%
And we can utilize any of the
modules we used previously.

00:07:55.150 --> 00:07:58.440 align:middle line:84%
So we can use PsExec or we
can utilize EternalBlue.

00:07:58.440 --> 00:08:02.130 align:middle line:84%
So in this case, let's
just use EternalBlue.

00:08:02.130 --> 00:08:04.740 align:middle line:84%
So I'll say search
eternalblue, use,

00:08:04.740 --> 00:08:06.105 align:middle line:90%
and we'll use the first exploit.

00:08:06.105 --> 00:08:07.860 align:middle line:90%
So I'll say use 0.

00:08:07.860 --> 00:08:10.330 align:middle line:84%
The payload is the
default 64-bit payload.

00:08:10.330 --> 00:08:11.920 align:middle line:90%
So I'll say show options.

00:08:11.920 --> 00:08:14.130 align:middle line:84%
And really, the only
option we need to specify

00:08:14.130 --> 00:08:15.600 align:middle line:90%
is the RHOSTS option.

00:08:15.600 --> 00:08:18.540 align:middle line:84%
You also need to configure
the LHOST and LPORT option.

00:08:18.540 --> 00:08:20.820 align:middle line:84%
But in my case,
that's done for me.

00:08:20.820 --> 00:08:23.340 align:middle line:84%
Once that is done,
I'll just hit Exploit.

00:08:23.340 --> 00:08:25.800 align:middle line:84%
And we should get an
elevated Meterpreter session

00:08:25.800 --> 00:08:27.630 align:middle line:84%
on the target system
that will allow

00:08:27.630 --> 00:08:32.010 align:middle line:84%
us to modify or to download
the phpMyAdmin config file,

00:08:32.010 --> 00:08:36.190 align:middle line:84%
modify it, and then upload
the new modified version.

00:08:36.190 --> 00:08:38.350 align:middle line:84%
So it looks like we get
an Meterpreter session.

00:08:38.350 --> 00:08:43.500 align:middle line:84%
So sysinfo and get user
ID-- now, in certain cases,

00:08:43.500 --> 00:08:47.160 align:middle line:84%
in order to modify files
that belong to applications

00:08:47.160 --> 00:08:49.680 align:middle line:84%
like WAMP, you will
need-- you will actually

00:08:49.680 --> 00:08:52.210 align:middle line:84%
need elevated privileges
in order to do that.

00:08:52.210 --> 00:08:53.730 align:middle line:90%
And in this case, we do.

00:08:53.730 --> 00:08:55.780 align:middle line:84%
So we can take
advantage of that.

00:08:55.780 --> 00:08:59.820 align:middle line:84%
Now, the WAMP stack
for Windows typically

00:08:59.820 --> 00:09:02.340 align:middle line:84%
stores the actual
web applications

00:09:02.340 --> 00:09:04.260 align:middle line:84%
that are being hosted
on it as well as

00:09:04.260 --> 00:09:08.040 align:middle line:84%
the configuration files
for them within the C drive

00:09:08.040 --> 00:09:09.660 align:middle line:90%
in a folder called "wamp."

00:09:09.660 --> 00:09:12.450 align:middle line:84%
So you can see right
over here if I print out

00:09:12.450 --> 00:09:14.130 align:middle line:84%
the current working
directory, we're

00:09:14.130 --> 00:09:15.990 align:middle line:90%
in the root of the C drive.

00:09:15.990 --> 00:09:18.220 align:middle line:84%
And we can take a look
at the wamp directory.

00:09:18.220 --> 00:09:21.190 align:middle line:84%
So under wamp, you
will see that we'll

00:09:21.190 --> 00:09:24.220 align:middle line:84%
have quite a few folders
and directories here.

00:09:24.220 --> 00:09:26.530 align:middle line:84%
And under apps, that's
typically where you'll

00:09:26.530 --> 00:09:28.210 align:middle line:90%
find your web applications.

00:09:28.210 --> 00:09:30.770 align:middle line:84%
Alternatively, they
could be under www.

00:09:30.770 --> 00:09:33.880 align:middle line:84%
So if I click on
www here, you can

00:09:33.880 --> 00:09:39.130 align:middle line:84%
see that we have WordPress, Test
MySQL, Meterpreter, et cetera.

00:09:39.130 --> 00:09:42.250 align:middle line:84%
Now, we could have obtained
the MySQL credentials

00:09:42.250 --> 00:09:44.750 align:middle line:84%
by taking a look at the
WordPress config file.

00:09:44.750 --> 00:09:47.260 align:middle line:84%
So if I head over into
the WordPress directory

00:09:47.260 --> 00:09:52.090 align:middle line:84%
and I cat out the contents
of wordpressconfig.php,

00:09:52.090 --> 00:09:57.290 align:middle line:84%
that file typically contains
the MySQL database passwords.

00:09:57.290 --> 00:09:59.780 align:middle line:84%
So let's see if I can
identify that there.

00:09:59.780 --> 00:10:00.650 align:middle line:90%
Indeed, it does.

00:10:00.650 --> 00:10:02.860 align:middle line:84%
So you can see the
database name is WordPress.

00:10:02.860 --> 00:10:04.600 align:middle line:90%
The database user is root.

00:10:04.600 --> 00:10:06.440 align:middle line:84%
And the password
is a null password.

00:10:06.440 --> 00:10:08.290 align:middle line:84%
So there's multiple
techniques or ways

00:10:08.290 --> 00:10:12.010 align:middle line:84%
you could have identified
the MySQL database

00:10:12.010 --> 00:10:14.390 align:middle line:90%
password for the root user.

00:10:14.390 --> 00:10:16.270 align:middle line:84%
But that's where
the apps are stored.

00:10:16.270 --> 00:10:19.870 align:middle line:84%
Now, if we want to change
the WordPress admin user--

00:10:19.870 --> 00:10:22.060 align:middle line:84%
the WordPress
admin password, you

00:10:22.060 --> 00:10:23.440 align:middle line:90%
need to do that through MySQL.

00:10:23.440 --> 00:10:24.850 align:middle line:84%
But as I said,
that will actually

00:10:24.850 --> 00:10:29.290 align:middle line:84%
require knowledge of
MySQL syntax or queries.

00:10:29.290 --> 00:10:33.070 align:middle line:84%
So we can leverage
phpMyAdmin because phpMyAdmin

00:10:33.070 --> 00:10:36.760 align:middle line:84%
is much easier to use in
regards to modifying data that's

00:10:36.760 --> 00:10:38.510 align:middle line:90%
stored within a table.

00:10:38.510 --> 00:10:41.050 align:middle line:84%
So we can go back a
step here as well.

00:10:41.050 --> 00:10:43.750 align:middle line:90%
And we can take a look at the--

00:10:43.750 --> 00:10:46.540 align:middle line:84%
I'm looking for the
phpMyAdmin config file.

00:10:46.540 --> 00:10:49.510 align:middle line:84%
That is probably stored
under alias, I believe.

00:10:49.510 --> 00:10:52.420 align:middle line:84%
So we take a look at
the alias directory.

00:10:52.420 --> 00:10:55.060 align:middle line:84%
Yes, you can see we
have phpmyadmin.conf.

00:10:55.060 --> 00:10:57.340 align:middle line:84%
Now, this configuration
file is, essentially,

00:10:57.340 --> 00:11:01.450 align:middle line:84%
used to control access and
the way phpMyAdmin works.

00:11:01.450 --> 00:11:04.720 align:middle line:84%
And it looks like this file has
been modified to prevent anyone

00:11:04.720 --> 00:11:07.870 align:middle line:84%
from accessing it, apart
from the actual user

00:11:07.870 --> 00:11:11.210 align:middle line:84%
on the actual
system or localhost.

00:11:11.210 --> 00:11:13.400 align:middle line:84%
So we can download
this file locally.

00:11:13.400 --> 00:11:16.580 align:middle line:84%
So I'm going to say download
and phpmyadmin.conf.

00:11:16.580 --> 00:11:19.300 align:middle line:90%


00:11:19.300 --> 00:11:20.620 align:middle line:90%
That's downloaded.

00:11:20.620 --> 00:11:24.070 align:middle line:84%
In this terminal window,
I'll just exit from MySQL.

00:11:24.070 --> 00:11:27.530 align:middle line:84%
And we should have
phpMyAdmin downloaded here.

00:11:27.530 --> 00:11:30.370 align:middle line:84%
So we can modify this with
VIM or any text editor

00:11:30.370 --> 00:11:32.300 align:middle line:90%
that you're comfortable with.

00:11:32.300 --> 00:11:34.420 align:middle line:84%
And if we take a
look at it here,

00:11:34.420 --> 00:11:39.130 align:middle line:84%
you can see under directory
C, WAMP, apps, phpMyAdmin,

00:11:39.130 --> 00:11:41.710 align:middle line:84%
this is where those
rules have been set.

00:11:41.710 --> 00:11:45.010 align:middle line:84%
So you can see right over here
the order, the default order,

00:11:45.010 --> 00:11:47.470 align:middle line:90%
is set to deny and allow.

00:11:47.470 --> 00:11:51.970 align:middle line:84%
And it denies access from all
IP addresses and allows access

00:11:51.970 --> 00:11:56.690 align:middle line:84%
only from the localhost, or
the target system itself.

00:11:56.690 --> 00:12:01.240 align:middle line:84%
So what we can do is we can
get rid of all of these rules.

00:12:01.240 --> 00:12:04.240 align:middle line:84%
So I'll just delete that line
there, delete that line there.

00:12:04.240 --> 00:12:08.260 align:middle line:84%
And instead of allowing access
only from the localhost,

00:12:08.260 --> 00:12:12.490 align:middle line:84%
we can say allow from
all, write and quit.

00:12:12.490 --> 00:12:13.610 align:middle line:90%
And that's pretty much it.

00:12:13.610 --> 00:12:16.130 align:middle line:84%
We now need to upload
the updated version.

00:12:16.130 --> 00:12:19.120 align:middle line:84%
So we can say upload
phpmyadmin.conf.

00:12:19.120 --> 00:12:20.770 align:middle line:84%
And the great thing
with Meterpreter

00:12:20.770 --> 00:12:23.560 align:middle line:84%
is it will automatically
replace the file with the one

00:12:23.560 --> 00:12:24.910 align:middle line:90%
that you've just uploaded.

00:12:24.910 --> 00:12:26.470 align:middle line:90%
So that contains the changes.

00:12:26.470 --> 00:12:31.390 align:middle line:84%
And we can confirm that by
saying cat and phpmyadmin.conf.

00:12:31.390 --> 00:12:34.030 align:middle line:84%
And you can see that those
rules have now been updated--

00:12:34.030 --> 00:12:35.620 align:middle line:90%
so allow from all.

00:12:35.620 --> 00:12:38.350 align:middle line:84%
Now, if we try and
reload phpMyAdmin here,

00:12:38.350 --> 00:12:40.090 align:middle line:84%
you can see it's still
saying forbidden.

00:12:40.090 --> 00:12:43.300 align:middle line:84%
The reason for that is because
once you make any change

00:12:43.300 --> 00:12:48.190 align:middle line:84%
to the Apache configuration file
for any of these applications

00:12:48.190 --> 00:12:50.860 align:middle line:84%
or to the default Apache
configuration file,

00:12:50.860 --> 00:12:54.070 align:middle line:84%
you actually need to
restart the Apache service.

00:12:54.070 --> 00:12:56.320 align:middle line:84%
Right now, in order to
restart the service,

00:12:56.320 --> 00:12:59.710 align:middle line:84%
we need to open up a Windows
command prompt session here.

00:12:59.710 --> 00:13:04.460 align:middle line:84%
And what we need to do now is
we need to stop the WAMP Apache

00:13:04.460 --> 00:13:04.960 align:middle line:90%
service.

00:13:04.960 --> 00:13:07.960 align:middle line:84%
That can be done through
the use of net stop.

00:13:07.960 --> 00:13:10.280 align:middle line:84%
And this requires
administrative privileges.

00:13:10.280 --> 00:13:12.670 align:middle line:90%
So net stop wampapache--

00:13:12.670 --> 00:13:14.140 align:middle line:90%
that'll stop the service.

00:13:14.140 --> 00:13:16.420 align:middle line:84%
As you can see, WAMP
Apache service is stopping.

00:13:16.420 --> 00:13:19.810 align:middle line:84%
We can then say net
start wampapache.

00:13:19.810 --> 00:13:24.070 align:middle line:90%


00:13:24.070 --> 00:13:26.230 align:middle line:84%
If it starts successfully
without any errors,

00:13:26.230 --> 00:13:28.450 align:middle line:84%
then we should be able
to access phpMyAdmin.

00:13:28.450 --> 00:13:30.800 align:middle line:90%
So I'll reload that.

00:13:30.800 --> 00:13:32.740 align:middle line:84%
And we should be able
to-- yeah, there we are.

00:13:32.740 --> 00:13:35.560 align:middle line:84%
In fact, we are automatically
logged into phpMyAdmin .

00:13:35.560 --> 00:13:38.170 align:middle line:84%
So that is a huge
security failure

00:13:38.170 --> 00:13:42.040 align:middle line:84%
on the side of the
administrator of the website.

00:13:42.040 --> 00:13:44.530 align:middle line:84%
So again, what we
were trying to do

00:13:44.530 --> 00:13:48.100 align:middle line:84%
is showcase how access to
the MySQL database server

00:13:48.100 --> 00:13:52.060 align:middle line:84%
can be used to essentially gain
access to the web applications

00:13:52.060 --> 00:13:54.620 align:middle line:84%
that are being hosted
on the target system.

00:13:54.620 --> 00:13:57.001 align:middle line:84%
So if we take a
look at WordPress,

00:13:57.001 --> 00:13:59.860 align:middle line:84%
WordPress user accounts are
stored under the WordPress

00:13:59.860 --> 00:14:00.970 align:middle line:90%
users table.

00:14:00.970 --> 00:14:03.860 align:middle line:84%
And you can see we want to gain
access to the admin account.

00:14:03.860 --> 00:14:06.580 align:middle line:84%
So we need to change the default
password, or the password that

00:14:06.580 --> 00:14:07.960 align:middle line:90%
existed previously.

00:14:07.960 --> 00:14:09.880 align:middle line:84%
Now, as I said, in
a real pen test,

00:14:09.880 --> 00:14:12.130 align:middle line:84%
you definitely do
not want to do this.

00:14:12.130 --> 00:14:15.100 align:middle line:84%
Your job is to just
show and, of course,

00:14:15.100 --> 00:14:17.350 align:middle line:84%
document the fact that
you were able to do this.

00:14:17.350 --> 00:14:19.340 align:middle line:84%
And you need to
highlight how you did it.

00:14:19.340 --> 00:14:21.910 align:middle line:84%
So this is just showing you
what an attacker would typically

00:14:21.910 --> 00:14:25.000 align:middle line:84%
be able to do and how
dangerous this is.

00:14:25.000 --> 00:14:26.170 align:middle line:90%
So you can click on Edit.

00:14:26.170 --> 00:14:28.630 align:middle line:84%
And under User
Password, I'll click

00:14:28.630 --> 00:14:31.030 align:middle line:84%
on the default
WordPress encryption

00:14:31.030 --> 00:14:33.100 align:middle line:90%
algorithm, which is MD5.

00:14:33.100 --> 00:14:35.710 align:middle line:84%
And I can change the
actual hash there

00:14:35.710 --> 00:14:38.830 align:middle line:84%
to my own cleartext
password-- so password123.

00:14:38.830 --> 00:14:41.440 align:middle line:84%
And the great thing with
phpMyAdmin and MySQL

00:14:41.440 --> 00:14:43.840 align:middle line:84%
is it will automatically
encrypt it with MD5.

00:14:43.840 --> 00:14:45.190 align:middle line:90%
So I'll hit Go.

00:14:45.190 --> 00:14:46.610 align:middle line:90%
And that is changed.

00:14:46.610 --> 00:14:49.360 align:middle line:84%
So I can now go back to
the WampServer home page.

00:14:49.360 --> 00:14:51.280 align:middle line:84%
And we can try and
log into WordPress.

00:14:51.280 --> 00:14:54.420 align:middle line:84%
So I'll click on
WordPress there.

00:14:54.420 --> 00:14:56.370 align:middle line:84%
We'll give this a
couple of seconds.

00:14:56.370 --> 00:14:59.550 align:middle line:84%
And under WordPress, I can
then say WordPress Admin.

00:14:59.550 --> 00:15:03.120 align:middle line:84%
That'll allow me to log
into the admin dashboard.

00:15:03.120 --> 00:15:04.950 align:middle line:84%
So the default
username is "admin."

00:15:04.950 --> 00:15:08.820 align:middle line:84%
And the password that we
set was "password123."

00:15:08.820 --> 00:15:10.020 align:middle line:90%
And log in.

00:15:10.020 --> 00:15:12.930 align:middle line:84%
And that should provide
us access to the WordPress

00:15:12.930 --> 00:15:15.660 align:middle line:84%
dashboard, which,
consequently, gives us access

00:15:15.660 --> 00:15:18.000 align:middle line:90%
to the entire WordPress site.

00:15:18.000 --> 00:15:22.320 align:middle line:84%
And we can make changes and,
furthermore, download and view

00:15:22.320 --> 00:15:24.330 align:middle line:84%
customer data or
whatever data is

00:15:24.330 --> 00:15:28.860 align:middle line:84%
being stored within the
actual WordPress site itself.

00:15:28.860 --> 00:15:31.180 align:middle line:84%
So we'll give this
a couple of seconds.

00:15:31.180 --> 00:15:32.460 align:middle line:90%
And it should log us in.

00:15:32.460 --> 00:15:33.160 align:middle line:90%
There we are.

00:15:33.160 --> 00:15:35.520 align:middle line:84%
And we now have access
to the WordPress site.

00:15:35.520 --> 00:15:39.600 align:middle line:84%
And we can pretty much modify,
do whatever we want with it.

00:15:39.600 --> 00:15:43.170 align:middle line:84%
So that, as you can
see, was quite a lot.

00:15:43.170 --> 00:15:48.120 align:middle line:84%
And it, essentially, involved
chaining or utilizing access

00:15:48.120 --> 00:15:51.670 align:middle line:84%
from one service to gain
access to another service

00:15:51.670 --> 00:15:55.350 align:middle line:84%
or, in this case,
a web application.

00:15:55.350 --> 00:15:59.380 align:middle line:84%
So that is how to target and
exploit the MySQL database

00:15:59.380 --> 00:15:59.880 align:middle line:90%
server.

00:15:59.880 --> 00:16:02.130 align:middle line:84%
As I said, in this
case, this system

00:16:02.130 --> 00:16:04.800 align:middle line:84%
was set up to showcase
the techniques as opposed

00:16:04.800 --> 00:16:08.280 align:middle line:84%
to it being hardened
and secured.

00:16:08.280 --> 00:16:11.490 align:middle line:84%
But if it was still protected
with a weak password,

00:16:11.490 --> 00:16:14.640 align:middle line:84%
we would have been able to
perform a brute force attack

00:16:14.640 --> 00:16:18.480 align:middle line:84%
and identify that password
irregardless of that.

00:16:18.480 --> 00:16:20.130 align:middle line:84%
With that being
said, that is going

00:16:20.130 --> 00:16:22.140 align:middle line:84%
to conclude the
practical demonstration

00:16:22.140 --> 00:16:25.570 align:middle line:90%
side of this video.

00:16:25.570 --> 00:16:28.810 align:middle line:84%
So that concludes the
Windows exploitation section

00:16:28.810 --> 00:16:30.640 align:middle line:84%
of this course--
more specifically,

00:16:30.640 --> 00:16:32.530 align:middle line:84%
the Windows black
box penetration

00:16:32.530 --> 00:16:35.500 align:middle line:84%
test that you were
assigned to do.

00:16:35.500 --> 00:16:39.130 align:middle line:84%
And hopefully, you went through
the actual target yourself

00:16:39.130 --> 00:16:42.370 align:middle line:84%
and were able to identify other
vulnerable services that you

00:16:42.370 --> 00:16:45.790 align:middle line:84%
could exploit in order to gain
access to the target system.

00:16:45.790 --> 00:16:48.310 align:middle line:84%
There are still quite a few
that I haven't explored,

00:16:48.310 --> 00:16:50.710 align:middle line:84%
and for good reason,
the reason being--

00:16:50.710 --> 00:16:52.750 align:middle line:84%
is the rest of the
vulnerable services

00:16:52.750 --> 00:16:55.810 align:middle line:84%
require a lot of
manual exploitation.

00:16:55.810 --> 00:16:58.870 align:middle line:84%
And I wanted you to actually
go through that yourself.

00:16:58.870 --> 00:16:59.920 align:middle line:90%
It's good practice.

00:16:59.920 --> 00:17:02.020 align:middle line:84%
And as I said,
the only objective

00:17:02.020 --> 00:17:03.550 align:middle line:90%
is just to gain access.

00:17:03.550 --> 00:17:05.710 align:middle line:84%
And within the
post-exploitation course,

00:17:05.710 --> 00:17:09.130 align:middle line:84%
we'll actually be covering the
various tactics and techniques

00:17:09.130 --> 00:17:11.650 align:middle line:84%
involved within
post-exploitation.

00:17:11.650 --> 00:17:14.770 align:middle line:84%
But if you were able to gain
access to the target system

00:17:14.770 --> 00:17:17.800 align:middle line:84%
through any of these
services, then well done.

00:17:17.800 --> 00:17:20.920 align:middle line:84%
And of course, I've
actually covered pretty much

00:17:20.920 --> 00:17:24.369 align:middle line:84%
the most important service that
you should have been targeting

00:17:24.369 --> 00:17:26.230 align:middle line:90%
given your current skill level.

00:17:26.230 --> 00:17:29.140 align:middle line:84%
But as you progress, you'll be
able to find vulnerabilities

00:17:29.140 --> 00:17:30.610 align:middle line:90%
within API endpoints.

00:17:30.610 --> 00:17:33.340 align:middle line:84%
And there are quite a
few on the target system,

00:17:33.340 --> 00:17:35.740 align:middle line:84%
probably about three or four
more vulnerable services

00:17:35.740 --> 00:17:37.708 align:middle line:90%
that you could have exploited.

00:17:37.708 --> 00:17:39.250 align:middle line:84%
With that being
said, we're now going

00:17:39.250 --> 00:17:42.250 align:middle line:84%
to move over to the Linux
exploitation section, where

00:17:42.250 --> 00:17:46.120 align:middle line:84%
we are going to be covering
a Linux black box penetration

00:17:46.120 --> 00:17:48.010 align:middle line:84%
test, similar to
what we've done here.

00:17:48.010 --> 00:17:50.470 align:middle line:84%
And your objectives are going
to be pretty much the same.

00:17:50.470 --> 00:17:53.840 align:middle line:84%
Your job is simply to gain
access to the Linux system.

00:17:53.840 --> 00:17:55.360 align:middle line:90%
So I hope you're excited.

00:17:55.360 --> 00:17:58.830 align:middle line:84%
And I'll be seeing
you in the next video.

00:17:58.830 --> 00:18:00.000 align:middle line:90%