WEBVTT

00:01.950 --> 00:03.150
Good afternoon.

00:03.310 --> 00:04.990
Thank you for coming to the talk.

00:05.790 --> 00:12.150
And yeah, it's the 33rd edition of WebCon, and it's better than ever.

00:13.090 --> 00:18.750
So, the talk, as you can see, is based on the title of the talk, as you can read, right?

00:18.750 --> 00:20.530
No radios, no problems.

00:25.270 --> 00:30.530
The title of the talk, as you can see, is No radios, no problems, Hacking Wi-Fi in the virtual world.

00:30.530 --> 00:41.750
So, what we are going to do in this is, we are going to talk about the first principles, the basics that you can use to emulate Wi-Fi in a VM, in a cloud, anywhere.

00:42.030 --> 00:49.030
And we will also discuss why it is important, what are the other easy ways of doing it.

00:49.270 --> 00:58.690
But the idea is, there are so many tools out there that you can use, but they don't really give you the full understanding of the basics that you are using.

00:58.690 --> 01:05.450
And some of these basics are also related to containers, you know, Docker containers, Podman, all the other things, right?

01:05.470 --> 01:10.030
So, we'll talk about them, and yeah, I'm looking forward to this.

01:11.230 --> 01:16.690
A little bit of introduction, my name is Nishant, I've been doing Wi-Fi for 10 years now.

01:16.970 --> 01:25.350
I was in cyber security education for almost all of my career, currently serving as the Head of Research at Square Enix.

01:25.350 --> 01:29.710
So yeah, this is my second time at RF Village.

01:30.370 --> 01:35.590
I have also taught Wi-Fi hacking classes at Black Hat for 2-3 years.

01:35.770 --> 01:37.370
So yeah, that's all.

01:38.370 --> 01:42.050
So first question is, why exactly do we want to do this?

01:42.310 --> 01:59.370
The simple answer is, you can buy one device, you can buy it for 2.4 GHz, you can buy it for 5 GHz, but then when things get more complicated, there is a limit to how many devices you will be able to buy, how many devices you will be able to set up, how many devices you will be able to play with,

01:59.370 --> 02:00.110
right?

02:00.290 --> 02:11.210
And if you want to simulate complicated scenarios, for example, you want to simulate 100 devices, 10 access points, they are connecting, disconnecting, they are moving farther, backward, right?

02:11.210 --> 02:14.590
And then you also want to do Wi-Fi security on it.

02:14.590 --> 02:22.090
When we talk about it, Wi-Fi security is your monitoring, after that you analyze it, and then you also attack the older schemes.

02:22.090 --> 02:28.130
We know that WPA3 is practically unhackable, if you want to put it that way, right?

02:28.130 --> 02:36.970
If you are not talking about social engineering and all the other kind of deceiving attacks, if you are talking about technical attacks, WPA3, they have kind of locked everything down.

02:36.970 --> 02:43.770
However, if you talk about WPA for some reason, WPA2 enterprise, you have your MSCHAP, V2 and all of that, right?

02:43.770 --> 02:49.230
That still you can hack, and a lot of places, that is what you are going to find as well till today, right?

02:49.230 --> 02:50.070
Even today.

02:50.370 --> 02:54.690
So if you want to practice that, these setups give you more flexibility.

02:55.390 --> 03:02.010
And the reason we had built this is because at one point of time, we were building Wi-Fi labs in the cloud.

03:02.010 --> 03:04.490
We did that, all of that worked great.

03:04.570 --> 03:06.470
So same things we are going to discuss.

03:06.470 --> 03:10.690
It's scalable, it is easy to set up, you can set up it in the cloud, in the VM.

03:10.690 --> 03:15.030
If you make a mistake, you just take it down, run it again, good as new, right?

03:15.050 --> 03:19.690
And for the new people who are trying to learn Wi-Fi security, it is very, very, very helpful.

03:19.690 --> 03:25.150
Because you don't have to deal with all the uncertainty that comes with real packet capture, right?

03:25.150 --> 03:33.330
You are not able to find the packet, and I'll say 50-60% of the mistakes that are there when you are capturing it.

03:33.330 --> 03:36.710
So again, this doesn't really mean that you can get away with that part.

03:36.710 --> 03:41.350
If you are doing it in real world, obviously you have to learn how to catch the packet correctly.

03:41.430 --> 03:47.710
And that's the combination of your tools, bands, and the hardware.

03:47.710 --> 04:01.930
If it is an 11 AC that you are trying to flip, you have to make sure that your device is also 11 AC, and you are also supporting the bands and the MIMO and all the other things, right?

04:01.930 --> 04:05.770
You have the throughput requirements of the same, and all of that.

04:05.770 --> 04:08.990
So 60-70% work is there, and it still needs to be done.

04:08.990 --> 04:14.470
However, if you just want to skip that part, you are like, OK, I get it, it is complicated, I can do it.

04:14.470 --> 04:23.230
But right now I just want to talk how to analyze it, how to create my own scenarios, how to attack these things, in a VM, that's what we are going to talk about.

04:24.270 --> 04:29.370
So, this is pretty much what you need in terms of basic principles.

04:29.370 --> 04:45.570
This will create your first setup, and then on this setup, just like you use your Kali attacker tools here, you use your air mons, air dumps, and then all the other, WPS, Wi-Fi, all of that can run on top of this.

04:45.570 --> 04:57.090
Because all of these tools, they assume that you have a Linux machine, you have a Wi-Fi adapter, which is in monitor mode, and then you are doing things on the basis of that.

04:57.090 --> 05:07.750
So, we are talking about this lower stack, how to emulate it, because once you have it, it's on a Linux machine, you can pretty much install anything and everything that is there on a Kali box.

05:08.230 --> 05:09.830
So, what all is this?

05:09.830 --> 05:12.910
First thing, obviously, Linux required.

05:12.950 --> 05:20.830
The main secret of this recipe, again, it's not really a secret, this thing is there for multiple years now.

05:20.830 --> 05:25.870
So, I'm talking about 80211-SWC.

05:25.870 --> 05:29.170
This is the hardware simulation for the Wi-Fi module.

