WEBVTT

00:01.000 --> 00:03.960
Okay, now our program is completed.

00:05.000 --> 00:15.440
Okay, but for learning Python, for understanding the Python better, I can use another way or another

00:15.440 --> 00:18.240
thing to create this part.

00:18.280 --> 00:19.080
Okay.

00:19.120 --> 00:19.760
Improve this.

00:19.760 --> 00:25.520
For example right here we're just using lists but I can use dictionary okay.

00:25.560 --> 00:30.320
So it is just for better understanding of dictionaries.

00:30.920 --> 00:38.320
So let's remove this part okay I will just remove it or I can comment this or I will remove it okay.

00:38.320 --> 00:39.000
So here.

00:41.120 --> 00:43.640
First we need to create an empty list.

00:43.640 --> 00:52.000
And then for each time that it is reading or getting a packet, we need to add that packet to the list.

00:52.000 --> 00:54.920
And it will create a dictionary for me.

00:54.920 --> 00:57.600
And later I can use dictionaries.

00:57.600 --> 01:05.160
Dictionaries has keys and values and I can use keys and values to print the result.

01:05.200 --> 01:05.560
Okay.

01:05.760 --> 01:06.520
Very easy.

01:08.840 --> 01:09.640
Let's do that.

01:09.680 --> 01:10.200
Okay.

01:10.240 --> 01:16.200
So here I am inside this function, which is called scan.

01:16.400 --> 01:18.680
I'm going to create a new list.

01:18.680 --> 01:23.320
Let's name it client underscore list.

01:23.360 --> 01:23.760
Okay.

01:27.560 --> 01:30.560
So it is going to be an empty list right now.

01:31.200 --> 01:31.600
Okay.

01:32.240 --> 01:34.880
Let's use for loop A for loop here.

01:34.920 --> 01:35.360
Okay.

01:35.920 --> 01:36.680
Element.

01:41.800 --> 01:44.880
Element in we had answered.

01:44.920 --> 01:45.320
Okay.

01:46.080 --> 01:46.640
In answer.

01:46.680 --> 01:51.240
Do you know that this answer variable is a list right now okay.

01:52.160 --> 01:55.080
So here I need to create two things.

01:55.120 --> 01:55.560
Okay.

01:56.320 --> 02:02.970
For at least one thing we are going to have the IP and also the Mac.

02:03.130 --> 02:05.290
So let's create a dictionary here.

02:05.610 --> 02:05.970
Okay.

02:06.330 --> 02:10.970
It's going to be client dictionary I'm going to name it client dict.

02:11.010 --> 02:14.330
It is equal to a dictionary.

02:14.370 --> 02:22.330
So this dictionary has a key with the key is going to be IP and it has a value.

02:22.490 --> 02:28.730
So the value is going to be for this one is going to be element okay.

02:33.090 --> 02:36.770
Dot the IP which is p.s.r.c.

02:36.810 --> 02:39.730
And also we have the Mac address.

02:39.770 --> 02:40.490
Okay.

02:40.530 --> 02:41.810
This is going to be the key.

02:41.850 --> 02:45.650
And the value for Mac address is going to be element.

02:48.090 --> 02:56.890
One dot h w is r c which is going to be hardware source for the Mac address.

02:57.250 --> 03:00.210
Okay now I have the client dictionary.

03:00.930 --> 03:08.810
And for each loop for each time that it is, uh, reading the packet.

03:08.850 --> 03:12.170
I need to add these to the list.

03:12.290 --> 03:13.930
So how can I do that?

03:14.610 --> 03:17.530
List has a function called append.

03:18.090 --> 03:19.050
So let's use that.

03:19.090 --> 03:19.290
Okay.

03:19.290 --> 03:21.050
We have clients list.

03:21.330 --> 03:24.050
Then let's use the function that it has.

03:24.050 --> 03:25.770
It calls append.

03:25.810 --> 03:34.730
This append will add okay this to the list for each of a loop for each time that it is getting a packet.

03:35.210 --> 03:43.490
So and then give the client dictionary okay for the first time it will come and read the element from

03:43.490 --> 03:44.850
the answer list.

03:44.890 --> 03:45.690
Okay.

03:45.730 --> 03:50.410
And then it will append that to the client list which is here okay.

