WEBVTT

00:00.000 --> 00:03.280
Hey everyone, as you start moseying in, we're going to have Bertin.

00:03.280 --> 00:05.740
He is an independent security researcher.

00:05.780 --> 00:08.300
He's going to talk to you guys about industrial protocols.

00:08.300 --> 00:09.640
It's going to be a really fun talk.

00:09.640 --> 00:11.280
I hope you all enjoy it.

00:11.320 --> 00:15.740
And yeah, as you start moseying in, I see the camera guy has given me the okay.

00:15.740 --> 00:17.620
We'll just start kicking things off.

00:17.620 --> 00:21.620
So please give Bertin a warm welcome and everyone enjoy themselves.

00:21.620 --> 00:22.380
Thanks.

00:27.770 --> 00:28.910
Okay, cool.

00:28.990 --> 00:30.010
Hello everyone.

00:30.010 --> 00:31.350
Welcome to my talk.

00:31.530 --> 00:41.310
This is about um, well, as the title says, mixing industrial protocols with web application floss.

00:41.310 --> 00:44.350
In order to exploit devices in the internet.

00:44.350 --> 00:49.910
Which is a thing that I used to do all the time for like uh, ten years ago.

00:49.910 --> 00:52.730
I mean, something really crazy.

00:52.810 --> 00:58.890
Um, let me, that too.

00:58.890 --> 01:00.510
Okay, here we go.

01:01.230 --> 01:04.110
So okay, oh, why is it so fast?

01:06.820 --> 01:08.400
There it is.

01:08.520 --> 01:09.460
So fast.

01:09.460 --> 01:10.160
Okay.

01:10.680 --> 01:17.000
Okay, hello, uh, my name is Bertin, as uh, they present me.

01:17.060 --> 01:18.260
Uh, this is my tutor.

01:18.260 --> 01:20.800
I'm uh, working as a security consultant.

01:20.880 --> 01:33.520
Uh, professionally in network engineering, security research, device security, protocol security, uh, basically all of my uh, research is based in remote exploitation all the time.

01:33.520 --> 01:35.780
I mean, all the things that I do is remote.

01:35.840 --> 01:40.660
And always, all the devices that I use to exploit are connected to the internet.

01:40.660 --> 01:41.720
All the time.

01:43.260 --> 01:54.080
Okay, agenda for today, uh, the motivation for this research, how it started, how I found this, and how I developed exploit and all this stuff.

01:54.340 --> 01:58.280
Uh, I'm gonna be talking about modern, modern magnet devices.

01:58.660 --> 02:01.140
The security problem in those devices.

02:01.660 --> 02:09.940
And then I'm going to be explaining how to use magnet protocol itself as an attack vector for this kind of devices.

02:10.080 --> 02:19.360
Uh, the fundamentals for magnet, because in order to understand this, we need to recap all the things about magnets, how it works, how it's designed, and all this stuff.

02:19.420 --> 02:23.880
The theory and the technique, and the exploits and the conclusions.

02:23.940 --> 02:28.360
At the end, uh, there is a bonus track that I decided to include in this talk.

02:28.360 --> 02:33.000
It's an RCE, an, uh, industrial router.

02:33.020 --> 02:35.600
Yeah, that's critical, as usual.

02:36.200 --> 02:38.260
So, the motivation about this.

02:38.640 --> 02:43.660
There is a lot of fun, a lot of fun, in industrial protocol security.

02:43.880 --> 02:58.880
Usually you can, uh, on off things, uh, start stuff, uh, start and stop stuff, read critical data, uh, modify critical data, inject malicious data, execute malicious stuff, and so on.

02:58.880 --> 03:04.920
All these remotely, from your home, from your, I mean, your hotel room, everywhere in the world.

03:05.400 --> 03:12.120
So, I start playing around with many of them, of these protocols, visible for search engines.

03:12.120 --> 03:15.380
And some of them are invisible.

03:15.700 --> 03:25.080
That is a fun fact that many researchers, uh, ignore, because they think that current, uh, search engines are indexing all the industrial protocols.

03:25.080 --> 03:27.120
No, but that is not true.

03:27.380 --> 03:35.500
Because, uh, there are a lot of new technology, there are new, there are a lot of new devices with proprietary protocols.

03:35.940 --> 03:39.940
And these protocols are based usually in UDP TCP.

03:40.040 --> 03:48.000
So, you can, of course, scan the internet for these, uh, new protocols, and, uh, have some fun with them.

03:48.260 --> 04:04.240
So, uh, please, uh, keep in mind that thing, that there are security, I mean, there are industrial security protocols, or industrial protocols that, uh, are not being indexed by current search engines, like Shodan or Sumai.

04:04.340 --> 04:05.920
And people don't know that.