05:29.250 --> 05:31.230
It is there in the Linux kernel.

05:31.330 --> 05:38.330
It doesn't come as a package, but you can pretty much use two to three commands and get it on your machine.

05:38.610 --> 05:46.290
It is there for multiple years now, but most people don't know about it, most people are using it when they are using some other tools, and we'll talk about them as well.

05:46.290 --> 05:52.770
But behind the scenes, on Linux machine, if you are emulating Wi-Fi, this is what is going to be used.

05:52.770 --> 05:58.630
Because this thing gives you the exact packet capture as you'll get in the real world.

05:58.790 --> 06:08.530
If you do a raw packet capture on it, if you do a monitor mode capture on it, it is the same beacon frame, it is the same probe request, it is the same probe response that you're going to see in the real world.

06:08.610 --> 06:09.590
So, that's there.

06:09.970 --> 06:12.310
Then comes namespaces.

06:12.310 --> 06:17.490
So, Linux namespaces is a concept that we'll talk about, why it is needed in our setup, we'll talk about that.

06:17.490 --> 06:21.250
After that, hosted PD, I'm very sure most of you are already aware of it.

06:21.250 --> 06:25.170
It is the most used, I'll say, access point creator.

06:25.170 --> 06:26.710
That's the easy term for it.

06:26.710 --> 06:45.970
If you have a Linux machine, if you have an IoT device which is running Linux, like most of your access point devices, your open word and all of that, on that, if you want to create an SSID, that's the Wi-Fi network, wireless network, this is what you use.

06:45.970 --> 06:49.450
It is battle-tested, it is around for more than 15 years.

06:49.450 --> 06:55.190
Most of your enterprise-grade machines, APs, they actually use this thing.

06:55.190 --> 06:58.030
And you can pretty much use it in like two commands.

06:58.030 --> 07:00.650
We'll use that to create our access point.

07:00.890 --> 07:03.370
Then wps-applicant is the another part.

07:03.370 --> 07:05.470
It comes installed in your Linux.

07:05.470 --> 07:13.130
This is the thing that makes your Wi-Fi card to connect to your SSID if it is protected.

07:13.130 --> 07:22.670
So when you are connecting to a WEP, WPA2-PSP, WPA-EEP, this is the thing which is making that handshake, and you can see all of that in the logs as well.

07:22.670 --> 07:26.510
So we will be using this to create or emulate the client.

07:26.510 --> 07:35.630
So we'll do this for one thing, and the same logic with some shell scripting, Python, you can actually then replicate it, you can create a big scenario.

07:35.630 --> 07:43.970
So in one PC, in one virtual machine, you can have like hundreds of these devices connecting to each other, roaming.

07:44.070 --> 07:52.970
And if somebody just takes a look at the packet capture, barring the signal strength, that's the part that another tool will take care of.

07:53.050 --> 07:55.890
It will look like it's a high-density Wi-Fi environment.

07:55.890 --> 07:58.530
You are seeing all of this traffic, it behaves just like Wi-Fi.

07:58.530 --> 08:03.590
You will have channels, and you will have to hop the channel here to all of this.

08:03.830 --> 08:07.490
So till here, you are covering layer 2.

08:07.490 --> 08:12.730
So your layer 1 is obviously physical, second is the MAC layer, that's where your Wi-Fi actually operates.

08:12.870 --> 08:15.150
Then comes the IP layer connectivity.

08:15.150 --> 08:18.350
Because if you really want to emulate it, this part is simple.

08:18.390 --> 08:21.830
The main complexity comes after this, because you have one machine.

08:21.830 --> 08:26.510
On that one machine, obviously, you can create two of these interfaces.

08:26.970 --> 08:32.250
And you can make one of them as access point, another one is a client, you connect them up.

08:32.250 --> 08:36.950
After that, you need to give them IP addresses if you really want to simulate traffic.

08:37.210 --> 08:39.870
And that is where the namespaces and all other things will come.

08:39.870 --> 08:42.870
So yeah, dnsmasq is going to be our DHCP server.

08:43.050 --> 08:48.070
And then dhclient is going to be the client which you will use to request for an IP.

08:48.070 --> 08:57.750
And once you have layer 3 connectivity, after that, you can pretty much run any server, any appliance, and simulate all the traffic that you want to do.

08:57.750 --> 09:05.210
Once layer 3 connectivity is there, after that, the only thing that remains is to install stuff and then use it using some scripting.

09:05.370 --> 09:07.230
So this is the whole stack.

09:07.230 --> 09:08.950
That is how it looks like.

09:09.390 --> 09:10.830
So what do you need?

09:10.830 --> 09:13.330
You need a Ubuntu desktop.

09:13.330 --> 09:16.610
I have used 24.04 just to keep it fresh.

09:16.610 --> 09:22.550
Once you have this machine, and you can either install it from Ubuntu's website.

09:22.550 --> 09:24.790
You can take an ISO or VM from there.

09:24.950 --> 09:28.290
Or if you want to save some time, you can go to osboxes.org.

09:28.290 --> 09:29.210
It's a free site.

09:29.210 --> 09:31.090
I'm very sure most of you have used it.

09:31.090 --> 09:34.670
You can directly download a ready-to-use VM from it.

09:34.810 --> 09:35.910
And you download it.

09:35.910 --> 09:37.330
It is ready to use.

09:39.250 --> 09:43.690
And obviously when you run it, I'll obviously not go through the setting up part.

09:43.690 --> 09:46.130
I'm very sure that most of you already know it.

09:46.930 --> 09:48.410
VirtualBox you can use.

09:48.490 --> 09:50.550
VMware player you can use for it.

09:50.550 --> 09:53.930
You're running it on a Linux machine, Windows machine, doesn't really matter.

09:53.930 --> 09:55.430
It's a guest VM.

09:55.590 --> 10:00.770
Once it is up, if you go inside, you'll see that obviously there is no Wi-Fi.

10:01.150 --> 10:03.930
Because again, we have not plugged any adapter to it.

10:03.930 --> 10:05.750
We have not started our work yet.

10:05.750 --> 10:15.390
So once you're here, after that we are going to use this Mac 802.11 hardware simulation.