03:50.450 --> 03:58.250
And then it come to read the second packet the third packet fourth packet and all the packet okay.

03:58.290 --> 04:01.370
So when it is finished you need to return that.

04:01.370 --> 04:03.650
So let's return it okay.

04:03.780 --> 04:07.100
Return client list.

04:07.420 --> 04:11.060
Okay, so now it is the first function that is doing its job.

04:11.460 --> 04:16.340
And you need to create another function to print the result.

04:16.580 --> 04:24.100
So let's create a function named print underscore result.

04:24.580 --> 04:25.020
Okay.

04:26.380 --> 04:32.220
So this is going to get uh something.

04:32.220 --> 04:37.540
Let's name it result list is going to be an argument okay.

04:37.860 --> 04:41.740
So here we need to print the IP mac address.

04:42.060 --> 04:44.380
And then going to the next line.

04:44.540 --> 04:54.460
And like that the thing that we have done it before okay we have IP okay at least three tab.

04:54.460 --> 04:58.580
And then what Mac address.

04:58.620 --> 05:02.300
Okay Mac address.

05:04.420 --> 05:10.180
And then go to a new line which is backslash n and something like this.

05:11.060 --> 05:11.500
Okay.

05:11.900 --> 05:13.780
Now it is the header okay.

05:13.820 --> 05:15.300
The header is completed.

05:15.460 --> 05:19.380
So now it is time to print the IP and the Mac address itself.

05:19.580 --> 05:21.780
So how can we do that.

05:21.780 --> 05:23.580
Again I'm going to use a for loop.

05:23.980 --> 05:28.180
Or I'm going to create a new variable called client.

05:28.460 --> 05:34.100
For client in we have the result list okay.

05:35.300 --> 05:37.740
And here I'm going to print that.

05:38.300 --> 05:42.340
So now this client is a dictionary.

05:43.020 --> 05:52.300
And here I'm going to print the IP for this and concatenate this with at least two tab.

05:55.300 --> 05:59.220
And again the Mac address.

05:59.580 --> 06:00.020
Okay.

06:04.940 --> 06:05.620
And.

06:07.380 --> 06:07.900
finished.

06:07.940 --> 06:10.340
Okay, so now it is time to.

06:13.220 --> 06:15.900
To call those functions.

06:15.940 --> 06:16.620
Okay.

06:16.660 --> 06:18.580
So here we have the scan function.

06:18.620 --> 06:19.540
Okay.

06:19.580 --> 06:23.940
And as you see we have the result list here.

06:24.180 --> 06:30.300
We need to, uh store this scan function into a variable.

06:30.340 --> 06:32.620
I'm going to name it scan result.

06:32.660 --> 06:33.500
Okay.

06:33.540 --> 06:34.940
So let's use scan.

06:34.940 --> 06:38.460
Underscore result is equal to this one.

06:38.820 --> 06:43.540
And then I am calling the print result function.

06:43.540 --> 06:48.500
And then giving it the scan result.

06:48.940 --> 06:52.500
And I think now it is completed.

06:52.580 --> 07:02.820
If I come back right here and re-execute this providing the password which is Collie and waiting a moment,

07:02.820 --> 07:08.590
you're seeing that we are having the same result this time with dictionary.

07:11.870 --> 07:16.190
I want to add a little some more of this dot.

07:16.590 --> 07:17.030
Okay.

07:18.870 --> 07:23.830
So it looks more beautiful now.

07:23.870 --> 07:25.710
I think it is better.

07:25.990 --> 07:31.950
So here you learn how to use one function using list.

07:31.950 --> 07:36.030
And also you learn how to use dictionaries okay.

07:36.070 --> 07:37.630
You create this program.

07:38.070 --> 07:41.710
And here we use two function to do this.

07:41.750 --> 07:43.230
So thanks for watching.

07:43.270 --> 07:46.070
And this section is completed.

07:46.150 --> 07:49.550
You created your network scanner and it is completed.

07:49.550 --> 07:51.110
It's working for all network.

07:51.150 --> 07:52.070
Okay.

07:52.110 --> 07:58.670
No matter if it is wired or wireless or Wi-Fi or anything, it is going to work for all networks.

07:58.870 --> 08:02.990
So for me it is a virtual network and wired.

08:03.030 --> 08:07.670
So thanks for watching and I will see you in the next section.
