[00:00.000 --> 00:05.980] All right, everyone, thank you for coming to our talk. It's named Extending Zeke for ICS Defense. [00:06.720 --> 00:11.080] My name is Norman Lunt. As the slide shows you, I'm a security enthusiast. [00:11.440 --> 00:18.400] I love PCAPs, and I love the defense side of this game, [00:18.400 --> 00:22.320] where if I can find you anywhere, we'll get you out. [00:24.680 --> 00:30.800] Hey, I'm James Dickinson, and as the slide shows, I'm also a security enthusiast. [00:30.800 --> 00:37.260] And much like Norm, I enjoy PCAPs and packets that are placed inside of PCAPs. [00:40.700 --> 00:44.580] All right, so to start us off, we're going to talk about some fundamental definitions [00:44.580 --> 00:50.080] in case anybody doesn't know. I'm just going to refer to them by their acronym names and not by [00:50.080 --> 00:57.740] their full names as it suits me. So ICS stands for Industrial Control System. PLC is Programmable [00:57.740 --> 01:05.340] Logic Controller. HMI for Human Machine Interface. And NSM stands for Network Security Monitoring. [01:06.160 --> 01:14.420] All right, so who cares about ICS data, right? It seems in the NSM world, ICS is just an [01:14.420 --> 01:19.880] afterthought. Nobody cares, gives a good doggone about what's happening on Modbus or what's [01:19.880 --> 01:26.660] happening on DMP3 or what's happening with all your Siemens PLCs. So what happens, I [01:27.240 --> 01:32.660] downloaded the most recent version of Zeek, and I built it from source, and I discovered [01:32.660 --> 01:40.480] that three out of 72 out-of-the-box analyzers were for ICS. And I went online, I poked around, [01:40.480 --> 01:47.380] and the Survey of Security Tools for the Industrial Control System Environment said, [01:47.380 --> 01:52.980] the survey identified tools such as Bro, which is what Zeek used to be called, Snort and Yara, [01:52.980 --> 01:57.460] which are by design highly extensible. Enough so that with minor development, they could be [01:57.460 --> 02:09.630] used as ICS solutions for which there's no current tool set. So every year, more and more devices [02:09.630 --> 02:19.830] are exposed to attack. And the people who want ICS in their systems, a lot of times they don't [02:19.830 --> 02:24.790] care about security because they haven't been hacked or they haven't gotten to a point where [02:24.790 --> 02:29.630] they need security. And so they'll be advised and say, hey, you know what, if we expose this [02:29.630 --> 02:32.870] internet, we're probably going to get in trouble. And they're like, I don't care, it's not [02:32.870 --> 02:39.430] affecting my bottom dollar yet, just push it, just push it, just push it. And so from Security [02:39.430 --> 02:44.910] Week.com, this is a report from 2017, they used Shodan, Synthesis and Google search engines [02:44.910 --> 02:50.510] and they identified over 170,000 ICS components accessible from the web. And it was a 10% [02:50.510 --> 02:55.350] growth from 2016 to 2017. I don't know what it is currently, but I don't think it got less. I [02:55.350 --> 03:02.770] don't think they're like, you know what, we better not put more ICS stuff out there because, you [03:02.770 --> 03:10.750] know, so why this is really relevant is programmable logic controllers or ICSs in general [03:10.750 --> 03:16.450] aren't fault tolerant. Like if at any point you send your data out of order or a malformed packet [03:16.450 --> 03:20.190] or something just doesn't hit right, it just crashes. And sometimes it crashes in a state [03:20.190 --> 03:24.630] that's unrecoverable. Unrecoverable in the sense that you can't do it remotely where somebody has [03:24.630 --> 03:29.130] to physically drive out there and power cycle it or physically go out there and replace it [03:29.130 --> 03:36.970] because it's broke so hard. And so why this, so this is also what happened. I was talking to a [03:36.970 --> 03:40.970] guy, this is the whole reason we have this talk, and he was a fellow security researcher and he [03:40.970 --> 03:46.610] said, he said, you have ICS data on your network. And I told him, no, I don't. He says, you do, [03:46.610 --> 03:51.330] go find it. And so after he and I left this conference, I went back and I found this ICS data. [03:51.330 --> 03:55.830] I found these attacks coming in and I didn't have a convenient way to figure out what was [03:55.830 --> 04:00.790] happening with them. I saw the data, I could see the raw bytes, but I didn't know what they meant, [04:00.790 --> 04:04.850] I didn't know what they were doing. And I thought, this is probably a problem for everybody. Like, [04:04.850 --> 04:10.270] how do I explain to my customer, hey, you know what, you, you know, foreign IP tried to hit you [04:10.270 --> 04:15.530] 400,000 times to turn off your PLC. I mean, none of them were successful, of course, but it doesn't [04:15.530 --> 04:21.350] stop the attacks. So I would like to turn my time over for James to explain to you the Purdue model [04:21.350 --> 04:30.830] and how Zeek works. Yeah, so the Purdue model's been around for a while, 1970-ish, I think. [04:31.370 --> 04:38.350] And really what it is, it's just a way to describe how these ICS systems tie into the business [04:38.350 --> 04:44.510] network. So if you look at this, you can see down here at level zero, you have the physical devices [04:44.510 --> 04:52.570] that are actuating physical processes. So these are things like pumps, sensors, belts, things like [04:52.570 --> 04:58.710] that. And then level one here, you have the control devices that are controlling those physical [04:58.710 --> 05:04.850] processes. And then as you work your way up the network, you get up to the business analytics [05:04.850 --> 05:10.810] portions that are consuming this data to be used for making business decisions and risk decisions, [05:10.810 --> 05:17.350] right? And so what we're talking about is defense, right, of the network. And so what we want to [05:17.350 --> 05:24.370] look at is the basic stuff that you do with any network, figuring out where to do segmentation [05:24.370 --> 05:30.610] and where to create those security boundaries to isolate that data and protect it, right? And so [05:30.610 --> 05:37.130] if you look here, we have some notional firewalls that are in this diagram, right? And so those are [05:37.130 --> 05:41.730] some good places to place spans or taps or what have you, however you're going to monitor this [05:41.730 --> 05:52.450] network, um, to capture that data and see what is going on. So why did we choose Zeek as opposed to [05:52.450 --> 06:00.870] some other tool for using to monitor and defend ICS data? A couple reasons. Um, Zeek is open [06:00.870 --> 06:05.330] source, so that means it's freely available for anyone to use and it has a very active, uh, [06:05.330 --> 06:10.610] development community. It's also very well documented. There's tons of white papers, talks, [06:10.610 --> 06:17.750] and, uh, uh, whatnot to go look at. Additionally, Zeek comes with a turn complete scripting [06:17.750 --> 06:24.770] language. The Zeek scripting language is event driven and it's purpose built for network [06:24.770 --> 06:31.410] communications. Um, so it's a, it's a great tool for building additional detections on top of, [06:31.410 --> 06:39.250] uh, and other, and tying it into your other systems. Um, additionally, it has the ability to [06:39.250 --> 06:44.350] create custom parsers. So that's what we're talking about today. Um, so you can go into Zeek [06:44.350 --> 06:51.450] and modify it for your purposes and build a parser to monitor the protocols that you want to, [06:51.450 --> 06:57.970] that you care about. Additionally, Zeek is fully extensible because of the scripting language and [06:57.970 --> 07:02.430] all the other stuff and all the other tools, uh, the community has built. It's very easy to [07:02.430 --> 07:07.030] plug into your existing network and get those logs into your sim or to do some sort of active [07:07.030 --> 07:16.760] defense with. So creating parsers, um, we sort of took two approaches here, right? You need to [07:16.760 --> 07:23.160] write your own or you can find someone else's and we sort of did both. Um, so the protocol we [07:23.160 --> 07:31.000] chose to write our own on is, uh, EtherNet IP and SIP. EtherNet IP, uh, is the session layer [07:31.000 --> 07:38.600] particle for SIP, which is the common industrial protocol. Additionally, um, we went around and [07:38.600 --> 07:45.960] tried to find what other tools and things people had done and, uh, this researcher, uh, [07:45.960 --> 07:53.920] Dane Wolin wrote, uh, S7 protocol that we also used. Uh, I should say S7 is the protocol that's [07:53.920 --> 08:04.570] used for Simmons PLCs. So creating a Zeek parser. So we aren't going to dive into the deep, [08:04.570 --> 08:10.390] nitty gritty details, but we'll cover it over, uh, sort of a high level overview. Um, so first [08:10.390 --> 08:17.770] thing you need to do is go grab Zeek, right? So you can go to GitHub, find Zeek and just get [08:17.770 --> 08:23.270] clone that sucker and you'll have it there. Additionally, other things you want to do, um, [08:23.270 --> 08:29.370] Vlad, who's a member of the Zeek developer community, has this BINPACK quick start script. [08:29.370 --> 08:34.530] It's just a Python script. What that will do for you is it'll create the boilerplate, uh, files [08:34.530 --> 08:40.110] and code that you need to get started writing a protocol. And then after that, you need to [08:40.110 --> 08:46.330] write a protocol. Uh, Zeek protocols are written in a high level language called BINPACK. And [08:46.330 --> 08:54.210] so BINPACK is purpose built for, uh, describing protocols. Um, and so you're just going to [08:54.210 --> 09:00.050] describe the structures in the protocol and then you're going to tie that into the events and, [09:00.050 --> 09:05.930] uh, at a high level that's what's going on. And then after that, you're going to run it and [09:05.930 --> 09:12.400] it's probably not going to work and you're just going to keep iterating. So this is what [09:12.400 --> 09:22.180] BINPACK looks like. Um, so you can see here we have a couple different things going on. So this [09:22.180 --> 09:28.940] top level structure here is the ethernet IP header that the two protocols we just mentioned [09:28.940 --> 09:35.160] use. And we are describing the different values and where they lie in that structure. So for [09:35.160 --> 09:40.700] instance, it has a command value that will tell, uh, that describes what the command is that [09:40.700 --> 09:47.260] is coming across the wire. And then the length variable just says, hey, expect this much data [09:47.260 --> 09:55.120] in the, uh, SIP, in the SIP PDU that's to follow. And then so on and so forth. And then right [09:55.120 --> 10:01.700] below that, uh, we have a case statement. And the case statement is just saying, uh, whether [10:02.560 --> 10:10.080] the data is from the originator or the responder. And so in this case, uh, and then it's just [10:10.080 --> 10:15.700] passing it to another data structure here. Either e- ethernet IP request or ethernet IP [10:15.700 --> 10:22.700] response. And then finally, down here at the bottom, we have the ethernet IP request. And [10:22.700 --> 10:28.480] here we're calling, uh, another case statement for the command value that's up in the [10:28.480 --> 10:34.640] ethernet IP header. And so we're just looking at what value is in there to identify what the [10:34.640 --> 10:41.140] command is. And then passing that along further into the protocol, uh, structure. So in a [10:41.140 --> 10:46.420] nutshell, that's how BINPACK works. There's a little bit more with it in terms of then getting [10:46.420 --> 10:52.220] those events into the script layer. But, uh, that's, that's a, that's our quick five minute [10:52.220 --> 11:02.210] intro to BINPACK. Alright, so I'm gonna cover, cover what we did with that data. The, so [11:02.210 --> 11:10.270] off of, what's that thing? That, oh. So off of eBay, years ago, James had bought a Siemens PLC. [11:10.590 --> 11:16.250] And we're like, hey, you know, let's, let's blow this thing up, see what happens. And so, as [11:16.250 --> 11:23.110] far as the S7 protocol parser goes, I, I took a good hand to it for about 35 hours and then, and [11:23.110 --> 11:27.570] then realized somebody else had done all the work and felt dumb. And load it up and it worked [11:27.570 --> 11:32.870] great. So, first thing we did, so after that, when we decided, hey, let's break into this thing [11:32.870 --> 11:38.350] and blow it up, the, it didn't have an IP and we couldn't figure out how to give it an IP. So [11:38.350 --> 11:42.030] eventually we landed on the Siemens software portal. At one point, Siemens had sent us an [11:42.030 --> 11:44.810] email saying they couldn't verify we were American and they wouldn't let us download any of [11:44.810 --> 11:50.430] their software. We downloaded, we finally got this one called the TIA portal and we set the IP [11:50.430 --> 11:55.370] on the PLC. And it seems like this one liner, like, download the software, set the IP, right? [11:55.370 --> 12:03.970] This is like 30 hours into our project. The next thing I found is there was a, this guy, Dark [12:03.970 --> 12:08.550] LBP, he doesn't, I don't, I don't know any more data than that from his GitHub. He created this [12:08.550 --> 12:13.630] thing called ICSploit. It's a creative use of Scapey and Python to create custom attacks on [12:13.630 --> 12:18.850] PLCs. And it already has pre-built attacks for S7. So that worked fantastic. And he calls it [12:18.850 --> 12:24.310] ICSploit because it has a Metasploit style interface. But it, it's good if you just wanna, [12:24.310 --> 12:31.010] you know, if you wanna blow up your own PLCs from eBay. Then I started Wireshark. I [12:31.010 --> 12:37.510] captured data off my NIC. Then I ran the attacks. And then I took that data, fed it into Zeek [12:37.510 --> 12:45.110] that was running our S7 parser and we produced Zeek logs. So what this is, is this is ICSploit [12:45.110 --> 12:51.650] giving me data back, right? So this is a scanning style attack. And you can tell it what rack and [12:51.650 --> 12:59.270] what slot, etc. And it said it found these two vulnerable spots. Slot 0 and slot 1. The IP we [12:59.270 --> 13:08.870] set for our Siemens PLC was 192.168.38.200. The, so this is what, as an attacker you say, oh [13:08.870 --> 13:13.870] look, there's some stuff. I got, I got some data. There's, you know, so this is say, here's [13:13.870 --> 13:18.750] where I launched my attacks. This order code on there will give, you know, if you go and [13:18.750 --> 13:23.830] search, it gives you insight about what type of PLC it is. And this is what Zeek looks like. [13:23.830 --> 13:27.030] There's three type of logs represented here. The con log, which is your connection log, your [13:27.030 --> 13:33.670] S7 setup communication log, and on the bottom your S7 user data log. Now, the first field there [13:33.670 --> 13:37.970] is your, is your UID. And Zeek is really important because your UID ties all your different [13:37.970 --> 13:43.050] logs together. And so all the blue logs go with blue logs and yellow logs go with yellow logs. [13:43.050 --> 13:47.530] And if they aren't highlighted, it's because they were scanned and nothing returned. So you [13:47.530 --> 13:52.470] can see in the, in the column just before it says SRSTR, everywhere where it has zero means [13:52.470 --> 13:57.130] there was zero bytes returned. So it got, it got no, no return. So on my big scan, those are [13:57.130 --> 14:00.430] the ones that didn't return, which is why they're not highlighted. They're included just to [14:00.430 --> 14:06.770] say, hey, I scanned more than just that one area. So in the, then in the 7 setup con log, it [14:06.770 --> 14:11.710] shows you there was a call for a job. The job was acknowledged. And then the user data, it [14:11.710 --> 14:17.210] sends these SLS, SZL requests and response. And one of the things about Siemens PLCs is [14:17.670 --> 14:22.130] it doesn't matter what kind of protections you have on them, you can, you can still read, you [14:22.130 --> 14:28.130] can send read requests to the SZL and it'll respond to you every time. You may not be able to [14:28.130 --> 14:35.380] do any much more after that, but at least you know that you have a live target. The next thing [14:35.380 --> 14:41.400] I did is we tried to turn it on and off. So as you can see here, the command description, 1 to [14:41.400 --> 14:48.840] start the PLC or 2 to stop the PLC. So I set the slot to 1 because that's, that's the slot that [14:48.840 --> 14:54.120] was vulnerable. I set the command to 1 and then I ran it. And then it, then as you can see, [14:54.120 --> 14:59.420] running module, target is alive, sending packet to target, start PLC. So me as the attacker say, [14:59.420 --> 15:04.860] oh cool, the, the PLC started. And then I changed the command to stop it and this is, oh okay, [15:04.860 --> 15:10.100] the PLC stopped now. Now, turning on and off, right, doesn't seem like a major attack, right? [15:10.100 --> 15:15.320] You turn PLC, you turn it on, you turn it off, big whoop. So a couple years ago, one of the [15:15.320 --> 15:19.900] national labs had this giant generator just like, I don't know, like a billion kilowatts. I don't, [15:19.900 --> 15:23.600] it's not that high. I don't know how much it was. It was a giant, it was large. And they turned it [15:23.600 --> 15:28.720] on and off rapidly. Bum, bum, bum, bum. And it blew up because they started it and stopped it [15:28.720 --> 15:33.360] and started it and stopped it and it blew the heck up. And so, so maybe not a catastrophic [15:33.780 --> 15:39.020] explosion to kill everybody in the plant, but it's significant enough to require, who knows [15:39.020 --> 15:43.580] the amount of down time to get the heavy equipment in there to replace that generator. And, [15:45.480 --> 15:51.020] and besides like, any time your PLC just take rogue, wild turn on and off statements, like it's [15:51.020 --> 15:57.860] ridiculous. It should never happen. Here's what we have. I split it up in two parts. The top [15:57.860 --> 16:02.700] part I call turn on and the top, bottom part I call turn off. And again, it's the same, the [16:02.700 --> 16:06.740] first two logs are the same. Your con log, which is your connection log, then your setup [16:06.740 --> 16:11.880] communication, and then the bottom one that's new for this type of, of log source is your PLC [16:11.880 --> 16:19.320] function. So, main thing in your connection log, data was, was processed. It went, you got [16:19.320 --> 16:24.140] bytes to and from. Then you have the job and the job was acknowledged in the setup, in the, [16:24.140 --> 16:28.560] yeah, the setup communication. And the last part, it calls this program called P program and [16:28.560 --> 16:33.460] then it says empty. Because we didn't actually have a program in there. We, uh, we did, but [16:33.460 --> 16:40.560] we deleted it out. Our PLC wasn't connected to anything during this, during this setup. We, [16:40.560 --> 16:45.060] uh, I was just happy that we could turn it on and turn it off. And the turn off is the exact [16:45.060 --> 16:50.120] same. There's data in the connection log. We have the communication. There's a job. We [16:50.120 --> 16:58.080] acknowledge the job. And then it stopped. PLC stopped. And so, so how this is relevant to an [16:58.080 --> 17:02.000] analyst is rather than just seeing raw data on the wire, just bits, they're trying to figure [17:02.000 --> 17:08.320] out, like, if it was UDP and like DNS, if, if I give an analyst raw DNS, they could probably [17:08.320 --> 17:13.740] tell me what the IP it came from, what the IP requested it, what the IP was returned, because [17:13.740 --> 17:18.520] they know that. They live in that space. The TCP IP stack is, is daily stuff, right? But if I [17:18.520 --> 17:23.880] say, hey, here's some raw bytes from a PLC turn off command for an S7 protocol. And the [17:23.880 --> 17:29.840] analyst is like, yeah, that's cool, bro. You know, I, I hope it's not broke. Generally, right? [17:29.840 --> 17:35.720] In general, like, because we're not a PLC shop, but maybe if you have a PLC shop, you have guys [17:35.720 --> 17:41.480] dedicated just to Siemens PLCs and just to Allen Bradley PLCs and just only guys who study [17:41.480 --> 17:54.000] Modbus, right? Does anybody, is that a thing? It is? No, no, no. Where you have a Modbus guy on [17:54.000 --> 18:02.760] the network analyzing only Modbus data and he's like. So, so that's what we had. Those are [18:02.760 --> 18:10.560] attacks we ran. We scan and we turned it off. And I will now turn the time over for, to James [18:10.560 --> 18:18.620] for our conclusion. So, we're blue team guys, right, through and through. We enjoy finding [18:18.620 --> 18:24.560] bad guys. We enjoy seeing them attack our networks and then null routing their stuff. That's, [18:24.560 --> 18:30.720] that's what we do, right? So, uh, I think from our perspective, we think this stuff's really [18:30.720 --> 18:36.540] cool. We hope you guys think it's cool too. Um, we encourage you, if you think it's cool, to go [18:36.540 --> 18:42.940] look at Zeek, uh, maybe contribute, write some parsers of your own. And then additionally, uh, [18:42.940 --> 18:47.580] if you have guys have novel detections you can think of, uh, Zeek's a great tool to build [18:47.580 --> 18:53.520] detections in. And, uh, I think that's all we have. Yeah, does, are there any questions? Does [18:53.520 --> 19:00.340] anybody care to know more about my PCAP? Alright, thank you guys. Thanks.