10:15.510 --> 10:22.910
So what it allows you to do is, it will allow you to create these fake radio adapters.

10:22.910 --> 10:28.030
On which then you can make them act like any way you want.

10:28.250 --> 10:29.610
So there is no limitation.

10:29.610 --> 10:32.770
It will replicate what your real device does.

10:32.770 --> 10:34.190
It will behave in the same way.

10:36.290 --> 10:38.270
So these are the commands.

10:38.270 --> 10:40.810
First command obviously is to check the kernel version.

10:41.070 --> 10:44.430
And second command is to install the build essential.

10:44.430 --> 10:45.590
That will be required.

10:45.590 --> 10:49.090
As I mentioned, it does not come with the default kernel.

10:49.110 --> 10:51.890
You have to download some extra Linux modules.

10:51.950 --> 10:56.750
And then you have to inject this to create these fake Wi-Fi adapters.

10:56.750 --> 10:58.590
And that is what we are doing here.

10:58.710 --> 11:01.270
If you take a look at this third line.

11:01.270 --> 11:03.810
So in the second line we are installing build essentials.

11:03.810 --> 11:08.170
We are also downloading and installing Linux modules.

11:08.170 --> 11:09.450
The extra ones.

11:09.450 --> 11:10.190
It's a package.

11:10.190 --> 11:10.810
You download it.

11:10.810 --> 11:12.390
A lot of other things come in.

11:12.550 --> 11:15.650
Once it is done, you have to use the third command.

11:15.650 --> 11:16.690
That is modprobe.

11:16.690 --> 11:18.410
So modprobe is a generic command.

11:18.410 --> 11:19.570
It's not specific to this.

11:19.570 --> 11:22.850
You use it to inject kernel modules on runtime.

11:22.910 --> 11:24.590
So that is what we are doing here.

11:24.650 --> 11:32.630
So when I say kernel modules, these are the packages which are going to enhance or increase your functionality of your kernel.

11:32.630 --> 11:38.330
And the reason it is not shipped with the default kernel is because you don't really want to make it bulky.

11:38.330 --> 11:41.810
There are like hundreds of these things which are specific to some purpose.

11:41.810 --> 11:43.650
You don't want to make it heavy.

11:43.950 --> 11:48.870
But at the same time, you want the people who really want to use them to have an option to use it.

11:48.870 --> 11:50.090
And that's what it is.

11:50.090 --> 11:51.630
So you can use modprobe.

11:51.630 --> 11:53.590
You can give the name of the module.

11:53.650 --> 11:56.390
And then, as you can see, there is an argument.

11:56.550 --> 11:58.210
Radio is equal to 3.

11:58.210 --> 12:02.850
It means we are asking it to create 3 virtual radios.

12:02.890 --> 12:04.650
And that is what it will do.

12:04.650 --> 12:10.430
So once you do this, on the Ubuntu machine, you are going to see 3 of these interfaces.

12:10.610 --> 12:13.330
wlan0, wlan1, and wlan2.

12:13.330 --> 12:16.430
And you can verify that using this ip link show command.

12:16.430 --> 12:18.910
This is how it will look.

12:19.390 --> 12:26.110
So it is that easy till this point to actually get 3 virtual Wi-Fi interfaces.

12:26.110 --> 12:31.010
These interfaces are going to behave just like your real adapter will behave.

12:31.450 --> 12:32.930
Minus all the limitations.

12:32.930 --> 12:36.330
You don't have to worry about if it is a 2.4GHz, 5GHz.

12:36.330 --> 12:39.470
Does it support 80MHz or 160MHz or not.

12:39.470 --> 12:41.270
You don't have to worry about it.

12:41.270 --> 12:42.730
They support everything.

12:43.290 --> 12:46.410
And they will capture all the traffic perfectly.

12:46.410 --> 12:48.070
Because again, it's software layer.

12:48.070 --> 12:49.130
There is nothing.

12:49.130 --> 12:51.890
There is no unknown in this.

12:51.890 --> 12:57.850
And that's why this makes a very good bed for lab and practice.

12:57.870 --> 13:02.870
And the same is also being used by people to simulate high-density environments.

13:02.870 --> 13:04.770
To run simulations there.

13:05.770 --> 13:08.750
So here, the thing that we have highlighted.

13:09.750 --> 13:14.330
swsim0 is the device that will tell you that yes, it is working.

13:14.690 --> 13:18.810
Then wlan2, wlan1, wlan3 are the virtual ones.

13:18.810 --> 13:20.130
And there is no limit.

13:20.230 --> 13:23.830
You can actually put 16, 17, 20, 25.

13:23.890 --> 13:26.190
And you will see all of these devices here.

13:26.670 --> 13:28.390
So once this part is done.

13:28.710 --> 13:33.710
If you do iwdev, just like you do when you connect any kind of adapter to your Linux machine.

13:33.750 --> 13:35.130
You see all of these, right?

13:35.130 --> 13:36.210
Same thing.

13:37.530 --> 13:40.190
And now if you go back to your UI.

13:40.410 --> 13:43.750
Suddenly there are 3 WiFi adapters with you.

13:43.750 --> 13:46.730
Which you can use to connect or to do something else.

13:46.730 --> 13:50.790
This UI part obviously is just to show you that it is system-wide.

13:50.790 --> 13:53.210
It's not happening just on the command line.

13:53.230 --> 13:54.750
But it will happen here.

13:54.750 --> 13:59.090
If you try to interact with it, it will work just like a real device.

13:59.610 --> 14:01.130
And even if you take a capture.

14:01.130 --> 14:03.970
You will see the exact same thing that you see on the real devices.

14:03.970 --> 14:07.350
Apart from the fact that it is not from the outer world.

14:07.350 --> 14:08.690
It is from the inner world.

14:09.710 --> 14:11.450
So now what you want to do.

14:11.450 --> 14:12.830
And what we are doing here.

14:12.830 --> 14:14.250
For this example.

14:14.450 --> 14:15.970
So you are seeing 3 of these.

14:15.970 --> 14:16.910
Now what we will do.

