WEBVTT

00:00.860 --> 00:05.840
The third type of vulnerability that we looked at was the file inclusion and we looked at two types,

00:06.020 --> 00:12.110
the local file inclusion, which allowed us to include any file on the system and then read files which

00:12.110 --> 00:17.210
will cause a file disclosure vulnerability, and then you'd be able to read any file on the server.

00:17.570 --> 00:23.480
And then we looked at the remote file inclusion, which is very dangerous, which allowed us to include

00:23.480 --> 00:25.630
any file from any Web server.

00:25.640 --> 00:30.830
So we were able to include BHP shells and then get Conexion from the target computer.

00:32.490 --> 00:37.530
To prevent this, first of all, make sure you prevent the remote fall inclusion, so just in case anything

00:37.530 --> 00:43.230
goes wrong, people can't include files from outside your server and you can do that the same way we

00:43.230 --> 00:49.590
enabled it using the API by disabling the allow yourself open and allow your URL include.

00:50.160 --> 00:53.520
And if we go here to our little exploitable, I'll just show you very quick.

00:54.030 --> 00:55.170
So if we do.

00:56.630 --> 01:03.230
Pseudo Nano, which is the text editor at CGI with a tiny the same file that we used.

01:03.470 --> 01:07.070
This is the file for the HP settings if you open that file.

01:09.660 --> 01:11.340
And now I'm going to do controlled W.

01:13.550 --> 01:14.450
And look for.

01:15.590 --> 01:17.300
Allow your el.

01:23.700 --> 01:27.860
And you want to make sure that they allow yourself openly said to of.

01:29.490 --> 01:32.430
And the L include is said to off as well.

01:35.090 --> 01:38.630
Control X, Y and enter, and that'll save it for you.

01:42.480 --> 01:48.360
The other way to prevent these exploits is to use static file inclusion, so instead of using dynamic

01:48.360 --> 01:54.300
file inclusion, which we've seen, you can hard code the files that you want to include in the code

01:54.300 --> 01:58.200
and not get them using get or post, for example, what's happening.

01:58.200 --> 02:04.790
And the examples we see in the vulnerable examples is we have a page called Page or Indexed that BHP.

02:06.220 --> 02:11.650
And then this index that takes a parameter called Page, and then it takes another page, for example,

02:11.650 --> 02:15.970
news that BHP and it includes this newspaper in the code.

02:16.420 --> 02:20.090
So what's the code look like in the code?

02:20.230 --> 02:21.340
You'll see something like.

02:21.340 --> 02:22.060
Include.

02:31.000 --> 02:38.320
So what this will do, basically, and that looks like this, I believe what this do it includes.

02:39.350 --> 02:42.200
Whatever comes after the page parameter.

02:43.380 --> 02:50.250
So the code will dynamically takes whatever that comes in after the page parameter and includes it in

02:50.250 --> 02:50.940
the current page.

02:50.970 --> 02:54.060
So this will be in the index, that BHP page.

02:55.050 --> 03:01.230
OK, this is very bad because even if it's not get sometimes people use post and in post you won't see

03:01.230 --> 03:01.530
this.

03:01.710 --> 03:08.370
So it will be posted, but you can use a proxy such as proxy and this would look like that and then

03:08.370 --> 03:14.820
you can modify it and get it to include anything you want and then it's displayed on the page.

03:15.390 --> 03:21.570
What we really want to do is we want the user not to be able to manipulate with what's going to be included.

03:21.720 --> 03:28.860
So if you want it to include a page called News that we just included inside this without giving the

03:28.860 --> 03:35.100
user the ability to change it, I know you're going to program your code to just have it looking like

03:35.100 --> 03:35.480
this.

03:36.330 --> 03:42.330
But the users we know, we see how users can play with this and just get it to include anything they

03:42.330 --> 03:42.630
want.

03:42.870 --> 03:46.400
So the best way to do it is just to get it to include a page that BHB.

03:46.830 --> 03:49.320
So your code is not using any variables.

03:49.470 --> 03:50.940
It's it's hard coded.

03:50.940 --> 03:54.550
It might make your code log longer, but it's much more secure.

03:57.990 --> 04:02.220
And this is exactly what the high security option does.

04:02.610 --> 04:06.900
So let's go back to the final conclusion first, and we're at the low.

04:07.320 --> 04:13.200
And if I view the source now, you'll see that basically a file is what you pass through it.

04:13.200 --> 04:19.230
So file is what we pass through it in here and the after the page parameter and you can see that it

04:19.230 --> 04:21.850
tries to display anything that we send it.

04:21.870 --> 04:26.670
So when we send it ATC password, it shows us the password.

04:28.200 --> 04:33.630
Now I'm actually going to keep this open and I'm going to go to the security level, to the security,

04:33.900 --> 04:35.310
and I'm going to set it to high.

04:38.140 --> 04:45.550
And now the medium is similar to Zillow, so you can actually use the same, you can exploit it the

04:45.550 --> 04:47.600
same way that we exploited the low.

04:47.920 --> 04:51.880
So we're going to the house right away and we're going to view the source.

04:53.550 --> 04:57.450
And I'm just going to minimize this because they have the two sources now so we can compare them.

04:59.800 --> 05:05.790
So as you can see here in the low and medium security level, you can see that anything we pass to the

05:05.800 --> 05:08.560
file of a variable, it will be displayed to us.

05:09.130 --> 05:15.910
Whereas in here at the high security level, you can see that it is hard coded, that it is only allowed

05:15.910 --> 05:18.990
to show us the include the BHP file.

05:19.450 --> 05:21.940
So you can you can modify this if statement.

05:21.940 --> 05:26.920
If you had a number of files that you wish to include, then you can allow them in here or you can have

05:26.920 --> 05:27.700
them in a list.

05:27.910 --> 05:33.300
But basically the concept is you only allow the files that the user is allowed to see.

05:33.430 --> 05:35.410
So you can just have them in a list here.

05:35.420 --> 05:41.200
You can use an our statement or you can just have a list and say if the file is in this list, then

05:41.200 --> 05:44.950
displayed, otherwise give an error, saying the file is not found.

05:46.240 --> 05:48.070
So avoid this.

05:48.220 --> 05:49.760
Go with the hardcoded method.

05:49.780 --> 05:50.170
Yes.

05:50.170 --> 05:53.580
It doesn't look as pretty as this, but it's much more secure.
