00:00:01.835 --> 00:00:08.976 >> Good afternoon how are we? We can do better than that. Maybe 00:00:08.976 --> 00:00:14.982 get beer. So how many people made it over to ctf? Go check it 00:00:20.254 --> 00:00:27.060 out. Look at it. It's fun. And we've heard a little bit ctf and 00:00:27.060 --> 00:00:32.599 you will talk more about this? Good stuff. Let's give these 00:00:32.599 --> 00:00:38.639 guys a big round of applause [ applause ] >> All right. I sound 00:00:43.210 --> 00:00:48.849 really loud. Welcome to our talk. We are here to talk about 00:00:48.849 --> 00:00:54.721 some work we've been doing in the context of ctf team and 00:00:54.721 --> 00:00:58.859 security research and in the context of cdc and open-source. 00:00:58.859 --> 00:01:04.798 We are here to talk about arraign and we will get to that 00:01:07.601 --> 00:01:13.607 later. First, we are we. I'm Zidus and this is Fish. We are 00:01:16.410 --> 00:01:22.916 from shellfish. We are ctf team. We are playing the ctf right now 00:01:22.916 --> 00:01:28.922 on the Defcon floor there. We are fighting hard. As you will 00:01:31.291 --> 00:01:37.297 see so this talk is full of these live demos. We are going 00:01:39.366 --> 00:01:46.173 to try some ctf challenges. Show how to approach that challenge 00:01:46.173 --> 00:01:51.745 with this framework. You will see everything melting down 00:01:51.745 --> 00:01:58.585 completely and a lot of fun stuff. The point is, something 00:01:58.585 --> 00:02:05.559 is happening on the ctf floor. We come bad ass and prepared and 00:02:05.559 --> 00:02:11.565 then the game starts. Any ways, we are shellfish. And we are 00:02:18.472 --> 00:02:20.774 also from UC Santa Barbara and there we have an awesome 00:02:20.774 --> 00:02:26.780 computer security lab and that's where anger was created. And 00:02:30.283 --> 00:02:36.289 major attributers, me and fish, Andrew Dutcher. Amazing dude. 00:02:43.230 --> 00:02:49.236 Nezgor, aka John. He's the leadest one of us. And Chris, 00:02:59.079 --> 00:03:05.018 very creative. And Chris. Pose dock. This is the anger team. As 00:03:16.263 --> 00:03:22.269 for me, I've been coming to Defcon since Defcon 9. Back in 00:03:27.541 --> 00:03:33.547 the park. It's awesome then and now. It's been a lifelong dream 00:03:42.322 --> 00:03:45.325 to come here speaking. And now I'm here it's awesome to be here 00:03:45.325 --> 00:03:48.428 in front of you guys. I'm a student in Santa Barbara. And 00:03:48.428 --> 00:03:53.433 I'm actually there because of ctf. Shellfish is mostly from 00:03:53.433 --> 00:03:57.537 Santa Barbara and I joined them for Defcon qualifier and got 00:03:57.537 --> 00:04:02.175 pulled in and pulled into the lab. That was pretty cool. And I 00:04:02.175 --> 00:04:12.786 let my fish here to introduce himself. >> All right. You guys 00:04:12.786 --> 00:04:16.890 can hear me. Awesome. Thanks. I'm fish obviously. This is not 00:04:16.890 --> 00:04:22.295 my real name. I don't think you guys can read my real name if 00:04:22.295 --> 00:04:31.972 you are not from china. Anyone from china can read it. Probably 00:04:31.972 --> 00:04:37.511 not. You guys are honest. I'm a ph.d. student from Santa 00:04:37.511 --> 00:04:49.689 Barbara. Super famous from melting work. >> Super famous. 00:04:49.689 --> 00:04:57.631 >> And I've been playing Defcon ctf, this is my 4th year. But 00:04:57.631 --> 00:05:08.341 I've been playing ctf for 6 years. I'm a reverser. Yesterday 00:05:08.341 --> 00:05:18.785 I just solved my first one. First out of four years. So I'm 00:05:18.785 --> 00:05:22.489 very happy. So solve that challenge I didn't really sleep 00:05:22.489 --> 00:05:27.727 last night. And if I talk about some none sense today...that's a 00:05:27.727 --> 00:05:39.072 little bit about me and I will hand it back to yan. So this is 00:05:39.072 --> 00:05:45.145 I tin narrow today. And we might fail completely. Why we build 00:05:45.145 --> 00:05:59.726 it? Spoil alert releasing it. Then we will talk about what we 00:05:59.726 --> 00:06:05.732 designed it to do. We will talk about the different parts of our 00:06:05.732 --> 00:06:13.640 analysis system. We will talk about application of it. Show 00:06:13.640 --> 00:06:20.247 off some ctf challenge, solving or assisting ctf challenge and 00:06:20.247 --> 00:06:27.520 open-source release. >> Any of you guys playing ctf right now? 00:06:27.520 --> 00:06:35.729 Raise your hand. Couple of them. Okay. So you don't want to leave 00:06:35.729 --> 00:06:41.234 before the talk ends. >> Unless you are not shellfish then you 00:06:41.234 --> 00:06:50.010 should leave before we get to the live example. Okay. Let's 00:06:50.010 --> 00:06:54.748 jump into that. Why anger? Why do we build the binary analysis 00:06:54.748 --> 00:07:01.021 platform mostly from scratch of using the one available out 00:07:01.021 --> 00:07:07.927 there right now. In fact there are tons of them out there. I 00:07:07.927 --> 00:07:11.731 went through and see what's our competition kind of. There are 00:07:11.731 --> 00:07:17.837 enough to fill a fire slide. When we started anger two years 00:07:17.837 --> 00:07:27.514 ago there were not this many. But now everyone staring binary 00:07:27.514 --> 00:07:36.189 in ida. It came out 2005 or so. Ida kind of a defect toe binary 00:07:36.189 --> 00:07:42.896 analysis tool that everyone uses. So, of course, our 00:07:42.896 --> 00:07:48.201 long-term goal is to, you know, replace ida. Working with ida 00:07:48.201 --> 00:07:53.173 quite a lot it's sometimes frustrating. We have moments of 00:07:53.173 --> 00:08:00.780 why it's doing this, why it's designed it that way. The truth 00:08:00.780 --> 00:08:05.352 is design analysis tool is extremely difficult. They are 00:08:05.352 --> 00:08:11.825 nowhere near replacing ida but there are things we do ida does 00:08:11.825 --> 00:08:19.399 not and the way we do them there are no other software out there 00:08:19.399 --> 00:08:26.439 is capable. We will add one more name on it and hopefully you 00:08:26.439 --> 00:08:34.013 will find it useful, at least we do. So we are pretty excited. So 00:08:34.013 --> 00:08:38.885 let's talk about the fundamentals of anger. What did 00:08:38.885 --> 00:08:46.459 we design it to be like? The idea is we are all python user 00:08:46.459 --> 00:08:52.932 mostly in the lab. Show of hands. Who uses python as a 00:08:52.932 --> 00:08:58.938 primary hacking language. So anger is written in python and 00:09:15.555 --> 00:09:21.561 for python working on binary that gives us flexibility and 00:09:28.935 --> 00:09:33.873 explores analyses that are powerful and unique way. We will 00:09:33.873 --> 00:09:39.279 show how to you anger to quickly script symboliks executions, the 00:09:39.279 --> 00:09:45.185 finding of ropgadget and is so forth. And, of course, a core 00:09:45.185 --> 00:09:51.558 component of any modern analysis system is that it has to work on 00:09:51.558 --> 00:09:56.496 platform other than the nexus 86. By levering the station 00:09:56.496 --> 00:10:01.901 called vex, we support the 64-bit and 32-bit of all major 00:10:01.901 --> 00:10:06.806 architecture. And legitimate bs we did spark troll twit. We 00:10:06.806 --> 00:10:12.712 spent couple of days to hack spark four into this and it's 00:10:12.712 --> 00:10:17.650 almost there. It's pretty extensible. This is what a user 00:10:17.650 --> 00:10:23.523 using anger might go see. You just import it. Open up an 00:10:23.523 --> 00:10:29.929 example binary and then you will go into all of analyses and all 00:10:29.929 --> 00:10:35.835 of the things that anger offers later in the demo. Anger have 00:10:35.835 --> 00:10:40.273 several different components. A binary loader that's general. We 00:10:40.273 --> 00:10:47.413 can load pe files. We can't do much with pe files yet. But we 00:10:47.413 --> 00:10:50.617 can load them and start executing until we hit some 00:10:50.617 --> 00:10:58.525 environmental interactions. We are linux binary and so forth, 00:10:58.525 --> 00:11:02.962 and we even support [ inaudible ] so if you have dump off of iot 00:11:02.962 --> 00:11:09.836 device, anger will tell you where you can load in memory and 00:11:09.836 --> 00:11:15.909 start analysis it. Fish will talk and symboliks execution 00:11:15.909 --> 00:11:21.314 engine and the symboliks execution engine is capable 00:11:21.314 --> 00:11:26.719 identifying unsafe situations and reversing what inputs need 00:11:26.719 --> 00:11:32.725 to be drive a program down a spect bat. So let's dive in. We 00:11:36.195 --> 00:11:42.302 will start with symboliks execution. Whoa. And we are 00:11:42.302 --> 00:11:49.342 done. [ laughter in the room ] It's been nice talking to you 00:11:49.342 --> 00:11:55.348 guys. I'm sure this is one of many situations. Awesome. And 00:11:58.718 --> 00:12:05.825 now it's no longer full screen. Awesome. And okay. We are almost 00:12:05.825 --> 00:12:11.831 there. Boom! [applause] Thank you. That was the first demo. 00:12:16.069 --> 00:12:22.075 Start with symboliks execution. It's a sub that has been around 00:12:25.511 --> 00:12:32.285 a little while and gaining more prominence. I don't know if you 00:12:32.285 --> 00:12:35.221 were at yesterday's talk on symboliks execution on another 00:12:35.221 --> 00:12:45.031 analysis system. This is kind of analogous thing. What's 00:12:45.031 --> 00:12:49.702 symboliks execution is. Answer the question how do I trigger a 00:12:49.702 --> 00:12:55.008 certain path or a certain condition. So you might imagine 00:12:55.008 --> 00:13:00.013 a binary that does something when you give it a certain input 00:13:00.013 --> 00:13:07.553 like crack me ctf challenge which we will look at later. And 00:13:07.553 --> 00:13:09.422 how would you interact with that. Just give it input. You 00:13:09.422 --> 00:13:16.929 say, here's a guess, is it good. And it will tell you no. Most 00:13:16.929 --> 00:13:21.100 likely you are not going to guess a flag. And you can do 00:13:21.100 --> 00:13:27.273 some sort of flag analysis. Do ida randomly. Looking at binary 00:13:27.273 --> 00:13:31.411 and clicking here and there. And you can do this way, it's not 00:13:31.411 --> 00:13:38.418 going to give you an answer because it's not precise enough. 00:13:38.418 --> 00:13:45.158 We will talk about status analysis later on. Now we need 00:13:45.158 --> 00:13:53.433 symboliks execution. We interpret an application as we 00:13:53.433 --> 00:14:01.774 interpret it we track constraint symboliks variables and required 00:14:01.774 --> 00:14:06.913 condition is trigger and see a path that we like we conquertize 00:14:06.913 --> 00:14:10.550 the input, the variables to identify possible concrete 00:14:10.550 --> 00:14:20.893 input. A quick example of this, if you have a constraint on 00:14:20.893 --> 00:14:28.501 symboliks x. You can do constraints solve. Come up with 00:14:28.501 --> 00:14:37.610 a number 42. In this case it's super trivial and in general 00:14:37.610 --> 00:14:45.218 it's an empty problem and it's kind of pain in the ass. You 00:14:45.218 --> 00:14:51.124 start constraint solve and it will never finish. That's one of 00:14:51.124 --> 00:14:51.324 the challenge in symboliks execution. Let's go for example 00:14:51.324 --> 00:15:03.236 program. Anger analysis binary. Not python. But python is more 00:15:03.236 --> 00:15:07.774 approachable. Bonus points if you can catch the vulnerability 00:15:07.774 --> 00:15:12.645 in this program by the way. First thing we do with symboliks 00:15:12.645 --> 00:15:20.219 execution is go line by line, hit this input. You see blue and 00:15:20.219 --> 00:15:27.160 execute it. That input symboliks variable x. X is unfounded. It 00:15:27.160 --> 00:15:32.131 does no known constraint on it. Then we continue executing and 00:15:32.131 --> 00:15:37.937 we will hit this branch and what it does is it splits into two 00:15:37.937 --> 00:15:43.543 possibilities. And so one of the possibilities is when x was 00:15:43.543 --> 00:15:47.713 greater than ten and that branch was taken otherwise it's the 00:15:47.713 --> 00:15:54.787 inverse of that x is less than ten. And so we continue 00:15:54.787 --> 00:15:57.523 executing. Now we have two states. Keep that in mind. So my 00:15:57.523 --> 00:16:01.127 frustration there's multiple state and we will see why that's 00:16:01.127 --> 00:16:04.263 the problem. So now we have two states. And one branch, one 00:16:04.263 --> 00:16:11.037 state is not done yet. And it splits as well according to the 00:16:11.037 --> 00:16:18.477 different possibilities. Then if you want to answer the question 00:16:18.477 --> 00:16:22.682 of what does it take to print two in this scenario. In order 00:16:22.682 --> 00:16:28.354 to print two we have our constraint we have the state 00:16:28.354 --> 00:16:31.357 that path made it there and we do constraint solve and 00:16:31.357 --> 00:16:35.127 constraint solve tell you you can put 99 or 42 and so forth 00:16:35.127 --> 00:16:42.668 and give that dynamically to the program, launch it and see the 00:16:42.668 --> 00:16:50.209 expected there. So let's do a demo of kind of very simply 00:16:50.209 --> 00:16:55.114 binary that have this tool backdoor that we want to detect 00:16:55.114 --> 00:16:59.585 with symboliks execution. This key come is from me because I 00:16:59.585 --> 00:17:09.996 stupidly get pulled right before doing this and so I don't think 00:17:09.996 --> 00:17:14.667 it works anymore. So we might have to switch to fish's laptop. 00:17:14.667 --> 00:17:32.585 Can everyone see that? Awesome. So we launch it. Okay. We will 00:17:32.585 --> 00:17:36.222 switch to fish's laptop for this demo. This is what live demo is 00:17:36.222 --> 00:17:49.168 all about. Python exceptions. There you go. So fish uses 00:17:49.168 --> 00:17:58.611 window, I know it's embarrassing. Bare with us. >> 00:17:58.611 --> 00:18:00.713 You know like in this kind of situation window is never [ 00:18:00.713 --> 00:18:08.020 inaudible ] [ laughter in the room ] >> At least it's a linux 00:18:08.020 --> 00:18:12.191 vn. >> Anger currently support linux. In the future it will be 00:18:12.191 --> 00:18:22.401 run on windows. >> Allegedly. So this is an anger management. 00:18:22.401 --> 00:18:29.308 Anger's gui to do symboliks analysis and static analysis. So 00:18:29.308 --> 00:18:35.381 we will look at this tool binary we have that's nice for testing 00:18:35.381 --> 00:18:43.389 and explain what symboliks execution mean and let's look at 00:18:43.389 --> 00:18:49.161 ida first. As I said, of course, everyone uses ida, oh, the 00:18:49.161 --> 00:19:00.539 source code. Yeah. We do. Great. All right. So we will just look 00:19:00.539 --> 00:19:13.886 at it. The, this binary is a binary that asks...we do have 00:19:13.886 --> 00:19:36.175 the source code. All right. So here is.... >> Is it readable? 00:19:36.175 --> 00:19:47.153 >> Awesome. All right. Guys, if you can't read this, then we are 00:19:47.153 --> 00:19:52.324 screwed. So it's a very simple binary. It has user name 00:19:52.324 --> 00:19:55.695 password. It takes the user name password as input. And it cause 00:19:55.695 --> 00:20:01.534 authenticate function return one and says you've been accepted. 00:20:01.534 --> 00:20:06.172 Authenticate function has a backdoor. If you pass string 00:20:06.172 --> 00:20:14.880 compare, then you will authenticate automatically. So 00:20:14.880 --> 00:20:21.787 it's possible to detect this automatically in anger 00:20:21.787 --> 00:20:26.826 management. So here's the gui. Over here we have the display of 00:20:26.826 --> 00:20:33.566 what paths are currently active in the analysis. We can run 00:20:33.566 --> 00:20:37.036 multiply analyses at the same time and never run just one. We 00:20:37.036 --> 00:20:41.540 can stub these paths and we can look at what's present currently 00:20:41.540 --> 00:20:47.980 in their registers. Is there a way you can scroll somehow? So 00:20:47.980 --> 00:20:58.791 this is what's currently on the stack. So then, we can take that 00:20:58.791 --> 00:21:05.297 and stop it. Let's execute until it branches. So here we have a 00:21:05.297 --> 00:21:13.005 path that branched. And it branched for some reason and 00:21:13.005 --> 00:21:18.477 that reason is because there's user that's symboliks variable 00:21:18.477 --> 00:21:21.881 that can be compromise to anything. And here we can 00:21:21.881 --> 00:21:31.757 actually look at it. You can look at user input and we see 00:21:31.757 --> 00:21:39.832 that...fisher I can't use your mouse. Oh, I'm touching...but 00:21:39.832 --> 00:21:47.806 you can see that on one hand the user can input any password and 00:21:47.806 --> 00:21:52.144 it does one thing and if the user input sneaky it does 00:21:52.144 --> 00:21:58.918 another. If you look at standard output instead and we keep 00:21:58.918 --> 00:22:06.692 stepping, there. You'll see that here when the user input so 00:22:06.692 --> 00:22:12.198 sneaky it immediately trusted him and let him in so this is an 00:22:12.198 --> 00:22:18.370 example how symboliks execution can help us analysis binary and 00:22:18.370 --> 00:22:22.474 we will go into more complexed one for ctf challenges. So 00:22:22.474 --> 00:22:56.008 let's...there. Oh, come on. Great. That was my temporary 00:22:56.008 --> 00:23:05.117 Defcon password. It's gone! Great. Yeah. Let's keep going on 00:23:05.117 --> 00:23:10.756 yours. People tell me not to use linux for presentation but I 00:23:10.756 --> 00:23:25.537 don't believe them. I think it's just fine. But it's dark magic. 00:23:25.537 --> 00:23:33.846 So oh, well it's you. So along with that, status analyses. >> I 00:23:33.846 --> 00:23:43.289 just figure out has taken too much of my time so I will keep 00:23:43.289 --> 00:23:47.893 it simple so I will talk a little bit it. If you are 00:23:47.893 --> 00:23:56.635 interested you should come to my lab and become ph.d. student. So 00:23:56.635 --> 00:24:00.439 let's start. Before we know binary we all need to know 00:24:00.439 --> 00:24:08.747 control flow. The first thing you see is a property box. You 00:24:08.747 --> 00:24:14.653 click okay. You will see control flow. We also do the same. In 00:24:14.653 --> 00:24:18.991 anger management that's our gui. We will show you the graph of 00:24:18.991 --> 00:24:23.896 every single function very to ida. What's the difference? It's 00:24:23.896 --> 00:24:33.972 more accurate, more adjustment, the result is it's much slower. 00:24:33.972 --> 00:24:38.377 That is because we support multiple options like contact 00:24:38.377 --> 00:24:44.783 activity level support like backward sleazing, et cetera. To 00:24:44.783 --> 00:24:50.689 automatically resolve some stuff that's hard to resolve normally 00:24:50.689 --> 00:24:54.393 or statically. For example jump target or virtual pointer 00:24:54.393 --> 00:25:01.266 tables. In comparing that cfg is faster. This is how we create 00:25:01.266 --> 00:25:14.613 cfg in anger. First line input, second line create, the binary 00:25:14.613 --> 00:25:22.054 name, third line you see.cfg. Press enter and it will give you 00:25:22.054 --> 00:25:29.228 cfg. We want to see how many basic blocks there are. There 00:25:29.228 --> 00:25:34.967 are 78. So if you want a faster cfg and you don't want to buy 00:25:34.967 --> 00:25:41.840 ida you can check this out. It's a fast mode of cfg generation 00:25:41.840 --> 00:25:48.647 that doesn't do any symboliks solving. There's also boy scott. 00:25:48.647 --> 00:26:00.125 All right. Another static analysis routine in anger is 00:26:00.125 --> 00:26:08.000 value set analysis. This is a kind of abstract interpretation. 00:26:08.000 --> 00:26:12.438 In case some people haven't heard of that is kind of static 00:26:12.438 --> 00:26:24.283 analysis to execute part of the program. There's a loop, in that 00:26:24.283 --> 00:26:33.225 it will loop three times. Then we figure out the semantics of 00:26:33.225 --> 00:26:39.231 the program and execute part of the program. So that gives us 00:26:39.231 --> 00:26:45.838 the possibility if enumerating the state space because we are 00:26:45.838 --> 00:26:49.141 not executing all the program. We are exhausting the state 00:26:49.141 --> 00:26:56.915 space. On top of that we can have variable recovery. And on 00:26:56.915 --> 00:27:04.923 top that we can build memory and type inference. Credit goes to 00:27:04.923 --> 00:27:09.328 the author of this paper. I tried so hard to read your name. 00:27:09.328 --> 00:27:15.868 He's the creator of vsa value set analysis. Here's an example 00:27:15.868 --> 00:27:30.649 of what the value set analysis looks like. Here's a piece of x 00:27:30.649 --> 00:27:41.260 64 assembly. You have 5 seconds to read it. Okay. Great. I think 00:27:41.260 --> 00:27:47.566 if you know this, you will understand this program. So what 00:27:47.566 --> 00:27:55.474 is that in the yellow square? It's symboliks execution, it 00:27:55.474 --> 00:28:05.717 will just keep executing it. The problem is at every of the loop 00:28:05.717 --> 00:28:17.362 it will branch out. Zero acts 25 thousand different states. If 00:28:17.362 --> 00:28:26.238 you are using this, rbi will do anything. Because we are not 00:28:26.238 --> 00:28:30.943 following every single branch. With random analysis we can 00:28:30.943 --> 00:28:42.220 actually tell rbx is less than 1025. Is that good enough? Try 00:28:42.220 --> 00:28:53.899 to do better. Value set analysis, this is one of the 00:28:53.899 --> 00:29:00.172 type of values that the value set analysis is using. It's 00:29:00.172 --> 00:29:01.473 called strident intervals. A set of number can describe in upper 00:29:01.473 --> 00:29:06.111 bound and must strike between each single value and their 00:29:06.111 --> 00:29:14.086 size. So here the interval can be computerize and be it means 00:29:14.086 --> 00:29:22.961 nine different values. Between zero x 100, zero x 4. That's 00:29:22.961 --> 00:29:30.469 what stripe mean. What is rbx in the little square? We take the 00:29:30.469 --> 00:29:40.879 loop, rbx can be from zero to 4. Second interaction it can be 00:29:40.879 --> 00:29:51.857 from z to 8. And next z to -- and after the loop is not 00:29:51.857 --> 00:29:56.862 terminating. What do we do? If it's looping forever if we 00:29:56.862 --> 00:30:06.772 continue? No. Rbx go to infinite. After that zero to 00:30:06.772 --> 00:30:11.443 infinite is not accurate enough. We perform a narrate. It becomes 00:30:11.443 --> 00:30:19.117 zero 1024 with that. In this case it's pretty accurate. We 00:30:19.117 --> 00:30:23.121 extended the original random set analysis following two different 00:30:23.121 --> 00:30:29.261 improvements. The first one we name it limited related 00:30:29.261 --> 00:30:35.734 analysis. In this case. Normal vsa will be able to tell the 00:30:35.734 --> 00:30:40.706 bound of rex should be 5, rcx they don't do any relation 00:30:40.706 --> 00:30:47.713 tracking. They don't know that. We are doing some limited amount 00:30:47.713 --> 00:30:52.617 of variable relation tracking and in this case we are able to 00:30:52.617 --> 00:31:00.225 tell rcx equals r plus 1 and rcx 36. That improvement we made our 00:31:00.225 --> 00:31:07.699 vsa agnostic. We included another analysis called rapt 00:31:07.699 --> 00:31:16.608 interval analysis. The credit goes to this guy published in 00:31:16.608 --> 00:31:28.854 2012. With that the precision is quickly improved. And now I'll 00:31:28.854 --> 00:31:32.324 give back to yan, and we will talk about application and reel 00:31:32.324 --> 00:31:43.335 demo. >> All that technical talk or theoretical talk maybe a 00:31:43.335 --> 00:31:48.740 little boring but it's necessary to get us into the actual anger 00:31:48.740 --> 00:31:52.244 application. Here we will demo off the thing that we do and you 00:31:52.244 --> 00:31:58.049 can do with anger. First we will demo off ropgadget finder. 00:31:58.049 --> 00:32:08.260 Ropgadget or x rub that will tell you there's the gadget and 00:32:08.260 --> 00:32:14.032 the instructions. This tells you what the gadget does and you can 00:32:14.032 --> 00:32:22.307 filter it down later. And, of course, implemented in anger and 00:32:22.307 --> 00:32:25.710 it's super easy to use. So here's the example. So we load 00:32:25.710 --> 00:32:31.650 ctf binary called nuclear. I'm not from this Defcon ctf but 00:32:31.650 --> 00:32:36.354 different ctf in the past and we analyze it. We want all 00:32:36.354 --> 00:32:40.425 ropgadget find them and print them out. So let's do that. 00:32:40.425 --> 00:32:51.503 Because it does semantic analysis. It's a little bit 00:32:51.503 --> 00:32:57.943 slow. So it takes 20 seconds maybe a little bit more for this 00:32:57.943 --> 00:33:01.980 guy. So right now anger is analyzing every basic block and 00:33:01.980 --> 00:33:07.018 figuring out semantics. What register to touch, how much 00:33:07.018 --> 00:33:13.058 change the stack by and where it writes to in relation to the 00:33:13.058 --> 00:33:19.297 variation registers that it uses. So here's an example 00:33:19.297 --> 00:33:25.136 gadget. It's a gadget at ox 4040 c and binary changes the stack 00:33:25.136 --> 00:33:31.743 by ox 14 it pops rbx and rbv and it does a memory write to this 00:33:31.743 --> 00:33:37.282 address. So this is actually on the stack. It doesn't memory 00:33:37.282 --> 00:33:43.255 write onto the stack. And the memory read from address that 00:33:43.255 --> 00:33:46.992 depends on rvp. This gives of information. In fact our next 00:33:46.992 --> 00:33:52.864 step is to implement rop compiler based on this. We were 00:33:52.864 --> 00:33:55.967 hoping to have this but not quite ready but stay tuned. 00:33:55.967 --> 00:34:03.541 Another thing that I'll demo off is a how to solve a crypto 00:34:03.541 --> 00:34:11.816 challenge in anger. This is more of a crack me. But it's a cool 00:34:11.816 --> 00:34:15.754 little demo of anger's ability. The challenge is from a white 00:34:15.754 --> 00:34:20.558 hat ctf. It's a ctf that happened last month and then I 00:34:20.558 --> 00:34:27.032 was looking at the challenge later to see some crypto. And 00:34:27.032 --> 00:34:30.068 found this. Figured it would be a good example for you guys. 00:34:30.068 --> 00:34:35.607 This challenge takes input on the command-line and standard 00:34:35.607 --> 00:34:40.545 crack me fax. It tells you if you are right or wrong. In 00:34:40.545 --> 00:34:43.915 general we try to guess, we are wrong. Let's open up an ida. We 00:34:43.915 --> 00:34:51.723 start looking around and the binary is really big. So, of 00:34:51.723 --> 00:35:00.098 course, we can start drilling down into parts of the binary. 00:35:00.098 --> 00:35:06.404 Figuring out what it might do. We can did he come pile it and 00:35:06.404 --> 00:35:10.709 try to figure out. One of the first things we see immediately 00:35:10.709 --> 00:35:24.322 is it does something. And if this return zero, it says please 00:35:24.322 --> 00:35:28.426 check again. All right. Let's look at it. And it does some 00:35:28.426 --> 00:35:33.398 complicated stuff. But there are equals equals eight. This is 00:35:33.398 --> 00:35:44.743 part of the process for solving the challenge. So I went, quit 00:35:44.743 --> 00:35:52.017 out of ida. Went to anger. I wrote a little...whoa a little 00:35:52.017 --> 00:35:56.755 bit of code. So it just heavily commented in our example 00:35:56.755 --> 00:36:05.030 repository. We opened the binary. Anger, symboliks 00:36:05.030 --> 00:36:08.066 execution have trouble with certain kinds of code especially 00:36:08.066 --> 00:36:15.106 in static binary. I hook with python replacement to help them 00:36:15.106 --> 00:36:23.882 along. And then basically I ran it. I said, I created a path gui 00:36:23.882 --> 00:36:31.656 which is a single entry point of symboliks execution engine and I 00:36:31.656 --> 00:36:36.461 told it to go and find this point. And this is the point 00:36:36.461 --> 00:36:44.135 where it says it passes this stage and it says the input is 00:36:44.135 --> 00:36:47.872 okay. And it does some more processing and this is the pain 00:36:47.872 --> 00:36:51.910 in the butt to get through. So let's look at where we are at 00:36:51.910 --> 00:36:57.716 this point. It turns out at that point the key space is much 00:36:57.716 --> 00:37:00.118 reduced the possible key space to make that point in and after 00:37:00.118 --> 00:37:05.990 that is root forcible. So here I get the possible value from 00:37:05.990 --> 00:37:11.663 anger. And, of course, how to do this is all not docs. Or look at 00:37:11.663 --> 00:37:16.668 this example. With the very fancy practicing bar and test 00:37:16.668 --> 00:37:23.875 every possible value until I get the right now. Allowing me to 00:37:23.875 --> 00:37:37.388 solve this crypto challenge. So let's see how this goes. Run it 00:37:37.388 --> 00:37:44.829 here. Here anger stepping through the binary, it's at this 00:37:44.829 --> 00:37:51.736 point where the input was is tested again. I guess at this 00:37:51.736 --> 00:38:00.745 point. And now it's just trying to reduce the set of 00:38:00.745 --> 00:38:03.882 possibilities which found from 8 bytes to 6 thousand more 00:38:03.882 --> 00:38:08.786 possibilities. This is an example guess debugging 00:38:08.786 --> 00:38:12.690 iterating through the possible keys that can even make it 00:38:12.690 --> 00:38:18.563 through this point and try to find one that says success. It 00:38:18.563 --> 00:38:23.201 should find it at the 80% mark. I'm surprised that it hasn't 00:38:23.201 --> 00:38:28.940 crashed yet. Boom. We found it. The flag is this. If we run a 00:38:28.940 --> 00:38:38.149 crypto, actually this is the input. If you run the binary, 00:38:38.149 --> 00:38:47.225 boom. So anger is very useful for these sorts of challenges. 00:38:47.225 --> 00:38:58.002 I'll pass it onto fish to look at real world or ctf that's 00:38:58.002 --> 00:39:17.422 happening now and how to use anger for that. >> So one of the 00:39:17.422 --> 00:39:21.726 anger's ability is load up binary, execute arbitrary part 00:39:21.726 --> 00:39:28.099 of the code in it. I had some demos for it before and prepared 00:39:28.099 --> 00:39:30.101 Defcon but yesterday when I was playing ctf Defcon there was a 00:39:30.101 --> 00:39:32.503 challenge for another. This is a good one to talk about for 00:39:32.503 --> 00:39:47.118 anger. >> Cover your ears, please. >> Rxc is 64-bit binary. 00:39:47.118 --> 00:39:53.825 It's big reverse is hard. We spend a long time reversing it. 00:39:53.825 --> 00:39:57.729 Before that we got some suspected rob chain. What does 00:39:57.729 --> 00:40:12.010 rob chain do? I mean we can definitely hire a bunch of 00:40:12.010 --> 00:40:20.752 monkey to figure out but we have anger. >> The monkey we hire 00:40:20.752 --> 00:40:28.826 would be ourselves. >> So this is our rop chain execution 00:40:28.826 --> 00:40:36.067 program called derop. You pass the rop chain load the binary 00:40:36.067 --> 00:40:45.009 rfc and dump all our stack. Create a state. I dump that on 00:40:45.009 --> 00:40:54.385 our stack, and then I execute it. I use explorer, execute and 00:40:54.385 --> 00:41:05.430 return. Let's run this program. Python rop chain to pi. We 00:41:05.430 --> 00:41:28.052 return the first rop chain. Bummer. It's called r. >> Very 00:41:28.052 --> 00:41:40.131 descriptive variable name. >> There's an unconstraint path. >> 00:41:40.131 --> 00:41:42.767 Of course, this is all. >> Fie rows. >> This is technical. You 00:41:42.767 --> 00:41:46.504 can read the documentation to see what's going on. >> This is 00:41:46.504 --> 00:41:52.343 the exact path that rop chain is following. And now, of course, 00:41:52.343 --> 00:41:55.813 you have the ability to read every single state and every 00:41:55.813 --> 00:41:58.883 point in the chain. The next example for the same binary, in 00:41:58.883 --> 00:42:14.165 this binary there's a really interesting function. It does 00:42:14.165 --> 00:42:20.338 some encryption. And later on we figure out it's t. We don't want 00:42:20.338 --> 00:42:26.844 to implement out when we were writing exploits -- (inaudible) 00:42:26.844 --> 00:42:33.951 -- what do we do about it? Luckily we have python. Great. 00:42:33.951 --> 00:42:40.458 So there's another program I wrote it's small called 00:42:40.458 --> 00:42:48.266 collarbone. What it does is it takes in a data live and 00:42:48.266 --> 00:42:53.938 encrypted with the exact program, srd exact function in 00:42:53.938 --> 00:43:00.044 that rxe program with the exact encryption function. So it has 00:43:00.044 --> 00:43:05.817 30 something lines of code and then you don't understand to 00:43:05.817 --> 00:43:10.221 encryption function anymore. You spot python and automatically 00:43:10.221 --> 00:43:21.199 encryption for you. Let's try it. Python. Call it pi. 8 bytes. 00:43:21.199 --> 00:43:31.209 And then you get encrypted data that it all works. >> Whoa. 00:43:31.209 --> 00:43:39.016 Binary dipping but interest of time you can check this out on 00:43:39.016 --> 00:43:54.599 your own and we will briefly talk about cdc. You know it's a 00:43:54.599 --> 00:43:57.635 cyber grand challenge. That's the machine, one of the machines 00:43:57.635 --> 00:44:00.705 that will be running the finals where machines will battle each 00:44:00.705 --> 00:44:03.341 other for hacking some premises next Defcon. Shelf fish accept 00:44:03.341 --> 00:44:17.221 this challenge and we manage to qualify. There has been a lot of 00:44:17.221 --> 00:44:19.023 presenting. Go back. This is a very clever sets of slides. 00:44:19.023 --> 00:44:20.124 Shellfish participated in this challenge. And we qualify 00:44:20.124 --> 00:44:24.529 putting from just another ctf into the richest ctf teams in 00:44:24.529 --> 00:44:30.801 the world along with others who qualify. With the cdc we use the 00:44:30.801 --> 00:44:36.841 cyber link system exploits from binary and patch them. It is 00:44:36.841 --> 00:44:42.813 complex and anger actually sat at the core of every component. 00:44:42.813 --> 00:44:47.218 Which is pretty cool. So check out the system. It's real world 00:44:47.218 --> 00:44:53.925 system with real world uses and we love it. And it's 00:44:53.925 --> 00:45:01.198 open-source. With special thanks to our professor darpa with two 00:45:01.198 --> 00:45:07.405 different project anger was developed for. And, of course, 00:45:07.405 --> 00:45:13.044 all of, the contributors to anger that we've gone over. You 00:45:13.044 --> 00:45:21.319 can pull it at get hub. Anger dot o scribe to our mailing list 00:45:21.319 --> 00:45:28.259 and we welcome questions. We were hoping to make this next 00:45:28.259 --> 00:45:32.463 generation binary analysis tool and we hope to work with you to 00:45:32.463 --> 00:45:38.402 do it. Anger is two years old now with almost 60 thousand code 00:45:38.402 --> 00:45:45.109 about 6 thousand commits and we love all of you working with it 00:45:45.109 --> 00:45:50.648 with us. Any questions? I guess no questions. [ applause ] 00:45:50.648 --> 00:00:00.000 Thanks. >> Thank you guys.