14:16.910 --> 14:18.210
We will take one of these.

14:18.210 --> 14:21.170
And we will make it play as client.

14:21.430 --> 14:23.170
And that's where the complexity starts.

14:23.170 --> 14:25.050
So till here only 3 commands.

14:25.310 --> 14:26.930
Not much difficult.

14:27.430 --> 14:29.270
So what we are doing here.

14:29.310 --> 14:33.430
Whenever you are plugging anything to your desktop Ubuntu.

14:33.430 --> 14:36.150
It has a network manager running in the backend.

14:36.170 --> 14:39.010
And that will create a lot of problems when you are doing these things.

14:39.630 --> 14:41.410
If you know what you are doing.

14:41.410 --> 14:42.290
Just turn it off.

14:42.290 --> 14:44.530
If you are not using that VM for anything else.

14:44.530 --> 14:45.250
Just turn it off.

14:45.250 --> 14:47.490
It is going to do a lot of other things otherwise.

14:47.510 --> 14:48.970
But here what I am doing is.

14:48.970 --> 14:51.810
I am just removing one of these devices.

14:52.090 --> 14:52.650
WLAN2.

14:52.810 --> 14:54.290
From the managed world.

14:54.430 --> 14:57.470
So that this network manager is not messing it up.

14:57.470 --> 14:59.790
Because I want to move it to an isolation.

15:00.190 --> 15:04.350
Where I can make it use or work like a client.

15:04.610 --> 15:06.610
And we will do all of that in the same machine.

15:06.610 --> 15:07.550
That's the beauty of it.

15:07.550 --> 15:09.170
And you can do it multiple times.

15:09.170 --> 15:12.750
You can have 15, 20, 100 of these on the same VM.

15:12.750 --> 15:16.770
And the good thing is you don't even need a very powerful machine.

15:16.770 --> 15:19.830
You can actually take a bare minimum VM stack.

15:19.830 --> 15:21.190
And it will run online.

15:21.950 --> 15:23.830
So once that part is done.

15:24.090 --> 15:25.730
If you go here.

15:26.070 --> 15:30.270
What I am doing here is pretty familiar to I think most of the people.

15:30.450 --> 15:35.730
So this is a bare minimum open network configuration for HostAPD.

15:35.790 --> 15:38.670
HostAPD as you remember I just described.

15:38.670 --> 15:42.690
It is the software that all of your enterprise devices.

15:42.690 --> 15:46.090
All of your Wi-Fi devices which are running on Linux.

15:46.090 --> 15:47.930
Use to create your Wi-Fi networks.

15:47.930 --> 15:50.310
The SSIDs are created using this.

15:50.310 --> 15:52.550
The configuration are also like this.

15:52.550 --> 15:55.790
The only difference is when you do it in real world on real devices.

15:55.790 --> 15:57.710
You will see much more parameters here.

15:57.710 --> 16:02.370
So HostAPD in total actually supports over 150 plus parameters.

16:02.370 --> 16:04.730
Good thing is even if you don't define them.

16:04.730 --> 16:07.050
It will assume default values.

16:07.050 --> 16:10.450
And it will only take the values that you are providing.

16:10.450 --> 16:11.790
And make them different.

16:12.090 --> 16:14.570
So you have provided that part.

16:14.750 --> 16:18.870
And then here you are just running it with the configuration file.

16:19.030 --> 16:20.830
HostAPD is very easy to install.

16:20.830 --> 16:23.070
You can do apt-get install hostapd.

16:23.070 --> 16:24.430
It just works.

16:24.430 --> 16:28.290
And the reason I am not going into each and every command.

16:28.290 --> 16:30.590
Is now because you have chat-gpt file.

16:31.090 --> 16:32.210
So yeah.

16:32.310 --> 16:33.590
Very easy to see.

16:33.590 --> 16:37.350
I feel that the way today's world is working.

16:37.350 --> 16:39.010
If you know what you are looking for.

16:39.010 --> 16:42.270
It is very very very easy to start from there.

16:42.390 --> 16:45.910
However a lot of people don't really understand the basics of it.

16:45.910 --> 16:47.370
And that's what I am trying to clear up.

16:47.370 --> 16:50.130
Rest using chat-gpt and clod and all of that.

16:50.130 --> 16:54.010
You can write very powerful simulations around these basics.

16:54.010 --> 16:55.970
Which will create the main setup.

16:56.110 --> 16:57.490
So once you do this.

16:57.490 --> 16:59.310
You have an access point running.

16:59.310 --> 17:00.670
You have an SSID.

17:00.670 --> 17:02.390
The name is OpenTestNet.

17:03.250 --> 17:04.550
It's on channel 6.

17:04.550 --> 17:05.950
You can assign it a MAC.

17:05.950 --> 17:08.110
Because by default when you inject these.

17:08.110 --> 17:11.150
The MAC is 0000.2 or something.

17:11.150 --> 17:12.390
Which looks very odd.

17:12.390 --> 17:14.670
When you capture traffic on it.

17:14.770 --> 17:16.310
But yeah once you have this.

17:16.310 --> 17:17.790
You have SSID running.

17:17.830 --> 17:21.090
And if you go back to your GUI.

17:21.110 --> 17:24.590
You will actually see that there is a network operating here.

17:24.590 --> 17:28.070
Just like you see in the real world on your machine.

17:28.430 --> 17:30.470
Because again exact same thing.

17:30.470 --> 17:31.470
And if you click on it.

17:31.470 --> 17:32.910
On the HostCPD side.

17:32.910 --> 17:35.570
You will actually see all of these logs appearing.

17:35.810 --> 17:37.270
So what we just did.

17:37.410 --> 17:39.570
We made layer 2 connectivity.

17:39.570 --> 17:41.690
Between these two interfaces.

17:41.690 --> 17:43.050
On the same machine.

17:44.210 --> 17:46.630
Again it is a layer 2 connectivity.

17:46.630 --> 17:49.570
We don't really are dealing with netmasks.

17:49.570 --> 17:51.590
And layer 3 complications as of now.

17:51.590 --> 17:54.930
So that's why we can keep them in the same space.

