WEBVTT

00:00.690 --> 00:06.810
And this lecture, we're going to see another method of exploiting local file inclusion vulnerabilities

00:06.900 --> 00:11.790
and gain full share or full control over the target server.

00:12.390 --> 00:17.930
So in the previous video, we've seen how to do with using the environ variable or environmental variables.

00:18.240 --> 00:22.170
And in this lecture, we're going to see how to do it based on the logs.

00:23.100 --> 00:29.400
These servers have a lot of log files and basically at the moment we can read any file on the server

00:29.400 --> 00:31.160
as long as we have permissions to read it.

00:31.530 --> 00:38.190
So if we can manage to write anything to any of these files, then we can pretty much execute code and

00:38.190 --> 00:40.140
gain control over our target.

00:40.740 --> 00:48.090
So what you need to do is you need to try and read any of the log files and see or think of a way to

00:48.300 --> 00:51.240
interact with this log file so that you can write stuff on it.

00:51.270 --> 00:58.470
For example, if the log files that you're reading or interacting with our mail log files, then maybe

00:58.470 --> 01:02.740
you can send an email with a code and then it'll show up in the log file.

01:02.970 --> 01:06.600
And our example, we're going to be using the VA log of that log.

01:06.990 --> 01:11.110
And this file contains all the login attempts to the target server.

01:11.610 --> 01:15.420
So let's do it and you'll have a better understanding at the moment.

01:15.450 --> 01:20.460
Now, I just have the basic exploit and I'm trying to show it password.

01:21.000 --> 01:24.240
So this is the file that we use in our basic exploit.

01:24.660 --> 01:25.710
I'm just going to remove that.

01:26.610 --> 01:29.190
And I'm going to look for one.

01:31.000 --> 01:31.570
Log.

01:34.140 --> 01:34.830
Northlake.

01:38.350 --> 01:44.420
Now, as you can see, the file is readable and we can read login attempts to the target server.

01:45.550 --> 01:49.510
So what we're going to do, we're going to think now this file displays all login attempts.

01:49.690 --> 01:53.740
So why not try to log in and see if the attempt will be displayed here?

01:54.290 --> 01:55.360
So I'm going to do here.

01:55.360 --> 01:57.780
I'm just going to try to search into the server.

01:58.090 --> 02:04.030
So I'm going to use S.H., as I say, which is just a lot of remote login service that is used by Web

02:04.030 --> 02:04.570
servers.

02:04.570 --> 02:06.970
Pretty much every Web server has it installed.

02:07.750 --> 02:09.700
So we're going to try to access into it.

02:09.710 --> 02:14.800
So we're going to do a search and then we're going to put the username and I'm just going to put a random

02:14.800 --> 02:16.810
username that probably doesn't even exist.

02:16.910 --> 02:21.670
I just want to see if this request will be recorded and the log file.

02:22.000 --> 02:26.890
So I'm just as I'm going to SSA and I'm just going to put a username as random.

02:28.590 --> 02:34.680
And then I'm going to do add and we get to put the IP address, which is 10, 20, 14 to 10.

02:36.860 --> 02:37.550
I'm going to hit enter.

02:39.670 --> 02:44.350
Now it's asking me for a password, obviously, this username doesn't exist anyway, so I'm just going

02:44.350 --> 02:45.780
to put a random password as well.

02:47.410 --> 02:52.680
I am not really trying to use an SS age, I'm literally just attempting to log in.

02:52.690 --> 02:56.760
I'm going to control see now and I want to see if this will be logged in this file.

02:57.040 --> 02:58.900
So I'm going to send another request.

03:00.310 --> 03:05.650
And I'm going to look for my username, so the username was called random and I'll see if that was logged.

03:08.470 --> 03:14.170
And you can see here, it's telling us and the log file, so it was recorded in the server that someone

03:14.170 --> 03:18.660
tried to log in with the username random and it actually has my IP address.

03:18.670 --> 03:20.970
So it's actually recorded my IP address as well.

03:22.360 --> 03:29.950
So now we can read that file and we can also write to the file by logging in with a nonexisting account.

