00:00:00.000-->00:00:06.106 >>For our next talk we have uh Wes McGrew. He’s gonna talk to us about post exploitation of 00:00:06.106-->00:00:11.111 Docker containers. [audience claps] >>Thank you. So the uh the the target audience for this 00:00:16.617-->00:00:22.456 talk is uh unapologetically red team members. People who are doing red teaming engagements uh 00:00:22.456-->00:00:28.362 other offense orient services such as penetration testing, application security testing, uh 00:00:28.362-->00:00:33.600 and the the title of the talk always have long titles for my talks uh there’s the clever bit 00:00:33.600-->00:00:39.640 and then there’s the actual part of it so it’s a look at multi-container applications. Uh 00:00:39.640-->00:00:45.112 so building nowadays with the with with containerization technology and Docker which I’ll 00:00:45.112-->00:00:50.484 cover in a little more detail uh you can build an application basically out of these lego 00:00:50.484-->00:00:56.990 blocks of of Docker images or other containers that you find on the internet. And uh and and 00:00:56.990-->00:01:01.962 so portions of your applications can be made up of these immutable containers and uh what 00:01:01.962-->00:01:08.368 that means is that the uh you’re working at a higher level of abstraction and all of your 00:01:08.368-->00:01:13.473 vulnerabilities come from these lower levels of abstraction where these Docker images have 00:01:13.473-->00:01:18.512 vulnerabilities and uh the way they talk to each other in an unauthenticated way on the back 00:01:18.512-->00:01:24.351 end can cause issues and so the goal of this talk is to give a penetration testing practitioner 00:01:24.351-->00:01:30.824 who is not already familiar with Docker uh a uh uh or um is facing multi-container 00:01:30.824-->00:01:35.829 applications a little bit of uh tactics and tools to use to examine these systems. And so 00:01:39.299-->00:01:44.304 I’m a uh uh my title at HORNE Cyber Solutions is uh is uh Director of Cyber Operations and 00:01:46.506-->00:01:51.511 so the what that means is that I oversee all offense oriented services uh I run teams that do 00:01:53.981-->00:01:58.685 multiple teams that are simultaneously doing pin tests, red teaming engagements and 00:01:58.685-->00:02:03.190 applications security testing for a number of different clients and so uh you know I try 00:02:03.190-->00:02:07.794 to get hands on with it as much as I can uh but really I- I’m more interested in the 00:02:07.794-->00:02:13.734 management of all these s-sorts of things. and uh making sure that the uh all the teams are up 00:02:13.734-->00:02:18.205 to date on the latest tools and techniques. Uh in a previous life I was a professor at 00:02:18.205-->00:02:23.010 Mississippi State University I still adjunct there I teach class every semester and uh 00:02:23.010-->00:02:27.848 there I worked on Industrial Control Systems uh developed reversed engineering program 00:02:27.848-->00:02:32.853 there for uh getting the NSA uh uh CAE and research uh education Cyber Operations uh and so 00:02:36.723-->00:02:41.228 basically most of my research most of my work is been on the offense side of things and so if 00:02:41.228-->00:02:45.832 y- you’re blue team in here or you might find things a little bit lean but uh but you know if 00:02:45.832-->00:02:51.805 you can learn how to break these things and so that you can then you can look out uh f- for these 00:02:51.805-->00:02:57.477 tactics and techniques. The intention for this deck really is to uh make a strong point 00:02:57.477-->00:03:02.482 about the relationship between an attacker’s skill level uh your skill set t- the set of 00:03:02.482-->00:03:07.988 things that you know as an attacker uh and your development as an attacker every time versus 00:03:07.988-->00:03:13.393 developer trends and so this talk isn’t just about uh attacking Docker containers 00:03:13.393-->00:03:17.197 specifically or even multi-container applications specifically it’s really about 00:03:17.197-->00:03:22.402 how do you develop your skills over time as an attacker uh whether malicious or non right 00:03:22.402-->00:03:27.474 uh and so how we leverage what you already know and how to look at knew technologies moving 00:03:27.474-->00:03:32.712 forward and uh the sort of attitude to approach it with we want to provide uh hacker that’s 00:03:32.712-->00:03:37.617 experienced in exploitation uh and post exploitation of networks of systems and so if 00:03:37.617-->00:03:41.888 you think of uh penetration test of an organization you’re given the scope and y-you’re scanning 00:03:41.888-->00:03:47.160 that scope and you have a set of systems that interact with each other that’s your attack 00:03:47.160-->00:03:52.766 surface. The set of things that you can interact with how do you move and take your y-your most 00:03:52.766-->00:03:57.237 of your training as a penetration tester or red teamer has been in that mode uh uh 00:03:57.237-->00:04:02.709 looking at that attack surface, looking at protocols between services, uh looking at uh uh 00:04:02.709-->00:04:08.648 vulnerabilities on the outside edge of each of those individual systems. How do you move and 00:04:08.648-->00:04:15.322 take that skill set and apply it to an application. And so, historically, the applications 00:04:15.322-->00:04:20.560 have been monolithic, and so a monolithic application is something that’s uh it’s made up 00:04:20.560-->00:04:26.500 of primarily a single binary or a single service running on a single system. Uh or a single 00:04:26.500-->00:04:31.671 virtual machine and so uh with monolithic application, if you’re wanting to inspect the 00:04:31.671-->00:04:37.978 state of internal things to the application, how functions call each other, how data is stored 00:04:37.978-->00:04:42.215 in memory, you’re looking at attaching as a debugger, you’re looking at setting breakpoints, 00:04:42.215-->00:04:46.820 you’re looking at uh exploitations in terms of memory corruption or other sorts of 00:04:46.820-->00:04:51.625 remote execution to get to the point that you can examine these things and then you’re in this 00:04:51.625-->00:04:56.263 sort of environment of a debugger or something where y-you’re limited in how you 00:04:56.263-->00:05:00.834 move. Uh with multi-container applications you’re building your application out of these 00:05:00.834-->00:05:05.839 immutable uh images uh talking to each other a lot of times you’re variable storage in your 00:05:08.175-->00:05:13.747 function calls wind up taking the place of TCPIP connections, wind up taking the place of 00:05:13.747-->00:05:19.819 things like retis databases that actually store what would normally be a local variable. 00:05:19.819-->00:05:23.290 And so it allows you to explore the internals of an application in the same way that you 00:05:23.290-->00:05:28.228 penetration tested network. So I’m gonna demonstrate this with some Dock- some concrete Docker 00:05:28.228-->00:05:34.935 example uh with M-MVA Docker example the white paper for this talk has a set of different 00:05:34.935-->00:05:39.940 things that sort of step up to this but I’m gonna show you the cool one first. Uh and the 00:05:39.940-->00:05:45.478 inspiration for this approach and this talk is uh is uh what I consider a classic talk by HD 00:05:45.478-->00:05:51.818 Moore and Val Smith from DefCon 15 uh Tactical Exploitation. Uh uh it’s quite an old talk I 00:05:51.818-->00:05:56.022 guess now but it’s actually well worth going back and looking at it if you’re a pentester and 00:05:56.022-->00:06:00.961 never saw it. All of the work i-in any kind of field uh is is built on the shoulders o-of 00:06:04.497-->00:06:09.069 giants built on the shoulders of people who’ve come before you and in doing this sort of work 00:06:09.069-->00:06:14.541 uh there’s been a number of talks on Docker and containers uh uh overall this entire uh you 00:06:14.541-->00:06:21.014 know there’s Docker CON in general purpose Docker talks out there and research but uh 00:06:21.014-->00:06:26.653 specifically in security, and uh in uh previous DefCon’s and Black Hat’s, uh we have here a 00:06:26.653-->00:06:31.558 list o-of good references, good material to read, to prepare yourself for this sort of thing, 00:06:31.558-->00:06:37.664 uh we’ve got Mortman, Grattafiori, uh Bettini, Cherney, Dulce, and the uh uh 00:06:37.664-->00:06:43.603 a-and these are all great works but they all focus on different things than what we are focusing 00:06:43.603-->00:06:47.574 on here. Uh, they either uh f-focus on underlying implementation or architecture 00:06:47.574-->00:06:53.179 of Docker uh the way it’s implemented at a Kernel level, the purpose of this talk isn’t 00:06:53.179-->00:06:58.151 exactly the most important thing, uh and having some advice for that low level security 00:06:58.151-->00:07:04.057 sorts of things, uh and then there’s uh vulnerabilities in the platform itself, and your 00:07:04.057-->00:07:10.196 Docker run times and your Docker infrastructure, the way the developers use Docker and how 00:07:10.196-->00:07:15.602 you can t-target Docker developers. Uh the thing is, i-if I get on stage here and I 00:07:15.602-->00:07:21.274 present a a Docker talk that has Docker zero day well in a couple of weeks everybody will have 00:07:21.274-->00:07:26.613 updated well most everybody, except for that one client right? Uh, they’ll uh h-have 00:07:26.613-->00:07:31.751 updated their Docker and those vulnerabilities don’t work anymore. So really, you want 00:07:31.751-->00:07:36.523 something more timeless, and so what you’re looking really here is is post exploitation is being 00:07:36.523-->00:07:41.695 something more useful to learn in the long term because you’re always going to find a way into 00:07:41.695-->00:07:45.598 one of these applications through a vulnerability in its outer attack surface. And so the 00:07:45.598-->00:07:50.603 focus on all those other talks has been on defense as well or at least on specific attacks. 00:07:54.107-->00:07:59.212 And so this is more of a general tactics for red teamers type thing. So when we’re looking at 00:07:59.212-->00:08:02.582 containerization and Docker, if you if you haven’t fooled around with it a lot and I-I don’t 00:08:02.582-->00:08:08.054 think a lot of penetration testers have uh uh it’s getting more and more popular but as a 00:08:08.054-->00:08:11.891 m-means of developing an application, what you’re looking at here is uh essentially an 00:08:11.891-->00:08:16.396 operating system level of virtualization that’s versus VMware where it’s uh simulating 00:08:16.396-->00:08:22.001 the hardware of a system, we’re talking about simulating t-the user space and filesystems and 00:08:22.001-->00:08:28.141 libraries and networks for this container that’s running. Uh, b-but everything all the 00:08:28.141-->00:08:33.012 containers are sharing a single Kernel and uh and so that means that it’s a lot more 00:08:33.012-->00:08:37.617 lightweight, if you want to open up a new Docker container from an image that just takes a 00:08:37.617-->00:08:42.489 matter of seconds to do that and uh it’s very quick to do this because it’s a very lightweight 00:08:42.489-->00:08:47.494 uh system. And so with it being lightweight and it being dynamic and if you tag on something like 00:08:49.996-->00:08:55.001 Kubernetes or Docker Swarm onto this to um to have a uh these things scaled dynamically with 00:08:58.304-->00:09:03.243 load o-or size of data um what you wind up with is um a really easy way of developing 00:09:05.345-->00:09:11.151 applications out of these pre built containers. And uh it eases deployment uh and 00:09:11.151-->00:09:16.623 development so if I develop the - the reason why I’m doing this talk is I started developing an 00:09:16.623-->00:09:22.061 intelligence collections platform that used this to scale, uh for large sets of data 00:09:22.061-->00:09:27.066 and uh, t-the uh useful thing for me for it was that uh when I developed it on my laptop uh I 00:09:29.869-->00:09:35.175 can p-push that image out to the server and it work exactly the same as it did on my laptop. And 00:09:35.175-->00:09:39.846 that’s uh that’s a very solid guaranteed thing as far as Docker is concerned so 00:09:39.846-->00:09:46.419 development and deployment of these things winds up being relatively easy. When we look at 00:09:46.419-->00:09:51.558 vulnerabilities in these systems uh i-it’s important to look and I think this is one of the most 00:09:51.558-->00:09:57.664 important overall themes for this talk is to look at the concept of of vulnerabilities 00:09:57.664-->00:10:01.501 and layers of abstraction. I’ve talked about this in some of my previous talks when I talk about 00:10:01.501-->00:10:06.239 security of penetration testing, basically OPSEC for pentesters, that’s my previous few years of 00:10:06.239-->00:10:12.612 talks, uh you know I see vulnerabilities the life cycle, it doesn’t begin with discovery. 00:10:12.612-->00:10:17.183 So you see these vulnerabilities life cycle diagrams and they begin with you know with the 00:10:17.183-->00:10:21.821 discovery of the vulnerability and then notification and then patching and on and so forth and 00:10:21.821-->00:10:26.759 then the cycle, the life cycle begins again. Uh it really begins with a mistake. A 00:10:26.759-->00:10:31.664 developer made a mistake in the development of an application. They either didn’t design 00:10:31.664-->00:10:36.669 security in, they made a typo in their programming, they they they have some uh they they 00:10:39.239-->00:10:43.910 committed some error that becomes exploitable and in Sergey Bratus’ uh uh weird 00:10:43.910-->00:10:48.948 machines terminology it’s essentially unexpected execution. It’s uh unexpected 00:10:48.948-->00:10:55.955 functionality in a program that allows you to inject incomplete code or to override a flag 00:10:55.955-->00:11:00.593 saying that you’re an admin or something of that nature. And to me, I think that these 00:11:00.593-->00:11:06.099 vulnerabilities are mostly the result of not understanding the layer of abstraction directly 00:11:06.099-->00:11:12.171 beneath you. And so, if uh um, if you’re a web application developer or not understanding 00:11:12.171-->00:11:17.176 uh uh the the http protocol underneath you as you’re working in javascript and API’s and 00:11:19.412-->00:11:21.681 frameworks and things like that. Or uh if you don’t understand how cookies work but you’re 00:11:21.681-->00:11:26.819 relying on your framework to do that for you, you know it can be an issue there. Uh, textbook 00:11:26.819-->00:11:32.492 example of this is with C programmers, if you are C programming and learned in a 00:11:32.492-->00:11:37.463 college course that didn’t you know really dive into the implementation of C, uh you 00:11:37.463-->00:11:43.836 know, you might think that uh that these buffers are just going to be uh ‘I-I said I had 00:11:43.836-->00:11:47.473 twenty bytes for this buffer why is it even letting me put even more in there’ right? Well C 00:11:47.473-->00:11:52.345 will halfway let you do that obviously, We all know this, uh and and even if you know that, 00:11:52.345-->00:11:55.548 and you know your program is going to crash, you don’t really understand the implications of 00:11:55.548-->00:12:00.186 it. You write a C program and it crashes when the input’s wrong, segmentation fault, ‘well I 00:12:00.186-->00:12:04.958 screwed up’ and you go and you keep re-compiling it until it stops doing that thing. Right? 00:12:04.958-->00:12:08.661 And uh, but what you don’t understand is what’s really happening is you going past that 00:12:08.661-->00:12:12.398 buffer and you’re running over things on the program stack, if you don’t understand that 00:12:12.398-->00:12:16.135 there’s a program stack that’s holding your local variables then you didn’t understand you 00:12:16.135-->00:12:20.773 know what’s happening in that segmentation fault. Uh, base pointers, return pointers, all 00:12:20.773-->00:12:25.311 that sort of thing that you can manipulate. And so all that sort of thing that if you go a level 00:12:25.311-->00:12:31.050 lower than C, and you’re looking at assembly and and machine code and stepping through things with 00:12:31.050-->00:12:34.554 a debugger, you learn to understand those sorts of things but that’s not at the layer of 00:12:34.554-->00:12:38.858 abstraction that you’re developing and so you have, your user experience, your which is 00:12:38.858-->00:12:43.997 your end user pointy clicky type things uh your scripting languages your high level 00:12:43.997-->00:12:48.801 compiled languages, machine code, things like hard - what you think of as low level things 00:12:48.801-->00:12:53.339 like uh uh machine code and virtual memory and things like that but underneath it at some 00:12:53.339-->00:12:58.077 point it becomes a magic box you you have an understanding of how that computer works at a basic 00:12:58.077-->00:13:03.082 level but it may not be this the case. And even for myself you know, I think sometimes well 00:13:03.082-->00:13:07.020 maybe I should’ve done uh a degree in computer engineering instead of computer science 00:13:07.020-->00:13:11.090 because when it gets down to like the transistors and this pro physical properties the 00:13:11.090-->00:13:16.095 silicon I d-don’t know right you know it’s uh uh there’s probably something to that I don’t 00:13:16.095-->00:13:21.834 understand it will bite me one day and so for a hacker to keep up with these sorts of things 00:13:21.834-->00:13:26.539 you’ve got two different directions to look in one is in your layer of abstraction higher 00:13:26.539-->00:13:31.911 or lower and and as a hacker you tend to want to start learning lower and lower and lower so 00:13:31.911-->00:13:37.583 that you can get further underneath that developer’s understanding of things but 00:13:37.583-->00:13:41.587 horizontally you’ve got different technologies like this in this diagram you’ve got uh 00:13:41.587-->00:13:47.927 you’ve got languages on the left hand side and protocols on the and protocols in medium on the 00:13:47.927-->00:13:52.765 uh the right hand side and so there’s different there’s there’s lots of different things 00:13:52.765-->00:13:56.569 and it’s hard to keep up with this and so you have things that you specialize in for our pen 00:13:56.569-->00:14:01.207 testing teams we have we have folks that are very good at web applications we have folks that 00:14:01.207-->00:14:07.313 are very good at uh a-at network base attacks we have folks that are very good at at looking at 00:14:07.313-->00:14:12.085 embedded control systems things like that and so you have your specializations but you always 00:14:12.085-->00:14:17.090 want to be broadening this. If you’re a developer, you usually move upwards in the stack 00:14:19.759-->00:14:26.199 though. So we’re we’re moving downwards as a uh as penetration testers, red teamers and things 00:14:26.199-->00:14:32.538 like that uh but a developer is typically moving upwards. And so if you’re a web developer, uh in 00:14:32.538-->00:14:37.210 the late 90’s you might’ve been writing your code in C, I-I’ve written uh I’ve written some uh 00:14:37.210-->00:14:42.215 web applications in C plus plus, CGI, uh it’s not something I’m proud of but uh and it’s not 00:14:44.484-->00:14:48.221 something that I would deploy on anything internet facing nowadays, if I found the code, I 00:14:48.221-->00:14:53.526 need to find that code uh but but you know you used to uh y-you c-could compile a program 00:14:53.526-->00:15:00.466 that that outputted http headers and html and stick it in a CGI bin directory and then wait to 00:15:00.466-->00:15:03.903 get home right? Uh and uh uh you know well that’s not so smart so we uh start putting scripts out 00:15:03.903-->00:15:09.342 there and that’s a higher level of abstraction and then we have like web specific languages ok 00:15:09.342-->00:15:14.347 things like regrettably PHP and uh and and things like that that are designed for the web, right? 00:15:19.085-->00:15:23.156 Uh and then on top of that we have frameworks. T-think things like Jenga that do a lot of 00:15:23.156-->00:15:27.593 things for you, so like Jenga you’ve got your object model that handles all your database 00:15:27.593-->00:15:30.797 stuff, y-you’ve got all these connectors and everything to where you don’t have to 00:15:30.797-->00:15:35.301 understand http you just write the code that back ends your website and you have some 00:15:35.301-->00:15:39.672 templates for the front end and it’s all, it’s kind of hiding things from you but it’s making 00:15:39.672-->00:15:44.110 it easier for you to develop apps. As you go up this these layers of abstraction it becomes 00:15:44.110-->00:15:49.448 easier for you to develop applications. And then nowadays it seems most uh most web 00:15:49.448-->00:15:54.253 applications are strictly running in java script in your browser and hitting web APIs on 00:15:54.253-->00:16:00.193 the back end. Uh and so that’s a that’s another way of developing another way of hiding some of 00:16:00.193-->00:16:05.464 this complexity. When we look at containerization, it’s as if we can take any specific web 00:16:05.464-->00:16:09.268 application that’s been developed almost and you can look on the Docker hub out there 00:16:09.268-->00:16:14.440 and pull down an image of it and have them talk to each other and you can you can build a 00:16:14.440-->00:16:18.778 serviceable app out of these things with just some connecting code and some configuration 00:16:18.778-->00:16:23.549 files and some scripts to spin up the containers for them and to have them talk to each other. 00:16:23.549-->00:16:28.554 And so essentially this is the next sort of meta level of developing an application. And 00:16:30.790-->00:16:37.396 so your mindset uh as an attacker versus a developer uh after you learn “hello world” 00:16:37.396-->00:16:41.033 for something, you learned these things by looking at their tutorials. You look- you learned 00:16:41.033-->00:16:46.038 them by reading the the most basic introductory book that you can find on the topic. Uh you 00:16:48.107-->00:16:53.079 you learn them uh from from trainings and tutorials and videos and things like that. And 00:16:53.079-->00:16:58.718 everybody sits down with like uh everybody sits down with KNRC and learns C anymore right? They 00:16:58.718-->00:17:02.855 they’re gonna go with some tutorials first. So as a developer, what you’re gonna 00:17:02.855-->00:17:07.093 learn i- after you’ve learned how it works is what can I build with these language constructs 00:17:07.093-->00:17:13.099 if I go through the tutorials, everything that I build is gonna look like that tutorial software 00:17:13.099-->00:17:19.038 with modifications to fit my needs. I’m gonna use the same approaches and the same uh 00:17:19.038-->00:17:24.277 practices. And the problem with security for that is most of the time, tutorials sort of hand 00:17:24.277-->00:17:28.514 wave security for things in favor of getting something up and running in like like a 00:17:28.514-->00:17:35.388 couple of uh uh screens worth of uh texts on a website. If you’re an attacker, the first thing 00:17:35.388-->00:17:39.725 that you do, like first thing I did after i started looking at doing hello world and Docker so 00:17:39.725-->00:17:43.596 I can build a multi container application is well ‘how does this work? How does this hello 00:17:43.596-->00:17:48.167 world work?’ and so you start digging into well how do these Docker containers look at each 00:17:48.167-->00:17:53.172 other? And so uh and so so if you’re uh if you’re a-an attacker or er er er a developer 00:17:56.609-->00:18:00.146 t-this abstraction allows for more efficient development. That’s basically what we’re 00:18:00.146-->00:18:05.151 talking about here. Uh these these these layers of of abstraction uh e-essentially 00:18:11.223-->00:18:15.094 t-the idea of having these building block containers, you can have mixed technology in 00:18:15.094-->00:18:18.831 them. It doesn’t matter if this one application is written in dot net doesn’t matter if this 00:18:18.831-->00:18:24.437 one’s written in python we’ll actually look at an example in the video of of an application 00:18:24.437-->00:18:29.041 like this. And the way that they talk to each other they have to at that point speak over common 00:18:29.041-->00:18:34.046 protocols like TCPIP. They can’t rely on them being PHP talking to PHP or C talking to C uh 00:18:36.716-->00:18:41.721 these are these are technologies that have to communicate over the same sorts of networks that 00:18:41.721-->00:18:47.526 that organi - organizations operate on. Uh an an interesting example of this is, if you look 00:18:47.526-->00:18:52.598 at a lot of multi container applications use redis and and I might not be pronouncing it 00:18:52.598-->00:18:57.603 correctly but it’s a uh it’s essentially when I saw it in an application, I was like ‘what is 00:18:57.603-->00:19:02.441 this thing?’ and uh it’s essentially it’s a key value store. So uh uh it’s essentially 00:19:02.441-->00:19:08.781 a variable storage uh container or a service. You can run it outside the container but you 00:19:08.781-->00:19:13.886 connect to it and you say this variable name assign it to this value. And you have some complex 00:19:13.886-->00:19:18.758 data structures in there too you can have some cues and stacks and and things like that in 00:19:18.758-->00:19:24.263 there and so instead of storing things in local variables in your container applications 00:19:24.263-->00:19:29.035 since your containers are immutable they can’t maintain state if they go away and then 00:19:29.035-->00:19:35.174 come back. They’ll store state inside of these redis containers where other applications can 00:19:35.174-->00:19:40.212 come in and look at that data and use it and so w-we’ll look at some examples of that. But so 00:19:40.212-->00:19:46.519 instead of having a stack a program stack in C for example where you’d have storage memory 00:19:46.519-->00:19:51.524 that pointers are pointing to locally, you now have them on this network-based service. And 00:19:53.826-->00:19:59.398 so what this means is the the developers are moving up the stack and and abstraction and us 00:19:59.398-->00:20:03.669 attackers are moving down there’s a few things happening. One there’s uh there’s things 00:20:03.669-->00:20:08.374 higher on the stack that that attackers need to learn to to work with things like 00:20:08.374-->00:20:13.779 containerization and uh and and uh uh and you know modern web development technologies and 00:20:13.779-->00:20:18.017 things like that that we might not be very interested in. the good news however is that our 00:20:18.017-->00:20:24.490 existing techniques for penetration testing networks of systems apply directly to 00:20:24.490-->00:20:30.029 penetration testing inside of a multi container app. And so, your existing, now you might be 00:20:30.029-->00:20:34.500 a penetration tester today, but once you start looking at at web applications now now 00:20:34.500-->00:20:39.605 congratulations you’re an applications security expert, right? And so so your your 00:20:39.605-->00:20:45.044 current tool set your current skill set becomes more lucrative over time because you’re going 00:20:45.044-->00:20:49.081 relatively lower in the stack to the developers. So think of somebody in the seventies or 00:20:49.081-->00:20:53.452 eighties who was writing assembly language code uh and that’s what they had to do just 00:20:53.452-->00:20:58.157 to write an application for a computer back then well now you know they’re very good they 00:20:58.157-->00:21:02.495 would that person would be very well suited towards embedded systems developments or other 00:21:02.495-->00:21:08.934 lower level things. And so uh, when we’re looking at these sort of these multi container 00:21:08.934-->00:21:14.406 applications and application internals we want to have things like control over execution, 00:21:14.406-->00:21:19.411 opportunity t-to turn code against itself things like ROP and web API’s and CSRF and 00:21:19.411-->00:21:24.817 things like that. Uh all these sorts of things especially in case of malware analysis and 00:21:24.817-->00:21:30.723 return oriented programming in CSRF, you know these things uh requires very specialized tools 00:21:30.723-->00:21:34.760 and sometimes your y-you might even be uh internal to an application right? T-to 00:21:34.760-->00:21:40.432 e-exploit a uh monolithic binary application you’re you’re looking at you know uh uh having 00:21:40.432-->00:21:46.205 to attach this thing to a debugger, just to get an understanding on how to develop 00:21:46.205-->00:21:52.645 an exploit for it. Uh, the skill set for this uh, you know, it’s different. So an internal 00:21:52.645-->00:21:56.415 application uh security expert, somebody who who analyzes applications for 00:21:56.415-->00:22:00.252 vulne-vulnerabilities needs to have a very strong understanding of the language that that 00:22:00.252-->00:22:05.891 they’re targeting uh and and uh and methods of exploitation and some of this can get quite 00:22:05.891-->00:22:11.597 arcane um, but if penetration tester generally works on the outside attack surface they’re 00:22:11.597-->00:22:16.001 using known vulnerabilities or relatively easy to find vulnerabilities because they’re 00:22:16.001-->00:22:21.340 targeting uh the attack surface of an entire organization at once. And so you might have been 00:22:21.340-->00:22:26.178 trained you know in doing some simple buffer overflow of exploits as a penetration tester 00:22:26.178-->00:22:31.584 but uh uh if you’re writing them everyday a-and your daily work as a penetration tester I’m 00:22:31.584-->00:22:37.256 going to be very surprised, right? Uh uh you know if you’re connecting to a remote service 00:22:37.256-->00:22:43.596 on a client and you’re you’re you know throwing the As in until it crashes type of thing 00:22:43.596-->00:22:47.933 and you’re able to develop that exploit sort of blindly without seeing the other side of it you 00:22:47.933-->00:22:52.938 know that’s a that’s a I mean kudos to you but that’s just not not the norm in pentesting. It’s 00:22:55.040-->00:22:59.778 more of an application security thing. And so there’s a training gap there, uh but the nice 00:22:59.778-->00:23:04.450 n-news is with this containerization is that your existing skills of system to 00:23:04.450-->00:23:10.956 system pentesting uh apply much easier. So containerization allows for the design of 00:23:10.956-->00:23:15.561 applications that are as in many of these things and so we’re democratizing post-exploitation 00:23:15.561-->00:23:20.199 manipulation so essentially after you gain access to one of these multi-container 00:23:20.199-->00:23:26.272 applications and so so uh there’s lots of vulnerabilities in these things and so uh if you 00:23:26.272-->00:23:31.744 look on the Docker hub there’ll be official Docker images for different web applications but 00:23:31.744-->00:23:36.315 there’ll also be a lot of Docker images that people maybe want off for web applications that at 00:23:36.315-->00:23:40.519 some point may not have had official Docker images. And so, somebody will take it upon 00:23:40.519-->00:23:44.690 themselves to create an image for their own use, push it to their Docker hub so that they 00:23:44.690-->00:23:49.595 can use it, and by default it’s available for anybody else to go and grab and use in theirs. But 00:23:49.595-->00:23:54.366 they didn’t sign up to be a package maintainer, right? they didn’t sign up t-to m-maintain 00:23:54.366-->00:23:59.271 this thing over long periods of time, and so their use of it may be over or they might not care 00:23:59.271-->00:24:04.877 about the vulnerabilities in it and so uh you’ll see in the demo there’s a there’s a Joomla image 00:24:04.877-->00:24:09.682 out there that you can grab and and it’s a it’s an old version of Joomla, there’s an official 00:24:09.682-->00:24:14.987 image of Joomla out there. But there’s also a lot - that isn’t vulnerable - there’s also a lot 00:24:14.987-->00:24:19.992 of uh uh backdoored images, and there’s a news article a while back on uh on uh somebody who 00:24:22.294-->00:24:27.132 had cryptominers embedded in these images. And so there’s lots of things, that’s smart I 00:24:27.132-->00:24:33.105 wish I had thought of that, uh uh [laughs] the so there’s lots of uh vulnerability in the 00:24:33.105-->00:24:38.110 images themselves that can give you that entrance into the back end network for these things. 00:24:40.212-->00:24:46.251 And so, you essentially have this Docker network underneath the horizontal line there uh 00:24:46.251-->00:24:50.856 where your containers all work and can talk to each other and then there’s an outside attack 00:24:50.856-->00:24:55.194 surface of ports that are forwarded to the outside world from the host and those ports 00:24:55.194-->00:25:01.066 are um and you specify those ports. But once you’re on the inside of this network uh it’s 00:25:01.066-->00:25:07.673 uh they can it’s kinda free for all. They can all kinda talk to each other no matter what they’d 00:25:07.673-->00:25:14.179 specify. Uh and so, essentially a test of an application becomes a comp - a uh uh a microcosm of 00:25:14.179-->00:25:19.184 an organization-wide test. Uh your your actual um your actual post exploitation of this sort 00:25:23.689-->00:25:27.493 of thing is gonna involve identifying that you’re on a Docker network, which will be 00:25:27.493-->00:25:30.929 pretty simple because you’re gonna find yourself on a system that doesn’t have a lot of 00:25:30.929-->00:25:35.634 tools. It’s purpose built for that one application and so you might be getting a busybox shell 00:25:35.634-->00:25:39.905 or something and in in the video it’ll actually show you uh uh another technique that you can 00:25:39.905-->00:25:45.911 look at very quickly to see that you’re on a Docker uh container network. Uh, and and so that 00:25:45.911-->00:25:49.014 you’re idea is that once I gain access to one of these things let’s enumerate the rest of 00:25:49.014-->00:25:52.351 them, let’s find out what’s on the rest of them, let’s figure out how they talk to each other 00:25:52.351-->00:25:58.157 and see if we can move around. And this is all analogous to to own a monolithic application 00:25:58.157-->00:26:03.095 function hooking and break points and inspection of memory but it’s at a network scale. And 00:26:08.634-->00:26:12.604 so the the implementation of this, is so you you have access to conventional exploits, it’s 00:26:12.604-->00:26:18.010 familiar territory for attackers with system or network level attack e-experience uh the the 00:26:18.010-->00:26:21.613 limitations of this is you’re living off the land. You’re gonna have to transfer your own 00:26:21.613-->00:26:23.615 tools in and just kind of hope statically compile them and hope for the best that they’ll work 00:26:23.615-->00:26:25.617 once they’re on there. Uh, it it’s challenging because the the images are quite minimalistic. 00:26:25.617-->00:26:27.619 You’re gonna be doing a lot of port forwarding, uh in order to to get your tools on your system 00:26:27.619-->00:26:29.621 to to reach in there and look at those other hosts. And so the the demonstration video for this 00:26:29.621-->00:26:32.191 uh is uh demonstration of exploitation and post-exploitation of a 00:26:32.191-->00:26:37.196 multi-container application. This is a uh this is a a Docker multi container application that 00:26:52.978-->00:26:57.983 is used frequently in in public Docker trainings, it’s out on there in GitHub the links are 00:27:02.120-->00:27:08.994 all in the white paper for the talk, uh this is used to teach people about Docker. And it’s uh 00:27:08.994-->00:27:13.832 it’s a voting application, it’s meant for cats versus dogs about changing to blue team versus red 00:27:13.832-->00:27:20.239 team, so we can have some fun, uh uh we’re gonna attack this thing, we’re gonna look at how 00:27:20.239-->00:27:26.845 uh different aspects of it like the voting interface is written in one language the back end 00:27:26.845-->00:27:31.817 takes the votes as another language, the database is a postgres database and then 00:27:31.817-->00:27:36.922 there’s a red SKU that the votes get stuffed into and popped out of. It’s like a stack. Or a cue 00:27:36.922-->00:27:42.361 actually in this case, uh you have a data structure or a list in redis where the votes are 00:27:42.361-->00:27:47.366 being pushed on to the left hand side and popped off the right hand side as a cue. And so we’ll 00:27:52.471-->00:27:57.476 uh bump over to our video here. If I can get my controls. Ok, my controls were hidden under the 00:28:06.585-->00:28:11.590 bar there, alright. [plays video] ok so this is a tour through the application itself, 00:28:14.626-->00:28:21.033 uh the voting app at the top there is written uh is written in python. It bumped out of 00:28:21.033-->00:28:27.906 fullscreen on me. The uh the results are written in with node and javascript. There’s a joomla 00:28:27.906-->00:28:33.979 image I, in the tutorial of this uh there’s not really external attack surface so I dropped that 00:28:33.979-->00:28:37.950 extra - that vulnerable joomla image in there just for the purposes of the demon - of the 00:28:37.950-->00:28:42.487 demonstration. You see in the networks there it’s showing front-tier, back-tier, for some 00:28:42.487-->00:28:47.492 of these, some of them are only back-tier, uh containers, uh there’s that that’s two separate 00:28:49.995-->00:28:55.000 Docker networks. And it’s e-essentially like a DMZ and the uh the internal network that 00:29:00.639-->00:29:03.976 we’re talking on. There’s a worker node that uh that depends on redis, and it’s simply 00:29:03.976-->00:29:06.912 popping uh votes off of the redis cue and then pushing them into a database. There’s the 00:29:06.912-->00:29:11.917 redis cue itself on the back end and then a database that the votes actually wind up in. And 00:29:17.255-->00:29:21.293 it’s good that this is a video because there’s a lot of moving parts to this that that can go 00:29:21.293-->00:29:28.100 wrong. It took a few takes for this uh, and so we can start this thing up using Docker uh 00:29:28.100-->00:29:34.206 Docker swarm as instrumentation, and the details of all this are in the white paper and so uh I’m 00:29:34.206-->00:29:39.745 moving through this quickly but it’s but it’s it’s all there. So there’s your voting interface, 00:29:39.745-->00:29:44.783 there’s the results, uh off that’s served off of another port and there’s that uh that 00:29:44.783-->00:29:49.788 that juicy joomla image there waiting to get popped. We can punch in votes and see the 00:29:54.126-->00:29:59.531 results and we can even change our vote, we get a cookie that our uh vote is associated with 00:29:59.531-->00:30:04.536 and so it can flip and flop as time changes. So we want to break it right? And luckily uh 00:30:08.740-->00:30:14.713 you know, this this particular joomla uh image, there’s a there’s a module in mettis that 00:30:14.713-->00:30:21.019 can take care of hitting this thing. That’s just making note of the local IP address of the 00:30:21.019-->00:30:25.290 attacker, uh you can see at the bottom of the screen the attacker target designation 00:30:25.290-->00:30:28.894 there the asterisk that designates which screen we’re looking at at any moment. Right 00:30:28.894-->00:30:33.632 now we’re looking at target. We’re uh loading up that particular attack module, we’re 00:30:33.632-->00:30:38.637 setting our target up which we identified from the web interface uh, yeah, boring uh 00:30:40.939-->00:30:45.944 meter- mettis exploit stuff. Type faster old Wesley [chuckles]. Setting our local 00:30:51.450-->00:30:56.455 host because that PHP meterpreter is gonna phone back to our to us. And it’s a quick 00:31:03.695-->00:31:08.166 exploits, it goes ahead and works, you’re you’re sitting in a PHP meterpreter right now uh 00:31:08.166-->00:31:13.371 you get some information about the system that you’re on, uh it’s the and it’ll be the same 00:31:13.371-->00:31:17.776 kernel version for every container because they’re all sharing in the kernel. We can 00:31:17.776-->00:31:21.613 drop to a shell. And this is showing you in the proc filesystem, in the C groups you 00:31:21.613-->00:31:26.551 can actually a uh uh without going into what all that means you see a lot of references to 00:31:26.551-->00:31:32.290 Docker. And so that that’s first indication that we’re we’re on such a system. Now we’re doing 00:31:32.290-->00:31:36.862 IP information for this Docker container that we’re inside of, and there’s an internal and an 00:31:36.862-->00:31:42.968 external network there. There’s the 172 dot 19 and 172 dot 18 that are these both that that 00:31:42.968-->00:31:49.007 are those front-tier and back-tier networks. We can background that meterpreter 00:31:49.007-->00:31:55.313 session uh and and so we have that session sitting there and we have that persistence on uh 00:31:55.313-->00:32:00.252 on that that joomla server. We’re grabbing a statically compiled version of nmap off 00:32:02.387-->00:32:07.959 GitHub uh in order to uh be able to scan that internal network uh statically compiled because we 00:32:07.959-->00:32:12.931 wanna upload that which is what we’re doing right now into a temp folder onto that 00:32:12.931-->00:32:17.102 compromised container so that we can start working from there. We have to have it statically 00:32:17.102-->00:32:22.107 compiled because we don’t have a lot of library support on that target uh and and certainly 00:32:27.746-->00:32:29.748 nmap’s not already there unless you’ve you broke into a cali image container, right? They 00:32:29.748-->00:32:34.186 they make those, they’re fantastic uh I like working with them. I think uh the the actual 00:32:34.186-->00:32:40.625 attacker pane on this interface is is running in a cali container. And so here we’re 00:32:40.625-->00:32:45.630 nmap-ing the uh this 172 dot 18 network which is the external network the front-tier network. 00:32:49.501-->00:32:53.805 All ports on the first 10 hosts uh by these default configurations the Docker there 00:32:53.805-->00:32:59.211 it’s sort of incrementally uh assigned IP address numbers. And so you see, and there’s actually 00:32:59.211-->00:33:04.916 good naming for most of them except for that joomla server that I didn’t really give a good 00:33:04.916-->00:33:09.921 name for uh and also the Docker host is the first one up there. So that gives you an idea of 00:33:13.925-->00:33:19.598 those three http services that we’re looking at. The front end voting interface, the intern- or 00:33:19.598-->00:33:24.569 the the results application and the joomla. Now the scan is going across the back-tier 00:33:24.569-->00:33:28.673 because now we have access to one of these containers now we can start scanning the back-tier 00:33:28.673-->00:33:32.110 network and seeing what’s the- what’s there. It’s gonna be a lot more interesting stuff. It’s 00:33:32.110-->00:33:37.816 gonna be stuff we can play around with. And so you’ve got the rettis server down at the 00:33:37.816-->00:33:42.821 bottom uh the next one up is the uh is the joomla instance, uh the the postgres database there, 00:33:46.057-->00:33:51.062 we’ve got uh and again the the Docker host up there at the top at dot 1. And so now we’ve got 00:33:53.498-->00:33:58.503 database and rettis server we can mess with so now we can start manipulating local 00:34:02.507-->00:34:07.512 variables. So we’re back into our meterpreter console running on our joomla instance, uh and 00:34:11.549-->00:34:17.756 we’ll need to set up uh uh we’re gonna set up some port forwarding so that we can 00:34:17.756-->00:34:20.825 interact with those services directly. Basically, we’re creating a tunnel from our 00:34:20.825-->00:34:27.766 external attacker uh image or er container or virtual machine or your local instance of of cali 00:34:27.766-->00:34:34.139 metasploit. And uh and so we set a port forward here to where we can get at that database and we 00:34:34.139-->00:34:38.910 can just use the regular ol’ uh postgres command line to interact with it. And the thing 00:34:38.910-->00:34:43.615 is is by default with all these Docker images is is they’re they’re meant to get up and 00:34:43.615-->00:34:47.752 running very quickly so many of them are configured to just have defaults or no credentials no 00:34:47.752-->00:34:51.656 authentications nothing because they’re all sitting on those back-tier networks where nobody 00:34:51.656-->00:34:55.727 can get at them directly. And so, once you are in there, you’re usually good to talk to 00:34:55.727-->00:34:59.531 each other unless some guy’s done a lot of some special configuration, which is not in 00:34:59.531-->00:35:04.636 the tutorials. Uh and so, here we’re looking at the tables and and looking at the votes that 00:35:04.636-->00:35:10.408 are in there the votes take the form of an ID associated with that voter, uh and uh uh and 00:35:10.408-->00:35:15.246 also which one they vote. A is red and B is blue, I guess, I don't know. I don’t quite 00:35:15.246-->00:35:20.251 remember. But then we’ve also done some inserts to see uh more votes being put in for blue so 00:35:25.991-->00:35:30.996 blue team members can can celebrate for now. Now as, past Wesley’s pause there, just brain 00:35:37.869-->00:35:42.874 farting I guess, alright now we’re back into a shell, uh and we’re going to uh uh uh since we 00:35:45.276-->00:35:49.814 since we’re just doing netcat for the rettis, we don’t really need to set up a port for it we 00:35:49.814-->00:35:55.086 can netcat from uh we can net cat from that host. A lot of times you’ll have busybox with 00:35:55.086-->00:36:00.392 will have netcat built in. here we’ve gone into monitor mode on rettis. So once you telnet onto 00:36:00.392-->00:36:05.497 a redis instance all the commands are plain text and monitor allows you to see what’s 00:36:05.497-->00:36:10.335 going on, in a live feed of interactions and so all those pops are that worker er 00:36:10.335-->00:36:12.337 container continuously looking, is there a new vote, is there a new vote, is there a new vote, 00:36:12.337-->00:36:14.339 because when it finds a new vote, it will pop it and throw it into the database. And so 00:36:14.339-->00:36:16.341 it’s continuously doing that, and as I hit the votes here er uh you’ll see things change and 00:36:16.341-->00:36:18.343 uh I’ll uh move the window outta the way there so you can see it. And so you see, votes being 00:36:18.343-->00:36:20.345 pushed onto the right hand side and popped off the left hand side. And so now we know how 00:36:20.345-->00:36:22.347 this works we kinda got a feel for that and it’s almost like watching it instrumented in a 00:36:22.347-->00:36:27.986 debugger to see how how does this how does this part of the program talk to this other part 00:36:27.986-->00:36:32.991 of the program. We can now uh start playing with it directly. And so uh so now that we’re in 00:36:53.511-->00:37:00.018 there. I’m copying and pasting a bunch of uh of uh push commands into here so that we can push a 00:37:00.018-->00:37:06.658 bunch of of arbitrary votes into this thing. And it’s just as good as pushing them from the 00:37:06.658-->00:37:12.997 web interface. And so I posted in a ton of votes there. With unique IDs of just alphabetic 00:37:12.997-->00:37:20.004 letters. It doesn’t verify that they’re valid or associated with any cookie or anything it’s just 00:37:20.004-->00:37:25.009 sort of there. It’s a toy application. And so now the red team is winning of course. And 00:37:29.147-->00:37:34.152 there I am by rubbing it in and highlighting it. [muffled laughter] Alright so. And so the 00:37:37.755-->00:37:43.261 take away from this is that your existing offense oriented skills, none of that was very 00:37:43.261-->00:37:48.766 difficult, right? This is not zero day this is just regular old tactical post-exploitation 00:37:48.766-->00:37:53.271 stuff, uh that you’ll learn as a pentester, if you haven’t already learned it, if you’re 00:37:53.271-->00:37:58.109 getting started, these are things that’ll be in classes and stuff but these existing offense 00:37:58.109-->00:38:03.815 skills become useful at a lower relative position in the a stack of abstraction from developers 00:38:03.815-->00:38:08.987 as they’re using higher and higher abstracted technologies. And so developers are moving up 00:38:08.987-->00:38:14.592 and so the new new low level moves up. And so, but it’s important that you update 00:38:14.592-->00:38:20.665 yourself. So for us, you know, we don’t want the first, we don’t want the first uh 00:38:20.665-->00:38:25.870 multi-container application we encounter to be on a client Git. we don’t want to have to learn 00:38:25.870-->00:38:31.743 it on the spot then we wanna have some familiarization with Docker and Cubernetti’s and 00:38:31.743-->00:38:36.981 other technologies for newer development methodologies uh so that we’re familiar with these 00:38:36.981-->00:38:40.785 things when we see them and we don’t freak out when we break into a joomla instance and see 00:38:40.785-->00:38:45.924 that there are no tools in place and that it uh it uh and and don’t even think to see if 00:38:45.924-->00:38:50.728 there’s another back end network that this thing can talk to. And so it’s important to update 00:38:50.728-->00:38:55.400 yourself and not only move down the stack in terms of getting lower and lower and lower in 00:38:55.400-->00:39:00.104 skills for exploitation but work up the stack as well. If something seems cool and trendy 00:39:00.104-->00:39:06.544 like cloud or or or containerization or block chain or anything like that. It’s it’s 00:39:06.544-->00:39:12.650 really easy to to turn your nose up at it right, uh because it’s trendy and you don’t want to be 00:39:12.650-->00:39:16.521 trendy, but ultimately your clients are gonna wind up using these technologies and you need 00:39:16.521-->00:39:21.526 to understand them. And so, it’s it’s references a a good a good entrance into application 00:39:24.162-->00:39:28.766 security testing for existing penetration testers. There’s a white paper available in the 00:39:28.766-->00:39:33.805 conference materials uh it has all the information about the demo and a couple other demos uh 00:39:33.805-->00:39:38.543 there’s a lot of discussion in that that’s not in this talk and a lot of links to resources that 00:39:38.543-->00:39:43.748 I used when I was learning about this stuff uh previous work that’s being done in security of 00:39:43.748-->00:39:47.685 these things and also some pointers to some information on how to to secure these 00:39:47.685-->00:39:54.492 applications, if that’s you’re thing. Uh, but uh I appreciate your time and and uh I’ll be 00:39:54.492-->00:39:59.497 down here uh uh ready for questions and to hand out cards and trade contact information. 00:40:01.766-->00:40:06.771 [crowd applause] Thank you.