17:55.070 --> 17:57.690
And nothing will break loose.

17:57.890 --> 18:00.230
However when you want to move forward.

18:00.230 --> 18:01.890
And you really want a real lab.

18:01.890 --> 18:03.070
A real connected lab.

18:03.070 --> 18:05.010
Where you are maybe running a web server.

18:05.010 --> 18:06.450
Or something on one side.

18:06.450 --> 18:08.570
And client is then trying to access it.

18:08.610 --> 18:11.810
Or you have a P2P application.

18:11.810 --> 18:13.830
That is running on different clients.

18:13.830 --> 18:15.790
Exchanging traffic through that access point.

18:15.790 --> 18:18.810
You will need layer 3 connectivity.

18:19.270 --> 18:23.510
And that is where the concept of Linux namespaces will come in.

18:23.510 --> 18:28.430
So I am very sure that most of you guys have already worked with Docker containers.

18:28.430 --> 18:32.090
So your Docker containers or for that matter any kind of Linux containers.

18:32.090 --> 18:34.570
They are built using Linux namespaces.

18:34.570 --> 18:35.890
What are namespaces?

18:35.950 --> 18:39.470
This is a way to isolate the system resources.

18:39.670 --> 18:42.330
So if you want that on the same machine.

18:42.330 --> 18:44.850
When I list my interfaces.

18:44.850 --> 18:47.990
I should be able to see two resources on one side.

18:47.990 --> 18:50.570
And another one in another section.

18:50.570 --> 18:55.730
And these resources should not know that there are other resources on the same machine.

18:55.730 --> 18:57.050
So you are isolating them.

18:57.050 --> 18:59.070
Same way your containers do.

18:59.070 --> 19:01.390
So when you are running a process in a container.

19:01.390 --> 19:05.150
It does not know what is happening outside of container.

19:05.150 --> 19:07.370
What is happening in another container.

19:07.370 --> 19:10.870
And that is also implemented using namespaces.

19:10.970 --> 19:14.590
So for the containers we use process namespaces.

19:14.590 --> 19:16.230
And network namespaces.

19:16.230 --> 19:17.610
And IPC namespaces.

19:17.610 --> 19:18.950
And mouth namespaces.

19:18.950 --> 19:20.430
However in this case.

19:20.430 --> 19:24.690
Because we are just concerned with the network part of it.

19:24.690 --> 19:26.830
We can just use network namespaces.

19:26.830 --> 19:30.450
So this is how you set a network namespace.

19:30.450 --> 19:32.390
You do ip netns.

19:32.390 --> 19:34.830
Again stands for network namespaces.

19:34.910 --> 19:36.210
Then you say add.

19:36.230 --> 19:38.490
And then there is the name of the namespace.

19:38.490 --> 19:39.770
It can be anything.

19:39.850 --> 19:41.870
It's a construct that you are creating.

19:41.870 --> 19:44.570
So that you can isolate these on the same machine.

19:44.570 --> 19:46.650
Because if you don't isolate it.

19:46.650 --> 19:48.470
Then there is a problem called.

19:49.970 --> 19:51.630
R... R what?

19:51.630 --> 19:52.630
Not R flooding.

19:52.630 --> 19:53.890
R confusion or something.

19:53.890 --> 19:54.790
So there is this thing.

19:54.790 --> 19:57.650
If you have two interfaces on your machine.

19:57.730 --> 19:59.230
They are able to see each other.

19:59.230 --> 20:01.890
And if they have IPs from the same subnet.

20:01.890 --> 20:05.470
The machine doesn't know which interface is the right one.

20:05.470 --> 20:08.470
So it tries to send the traffic from both of these interfaces.

20:08.470 --> 20:09.390
And what will happen?

20:09.390 --> 20:11.770
Your machine will actually lose connectivity.

20:11.770 --> 20:12.970
It won't be able to work.

20:12.970 --> 20:14.290
Because your packets.

20:14.290 --> 20:15.490
They are going from one interface.

20:15.490 --> 20:18.450
And then they are trying to come from another interface.

20:18.510 --> 20:20.610
So to avoid that confusion.

20:20.610 --> 20:23.490
That's where your network namespaces are required.

20:23.490 --> 20:24.810
So what we are doing here is.

20:24.810 --> 20:27.210
We are setting up one more namespace.

20:27.410 --> 20:29.110
So when you log into your machine.

20:29.110 --> 20:31.130
There is always a default namespace.

20:31.130 --> 20:33.630
That is where you are playing most of the time.

20:33.630 --> 20:35.970
You only go into creating additional ones.

20:35.970 --> 20:38.290
When you want to do something like containers.

20:38.370 --> 20:39.690
Containers do this all the time.

20:39.690 --> 20:42.930
That's how you can see a ETH0 inside the container.

20:42.930 --> 20:44.810
And outside as well.

20:44.810 --> 20:46.050
So same thing we did here.

20:46.050 --> 20:47.450
We created a namespace.

20:47.450 --> 20:48.370
After that.

20:48.370 --> 20:52.430
We made sure that that namespace has a local interface.

20:52.430 --> 20:54.430
It is the local host.

20:54.430 --> 20:56.250
Local interface that you see.

20:56.250 --> 20:59.050
And if you want to check the namespaces that are created.

20:59.050 --> 21:00.190
If you do list.

21:00.190 --> 21:03.170
You will see the one that you have created here.

21:04.610 --> 21:06.050
Once that is there.

21:06.050 --> 21:07.290
What you can do.

21:07.290 --> 21:09.550
You can take one of these devices.

21:09.590 --> 21:12.830
And you can move it over into the new namespace.

21:12.870 --> 21:15.370
So this command here precisely does that.

21:15.370 --> 21:17.110
When you say iw.

21:17.110 --> 21:22.010
This is the utility that you use to play around with the WiFi companies.

21:22.010 --> 21:24.710
PHY stands for Physical Device.

21:25.210 --> 21:28.090
PHY2 stands for Physical Device 2.

21:28.110 --> 21:29.570
So if you go back.

21:29.770 --> 21:32.790
And if you take a look at this here.

21:32.790 --> 21:35.210
What you will see is that every device.

