00:00:00.200 --> 00:00:03.103 All right. Good evening, everybody. How are we doing? 00:00:03.103 --> 00:00:10.644 Good? Good. Awesome. How many people [ inaudible ] today? How 00:00:10.644 --> 00:00:16.650 many first timers? Ctf area. When I came to my first Defcon 00:00:18.919 --> 00:00:26.460 and all the lights and everybody hacking everybody else, it's the 00:00:26.460 --> 00:00:32.466 coolest thing. The Defcon ctf is about the hardest contest in the 00:00:34.701 --> 00:00:41.575 world. And this team has won four times. Four different 00:00:41.575 --> 00:00:45.045 times. One of the best things I like about Defcon and coming and 00:00:45.045 --> 00:00:51.051 finding people are just better at stuff than we are. Here we 00:00:53.587 --> 00:00:56.757 are all learning from everybody else. It's my pleasure to 00:00:56.757 --> 00:01:02.129 introduce Atlas with some technical stuff. Give him a big 00:01:02.129 --> 00:01:08.135 hand [ applause ] >> Hey, y'all. How many have participated in 00:01:11.972 --> 00:01:16.643 capture the flag? How many are doing so right now and coming to 00:01:16.643 --> 00:01:22.049 see me? Thank you that's very hot. How many of you are 00:01:22.049 --> 00:01:29.389 government? [ laughs ] I saw that. Well, welcome. Today we 00:01:29.389 --> 00:01:32.292 will talk about symboliks analysis. The creator of which 00:01:32.292 --> 00:01:38.465 who were threatening to show up today. Dodged that bullet. How 00:01:38.465 --> 00:01:43.403 many of you have heard of symboliks execution? How about 00:01:43.403 --> 00:01:45.405 symboliks analysis in larger scale. Is symboliks execution 00:01:45.405 --> 00:01:47.407 the only thing you've heard of? Today we will talk about some of 00:01:47.407 --> 00:01:49.409 the difficulties with doing binary analysis and doing some 00:01:49.409 --> 00:01:51.411 of the holy crap. I'm closed captioned. I love it. [ laughs 00:01:51.411 --> 00:01:57.150 ]. So today we will talk about symboliks analysis and it's used 00:01:57.150 --> 00:02:03.090 to determining interesting things about binary. Um, a 00:02:32.986 --> 00:02:37.824 little bit about me. Very fast. I'm a Jesus follower. Walk out 00:02:37.824 --> 00:02:44.197 if do you like. One wife. Father of three I have goats and 00:02:44.197 --> 00:02:51.438 chickens and I ride a Honda shadow 2002 but that's not why 00:02:51.438 --> 00:02:59.312 you are here. I'm also this guy like to tear things apart. Make 00:02:59.312 --> 00:03:05.385 and break things in interesting way. And learned from some of 00:03:05.385 --> 00:03:12.092 you in the crowd. I'm fucking rock star. This is about. This 00:03:12.092 --> 00:03:17.964 is cool shit. Let's make good use of it. Once you want to kill 00:03:17.964 --> 00:03:23.570 all the bugs and let them lead long productive lives, hopefully 00:03:23.570 --> 00:03:30.510 this will help out. I'm tripping over my tongue as well. Reverse 00:03:30.510 --> 00:03:36.616 engineering I my hardware, radio, firmware, software and 00:03:36.616 --> 00:03:41.822 cars medical devices, smart meters the whole thing. I'm a 00:03:41.822 --> 00:03:46.426 bit add. If it weren't for my wife, I would probably be dead. 00:03:46.426 --> 00:03:52.432 I'm a core developer created by invisigod. Binary analysis 00:03:57.704 --> 00:04:05.645 framework. It is written in pure python, you can poke at and 00:04:05.645 --> 00:04:11.418 figure out how code flows through your binary. It provides 00:04:11.418 --> 00:04:17.858 scripting options. And written from scratch to be 00:04:17.858 --> 00:04:21.862 collaborative, there's a client server model and shared space 00:04:21.862 --> 00:04:28.368 model. It includes a multi platform debugger. Emulator for 00:04:28.368 --> 00:04:35.108 multiple platforms a gui for those who want one. Focus on 00:04:35.108 --> 00:04:41.381 program analysis. We want to write programs that finds and 00:04:41.381 --> 00:04:47.387 exploit it. Yeah. I think we are in the right time. Give it the 00:04:49.422 --> 00:04:53.293 colorize version because the last one was so hard. I'm going 00:04:53.293 --> 00:05:00.934 to through some codes at you early on so it's familiar to you 00:05:00.934 --> 00:05:05.372 so you can go back to the slides later and start your binary and 00:05:05.372 --> 00:05:11.378 your own interactive. To start vin bin. Don't bring up a gui so 00:05:15.749 --> 00:05:21.755 that it slows down and analyze the crap out of it. For today we 00:05:24.858 --> 00:05:30.864 will be talking about stage 5 from 2005. It creates.viv file 00:05:34.434 --> 00:05:41.441 which is a list of events that happen from the creation. It 00:05:41.441 --> 00:05:46.947 means it's not fully implemented yet. There are ways to back out 00:05:46.947 --> 00:05:52.953 changes, those who know, you know why that's important. Can 00:05:55.789 --> 00:06:01.728 you see vulnerability in this slide? Yes. It's too small. Look 00:06:06.266 --> 00:06:12.272 again. If you can't read it, that is a push 2047 a call to, 00:06:15.775 --> 00:06:21.781 pushing an input buffer, bushing rx zero which is the socket and 00:06:23.917 --> 00:06:31.725 then reading. So we are reading 2047 bytes. It basically goes on 00:06:31.725 --> 00:06:36.029 forever. This is not a buffer overflow. Down below load 00:06:36.029 --> 00:06:42.035 effective address. Blah. Blah. Blah. That's basically a [ 00:06:45.639 --> 00:06:52.512 inaudible ] and then a call to scan f. Scan f reads in. Well up 00:06:52.512 --> 00:06:58.718 to the end of the string, right? Causing any stack mash and easy 00:06:58.718 --> 00:07:05.892 to implement exploits. Here's how I like to view this. Most 00:07:05.892 --> 00:07:11.898 often I will have two ways of accessing this. The viv gui so I 00:07:16.269 --> 00:07:23.543 can scroll through analysis. Poke into a server which handled 00:07:23.543 --> 00:07:31.051 and command-line tool. I make changes in the gui and 00:07:31.051 --> 00:07:35.889 command-line, it all updates, 2 gui changes when I run my 00:07:35.889 --> 00:07:41.394 analysis stuff. If you are using python and not I python, i'm 00:07:41.394 --> 00:07:47.400 sure please consider seeing the light. Important viv, cli that's 00:07:52.605 --> 00:07:59.279 standard python stuff. We create a vivid sec work space. We then 00:07:59.279 --> 00:08:05.218 load from a file and it will look for, pe, an I hex or a 00:08:07.520 --> 00:08:13.526 binary a blob. And it just puts the loadable modules into the 00:08:15.829 --> 00:08:22.035 work space and does nothing else. I then call analyze. It 00:08:22.035 --> 00:08:28.041 does automatic analysis. And then I call say work space and 00:08:31.311 --> 00:08:34.881 it saves out all the events that have happened during analysis 00:08:34.881 --> 00:08:40.887 including the loading. There we go. So that's enough about viv 00:08:44.691 --> 00:08:50.697 for now, enough to get you started. Symboliks. What are the 00:08:54.434 --> 00:09:01.241 core for this is nv disassembling framework. In 00:09:01.241 --> 00:09:08.014 order to make this module you are supposed to great an 00:09:08.014 --> 00:09:15.588 emulator. It's amazing when it does when you are analyzing 00:09:15.588 --> 00:09:22.262 particularly in arm. They have conditional everything and 00:09:22.262 --> 00:09:28.268 there's hopping back and forth between arm and thumb mode. The 00:09:32.138 --> 00:09:39.112 idea of symboliks is the dragging of system state from a 00:09:39.112 --> 00:09:43.883 beginning of a code path through to some end state. So maybe 00:09:43.883 --> 00:09:51.057 that's from an entry of a function, return, and many of 00:09:51.057 --> 00:09:54.093 you will know there are many ways through a function that has 00:09:54.093 --> 00:10:00.099 beginning and end. So we choose one. But for this point, just 00:10:03.803 --> 00:10:07.507 think of a list of assemble instructions that will get 00:10:07.507 --> 00:10:13.213 executed in a roll. Those assembly instruction transfer to 00:10:13.213 --> 00:10:18.952 the symboliks effects they would have on the underline processor. 00:10:20.987 --> 00:10:26.993 For example, cvp shout out if you know what that is. Yes. Sir. 00:10:30.864 --> 00:10:38.238 It's function prologue. Exactly. So we translate these into 00:10:38.238 --> 00:10:44.544 symboliks effects. And then later I translated this into 00:10:44.544 --> 00:10:47.814 applied effects and we will talk about the difference. So it 00:10:47.814 --> 00:10:53.820 becomes set esp to esp minus 4 and then memory location the esp 00:10:57.090 --> 00:11:04.597 points to now it has holds the edp values. And then we update 00:11:04.597 --> 00:11:10.603 that with the new esp. I have a fly and it's bugging me. So we 00:11:19.345 --> 00:11:25.151 have to talk about graft theory. The single threat of program can 00:11:25.151 --> 00:11:28.621 find vulnerability in an especially crafted thing. What 00:11:28.621 --> 00:11:35.128 we are trying to do is execute code path as many as we can that 00:11:35.128 --> 00:11:40.767 are valuable and to do so we rely on graph theory. Have you 00:11:40.767 --> 00:11:48.308 heard of graph theory? I hope so. Graph theory is amazing. 00:11:48.308 --> 00:11:53.880 It's not necessarily easy. It covers some complex problems. 00:11:53.880 --> 00:11:58.651 There have been times where I found, a while back, didn't do a 00:11:58.651 --> 00:12:04.023 good a job of creating a graph for a particular problem and it 00:12:04.023 --> 00:12:07.093 caused me great headache so there's where the first bullet 00:12:07.093 --> 00:12:13.099 came from. You've probably interacted with certain visual 00:12:15.101 --> 00:12:22.575 aspect of graph theory. You turned apart a function and 00:12:22.575 --> 00:12:28.481 you've looked at graph u, it is kind of a visual representation 00:12:28.481 --> 00:12:34.487 of a graph. A code graph. It is a graph obviously. So you can 00:12:39.626 --> 00:12:46.933 all hold your applause until later. You see at the top we 00:12:46.933 --> 00:12:53.039 have a code block that has a decisionary either goes right or 00:12:53.039 --> 00:12:59.579 left. They remerge and end up exiting the function. Very 00:12:59.579 --> 00:13:02.015 simple view of the code graph, it is a directed...did I skip 00:13:02.015 --> 00:13:08.021 that already? Yes. It is a directed graph, which means that 00:13:10.923 --> 00:13:15.828 edges flow in one direction. Very important because if you 00:13:15.828 --> 00:13:21.134 could actually make your code flow backwards then we have a 00:13:21.134 --> 00:13:27.140 hole different class of vulnerabilities. So to take this 00:13:29.475 --> 00:13:34.314 back to stage 3 just briefly. What you can't really read is 00:13:34.314 --> 00:13:41.821 the code graph from the child handler in stage 3. So I said 00:13:41.821 --> 00:13:45.224 that it's not quite the same thing to have a code graph and 00:13:45.224 --> 00:13:51.230 have an ida graph the reason is ida and viv don't follow every 00:13:54.434 --> 00:14:01.174 call and there are things that are conditional that don't 00:14:01.174 --> 00:14:05.378 necessarily show up as a different node as they should. 00:14:05.378 --> 00:14:07.980 If they are conditional they are either execution able or not. 00:14:07.980 --> 00:14:13.986 Compare change it 86 just show up in the code flow. So if we 00:14:17.857 --> 00:14:24.864 were to take this graph, calls, and linked them to other parts 00:14:24.864 --> 00:14:30.403 of the graph and have more code flow from there and back into 00:14:30.403 --> 00:14:37.543 this graph, it would be more of a specific or an exact code flow 00:14:37.543 --> 00:14:42.715 graph. If we were to take specific instructions like 00:14:42.715 --> 00:14:50.356 branch, for example, jz, if we jump, if the zero flag said in 00:14:50.356 --> 00:14:54.761 reality, that's kind of its own thing, it deserves its own nodes 00:14:54.761 --> 00:14:59.999 because it may or may not [ inaudible ], because that would 00:14:59.999 --> 00:15:05.938 be hard to follow. [ inaudible ]. So as we are analyzing a code 00:15:13.980 --> 00:15:19.986 path, we drag through the initial state through 00:15:22.321 --> 00:15:28.928 symbolically modify register values, they are modified and 00:15:28.928 --> 00:15:34.934 represented and stored in terms of the initial state. So eax 00:15:37.870 --> 00:15:45.011 started off as zero, all of your state throughout each 00:15:45.011 --> 00:15:50.516 instruction would be aware that eax started out as zero and 00:15:50.516 --> 00:15:55.354 reference eax as off sets or whatever as you subtract to it 00:15:55.354 --> 00:15:58.291 because it needs to maintain that initial state in order to 00:15:58.291 --> 00:16:01.828 do the analysis that we need. So when we are walking through 00:16:01.828 --> 00:16:09.268 code, we first translate a binary up code into a simple of 00:16:09.268 --> 00:16:15.274 effects. As we hit conditional flow, we add constraints. So as 00:16:20.646 --> 00:16:25.651 the graph branches, based on a yes or no, a constraint added 00:16:25.651 --> 00:16:31.657 path goes left and opposite added a path that goes right. 00:16:33.993 --> 00:16:38.865 That allows us to determine a code path that we want and 00:16:38.865 --> 00:16:46.305 figure out what the hell gets us there. So I keep showing you 00:16:46.305 --> 00:16:49.242 things that are not really, what is that? It looks different 00:16:49.242 --> 00:16:55.381 every time. I don't quite understand. Well, lizie and his 00:16:55.381 --> 00:17:01.120 wonderfulness created all of symboliks to supply a rep 00:17:01.120 --> 00:17:07.226 version and string version what they need. This helps in 00:17:07.226 --> 00:17:10.730 developing because it allows us to see a second notice what the 00:17:10.730 --> 00:17:16.736 state of symboliks is. So the top part here we are looking at 00:17:20.039 --> 00:17:23.209 the repper version of it and it's created that you can 00:17:23.209 --> 00:17:28.314 copy/paste it into another interactive python shell or 00:17:28.314 --> 00:17:35.521 audio code and recreate the symboliks state because of all 00:17:35.521 --> 00:17:41.527 the symboliks -- can I get some water? If we print symboliks 00:17:47.099 --> 00:17:52.238 state, you notice these are constraint paths at the top. In 00:17:52.238 --> 00:17:59.812 the pretty version down below, it's t same. It says all that 00:17:59.812 --> 00:18:03.950 goodness repeat python symboliks state this is what they mean. 00:18:08.020 --> 00:18:14.026 Return to none zero. They didn't have vodka in the speaker room. 00:18:17.930 --> 00:18:25.471 I was kind of depressed. It's a lot easier to read than the top 00:18:25.471 --> 00:18:32.144 one. Leading back to working with the system, creating the 00:18:32.144 --> 00:18:38.117 code, tears apart code, very powerfully and easily and easily 00:18:38.117 --> 00:18:44.123 to bug. So a little bit more example. Set variable eax. To a 00:18:48.194 --> 00:18:54.200 constraint one. Set variable esp to be subtraction of constraint 00:18:56.335 --> 00:19:01.540 via the top of the stack. I'm using tools that actually turn 00:19:01.540 --> 00:19:04.810 the top of the stack that turns into something easy that most of 00:19:04.810 --> 00:19:10.816 us had to jive with. So we are subtracting from esp 4. Setting 00:19:14.954 --> 00:19:20.960 evp to evp. Then we add to, oh, man, i'm not even going to 00:19:23.462 --> 00:19:29.735 continue. Look at the bottom one. It's the exact same symbol, 00:19:29.735 --> 00:19:35.741 using print. Eax to one, esp minus esp minus 4. Evp blah, 00:19:39.311 --> 00:19:42.515 blah, blah blah, blah, blah blah, blah, blah. Much easier to 00:19:42.515 --> 00:19:49.555 read. I think you will agree. So I have to call out, though. 00:19:49.555 --> 00:19:53.325 Symboliks have two different ways, stages in symboliks 00:19:53.325 --> 00:19:59.331 analyses bot of which is powerful. We translate binary 00:20:01.600 --> 00:20:07.606 opcode to search effect and then apply to symboliks emulator. And 00:20:15.915 --> 00:20:22.822 extrude every single effect. So you left with simple effect and 00:20:22.822 --> 00:20:28.828 I know this is push evp and subtract from esp 4. It doesn't 00:20:31.063 --> 00:20:36.001 actually keep the state and then pushes into the memory location 00:20:36.001 --> 00:20:42.408 of esp. The applied effects are the ones that keep this state 00:20:42.408 --> 00:20:49.815 all the way through. So to give you a couple of things to type 00:20:49.815 --> 00:20:53.419 in when you go home and want to play around with this. Once you 00:20:53.419 --> 00:20:58.724 set up your workplace, you disassemble the opcode. On 00:20:58.724 --> 00:21:04.663 equals -- and you give it a virtual address. And to simple 00:21:07.333 --> 00:21:13.906 effect having a translator and executing translate opcode that 00:21:13.906 --> 00:21:19.912 you did. Giving a list of applied effect. Mu, effects, 00:21:24.950 --> 00:21:29.522 translator and it spits out a list of applied effects. 00:21:33.893 --> 00:21:38.430 Basically symboliks architecture independent. The only god to 00:21:38.430 --> 00:21:42.768 there is the name of things change to the architecture. R 15 00:21:42.768 --> 00:21:48.774 on arm would be pc or irp or 86 or s 64. So how was symboliks 00:21:55.047 --> 00:22:02.655 put together and why do I care? So he used many powerful thing 00:22:02.655 --> 00:22:08.661 in the python language the arithmetic functions that every 00:22:12.064 --> 00:22:18.070 object has, addition subtraction x or whatever. And I'm jumping 00:22:20.272 --> 00:22:26.278 ahead of myself. I'm in the middle of ctf. So python, 00:22:31.250 --> 00:22:35.888 symboliks has the following primitives. Constant, we have a 00:22:35.888 --> 00:22:43.562 variable. Which is a variable of whatever name. It could be a 00:22:43.562 --> 00:22:50.269 register. It could be some known symbol in the work space. A 00:22:50.269 --> 00:22:55.140 memory object which represents memory. [ laughs ]. And we have 00:22:55.140 --> 00:23:01.080 a call. And this allows us track where a call may fit into the 00:23:01.080 --> 00:23:08.020 symboliks state and finishing the calls before we do the 00:23:08.020 --> 00:23:14.026 analysis path. And r means [ inaudible ] function. A c not 00:23:16.295 --> 00:23:22.301 effect which is [ inaudible ] is the opposite of that. So r, eax, 00:23:26.272 --> 00:23:32.811 your register and you say not eax you end up with c not. And 00:23:32.811 --> 00:23:37.983 then an operator. So our operators are aware of looking 00:23:37.983 --> 00:23:44.490 at python methods come into play. So basically we have an 00:23:44.490 --> 00:23:51.163 operator o under score add. Which is used to represent the 00:23:51.163 --> 00:23:57.202 addition of two symboliks state. O under score sub ratcheting the 00:23:57.202 --> 00:24:03.509 subtraction of symboliks state, the orders are important here. 00:24:03.509 --> 00:24:09.915 Implement here using the symboliks state, python class of 00:24:09.915 --> 00:24:15.220 symboliks component subclass. And simply over loading the 00:24:15.220 --> 00:24:18.991 under score add function and I add. Because it doesn't matter [ 00:24:18.991 --> 00:24:22.928 inaudible ] in this case. We have effects and these are the 00:24:22.928 --> 00:24:30.202 things that actually happen. We have set variable, read memory, 00:24:30.202 --> 00:24:34.173 write memory. Call function and constraint path. So the 00:24:34.173 --> 00:24:38.711 constraint path obviously is where you hit an addition case 00:24:38.711 --> 00:24:42.247 and you have to choose where to go from there. Your constraint 00:24:42.247 --> 00:24:48.253 are little objects well little names anyway called eq or e not 00:24:50.856 --> 00:24:56.028 equal, great or equal as you know. When you run into unk or 00:24:56.028 --> 00:25:01.967 not unk. What the the constraint is orthometrically. Or or x or. 00:25:09.842 --> 00:25:15.848 Some of the bit wise effect. So let's talk about how to made 00:25:21.487 --> 00:25:29.461 powerful about this. I like to use symboliks interactively. I 00:25:29.461 --> 00:25:33.499 get code that I don't know what it does. Throw into a code path 00:25:33.499 --> 00:25:39.972 that's interesting. Symboliks emulated and see the effects. 00:25:39.972 --> 00:25:46.712 The symboliks state is what I'm interested in. Well that can be 00:25:46.712 --> 00:25:52.384 overwhelming and I'll tell you why. Our applied effects gets 00:25:52.384 --> 00:25:59.224 run through the emulator. We then have the option to run 00:25:59.224 --> 00:26:05.164 reduced on this symboliks effects. This takes ex-or eax 00:26:08.534 --> 00:26:12.438 equals zero and things of that nature. If mathematically you 00:26:12.438 --> 00:26:16.208 can combine them easily, then they can be reduced. Why? That 00:26:16.208 --> 00:26:21.079 kind of sounds nerdy. Because this effect right here is enough 00:26:21.079 --> 00:26:27.086 to blow your mind. And yet it reduces to something exceedingly 00:26:32.424 --> 00:26:38.430 simple. We are also given the capability of solving. The 00:26:41.867 --> 00:26:47.706 symboliks state maybe discreet or not how do we solve it. If it 00:26:47.706 --> 00:26:53.712 is discrete, we run the number through. If it is not discrete, 00:26:57.516 --> 00:27:02.054 symboliks give you the ability to compare even though they are 00:27:02.054 --> 00:27:08.060 not discrete. And this is using the hash of its basic repper. So 00:27:13.232 --> 00:27:19.238 for example, var can't be discrete and spits out a long 00:27:22.841 --> 00:27:28.847 integer of sum of its thing. We can also update symboliks state 00:27:35.354 --> 00:27:41.360 using an emulator that already has data. And as of about a year 00:27:44.696 --> 00:27:52.137 ago, create substitutions. Now in my opinion this is should 00:27:52.137 --> 00:27:58.677 have been called solve as well because we put together a set of 00:27:58.677 --> 00:28:05.150 values that a symboliks variable can have and then we ratchet 00:28:05.150 --> 00:28:10.355 that into the symboliks state solver and we get back a 00:28:10.355 --> 00:28:16.361 generator which gives us all the different things that those 00:28:20.365 --> 00:28:27.005 values would have provided. That's weird. So here's an 00:28:27.005 --> 00:28:33.378 example of using substitution. I use this in switch case analysis 00:28:33.378 --> 00:28:39.384 in my branch. Basically, I put together a list of ranges given 00:28:44.389 --> 00:28:47.225 a constraint, for example when you are looking at a switch 00:28:47.225 --> 00:28:52.931 case, you generally start at zero index and you roll through, 00:28:52.931 --> 00:28:57.869 you know, o-, 3, 550 different options. I don't know how many 00:28:57.869 --> 00:29:05.210 of you done the work to analyze switch cases. But when they 00:29:05.210 --> 00:29:10.449 happen there's an often print up into like groups. Because if you 00:29:10.449 --> 00:29:16.121 have a switch case that has a 0-case in a 32 --> 000-case you 00:29:16.121 --> 00:29:22.127 don't want to have 32,999 if there's just two. Or like a 00:29:25.497 --> 00:29:31.303 pocket of five or 20 around each one. So generally they represent 00:29:31.303 --> 00:29:36.875 different code path and they end upstarting at zero index with 00:29:36.875 --> 00:29:41.146 some relative base. So we come through and you can see the 00:29:41.146 --> 00:29:45.450 debugging here. See how good my laser scale are. I'm not used to 00:29:45.450 --> 00:29:51.456 being this far. Debugging here with the print of variables of 00:29:55.160 --> 00:30:02.401 the given state. We create a red range and we roll through every 00:30:02.401 --> 00:30:07.272 index that we've identified that this switch case handles and by 00:30:07.272 --> 00:30:12.110 solving that we are able to see what the out come of the switch 00:30:12.110 --> 00:30:18.684 case is. If it's a switch case zero, then there's some place in 00:30:18.684 --> 00:30:22.988 array that has a pointer, to a code block that handles switch 00:30:22.988 --> 00:30:26.725 case zero and so on and so forth. So we ratchet through 00:30:26.725 --> 00:30:30.495 that so we create cross references in the viv sec work 00:30:30.495 --> 00:30:36.501 space. So I won't talk more about this right now, but I 00:30:38.704 --> 00:30:44.142 recommend that if you check this out, look into arch in module 00:30:44.142 --> 00:30:50.148 that lets you do a lot more independent. I know firsthand 00:30:55.420 --> 00:31:01.126 that it's been used to solver completely the function 00:31:01.126 --> 00:31:06.498 comparison problem. So why do we care about this? I know i'm a 00:31:06.498 --> 00:31:12.504 nerd. Well, vulnerability research and reverse engineering 00:31:21.012 --> 00:31:24.449 they basically are solving problem and/or answering 00:31:24.449 --> 00:31:28.920 questions that are very difficult to answer. Reverse 00:31:28.920 --> 00:31:34.926 engineering is identifying behavior and vulnerability is 00:31:38.597 --> 00:31:42.200 finding vulnerability behaviors so we are hunting juicy 00:31:42.200 --> 00:31:49.474 behaviors? Absolutely. We have couple case studies here. Who 00:31:49.474 --> 00:31:55.480 has dug through looking for that? Yes, we all have. It turns 00:32:00.318 --> 00:32:06.057 out by searching through a binary and executable area of 00:32:06.057 --> 00:32:12.130 binary, you can trace symboliks state up to some known 00:32:12.130 --> 00:32:18.136 terminator point and ask very specific questions about what 00:32:21.406 --> 00:32:27.879 that little code does. So rather than starting at a rett and 00:32:27.879 --> 00:32:33.451 stepping back byte by byte by byte and making sure that it's 00:32:33.451 --> 00:32:38.023 still decodes into a rett after some things and trying to figure 00:32:38.023 --> 00:32:42.027 out oh, this is a really cool gadget and does this thing. It 00:32:42.027 --> 00:32:48.233 kind of writes this thing and update these things that I'm 00:32:48.233 --> 00:32:53.839 interested in. You can use symboliks to do analysis on code 00:32:53.839 --> 00:32:59.845 snippets and pit out. Hey, this moves evx into eax and it's 3 00:33:03.348 --> 00:33:09.354 instructions long. You can do actual calling of rob gadgets 00:33:12.390 --> 00:33:15.594 using a symboliks state engine. For example...forgive me. So for 00:33:15.594 --> 00:33:21.600 example, we roll through a snippet of code. And then we dig 00:33:44.856 --> 00:33:52.597 into the variables that are discovered. So we say symboliks 00:33:52.597 --> 00:33:57.836 state what things have been written to. We then look for 00:33:57.836 --> 00:34:03.608 hey, is that thing this register? And is it writing to a 00:34:03.608 --> 00:34:09.381 register? And we know that we have a register copy. And hey, 00:34:09.381 --> 00:34:16.488 if the value of the second register ended up in the first 00:34:16.488 --> 00:34:22.394 register we know we have a change. These things are 00:34:22.394 --> 00:34:27.799 problematic and solvable by your own code. And just to give you 00:34:27.799 --> 00:34:34.639 something else to think about it but not dig into these. But...we 00:34:34.639 --> 00:34:42.514 already talked about switch case analysis. So basically what we 00:34:42.514 --> 00:34:49.220 are doing is we are trying to tell the computer to do the 00:34:49.220 --> 00:34:54.259 things that we do in our own super magical portal, our brain. 00:34:57.495 --> 00:35:02.467 So in switch case analysis in my branch we start off at every 00:35:02.467 --> 00:35:07.906 dynamic branch. Then we say, dynamic branch can be call to b 00:35:07.906 --> 00:35:12.811 reference or whatever your architecture reference are. So 00:35:12.811 --> 00:35:18.817 in that pass we've already identified these things. Virtual 00:35:22.053 --> 00:35:27.559 address set. So we pulled what viv had already given us and we 00:35:27.559 --> 00:35:33.565 back up until we are able to identify which register is used 00:35:36.835 --> 00:35:42.841 as a index pointer. We then roll through looking for anything 00:35:47.779 --> 00:35:55.654 that modifies that index. And it gives us constraint that say 00:35:55.654 --> 00:36:01.593 well this is like from 50 to 75 so our switch case is 50 to 75 00:36:04.596 --> 00:36:09.734 in this case. So let's now start at the beginning and ratchet 00:36:09.734 --> 00:36:16.908 through all this one code path, over and over with different 00:36:16.908 --> 00:36:22.280 indices and it gives us the next code block that gets executed 00:36:22.280 --> 00:36:27.719 for every different index and we are able to wire up the 00:36:27.719 --> 00:36:33.725 function, code block edges and that helps us a lot. And that 00:36:39.330 --> 00:36:46.871 leads us back to stage 3. So as you've been hearing about the 00:36:46.871 --> 00:36:51.543 cyber brand challenge, this whole idea of automating and 00:36:51.543 --> 00:36:58.883 discovering vulnerability is a pretty big hit list. How do we 00:36:58.883 --> 00:37:05.056 do that? There are many [ inaudible ] couple of different 00:37:05.056 --> 00:37:10.462 ways. Some people I have taken to just basically symboliks 00:37:10.462 --> 00:37:16.468 fuzzing. You start at some place and keep going through different 00:37:18.470 --> 00:37:23.775 code path until some desired effects like for example, I 00:37:23.775 --> 00:37:29.781 don't know, eip equals something of a input. We can do that. And 00:37:32.183 --> 00:37:34.185 it can be a very impactful way. I know computers do awesome 00:37:34.185 --> 00:37:40.191 things repetitively over and over. There's this halting 00:37:47.232 --> 00:37:53.238 problem. With graph theory and code path tracing we end up 00:37:57.108 --> 00:38:03.181 running into code past that may never end and we also can mean 00:38:03.181 --> 00:38:09.687 ander all the cycle in the world and still not find what we are 00:38:09.687 --> 00:38:13.358 after. So I prefer starting at where we are trying to go and 00:38:13.358 --> 00:38:19.497 back up and seeing if where we want to go with particular code 00:38:19.497 --> 00:38:23.368 path can provide us with the behaviors that we are after. So 00:38:23.368 --> 00:38:29.374 we start with meme copy. And with a good graph we are able to 00:38:34.145 --> 00:38:40.151 say this meme copy is called with two fix buffer -- okay. Not 00:38:44.122 --> 00:38:49.360 vulnerable. Move on. Find something that will allow us to 00:38:49.360 --> 00:38:56.401 compare and look for a dynamic sized either source destination 00:38:56.401 --> 00:39:02.340 and move size. Now it can be a little complex. That's a fairly 00:39:04.609 --> 00:39:10.648 simple way. Definitely one of the analyses modules. But back 00:39:10.648 --> 00:39:17.121 at our stage 3-case study, the vulnerability is the fact that 00:39:17.121 --> 00:39:23.127 we've allowed creating of a string up to 2047 bytes and then 00:39:25.263 --> 00:39:29.934 run s scan f on that string and put the output into [ inaudible 00:39:29.934 --> 00:39:34.939 ]. So we have to identify the size of our destination and our 00:39:34.939 --> 00:39:41.946 source and the constraints on them because our source is 00:39:41.946 --> 00:39:48.920 actually unconstraint. It's huge. But we have to be able to 00:39:48.920 --> 00:39:53.157 copy then into a buffer that is too small and not have 00:39:53.157 --> 00:39:57.829 constraint applied that keep us from overflowing and over 00:39:57.829 --> 00:40:03.835 writing rett. So here's that example. The call to read. 2047 00:40:08.273 --> 00:40:13.444 bytes. S scan f. Oh, I forgot the bacon part. We all love 00:40:13.444 --> 00:40:19.450 bacon, right? So since bfbfebe 4 is 1052-byte from the top of the 00:40:25.990 --> 00:40:32.530 stack which is rett then we overflow by 95 -- bytes. We can 00:40:32.530 --> 00:40:34.832 do this problematic. I'll show you code for it. You'll write 00:40:34.832 --> 00:40:40.838 your own. So as I said, starting where you want to go and backing 00:40:47.278 --> 00:40:51.549 up is my preferred method. Starting at a known entry point 00:40:51.549 --> 00:40:55.253 and go forward is also powerful. It turns out the combination of 00:40:55.253 --> 00:41:00.258 the two is probably the best option. So I leave a couple 00:41:00.258 --> 00:41:06.264 things for your play time. Input viv as vivclv. [ on screen ]. 00:41:15.039 --> 00:41:22.714 Vw.load. Some binary. I like to turn on this load. And then call 00:41:22.714 --> 00:41:28.720 vw analyze. Input this. Input that. Create symboliks context. 00:41:42.166 --> 00:41:49.273 Create symboliks graph. And then get some symboliks paths going. 00:41:49.273 --> 00:41:54.212 Adds you interactively going create symboliks paths and you 00:41:54.212 --> 00:42:00.651 review this symboliks effects. I think you will see just how 00:42:00.651 --> 00:42:06.657 powerful you can be. And here are couple of places to go look. 00:42:11.796 --> 00:42:17.635 Thank you very much. [applause]