04:06.940 --> 04:23.460
So, the following is the result of hours of reading documentations, analyzing servers in the internet, and testing on common things, trying to find out new paths for remote injection and web application services for specific devices using the BACnet protocol.

04:25.120 --> 04:27.560
Okay, BACnet previous research.

04:27.560 --> 04:29.640
There are a lot of talk about BACnet.

04:29.640 --> 04:32.760
I mean, um, several talks about that.

04:32.760 --> 04:38.340
You can find out, uh, it's always the same thing, like, uh, on, off, start, stop attacks.

04:38.340 --> 04:41.800
Uh, we know that there is no security in this protocol.

04:41.800 --> 04:43.680
It's basically plain text.

04:43.680 --> 04:46.860
Uh, there is no authentication method.

04:47.180 --> 04:54.680
Um, you can perform, actually, BACnet network scans remotely to the BACnet topology infrastructure.

04:55.240 --> 05:00.980
No web applications issues find, found, until today, in this talk.

05:01.120 --> 05:11.380
I was, uh, trying to figure out if someone else, years before, tried to do something that I, uh, am going to show you today, but I had no luck.

05:11.380 --> 05:13.420
So, basically, this is something new.

05:14.560 --> 05:18.100
Okay, today, I am introducing a new attack vector in BACnet devices.

05:18.100 --> 05:19.240
This is remote.

05:19.500 --> 05:24.000
And last night, I found another brand affected by this, curiously.

05:24.020 --> 05:26.200
So, this is a travel touch thing.

05:26.200 --> 05:31.860
I mean, there are several brands affected by this thing, but I don't know , and we don't know exactly which they are.

05:31.860 --> 05:33.000
We need to find out.

05:33.740 --> 05:35.940
Um, you don't need tools to do this.

05:35.940 --> 05:37.720
It's just a simple script.

05:37.740 --> 05:40.300
It's a crafted attack, very, very crafted attack.

05:40.300 --> 05:45.280
It's a stealth, uh, UDP base, and you can get persistence.

05:45.280 --> 05:50.420
And finally, code execution in browser, which is really cool.

05:51.340 --> 05:53.260
This thing doesn't work here.

05:53.260 --> 05:59.340
I mean, we're talking about web application, but this thing is not capable of, uh, find these kind of things.

05:59.340 --> 06:02.800
So, if you think that this is the thing, you are wrong.

06:02.800 --> 06:04.600
I'm gonna prove that today.

06:04.600 --> 06:07.620
So, please, keep in mind that this thing doesn't work here.

06:07.620 --> 06:09.540
It's not prepared, yet.

06:10.220 --> 06:16.580
Okay, so, brands affected by this issue, discovered until now, this is a traversal issue, as I mentioned.

06:16.800 --> 06:21.620
The first, uh, brand is called RLE Technologies.

06:21.780 --> 06:26.820
This is a brand who manufactures devices for industrial purposes.

06:27.300 --> 06:30.700
Uh, protocol converters, industrial routers, blah, blah, blah.

06:30.920 --> 06:37.100
They can, which, I don't know which is the relationship with MyQi, which is a Hong Kong company.

06:37.620 --> 06:42.700
Uh, they are using the same kind of server in both, uh, brands.

06:42.740 --> 06:49.520
So, they have, uh, one device here and another device here, and they are using the same technology, so they are affected by the same issue.

06:50.140 --> 06:53.720
Two brands, uh, using the same technology.

06:53.840 --> 06:59.340
There is another brand which is not included here, that I found last night, which is called KMC Controls.

06:59.340 --> 07:04.920
It's affected by the same, but it was found last night, so, it's, uh, new.

07:05.440 --> 07:11.800
Okay, this is the, the first device that, uh, I was able to exploit with this thing.

07:12.420 --> 07:16.480
Everything started here with this thing, the RLE protocol converter.

07:16.720 --> 07:27.920
Uh, what this, this thing does is, uh, trying to, well, actually, not trying to, okay, it converts, uh, Bagnet protocol to Modboost protocol.

07:27.920 --> 07:29.400
This is a protocol converter.

07:29.400 --> 07:41.220
When you don't have, um, a way to communicate with devices, this thing helps you to, uh, modify this kind of protocol conversion, and you will be able to reach devices through this thing.

07:41.880 --> 07:51.220
Okay, the devices affected by this issue are this one, graphically, uh, Daikin and McQuay.

07:51.220 --> 07:57.040
They, uh, manufacture chilling, big chilling, big chillers, chillers, that's it, chillers.

07:57.680 --> 08:05.640
And those devices are connected to the internet, they have a web application in order to, uh, manage, configure, set up the whole thing.

08:07.180 --> 08:09.840
And things are just getting bigger and bigger.