21:35.210 --> 21:36.250
Every virtual device.

21:36.250 --> 21:38.610
Just like the real device that you plug in.

21:38.610 --> 21:40.330
Is marked with the name.

21:40.450 --> 21:43.770
In this case it is PHY2 that we want to move.

21:44.270 --> 21:46.990
So go back here.

21:47.110 --> 21:49.170
And that is what you have done.

21:49.170 --> 21:50.590
Now after doing this.

21:50.590 --> 21:52.310
If you run iwdev.

21:52.710 --> 21:53.510
Surprisingly.

21:54.010 --> 21:55.690
Or not surprisingly.

21:55.690 --> 21:57.610
Because we knew this is going to happen.

21:58.890 --> 22:01.030
PHY2 is not there anymore.

22:01.030 --> 22:02.110
It has moved.

22:02.230 --> 22:04.090
And currently the command that you are running.

22:04.090 --> 22:06.270
It is running in the default namespace.

22:06.430 --> 22:08.190
So that is why you are not able to see it.

22:08.190 --> 22:10.010
Your commands are not going to see it.

22:10.010 --> 22:11.950
And that is precisely what we want.

22:11.950 --> 22:14.990
If we really want to do layer 3 connectivity.

22:14.990 --> 22:16.030
On the same machine.

22:16.030 --> 22:17.450
Using the same subnet.

22:17.450 --> 22:18.910
And this can be extended.

22:18.910 --> 22:21.390
And that is how your containers also work.

22:21.590 --> 22:22.790
They are on the same machine.

22:22.790 --> 22:24.390
They have different interfaces.

22:24.390 --> 22:26.210
You are doing networking between them.

22:26.210 --> 22:27.550
They are in the same subnet.

22:27.550 --> 22:28.890
Still everything runs.

22:28.890 --> 22:29.270
Why?

22:29.270 --> 22:32.210
Because these interfaces are not seeing each other.

22:32.310 --> 22:34.170
They feel that they are in separate machines.

22:34.170 --> 22:35.730
And that is what we are doing here.

22:36.110 --> 22:39.150
So you have PHY1 and PHY2.

22:39.270 --> 22:40.670
In this namespace.

22:41.250 --> 22:43.250
If you go to another namespace.

22:43.250 --> 22:44.230
So here.

22:44.670 --> 22:46.170
When you run ip link.

22:46.170 --> 22:46.930
Like this.

22:46.930 --> 22:48.790
It runs in the default namespace.

22:48.990 --> 22:52.270
You are seeing two of these devices here.

22:52.330 --> 22:54.970
And then you use ip net ns.

22:54.970 --> 22:57.130
So this is the command that you use.

22:57.130 --> 22:59.770
When you want to run a specific command.

23:00.230 --> 23:04.270
In a specific network namespace.

23:04.270 --> 23:05.930
So you do extc.

23:05.930 --> 23:07.630
That is execute.

23:07.730 --> 23:10.450
Name of the network namespace.

23:10.450 --> 23:12.510
And then the command that you want to run.

23:12.510 --> 23:13.890
So now when we are running it.

23:13.890 --> 23:16.430
It is not in default namespace.

23:16.430 --> 23:18.890
It is in the namespace that you created.

23:19.090 --> 23:20.630
And as you can see.

23:20.630 --> 23:22.510
It also has a local one.

23:22.510 --> 23:24.230
And then WLAN2.

23:24.370 --> 23:28.850
So now WLAN2 cannot see WLAN1 and WLAN0.

23:29.070 --> 23:35.490
And that is the magic behind your virtualization of this kind of lab.

23:35.590 --> 23:38.730
It is the same concept that we have borrowed from the containers.

23:38.730 --> 23:41.390
This is how containers are working behind the scenes.

23:41.390 --> 23:44.030
And you can extend the same logic for this.

23:44.030 --> 23:47.290
There is also one more module on similar lines.

23:47.290 --> 23:50.570
It is MAC8015.

23:50.710 --> 23:54.210
So you can also use that to simulate that network.

23:54.350 --> 23:55.850
As far as my knowledge goes.

23:55.850 --> 24:00.490
Currently there are only two of these modules that you can use to simulate very closely.

24:01.170 --> 24:03.830
There are multiple other options as well.

24:03.830 --> 24:06.150
But most of these options they actually emulate.

24:06.150 --> 24:07.130
They don't simulate.

24:07.130 --> 24:08.970
So if you take a packet capture.

24:08.970 --> 24:11.750
And if you take a look closer on their behavior.

24:11.750 --> 24:16.330
You will actually see that their behavior is very different how real devices work.

24:16.350 --> 24:20.610
But in this case it is as good as your physical device.

24:20.610 --> 24:26.550
Apart from the fluctuations in the power and the physical disturbances.

24:27.070 --> 24:29.410
So once our setup is ready.

24:29.550 --> 24:31.370
What we need to do now.

24:31.970 --> 24:37.210
We are taking this one interface WLAN1 on which we have already created an SSID.

24:37.210 --> 24:39.930
Because we are now talking about layer 3 connectivity.

24:39.930 --> 24:41.210
We need IPs.

24:41.210 --> 24:43.330
So we are setting an IP address on it.

24:43.650 --> 24:45.430
Then we are turning it on.

24:45.430 --> 24:48.290
If it is not on, it is already on but just to be sure.

24:48.650 --> 24:50.190
And then we are creating this.

24:50.370 --> 24:53.710
This is the same file that we have used to run that access point.

24:53.730 --> 24:58.190
You can also run it as a daemon by using "-b".

24:58.190 --> 24:59.390
So that's what we did.

24:59.390 --> 25:00.790
Access point is enabled.

25:01.670 --> 25:06.350
And this is the default namespace that we are currently dealing with.

25:07.510 --> 25:09.170
SSID will start.

25:09.170 --> 25:15.590
If you do IWDEV, you will see that instead of saying managed, now it will say access point.

25:16.690 --> 25:18.770
Because it is operating an SSID.

25:18.910 --> 25:20.970
HostAPD is making it do this.

25:21.130 --> 25:23.170
The second one we are not playing with.

