WEBVTT

00:01.000 --> 00:06.820
In this lecture, I would like to cover a case that I faced in pretty much 50 percent of the websites

00:06.820 --> 00:08.510
that I do penetration testing on.

00:09.130 --> 00:14.110
So let me first just run and exploit the one that we've already seen.

00:14.110 --> 00:19.210
So we're just going to run this statement, which will select the table name from information schemata

00:19.210 --> 00:19.740
tables.

00:19.990 --> 00:23.890
So this should list all the tables that exist within our page.

00:25.210 --> 00:29.800
And I have my security set too low at the moment, so I'm just going to start that here.

00:30.850 --> 00:32.950
Remove this extra one and hit enter.

00:35.730 --> 00:41.350
As you can see, it gets exploited and it shows us the table name here instead of number one.

00:41.730 --> 00:46.490
So we see all the table names that exist within this current database.

00:48.660 --> 00:54.780
Now, the case that I'd like to cover is when you actually run the statement, so the website will be

00:54.780 --> 00:59.790
vulnerable and when you run the statement, you will only see one result at a time.

01:00.360 --> 01:05.460
And that's because the page is programmed in a way to display only one result at a time.

01:06.330 --> 01:11.770
To do this, we're actually going to need to modify the code for the low security level for DPW.

01:11.910 --> 01:15.240
I will do that now and then we'll come back to exploit it.

01:15.720 --> 01:18.570
So I'm actually just going to modify the code for DPW.

01:18.690 --> 01:20.530
This is not part of the exploitation.

01:20.700 --> 01:23.850
This is just to make this exploit a little bit trickier.

01:24.850 --> 01:33.070
So Mr. Meet Exploitable now, and I'm going to open the low security level of the Ezekial injection

01:33.070 --> 01:40.870
file, so I'm going to use Sudo because the file has root permissions and I'm going to use Nano as the

01:40.870 --> 01:41.620
text editor.

01:43.440 --> 01:48.750
So this is the program that we'll use to modify the file and the file is stored in.

01:50.330 --> 01:56.960
The w w w w a vulnerability's Eskil injection.

01:58.570 --> 02:01.770
Source and then follow that up.

02:02.590 --> 02:04.770
So, again, I'm just going to go through this.

02:04.780 --> 02:05.080
Come on.

02:05.120 --> 02:09.610
So what we're doing is we're saying pseudo to run the file in privileges.

02:09.820 --> 02:12.670
Nano is the program that we're going to open the file with.

02:12.850 --> 02:20.920
And then the file is stored and by there will be vulnerabilities as kuli source load.

02:22.300 --> 02:23.290
I'm going to hit enter.

02:24.260 --> 02:30.320
And asking me for the admin password now the root password is Ms admin exactly like the username.

02:33.780 --> 02:34.320
And.

02:35.410 --> 02:40.300
We have the source here for the file, so I'm going to modify here, I'm actually going to modify this

02:40.300 --> 02:40.620
loop.

02:40.900 --> 02:47.590
So what this loop does, it actually loops through all the characters, all the records that this Ezekial

02:47.590 --> 02:52.100
statement gets right here and then it displays them on screen.

02:52.510 --> 02:56.840
So what we want is we want to modify it to only display one result, the first result.

02:57.220 --> 03:00.820
So I'm just going to comment this line to forward Slash's other comment.

03:00.940 --> 03:03.750
So basically, this line will be ignored.

03:04.590 --> 03:10.400
And I'll also come at this one because it closes the wire loop, so this line would be ignored as well.

03:11.850 --> 03:16.530
Now, you don't really need to care to worry about what this means if you're not a programmer, it's

03:16.530 --> 03:17.420
not very important.

03:17.430 --> 03:22.560
Just comment these lines and we'll see what happens at the client site because, well, what we're interested

03:22.560 --> 03:26.510
in this lecture is not the programming we're interested in to the penetration testing.

03:27.000 --> 03:29.550
So I'm just going to hit control to save this.

03:29.880 --> 03:33.570
I'm going to hit Y and enter and that's it.

03:33.570 --> 03:35.010
And save the file.

03:36.120 --> 03:41.130
So we're back here and I'm going to run exactly the same statement, so I'm not going to modify it.

03:41.130 --> 03:45.990
So I'm still saying union selectable name from information schemata tables.

03:47.590 --> 03:49.270
I'm actually going to refresh the page.

03:50.370 --> 03:55.620
And as you can see now, this is not really working, nor is it working, but it's only showing us the

03:55.620 --> 03:59.970
first the first record that's been selected, which is the American.

04:01.210 --> 04:02.790
So this is not even useful.