08:10.780 --> 08:19.940
Okay, uh, this is an example of a Bagnet topology, how a Bagnet topology is, is, um, deployed in infrastructure.

08:20.600 --> 08:29.540
So our goal today is, or an attacker goal, is, uh, infect the engineer web browser.

08:29.540 --> 08:30.860
Why the engineer web browser?

08:30.860 --> 08:35.960
Because he's going to be connected to these kind of devices in every time.

08:36.040 --> 08:43.440
So usually those engineers, or these technicians, has access to another, uh, set of devices.

08:43.540 --> 08:55.680
So if we are able to, uh, execute code in their machine browser, probably we could steal, uh, other things that could be more interesting in, in this kind of, uh, particular attacks.

08:56.120 --> 09:00.360
Uh, we're talking about like an APT attack or some kind of thing, I don't know.

09:00.760 --> 09:15.500
But if you get persistent and the technician machine, you could probably, uh, steal other more critical devices in that infrastructure, or probably another, uh, more critical computer.

09:16.360 --> 09:18.780
This, this idea that I have with this.

09:19.560 --> 09:30.940
Okay, this is, this is taken from the Bagnet.org tutorial, um, basically the, the official documentation from Bagnet.

09:31.260 --> 09:35.200
And there is a little note, uh, about security.

09:35.200 --> 09:41.620
Because when I started this, I was, you know, interested in, uh , how the security of this thing works.

09:41.940 --> 09:43.920
But I found this.

09:44.280 --> 09:47.780
So there is a little discussion of security in this presentation.

09:47.960 --> 09:50.380
We have assumed that all nodes are trusted.

09:50.540 --> 09:54.340
Security will obviously be an important future consideration.

09:54.640 --> 09:58.480
For now, assume that all devices are sitting behind a firewall.

09:58.480 --> 10:05.000
That does packet filtering and the environment has well implemented restrictions on the software that can run inside a firewall.

10:05.360 --> 10:10.160
This is all the thing that this guy said about Bagnet security.

10:10.160 --> 10:12.400
You can find out in, in, in that link.

10:12.520 --> 10:18.960
This is all that you will have, uh, that you will find about, uh, security implementations and the protocol itself.

10:19.300 --> 10:22.900
So it means that there is no authentication methods.

10:22.900 --> 10:29.660
There is nothing, uh, to protect the, the protocol itself if there is no, uh, firewall, uh, very well implemented.

10:29.780 --> 10:31.040
And infrastructure.

10:31.840 --> 10:34.600
So our goal today will be the following.

10:34.860 --> 10:43.020
Uh, remote attacker from the internet, uh, has access to the device, but has no access to the web application.

10:43.800 --> 10:46.740
But has access to the Bagnet protocol.

10:46.740 --> 10:50.760
And he can read and modify things using just the protocol.

10:52.240 --> 10:54.960
So let's start with the Bagnet specs.

10:54.960 --> 11:01.460
In comparison with the OSI layers, uh, the Bagnet works in the application and network layer.

11:02.680 --> 11:04.880
And of course, IP.

11:05.500 --> 11:06.360
IP protocol.

11:06.360 --> 11:07.060
So let's start with the Bagnet protocol.

11:08.600 --> 11:13.080
It's, uh, the port is 47808.

11:13.080 --> 11:14.720
It's UDP based.

11:14.720 --> 11:17.700
No complex security mechanism, as, as I said.

11:17.700 --> 11:26.000
No CRC, no integrity checks, no hash, blank text, read write capabilities, and it's completely open in the internet.

11:26.000 --> 11:34.400
You just need to perform a query in some extensions and you will find out that, um, there are a lot of devices connect, connected.

11:35.860 --> 11:40.000
Okay, uh, so the Bagnet structure is basically Bagnet, Bagnet IP.

11:40.280 --> 11:47.500
The first layer would be the VUVLC or Bagnet virtual local control.

11:47.800 --> 11:55.500
The third layer, the second layer would be the MPDU, uh, network protocol data unit.

11:55.500 --> 12:04.800
And the last layer would be the application data unit, which contains all the information that we need to inject to the device.

12:05.220 --> 12:06.360
The magic happens there.

12:06.980 --> 12:12.300
Okay, let's talk about the first layer, the Bignot, Bagnet virtual link control.

12:12.760 --> 12:14.940
It's basically two bytes.

12:16.900 --> 12:18.600
Oh, excuse me, four bytes.

12:18.600 --> 12:19.700
It's four bytes.

12:19.740 --> 12:21.640
The first byte defines the type.

12:21.880 --> 12:27.140
In this case, Bagnet IP, which is, um, A1 and hex.

12:27.580 --> 12:29.840
The second one defines the function.