25:23.170 --> 25:26.870
This is the one that network manager is currently playing with.

25:26.870 --> 25:29.070
The Ubuntu desktop network manager.

25:29.070 --> 25:31.170
You can safely ignore it for now.

25:32.270 --> 25:34.470
Then comes the client part.

25:34.470 --> 25:40.030
And this is where you actually run this logic in the other namespace that you have created.

25:40.290 --> 25:43.270
So you first switch into the other namespace.

25:43.270 --> 25:49.250
What I am doing here, I am launching a bash shell in this new namespace that I have created.

25:49.410 --> 25:52.090
Once you do that, you are inside it.

25:52.090 --> 25:55.090
If you do IWDEV, it will run any other commands now.

25:55.090 --> 25:58.210
Because you are inside the bash which is running in this namespace.

25:58.210 --> 26:02.730
It won't show you the interfaces that are there in the default namespace.

26:02.730 --> 26:05.450
But only the one that you moved and the local one.

26:06.090 --> 26:11.050
And after that, we created this very simple configuration file.

26:11.090 --> 26:14.550
It is to connect to this open network that is there.

26:14.770 --> 26:17.970
And then we will use WPSApplicant.

26:18.010 --> 26:20.050
We will give it the interface name.

26:20.050 --> 26:22.250
And then we will give it the configuration file.

26:22.250 --> 26:26.030
So whenever you are using a Linux machine and you are connecting to any network.

26:26.030 --> 26:29.930
Back in the back, WPSApplicant is the one that is running and doing all the jobs.

26:29.930 --> 26:32.610
So here we are just running it using the command.

26:32.610 --> 26:37.270
Otherwise, when your network manager has to connect it, it also is going to call it.

26:37.570 --> 26:40.890
So by doing this, now you have that connectivity.

26:41.270 --> 26:51.370
And after that, the only thing that remains is on the access point side, you have to run dnsmasq or any other tool which can run a DHCP server.

26:51.870 --> 26:52.930
That part is done.

26:52.930 --> 26:59.630
Then you come on this side and you run dhclient, which will request for the IP address and it will get the IP address.

26:59.630 --> 27:03.310
And you have full layer 3 connectivity on the same machine.

27:03.310 --> 27:05.630
So this is the basic construct.

27:05.670 --> 27:11.710
Now, once you have this, as you saw, everything was done using Linux commands.

27:11.710 --> 27:13.470
How do we automate it?

27:13.470 --> 27:25.950
You write a shell script, which will generate random names, random IDs, and then you loop over it again and again and again, depending on what exactly you want to make.

27:25.950 --> 27:35.190
If you want to simulate 5 to 6 of these networks, you can make a more elaborated or multiple post-APD computation file.

27:35.190 --> 27:41.350
You can run it and you'll have 10 or 20 or 30 or 40 networks there.

27:41.350 --> 27:46.130
You want to create roaming clients, just create clients, run WPA supplicant on it.

27:46.130 --> 27:47.190
They'll start probing.

27:47.190 --> 27:49.150
If they find the network, they'll connect.

27:49.150 --> 27:55.230
If they connect, then if you're running DHCP, they're automatically going to get IP connectivity.

27:55.230 --> 27:58.250
So this way, you can pretty much simulate.

27:58.270 --> 27:59.830
Even WPA3 you can simulate.

27:59.830 --> 28:02.090
That's another thing that you won't be able to break it.

28:02.090 --> 28:09.770
But if you really want to quickly capture packets of the handshake, for WPA2, WPA3 as well, there is a handshake.

28:10.190 --> 28:18.450
Even if you want to simulate WEP for some reason, you're trying to look at packets, you want to see how exactly those attacks used to work.

28:18.510 --> 28:20.690
It will work perfectly in this case.

28:20.690 --> 28:20.970
Why?

28:20.970 --> 28:22.530
Because you're not missing any packet.

28:22.530 --> 28:24.030
You'll see everything.

28:24.030 --> 28:26.770
And again, this also has a channel of concepts.

28:26.790 --> 28:36.210
So you still have to use your error dump to jump around, to see all the things, and then to set on one channel, then to lock on one target, and then to do all of this.

28:36.630 --> 28:39.390
So yeah, this is how you do it.

28:39.430 --> 28:42.470
It will run on any kind of VM that you run.

28:42.470 --> 28:45.010
It actually even runs on open word.

28:45.010 --> 28:47.870
So if for some reason you want to do that, you can do that.

28:47.870 --> 28:49.390
It also runs on Raspberry Pi.

28:49.390 --> 28:51.010
We tried it there as well.

28:52.010 --> 29:02.350
The only thing is that when you do this on IoT devices, sometimes you might have to compile their kernel and their firmware using the buildchains.

29:02.410 --> 29:05.250
In desktop it is easy, that's why I'm showing this to you.

29:05.250 --> 29:11.550
If you try to do this with open word, you have to take the whole source code, you have to make the changes in the configuration file.

29:11.550 --> 29:14.950
So when the kernel is compiled, at that time you can do this.

29:15.010 --> 29:19.110
So it is a little bit more difficult, but not impossible, you can do it.

29:20.470 --> 29:24.970
So next thing is, what if I'm too lazy to do all of this?

29:24.970 --> 29:31.490
I understand there are namespaces, I understand there is hostcpd, nwps-applicant and all of this, right?

29:31.490 --> 29:40.250
But I don't really want to get into scripting and to fix it, even with Cloud or other things.

29:40.250 --> 29:43.690
So in that case, people have created something like this.

29:43.690 --> 29:45.870
They have Mininet Wi-Fi.

29:46.550 --> 29:48.290
How does this work?

29:48.290 --> 29:50.450
Exactly the way I stated.

29:50.850 --> 29:53.950
So what they have done, they have taken the same construct.

29:54.230 --> 29:56.970
They have done all the plumbing for you.

29:56.970 --> 29:59.070
So you can just run commands.

29:59.410 --> 30:04.110
And by using these commands, you can pretty much simulate all the things that we just discussed.

30:04.110 --> 30:11.070
You can have multiple clients, multiple APs, all of that, by using very simple things.

