WEBVTT

00:01.420 --> 00:08.290
In this lecture, we're going to have a look on CSR or cross site request forgery, these vulnerabilities

00:08.290 --> 00:12.280
allow us to force a user to do things that they don't want to do.

00:12.670 --> 00:14.540
For example, once you log into a website.

00:14.560 --> 00:15.520
Let's take Facebook.

00:15.700 --> 00:20.740
You'll be able to do certain things to your profile so you can upload pictures, you can change your

00:20.740 --> 00:25.280
password, you can change your information, send messages and post stuff to your wall.

00:26.140 --> 00:33.130
Now, CSR advocates want the website doesn't validate if the user actually wants to do the certain tasks.

00:33.130 --> 00:39.070
So it doesn't check if the user actually intends to change their profile picture or to change their

00:39.070 --> 00:39.600
password.

00:39.970 --> 00:46.150
So if the website doesn't do that, will be able to programmer HTML page and if the user clicks it or

00:46.150 --> 00:51.090
runs it, they'll be forced to carry out a certain task that we program it to do.

00:51.100 --> 00:55.570
For example, we can get users to change their passwords without them even knowing.

00:56.590 --> 01:00.820
Let's have an example on how this happens and it will become more clear to you.

01:01.600 --> 01:07.360
So I have my divi here and I'm just going to log in with my username and password, which is admin.

01:08.710 --> 01:10.510
And I'm going to put my password.

01:14.250 --> 01:22.100
Now, if we go to the Sierra, stop here, you'll see that allows us to change our our password.

01:22.120 --> 01:25.760
So this is just like a normal control panel to a normal website.

01:25.860 --> 01:30.330
And usually when you log into your account, one of the features that you can do is you can change your

01:30.330 --> 01:31.620
password to a different password.

01:31.920 --> 01:35.940
So from here, I'm going to set my password to two, two, two, two to two.

01:36.570 --> 01:40.610
And also in here as well, the same password I'm going to hit enter.

01:41.070 --> 01:44.130
And as you can see, it's telling us that the password has been changed.

01:45.270 --> 01:49.830
So this is an example of a feature that the user can do to their account.

01:49.840 --> 01:50.910
They can change their password.

01:51.630 --> 01:54.960
If the target website, which is divided, doesn't check.

01:54.960 --> 02:01.080
If the user actually wants to do this task, then we can create a page that is similar to this page.

02:01.380 --> 02:06.880
And once the user runs that page, they'll actually change their password without them even knowing.

02:07.800 --> 02:12.420
Now, there's a number of ways to analyze the connection and analyze the information sent between the

02:12.420 --> 02:15.990
client and the target to make that SRF exploit.

02:16.350 --> 02:18.960
I'm going to show you the easiest and most reliable way.

02:18.990 --> 02:22.440
And it works regardless of the type of form, whether it's post or get.

02:23.220 --> 02:27.930
So with this particular one, it's actually really easy to exploit if you just send your URL right here

02:27.930 --> 02:31.250
to the target user and then if they run it, their passwords will be changed.

02:31.590 --> 02:35.900
But in more complicated ways, sometimes you don't see that sometimes post is used.

02:36.120 --> 02:39.700
So I'll show you the most reliable way to do this kind of attack.

02:40.260 --> 02:41.820
So the first thing to do is right.

02:41.820 --> 02:43.650
Click the form that you want to hijack.

02:44.460 --> 02:46.110
You were going to inspect the element.

02:47.990 --> 02:54.560
And we're going to look to at where the farm is, we're going to look at where is the start of the form

02:54.560 --> 02:56.510
tag and the end of the form tag.

02:58.260 --> 03:00.740
I'm actually going to right click it in here inside the forum.

03:03.330 --> 03:10.440
And as you can see now, we have the start of the forum is in here and it ends with a slash forum,

03:10.440 --> 03:14.110
forward slash forum, and you can see it right here at the end.

03:14.850 --> 03:17.870
So this is the part of the code that we're interested into.