12:30.020 --> 12:36.520
In this case, uh, which function we, we would like to execute in, in, in the communication.

12:37.060 --> 12:41.180
And the last two bytes define the length of the whole packet.

12:41.180 --> 12:50.340
So you need to sum the three layers and put the result in that first layer in order to create a correct, uh, Bagnet packet.

12:50.340 --> 12:54.140
And then send it to, to the network and get the response.

12:54.300 --> 12:58.700
If that number is not correct, uh, you will get a more firm packet.

12:58.980 --> 13:00.480
So it's not going to work.

13:01.520 --> 13:06.240
This is a graphical representation in Wireshark about the first layer.

13:06.240 --> 13:08.400
The Bagnet virtual link control.

13:08.660 --> 13:10.360
You can see the function.

13:10.680 --> 13:14.460
This is our original unicast, unicast communication.

13:14.620 --> 13:18.300
And the two bytes are the length.

13:19.620 --> 13:23.040
Then we have the Bagnet network protocol data unit.

13:23.200 --> 13:28.300
This is a representation according to Bagnet wiki, but in practice it's just two bytes.

13:28.940 --> 13:30.260
Like this.

13:30.300 --> 13:35.160
So it's just telling you the version that you need to use and the control.

13:35.500 --> 13:39.320
So in this case, we set up the, the byte to four.

13:39.340 --> 13:43.460
Which means we are expecting reply from the device.

13:44.160 --> 13:52.700
So if you don't configure this control byte, uh, you probably, you could, uh, you can, you can get the reply back to you.

13:52.700 --> 13:54.340
If it's not properly configured.

13:54.340 --> 14:00.040
So you need to read the documentation and start constructing the packet byte by byte.

14:00.800 --> 14:04.340
And the last header is the Bagnet application data unit.

14:05.140 --> 14:15.540
Uh, this thing, uh, is the last header and contains, uh, variable length that also should be specified in that, in that header.

14:16.080 --> 14:19.900
Otherwise, you will face, uh, more phone packet issues again.

14:20.940 --> 14:24.180
This is how it looks like in Wireshark.

14:25.600 --> 14:25.940
Uh, this is a graphical representation of Wireshark .

14:26.240 --> 14:31.200
One important thing here is, uh, the service choice.

14:31.280 --> 14:39.520
The service choice is the, the byte that allows you, uh, read or write things in the Bagnet device.

14:39.840 --> 14:40.660
Okay?

14:41.100 --> 14:48.200
The magic is in the APU header that allows you to read or write values in the Bagnet data, uh, structure.

14:49.920 --> 14:53.500
Okay, here's what I'm talking about, the Bagnet service choice.

14:53.920 --> 15:02.180
So, you have all those values and bytes that allows you to set up how the communication is gonna be executed.

15:03.060 --> 15:11.580
So, in this case, we're gonna be using, uh, the 12 number value, which is 0C and hex, in order to read.

15:11.580 --> 15:12.420
Just read.

15:12.420 --> 15:13.140
Right?

15:15.940 --> 15:19.340
In order to read write, you need to set up correctly the service choice byte.

15:19.340 --> 15:32.380
At this point, probably you're thinking, you're taking a look into the 14 byte, because the 14 byte here, allows you to, uh, restart the device.

15:32.380 --> 15:35.340
If you send that byte, uh, the device will just restart.

15:35.340 --> 15:40.380
But we're not gonna be talking about this today, but keep in mind that this can be possible.

15:40.380 --> 15:43.240
Just sending a single packet to the network.

15:44.720 --> 15:52.780
So, in order to read, we'll be, and for write, it would be 0F.

15:52.800 --> 15:53.820
That's it.

15:56.380 --> 16:00.000
This is how, uh, a read packet looks like.

16:00.000 --> 16:06.060
You will see the read property configured there, and the number 12 in decimal.

16:08.380 --> 16:13.100
Okay, the values that we need to read and write will be the Bagnet objects.

16:13.100 --> 16:17.260
A Bagnet object is, uh, unique in a given device.

16:17.820 --> 16:22.040
It's a combination, uh, with many, uh, properties.

16:22.180 --> 16:35.760
Specifically, when you create a device in a Bagnet device, it means that every sensor, every in-out output, input output, will be created in a single device.

16:35.760 --> 16:40.680
This device has a name, and this device has, uh, his own properties .

16:40.940 --> 17:00.220
Every, every sensor in the Bagnet device has this, uh, segmentation, like, uh, specific, uh, may I compare this with, uh, profiles, would be kind of a specific profile, and the property of each profile can be modified, remodeled.

17:02.120 --> 17:07.320
Okay, the object identifier contains the property identifier.

17:07.660 --> 17:17.220
Basically, the string values represent the unary and readable strings like location, device model, device name, and so on, in a few words, or targets today.