04:03.800 --> 04:08.750
So the first thing that I'm going to do is this is bringing us the Army record because the admin has

04:08.750 --> 04:10.820
the ID of no one.

04:11.540 --> 04:16.580
So we're going to do now is we're actually just going to give it an invalid I.D. So I'm going to give

04:16.580 --> 04:17.810
it a minus one.

04:21.790 --> 04:26.860
As you can see now, the statement works, we're getting a table that exists in the information scheme

04:26.860 --> 04:29.920
at our tables, but we're only getting one table at a time.

04:29.920 --> 04:31.990
We're not getting the full list of the tables.

04:32.470 --> 04:37.210
And this is because the page is programmed in a way that will only display one result.

04:37.490 --> 04:41.470
And this happened to me a lot of a lot of times when I'm doing penetration testing.

04:42.250 --> 04:49.480
So keep in mind that we can run any Ezekial statement that we want on the tape, on the server so we

04:49.480 --> 04:55.360
can modify our skill statement to iterate over all the records and display their content.

04:56.140 --> 05:01.810
So what we're going to do is we're going to now, obviously, you can use the word statement to on this

05:01.810 --> 05:04.840
show database tables within your current database.

05:05.020 --> 05:10.150
But at the at the at the moment, I want to show you how it how to iterate over all the tables.

05:10.660 --> 05:18.340
So what we're going to do instead is use the limited keyword to specify which record we want to display

05:18.490 --> 05:20.080
with the current statement.

05:21.130 --> 05:26.830
This way we'll be able to iterate over the records one by one and display all of them.

05:28.140 --> 05:35.820
So the statement is going to be union select table name from information, scheme the tables, and we're

05:35.820 --> 05:41.220
going to say I want to limit and the limit keyword teach to values.

05:41.640 --> 05:48.710
The first value is the location of the record that we want to start displaying records from.

05:48.720 --> 05:51.360
So where we want to start displaying records.

05:52.710 --> 05:59.280
So I want to start displaying records from the first record, so I'm going to put zero because the record

05:59.280 --> 06:01.080
numbers start at zero.

06:02.380 --> 06:08.860
And the second value that the limit keyword takes is the number of records that we want to display on

06:08.860 --> 06:12.760
screen, starting at the value that we specified in here.

06:13.600 --> 06:18.380
Now we know that this page right here can only show me one record at a time.

06:18.970 --> 06:23.410
So the second value to the limited keyword can only be won in this case.

06:24.130 --> 06:29.350
So basically what we're saying is we want to select the table name from the information schema that

06:29.350 --> 06:29.950
tables.

06:30.430 --> 06:35.080
And I only want you to display one record starting from record zero.

06:36.200 --> 06:37.460
So if I copy this.

06:39.160 --> 06:40.390
And pasted here.

06:44.190 --> 06:51.420
You'll see, I'll get the first table right now, and then if I want to go to the second table, all

06:51.420 --> 06:53.280
I have to do is modify this.

06:53.280 --> 06:58.880
So like I said, this value the first value in here means I want to start at record zero.

06:59.190 --> 07:05.010
So if I want to start at record one, I'm just going to put one and then I can copy this.

07:06.040 --> 07:08.460
And paste it up in here again.

07:11.020 --> 07:16.940
And as you can see, we got the next table now, again, if I want to get the table after this, all

07:16.940 --> 07:20.210
I have to do is modify this and set it to two.

07:20.300 --> 07:25.730
And that means that I want to start this plane from record to and I only want to start to display one

07:25.730 --> 07:28.220
record again if I hit enter.

07:28.670 --> 07:35.480
As you can see, I'm getting the next table and I can keep doing this to iterate over all the records

07:35.480 --> 07:36.110
manually.

07:37.970 --> 07:44.240
Now, we can also enhance the statement by using the word close, so before the limit, we can say I

07:44.240 --> 07:50.900
want to select table name from information schemata tables where tables schema.

07:51.970 --> 07:54.790
Is equal to DV w a.

07:56.820 --> 07:59.400
And now if we paste this in here.

08:01.350 --> 08:08.250
As you can see, this is showing me the users and again, I can iterate over the tables by changing

08:08.250 --> 08:08.930
the number here.

08:08.940 --> 08:13.440
So this is displaying the record at offset one.

08:13.650 --> 08:17.310
I can set this to zero to display the first record.

08:17.430 --> 08:23.400
And as you can see, the first table or the first record is Guestbook, and that's it.

08:23.880 --> 08:27.690
So just a quick and nice lecture to show you how to bypass this problem.

08:27.840 --> 08:35.070
If you face it in pages, that would only display one value or one record for you at a time.