03:31.120 --> 03:34.150
So what I'm going to do now is I'm actually going to try to log in again.

03:34.300 --> 03:39.070
And instead of put in a username, instead of pulling the username as random, I'm actually going to

03:39.070 --> 03:45.930
put the code that we always used to give me a reverse shell or reverse connection on the server.

03:46.060 --> 03:48.490
Now, again, you can use any code you want.

03:48.610 --> 03:54.010
In my example, I'm going to use code that will give me a reverse shell on the target computer.

03:54.520 --> 03:58.810
So before I run the code, I'm going to listen on the part and I'm going to do that using that card

03:58.810 --> 03:59.770
like we always did.

03:59.800 --> 04:01.090
So it's going to be Ngarkat.

04:03.050 --> 04:04.370
Evy l.P.

04:05.680 --> 04:08.650
And I'm going to put my my part, which is eight eight eight eight.

04:11.250 --> 04:13.380
And now we're listening for a connexions.

04:14.800 --> 04:21.070
And I'm going to try to log in again to the target, and in this case, I'm actually going to put my

04:21.440 --> 04:21.910
vehicle.

04:22.240 --> 04:24.610
So same code that we used before.

04:25.830 --> 04:31.070
So my username is going to be I'm going to put two quotes and then I'm going to put my code.

04:32.740 --> 04:34.000
So we're using passthrough.

04:36.200 --> 04:42.710
And then we're going to pass the command, the command that we want to run, and that command is going

04:42.710 --> 04:47.750
to be I'm going to use single quotes here and then my command is going to be Netcare.

04:48.860 --> 04:49.210
E!

04:50.780 --> 04:51.710
Ben S.H..

04:53.260 --> 05:00.910
Then I'm going to put my IP address, which is 10 2014 to 08, then I'm going to put the person I'm

05:00.910 --> 05:03.850
listening on, which is eight eight eight eight.

05:05.080 --> 05:05.470
Now.

05:06.470 --> 05:12.380
With this method, you're only going to get one shot with this code because if you put the code incorrectly,

05:12.680 --> 05:17.750
the whole thing is going to break and the file is not going to be displayed anymore because you have

05:17.750 --> 05:18.870
an error in your code.

05:19.340 --> 05:24.530
So what I suggest is I'm going to keep the pass through as it is, because that's a safe function and

05:24.530 --> 05:26.470
I'm sure that this is going to run correctly.

05:26.870 --> 05:30.590
I just need I forgot to put a semicolon here, so I'm going to put that there.

05:31.010 --> 05:33.200
So I'm sure that this code is going to run correctly.

05:33.200 --> 05:35.860
But I have a lot of minuses in here.

05:36.050 --> 05:41.210
I have a lot of spaces and I have a lot of forward slashes which always have problems.

05:41.390 --> 05:47.180
When you're trying to pass them between the next commands, you can try to skip through these characters.

05:47.480 --> 05:54.440
But what I suggest is you actually encrypt this using base64 and then decrypted at the other end.

05:55.310 --> 05:56.480
So I'll show you how to do that.

05:56.510 --> 05:58.310
First off, I'm going to copy this command.

05:58.850 --> 06:05.330
So this is the digital command that we want to pass through function to run and copied it.

06:05.570 --> 06:07.190
I'm going to go to my website.

06:10.100 --> 06:12.340
And I'm going to go to my decoder here.

06:12.410 --> 06:18.680
We never had to look on the decoder, so this allows you to encode and decode text to different types

06:18.680 --> 06:19.420
of encoding.

06:20.030 --> 06:21.560
So I'm going to paste what I copied.

06:22.700 --> 06:26.090
And I'm going to encode it as base64.

06:27.340 --> 06:36.100
So this text, the net Katherine as hedge, my IP port is converted to this encrypted code, I'm going

06:36.100 --> 06:36.970
to copy this code.

06:38.410 --> 06:44.800
And I'm going to substitute it here into my command, so instead of running it like this, instead of

06:44.800 --> 06:50.290
pulling the text, I'm going to put the base64 code to make sure that there is no special characters

06:50.470 --> 06:53.320
that would interfere with the command, with the bush.