17:18.780 --> 17:27.740
So, in this case, we are reading, uh, that specific object, the object identifier, which is a property identifier.

17:27.740 --> 17:31.000
It's kind of confusing, but one thing is upon the other.

17:31.000 --> 17:33.880
A property identifier has an object identifier.

17:36.600 --> 17:41.120
So, if you see, this is encoded as a character string.

17:41.120 --> 17:47.440
The object name, uh, the location name, application software version is character string.

17:49.160 --> 17:55.040
There are several tools available you can use, uh, in order to read and write values with Bagnet.

17:55.040 --> 18:05.260
There are a lot of Bagnet clients, uh, but the purpose of this thing is go deep and do this without tools in order to understand exactly how it works.

18:05.260 --> 18:09.480
Uh, you can do this with any language that supports socket communication.

18:11.220 --> 18:15.780
Okay, let's take a look how this looks like in execution.

18:16.960 --> 18:25.000
So, this is an example of how our read package looks like, uh, in a really raw way, in a really primitive way.

18:25.000 --> 18:39.780
You can see the four bytes, the first layer, the B -U-L-C, and then two bytes, the M-P-D-U, and then the biggest layer, which is the A-P-D-U, which is, uh, a lot of bytes, two, four, five, six, nine bytes, okay?

18:42.000 --> 18:51.380
So, if you want to read a property identifier and an object identifier inside that thing, you need to send a packet that looks like this.

18:52.440 --> 19:01.200
You will see the service choice, which is 12, properly configured, and then, uh, the object identifier.

19:01.200 --> 19:12.980
The object identifier is the only thing that I found as a security mechanism, because you cannot read or write without that value, uh, configured there.

19:13.260 --> 19:25.820
So, in this case, the device is using a 3,000, uh, string, uh, excuse me, um, uh, integer in order to, uh, execute, uh, functions.

19:25.820 --> 19:31.180
I mean, you can, you cannot execute something without that number specified in the packet.

19:31.440 --> 19:41.620
So, for example, if you try to write values there, and the value is not matching with this value 3,000 in the device, you are going to be able to, to write something.

19:41.620 --> 19:48.400
So, you need to first, uh, know this value in order to then, uh, write properly.

19:49.300 --> 19:54.180
Okay, let's

20:00.260 --> 20:08.820
develop, um, a tiny script in Python that perform all these things that I've been talking about.

20:09.680 --> 20:15.820
You can see the first, um, the first packet will be this thing.

20:16.300 --> 20:28.780
So, this thing, uh, is just asking for the object identifier, and then the second packet is asking for the vendor name, uh, the software version, and so on.

20:29.200 --> 20:33.780
So, it's like, uh, 7 functions.

20:34.020 --> 20:37.660
Each packet is for each function.

20:37.660 --> 20:39.600
So, let's see how it works.

20:42.670 --> 20:47.710
Let's open the wire shark in order to see the communication flow.

20:48.630 --> 20:51.950
Okay, you see, there is a filter for BACnet.

20:51.950 --> 20:53.550
I'm going to execute this.

20:56.320 --> 20:58.840
And you see the communication.

20:59.220 --> 21:03.220
Correctly, I'm, um, I'm performing communication with the device remotely.

21:03.220 --> 21:06.080
This is a real device connected to the internet.

21:06.600 --> 21:10.920
And, uh, I am, I'm asking him information regarding BACnet.

21:10.920 --> 21:15.820
Specifically, I'm asking him for, uh, his object identifier.

21:16.060 --> 21:29.640
You will see he, he ask me like, uh, yeah, my object identifier is 5,000, my vendor name, the firmware version, the description, the location, model name, application software, and other object name.

21:29.940 --> 21:35.300
All this information is printed here, on, on, in the output of my script.

21:36.800 --> 21:41.840
This is, uh, my quite shiller, a big shiller, for sure.

21:42.600 --> 21:45.180
And this is how the communication works.

21:45.220 --> 21:50.980
When you understand this, when you, in practice, are able to do this, you are ready to write values.

21:50.980 --> 21:52.840
But which values are interesting?

21:52.840 --> 21:55.520
I mean, what can I do with this?

21:55.520 --> 22:03.060
That was the first question when I tried to figure out, found something in the protocol and the web application.

22:03.560 --> 22:09.480
Uh, the beginning, my purpose of all this whole thing was not to find web application issues.

22:09.560 --> 22:13.860
Uh, was to figure out how to find something in the protocol itself.

22:13.860 --> 22:18.420
I mean, execute the stuff, but in the process I found something cool.

22:18.780 --> 22:20.840
And this is the result.

22:21.880 --> 22:24.840
Okay, this is how you can, uh, communicate with the devices.

