WEBVTT

00:01.160 --> 00:07.670
Now, let's talk about how we can prevent access as vulnerabilities, the way these vulnerabilities

00:07.670 --> 00:15.380
happen is because whenever a user enters something into a text box or into a parameter, that input

00:15.500 --> 00:17.840
is displayed into the HTML.

00:17.840 --> 00:23.750
So it's treated as if it's part of the page and therefore, if there is JavaScript in it, the code

00:23.750 --> 00:24.860
is being executed.

00:25.880 --> 00:33.530
So to prevent this exploit, the best thing to do is to try and minimize the usage of untrusted input.

00:33.550 --> 00:39.590
So any time a user input something or anytime something's input from parameters, try to minimize that.

00:40.340 --> 00:47.540
Also, make sure that you always escape whatever that's going to be displayed or used into the HTML

00:47.540 --> 00:53.570
page, because exercise cannot only be injected into places where things are displayed on the page,

00:53.720 --> 00:59.720
but it can also be injected into parameters of certain elements of the actual page.

01:01.980 --> 01:08.400
So what I mean by escaping is converting each of these characters to what they would be represented

01:08.400 --> 01:14.220
by an HTML, you can do that using scripts and you can do that using your own script.

01:15.270 --> 01:16.860
Now, let me show you how this happens.

01:16.890 --> 01:21.780
Now, I'm here at my vulnerable Web page that we were using, and I'm going to go to the third one.

01:22.860 --> 01:28.440
And obviously, you can see that every time we click on that, the exercise rounds, so let's inspect

01:28.440 --> 01:29.250
this element now.

01:29.250 --> 01:32.190
This element is where we injected our alert.

01:32.820 --> 01:33.600
And if you right.

01:33.600 --> 01:42.810
Click and go on inspect element, it will show us the hasty HTML of this page or the HTML of this particular

01:42.810 --> 01:44.310
element right here highlighted.

01:46.150 --> 01:47.650
So I'm going to make this bigger.

01:49.350 --> 01:52.920
And if we look at it right here, you'll see that we have the name.

01:54.310 --> 01:55.210
And that Zaid.

01:56.390 --> 02:02.420
And then the other import, which is the message, it's a script and the script where the script does

02:02.420 --> 02:03.810
it does alert exercise.

02:03.810 --> 02:07.760
So it's exactly what we injected into it when we did the comment.

02:09.370 --> 02:14.150
So every time we were on this page, this piece of code gets executed.

02:14.650 --> 02:19.870
So we need to do is we need to make sure every time a user enters something and that something will

02:19.870 --> 02:24.850
be displayed on a page or that something will be used somewhere in the elements.

02:24.880 --> 02:31.970
So even the idea here or even the the idea is just, for example, is a perimeter of the div.

02:31.990 --> 02:32.800
It's not the state.

02:32.800 --> 02:34.060
You never see this idea.

02:34.330 --> 02:37.670
But this is this can be injectable can be injected as well.

02:38.050 --> 02:41.860
So hackers can actually try to inject stuff into the parameters.

02:42.070 --> 02:45.070
They can try to inject stuff into the image attributes.

02:45.070 --> 02:49.900
For example, they can do an image and inject stuff into the source or into the URL.

02:50.200 --> 02:51.820
So this is just an example here.

02:52.300 --> 02:56.820
And every time a user's input is going to be used anywhere on the page.

02:56.830 --> 03:02.140
So even if you don't see it, if you usually don't see it, you need to make sure that you keep that

03:02.140 --> 03:08.350
input and make sure that it does not contain any code and if it contains any code that it's converted

03:08.350 --> 03:09.970
to its equivalent.

03:10.180 --> 03:13.690
Once you escape this, you'll actually see this in the message.

03:13.700 --> 03:18.760
So you see the message as script alert exercise, but it will never be executed.

03:19.540 --> 03:24.100
This script will never actually be executed on the target person when they run it.

03:26.320 --> 03:32.140
And this is exactly what the high security level implements, so let me go through the security settings.

03:33.770 --> 03:35.870
And let me close this.

03:37.460 --> 03:39.140
And I'm going to set this to high.