06:55.560 --> 07:03.030
So I have that copied now if I run this this way, so I have my passthrough, which is a function and

07:03.030 --> 07:05.440
I'm telling it to execute this shall command.

07:05.700 --> 07:10.770
Now, obviously, if you copy this text and run it, it's not going to run anything because it's just

07:10.770 --> 07:11.270
gibberish.

07:11.790 --> 07:19.770
So I need to tell it that this is basically 64 code and I'm going to do that using the HP function called

07:19.770 --> 07:21.120
Base64 Decoded.

07:21.270 --> 07:28.410
So I'm going to tell it to decode this this piece of text and then once you decoded, run the pass through

07:28.410 --> 07:28.830
on it.

07:30.150 --> 07:32.910
So I'm just going to type it in here, so it's going to be.

07:34.830 --> 07:36.000
Base64.

07:39.080 --> 07:42.800
Decode, and that's just another function, uh, function.

07:44.380 --> 07:46.120
And then I'm going to put the brackets.

07:49.980 --> 07:54.000
So I'm just going to make this a little bit bigger so we can talk about it more.

07:54.150 --> 08:00.090
And I'm just actually going to copy and run it again just so that we will talk about it a little bit

08:00.090 --> 08:00.320
more.

08:01.780 --> 08:09.190
OK, so first off, we're actually using the username as our code, as the code that we want to inject

08:09.190 --> 08:13.950
because because as we see the user name is being displayed on the log page.

08:13.960 --> 08:17.850
So anything we put in the user name will be executed as BHP code.

08:18.520 --> 08:23.530
So we have that between two quotes here between this and this quote.

08:24.430 --> 08:31.660
Now we have our record that we always use and we also always used the Pass-through function to run Unix

08:31.660 --> 08:33.430
commands on the target server.

08:33.850 --> 08:39.400
So we're keeping that the exact same and we're telling it to run this text.

08:39.610 --> 08:44.470
But before you run this text, I want you to decode it based on base64.

08:45.550 --> 08:50.480
So we have passed through the code, the following code, and this is the code.

08:50.500 --> 08:54.310
So this is the command net cut command that we always use.

08:54.460 --> 09:00.250
We're decoding it based on base64 and then we're telling it to run it using the passthrough function

09:00.400 --> 09:03.070
to execute it as a Basche command.

09:03.910 --> 09:05.170
So I'm going to hit enter now.

09:06.350 --> 09:10.670
And that's asked ask me for a password because it thinks that this is actually a username, so we're

09:10.670 --> 09:12.590
injecting the whole thing as a username.

09:12.920 --> 09:16.160
So I'm just going to put any password, anything random had enter.

09:16.410 --> 09:19.840
Now, this should be stored now and the logs.

09:20.090 --> 09:24.340
So this code should have been injected into the Alstott log.

09:25.520 --> 09:28.130
So we're going to go back now to our browser.

09:29.580 --> 09:34.260
And you can see that I'm already listening here, so I'm just going to hit enter here on the browser

09:35.640 --> 09:40.140
and as you can see, we got a connection back from our Target website.

09:40.350 --> 09:48.210
And if we do it, you'll see that arm into the target website with the data username or user group.

09:48.480 --> 09:53.880
And I can run commands or do whatever I want on the target server.

09:57.080 --> 10:04.190
This is just another method of exploiting local file inclusion vulnerabilities to get a show on the

10:04.190 --> 10:05.090
target computer.

10:05.450 --> 10:12.170
Now, again, this is just an idea and you can try these ideas with different types of log files so

10:12.170 --> 10:13.880
you can try it with the dot log.

10:14.000 --> 10:16.550
You can try it with any other type of log files.

10:16.550 --> 10:17.730
But you need to think about it.

10:17.870 --> 10:21.350
You need to think how you could inject code into that log file.

10:21.380 --> 10:26.660
So, for example, as I said, if it's a male servers and then try to send us an email, if it's the

10:26.900 --> 10:32.810
dot log like we have in this current example, then try to log in using S.H. and see if you can inject

10:32.810 --> 10:36.440
code and if that code will be executed on the target computer.