22:24.840 --> 22:47.360
We just, with a simple script, as you can see, uh, all that I did was just read the documentation, understand how the protocol, uh, works, and then, uh, put it in code, in just a, a single socket connection, just sending row bytes, and then splitting the response in order to show,

22:47.360 --> 22:49.780
uh, the plain state data coming from the device.

22:49.800 --> 22:50.280
Okay?

22:50.280 --> 22:50.900
Cool.

22:51.800 --> 22:53.700
Let's continue with the thing.

22:55.620 --> 22:57.640
Okay, let's check out the response.

22:57.640 --> 23:06.700
At this point you will notice that the communication with by the, when the device is successful, also the response back contains a specific value for the object identifier.

23:06.700 --> 23:08.720
Remember that, that, that number.

23:08.760 --> 23:12.340
Keep this value in mind because we will use later in order to write.

23:12.720 --> 23:13.860
It's really important.

23:13.860 --> 23:28.310
Okay, now we know how to, okay, now we know how to read the specific values from the Bagnet data structure.

23:28.390 --> 23:31.970
But the cool thing is that we can modify those values.

23:32.530 --> 23:40.670
And also the same values are being taken from the application to represent the string values, I mean, in the, in the web application from N.

23:40.730 --> 23:42.230
So this is cool.

23:42.250 --> 23:50.290
Because what if we could, uh, make a modify these string values for pieces of code.

23:50.290 --> 23:53.210
Pieces of Java, uh, HTML or JavaScript code.

23:53.630 --> 24:03.850
In theory, this could be works or couldn't be, but at the beginning I had no place to test this because that was just in theory.

24:04.230 --> 24:13.330
I needed, uh, a real device connected to the internet with this scenario, uh, in order to prove that this thing works.

24:13.330 --> 24:17.210
And well, I found it and, and, uh, this is what it is.

24:18.590 --> 24:20.210
The write property is tricky.

24:20.210 --> 24:29.310
Sometimes objects are restricted to be modified, but most of the time the property value location is able to be modified from the Bagnet protocol.

24:30.770 --> 24:34.810
Um, well the thing, the same thing about the device ID.

24:37.290 --> 24:50.530
Okay, in order to write, the property, uh, tells you that you need mandatory, uh, specific values, like the object identifier, the property identifier, and the property value that you want to modify.

24:52.090 --> 24:57.490
So let's see how we can modify stuff.

25:02.480 --> 25:05.080
So this is a real thing.

25:06.520 --> 25:07.940
This is a real application.

25:07.940 --> 25:11.620
This is a real device, a MacQuietCheater connected to the internet.

25:12.360 --> 25:17.320
So, uh, when I found this, uh, it was the same impression as you.

25:17.320 --> 25:18.580
There is nothing there.

25:18.580 --> 25:25.700
I mean, it's not showing nothing, but if you right click on it and you check the source code, you will find Go.

25:25.800 --> 25:26.760
Why?

25:26.860 --> 25:31.140
Because here, first of all, there is a password.

25:31.240 --> 25:33.160
Um, let me check.

25:34.540 --> 25:37.240
Password for restart is 123.

25:38.280 --> 25:44.740
Yeah, this is out of scope today, but was a kind of, uh, nice, nice thing to find.

25:45.920 --> 25:53.000
And then, if you take a look closer to this thing, you will find something really cool.

25:55.020 --> 25:59.780
Ah, zoom in.

26:00.020 --> 26:01.060
Yeah, yeah, yeah.

26:02.360 --> 26:04.160
Let me see.

26:19.820 --> 26:21.920
Yeah, that's it.

26:23.240 --> 26:25.860
Okay, let's take a look at the password again.

26:25.860 --> 26:27.000
The funny part.

26:31.920 --> 26:35.040
Okay, there is a password for restart, 123.

26:35.680 --> 26:37.720
Uh, but here you cannot see any.

26:37.720 --> 26:41.180
I mean, on the main page you won't see any.

26:41.180 --> 26:44.500
You just need to check the source code in order to find cool things.

26:44.500 --> 26:48.160
But there was another thing that took my attention in the first place.

26:48.360 --> 26:50.960
The thing that is interesting here is this.

26:51.580 --> 26:52.680
The location.

26:52.940 --> 26:55.320
The location is Las Vegas.

26:55.440 --> 26:58.980
Well, I put this for, uh, demo purposes.

26:59.480 --> 27:06.240
But here, uh, I'm going to do this with, uh, this thing.

27:06.960 --> 27:10.000
This is, uh, Magnet Client.

27:10.660 --> 27:13.240
And you can do this from here.

27:13.720 --> 27:18.600
And now I change the location, the value from the location, right?

27:19.980 --> 27:24.220
So, if I reload this thing, I can see

