[00:00.000 --> 00:05.740] Hey everyone, as you start moseying in, we're going to have Bertin. He is an independent security researcher. [00:05.780 --> 00:09.640] He's going to talk to you guys about industrial protocols. It's going to be a really fun talk. [00:09.640 --> 00:14.960] I hope you all enjoy it. And yeah, as you start moseying in, I see the camera guy has given me [00:14.960 --> 00:20.640] the okay. We'll just start kicking things off. So please give Bertin a warm welcome and everyone [00:20.640 --> 00:32.670] enjoy themselves. Thanks. Okay, cool. Hello everyone. Welcome to my talk. This is about [00:32.670 --> 00:42.110] um, well, as the title says, mixing industrial protocols with web application floss. In order [00:42.110 --> 00:48.870] to exploit devices in the internet. Which is a thing that I used to do all the time for like uh, [00:48.870 --> 01:02.350] ten years ago. I mean, something really crazy. Um, let me, that too. Okay, here we go. So okay, [01:02.350 --> 01:15.700] oh, why is it so fast? There it is. So fast. Okay. Okay, hello, uh, my name is Bertin, as uh, [01:15.700 --> 01:21.540] they present me. Uh, this is my tutor. I'm uh, working as a security consultant. Uh, [01:21.540 --> 01:27.860] professionally in network engineering, security research, device security, protocol security, [01:27.860 --> 01:33.700] uh, basically all of my uh, research is based in remote exploitation all the time. I mean, [01:33.700 --> 01:39.380] all the things that I do is remote. And always, all the devices that I use to exploit are [01:39.380 --> 01:47.660] connected to the internet. All the time. Okay, agenda for today, uh, the motivation for this [01:47.660 --> 01:54.080] research, how it started, how I found this, and how I developed exploit and all this stuff. [01:54.340 --> 02:00.240] Uh, I'm gonna be talking about modern, modern magnet devices. The security problem in those [02:00.240 --> 02:07.780] devices. And then I'm going to be explaining how to use magnet protocol itself as an attack [02:07.780 --> 02:13.000] vector for this kind of devices. Uh, the fundamentals for magnet, because in order to [02:13.000 --> 02:17.240] understand this, we need to recap all the things about magnets, how it works, how it's [02:17.240 --> 02:23.020] designed, and all this stuff. The theory and the technique, and the exploits and the [02:23.020 --> 02:28.360] conclusions. At the end, uh, there is a bonus track that I decided to include in this talk. [02:28.360 --> 02:37.100] It's an RCE, an, uh, industrial router. Yeah, that's critical, as usual. So, the motivation [02:37.100 --> 02:44.640] about this. There is a lot of fun, a lot of fun, in industrial protocol security. Usually you [02:44.640 --> 02:52.400] can, uh, on off things, uh, start stuff, uh, start and stop stuff, read critical data, uh, [02:52.400 --> 02:59.620] modify critical data, inject malicious data, execute malicious stuff, and so on. All these [02:59.620 --> 03:06.440] remotely, from your home, from your, I mean, your hotel room, everywhere in the world. So, I [03:06.440 --> 03:12.620] start playing around with many of them, of these protocols, visible for search engines. And [03:12.620 --> 03:20.020] some of them are invisible. That is a fun fact that many researchers, uh, ignore, because they [03:20.020 --> 03:26.040] think that current, uh, search engines are indexing all the industrial protocols. No, but that [03:26.040 --> 03:32.160] is not true. Because, uh, there are a lot of new technology, there are new, there are a lot of [03:32.160 --> 03:40.400] new devices with proprietary protocols. And these protocols are based usually in UDP TCP. So, you [03:40.400 --> 03:47.340] can, of course, scan the internet for these, uh, new protocols, and, uh, have some fun with [03:47.340 --> 03:55.560] them. So, uh, please, uh, keep in mind that thing, that there are security, I mean, there are [03:55.560 --> 04:01.460] industrial security protocols, or industrial protocols that, uh, are not being indexed by [04:01.460 --> 04:07.920] current search engines, like Shodan or Sumai. And people don't know that. So, the following [04:07.920 --> 04:13.000] is the result of hours of reading documentations, analyzing servers in the internet, and [04:13.000 --> 04:18.500] testing on common things, trying to find out new paths for remote injection and web [04:18.500 --> 04:26.620] application services for specific devices using the BACnet protocol. Okay, BACnet previous [04:26.620 --> 04:32.960] research. There are a lot of talk about BACnet. I mean, um, several talks about that. You can [04:32.960 --> 04:39.220] find out, uh, it's always the same thing, like, uh, on, off, start, stop attacks. Uh, we know [04:39.220 --> 04:44.600] that there is no security in this protocol. It's basically plain text. Uh, there is no [04:44.600 --> 04:52.300] authentication method. Um, you can perform, actually, BACnet network scans remotely to the [04:52.300 --> 04:59.980] BACnet topology infrastructure. No web applications issues find, found, until today, in [04:59.980 --> 05:06.960] this talk. I was, uh, trying to figure out if someone else, years before, tried to do [05:06.960 --> 05:12.500] something that I, uh, am going to show you today, but I had no luck. So, basically, this is [05:12.500 --> 05:18.360] something new. Okay, today, I am introducing a new attack vector in BACnet devices. This is [05:18.360 --> 05:25.200] remote. And last night, I found another brand affected by this, curiously. So, this is a [05:25.200 --> 05:29.940] travel touch thing. I mean, there are several brands affected by this thing, but I don't [05:29.940 --> 05:34.980] know, and we don't know exactly which they are. We need to find out. Um, you don't need tools [05:34.980 --> 05:40.440] to do this. It's just a simple script. It's a crafted attack, very, very crafted attack. It's [05:40.560 --> 05:47.340] a stealth, uh, UDP base, and you can get persistence. And finally, code execution in [05:47.340 --> 05:54.360] browser, which is really cool. This thing doesn't work here. I mean, we're talking about web [05:54.360 --> 06:00.240] application, but this thing is not capable of, uh, find these kind of things. So, if you [06:00.240 --> 06:05.620] think that this is the thing, you are wrong. I'm gonna prove that today. So, please, keep in [06:05.620 --> 06:12.140] mind that this thing doesn't work here. It's not prepared, yet. Okay, so, brands affected by [06:12.140 --> 06:17.720] this issue, discovered until now, this is a traversal issue, as I mentioned. The first, uh, [06:17.720 --> 06:25.900] brand is called RLE Technologies. This is a brand who manufactures devices for industrial [06:25.900 --> 06:32.840] purposes. Uh, protocol converters, industrial routers, blah, blah, blah. They can, which, I [06:32.840 --> 06:38.460] don't know which is the relationship with MyQi, which is a Hong Kong company. Uh, they are [06:38.460 --> 06:45.000] using the same kind of server in both, uh, brands. So, they have, uh, one device here and [06:45.000 --> 06:48.820] another device here, and they are using the same technology, so they are affected by the same [06:48.820 --> 06:55.280] issue. Two brands, uh, using the same technology. There is another brand which is not [06:55.280 --> 07:00.120] included here, that I found last night, which is called KMC Controls. It's affected by the [07:00.120 --> 07:08.800] same, but it was found last night, so, it's, uh, new. Okay, this is the, the first device that, [07:08.800 --> 07:15.280] uh, I was able to exploit with this thing. Everything started here with this thing, the RLE [07:15.280 --> 07:22.500] protocol converter. Uh, what this, this thing does is, uh, trying to, well, actually, not [07:22.500 --> 07:28.500] trying to, okay, it converts, uh, Bagnet protocol to Modboost protocol. This is a protocol [07:28.500 --> 07:34.240] converter. When you don't have, um, a way to communicate with devices, this thing helps you [07:34.240 --> 07:40.020] to, uh, modify this kind of protocol conversion, and you will be able to reach devices through [07:40.020 --> 07:48.280] this thing. Okay, the devices affected by this issue are this one, graphically, uh, Daikin [07:48.280 --> 07:56.260] and McQuay. They, uh, manufacture chilling, big chilling, big chillers, chillers, that's it, [07:56.260 --> 08:01.840] chillers. And those devices are connected to the internet, they have a web application in order [08:01.840 --> 08:09.840] to, uh, manage, configure, set up the whole thing. And things are just getting bigger and bigger. [08:10.780 --> 08:17.200] Okay, uh, this is an example of a Bagnet topology, how a Bagnet topology is, is, um, [08:17.200 --> 08:26.920] deployed in infrastructure. So our goal today is, or an attacker goal, is, uh, infect the [08:27.820 --> 08:33.340] engineer web browser. Why the engineer web browser? Because he's going to be connected to [08:33.340 --> 08:40.340] these kind of devices in every time. So usually those engineers, or these technicians, has [08:40.340 --> 08:47.980] access to another, uh, set of devices. So if we are able to, uh, execute code in their machine [08:47.980 --> 08:53.160] browser, probably we could steal, uh, other things that could be more interesting in, in this [08:53.160 --> 08:59.060] kind of, uh, particular attacks. Uh, we're talking about like an APT attack or some kind of [08:59.060 --> 09:09.440] thing, I don't know. But if you get persistent and the technician machine, you could probably, [09:09.440 --> 09:13.960] uh, steal other more critical devices in that infrastructure, or probably another, uh, more [09:13.960 --> 09:22.000] critical computer. This, this idea that I have with this. Okay, this is, this is taken from the [09:22.000 --> 09:32.540] Bagnet.org tutorial, um, basically the, the official documentation from Bagnet. And there is a [09:32.540 --> 09:39.420] little note, uh, about security. Because when I started this, I was, you know, interested in, [09:39.420 --> 09:45.880] uh, how the security of this thing works. But I found this. So there is a little discussion of [09:45.880 --> 09:51.240] security in this presentation. We have assumed that all nodes are trusted. Security will [09:51.240 --> 09:57.340] obviously be an important future consideration. For now, assume that all devices are sitting [09:57.340 --> 10:01.420] behind a firewall. That does packet filtering and the environment has well implemented [10:01.420 --> 10:07.380] restrictions on the software that can run inside a firewall. This is all the thing that this [10:07.380 --> 10:13.380] guy said about Bagnet security. You can find out in, in, in that link. This is all that you [10:13.380 --> 10:17.940] will have, uh, that you will find about, uh, security implementations and the protocol [10:17.940 --> 10:24.840] itself. So it means that there is no authentication methods. There is nothing, uh, to protect [10:24.840 --> 10:30.180] the, the protocol itself if there is no, uh, firewall, uh, very well implemented. And [10:30.180 --> 10:36.380] infrastructure. So our goal today will be the following. Uh, remote attacker from the [10:36.380 --> 10:44.840] internet, uh, has access to the device, but has no access to the web application. But has [10:44.840 --> 10:52.820] access to the Bagnet protocol. And he can read and modify things using just the protocol. So [10:52.820 --> 10:58.800] let's start with the Bagnet specs. In comparison with the OSI layers, uh, the Bagnet works [10:58.800 --> 11:06.360] in the application and network layer. And of course, IP. IP protocol. So let's start with the [11:06.380 --> 11:16.340] Bagnet protocol. It's, uh, the port is 47808. It's UDP based. No complex security mechanism, [11:16.340 --> 11:23.920] as, as I said. No CRC, no integrity checks, no hash, blank text, read write capabilities, and [11:23.920 --> 11:29.480] it's completely open in the internet. You just need to perform a query in some extensions and [11:29.480 --> 11:36.360] you will find out that, um, there are a lot of devices connect, connected. Okay, uh, so [11:36.380 --> 11:44.680] the Bagnet structure is basically Bagnet, Bagnet IP. The first layer would be the VUVLC or [11:44.680 --> 11:52.940] Bagnet virtual local control. The third layer, the second layer would be the MPDU, uh, [11:52.940 --> 11:59.780] network protocol data unit. And the last layer would be the application data unit, which [11:59.780 --> 12:06.360] contains all the information that we need to inject to the device. The magic happens there. [12:06.980 --> 12:13.120] Okay, let's talk about the first layer, the Bignot, Bagnet virtual link control. It's [12:13.120 --> 12:20.840] basically two bytes. Oh, excuse me, four bytes. It's four bytes. The first byte defines the [12:20.840 --> 12:28.960] type. In this case, Bagnet IP, which is, um, A1 and hex. The second one defines the [12:28.960 --> 12:35.640] function. In this case, uh, which function we, we would like to execute in, in, in the [12:35.640 --> 12:41.940] communication. And the last two bytes define the length of the whole packet. So you need to [12:41.940 --> 12:49.100] sum the three layers and put the result in that first layer in order to create a correct, uh, [12:49.100 --> 12:55.240] Bagnet packet. And then send it to, to the network and get the response. If that number is [12:55.240 --> 13:02.500] not correct, uh, you will get a more firm packet. So it's not going to work. This is a [13:02.500 --> 13:07.440] graphical representation in Wireshark about the first layer. The Bagnet virtual link [13:07.440 --> 13:15.260] control. You can see the function. This is our original unicast, unicast communication. And [13:15.260 --> 13:24.280] the two bytes are the length. Then we have the Bagnet network protocol data unit. This is a [13:24.280 --> 13:30.740] representation according to Bagnet wiki, but in practice it's just two bytes. Like this. So [13:30.740 --> 13:37.080] it's just telling you the version that you need to use and the control. So in this case, we [13:37.080 --> 13:45.020] set up the, the byte to four. Which means we are expecting reply from the device. So if you [13:45.020 --> 13:51.340] don't configure this control byte, uh, you probably, you could, uh, you can, you can get the [13:51.340 --> 13:55.620] reply back to you. If it's not properly configured. So you need to read the documentation [13:55.620 --> 14:03.160] and start constructing the packet byte by byte. And the last header is the Bagnet application [14:03.160 --> 14:12.380] data unit. Uh, this thing, uh, is the last header and contains, uh, variable length that also [14:12.380 --> 14:18.520] should be specified in that, in that header. Otherwise, you will face, uh, more phone packet [14:18.520 --> 14:25.600] issues again. This is how it looks like in Wireshark. Uh, this is a graphical representation [14:25.620 --> 14:33.720] of Wireshark. One important thing here is, uh, the service choice. The service choice is the, [14:33.720 --> 14:42.380] the byte that allows you, uh, read or write things in the Bagnet device. Okay? The magic is [14:42.380 --> 14:48.200] in the APU header that allows you to read or write values in the Bagnet data, uh, structure. [14:49.920 --> 14:57.380] Okay, here's what I'm talking about, the Bagnet service choice. So, you have all those values [14:57.380 --> 15:04.060] and bytes that allows you to set up how the communication is gonna be executed. So, in this [15:04.060 --> 15:11.580] case, we're gonna be using, uh, the 12 number value, which is 0C and hex, in order to read. [15:11.580 --> 15:19.020] Just read. Right? In order to read write, you need to set up correctly the service choice [15:19.020 --> 15:24.740] byte. At this point, probably you're thinking, you're taking a look into the 14 byte, because [15:24.740 --> 15:34.400] the 14 byte here, allows you to, uh, restart the device. If you send that byte, uh, the device [15:34.400 --> 15:39.340] will just restart. But we're not gonna be talking about this today, but keep in mind that this [15:39.340 --> 15:49.000] can be possible. Just sending a single packet to the network. So, in order to read, we'll be, [15:49.000 --> 16:00.700] and for write, it would be 0F. That's it. This is how, uh, a read packet looks like. You will see [16:00.700 --> 16:09.840] the read property configured there, and the number 12 in decimal. Okay, the values that we [16:09.840 --> 16:16.200] need to read and write will be the Bagnet objects. A Bagnet object is, uh, unique in a given [16:16.200 --> 16:24.180] device. It's a combination, uh, with many, uh, properties. Specifically, when you create a [16:24.180 --> 16:33.780] device in a Bagnet device, it means that every sensor, every in-out output, input output, will [16:33.780 --> 16:40.040] be created in a single device. This device has a name, and this device has, uh, his own [16:40.040 --> 16:46.180] properties. Every, every sensor in the Bagnet device has this, uh, segmentation, like, uh, [16:46.960 --> 16:56.380] specific, uh, may I compare this with, uh, profiles, would be kind of a specific profile, and [16:56.380 --> 17:04.500] the property of each profile can be modified, remodeled. Okay, the object identifier [17:04.500 --> 17:10.020] contains the property identifier. Basically, the string values represent the unary and [17:10.020 --> 17:15.100] readable strings like location, device model, device name, and so on, in a few words, or [17:15.100 --> 17:23.880] targets today. So, in this case, we are reading, uh, that specific object, the object [17:23.880 --> 17:30.260] identifier, which is a property identifier. It's kind of confusing, but one thing is upon the [17:30.260 --> 17:39.880] other. A property identifier has an object identifier. So, if you see, this is encoded as a [17:39.880 --> 17:46.080] character string. The object name, uh, the location name, application software version is [17:46.080 --> 17:54.040] character string. There are several tools available you can use, uh, in order to read and write [17:54.040 --> 17:59.740] values with Bagnet. There are a lot of Bagnet clients, uh, but the purpose of this thing is go [17:59.740 --> 18:05.960] deep and do this without tools in order to understand exactly how it works. Uh, you can do [18:05.960 --> 18:13.740] this with any language that supports socket communication. Okay, let's take a look how this [18:13.740 --> 18:22.720] looks like in execution. So, this is an example of how our read package looks like, uh, in a [18:22.720 --> 18:28.300] really raw way, in a really primitive way. You can see the four bytes, the first layer, the [18:28.300 --> 18:34.060] 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, [18:34.060 --> 18:44.800] which is, uh, a lot of bytes, two, four, five, six, nine bytes, okay? So, if you want to read a [18:44.800 --> 18:50.420] property identifier and an object identifier inside that thing, you need to send a packet that [18:50.420 --> 18:59.580] looks like this. You will see the service choice, which is 12, properly configured, and then, uh, [18:59.580 --> 19:05.540] the object identifier. The object identifier is the only thing that I found as a security [19:05.540 --> 19:13.740] mechanism, because you cannot read or write without that value, uh, configured there. So, in [19:13.740 --> 19:24.200] this case, the device is using a 3,000, uh, string, uh, excuse me, um, uh, integer in order to, uh, [19:24.200 --> 19:29.480] execute, uh, functions. I mean, you can, you cannot execute something without that number [19:29.480 --> 19:36.160] specified in the packet. So, for example, if you try to write values there, and the value is not [19:36.160 --> 19:41.620] matching with this value 3,000 in the device, you are going to be able to, to write something. [19:41.620 --> 19:54.180] So, you need to first, uh, know this value in order to then, uh, write properly. 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:18.600] You can see the first, um, the first packet will be this thing. So, this thing, uh, is just [20:18.600 --> 20:25.820] asking for the object identifier, and then the second packet is asking for the vendor name, uh, [20:25.820 --> 20:36.820] the software version, and so on. So, it's like, uh, 7 functions. Each packet is for each [20:36.820 --> 20:45.470] function. So, let's see how it works. Let's open the wire shark in order to see the [20:45.470 --> 20:53.550] communication flow. Okay, you see, there is a filter for BACnet. I'm going to execute this. [20:56.320 --> 21:02.340] And you see the communication. Correctly, I'm, um, I'm performing communication with the [21:02.340 --> 21:08.520] device remotely. This is a real device connected to the internet. And, uh, I am, I'm asking [21:08.520 --> 21:15.820] him information regarding BACnet. Specifically, I'm asking him for, uh, his object identifier. [21:16.060 --> 21:23.380] You will see he, he ask me like, uh, yeah, my object identifier is 5,000, my vendor name, the [21:23.380 --> 21:28.440] firmware version, the description, the location, model name, application software, and other [21:28.440 --> 21:37.720] object name. All this information is printed here, on, on, in the output of my script. This is, [21:37.720 --> 21:45.460] uh, my quite shiller, a big shiller, for sure. And this is how the communication works. When [21:45.460 --> 21:50.980] you understand this, when you, in practice, are able to do this, you are ready to write values. [21:50.980 --> 21:57.000] But which values are interesting? I mean, what can I do with this? That was the first question [21:57.000 --> 22:04.180] when I tried to figure out, found something in the protocol and the web application. Uh, the [22:04.180 --> 22:10.600] beginning, my purpose of all this whole thing was not to find web application issues. Uh, was to [22:10.600 --> 22:16.640] figure out how to find something in the protocol itself. I mean, execute the stuff, but in the [22:16.640 --> 22:23.480] process I found something cool. And this is the result. Okay, this is how you can, uh, [22:23.480 --> 22:29.280] communicate with the devices. We just, with a simple script, as you can see, uh, all that I did [22:29.280 --> 22:36.320] was just read the documentation, understand how the protocol, uh, works, and then, uh, put it [22:36.320 --> 22:44.840] in code, in just a, a single socket connection, just sending row bytes, and then splitting the [22:44.840 --> 22:52.240] response in order to show, uh, the plain state data coming from the device. Okay? Cool. Let's [22:52.240 --> 22:58.560] continue with the thing. Okay, let's check out the response. At this point you will notice [22:58.560 --> 23:03.560] that the communication with by the, when the device is successful, also the response back [23:03.560 --> 23:08.980] contains a specific value for the object identifier. Remember that, that, that number. Keep [23:08.980 --> 23:13.860] this value in mind because we will use later in order to write. It's really important. [23:13.860 --> 23:25.990] Okay, now we know how to, okay, now we know how to read the specific values from the [23:25.990 --> 23:33.530] Bagnet data structure. But the cool thing is that we can modify those values. And also the [23:33.530 --> 23:38.930] same values are being taken from the application to represent the string values, I mean, in the, [23:38.930 --> 23:45.590] in the web application from N. So this is cool. Because what if we could, uh, make a [23:45.610 --> 23:53.210] modify these string values for pieces of code. Pieces of Java, uh, HTML or JavaScript code. [23:53.630 --> 24:01.450] In theory, this could be works or couldn't be, but at the beginning I had no place to test this [24:01.450 --> 24:09.510] because that was just in theory. I needed, uh, a real device connected to the internet with this [24:09.510 --> 24:15.590] scenario, uh, in order to prove that this thing works. And well, I found it and, and, uh, [24:15.610 --> 24:22.390] this is what it is. The write property is tricky. Sometimes objects are restricted to be [24:22.390 --> 24:28.090] modified, but most of the time the property value location is able to be modified from the [24:28.090 --> 24:38.490] Bagnet protocol. Um, well the thing, the same thing about the device ID. Okay, in order to [24:38.490 --> 24:44.530] write, the property, uh, tells you that you need mandatory, uh, specific values, like the [24:44.530 --> 24:50.530] object identifier, the property identifier, and the property value that you want to modify. [24:52.090 --> 25:07.940] So let's see how we can modify stuff. So this is a real thing. This is a real application. [25:07.940 --> 25:13.880] This is a real device, a MacQuietCheater connected to the internet. So, uh, when I found [25:13.880 --> 25:19.200] this, uh, it was the same impression as you. There is nothing there. I mean, it's not [25:19.200 --> 25:24.920] showing nothing, but if you right click on it and you check the source code, you will find [25:24.920 --> 25:35.280] Go. Why? Because here, first of all, there is a password. Um, let me check. Password for [25:35.280 --> 25:43.800] restart is 123. Yeah, this is out of scope today, but was a kind of, uh, nice, nice thing [25:43.800 --> 25:52.140] to find. And then, if you take a look closer to this thing, you will find something really [25:52.140 --> 26:24.560] cool. Ah, zoom in. Yeah, yeah, yeah. Let me see. Yeah, that's it. Okay, let's take a look [26:24.560 --> 26:36.240] at the password again. The funny part. Okay, there is a password for restart, 123. Uh, but [26:36.240 --> 26:42.320] here you cannot see any. I mean, on the main page you won't see any. You just need to check [26:42.320 --> 26:46.400] the source code in order to find cool things. But there was another thing that took my [26:46.400 --> 26:53.160] attention in the first place. The thing that is interesting here is this. The location. The [26:53.160 --> 27:03.860] location is Las Vegas. Well, I put this for, uh, demo purposes. But here, uh, I'm going to do [27:03.860 --> 27:14.840] this with, uh, this thing. This is, uh, Magnet Client. And you can do this from here. And now I [27:14.840 --> 27:23.140] change the location, the value from the location, right? So, if I reload this thing, I [27:23.160 --> 27:40.790] can see. Okay, there you go. Now let's check again the source code. And you will see how the [27:40.790 --> 27:52.830] location has changed by IOT. You see, now we are in IOT village. So, I did this from Magnet [27:52.830 --> 28:00.170] protocol. Uh, the device has no security. Actually there is no access for it. But I have access [28:00.170 --> 28:07.190] to the, to the protocol itself in order to modify stuff in the web application. So, now this is, [28:07.190 --> 28:15.790] this become a nice vector attack. A nice vector attack for, um, HTML or JavaScript code [28:15.790 --> 28:24.190] injection. And we are not using verb. That's the cool thing. Okay, so, now we know how to [28:24.190 --> 28:35.250] write. And now let's break it down, the exploit. Okay, the application is taking values from [28:35.250 --> 28:39.670] Magnet to be represented as string values in the web application. Those values can be [28:39.670 --> 28:44.950] modified from the Magnet data structure using the Magnet protocol write capabilities. And [28:44.950 --> 28:49.630] good theory is, I replace the string values for JavaScript code, the JavaScript code will be [28:49.630 --> 28:55.750] executed. Just in theory, at that time. Open up the source code, check again the value of [28:55.750 --> 29:02.590] location tag in the device. And our goal will be the following. Replace this thing for [29:02.590 --> 29:07.190] JavaScript code. And the result will be an stored, uh, crosshead scripting in the device [29:07.190 --> 29:14.590] web application in those tags. There is no need for a special XSS payload, a single alert in [29:14.590 --> 29:22.290] script tags. It's in order to figure the crosshead scripting. So, um, the application probably [29:22.290 --> 29:29.110] is password protected. So, as you can see, actually you don't need to touch it at all. This [29:29.110 --> 29:34.830] kind of cool because I, I, I didn't did any special, I mean with the web application [29:34.830 --> 29:41.470] actually was not touched at all. Everything comes from the Magnet. But as I said, no [29:41.470 --> 29:53.420] problem. Magnet is available to inject code. And now we know we should place our exploit. So [29:53.420 --> 30:11.940] let's see the demo. I have a video because, you know. Okay, here we go. The same device. [30:16.980 --> 30:24.900] And first of all, read, of course. You will see the location. It's Vegas. Uh, check again the [30:24.900 --> 30:35.960] source code as I did. You will see the tags. All this information can be modified to [30:35.960 --> 30:44.120] description. I mean, you have several places to put JavaScript code. That kind of thing. But [30:44.120 --> 30:50.100] the cool thing is, as I said, the, the location value. Now let's change Vegas for a cool [30:50.100 --> 31:05.760] payload there. Okay, everything is still fine. Now let's take a look to our exploit. So, our [31:05.760 --> 31:12.760] exploit would be this way. Uh, the same thing. The four bytes, uh, the two bytes for the [31:12.760 --> 31:20.000] second header. And the APDU with the biggest header, which includes our, our payload, our [31:20.000 --> 31:26.040] JavaScript payload, but encoded in hex because it's going to be sent on the network. So, you [31:26.040 --> 31:32.580] just need to send that. Don't expect a reply or anything because it's UDP. And the values are [31:32.580 --> 31:48.100] going to be injected in the web application. So, okay, now I just send the exploit. You will [31:48.100 --> 31:54.360] get the simple acknowledge reply from the device telling you that, you know, I received your [31:54.360 --> 32:05.120] packet and everything has been written, so you're good, you're good to know. If you follow [32:05.120 --> 32:15.540] the UDP flow, you will see our payload there, our script alert payload there. And the [32:15.540 --> 32:24.820] acknowledgement from the device is expected. So, now if you reload, so there is your, uh, [32:24.820 --> 32:30.820] code executed in, in the web application. And it's persistent. I mean, this, this thing is [32:30.820 --> 32:36.100] going to be stored forever there. So, every time that someone connects to the device, it's [32:36.100 --> 32:44.400] going to, it's going to be, get infected, something. Okay, other things that you can do with [32:44.400 --> 32:53.460] this is, uh, for example, leak internal server routes. And you can see config object input [32:53.460 --> 33:00.360] that comes from the device. So, you have, uh, path leaks there. You can take advantage with [33:00.360 --> 33:08.900] Bagnet. And also, uh, check, uh, the, the device description for each, uh, profile. So, for [33:08.900 --> 33:16.220] example, this was, uh, elevator, free machine room temperature. So, you can enumerate what [33:16.220 --> 33:23.860] exactly which specific device does in the device. So, conclusions for this part, the techniques [33:23.860 --> 33:28.340] allow you to inject JavaScript without touching the web application at all. This, uh, [33:28.340 --> 33:33.220] JavaScript protocol base injection technique. In this particular scenario, we don't need [33:33.220 --> 33:37.920] credential or access to the web application. You just need to inject the payload and say [33:37.920 --> 33:48.480] goodbye. Several protocols are also affected by this kind of issues. But, you know, I can, uh, [33:48.480 --> 33:55.000] publish everything in one, in, in one talk. Uh, several Bagnet, several Bagnet devices with [33:55.000 --> 34:04.780] the port 47808 are vulnerable to be modified remotely using this Bagnet protocol. And [34:04.780 --> 34:10.080] the number of current devices affected is unknown, at least for me. Always, there are [34:10.080 --> 34:15.620] probably new technologies affected. There are several tools to read and write. If you're [34:15.620 --> 34:20.160] spreading issues, try to reproduce, try to reproduce the vulnerability this way. Check your [34:20.160 --> 34:26.260] backlinks or operation code. So, finally, the bonus track, uh, this is something that I [34:26.260 --> 34:39.160] found a couple of months ago. It's, uh, basically, uh, an RSC vulnerability and those devices [34:39.690 --> 34:48.900] from this brand called Forfait. So, Forfait is a Chinese brand of industrial devices. Uh, [34:48.900 --> 34:56.160] they manufacture a lot of stuff with, um, 3G, 4G, industrial routers, Zigbee, LoRa, a lot of [34:56.160 --> 35:03.020] that thing that is related to industrial stuff. And, of course, they have, uh, devices [35:03.020 --> 35:09.560] connected to the internet. Uh, I found something really cool here, which is, uh, an option [35:09.560 --> 35:15.520] to execute commands. At first place, you would think, okay, it's just put the command there, [35:15.520 --> 35:22.300] put a netcat inside, and probably you would, you could get a reversal back, but that doesn't [35:22.300 --> 35:31.100] work, so I need to figure out how to execute code there. 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:53.280] Take a look. Okay, this box, this command shell, allows you to execute Linux commands, but as I [35:53.280 --> 35:59.840] said, if you try to execute a netcat or something like that for easy stuff, it won't work, won't [35:59.840 --> 36:07.400] work correctly. So, I had to figure out how to execute command here, commands here, and I found [36:07.400 --> 36:18.240] out, uh, this payload, this payload that create like a, um, descriptor or something, and then [36:18.240 --> 36:27.620] you will see the netcat command included here, pointing to my IP and my port. So, just copy [36:27.620 --> 36:44.630] that thing, paste there, copy, and run the command. Great. Now, I'm going to show you [36:44.650 --> 36:52.790] the, here you go, and you will see the shell back to me, remotely from the internet. And [36:52.790 --> 37:01.920] there you go. And also, you can perform a cat, you know, the same thing as usual, ATC, [37:01.920 --> 37:08.840] password, and that's it. Well, this kind of issues are always in those kind of devices, it's [37:08.840 --> 37:16.740] the same thing all the time. Uh, it's really, really easy to spot RCEs, um, I don't know. [37:17.280 --> 37:25.260] The thing continues, I mean, the research continues. Well, I think that is done for today. [37:25.260 --> 37:29.480] Any question or something, just let me know. This is my Twitter, if you want to follow me, I [37:29.480 --> 37:36.280] always publish in stuff related to this kind of, uh, IoT stuff, OT stuff, ICS stuff, so, thank [37:36.280 --> 37:38.300] for your time. Welcome.