Hello, everybody. Thank you for coming. This is There and Back Again, which is all about discovering OT devices across protocol gateways. My name is Rob King. There's my face if you want to see it twice. It's right there. So let's talk about how did we get here? So when we talk about OT, we talk about ICS, we talk about SCADA, we often think about these super cool looks like from the 1990s or maybe 80s with a good budget sci-fi thing with a control room and uniforms and bleepy things and all that. And that is part of it and it's super great. This is a control room from I think it's a refinery in Germany, but it's from Wikimedia, so very nice of them. But what we're really talking about as well and what we tend to kind of abstract away from as security practitioners is the fact that we're still talking about these machines that actually do things in the real world. They spin, they pump, they flap, they poke, whatever it is they do. And so we need to talk about how we actually control those devices. And by the way, we've got 43 slides to get through in 25 minutes, so I believe in you. So we're going to go fast. So industrial control technology. So it started with, you know, somebody having to stand there and push a button and pull a lever and read things off, you know, read symbols off things and then type or whatever, which is a horrible job that no one should ever have to do. And so we thought maybe we should automate this a bit more. So we came up with this concept of simple electronic logic. So we say, okay, that's a major improvement. We can have things that aren't just simply repeated over and over, but you can have a little bit of, you know, if then or do this three times and then do something else and it's all great. But those devices, those controllers were connected to the machines that were being controlled. If you needed to change something or check on something, you had to physically walk over there and, you know, like a pilgrim and touch things, right? Push buttons, do all that. Still a major improvement, but not particularly efficient. And then so someone had this great idea of what if we make the wires that connect those controllers longer? And we put all of the controls and the dials and everything all in one spot. This was the concept of distributed control systems. And so you put everything in one room and so you can check on the state of your factory in a glance, right? And this was great. This was much more efficient. You still had to occasionally go out and check on things, but it made it easier to get an overview of the whole process. But it was still a problem in that each one of those, you know, dials or switches or gauges or whatever was linked more or less to one specific device, right? So you still had a lot of wiring and a lot of cabling. Cats and dogs living together in a mass hysteria, you know, all that. If you ever watched, if you're of a certain age, if you ever watched The China Syndrome, Jane Fonda, Jack Lemmon, both of them nominated for Oscars, great movie, a little alarmist, there was a problem where one of these mechanical gauges got stuck and we almost had a nuclear meltdown. The movie was released just before Three Mile Island, it was very prophetic. Anyway, so we're like, hey, what if we started putting things like these newfangled computers in there? Well, now I see your problem, there's a computer in there. But what happened was we started coming up with the idea of using this newfangled computer intelligence technology to make buses. So instead of having tons of wires running everywhere, there was enough intelligence in the end devices and the controller devices to send signals, multiplex signals over a single set of cabling, a single set of wires, right? This is actually, this is an example of the Hewlett Packard instrument bus, which this was back when Hewlett Packard made laboratory equipment and not printers that made you sad. And also fun note, this was adapted to be the bus for like the Commodore 64, Commodore PET, was also HPIV, just kind of adapted and slower. So you were doing lab science work every time you used your Commodore 64. But what was neat about this is there was enough intelligence that you could say, okay, I'm going to send a message and I want it to go to device number 8 or 7 or whatever. And the other devices knew not to respond to that message, right? And you only had to have one bit of wiring. Now, HPIV was, it was designed more for like bench scenarios, like laboratory equipment, oscilloscopes, cool stuff, science, but not large industrial things. There was a fairly short maximum cable length, that sort of thing. Wasn't designed for particularly noisy environments, all that. So Modicon came up with the idea of Modbus, which you've all heard of, and if you haven't, you're about to. And so that was actually the first Modicon PLC, which Modicon got bought out by, was it Schneider Electric? Somebody tell me. Schneider Electric, I think. Either that or Siemens, Schneider. Anyway, and the standard protocol for Modicon, Modbus, became controlled by an industry consortium. So it's kind of an open standard now, very simple, but allowed this concept of a bus architecture in an industrial environment. So you could say, okay, and this is a little bit more modern, this is talking about Modbus TCP, but the principle is the same. You can talk to lots of different devices by their address using a common protocol and more or less a common set of physical media. Made things a lot more efficient, a lot easier. But then, as time marches on, we started converging on IP and Ethernet. All of these protocols either predate IP and Ethernet becoming standard or predate them entirely, you know, take your pick, or predate them even becoming useful in the kinds of environments that industrial situations involve, like noisy electrical environments and vibration and things like that. So we started doing industrial Ethernet because it's a commodity, right? Ethernet, IP, commodity software, commodity technology, it's cheaper, it's easier to use, it's easier to integrate. This is fantastic, but it does lead to now you can have your industrial systems connected directly to the Internet, which is a bad thing. You really shouldn't do that, but this was just an example. I'm not going to harp on this too much. Other people have talked about IP convergence and security and OT, but just for the record, I really should not see these sorts of things when I do a public scan of the public Internet, but I do. So you should fix that. But the advantages of this convergence are undeniable, right? It makes it much easier to work with, makes it much easier to integrate into existing systems. But now that they're all connected, I want to discover these devices. I want to find them on the network. I've spent most of my career searching for devices, trying to find them, trying to fingerprint them. I love it. It's super fun. I'm a lot of fun at parties. So this is Modbus when they took Modbus and adapted it to TCP. So what they did quite literally was just put a framing header on the front so you knew how long the message was going to be and then they took the core of the Modbus protocol and shoved it on top of TCP and it works. It works fine. But it's not ‑‑ it was never designed to really be supporting discovery. They kind of assumed that if you've got your factory, you should know what's in your factory, right? Well, factories have gotten bigger, technology has gotten bigger, shadow IT, we now have shadow OT, so it's good to know what's actually going on. And then this is just to give you an example, this is literally explaining how they're shoving it into the TCP data segment. It's just the entire Modbus message plus some framing. It's treated as a normal TCP stream. There's no magic. But Modbus as a protocol is very simple, which is not surprising. It was created in, I think, 1978, so it's about as old as I am and I'm, you know, not very smart. So it can do things like read a register. Please give me the number that's in register, you know, 2 or whatever. And you get that back. But that's all you get. There's not a lot of meta information, there's not a lot of self‑describing data, and that was on purpose, right? They don't want to waste the bandwidth. They don't want to waste the bits on the wire. It was much more important to have that maybe be error correction or something like that. So how do we identify a Modbus device? Well, this is the list, I know you're all like, wait, wait, there's one more, and I was like, yes, there is, but next slide. This is a list of all the possible ‑‑ all the standard function codes in Modbus. And you're like, okay, well, you know, maybe one of these can work. Like there's that report server ID down there, that seems useful. That only works on Modbus serial. Or occasionally on TCP, but it doesn't tell you much. It's just, yeah, my unit ID is 3. Which is, you know, great. I now know that your unit ID is 3. I still don't know what you are. Well, Modbus 1.1 in 2004, 6, something like that, gave us the idea of the encapsulated interface transport. So just like how they took Modbus and they shoved the entire thing inside TCP with some framing, they then shoved this entire sort of additional protocol that's much more complex entirely in the Modbus frame, the Modbus payload. Using opcode 2B, or not 2B. And one of the extended operations that they can do is read device identification. And read device identification, you can say, hey, you can see here that the function code is encapsulated interface transport, and then suddenly there's this new additional secondary opcode, MEI type, read device identification. And what that gets us back is much more information. Vendor name, product code, all sorts of useful things. And in fact, this is if your device supports MEI, it's required to at least support vendor name, product code, major or minor revision. Most devices also support vendor URL, product name, model name, all that good stuff. It's all exposed as objects because it was 2004 and everything had to be object oriented and there was probably, you know, somebody made a lot of money saying, oh, yes, object oriented Modbus, but it is, and it's kind of nice. So you can do that, and you can get all sorts of information automatically when you do this, which is very nice for discovering Modbus. But now let's talk about the second worst named, second most confusingly named protocol in this talk, which is distributed network protocol 3. Does anybody, just show of hands real quick, does anybody use DMP3? It's not super, okay, yeah, all right. So distributed network protocol 3 is a standard industrial protocol, but it's only, I don't want to say only, it's primarily used in utility distribution. So electricity, water, things like that. Super useful, I like having power, I like having water. DMP3 was designed later than Modbus, and so it has a much richer set of semantics. This beautiful diagram explains the level of, depending on how you want to look at it, complexity or sophistication of DMP3. DMP3 has its own framing, it has its own checksumming, it has its own transport layer, it has its own addressing scheme that's much more complicated than Modbus's addressing scheme. Modbus was just, hey, unit 23 on the shared bus, whatever, do this thing, maximum of 255 devices. This supports much, much more. But just like with Modbus where they took the Modbus protocol and just kind of plopped it on top of TCP, they really did that with DMP3. So DMP3, they didn't just take the user application layer or the transport layer or anything, they took the whole shebang, the whole kit and caboodle, and just plopped it on top of TCP. Which is great in that you can have a shared implementation and if you're wanting to talk across different physical media, it's all the same code and that's fantastic. But it also makes discovery of these devices a little problematic. So DMP3 devices, if they're on an IP network or they're speaking through an IP protocol gateway, they will have an IP address, as one does, but they will also have a DMP3 address. And also, also, on the gripping hand, they will only talk to their designated primary device. So when you configure a DMP, I mean, usually, it weighs around everything, but usually when you configure a DMP3 device, you say your primary is, you know, at DMP3 address 7 or whatever. And then it will only talk to that device. So if you connect to a DMP3 device via TCP, you will get basically nothing. You'll just get sort of an empty, you know, session, empty channel. And if you want to ask that device, you want to query that device for any information, you have to then construct an entire DMP3 transport layer message and application layer message and then send that across the wire with the appropriate destination address for the device you're talking to, but also you have to spoof the primary address. So that's a problem because there's, you know, 65,000ish, there's a couple of reserved ones. Addresses, it would take a long time to guess those. So what can we do about that? Well, I just said all that. Well, what we can do is there's banner sniffing for DMP3. Not a guarantee, and there's what's sad is the fallback is that you do have to enumerate the address space, but I'll cover that in a second. But most DMP3 devices, not all, not all, but most, when you connect to them via TCP, will send what's called an unsolicited response, which if you didn't solicit it, it's not a response, it's just a message, but I digress. But it will say, okay, you know, yeah, my clock is out of sync or here's the flags that have changed since the last time we talked or whatever, but the important thing is that's a full DMP3 message. It's got the entire transport layer in there as well, including the device's own address and the device that it's talking to, which is its primary. So you can say, oh, okay, well, great, now I know your address is whatever, because it's the source address, and I should pretend to be whatever the destination address was. Super useful. Doesn't always work. They don't always send these unsolicited responses. Sometimes they'll send them only if they haven't talked to the primary for five minutes. Sometimes they send them every time. Sometimes they never send them. But if you're doing DMP3 device discovery, sometimes you luck out and you just get one and it's great. But otherwise you have to go and enumerate the entire address space, which would take a really, really long time, because there's, you know, 65,000 possible combinations on the one end and the other end. The good news there is that most of those devices or most networks, they tend to put addresses at the lower end of the range. So really you're only talking about maybe the first 1,000 or so. You'll get at least a few hits. But it's not a guarantee. But anyway, once you've got that connection, once you've got that address guessed or determined or sniffed or spoofed or whatever, you can then get these DMP3 attributes. They're not quite standard, but they're pretty standard. And you can say, hey, give me your software version, your hardware version, your host name, all that good stuff. And there is, in fact, what you get. By the way, this was a lot of fun to set up. And when I say fun, I mean that I hated my life. But I got it working. So the lab was a mess, but I got it working. And you can discover DMP3. But now, let's move on. I said DMP3 was the second most confusingly named protocol we're going to talk about. The first most confusingly named, if you come from an IT background, is Ethernet IP. Because the IP does not stand for Internet protocol, it stands for industrial protocol. So when we talk about Ethernet IP, we are talking about Ethernet IP on top of IP on top of Ethernet and the two IPs means something different and one of the Ethernets doesn't actually mean Ethernet. So it's kind of a problem. But anyway, super fun. It's a very pretty protocol. I really like it. But I really like writing protocol parsers like I would do it if they didn't pay me. But they do pay me, which is great. So please keep paying me. Ethernet IP. So Ethernet IP is an adaptation of SIP, which is the common industrial protocol. Used to be an information protocol from Rockwell, but just like Modbus is now controlled by a consortium of whatever, SIP is now controlled by a consortium of whatever. I still don't know what ODVNA stands for. I cannot find it, but that's the name of the consortium. I'm assuming A is association, but I don't know. Anyway, SIP is an abstract protocol. Much like SNMP defines lots of encodings. You can use dir and bur and sir and all those. Which everyone out there who's ever worked with SNMP is like, no, no, please, stop talking about SNMP. ASN1, no. It's terrifying. But SIP has different adaptations to different protocols. So Ethernet IP is the SIP adaptation for IP networks, right? But there's also standard adaptations for combo net, control net, device net. There's one for CAN bus, you know, all this, right? But the point is, once you get there, you're talking this abstract protocol, which is defined as objects and messages, right? SIP defines the standard set of objects and messages and attributes on those objects. And so, but Ethernet IP is the lower level, right? You want to connect, or for an IP network. So you want to connect to a device that speaks SIP. You connect on an IP network via using Ethernet IP, and then you start talking SIP. But before you start talking SIP, you're talking Ethernet IP. And Ethernet IP provides a full device discovery mechanism right out of the box, super nice, it's great, called list identity. So list identity is, you can see it here, it's command list identity, and, oh, I want SIP identity, and then you get back, you know, Rockwell automation, Alan Bradley, program a logic controller, blah, blah, blah, blah, which is great. And you can send that via TCP, you can actually do that as a UDP broadcast, and devices will just respond and say, here I am. And that's great. Problem solved, right? We're Ethernet IP done? No, I say. Oh, and here's what it looks like when you connect. There's the devices you can pull. But I don't want just that device, because remember, we're talking about protocol adaptation. We're talking about multiple devices being adapted or having gateways to IP networks, right? What if we're talking about one of these racks where you've got an Ethernet IP adapter, and in that rack you've got a PLC and a motor controller and a thermal monitor and a spline reticulator and all that, and they're connected via some other back plane or some other transport protocol. Well, what I can do is I can connect via Ethernet IP to that Ethernet IP adapter, and one of the objects in SIP is a connection object. And another object in SIP is a connection manager object. And another object in SIP is an identity object. So if I just connect straight to the Ethernet IP adapter, and I say, hey, I want all of the attributes off of your identity object, I'll get back more or less what I got back from the list identity, just via Ethernet IP. But now I'm at SIP, it's a higher level of semantic meaning, whatever, but it's still more or less the same thing. But the magic that comes in is that you can then say, hey, connection object, please, or connection manager object, please get me a connection to the device at this other address, right? And what do you get? Well, now you can say, okay, it'll hand you back, it'll say, okay, great, here's a connection to this other device, or I can't make a connection , you know, whatever, there's an error. But you can now say, okay, I want you to forward this request to get all the identity attributes to this other object through that connection, and it will do so, and it will actually forward that theoretically recursively all the way down to this other object and then relay everything back up to you. And so now you can discover everything in the rack. It does use sort of, if you remember source routing, you actually do have to construct a path to get there. So how am I doing on time? Okay. So you can say, okay, I want to get all attributes from the identity object, you can see here, get attributes all, instance one, there's only ever one instance of an identity object. Port segment. So I'm trying to get slot 12 of this Rockwell RS links device on its back plane, please give me that. And what you get is voila, you get this. So what we have here is, here's the Ethernet IP adapter, and the PLC, and there's all these other devices. I want to discover all these other devices, because I'm not satisfied with just talking to this device, I want to know everything, right? And so that's what you get. You can say, hey, please walk through, please enumerate everything on the back plane recursively, give me a connection to this identity object, get all its attributes. Cycle through, give me a connection to that identity object, get all its attributes, on and on and on. Theoretically, even recursively, you have multiple connections, like one of these things could be another Ethernet IP adapter connecting to another rack, and you could still forward that on, and it might not be speaking Ethernet IP, it might be serial, it might be whatever. In fact, as you can see, down there at the bottom, you've got an RS232 connector, you've got a 24 volt DC magic thing that's probably making something cool happen in the real world, but the point is, you can use this to recursively discover everything in a SIP network. And I think I actually managed to finish on time. So thank you. If there's any questions, please, I'll be right here.