27:27.600 --> 27:27.600
.

27:28.760 --> 27:37.390
Okay, there you go.

27:37.450 --> 27:39.370
Now let's check again the source code.

27:39.370 --> 27:43.910
And you will see how the location has changed by IOT.

27:45.950 --> 27:49.910
You see, now we are in IOT village.

27:50.030 --> 27:54.290
So, I did this from Magnet protocol.

27:54.510 --> 27:57.090
Uh, the device has no security.

27:57.090 --> 27:59.310
Actually there is no access for it.

27:59.310 --> 28:05.050
But I have access to the, to the protocol itself in order to modify stuff in the web application.

28:05.950 --> 28:10.190
So, now this is, this become a nice vector attack.

28:10.450 --> 28:16.770
A nice vector attack for, um, HTML or JavaScript code injection.

28:17.410 --> 28:18.910
And we are not using verb.

28:18.910 --> 28:19.990
That's the cool thing.

28:21.090 --> 28:24.970
Okay, so, now we know how to write.

28:26.130 --> 28:28.910
And now let's break it down, the exploit.

28:33.110 --> 28:38.350
Okay, the application is taking values from Magnet to be represented as string values in the web application.

28:38.630 --> 28:44.490
Those values can be modified from the Magnet data structure using the Magnet protocol write capabilities.

28:44.830 --> 28:50.370
And good theory is, I replace the string values for JavaScript code, the JavaScript code will be executed.

28:50.370 --> 28:52.510
Just in theory, at that time.

28:53.090 --> 28:57.730
Open up the source code, check again the value of location tag in the device.

28:58.050 --> 29:00.470
And our goal will be the following.

29:01.070 --> 29:03.830
Replace this thing for JavaScript code.

29:03.830 --> 29:10.430
And the result will be an stored, uh, crosshead scripting in the device web application in those tags.

29:10.750 --> 29:15.370
There is no need for a special XSS payload, a single alert in script tags.

29:15.370 --> 29:17.990
It's in order to figure the crosshead scripting.

29:18.510 --> 29:24.130
So, um, the application probably is password protected.

29:24.290 --> 29:28.650
So, as you can see, actually you don't need to touch it at all.

29:28.930 --> 29:36.970
This kind of cool because I, I, I didn't did any special, I mean with the web application actually was not touched at all.

29:37.050 --> 29:38.710
Everything comes from the Magnet.

29:40.430 --> 29:42.350
But as I said, no problem.

29:42.450 --> 29:44.670
Magnet is available to inject code.

29:48.080 --> 29:52.920
And now we know we should place our exploit.

29:53.100 --> 29:54.780
So let's see the demo.

29:55.580 --> 29:57.760
I have a video because, you know.

30:09.840 --> 30:10.660
Okay, here we go.

30:10.660 --> 30:11.940
The same device.

30:16.980 --> 30:19.720
And first of all, read, of course.

30:19.820 --> 30:21.480
You will see the location.

30:22.240 --> 30:23.100
It's Vegas.

30:23.860 --> 30:26.760
Uh, check again the source code as I did.

30:28.180 --> 30:29.780
You will see the tags.

30:33.820 --> 30:37.180
All this information can be modified to description.

30:37.620 --> 30:41.920
I mean, you have several places to put JavaScript code.

30:42.140 --> 30:43.320
That kind of thing.

30:43.940 --> 30:47.160
But the cool thing is, as I said, the, the location value.

30:48.180 --> 30:51.280
Now let's change Vegas for a cool payload there.

30:57.300 --> 30:59.940
Okay, everything is still fine.

31:02.620 --> 31:04.820
Now let's take a look to our exploit.

31:04.820 --> 31:08.660
So, our exploit would be this way.

31:08.700 --> 31:09.660
Uh, the same thing.

31:09.660 --> 31:14.060
The four bytes, uh, the two bytes for the second header.

31:14.140 --> 31:24.280
And the APDU with the biggest header, which includes our, our payload, our JavaScript payload, but encoded in hex because it's going to be sent on the network.

31:24.580 --> 31:27.580
So, you just need to send that.

31:27.900 --> 31:30.780
Don't expect a reply or anything because it's UDP.

31:31.200 --> 31:35.400
And the values are going to be injected in the web application.

31:41.280 --> 31:45.180
So, okay, now I just send the exploit.

31:47.320 --> 31:59.180
You will get the simple acknowledge reply from the device telling you that, you know, I received your packet and everything has been written, so you're good, you're good to know.

32:04.100 --> 32:11.760
If you follow the UDP flow, you will see our payload there, our script alert payload there.

32:13.980 --> 32:18.240
And the acknowledgement from the device is expected.

32:19.880 --> 32:28.300
So, now if you reload, so there is your, uh, code executed in, in the web application.