03:41.450 --> 03:42.350
I'm going to submit it.

03:43.750 --> 03:49.680
And we'll go back to our reflected, the same measurements are taken in the reflected and in the.

03:50.650 --> 03:57.910
And now if we try to inject any of our codes that we were doing before, for example, if we try to

03:57.910 --> 04:05.380
inject this script, so script alert exercise and then we close the script, you'll see the script exactly

04:05.380 --> 04:07.840
the same way that you would have seen a normal name.

04:07.850 --> 04:12.340
So if we succeed here, you'll just see my name and if we inject our script.

04:13.250 --> 04:16.880
You'll see it appearing as if it's a normal name, it doesn't appear.

04:17.120 --> 04:22.880
You don't only see what's between the tags and then the code doesn't even get executed if we look at

04:22.880 --> 04:23.540
the source.

04:24.720 --> 04:29.520
You'll see that you see all the tags, so you can see the script tag, you can see the close of the

04:29.520 --> 04:32.900
script tag and everything is being injected properly.

04:32.910 --> 04:38.250
So you think that this should work, but it doesn't work because the website or the Web page or the

04:38.250 --> 04:45.360
browser knows that these tags are should be treated as HTML characters and should not be treated as

04:45.360 --> 04:46.320
part of the code.

04:46.950 --> 04:54.180
And this is all thanks to a function that's being used here, which is called the HTML special characters.

04:55.230 --> 05:01.500
So it's all thanks to the dysfunction, so whatever your input in and the name, it's being filtered

05:01.500 --> 05:02.470
through dysfunction.

05:02.730 --> 05:09.180
Now, this function will iterate over each character that you entered and it'll tell HTML or the browser

05:09.180 --> 05:12.530
it'll change it to its equivalent in HTML code.

05:12.810 --> 05:18.690
Therefore, the browser will know that this is not part of the code and this is part of what should

05:18.690 --> 05:20.960
be displayed onscreen as text.

05:21.540 --> 05:27.810
And this way, no matter what you try to inject, it will be converted to HTML code, which will just

05:27.810 --> 05:31.710
be displayed on screen like normal text or normal characters.

05:34.830 --> 05:42.060
Now, as a user, to prevent yourself from being used into an excess attack, now you are all coming

05:42.060 --> 05:45.450
to you will probably look like you are all of a trusted website.

05:45.460 --> 05:51.120
For example, let's assume that you work in a company and there it was, an exercise in your company

05:51.120 --> 05:54.980
and you are logging into your company and the code gets executed on you.

05:55.140 --> 05:58.880
Then there isn't much you can do yourself, but you need to be careful.

05:58.890 --> 06:03.930
So with beef, we sell in order to exploit the vulnerabilities we were showing, for example, a fake

06:03.930 --> 06:04.460
update.

06:04.770 --> 06:10.080
So make sure when you if you get if you get a message always that there is an update, make sure you

06:10.080 --> 06:13.990
actually go to the website that provides that application.

06:14.010 --> 06:19.770
So if Firefox said that there is an update, go to the to the website office face of Firefox and see

06:19.770 --> 06:25.650
if there is actually an update and if there is downloaded from that website, don't download it from

06:25.650 --> 06:27.120
the notification that you got.

06:27.630 --> 06:34.350
Also, make sure you're downloading it from a website and once you download it, you can inspect it

06:34.350 --> 06:39.930
and check it the same way that we've seen before to make sure that there is no back doors or anything

06:39.930 --> 06:40.290
in it.

06:41.130 --> 06:46.890
I can also check the MDVIP some to make sure that the file hasn't been manipulated while it was being

06:46.890 --> 06:47.520
downloaded.

06:48.180 --> 06:52.310
The same one we did the fake Facebook login when you were with beef.

06:52.530 --> 06:59.310
So what you can do is whenever you are told that you got logged out and please log back in again, ignore

06:59.310 --> 07:04.980
that, go to Facebook dot com, make sure it's going through tips and then log in to Facebook.

07:07.430 --> 07:13.700
So I always try to be careful with notifications popping up, telling you you need to do stuff, always

07:13.700 --> 07:15.190
be wary and never trust them.