30:11.070 --> 30:14.990
And here, you are seeing a diagram that I have taken from their site.

30:14.990 --> 30:18.670
And the reason for that is just to show you that all of this, you already know now.

30:18.670 --> 30:22.210
So you have these WLAN1, WLAN2, WLAN3, same thing.

30:22.210 --> 30:23.570
How they are doing it.

30:23.570 --> 30:25.190
Same module we talked about.

30:25.190 --> 30:28.250
Now we know how to inject it, how to do it on our own.

30:28.950 --> 30:31.590
This is called Netlink Socket.

30:31.610 --> 30:34.210
It is here for depiction purpose.

30:34.210 --> 30:35.390
This is how it actually works.

30:35.390 --> 30:37.470
But yeah, you don't need to know about it.

30:37.470 --> 30:40.130
It automatically just works if you are on Linux.

30:40.610 --> 30:43.630
And here, they are creating different namespaces.

30:43.630 --> 30:46.830
And in the namespaces, they are mapping these.

30:47.710 --> 30:49.830
Same way, like we did.

30:49.950 --> 30:53.130
And on top of that, you will have your connections and all.

30:53.330 --> 30:56.770
So easy way, very good documentation as well.

30:56.770 --> 31:02.010
Till the time you are not trying to simulate something very complicated, it will just work.

31:02.850 --> 31:06.390
And then, what is more that these guys are providing that we didn't discuss?

31:06.390 --> 31:08.970
So we didn't discuss the physical part of Wi-Fi.

31:08.970 --> 31:16.890
Because as your access points are at one place, your clients, if they are moving, the signal strength is going to be varying.

31:16.910 --> 31:25.410
Even if the access point is stationary and you are also stationary, due to the physical factors, there are so many things that actually interact with Wi-Fi signals.

31:25.410 --> 31:32.450
So even if I stand here, the Wi-Fi is stationary right there, you will still get packets of varying signals.

31:32.610 --> 31:36.770
So all of that, if you want to simulate, then this thing can do that.

31:36.770 --> 31:38.450
It simulates moving targets.

31:38.450 --> 31:46.810
So you can actually code or tell it to create moving clients from one access point to another access point.

31:46.810 --> 31:49.410
And you will also see the switching being happened.

31:49.430 --> 31:54.010
So when you are moving in a very big campus, you see a lot of these access points deployed.

31:54.010 --> 31:59.150
And what happens is when you move from one location to another, automatically a handover happens.

31:59.150 --> 32:06.070
So you switch from one access point to another one, the same way you switch your mobile networks when you move through space.

32:06.070 --> 32:08.670
This thing can also simulate that part.

32:08.670 --> 32:11.390
So you will see one client disconnecting and connecting on the other side.

32:11.390 --> 32:15.950
And that's the reason why you can use this to run simulations on a bigger scale.

32:16.290 --> 32:19.930
Propagation also, but that's not really for security purposes.

32:19.930 --> 32:23.110
That is if you really want to understand how the propagation works in Wi-Fi.

32:23.130 --> 32:24.450
So that's also there.

32:25.310 --> 32:30.570
And the good thing is that now they also have an easy-to-deploy container board.

32:30.570 --> 32:33.710
So you can just run these commands.

32:33.710 --> 32:36.130
It will create multiple containers.

32:36.130 --> 32:43.270
These containers, if you go into these, these will behave like different, different machines, which are connected using Wi-Fi.

32:44.310 --> 32:47.330
So it was very easy to do in Docker.

32:47.330 --> 32:56.570
Now you can also do it using Wi-Fi, where it feels like that you are using a wireless network, but essentially it is nothing but software.

32:56.930 --> 32:58.710
So yeah, very easy to use.

32:58.810 --> 33:00.210
What are other options?

33:00.210 --> 33:02.190
You have NSP.

33:02.210 --> 33:05.010
It's called Network Simulator 3.

33:05.190 --> 33:09.650
It's more for the wired thing or the protocol part.

33:09.650 --> 33:12.990
But can we do 802.11 on it?

33:12.990 --> 33:13.870
Yes, you can.

33:13.870 --> 33:23.110
However, if you try to capture the packets, the captures won't work the same way as they will with 802.11 SW-SIM.

33:23.190 --> 33:25.250
You have another thing called Core.

33:25.250 --> 33:26.450
You can look it up.

33:26.450 --> 33:27.450
That's another solution.

33:27.450 --> 33:29.610
It is more tightly coupled.

33:29.610 --> 33:31.770
So you cannot change a lot of things there.

33:31.770 --> 33:35.070
That's why not really the best place to start.

33:35.190 --> 33:38.010
Then you have MiniNet Wi-Fi and then obviously DNS3.

33:38.010 --> 33:42.130
But DNS3 does not really support the Wi-Fi frames.

33:42.130 --> 33:44.790
So you'll only see these being emulated.

33:44.790 --> 33:49.670
You'll see the traffic of Layer 3 and above, but Layer 2 you won't be able to see.

33:49.670 --> 34:07.110
So these are the different ways by which you can create your own cloud Wi-Fi lab or your home Wi-Fi lab, where you can have multiple of these devices and then you can run simulations, attacks, floods, de-auths, if you wanted to do that and now WP3 is not letting you do that.

34:07.110 --> 34:10.430
You can create one and then do a de-auth there.

34:10.430 --> 34:11.890
You can study the behavior.

34:11.890 --> 34:15.150
You can see in MiniNet.

34:15.150 --> 34:23.470
In MiniNet, you can actually see that when you move a client and you do de-auth it, it will go for the nearest one with stronger signals.

34:23.470 --> 34:30.550
All of these things you can literally see, which are very, very, very difficult when it comes to similarities in real world.

34:30.550 --> 34:34.370
In real world, you can speculate and then you can observe.

34:34.450 --> 34:36.990
Still, you are going to be wrong for the most part.

34:37.230 --> 34:37.870
So, yeah.

34:38.590 --> 34:39.970
So that's all.

34:39.970 --> 34:43.430
If there are any questions, please throw them my way.

34:44.810 --> 34:45.570
Thank you.