32:28.680 --> 32:29.680
And it's persistent.

32:29.680 --> 32:33.340
I mean, this, this thing is going to be stored forever there.

32:33.480 --> 32:38.640
So, every time that someone connects to the device, it's going to, it's going to be, get infected, something.

32:42.380 --> 32:51.480
Okay, other things that you can do with this is, uh, for example, leak internal server routes.

32:51.480 --> 32:55.040
And you can see config object input that comes from the device.

32:55.040 --> 32:58.700
So, you have, uh, path leaks there.

32:58.920 --> 33:01.500
You can take advantage with Bagnet.

33:01.940 --> 33:08.660
And also, uh, check, uh, the, the device description for each, uh, profile.

33:08.660 --> 33:13.400
So, for example, this was, uh, elevator, free machine room temperature.

33:13.540 --> 33:20.840
So, you can enumerate what exactly which specific device does in the device.

33:21.260 --> 33:27.580
So, conclusions for this part, the techniques allow you to inject JavaScript without touching the web application at all.

33:27.720 --> 33:31.060
This, uh, JavaScript protocol base injection technique.

33:31.360 --> 33:36.080
In this particular scenario, we don't need credential or access to the web application.

33:36.100 --> 33:38.920
You just need to inject the payload and say goodbye.

33:39.000 --> 33:43.460
Several protocols are also affected by this kind of issues.

33:43.820 --> 33:52.240
But, you know, I can, uh, publish everything in one, in, in one talk.

33:52.260 --> 34:02.380
Uh, several Bagnet, several Bagnet devices with the port 47808 are vulnerable to be modified remotely using this Bagnet protocol.

34:04.180 --> 34:08.840
And the number of current devices affected is unknown, at least for me.

34:08.920 --> 34:12.300
Always, there are probably new technologies affected.

34:12.480 --> 34:14.640
There are several tools to read and write.

34:15.260 --> 34:19.740
If you're spreading issues, try to reproduce, try to reproduce the vulnerability this way.

34:19.740 --> 34:22.520
Check your backlinks or operation code.

34:22.560 --> 34:29.180
So, finally, the bonus track, uh, this is something that I found a couple of months ago.

34:29.960 --> 34:42.340
It's, uh, basically, uh, an RSC vulnerability and those devices from this brand called Forfait.

34:42.340 --> 34:47.280
So, Forfait is a Chinese brand of industrial devices.

34:48.160 --> 34:59.760
Uh, they manufacture a lot of stuff with, um, 3G, 4G, industrial routers, Zigbee, LoRa, a lot of that thing that is related to industrial stuff.

35:00.240 --> 35:04.460
And, of course, they have, uh, devices connected to the internet.

35:05.080 --> 35:11.200
Uh, I found something really cool here, which is, uh, an option to execute commands.

35:12.080 --> 35:26.560
At first place, you would think, okay, it's just put the command there, put a netcat inside, and probably you would, you could get a reversal back, but that doesn't work, so I need to figure out how to execute code there.

35:26.980 --> 35:31.100
And, there is an option here, and

35:34.200 --> 35:40.820
application, this option called commands, administration commands, and you will find this.

35:41.560 --> 35:43.500
Take a look.

35:44.940 --> 36:01.160
Okay, this box, this command shell, allows you to execute Linux commands, but as I said, if you try to execute a netcat or something like that for easy stuff, it won't work, won't work correctly.

36:02.040 --> 36:23.760
So, I had to figure out how to execute command here, commands here, and I found out, uh, this payload, this payload that create like a, um, descriptor or something, and then you will see the netcat command included here, pointing to my IP and my port.

36:25.900 --> 36:37.480
So, just copy that thing, paste there, copy, and run the command.

36:44.090 --> 36:44.630
Great.

36:44.630 --> 36:49.930
Now, I'm going to show you the , here you go, and you will see the shell back to me, remotely from the internet.

36:52.310 --> 36:53.670
And there you go.

36:57.840 --> 37:04.260
And also, you can perform a cat, you know, the same thing as usual, ATC, password, and that's it.

37:04.820 --> 37:10.620
Well, this kind of issues are always in those kind of devices, it's the same thing all the time.

37:11.380 --> 37:16.740
Uh, it's really, really easy to spot RCEs, um, I don't know.

37:17.280 --> 37:20.160
The thing continues, I mean, the research continues.

37:22.320 --> 37:25.260
Well, I think that is done for today.

37:25.260 --> 37:27.640
Any question or something, just let me know.

37:27.660 --> 37:37.220
This is my Twitter, if you want to follow me, I always publish in stuff related to this kind of, uh, IoT stuff, OT stuff, ICS stuff, so, thank for your time.

37:37.500 --> 37:38.300
Welcome.

