start	end	text
0	1500	So I guess we'll get started here.
1500	2600	Can you hear me okay?
2600	3780	Is the audio working?
3780	4660	Perfect.
5320	19000	So today we're going to talk about Common Industrial Protocol and just kind of an introduction how to get started if you want to do your own exploitation, maybe learning about the protocol, do some basic pen testing, that kind of thing.
20780	23880	So let's talk about what is CIP.
25740	33900	Common Industrial Protocol is a communications protocol used by industrial devices.
34440	37460	So you have things like programmable logic controllers.
37460	42020	These are the computers actually in your industrial facilities.
42020	43840	They're controlling your plant.
43840	51060	They're running the logic, opening and closing valves, turning pumps on and off, looking at sensors.
51060	60560	And a lot of PLC systems can communicate via CIP or they work with other devices in your plant that will use CIP.
60560	69760	So examples would be like variable frequency drives, which are the devices that control the speed of motors running in your plant.
70020	71640	You have things like motor starters.
71640	80280	These would be energizing motors, power monitoring systems, smart sensors and instruments, devices that open and close valves.
80280	86040	All of these devices can talk Common Industrial Protocol at one level or another.
86820	94500	Now with that, CIP isn't a typical protocol in the sense that we think of for network protocols.
94500	98520	It actually extends beyond your Ethernet networks in your plant.
99140	102960	So there is versions of CIP like DeviceNet.
102960	106420	DeviceNet uses a CAN bus based system.
106420	110340	There's ControlNet, which is coaxial based.
110520	112680	EtherNet IP, which is the Ethernet version.
113060	115660	And CompoNet, which we're not going to talk about because nobody cares.
118220	126820	So originally, it was developed by Allen Bradley, which is a company that builds a lot of industrial hardware, especially in the US.
126980	133260	The very first implementation of it was revealed in Chicago in 1994.
133260	139940	And it really opened up the world for what was possible bringing data onto the plant floor.
139940	143560	How to actually have smart devices in your plant.
143680	149040	Before then, you had primitive PLC systems that were all independent of one another.
149040	155400	There was a couple vendors playing around with some serial forms of communication, but it was slow and clunky.
155400	171380	And when DeviceNet came out, it opened you up to having very flexible installations of smart sensors and other types of devices than a PLC able to exchange data in your plant.
172060	177460	In 1997, they released ControlNet, coaxial based.
177460	182780	It's based on the 802.3b specification for its Layer 1.
182780	185700	So that's your old school coaxial Ethernet.
185700	189620	It uses the same type of Manchester signaling on the coax.
190160	192920	Later in 2000, EtherNet IP came out.
192920	197620	That's EtherNet Industrial Protocol, not to be confused with TCP IP.
198120	203400	And it utilizes both UDP and TCP for transport, multicast, unicast.
203400	207140	It's quite the interesting system.
207380	210100	Again, nobody cares about CompoNet.
210100	213760	So how does EtherNet IP actually work?
213760	215940	Let's talk about the SIP stack.
216560	220860	You have your TCP and your UDP.
221660	224380	You have an encapsulation protocol.
224380	228480	That's actually what is EtherNet IP, is that encapsulation protocol.
228920	233100	You have different types of messaging, implicit and explicit.
233100	236560	Implicit is just a device streaming information.
236620	239640	Explicit is a request and a response.
239640	241160	Single transactions.
241740	245100	You have CIP network and transport.
245100	251880	CIP is super unique in the sense that it was pre-EtherNet networks in the plant.
251880	257240	So they invented their own method for doing things like routing, doing things like CRC checks.
257240	265260	Everything that you take for granted that's handled for you at your EtherNet level, CIP has those mechanisms built into it as well.
265260	277040	So when running on EtherNet-based networks, yes, you're taking advantage of TCP routing, but you're also taking advantage of CIP's network capabilities such as CIP routing.
277580	281980	And then finally you have your application objects, your device profiles.
281980	292720	These are actual C++ objects executing in the firmware of these devices that CIP hooks into, and that actually gives you the functionality for the protocol.
292720	294240	And we'll talk about that.
295460	298100	Like I said, objects.
298100	300100	So what are CIP objects?
300100	308300	CIP objects are fascinating because CIP operates a lot like a remote procedure call type protocol.
308300	320960	You have objects in memory, in your firmware, and you have a class ID, and that ID number is a unique ID that references that C++ class.
320960	326160	You have instance IDs, and they represent the instances of those classes.
326360	327660	You have attributes.
327660	331200	Your attributes are variables within those objects.
331600	339120	And finally you have your services, which are actual functions in that object that you can call over the network.
339800	349780	All of these different things, your class, your instance, your attribute, your service, they're addressed by unique identifiers, integer-based identifiers.
349780	351300	So they're not using strings.
351300	352780	They're not using names.
353720	373140	When you send a CIP request, if I'm telling a device, hey, I want you to go turn this pump on, or I want you to energize 24 volts out to some device in the field, you do that with a CIP command that consists of what service you want to run, what class you're running it on,
373140	381100	what instance you're executing that service actually against, and then sometimes what attribute that service is going to operate on.
381100	384880	Maybe you're setting the value of a variable within that object.
386780	394640	So let's talk about probably the most common, the most basic CIP object, the identity class.
394640	400500	The identity class is instance ID 1, easy to remember.
400880	405480	It has a default instance of that class, ID 1.
405600	413100	And it supports a function, a service code of get all attributes, which is service 1.
413300	417560	So, easy message to remember, 1, 1, 1.
417560	421880	And that's going to tell you all the basic information about that device.
421880	425300	So, we call that the who message.
425960	430100	And in the who message, you're going to get things like the vendor of the device.
430300	441320	And you can see, or maybe not because it's kind of cut off here at the bottom, but on the bottom you can see this JSON payload here where I've sent a who message to a device using a Python tool.
441680	447180	And it's returned to me the vendor, the product type, the firmware revision.
447180	449200	It's returned to me the device status.
449200	449940	Is it running?
449940	450740	Is it faulted?
450740	453100	Is it in some kind of configuration mode?
453600	456840	It's told me the serial number of the device.
457400	462580	It's told me the actual product name, the string of the device, which is on the end over here so you can't see it.
464820	470940	The who message retrieves all the information about the device from the identity object.
470940	477060	And just like the identity object exists, there's hundreds of CIP objects within these devices.
477060	479580	And all of them have a very specific purpose.
479720	485860	They have very specific services which retrieve data out of them, or they perform functions within that object.
486280	492260	And all of these objects all together make up your CIP protocol.
492420	494940	So, different devices will have different objects.
494940	499960	The core specification says which ones you're required to have, which ones are optional.
499960	504740	And most vendors throw all that out the window and just say we're going to implement whatever we want.
504980	510020	And so you're really up to the vendor to tell you what objects exist and why they exist and how to use them.
510020	512160	And generally they don't like giving up that information.
514580	521960	So, if we want to actually talk to one of these devices, access these CIP objects, there's three ways to do this.
521960	526720	There's three forms of what we call explicit communication.
526720	531180	That's where we're doing a request and we get a response from the device.
531540	533220	There is UCMM.
533280	536400	That's your Unconnected Message Manager.
536820	546760	And what that means, we talked about how CIP has its own mechanisms for things like routing and other network services that TCP already provides.
547060	552520	So, UCMM, that's kind of similar to saying, hey, I don't need a session.
552520	557120	That's saying, you know, kind of like you're sending out a UDP request and getting it back.
557120	559240	That would be the equivalent in networking terms.
559240	565100	Now, this is over TCP, but I'm creating a CIP request without a CIP session.
565100	567120	And I'm saying, hey, do this thing.
567120	568160	Send me the data back.
568160	570060	There's no CIP routing involved.
570060	572740	There's no other CIP networking mechanisms involved.
572740	575140	It's the most simple type of request.
575660	580360	Then there's unconnected messaging, unconnected requests.
580360	583920	Unconnected means I'm creating a CIP session.
583920	585360	I'm creating a request.
585360	592620	I'm using all of the capabilities of CIP routing, but I'm only going to do it for a single request.
592780	596000	And so both sides know, hey, we spent all this effort.
596000	598440	We set up a CIP route.
598440	600460	We had multiple devices involved.
600460	602300	I'm processing the request.
602300	606400	I send you the response, and then we automatically destroy that connection.
606760	610060	So it is a single session used for a single request.
610660	616900	And finally, there are connected sessions, connected CIP requests.
616900	620460	And that's identical to unconnected, but it leaves the connection open.
620460	629980	So you can now reuse all of that information that you've specified for your routed path, for any other network infrastructure you set up between those devices.
629980	631760	They'll persist that connection.
631760	635760	You have a session number, and you can reuse that session number.
635760	641220	That session number is interesting because that is completely independent of your TCP session.
641300	646320	Your TCP session can make or break a hundred times, and CIP doesn't care.
646320	648820	Your CIP session will persist.
649300	663440	So you can see that layer of abstraction where we have duplications of infrastructure scaffolding in our networking environment where CIP has its own versions of things like sessions and routing, independent of TCPs.
664940	670740	So let's talk about routing, because routing in CIP is one of the things that makes it super fascinating.
671820	681640	CIP, because it is different types of networks, not just Ethernet, it has mechanisms in it to allow it to be backwards compatible with its predecessor networks.
682020	685700	So here on the top, I have a CIP path.
686360	688320	You can see IP addresses in there.
688320	691420	That doesn't really look like a normal web path, does it?
691960	695740	On the top, we have an Ethernet IP network.
695740	697320	That's our SCADA network.
697320	701180	This would be your process control network, perhaps, in your plant.
701220	702980	And we're saying we're some device.
702980	706020	We're starting here, somewhere on our plant floor.
706220	716560	And I want to connect all the way down here to a card in this PLC, a module that is in the chassis of a PLC somewhere completely else in my plant.
717220	721360	Well, we can build out a path to do that, because all these devices talk CIP.
721420	726060	And we can say, hey, I want to talk to whatever device is 10.0.10.10.
726420	729060	And that takes me to that Ethernet card in that chassis.
729360	735900	I can say comma 1 to go out port 1 of that device, which actually takes me to the backplane of that chassis itself.
736160	738460	I can say then, go to slot 10.
738500	741160	And that takes me to slot 10 in my chassis.
741760	743780	From there, I say, go out port 2.
743780	745860	That's that purple 2.
745980	750360	And that takes me out the control net port of that card.
750360	755420	We've now transitioned from an Ethernet-based network onto a control net-based network.
755600	760140	From there, I'm going to say, go to node 4, which is my HMI down here.
760580	767880	From node 4, I'm going to say, go out port 3, which is the redundant Ethernet connection on that HMI.
768300	771780	And then I'm going to say, go to 192.168.1.1.
772080	774480	That's my PLC down here at the bottom.
774480	776240	That's its Ethernet card.
776240	782340	And finally, comma 1 to go to its backplane, comma 5 to go to slot 5.
782380	794400	I just sent a request from one Ethernet network that had no Ethernet-based connections to another Ethernet-based network by utilizing CIP routing.
794400	796500	I traversed a control net network.
796500	800700	I traversed three different devices to get there.
801900	810060	Essentially, we took two networks that, from a network topology standpoint, looked like they were air-gapped.
810160	813640	And we got a command between them.
814400	823720	That's what makes CIP routing so fascinating, is the security implications of what you can do on these devices between networks.
824240	825720	It's freely available.
825720	829640	You can route between these types of networks all day long, and these devices do not care.
831800	833980	So now we're going to talk about the fun stuff.
834820	838720	Just a quick disclaimer, this is critical infrastructure.
838920	843360	We are going to be talking a little bit about how to get started hacking critical infrastructure.
843620	847420	So with that, we'll put on our blue team hats, not our red team hats, right?
848420	852100	These systems do protect humans, right?
852100	855300	When hacking into these systems, you never want to hack a live system.
855300	857480	You could kill people, many people.
857480	859880	These systems protect the environments.
859880	866180	When hacking into these systems, there are catastrophic environmental consequences if you do something incorrectly.
866500	868820	And finally, physical infrastructure itself.
868820	872200	You could take down entire refineries, power grids.
872340	877160	The astronomical impacts of these systems when they go down is quite large.
877540	881880	We don't do this for the sake of breaking into things because it's fun.
881880	887400	We do this for the sake of knowing how to protect our critical infrastructure, right?
889260	890180	Okay.
890180	891520	There's the scary talk.
891520	892800	Let's do the fun talk.
892800	893880	Fuzzing!
893880	895460	Everybody like fuzzy things?
895460	896680	I like fuzzy things.
896680	898080	My dog is fuzzy.
900040	906780	Fuzzing is when we send targeted random values to a device through the protocol.
907200	913000	So we talked about how we have these ID numbers for classes, instances, attributes and services.
913220	914500	They're just numbers.
914500	923960	What if we selected some number ranges and just sent requests where we said, hey, I want to send a specific service.
924020	931160	Maybe I'm going to use the GetAttributeListService, service three, on every instance zero.
931280	935220	And instance zero is the singleton or static instance of a class.
935460	939680	And I'm going to say, do it on every instance number between X and Y.
939720	941540	I'm just going to see what I get back.
941540	951720	And that's a really common way to find out what C++ objects in my firmware are attached to the CIP protocol within that device.
951800	957980	That gives me very quick and dirty knowledge of what actually is in there in the device.
958340	962240	How do I find what functions I have available to me?
962240	965620	Because there's no way to say, hey, tell me what you can do.
965760	967760	The vendors don't want it to have that function, right?
967760	970580	So it's not going to give you a list of everything it supports.
970580	972300	You have to go find it.
972640	975640	So fuzzing is a really cool technique to do this.
976280	977980	So here's a fuzzing example.
978440	981540	I've built a simple Python script here.
981600	984900	I'm using service, zero, three.
985100	987260	That's GetAttributeList.
987820	993020	I'm using class code of class ID, as you can see, which is in my for loop.
993020	995960	And I'm saying, I just want to hit every class from one to a thousand.
995960	998140	Let's just see what we can find, right?
999240	1000740	I'm using instance zero.
1000740	1003820	I'm querying the singleton instance of these classes.
1004280	1009240	And I'm using attribute zero, which is the null attribute, meaning I don't need an attribute in this case.
1010540	1015540	At the bottom, you're going to see an output, a snippet of what this script returned here.
1015540	1021320	And you can see, we have a whole bunch of these destination unknown, class unsupported, instance, yada, yada, yada.
1021440	1024160	Basically telling me, hey, there's nothing there.
1024160	1024900	Good luck.
1024900	1025760	Try again.
1025760	1027800	But you can see we've got two hits there.
1027800	1030560	And I've put those in red boxes.
1030680	1037240	The first one, class 0xA1, we've got a service not supported.
1038040	1040320	Okay, what does that tell us?
1040320	1041860	There's an object there.
1042040	1047480	It doesn't support the GetAttributeList service, but we know there's an object there now, right?
1047480	1055280	So if we wanted to expand on our fuzzing, what we'd do is reset up our script to go hit every service code and see what service codes give us errors.
1056260	1057740	That's good to know, right?
1057740	1064700	We can now start pentesting that particular object and figuring out what it's capable of, what data it's storing.
1065160	1067680	We've got another hit, class 0xAA.
1067700	1073140	In this case, this is a known object that's actually part of the protocol specification.
1073640	1076340	It's the Ethernet TCP IP object.
1076340	1082010	It's the object that stores the device's IP address, MAC address, diagnostics counters for its Ethernet ports.
1082700	1085740	And we've got a service not supported from it as well.
1086260	1087560	Well, that's easy.
1087560	1093240	I'm just going to go get the spec out and say, hey, what services does this object actually have in it as part of the specification?
1093560	1096320	Because I know this device now has that object.
1096660	1099760	Now, granted, I'm talking to it on an Ethernet-based network.
1099760	1101320	It better have that object.
1101320	1111460	But the fact that it's exposing that object to me on the network means I can now access that object, I can query that object, and I can control that object.
1111460	1126320	Because as part of the CIP specification, the TCP object allows me to remotely set the IP address of the device, change its gateway, change its subnet mask, without requiring any authentication mechanism.
1127200	1134060	You can modify the script right here to go change the IP address of this device just like that, and the device would have a new IP address.
1136660	1140800	So, that's kind of a quick and dirty intro into fuzzing.
1141140	1142520	What do you do next?
1143020	1148540	Well , in the Rockwell-Allen-Bradley world, we have what we call a Minerf.
1148540	1150300	Really fun word to say.
1150540	1154060	That is a major non-recoverable fault.
1154060	1157320	And it is the easiest thing to do to a controller.
1157320	1160620	It's also perhaps one of the most dangerous things to do to a controller.
1160740	1165540	A Minerf will stop whatever device is from executing.
1165540	1167400	So, it will halt execution.
1167460	1172620	It will cause it to dump its entire configuration out of memory.
1173020	1175560	It has no more program, no more configuration.
1175820	1181660	It is just a dumb, dead box waiting for a technician or engineer to plug into it and give it a new program.
1182720	1186920	That's dangerous because, as we talked about, these devices are running critical infrastructure.
1187180	1196960	So, you can imagine, you have some computer in your plant, and it's controlling the pressure on a pressure vessel that's at 10,000 PSI.
1196960	1199060	And all of a sudden, that computer just halts.
1199060	1200800	It says, no, I'm done.
1200800	1207920	And, you know, you might have some valve feeding that system, providing whatever product is going into that vessel.
1207920	1212780	And if it can no longer say, hey, we're getting too much pressure, we need to close that valve.
1212780	1215580	And that vessel is just going to overpressure and blow up.
1215920	1226680	Now, presumably, your mechanical engineering team has put some other types of safety mechanisms in place, like pressure relief valves or any other type of mechanism like that.
1226680	1228600	Like, generally, these systems are fail-safe.
1228600	1232700	So, if one of these computers crashes, you have relay logic.
1232700	1238860	And as part of the electrical installation, how these systems are wired, your valves should go to whatever their safe position is.
1238860	1240180	Maybe you're venting that vessel.
1240180	1243500	Maybe you're cutting off the flow of product into that vessel.
1243500	1249160	But still, you have caused a disruption that very potentially could have major impacts.
1249800	1257420	The reason minerfs are easy to find from a fuzzing perspective is these systems do integrity checks on themselves continuously.
1258600	1269280	And if they see that there was a failure to validate input and it caused a buffer overflow, the system's going to go, hey, I don't have data integrity anymore.
1269440	1270900	I need to minerf.
1271880	1273560	And boom, it's gone.
1273600	1283580	So, you could presumably go through and, during your fuzzing, have given it a service ID that they didn't account for when they do their input validation.
1283580	1288480	And all of a sudden, the code goes off into some random branch that it's not supposed to go out into.
1288800	1291140	And it fails that integrity check in minerfs.
1291920	1297840	In my experience, when I'm doing fuzzing, I can find, on average, three minerfs a day.
1299840	1303480	So, that just tells you how often these minerfs occur in these devices.
1305860	1310560	I would say that I spent many, many hours in Wireshark.
1310560	1312600	I'm sure everybody here knows what Wireshark is.
1312600	1317980	Wireshark has awesome, awesome capabilities at decoding CIP.
1318320	1325380	I don't know who, but some poor soul spent a lot of time building the CIP plugin for Wireshark, and it's absolutely fantastic.
1325380	1328020	So, definitely utilize Wireshark.
1329980	1331340	And that's it.
1331340	1332600	So, thank you.
1332600	1333720	Thanks for coming.
1333720	1335920	I'm going to leave you with a couple tools.
1336140	1345880	So, first, if you go to the ICS Village GitHub account in our CTF repository, every script and demo I used to build this presentation is in that repository.
1345880	1347900	You can actually get that tooling to do fuzzing.
1347900	1351040	I have fuzzing tools in that repository to get you started.
1351840	1354260	You can also use the Molex Ethernet IP tool.
1354260	1356340	This is a free tool provided by Molex.
1356580	1358940	It's for doing device validation and testing.
1359120	1361100	Awesome tool for this kind of stuff.
1361500	1366940	And finally, if you're a Python guy and you just want to do it all on your own, PyCom 3 is a fantastic library.
1367280	1369600	I am not the developer, but I know the developer.
1369600	1372500	He is awesome, very open to suggestions.
1373440	1374980	And I say, just go to eBay.
1375020	1376020	Find some hardware.
1376020	1377060	That's what I do.
1377140	1379920	This stuff on eBay isn't cheap, but it's not too expensive.
1379920	1383020	It won't break the bank if you want to have your own little cyber range at home.
1383720	1387200	And finally, once you find something, report it to sysevents.
1387640	1394180	They'll help you get connected with the vendor, build those relationships for you, and that way the vendor can get it fixed.
1395200	1396420	And that's it.
1401820	1402820	Thank you.