03:17.880 --> 03:25.140
This is the part of the code that we want to modify and send to the target users so that when they run

03:25.140 --> 03:28.110
it, they'll actually change their password without them knowing.

03:29.250 --> 03:35.730
So I'm going to right click this and I'm going to edit as HTML and I'm going to copy everything inside

03:35.730 --> 03:38.850
here, so I'm going to do control a control see.

03:40.080 --> 03:41.430
And that's cockpit's for me.

03:43.770 --> 03:48.270
And then I'm going to go to my left side right here and I'm going to pasted.

03:49.930 --> 03:53.620
And I'm going to save this and we'll call it six hour aftertaste Tmall.

03:59.450 --> 04:08.240
And I'll put this in the desktop and click on Save, and that's it, save now if we let's just run this

04:08.240 --> 04:10.520
code at the start and see what we get.

04:10.850 --> 04:12.890
So I have it right here on my desktop.

04:14.270 --> 04:15.580
And I'm just going to double click it.

04:17.290 --> 04:22.120
And as you can see, you just get a page, a normal page that asks you for a new password and to confirm

04:22.120 --> 04:27.520
the password so you can see the form here is actually similar to the form that we want to hijack.

04:29.580 --> 04:35.130
Now, to get that to work, we need to modify a few things now you can see here we have a forum right

04:35.130 --> 04:39.120
here and the action is set to a hashtag.

04:39.120 --> 04:43.090
So it actually doesn't give a website to submit this form to.

04:43.560 --> 04:48.090
So the first thing you want to modify is you want to give it to the website to submit this form to.

04:48.390 --> 04:51.540
And this is going to be the same website that we're on at the moment.

04:51.570 --> 04:53.160
So I'm going to control copy this.

04:54.690 --> 04:57.450
And I'm going to put it in here instead of the hashtag.

04:59.780 --> 05:04.610
Now, sometimes you'll actually, if you are copying a form from a different website, you might actually

05:04.610 --> 05:06.230
see a name of a file.

05:06.240 --> 05:07.690
So you'll just see a file name.

05:07.940 --> 05:13.820
You want to make sure you have the full your URL to the to the form, because if you just have a file

05:13.820 --> 05:19.070
name, for example, if you just have indexed that BHP, it won't know where that index is.

05:19.250 --> 05:23.140
It now it when it's on the website because it's already started on that website.

05:23.420 --> 05:27.370
But one, we're actually taking the file like this and storing it on our local machine.

05:27.620 --> 05:30.400
You want to make sure you have the full URL in here.

05:30.410 --> 05:35.330
So even if you sign something instead of the hash tag, if you see something like indexed at BHP or

05:35.330 --> 05:41.240
whatever, keep that in there, but make sure you give it the fully URL that comes before that page.

05:43.330 --> 05:49.750
So this is all good now if I save this and if we run, this will actually be able to change the password

05:49.750 --> 05:50.620
using this form.

05:51.550 --> 05:56.530
Now, the beautiful thing about these exploits, you can actually confirm that it works for you first

05:56.530 --> 06:00.310
and then you can send it to the target client or to the target person.

06:01.530 --> 06:05.700
So if we actually reset our password here, so I'm going to set the password two, three, three, three.

06:06.950 --> 06:07.790
Three, three, three.

06:09.650 --> 06:10.970
And confirm it in here.

06:13.350 --> 06:15.360
And then I'm going to do hit enter.

06:16.850 --> 06:21.590
You'll see that we get a message telling us that the password has been changed and we can actually now

06:21.590 --> 06:23.570
log out and log in with the new password.

06:24.170 --> 06:24.970
So this is good.

06:24.980 --> 06:30.710
Now we have a form that's actually not stored on the website, but using it, we can actually go to

06:30.710 --> 06:32.560
that website and change the password.

06:32.870 --> 06:40.010
So this actually confirms that the target website is vulnerable to R.F. because it's not validating

06:40.010 --> 06:42.590
that the request is coming from the website itself.

06:42.800 --> 06:46.130
So it's not validating if the user actually wants to do that.
