1 00:00:00,000 --> 00:00:04,840 I'm a reverse engineer. I work for a security company, or for a company in Germany called 2 00:00:04,840 --> 00:00:11,620 Sabre Security. We do obscure reverse engineering tools for niche markets. And I'm going to give 3 00:00:11,620 --> 00:00:15,900 one of the oddest talks I've given in my life, mainly because this talk will not actually 4 00:00:15,900 --> 00:00:20,960 present any solutions to anything, but mainly list a bunch of things that I think are not 5 00:00:20,960 --> 00:00:26,980 that hard to solve, but haven't been publicly solved yet, and things that I would like to 6 00:00:26,980 --> 00:00:31,900 see solved. It will also include a few problems that are a bit more difficult. 7 00:00:32,740 --> 00:00:38,940 All right, so this talk is quite different from the other talks I've given. No bugs, 8 00:00:40,120 --> 00:00:46,680 no new tools, no solutions, mainly a wish list of things that I would like other people 9 00:00:46,680 --> 00:00:53,540 to solve, or that I will work on at some point, I just don't know when. Secondly, ideas. For 10 00:00:53,540 --> 00:00:56,820 many of the problems that I'll be presenting, I'll have a vague idea 11 00:00:56,820 --> 00:01:02,440 of how to do this. This idea is most likely going to be completely wrong, and thoroughly 12 00:01:02,440 --> 00:01:09,420 misleading, so take them with a grain of salt. All right, I think I'll just start. Now, reverse 13 00:01:09,420 --> 00:01:14,060 engineering has grown quite a bit over the last few years, and perhaps we should start 14 00:01:14,060 --> 00:01:18,960 understanding or trying to understand what reverse engineering means. And in order to 15 00:01:18,960 --> 00:01:21,740 understand reverse engineering, we first have to understand engineering, because reverse 16 00:01:21,740 --> 00:01:26,740 engineering obviously is the inverse process of engineering. So when you engineer, then 17 00:01:26,740 --> 00:01:31,140 you have a problem, you define a problem, and then you design a system consisting of 18 00:01:31,140 --> 00:01:35,680 multiple components and their interaction. And then you construct these components, or 19 00:01:35,680 --> 00:01:40,720 you buy them, or you steal them, or whatever. And then, finally, you integrate them, make 20 00:01:40,720 --> 00:01:45,440 them all work together, and hopefully your problem is solved. So in software, this means 21 00:01:45,440 --> 00:01:49,940 that the source code that you actually compile is the last step of a concretization process, 22 00:01:50,200 --> 00:01:54,740 where you start with an abstract design, an abstract understanding of your problem, an 23 00:01:54,740 --> 00:01:56,720 abstract understanding of the solution you want to build. 24 00:01:56,740 --> 00:02:00,960 And then you build it on the source level, and that is really, like, once you have the 25 00:02:00,960 --> 00:02:05,000 source code, that's the last step of the engineering process. Then it's just compilation and running, 26 00:02:05,080 --> 00:02:12,320 testing, selling. So I have to work in a few jokes to compete, I guess, but I'm very 27 00:02:12,320 --> 00:02:18,940 bad at this being German. So the engineering process is not only producing the final output. 28 00:02:19,040 --> 00:02:23,640 Like, when I engineer or build a car, I don't only get the car in the end. I get a whole 29 00:02:23,640 --> 00:02:26,720 bunch of high-level design. I get interactions between the cars. I get interactions between 30 00:02:26,740 --> 00:02:31,660 the components. I get specifications for the components, and so forth. So the engineering 31 00:02:31,660 --> 00:02:37,240 process produces way more than just the source code or the final problem. It produces an 32 00:02:37,240 --> 00:02:40,920 understanding of the problem or of the program that we're building. 33 00:02:41,600 --> 00:02:47,040 So, well, everybody of us who has been involved in engineering at some point knows that the 34 00:02:47,040 --> 00:02:50,480 actual process of building something is a lot messier than what I just described. This 35 00:02:50,480 --> 00:02:55,020 does not change the fact that even if I just puke a bunch of code into a file somewhere, 36 00:03:05,660 --> 00:03:08,280 it doesn't change the fact that the actual process of building something is as successful 37 00:03:08,280 --> 00:03:12,280 What I want to show you today is theimentation. If I have to go back and fix a problem, I 38 00:03:12,280 --> 00:03:12,560 one idea. But if I have to go back and fix the problems from a concept or a concept. 39 00:03:12,560 --> 00:03:16,360 I can do both. Ok. As a result, a lot of the problems were solved. The problem is that 40 00:03:16,360 --> 00:03:17,240 it was really hard to fix. 41 00:03:17,240 --> 00:03:18,040 So the problem is that it was just afraid of people because of the results of the input. 42 00:03:18,060 --> 00:03:22,700 So what if I was to go to a computer and I was to go to a computer and it's not working 43 00:03:23,560 --> 00:03:25,080 well? I was going to follow it, I was going to go to a computer that was at the start 44 00:03:25,080 --> 00:03:31,360 first step, but really, well, reverse engineering is way beyond that. Just given a large, large 45 00:03:31,360 --> 00:03:37,280 set of disassemblies, you don't really understand anything. So a good disassembler is, of course, 46 00:03:37,300 --> 00:03:42,400 something that you absolutely need to understand more, but it is not the end goal. Like, having 47 00:03:42,400 --> 00:03:45,940 a clean disassembly cannot be the end goal of reverse engineering. A good disassembler 48 00:03:45,940 --> 00:03:49,940 should recover all the functions in the executable and which function calls which other function 49 00:03:49,940 --> 00:03:56,000 and properly or mostly properly separate data from code. So secondly, what is not reverse 50 00:03:56,000 --> 00:04:00,280 engineering? A lot of reverse engineers think that decompilation would be the holy grail 51 00:04:00,280 --> 00:04:05,160 of reverse engineering, but honestly, decompilation cannot be the end goal of reverse engineering 52 00:04:05,160 --> 00:04:09,640 either because, as I just described, we start in the engineering process at a very high 53 00:04:09,640 --> 00:04:15,140 level and then whittle down to have source code and then compile. So the source code 54 00:04:15,140 --> 00:04:19,420 is already like the last step of the engineering process, which means that recovering source 55 00:04:19,420 --> 00:04:23,160 code does not recover any of the high level abstractions. If I give you the source code 56 00:04:23,160 --> 00:04:28,400 to Oracle now, you have no clue of how the different components interact and fit together, 57 00:04:28,580 --> 00:04:33,720 so I might as well just give you the assembly. This scales upwards because I don't think 58 00:04:33,720 --> 00:04:39,460 anybody at Microsoft really understands Vista or anybody really understands any larger piece 59 00:04:39,460 --> 00:04:46,400 of software. So there's a big difference between decompiling something and really understanding 60 00:04:46,400 --> 00:04:46,680 it. 61 00:04:47,560 --> 00:04:48,760 If I have all the... 62 00:04:48,760 --> 00:04:49,400 Like, if I can... 63 00:04:49,420 --> 00:04:53,800 If I can completely disassemble or take apart a car and have all the pieces there, I still 64 00:04:53,800 --> 00:04:58,360 have no understanding of the rationale behind the design of each individual component and 65 00:04:58,360 --> 00:05:01,400 I have no understanding necessarily of how an engine works. 66 00:05:02,740 --> 00:05:08,060 All right. So the really broad definition of reverse engineering would be recovery of 67 00:05:08,060 --> 00:05:16,200 high level abstractions and program understanding. So ideally, we should try to, given an arbitrary 68 00:05:16,200 --> 00:05:17,720 executable, well... 69 00:05:18,860 --> 00:05:23,420 Reconstruct the things that a good design process would have had, like remodularize the 70 00:05:23,420 --> 00:05:27,960 functions, just get one bit of functions in the relations. Separate them into modules. 71 00:05:28,560 --> 00:05:35,560 Build things that help us understand the program. Of course, for most of us, bug finding 72 00:05:35,560 --> 00:05:39,020 is the primary target. Like, why would we need to understand the program in order to 73 00:05:39,020 --> 00:05:39,920 find bugs and so forth? 74 00:05:40,340 --> 00:05:45,940 So the thing is that, realistically speaking, I don't know if it's going to be two years 75 00:05:45,940 --> 00:05:47,700 or five years or ten years or twenty years. But at the moment, I'm going to say roughly 76 00:05:47,700 --> 00:05:51,040 but out-of-bounds memory access will be gone at some point. 77 00:05:51,160 --> 00:05:51,920 Just gone, gone. 78 00:05:52,460 --> 00:05:55,300 I mean, the A340 avionics code 79 00:05:55,300 --> 00:05:58,300 was verified with a static checker that works soundly 80 00:05:58,300 --> 00:06:01,260 and proven to be free of out-of-bounds memory access. 81 00:06:01,580 --> 00:06:04,880 And that's 110,000 lines of code and multi-threaded. 82 00:06:04,980 --> 00:06:06,380 So that's a fair achievement. 83 00:06:06,780 --> 00:06:08,540 Now, scale this 10 years into the future 84 00:06:08,540 --> 00:06:10,900 and you can see that most things that are critical 85 00:06:10,900 --> 00:06:14,000 will be verified to be free of out-of-bounds memory access. 86 00:06:14,540 --> 00:06:17,400 So anything, any bugs that we want to have 87 00:06:17,400 --> 00:06:18,560 in order to break systems 88 00:06:18,560 --> 00:06:21,040 will require us understanding the system 89 00:06:21,040 --> 00:06:23,660 and then finding ways that it was misdesigned 90 00:06:23,660 --> 00:06:25,240 or there's flaws in the logic and so forth. 91 00:06:25,580 --> 00:06:28,740 So we will need these things a few years down the line. 92 00:06:30,960 --> 00:06:33,140 So what does software really consist of? 93 00:06:33,180 --> 00:06:34,960 And what would be a proper way of abstracting 94 00:06:34,960 --> 00:06:36,100 like a bunch of functions 95 00:06:36,100 --> 00:06:37,880 that you just get thrown into your face 96 00:06:38,380 --> 00:06:39,800 into something that makes more sense? 97 00:06:40,840 --> 00:06:42,800 Well, one possible abstraction would be 98 00:06:42,800 --> 00:06:44,480 that an application is a set of modules. 99 00:06:44,660 --> 00:06:45,840 Like you have the network interaction module, 100 00:06:46,060 --> 00:06:47,160 you have the packet parsing module, 101 00:06:47,400 --> 00:06:49,300 you have the authentication crypto module, and so forth. 102 00:06:50,000 --> 00:06:52,100 And these modules interact with each other 103 00:06:52,100 --> 00:06:54,080 and they interact with the operating system 104 00:06:54,080 --> 00:06:55,960 and they're strung together to form an application. 105 00:06:58,100 --> 00:07:00,400 So what is a module in itself? 106 00:07:00,840 --> 00:07:02,240 A module is a set of functions 107 00:07:02,820 --> 00:07:06,560 and a bunch of these are being, well, exported. 108 00:07:06,780 --> 00:07:08,920 So you don't call every function in a module. 109 00:07:09,080 --> 00:07:10,900 You call a number of predefined APIs 110 00:07:10,900 --> 00:07:13,800 and they act as gateway nodes basically in the core graph. 111 00:07:13,960 --> 00:07:16,520 Meaning, in order to reach most of the functions of the module, 112 00:07:16,520 --> 00:07:18,580 you pass through a relatively small number 113 00:07:18,580 --> 00:07:19,480 of well-defined interfaces. 114 00:07:20,240 --> 00:07:22,840 So you have the external interface, external functions. 115 00:07:23,240 --> 00:07:24,780 And then you have external data structures, 116 00:07:24,960 --> 00:07:26,460 which are data structures that the module uses 117 00:07:26,460 --> 00:07:28,040 to communicate with the outer world. 118 00:07:28,520 --> 00:07:29,880 And then you have the second set. 119 00:07:30,020 --> 00:07:31,060 You have the internal functions. 120 00:07:31,220 --> 00:07:33,320 Functions that are never actually called from the outside 121 00:07:33,320 --> 00:07:35,180 are only called through the gateway nodes. 122 00:07:35,440 --> 00:07:38,360 And these functions might have a set of internal data structures 123 00:07:38,360 --> 00:07:40,840 which are used only internally to that module. 124 00:07:43,160 --> 00:07:46,500 And in, well, the idea would be that, well, 125 00:07:46,500 --> 00:07:48,400 the idea would then be to try to recover these structures. 126 00:07:48,520 --> 00:07:51,040 So we just assume that somebody is somewhat sane 127 00:07:51,040 --> 00:07:52,240 in the process of building software. 128 00:07:52,780 --> 00:07:55,680 And we then look at any book on design principles. 129 00:07:56,280 --> 00:07:58,380 Since I don't own any books on design principles, 130 00:07:58,560 --> 00:08:00,120 I had to use a book on source code auditing 131 00:08:00,120 --> 00:08:01,860 that Mark Dowd and John McDonald have written. 132 00:08:01,960 --> 00:08:03,620 Excellent book, pre-ordered on Amazon now. 133 00:08:03,700 --> 00:08:03,960 It's great. 134 00:08:05,580 --> 00:08:09,600 And there's two principles that should, well, apply to modules. 135 00:08:09,840 --> 00:08:10,860 One is loose coupling. 136 00:08:12,360 --> 00:08:13,600 Not, well, whatever. 137 00:08:13,600 --> 00:08:15,400 I know what you people are thinking. 138 00:08:16,800 --> 00:08:19,120 Which means that modules should communicate 139 00:08:19,120 --> 00:08:22,120 using very, very few well-defined interfaces 140 00:08:22,120 --> 00:08:24,620 that do clear input sanitization and so forth. 141 00:08:25,320 --> 00:08:27,040 Secondly, strong cohesion. 142 00:08:27,220 --> 00:08:30,880 Modules should provide functions that operate on very much related tasks. 143 00:08:31,880 --> 00:08:36,340 So it would be interesting if given an executable, 144 00:08:36,420 --> 00:08:39,360 we could decompose the executable into modules 145 00:08:39,360 --> 00:08:42,060 that exhibit, well, loose coupling and strong cohesion. 146 00:08:43,060 --> 00:08:45,260 In a situation where you look at OOP code, 147 00:08:45,400 --> 00:08:46,520 stuff gets a lot easier. 148 00:08:47,400 --> 00:08:49,680 Just, well, OOP, we have objects. 149 00:08:50,380 --> 00:08:53,100 We can reconstruct classes from the executable. 150 00:08:53,240 --> 00:08:55,500 We can reconstruct class hierarchies 151 00:08:55,500 --> 00:08:56,760 from the executable and so forth. 152 00:08:56,920 --> 00:08:57,880 So once we can do that, 153 00:08:58,640 --> 00:09:02,080 we have a lot of the abstract architecture already recovered. 154 00:09:02,540 --> 00:09:06,080 So factually, I think that reconstructing higher level design patterns 155 00:09:06,080 --> 00:09:09,260 or higher level, getting a higher level understanding of executables 156 00:09:09,260 --> 00:09:11,980 might actually be easier in the object-oriented case. 157 00:09:11,980 --> 00:09:13,300 Than in the standard C case. 158 00:09:13,500 --> 00:09:16,040 Just because more of the higher level design thinking 159 00:09:16,040 --> 00:09:18,380 is still present in the executable. 160 00:09:19,360 --> 00:09:19,960 All right. 161 00:09:20,200 --> 00:09:22,760 So the thing is that reverse engineering 162 00:09:22,760 --> 00:09:25,500 is in some aspects stuck in the 80s. 163 00:09:25,620 --> 00:09:28,120 What I mean with that is not very bright colors 164 00:09:28,120 --> 00:09:30,160 and shoulder pads in your jackets. 165 00:09:30,300 --> 00:09:32,880 But what I mean is reverse engineering 166 00:09:32,880 --> 00:09:34,200 is a really, really small community. 167 00:09:34,520 --> 00:09:36,160 And most of it has been done in secret 168 00:09:36,160 --> 00:09:37,940 or has been done by government agencies and so forth. 169 00:09:38,340 --> 00:09:41,580 So we have on one side the development 170 00:09:42,120 --> 00:09:43,120 like software development. 171 00:09:43,300 --> 00:09:44,320 And that's like a huge industry. 172 00:09:44,720 --> 00:09:47,640 And they do all this crazy research into how to build better tools. 173 00:09:47,720 --> 00:09:49,000 You have these round trip engineering tools 174 00:09:49,000 --> 00:09:50,820 which generate code from your UML diagrams 175 00:09:50,820 --> 00:09:52,680 and UML diagrams from code and so forth. 176 00:09:53,300 --> 00:09:54,880 And on the reverse engineering side, 177 00:09:55,040 --> 00:09:55,720 we have EDA. 178 00:09:57,280 --> 00:09:58,600 And not so much else. 179 00:09:58,920 --> 00:10:00,400 Or not so much in addition to that. 180 00:10:02,100 --> 00:10:05,120 So the reverse engineering scene has grown a lot 181 00:10:05,120 --> 00:10:06,260 in the last few years, which means 182 00:10:07,200 --> 00:10:08,880 well, it's just crazy these days. 183 00:10:08,920 --> 00:10:10,980 The fact that I'm standing in front of a room of these many people 184 00:10:10,980 --> 00:10:13,060 who seem to have a cursory interest in reverse engineering at least 185 00:10:14,920 --> 00:10:17,720 is already showing that the industry is growing a lot. 186 00:10:18,180 --> 00:10:20,160 And we now have more reverse engineering tools 187 00:10:20,160 --> 00:10:22,540 that are coming in like H.P. Garry's Inspector 188 00:10:22,540 --> 00:10:23,920 and Pedram's PyME 189 00:10:23,920 --> 00:10:27,320 or Bindif and Binnavi, the two products which we're selling. 190 00:10:28,080 --> 00:10:30,080 But all these products are really, really niche 191 00:10:30,080 --> 00:10:31,340 and really tiny in their reach. 192 00:10:31,680 --> 00:10:33,880 But because reverse engineering has been growing so much 193 00:10:33,880 --> 00:10:36,100 it might be possible that we finally get some real research 194 00:10:36,100 --> 00:10:38,060 and development money flowing in from somewhere. 195 00:10:39,180 --> 00:10:40,240 And what I'll 196 00:10:40,980 --> 00:10:41,840 do in the following now, 197 00:10:41,920 --> 00:10:43,240 I'll name ten research problems 198 00:10:44,700 --> 00:10:46,360 that, well, for most of them 199 00:10:46,360 --> 00:10:48,040 I think that they can be solved using 200 00:10:48,520 --> 00:10:51,100 moderate amounts of time and money investment. 201 00:10:51,520 --> 00:10:52,640 For some of them, I don't know. 202 00:10:54,300 --> 00:10:56,300 Well, many of the problems that I'll be presenting 203 00:10:56,300 --> 00:10:59,140 will be NP-hard in the general case. 204 00:10:59,400 --> 00:11:01,560 But luckily enough, I've never met the general case. 205 00:11:01,840 --> 00:11:04,520 So don't be turned off by that. 206 00:11:05,460 --> 00:11:08,380 A very, very simple first challenge. 207 00:11:08,540 --> 00:11:09,880 It's so simple that it's got the number zero. 208 00:11:09,880 --> 00:11:11,880 It's really, really not that difficult. 209 00:11:13,100 --> 00:11:14,660 I find it surprisingly useful 210 00:11:14,660 --> 00:11:16,460 to have a program that, 211 00:11:16,520 --> 00:11:18,240 given a set of functions, 212 00:11:18,820 --> 00:11:20,260 generates me for each function 213 00:11:20,260 --> 00:11:22,480 the set of possible return values of that function. 214 00:11:23,460 --> 00:11:25,440 So you just see a sub-function call 215 00:11:25,440 --> 00:11:27,000 and you see that this function can return 216 00:11:27,000 --> 00:11:28,240 plus one, minus one, zero. 217 00:11:28,420 --> 00:11:30,900 You can almost deduce that this is a comparator 218 00:11:30,900 --> 00:11:31,440 of some sorts. 219 00:11:31,900 --> 00:11:33,960 And you get a function that returns 220 00:11:33,960 --> 00:11:36,380 minus one or the return value of malloc. 221 00:11:36,480 --> 00:11:39,180 You know that minus one signals failure of malloc. 222 00:11:39,980 --> 00:11:40,880 Things like these. 223 00:11:41,340 --> 00:11:42,860 This is really, really trivial 224 00:11:42,860 --> 00:11:45,180 and can be done in a few hundred lines of Python. 225 00:11:45,540 --> 00:11:48,040 So let's go on to something more interesting. 226 00:11:48,440 --> 00:11:50,040 Something that we really want 227 00:11:50,040 --> 00:11:52,260 is full executable data structure reconstruction. 228 00:11:53,060 --> 00:11:54,420 Given an executable, 229 00:11:54,580 --> 00:11:56,400 reconstruct all data structures 230 00:11:56,400 --> 00:11:58,400 that are used in this executable. 231 00:11:59,340 --> 00:12:00,840 Just get me all of them. 232 00:12:01,180 --> 00:12:04,180 Secondly, reconstruct all the points-through relations 233 00:12:04,180 --> 00:12:05,600 between the data structures. 234 00:12:05,700 --> 00:12:08,620 Meaning, if possible, try to recover nested data structures. 235 00:12:08,620 --> 00:12:10,400 And whenever you have a structure member 236 00:12:10,400 --> 00:12:11,680 pointing to another data structure, 237 00:12:11,960 --> 00:12:13,620 include that in your, 238 00:12:14,220 --> 00:12:16,300 well, recover this relation as well. 239 00:12:16,940 --> 00:12:18,960 Finally, once you're done doing that, 240 00:12:19,020 --> 00:12:19,800 construct a graph 241 00:12:19,800 --> 00:12:21,820 consisting of the data structures. 242 00:12:21,960 --> 00:12:22,980 Every data structure is a node. 243 00:12:23,380 --> 00:12:26,120 And whenever a data structure contains a class member 244 00:12:26,120 --> 00:12:28,480 or a data structure member pointing to another data structure, 245 00:12:28,580 --> 00:12:29,340 add an edge. 246 00:12:29,660 --> 00:12:32,400 This graph will immediately tell you a lot 247 00:12:32,400 --> 00:12:34,600 about the relations of data structures in that program. 248 00:12:34,820 --> 00:12:36,780 You'll immediately see recursive data structures 249 00:12:36,780 --> 00:12:37,780 such as graphs and trees. 250 00:12:38,620 --> 00:12:39,900 You'll be able to very much understand 251 00:12:39,900 --> 00:12:41,440 what is going on a lot quicker. 252 00:12:41,680 --> 00:12:44,400 This would even be useful on the source code level. 253 00:12:44,500 --> 00:12:45,760 And there it's really trivial to generate. 254 00:12:47,680 --> 00:12:48,380 Yeah, so, 255 00:12:48,940 --> 00:12:50,380 I think this is 256 00:12:50,380 --> 00:12:51,960 relatively easily doable. 257 00:12:52,240 --> 00:12:54,280 I think it's even doable for 258 00:12:54,280 --> 00:12:55,420 venture capital backed companies. 259 00:12:56,280 --> 00:12:57,840 Which means it's not difficult. 260 00:12:58,220 --> 00:12:59,900 And it's definitely doable for anybody 261 00:12:59,900 --> 00:13:01,900 who does not run after cheap money. 262 00:13:03,560 --> 00:13:04,040 Alright. 263 00:13:04,360 --> 00:13:06,040 I even have a little bit of pseudo code 264 00:13:06,040 --> 00:13:07,780 which might or might not work 265 00:13:08,620 --> 00:13:08,800 if you build this. 266 00:13:09,960 --> 00:13:11,840 A very, very rough algorithmic sketch. 267 00:13:12,260 --> 00:13:14,340 So you iterate over all functions in the executable 268 00:13:14,340 --> 00:13:16,880 and you find all the memory cells 269 00:13:16,880 --> 00:13:18,140 like the separate memory cells 270 00:13:18,140 --> 00:13:19,960 accessed in that function. 271 00:13:20,300 --> 00:13:22,320 You retrieve the offsets for these separate 272 00:13:22,320 --> 00:13:24,520 memory cells and you create a data structure 273 00:13:24,520 --> 00:13:26,240 for that. So basically in each function 274 00:13:26,240 --> 00:13:27,800 for each memory cell you get a data structure. 275 00:13:28,200 --> 00:13:30,380 What you do then is you iterate through 276 00:13:30,380 --> 00:13:32,500 the entire executable and build prototypes 277 00:13:32,500 --> 00:13:34,740 for function call arguments 278 00:13:34,740 --> 00:13:36,480 from the data structures 279 00:13:36,480 --> 00:13:37,340 that you've just recovered. 280 00:13:38,620 --> 00:13:40,540 So basically you iterate over all functions 281 00:13:40,540 --> 00:13:42,160 in the executable and 282 00:13:42,160 --> 00:13:43,940 merge data structures that are passed. 283 00:13:44,120 --> 00:13:45,680 So if I have like a function prototype as 284 00:13:45,680 --> 00:13:48,380 my local data structure in this function 285 00:13:48,380 --> 00:13:50,020 is being passed in as first argument 286 00:13:50,540 --> 00:13:52,320 and you have a parent function which says 287 00:13:52,320 --> 00:13:54,520 well, the local data structure there is being 288 00:13:54,520 --> 00:13:56,340 passed as first argument to that sub function 289 00:13:56,340 --> 00:13:57,320 you merge the two. 290 00:13:57,960 --> 00:14:00,540 And you iterate that and in theory you should be 291 00:14:00,540 --> 00:14:02,260 terminating this after n half iterations 292 00:14:02,260 --> 00:14:04,520 where n is the maximum depth of the call graph. 293 00:14:05,780 --> 00:14:06,260 Alright. 294 00:14:06,940 --> 00:14:08,500 Well creating the graph 295 00:14:08,620 --> 00:14:10,680 of relations now after should be really, really easy 296 00:14:10,680 --> 00:14:11,660 so I won't 297 00:14:12,480 --> 00:14:14,480 talk too much about that. So let's go to 298 00:14:14,480 --> 00:14:15,000 challenge two. 299 00:14:16,360 --> 00:14:18,280 Given an executable, don't only 300 00:14:18,280 --> 00:14:19,920 reconstruct the data structures 301 00:14:19,920 --> 00:14:21,540 but reconstruct classes 302 00:14:22,420 --> 00:14:24,460 then associate functions to 303 00:14:24,460 --> 00:14:26,060 the classes, so recover all the methods 304 00:14:26,620 --> 00:14:28,180 and reconstruct the 305 00:14:28,180 --> 00:14:30,220 inheritance hierarchy between the classes. 306 00:14:31,120 --> 00:14:32,520 Finally create UML 307 00:14:32,520 --> 00:14:33,780 diagrams from the executable. 308 00:14:35,020 --> 00:14:35,760 Merge the 309 00:14:35,760 --> 00:14:38,460 UML diagrams with the type info generated 310 00:14:38,620 --> 00:14:40,480 in challenge one and you have something 311 00:14:40,480 --> 00:14:42,520 that will at least allow 312 00:14:42,520 --> 00:14:44,460 you to understand large object oriented programs 313 00:14:44,460 --> 00:14:46,420 a lot more quickly than what we can do now. 314 00:14:47,640 --> 00:14:48,920 I very much 315 00:14:48,920 --> 00:14:50,340 think this is doable. You might be 316 00:14:50,340 --> 00:14:52,580 to a certain extent compiler specific 317 00:14:52,580 --> 00:14:54,600 although I have yet to 318 00:14:54,600 --> 00:14:56,300 see a C++ compiler that doesn't 319 00:14:56,300 --> 00:14:58,180 build objects in the manner that putting 320 00:14:58,180 --> 00:14:59,620 like we put a V table at the first 321 00:15:00,300 --> 00:15:02,680 data member and then pad stuff at the end 322 00:15:02,680 --> 00:15:04,200 and so forth. There's 323 00:15:04,200 --> 00:15:06,180 in fact a striking convergence 324 00:15:06,180 --> 00:15:08,400 of compilers towards like 325 00:15:08,620 --> 00:15:10,620 a sane optimum for implementing C++ 326 00:15:10,620 --> 00:15:11,740 language features. 327 00:15:12,120 --> 00:15:13,620 So I think this is definitely doable. 328 00:15:17,240 --> 00:15:18,700 So just a few 329 00:15:18,700 --> 00:15:20,160 ideas on how to do what. 330 00:15:20,900 --> 00:15:22,480 You can glean the inheritance relationships 331 00:15:22,480 --> 00:15:24,540 between classes by looking at the constructors 332 00:15:24,540 --> 00:15:26,020 meaning I have a constructor 333 00:15:26,020 --> 00:15:28,540 it passes my this pointer on to another constructor 334 00:15:28,540 --> 00:15:30,520 I can usually 335 00:15:30,520 --> 00:15:32,560 if there's V tables present infer that 336 00:15:32,560 --> 00:15:34,560 my current class is being derived from the other class. 337 00:15:36,860 --> 00:15:38,500 Recovering the virtual methods while you have 338 00:15:38,620 --> 00:15:40,040 V tables that should not be too difficult. 339 00:15:41,520 --> 00:15:42,540 Recovering regular methods 340 00:15:42,540 --> 00:15:44,500 would imply doing a bunch of 341 00:15:44,500 --> 00:15:46,580 data flow analysis so that might take time 342 00:15:46,580 --> 00:15:48,720 and might be a bit more difficult. 343 00:15:49,840 --> 00:15:50,480 The amusing 344 00:15:50,480 --> 00:15:52,560 thing is that once you've done this you can 345 00:15:52,560 --> 00:15:54,580 very very cheaply build a runtime object 346 00:15:54,580 --> 00:15:56,500 editor. So what you do then is you 347 00:15:56,500 --> 00:15:58,140 scan through memory to find V tables 348 00:15:58,140 --> 00:16:00,420 like V table pointers and 349 00:16:00,420 --> 00:16:02,480 every time you find a V table pointer you know there's a class 350 00:16:02,480 --> 00:16:04,280 instance here and then you can just 351 00:16:04,280 --> 00:16:05,780 because you've reconstructed the types 352 00:16:06,460 --> 00:16:08,520 provide the user with an editor where he can run 353 00:16:08,620 --> 00:16:10,380 runtime edit the contents of the 354 00:16:10,380 --> 00:16:11,860 individual class instances in memory. 355 00:16:12,420 --> 00:16:12,980 Alright. 356 00:16:13,820 --> 00:16:16,520 This is definitely doable. I think the hardest 357 00:16:16,520 --> 00:16:17,860 part of this is going to be 358 00:16:18,940 --> 00:16:20,360 improving on silly 359 00:16:20,360 --> 00:16:22,180 obstructionist patents which have been put there by 360 00:16:22,180 --> 00:16:23,400 companies backed by venture capital. 361 00:16:24,520 --> 00:16:25,340 Sorry I'm 362 00:16:26,020 --> 00:16:27,680 alright. So 363 00:16:28,400 --> 00:16:29,460 challenge number three 364 00:16:30,780 --> 00:16:32,360 decomposing executables into 365 00:16:32,360 --> 00:16:34,760 modules. Given an executable 366 00:16:34,760 --> 00:16:36,420 not written in an object oriented 367 00:16:36,420 --> 00:16:38,460 manner decompose it into modules. 368 00:16:38,620 --> 00:16:40,500 Find all functions performing 369 00:16:40,500 --> 00:16:42,600 a similar task. The modules should 370 00:16:42,600 --> 00:16:44,320 reflect loose coupling and strong cohesions 371 00:16:45,360 --> 00:16:46,700 and you should 372 00:16:46,700 --> 00:16:48,360 try to minimize the number of 373 00:16:48,360 --> 00:16:50,280 external like of exported functions. 374 00:16:51,960 --> 00:16:52,540 Separate the 375 00:16:52,540 --> 00:16:54,360 data structures within these modules into 376 00:16:54,360 --> 00:16:55,780 internal and external data structures. 377 00:16:56,060 --> 00:16:58,600 Now I really have no idea 378 00:16:58,600 --> 00:17:00,460 at all how to do this. I have a bunch of 379 00:17:00,460 --> 00:17:02,440 rough ideas that might be 380 00:17:02,440 --> 00:17:04,460 starting points but really don't know how to 381 00:17:04,460 --> 00:17:05,040 proceed from there. 382 00:17:06,160 --> 00:17:07,960 Approach number one would be calculate 383 00:17:08,620 --> 00:17:10,360 trees on the call graph mainly 384 00:17:10,360 --> 00:17:12,580 because you will thus 385 00:17:12,580 --> 00:17:14,360 find like the nodes in the 386 00:17:14,360 --> 00:17:16,540 dominator tree once it's constructed which have a very high 387 00:17:16,540 --> 00:17:18,500 odd degree will reflect gateway nodes 388 00:17:18,500 --> 00:17:20,700 meaning nodes that dominate many other nodes 389 00:17:20,700 --> 00:17:22,580 meaning nodes that 390 00:17:22,580 --> 00:17:24,640 well through which you have to pass in order to 391 00:17:24,640 --> 00:17:26,520 reach other functions. So these 392 00:17:26,520 --> 00:17:28,340 would be candidates for gateway nodes to separate 393 00:17:28,340 --> 00:17:30,380 a call graph into individual 394 00:17:30,380 --> 00:17:30,840 modules. 395 00:17:32,300 --> 00:17:34,400 Approach number two might be consider this an optimization 396 00:17:34,400 --> 00:17:36,480 problem. Try to decompose the 397 00:17:36,480 --> 00:17:38,280 call graph into strongly connected 398 00:17:38,620 --> 00:17:40,420 components by removing a minimal 399 00:17:40,420 --> 00:17:41,500 number of nodes. 400 00:17:42,080 --> 00:17:44,480 This would be equivalent to or not equivalent but this would be 401 00:17:44,480 --> 00:17:45,960 similar to trying to find the gateway nodes. 402 00:17:46,660 --> 00:17:47,920 Approach number three would be 403 00:17:47,920 --> 00:17:50,560 try to group the functions not by the call hierarchy 404 00:17:50,560 --> 00:17:52,500 but by having them operate 405 00:17:52,500 --> 00:17:53,860 on the same data structures. 406 00:17:54,200 --> 00:17:56,460 So if you know that this set of functions here 407 00:17:56,460 --> 00:17:58,540 all operate on a set 408 00:17:58,540 --> 00:18:00,500 of data structures, group them together. 409 00:18:01,460 --> 00:18:02,580 A rough idea 410 00:18:02,580 --> 00:18:04,160 for this would be for 411 00:18:04,160 --> 00:18:06,720 every data structure in the executable 412 00:18:07,760 --> 00:18:08,520 look at the 413 00:18:08,620 --> 00:18:10,440 set of functions operating on 414 00:18:10,440 --> 00:18:12,040 this data structure. 415 00:18:12,940 --> 00:18:14,540 Then try to choose 416 00:18:14,540 --> 00:18:16,320 a set of functions that 417 00:18:16,320 --> 00:18:17,780 minimizes the number of nodes 418 00:18:17,780 --> 00:18:20,040 while maximizing the number of 419 00:18:20,620 --> 00:18:22,160 subsets operating on data structures 420 00:18:22,160 --> 00:18:23,260 which we've just described. 421 00:18:24,220 --> 00:18:25,660 That might work. I don't know. 422 00:18:25,860 --> 00:18:28,640 You will probably need some sort of fuzziness and configurability 423 00:18:28,640 --> 00:18:30,360 for this because it's not a problem where you 424 00:18:30,360 --> 00:18:32,160 have a very discrete 425 00:18:32,160 --> 00:18:34,380 solution space where you can say okay now this is the 426 00:18:34,380 --> 00:18:35,960 right solution and this is the wrong solution 427 00:18:35,960 --> 00:18:38,320 because we're speaking about decomposing 428 00:18:38,620 --> 00:18:40,280 things into something that appears logical 429 00:18:40,280 --> 00:18:41,220 to a human observer. 430 00:18:42,540 --> 00:18:44,460 Alright. Challenge number 431 00:18:44,460 --> 00:18:46,240 four. Recovery of template generated 432 00:18:46,240 --> 00:18:48,140 code from the executable. Well templates 433 00:18:48,140 --> 00:18:50,260 we've all seen them. They 434 00:18:50,260 --> 00:18:52,280 tend to generate a lot of duplicate code 435 00:18:52,280 --> 00:18:54,600 because essentially every time you instantiate 436 00:18:54,600 --> 00:18:55,900 a template with a new type 437 00:18:56,420 --> 00:18:57,920 all the functions for that 438 00:18:58,860 --> 00:19:00,800 template will be duplicated 439 00:19:00,800 --> 00:19:02,360 in the executable. So you'll get like 440 00:19:02,360 --> 00:19:04,400 50 variants of the same 441 00:19:04,400 --> 00:19:05,640 function which only differ 442 00:19:06,380 --> 00:19:08,360 in, well basically in 443 00:19:08,620 --> 00:19:09,920 subsets and call targets. 444 00:19:10,800 --> 00:19:12,500 And that just means that you have 445 00:19:12,500 --> 00:19:14,520 a massive explosion of code size and we 446 00:19:14,520 --> 00:19:16,440 as the reverse engineers should not be bothered with 447 00:19:16,440 --> 00:19:17,960 having to see oh I've read this before. 448 00:19:18,220 --> 00:19:20,480 Like we can programmatically tell now this function 449 00:19:20,480 --> 00:19:22,180 really is the same as the other function. 450 00:19:22,520 --> 00:19:24,500 It's just changed a few offsets, right? 451 00:19:26,000 --> 00:19:26,440 This 452 00:19:26,440 --> 00:19:28,320 should be very, very, very 453 00:19:28,320 --> 00:19:30,620 easy in most cases. The only cases 454 00:19:30,620 --> 00:19:32,480 where I can imagine complications with this 455 00:19:32,480 --> 00:19:33,840 is if somebody 456 00:19:34,600 --> 00:19:36,680 starts, like if the compiler starts inlining 457 00:19:37,400 --> 00:19:37,840 some 458 00:19:38,960 --> 00:19:40,300 functions of the template 459 00:19:40,800 --> 00:19:42,140 and doesn't inline others. 460 00:19:43,200 --> 00:19:44,540 I don't know. This depends 461 00:19:44,540 --> 00:19:46,120 on the madness of the compiler. I would assume 462 00:19:46,500 --> 00:19:48,680 that in most cases it's going to be very, very easy. 463 00:19:50,160 --> 00:19:50,600 Alright. 464 00:19:50,940 --> 00:19:52,660 Perhaps with like bindiff style 465 00:19:52,660 --> 00:19:54,620 structural comparison and then a little bit of semantic 466 00:19:54,620 --> 00:19:55,160 tracking thereafter. 467 00:19:57,120 --> 00:19:58,440 Okay. Challenge number five. 468 00:19:58,620 --> 00:20:00,280 Now this is my favorite one and it's also 469 00:20:00,280 --> 00:20:02,420 probably one of the hardest problems I 470 00:20:02,420 --> 00:20:03,460 can imagine. 471 00:20:04,540 --> 00:20:06,580 In fact I have a very hard time imagining 472 00:20:06,580 --> 00:20:08,300 a problem that is more difficult than this. 473 00:20:11,280 --> 00:20:12,320 The problem is 474 00:20:12,800 --> 00:20:14,920 given a location t in the executable 475 00:20:14,920 --> 00:20:16,260 we want to reach a 476 00:20:16,260 --> 00:20:18,280 well, we are given 477 00:20:18,280 --> 00:20:20,260 a location t which is our target location 478 00:20:20,260 --> 00:20:22,480 and we're given a location s that is our source 479 00:20:22,480 --> 00:20:24,560 location. We know how to get to s 480 00:20:24,560 --> 00:20:26,400 because, I don't know, we've traced the application 481 00:20:26,400 --> 00:20:28,180 we know we're here. And 482 00:20:28,180 --> 00:20:30,480 t is where our bug is. Now 483 00:20:30,480 --> 00:20:32,240 we would like to automatically construct input 484 00:20:32,240 --> 00:20:33,140 to reach t. 485 00:20:35,560 --> 00:20:36,520 And yeah. 486 00:20:36,620 --> 00:20:38,200 So that is 487 00:20:38,620 --> 00:20:40,480 difficult. And to make things a little bit more interesting 488 00:20:40,480 --> 00:20:42,320 we do not only want one 489 00:20:42,320 --> 00:20:43,880 input to reach t. 490 00:20:44,140 --> 00:20:46,400 We want a description of the set of 491 00:20:46,400 --> 00:20:48,360 all possible inputs that reach t. 492 00:20:49,340 --> 00:20:49,820 So 493 00:20:50,680 --> 00:20:52,620 that is going to be a bit 494 00:20:52,620 --> 00:20:54,740 tricky. In the general case this is 495 00:20:54,740 --> 00:20:56,440 this is three set and thus 496 00:20:56,440 --> 00:20:58,300 NP-hard and we can basically forget about it. 497 00:20:58,460 --> 00:21:00,620 As I said you never ever actually run into 498 00:21:00,620 --> 00:21:01,580 the general case but 499 00:21:01,580 --> 00:21:04,380 we shall see. The first 500 00:21:04,380 --> 00:21:05,780 obvious idea which 501 00:21:06,680 --> 00:21:08,520 has been explored by Sherry Sparks and 502 00:21:08,620 --> 00:21:10,200 her co-researchers 503 00:21:10,200 --> 00:21:12,040 is to use genetic algorithms for this. 504 00:21:12,260 --> 00:21:14,640 Because you have a very very easily measurable 505 00:21:15,300 --> 00:21:16,080 fitness function. 506 00:21:16,320 --> 00:21:18,420 Meaning you can measure the distance to your 507 00:21:18,420 --> 00:21:20,600 target node which means that for any input 508 00:21:20,600 --> 00:21:21,940 you can say okay now this came 509 00:21:21,940 --> 00:21:24,580 this close to my target node, this came that close to my 510 00:21:24,580 --> 00:21:26,360 target node. So it's really ideal for genetic 511 00:21:26,360 --> 00:21:27,380 algorithms in that sense. 512 00:21:28,800 --> 00:21:30,180 I saw the talk of 513 00:21:30,700 --> 00:21:32,220 Cunningham, Hamilton, Sparks at Black Hat. 514 00:21:32,460 --> 00:21:33,400 It was a good talk. 515 00:21:34,060 --> 00:21:36,580 I personally am not totally sure whether 516 00:21:37,180 --> 00:21:37,600 genetic 517 00:21:38,620 --> 00:21:39,960 algorithms will be the way to go 518 00:21:39,960 --> 00:21:42,440 for all of it. Mainly because you only get 519 00:21:42,440 --> 00:21:43,980 one solution to reach a certain place 520 00:21:44,440 --> 00:21:46,320 and you don't know which fields you can 521 00:21:46,320 --> 00:21:48,460 change which will not invalidate 522 00:21:48,460 --> 00:21:50,480 your sample. Because consider the fact that 523 00:21:50,480 --> 00:21:52,480 you want to overflow something and now you have 524 00:21:52,480 --> 00:21:54,460 reached a location and you still need to know 525 00:21:54,460 --> 00:21:56,240 whether you can actually put, like you 526 00:21:56,240 --> 00:21:58,400 still need to trigger that bug so you will need to modify 527 00:21:58,400 --> 00:22:00,120 your sample thereafter and 528 00:22:00,580 --> 00:22:01,500 I don't know, I 529 00:22:02,140 --> 00:22:02,960 have my doubts. 530 00:22:04,760 --> 00:22:06,300 Then again my idea is 531 00:22:06,300 --> 00:22:08,460 completely crazy so I don't think that anybody 532 00:22:08,620 --> 00:22:09,760 is crazy enough to pick up on this. 533 00:22:09,960 --> 00:22:12,160 The idea with this would be to model a path for the 534 00:22:12,160 --> 00:22:14,480 executable as an equation system 535 00:22:14,480 --> 00:22:16,040 mixing modular arithmetic, meaning 536 00:22:16,040 --> 00:22:17,540 modular 2 to the power of 32 537 00:22:17,540 --> 00:22:20,200 and the Boolean functions XOR and 538 00:22:20,200 --> 00:22:21,340 OR, NOT and ROAR. 539 00:22:22,600 --> 00:22:24,160 We would basically transform 540 00:22:24,160 --> 00:22:25,900 a path for the executable into a 541 00:22:25,900 --> 00:22:26,800 satisfiability problem. 542 00:22:28,740 --> 00:22:30,540 Or alternatively into a set 543 00:22:30,540 --> 00:22:32,160 of possibly very large 544 00:22:32,160 --> 00:22:34,500 polynomials over GF2 which is 545 00:22:34,500 --> 00:22:36,180 the field of 0 and 1 546 00:22:36,880 --> 00:22:38,500 where all the unknown bits 547 00:22:38,620 --> 00:22:39,380 are the inputs. 548 00:22:40,460 --> 00:22:42,520 And then we try to solve either the equation 549 00:22:42,520 --> 00:22:44,240 system or the satisfiability problem. 550 00:22:46,300 --> 00:22:48,480 Rotate right or rotate left, just 551 00:22:48,480 --> 00:22:49,040 bitwise rotation. 552 00:22:50,940 --> 00:22:52,600 If you find a general way to solve 553 00:22:52,600 --> 00:22:54,400 these equation systems, you've got MD5 and SHA 554 00:22:54,400 --> 00:22:56,520 solved so there won't be a really general way for 555 00:22:56,520 --> 00:22:58,220 solving arbitrary equation systems like this. 556 00:22:58,360 --> 00:23:00,080 They're equivalent to 3SAT. 557 00:23:01,020 --> 00:23:01,900 Alright, so 558 00:23:02,420 --> 00:23:04,580 for the satisfiability stuff we can 559 00:23:04,580 --> 00:23:06,220 use published SAT solvers. 560 00:23:06,400 --> 00:23:08,480 These things have gotten relatively good, like they can 561 00:23:08,620 --> 00:23:10,260 solve satisfiability problems with a few 562 00:23:10,260 --> 00:23:11,800 million variables by now. 563 00:23:12,020 --> 00:23:14,540 So perhaps they might be able to solve our path problem. 564 00:23:15,700 --> 00:23:16,520 What I've 565 00:23:16,520 --> 00:23:18,540 been mostly experimenting with was using 566 00:23:18,540 --> 00:23:20,440 OBDD style algorithms. 567 00:23:20,800 --> 00:23:22,460 OBDDs are special 568 00:23:22,460 --> 00:23:24,580 data structures with which you can represent functions 569 00:23:24,580 --> 00:23:26,700 that map from a series of bits 570 00:23:26,700 --> 00:23:28,780 like from a bit string to 0 and 1 571 00:23:28,780 --> 00:23:30,440 and can thus be used for 572 00:23:30,440 --> 00:23:31,800 representing very large data sets. 573 00:23:32,280 --> 00:23:34,580 And what I have 574 00:23:34,580 --> 00:23:36,500 gotten solved so far is solving equation 575 00:23:36,500 --> 00:23:38,380 systems that don't involve multiplication 576 00:23:38,620 --> 00:23:39,800 and rotation. 577 00:23:40,340 --> 00:23:42,640 Like if you only have addition and Boolean 578 00:23:42,640 --> 00:23:44,640 functions, I can solve the equation systems. 579 00:23:45,060 --> 00:23:46,520 Can't deal with multiplication or 580 00:23:46,520 --> 00:23:47,240 rotation yet, so 581 00:23:48,260 --> 00:23:48,920 oh well. 582 00:23:50,840 --> 00:23:52,240 There's going to be complications 583 00:23:52,240 --> 00:23:54,040 for all of this. 584 00:23:55,140 --> 00:23:55,980 There's another 585 00:23:56,520 --> 00:23:58,240 very, very nasty edge to the problem 586 00:23:58,240 --> 00:24:00,520 which is it's not enough to 587 00:24:00,520 --> 00:24:02,560 craft input for one path 588 00:24:02,560 --> 00:24:04,640 because most paths will not only 589 00:24:04,640 --> 00:24:06,540 be dependent on user input but on program state 590 00:24:06,540 --> 00:24:08,520 which means in order to exercise a certain 591 00:24:08,620 --> 00:24:10,400 path you first have to authenticate or you 592 00:24:10,400 --> 00:24:11,740 first have to send a different packet 593 00:24:11,740 --> 00:24:14,420 which leads to the fact that you basically have to determine 594 00:24:14,420 --> 00:24:16,380 okay now which state, like 595 00:24:16,380 --> 00:24:17,240 what for example, 596 00:24:17,960 --> 00:24:20,280 what state is the program in here 597 00:24:20,280 --> 00:24:22,480 and how can I get that program to 598 00:24:22,480 --> 00:24:24,420 that state. So if they test for like 599 00:24:24,420 --> 00:24:26,520 are we in state number 2, then I have to 600 00:24:26,520 --> 00:24:28,200 find out whether setting state to 2 601 00:24:28,200 --> 00:24:30,480 and then try to exercise the code path to go to 602 00:24:30,480 --> 00:24:32,140 state 2 and so forth. 603 00:24:32,280 --> 00:24:34,740 So this can very easily go massively out of hand. 604 00:24:35,380 --> 00:24:35,980 Oh well. 605 00:24:37,420 --> 00:24:37,820 Um 606 00:24:38,620 --> 00:24:40,560 enough of number 5. Number 5 is really, really 607 00:24:40,560 --> 00:24:42,120 a bitch in every way. 608 00:24:42,320 --> 00:24:43,400 Like it's just hard. 609 00:24:44,080 --> 00:24:46,200 Challenge number 6. This is going to be a little bit 610 00:24:46,200 --> 00:24:46,960 easier. 611 00:24:48,060 --> 00:24:50,180 Trying to automate the analysis of translation 612 00:24:50,180 --> 00:24:51,600 and emulation based obfuscators. 613 00:24:52,280 --> 00:24:53,620 Um, well 614 00:24:53,620 --> 00:24:55,920 code obfuscation is getting a bit boring. 615 00:24:56,080 --> 00:24:57,700 96 was the first time that 616 00:24:57,700 --> 00:24:59,880 Soda Designer published a 617 00:25:00,460 --> 00:25:01,900 CrackMe which was based on a virtual machine 618 00:25:01,900 --> 00:25:03,760 where you basically created a 619 00:25:04,240 --> 00:25:05,800 CPU and paper, wrote an emulator, 620 00:25:06,020 --> 00:25:07,420 wrote the CrackMe in the 621 00:25:08,620 --> 00:25:10,220 instruction set, executed it. 622 00:25:10,860 --> 00:25:12,660 Very, very, very difficult at the time 623 00:25:12,660 --> 00:25:14,560 to take apart. And these things have 624 00:25:14,560 --> 00:25:15,900 gotten boringly common by now. 625 00:25:16,280 --> 00:25:18,660 And there's no generic methods 626 00:25:18,660 --> 00:25:20,240 to analyze these things. 627 00:25:20,840 --> 00:25:22,540 And let's 628 00:25:22,540 --> 00:25:24,520 not kid people into thinking that 629 00:25:24,520 --> 00:25:25,860 these things are actually hard to take apart. 630 00:25:26,280 --> 00:25:28,620 So a good 631 00:25:28,620 --> 00:25:30,500 research topic would be try to build 632 00:25:30,500 --> 00:25:32,020 a framework which allows the 633 00:25:32,580 --> 00:25:33,700 rapid analysis of 634 00:25:34,480 --> 00:25:36,760 VM based obfuscations. 635 00:25:37,060 --> 00:25:38,600 Um, and usually 636 00:25:38,620 --> 00:25:40,540 all these VM based obfuscations operate 637 00:25:40,540 --> 00:25:42,640 in the same manner. You have like a context structure 638 00:25:42,640 --> 00:25:44,540 which describes the inner state of the 639 00:25:44,540 --> 00:25:46,260 virtual machine. 640 00:25:46,760 --> 00:25:48,420 And you have a decoding loop that fetches 641 00:25:48,420 --> 00:25:50,240 the next instruction. And that then 642 00:25:50,240 --> 00:25:52,460 branches off to the individual instruction handlers. 643 00:25:52,880 --> 00:25:53,760 So, um, 644 00:25:53,980 --> 00:25:56,420 my rough idea of this would be try to exploit the 645 00:25:56,420 --> 00:25:57,860 existing structure of these things. 646 00:25:58,740 --> 00:26:00,540 Um, for example you could very, very 647 00:26:00,540 --> 00:26:02,380 easily build a debugger for an arbitrary virtual 648 00:26:02,380 --> 00:26:04,380 machine. You just have to identify the 649 00:26:04,380 --> 00:26:06,600 decoding loop. If you identify the decoding loop 650 00:26:06,600 --> 00:26:08,140 set a breakpoint inside the 651 00:26:08,620 --> 00:26:10,500 decoding loop and dump the context structure 652 00:26:10,500 --> 00:26:12,360 on every step. Whoa, we have a single 653 00:26:12,360 --> 00:26:13,720 stepping debugger for the virtual machine. 654 00:26:14,080 --> 00:26:16,500 Very, very cheaply done. Should be able, like, should be 655 00:26:16,500 --> 00:26:18,020 possible to do this in Python very quickly. 656 00:26:19,160 --> 00:26:20,260 Um, and then 657 00:26:20,260 --> 00:26:22,220 comes the difficult part. Try to 658 00:26:22,220 --> 00:26:24,460 recover the semantics of the individual 659 00:26:24,460 --> 00:26:26,520 instructions. Because most of the people writing 660 00:26:26,520 --> 00:26:28,240 these virtual machines are not very imaginative. 661 00:26:28,480 --> 00:26:30,440 Meaning, they'll just have an 662 00:26:30,440 --> 00:26:32,240 addition instruction and a XOR instruction 663 00:26:32,240 --> 00:26:34,260 and the instructions will mirror like 664 00:26:34,260 --> 00:26:36,080 a real CPU that we know very closely. 665 00:26:36,260 --> 00:26:38,400 So the question is, can we somehow 666 00:26:39,100 --> 00:26:40,680 automatically, either statically 667 00:26:40,680 --> 00:26:42,540 or dynamically, recover the 668 00:26:42,540 --> 00:26:44,380 semantics of the individual instruction handlers? 669 00:26:44,600 --> 00:26:46,660 So, um, this could be done either 670 00:26:46,660 --> 00:26:48,580 by trying to statically analyze them, or 671 00:26:48,580 --> 00:26:50,660 by just seeing, okay, now, um, 672 00:26:50,740 --> 00:26:52,720 I just, like, 673 00:26:52,820 --> 00:26:54,500 I set the context to this state, I 674 00:26:54,500 --> 00:26:56,500 execute the handler, I see the output. I set 675 00:26:56,500 --> 00:26:58,380 the context to a different state, execute the handler, 676 00:26:58,500 --> 00:27:00,580 see the output. And, uh, 677 00:27:00,740 --> 00:27:02,640 well, if you see that always the, 678 00:27:02,700 --> 00:27:04,700 like, register C is the result of register A 679 00:27:04,700 --> 00:27:06,620 plus register B, obviously this 680 00:27:06,620 --> 00:27:07,720 function is going to be an addition. 681 00:27:09,180 --> 00:27:10,360 Um, I don't know how 682 00:27:10,360 --> 00:27:12,260 difficult all of this is going to be. I think that the 683 00:27:12,260 --> 00:27:13,900 first part is going to be very, very easy. 684 00:27:14,120 --> 00:27:16,380 I think the second part is going to be, uh, 685 00:27:16,520 --> 00:27:18,160 arbitrarily hard, depending on 686 00:27:18,160 --> 00:27:20,300 how clever the guy writing the virtual machine is. 687 00:27:20,520 --> 00:27:22,220 But I think in practice, for most 688 00:27:22,220 --> 00:27:24,200 existing virtual machines, it should not be hard. 689 00:27:25,320 --> 00:27:26,180 Challenge number seven. 690 00:27:26,660 --> 00:27:28,520 An algorithm to transform code 691 00:27:28,520 --> 00:27:30,220 into a canonical normal form. 692 00:27:30,720 --> 00:27:32,300 Now, uh, this ties in 693 00:27:32,300 --> 00:27:34,560 a little bit with the lecture we had before I started 694 00:27:34,560 --> 00:27:35,860 talking. Um, 695 00:27:36,720 --> 00:27:38,160 which is, basically, 696 00:27:38,620 --> 00:27:40,460 almost all the obfuscators, or many, many 697 00:27:40,460 --> 00:27:41,000 obfuscators, 698 00:27:43,700 --> 00:27:44,100 essentially, 699 00:27:44,300 --> 00:27:45,860 um, translate 700 00:27:45,860 --> 00:27:48,460 instructions by doing table lookups. So you have one 701 00:27:48,460 --> 00:27:50,600 instruction, and you have multiple tables 702 00:27:50,600 --> 00:27:52,580 which have equivalent entries, equivalent 703 00:27:52,580 --> 00:27:54,480 but different entries to represent a certain 704 00:27:54,480 --> 00:27:56,460 instruction. What they'll then do is they'll 705 00:27:56,460 --> 00:27:57,960 just do a lookup into the table. 706 00:27:58,700 --> 00:28:00,480 And replace one instruction with another 707 00:28:00,480 --> 00:28:02,060 one, and iterate this, and, uh, 708 00:28:02,240 --> 00:28:04,100 well, here in an example, we can 709 00:28:04,500 --> 00:28:06,520 obfuscate at EAX20 in these 710 00:28:06,520 --> 00:28:08,360 two different ways, and you can come up with an arbitrary 711 00:28:08,620 --> 00:28:10,420 number of ways to represent this. 712 00:28:11,060 --> 00:28:12,600 And you just iterate this 713 00:28:12,600 --> 00:28:14,260 over a bunch of garbage code for, uh, 714 00:28:14,420 --> 00:28:16,380 over a bunch of code, and your code, 715 00:28:16,620 --> 00:28:18,640 like your signal-to-noise ratio in your 716 00:28:18,640 --> 00:28:20,320 code can get arbitrarily small, like you can 717 00:28:20,320 --> 00:28:22,680 have, uh, one instruction in the end 718 00:28:22,680 --> 00:28:24,700 being represented by two hundred 719 00:28:24,700 --> 00:28:26,520 instructions, of which you can't remove a single 720 00:28:26,520 --> 00:28:28,120 one because the output would not be the same. 721 00:28:28,580 --> 00:28:30,120 So, the question is, 722 00:28:31,220 --> 00:28:32,620 um, under the assumption 723 00:28:32,620 --> 00:28:34,340 that the obfuscation introduces no 724 00:28:34,340 --> 00:28:36,280 new memory access, and no 725 00:28:36,280 --> 00:28:38,380 self-modifying code, can we 726 00:28:38,620 --> 00:28:40,400 create, uh, a reduction relation 727 00:28:40,400 --> 00:28:41,920 that is confluent, meaning, 728 00:28:42,480 --> 00:28:44,380 um, that holds, has the following 729 00:28:44,380 --> 00:28:46,640 property. If you have 730 00:28:46,640 --> 00:28:48,580 a code sequence s and 731 00:28:48,580 --> 00:28:50,420 s prime, derived 732 00:28:50,420 --> 00:28:52,280 by replacing one instruction 733 00:28:52,280 --> 00:28:54,280 with a sequence of equivalent instructions, 734 00:28:54,460 --> 00:28:56,160 as I described, um, 735 00:28:56,380 --> 00:28:58,560 without introducing memory access or self-modifying 736 00:28:58,560 --> 00:29:00,220 code, we want, uh, 737 00:29:00,560 --> 00:29:01,840 a function that reduces 738 00:29:02,520 --> 00:29:04,500 s and s prime to the same 739 00:29:04,500 --> 00:29:06,600 normal form n. This need 740 00:29:06,600 --> 00:29:08,020 not necessarily be the same 741 00:29:09,200 --> 00:29:10,320 instruction that was 742 00:29:10,320 --> 00:29:12,280 mutated. It just needs to be 743 00:29:12,280 --> 00:29:14,560 the same representation, no matter how 744 00:29:14,560 --> 00:29:15,840 I mutate my original one. 745 00:29:16,220 --> 00:29:18,600 So I can compare, I can later on test, is this 746 00:29:18,600 --> 00:29:20,380 the same as this? Um, 747 00:29:21,360 --> 00:29:22,120 yeah, so, 748 00:29:22,280 --> 00:29:24,380 if you are able to, to construct 749 00:29:24,380 --> 00:29:26,240 such a thing, you should be able to trivially 750 00:29:26,240 --> 00:29:28,060 deobfuscate most metamorphic engines. 751 00:29:28,620 --> 00:29:29,940 So, that would be fun. 752 00:29:30,500 --> 00:29:32,360 Uh, concerning the difficulty of this, 753 00:29:32,520 --> 00:29:34,620 I'm not sure whether it's possible, but it looks like a 754 00:29:34,620 --> 00:29:36,460 really, really fun exercise for anybody who is a bit 755 00:29:36,460 --> 00:29:37,200 mathematically inclined. 756 00:29:39,000 --> 00:29:40,280 Alright, uh, 757 00:29:40,480 --> 00:29:42,280 challenge number eight, we're back to fuzzy 758 00:29:42,280 --> 00:29:44,460 visualization, uh, clicky 759 00:29:44,460 --> 00:29:46,120 stuff. Um, basically, 760 00:29:46,800 --> 00:29:48,540 call graphs are really nice, and they're 761 00:29:48,540 --> 00:29:50,440 really useful to visualize and see which function 762 00:29:50,440 --> 00:29:52,260 calls which, but they have one 763 00:29:52,260 --> 00:29:54,460 big drawback. They lose 764 00:29:54,460 --> 00:29:56,580 the ordering of sub-function 765 00:29:56,580 --> 00:29:58,580 calls, which means, if I have 766 00:29:58,580 --> 00:30:00,420 a function that calls malloc string length 767 00:30:00,420 --> 00:30:02,660 memcpy, um, I just 768 00:30:02,660 --> 00:30:04,280 see in the graph, okay, now this node calls 769 00:30:04,280 --> 00:30:06,600 malloc string length memcpy, but 770 00:30:06,600 --> 00:30:08,540 I can't, um, know in which 771 00:30:08,620 --> 00:30:10,640 order they're called. But the thing 772 00:30:10,640 --> 00:30:12,620 is that the structure of the individual flow graphs 773 00:30:12,620 --> 00:30:14,220 of every function, 774 00:30:14,340 --> 00:30:16,500 um, introduces a 775 00:30:16,500 --> 00:30:18,800 partial ordering on the sub-function 776 00:30:18,800 --> 00:30:20,340 calls. And 777 00:30:20,340 --> 00:30:22,280 I would like to have a mode of visualizing 778 00:30:22,280 --> 00:30:24,640 a program which is 779 00:30:24,640 --> 00:30:26,600 similar to looking at the call graph, but 780 00:30:26,600 --> 00:30:28,420 which doesn't lose the information of which 781 00:30:28,420 --> 00:30:30,100 call comes before which other call. 782 00:30:30,240 --> 00:30:32,460 That somehow represents this partial 783 00:30:32,460 --> 00:30:34,560 order on the sub-function calls visually to me. 784 00:30:34,720 --> 00:30:36,520 Because then, I mean, it's 785 00:30:36,520 --> 00:30:38,340 very different whether a function first calls 786 00:30:39,520 --> 00:30:40,400 memcpy, then 787 00:30:40,400 --> 00:30:42,200 string length, then malloc, 788 00:30:42,320 --> 00:30:44,500 or a function that calls string length 789 00:30:44,500 --> 00:30:46,460 malloc memcpy. Like, just by 790 00:30:46,460 --> 00:30:48,500 looking at the two orderings, you can infer 791 00:30:48,500 --> 00:30:49,960 about what the function is actually doing. 792 00:30:50,740 --> 00:30:52,540 And, as such, it should be 793 00:30:52,540 --> 00:30:54,220 a lot better if we can actually see that order. 794 00:30:55,640 --> 00:30:56,520 Alright. Challenge 795 00:30:56,520 --> 00:30:58,420 number nine. Um, this is a fun one. 796 00:30:59,200 --> 00:30:59,640 Um, 797 00:31:00,260 --> 00:31:02,340 given a network daemon that 798 00:31:02,340 --> 00:31:04,280 has some sort of internal state, 799 00:31:04,380 --> 00:31:05,900 like an ISA-KMP parser or whatever, 800 00:31:06,120 --> 00:31:08,080 and they have some state variable internally, 801 00:31:08,620 --> 00:31:10,500 um, that they update depending on 802 00:31:11,020 --> 00:31:12,520 well, on what's happening on the network, 803 00:31:12,960 --> 00:31:14,580 can we construct 804 00:31:15,100 --> 00:31:16,380 basically a state diagram 805 00:31:16,380 --> 00:31:18,640 from the executable? First of all, we'd need 806 00:31:18,640 --> 00:31:20,460 to separate the functions into functions that 807 00:31:20,460 --> 00:31:22,320 can be reached in a certain state. So you'd be 808 00:31:22,320 --> 00:31:24,660 separating it like, these functions 809 00:31:24,660 --> 00:31:26,680 are reached in state one, these functions 810 00:31:26,680 --> 00:31:28,540 are reached in state two, these functions 811 00:31:28,540 --> 00:31:29,880 are reached in whichever state. 812 00:31:30,580 --> 00:31:32,320 And then, you try to reconstruct 813 00:31:32,320 --> 00:31:34,460 okay, now they're writing the value 814 00:31:34,460 --> 00:31:36,440 four to the state variable in 815 00:31:36,440 --> 00:31:38,140 a function reachable from state two. 816 00:31:38,620 --> 00:31:40,440 So obviously your state diagram should now 817 00:31:40,440 --> 00:31:42,400 have a transition from state two to 818 00:31:42,400 --> 00:31:44,400 state four. And the question is whether 819 00:31:44,400 --> 00:31:45,760 you can do this generically enough 820 00:31:45,760 --> 00:31:48,600 so you can reconstruct the, a diagram of 821 00:31:48,600 --> 00:31:50,400 possible straight transitions just from the 822 00:31:50,400 --> 00:31:52,460 executable. This would be tremendously 823 00:31:52,460 --> 00:31:54,560 useful for the analysis of anything that 824 00:31:54,560 --> 00:31:56,280 does any sort of network protocol parsing. 825 00:31:58,200 --> 00:32:00,120 Alright. Challenge number ten. 826 00:32:00,440 --> 00:32:02,480 Um, semantics-based library 827 00:32:02,480 --> 00:32:03,640 signatures. Um, 828 00:32:04,660 --> 00:32:06,600 semantics-based library signatures means 829 00:32:06,600 --> 00:32:07,140 um, 830 00:32:08,620 --> 00:32:10,620 well, if somebody hand rolls his string copy, 831 00:32:10,780 --> 00:32:12,580 I would like to see that. I would 832 00:32:12,580 --> 00:32:14,300 like my, my signature algorithm 833 00:32:14,300 --> 00:32:16,480 to somehow recognize somebody has hand rolled 834 00:32:16,480 --> 00:32:18,500 a string copy. And I want this to 835 00:32:18,500 --> 00:32:20,300 work, uh, no matter how, not 836 00:32:20,300 --> 00:32:22,520 necessarily no matter how, but I want this 837 00:32:22,520 --> 00:32:24,320 to work without having 838 00:32:24,320 --> 00:32:26,780 to have, requiring him to have a very specific 839 00:32:26,780 --> 00:32:28,640 implementation of string copy. Like, I want this to work 840 00:32:28,640 --> 00:32:30,220 even if you call it string length 841 00:32:30,720 --> 00:32:32,700 and mem copy, or also 842 00:32:32,700 --> 00:32:34,500 if he hand rolls both loops. I just want, uh, 843 00:32:34,660 --> 00:32:36,560 a semantic signature for these things. 844 00:32:36,640 --> 00:32:38,160 I want to semantically identify 845 00:32:38,620 --> 00:32:40,540 or I want to identify this function 846 00:32:40,540 --> 00:32:42,000 is inserting into a linked list. 847 00:32:42,300 --> 00:32:44,100 This function is removing from a linked list. 848 00:32:44,420 --> 00:32:46,060 And so forth. So, 849 00:32:46,180 --> 00:32:48,480 um, I think this, this, the 850 00:32:48,480 --> 00:32:50,420 difficulty of this can vary very, very much 851 00:32:50,420 --> 00:32:52,220 depending on what the function is doing. 852 00:32:52,580 --> 00:32:54,600 But I think for relatively simple library 853 00:32:54,600 --> 00:32:56,380 functions, it should not be that difficult. 854 00:32:56,680 --> 00:32:58,700 A possible, possible idea 855 00:32:58,700 --> 00:33:00,300 on, on how to do this would be 856 00:33:01,000 --> 00:33:02,580 well, I'm not sure whether this 857 00:33:02,580 --> 00:33:04,520 will work, but what you could do is you can represent 858 00:33:04,520 --> 00:33:06,560 memory as an abstract graph and try 859 00:33:06,560 --> 00:33:07,800 to represent a function 860 00:33:08,620 --> 00:33:10,720 as an operation on an abstract graph. 861 00:33:11,420 --> 00:33:12,540 And then see how a 862 00:33:12,540 --> 00:33:14,120 function manipulates this memory graph. 863 00:33:14,660 --> 00:33:16,320 And that should yield you information like 864 00:33:16,320 --> 00:33:18,440 you should be able to immediately see 865 00:33:18,440 --> 00:33:19,200 a linked list insert. 866 00:33:20,080 --> 00:33:21,420 I don't know whether this will work. 867 00:33:21,880 --> 00:33:22,860 Um, good luck. 868 00:33:24,280 --> 00:33:26,340 Uh, challenge number 11 is 869 00:33:26,340 --> 00:33:28,060 not all that, that serious 870 00:33:28,060 --> 00:33:30,580 in fact. So, uh, 871 00:33:30,700 --> 00:33:31,660 it's beyond the number 10. 872 00:33:32,120 --> 00:33:34,600 Um, but if we have the, the things that we just 873 00:33:34,600 --> 00:33:36,440 discussed here, we should be able to string 874 00:33:36,440 --> 00:33:37,980 them together to build something that's like a 875 00:33:38,620 --> 00:33:40,200 something that statically analyzes executables, 876 00:33:40,440 --> 00:33:42,400 finds bugs, crafts 877 00:33:42,400 --> 00:33:44,560 inputs to trigger these bugs, and 878 00:33:44,560 --> 00:33:46,580 then we would still have to tackle the problem of automated 879 00:33:46,580 --> 00:33:48,060 exploitation. Um, 880 00:33:48,260 --> 00:33:50,360 I'm not totally serious on this one, so, 881 00:33:50,480 --> 00:33:52,680 um, let's just skip 882 00:33:52,680 --> 00:33:54,260 it here. So to reiterate 883 00:33:54,260 --> 00:33:56,320 my, my difficulty estimates, I think 884 00:33:56,320 --> 00:33:58,180 challenge number 0 is trivial. 885 00:33:58,720 --> 00:34:00,620 Challenge number 1 should 886 00:34:00,620 --> 00:34:02,460 be doable, is not totally trivial, 887 00:34:02,560 --> 00:34:04,060 but doable to anybody skilled in the craft. 888 00:34:04,800 --> 00:34:06,460 Um, very important phrase, 889 00:34:06,620 --> 00:34:08,600 patent law. Challenge number 2 890 00:34:08,620 --> 00:34:10,600 doable, not totally trivial, but doable to 891 00:34:10,600 --> 00:34:11,500 anybody skilled in the craft. 892 00:34:12,040 --> 00:34:13,920 Uh, challenge number 3, um, 893 00:34:14,160 --> 00:34:16,400 that was decomposition to modules. I have no clue 894 00:34:16,400 --> 00:34:18,160 how difficult that is. Um, 895 00:34:18,360 --> 00:34:20,480 number 4 was template recognition. 896 00:34:21,300 --> 00:34:22,640 Should be relatively easy. 897 00:34:23,200 --> 00:34:24,460 Uh, number 5, 898 00:34:24,580 --> 00:34:26,200 uh, input crafting. Uh, 899 00:34:26,360 --> 00:34:28,560 as difficult as any problem you can think of, 900 00:34:28,600 --> 00:34:29,920 I think. Um, 901 00:34:30,120 --> 00:34:32,580 yeah, number 6, VM disassembly. 902 00:34:32,680 --> 00:34:34,420 Uh, VM analysis should 903 00:34:34,420 --> 00:34:36,360 be easy if 904 00:34:36,360 --> 00:34:38,440 we have a VM given, like with a structure 905 00:34:38,620 --> 00:34:39,960 as I described. Um, 906 00:34:40,420 --> 00:34:42,480 challenge number 7, what was challenge number 7? 907 00:34:43,540 --> 00:34:44,460 Oh, yeah, uh, 908 00:34:45,160 --> 00:34:46,300 confluent normal form. 909 00:34:46,480 --> 00:34:48,520 Yes, uh, very, very, very cool. 910 00:34:48,680 --> 00:34:49,980 Uh, probably quite difficult. 911 00:34:50,520 --> 00:34:52,500 Challenge number 8, I have no clue how difficult that is. 912 00:34:52,980 --> 00:34:54,560 Uh, challenge number 9, reconstruction 913 00:34:54,560 --> 00:34:56,460 of the state diagrams, uh, should 914 00:34:56,460 --> 00:34:58,220 be possible, but depends, 915 00:34:58,320 --> 00:35:00,400 depends of course on the, the structure of the 916 00:35:00,400 --> 00:35:01,840 executable. Um, 917 00:35:02,340 --> 00:35:04,200 challenge number 10, um, 918 00:35:04,300 --> 00:35:06,480 semantics-based library signatures. Looks very, 919 00:35:06,560 --> 00:35:08,460 very difficult at first, but getting 920 00:35:08,620 --> 00:35:10,560 something that recognizes some things should 921 00:35:10,560 --> 00:35:12,320 be relatively easy. Alright. 922 00:35:12,860 --> 00:35:14,320 Some other th- other stuff. 923 00:35:14,960 --> 00:35:16,500 Um, we as the reverse 924 00:35:16,500 --> 00:35:18,480 engineering community suffer from the fact that we have 925 00:35:18,480 --> 00:35:20,400 tools that are all closed and all 926 00:35:20,400 --> 00:35:21,940 fragmented and don't talk to each other. 927 00:35:22,300 --> 00:35:24,400 So, um, what 928 00:35:24,400 --> 00:35:26,480 we've been doing at, uh, Sabre recently 929 00:35:26,480 --> 00:35:28,640 was we sat down and we created, 930 00:35:28,680 --> 00:35:30,640 uh, a SQL schema to, 931 00:35:30,640 --> 00:35:32,220 uh, have an architecture independent 932 00:35:32,220 --> 00:35:34,460 rep- um, representation of disassemblies 933 00:35:34,460 --> 00:35:36,440 in a flat address space. And, 934 00:35:36,560 --> 00:35:38,500 um, what we're doing currently 935 00:35:38,620 --> 00:35:40,680 is we're dumping all our, we're 936 00:35:40,680 --> 00:35:42,560 remodeling all our reverse engineering tools 937 00:35:42,560 --> 00:35:44,280 to work on this database. 938 00:35:44,980 --> 00:35:46,540 So, um, we can 939 00:35:46,540 --> 00:35:48,460 have interaction between different tools that just 940 00:35:48,460 --> 00:35:50,000 all operate on the same disassembly, 941 00:35:50,020 --> 00:35:52,460 uh, operate on the same floor graph structure, same 942 00:35:52,460 --> 00:35:54,700 core graph structure, and you can dump data into that executable, 943 00:35:54,840 --> 00:35:56,500 take it out again, and 944 00:35:56,500 --> 00:35:58,420 so forth. Um, we had originally 945 00:35:58,420 --> 00:36:00,460 planned to make that thing public at, at Black Hat. 946 00:36:00,720 --> 00:36:02,700 Um, we've fallen behind a bit 947 00:36:02,700 --> 00:36:04,560 with the documentation, like the, the SQL schema 948 00:36:04,560 --> 00:36:06,640 itself is ready and in testing and seems to be quite good. 949 00:36:06,840 --> 00:36:08,600 Uh, it's just not very documented yet. 950 00:36:08,620 --> 00:36:10,380 And some of the SQL queries are 951 00:36:10,380 --> 00:36:12,560 non-obvious and took 952 00:36:12,560 --> 00:36:14,520 us quite a few time to, to 953 00:36:14,520 --> 00:36:16,440 probably build. So we will be releasing 954 00:36:16,440 --> 00:36:18,700 this in the next two to three months with full documentation. 955 00:36:19,060 --> 00:36:20,400 And we just encourage everybody 956 00:36:20,400 --> 00:36:22,480 to, uh, dump stuff and read stuff 957 00:36:22,480 --> 00:36:24,360 from the database format and then we'll hopefully 958 00:36:24,840 --> 00:36:26,660 have an open database format with which 959 00:36:26,660 --> 00:36:28,340 to exchange disassemblies on, 960 00:36:28,440 --> 00:36:30,440 on, with which to process disassemblies 961 00:36:30,440 --> 00:36:32,440 and on which to work. Um, 962 00:36:33,820 --> 00:36:34,700 so, please 963 00:36:34,700 --> 00:36:36,260 wait for two months while we get the documentation 964 00:36:36,260 --> 00:36:38,380 sorted. We're not very good at these, these things. 965 00:36:38,900 --> 00:36:40,200 Um, what else? 966 00:36:40,480 --> 00:36:42,580 What else? Anybody have any questions? 967 00:36:48,720 --> 00:36:50,440 Um, is this on? Okay. 968 00:36:50,540 --> 00:36:52,100 Um, for problem number seven, I was 969 00:36:52,580 --> 00:36:54,400 actually, something I've actually been looking 970 00:36:54,400 --> 00:36:56,500 at before and I'm wondering if you've ever looked 971 00:36:56,500 --> 00:36:58,520 at using, um, trace caches 972 00:36:58,520 --> 00:37:00,640 or looked into the research, I believe it was done by 973 00:37:00,640 --> 00:37:02,540 Motorola on real-time 974 00:37:02,540 --> 00:37:04,020 machine code to machine code translation. 975 00:37:05,220 --> 00:37:06,500 Um, basically being 976 00:37:06,500 --> 00:37:08,540 able to analyze machine code in real-time 977 00:37:08,620 --> 00:37:10,660 and then translate to an intermediary language 978 00:37:10,660 --> 00:37:12,500 and then spit out machine code that did the 979 00:37:12,500 --> 00:37:14,560 equivalent thing in real-time. They did this about 980 00:37:14,560 --> 00:37:15,340 like ten years ago. 981 00:37:16,000 --> 00:37:18,560 Yeah, but that's, like, there's lots of research on translation 982 00:37:18,560 --> 00:37:20,520 but they usually don't have the 983 00:37:20,520 --> 00:37:22,160 requirement of, um, 984 00:37:23,120 --> 00:37:24,440 after I translate something 985 00:37:24,440 --> 00:37:26,580 and get an output, I want to reduce 986 00:37:26,580 --> 00:37:28,480 this to, uh, a 987 00:37:28,480 --> 00:37:30,420 normal form that is the same for any translations 988 00:37:30,420 --> 00:37:32,380 from the same source. So what, what's, 989 00:37:32,380 --> 00:37:33,760 what's the important part here is that 990 00:37:33,760 --> 00:37:36,460 you really converge on something that is identical 991 00:37:36,900 --> 00:37:38,460 for every, everything that was 992 00:37:38,620 --> 00:37:39,540 generated from the same source. 993 00:37:40,360 --> 00:37:40,720 Okay. 994 00:37:44,680 --> 00:37:46,340 Uh, I have two questions for you. 995 00:37:46,420 --> 00:37:48,340 The first one is related to the first part where we're 996 00:37:48,340 --> 00:37:50,540 talking about we need, we're going to move into a world 997 00:37:50,540 --> 00:37:52,500 where all the variables are managed or at least are, 998 00:37:52,600 --> 00:37:54,560 you know, state-bound, etc. So then we, 999 00:37:54,640 --> 00:37:56,000 you know, the big issue would be application logic. 1000 00:37:56,820 --> 00:37:58,660 Uh, so the question is do you think that 1001 00:37:58,660 --> 00:38:00,600 the current managed language that we have 1002 00:38:00,600 --> 00:38:01,980 today, namely .NET and Java, 1003 00:38:02,160 --> 00:38:04,680 can fit that? And the second one is 1004 00:38:05,040 --> 00:38:06,540 what about doing these challenges 1005 00:38:06,540 --> 00:38:08,500 and starting them at the ma- at the 1006 00:38:08,620 --> 00:38:10,260 .NET and Java world so we can perfect 1007 00:38:10,260 --> 00:38:12,680 techniques and then move into the unmanaged 1008 00:38:12,680 --> 00:38:14,500 world which is the C++ assembly world? 1009 00:38:14,760 --> 00:38:16,660 I personally don't think that 1010 00:38:16,660 --> 00:38:18,460 we'll all move to managed code. I think that 1011 00:38:18,460 --> 00:38:20,500 static analyzers on unmanaged code will get 1012 00:38:20,500 --> 00:38:22,360 strong enough not to have out-of-bounds memory access. 1013 00:38:22,720 --> 00:38:24,460 I think, uh, just because 1014 00:38:24,460 --> 00:38:26,780 the, the world is moving embedded 1015 00:38:26,780 --> 00:38:28,420 in everything and 1016 00:38:28,420 --> 00:38:30,640 the embedded devices are all written in C but 1017 00:38:30,640 --> 00:38:32,480 they're statically verified whenever they're really 1018 00:38:32,480 --> 00:38:34,640 critical. And there's no, no 1019 00:38:34,640 --> 00:38:36,860 use in having a managed language if I can verify, 1020 00:38:37,540 --> 00:38:38,600 verify C code. 1021 00:38:38,620 --> 00:38:40,440 Because if I can ver- do the verification 1022 00:38:40,440 --> 00:38:42,640 upfront, then I can run at full 1023 00:38:42,640 --> 00:38:44,660 CPU speed and don't have to 1024 00:38:44,660 --> 00:38:46,400 worry about out-of-bounds memory access because I've proven 1025 00:38:46,400 --> 00:38:48,420 beforehand that there is none. So- 1026 00:38:48,420 --> 00:38:50,620 But if you take, sorry, if you take the .NET approach, 1027 00:38:51,100 --> 00:38:52,580 the compiled code is running at 1028 00:38:52,580 --> 00:38:54,360 full speed. The managed sort of 1029 00:38:54,360 --> 00:38:56,560 environment is just a way to get there with 1030 00:38:56,560 --> 00:38:58,680 better rules. So you, you 1031 00:38:58,680 --> 00:39:00,540 still have, you know, C++ assembly 1032 00:39:00,540 --> 00:39:02,600 code being executed. It's just that 1033 00:39:02,600 --> 00:39:04,580 we had some rules to get there, which 1034 00:39:04,580 --> 00:39:05,980 is the whole, you know, managed world. 1035 00:39:06,220 --> 00:39:08,120 Yeah. Well, um, 1036 00:39:08,620 --> 00:39:10,460 yeah, then we can of course start on, 1037 00:39:10,460 --> 00:39:12,340 on the managed level. The managed level 1038 00:39:12,340 --> 00:39:14,120 will make almost all of these problems, 1039 00:39:14,260 --> 00:39:16,480 not all of them, but a number of them trivial 1040 00:39:16,480 --> 00:39:18,400 because you can trivially extract classes 1041 00:39:18,400 --> 00:39:20,440 and hierarchies and so forth from the managed code. 1042 00:39:20,640 --> 00:39:22,220 So that's not really a challenge then. 1043 00:39:22,320 --> 00:39:24,340 Well, it's still a challenge to do them, but at least 1044 00:39:24,340 --> 00:39:26,140 you can, you have a good base to start. 1045 00:39:27,300 --> 00:39:28,640 Yeah, yeah. But you might 1046 00:39:28,640 --> 00:39:29,860 as well start with a real challenge. 1047 00:39:33,460 --> 00:39:34,340 Any other questions? 1048 00:39:37,000 --> 00:39:38,080 Bring up 11 again. 1049 00:39:40,880 --> 00:39:41,560 Automated exploitation? 1050 00:39:43,020 --> 00:39:44,540 Can you talk a little bit about 1051 00:39:44,540 --> 00:39:45,500 the bug recognition? 1052 00:39:46,160 --> 00:39:48,500 Can you stand up and talk and, like, 1053 00:39:48,540 --> 00:39:49,080 speak into the microphone? 1054 00:39:50,700 --> 00:39:52,420 I guess I was just curious about the 1055 00:39:52,420 --> 00:39:53,980 bug recognition. So you find, 1056 00:39:54,780 --> 00:39:56,520 it was kind of related to Sherry's talk 1057 00:39:56,520 --> 00:39:58,080 that I, I went to at Black Hat. 1058 00:39:58,300 --> 00:40:00,580 And she was talking about the starting point and the end point. 1059 00:40:00,760 --> 00:40:02,440 But really you have multiple end points 1060 00:40:02,440 --> 00:40:04,420 and, and end point is kind of defined as 1061 00:40:05,280 --> 00:40:06,440 like, say, one variable 1062 00:40:06,440 --> 00:40:08,380 overwriting another with an out of bounds memory check. 1063 00:40:08,620 --> 00:40:10,280 And trying to define those 1064 00:40:10,840 --> 00:40:12,660 as bugs and what other classes 1065 00:40:12,660 --> 00:40:14,100 of bugs might be found there. 1066 00:40:14,820 --> 00:40:16,280 So the question is 1067 00:40:16,280 --> 00:40:18,340 that, like, what, 1068 00:40:18,380 --> 00:40:19,420 what are the end points or? 1069 00:40:24,960 --> 00:40:25,360 Okay. 1070 00:40:28,780 --> 00:40:29,700 Okay, sorry, I, 1071 00:40:30,160 --> 00:40:32,520 if you can rephrase it, I might be able to answer it. 1072 00:40:32,580 --> 00:40:34,100 Like, let's try it after the talk. 1073 00:40:35,060 --> 00:40:36,180 Alright, any other questions? 1074 00:40:39,080 --> 00:40:40,620 No questions. I still have quite a bit of 1075 00:40:40,620 --> 00:40:42,580 free time. Should I just discuss 1076 00:40:42,580 --> 00:40:44,600 a bit of the research that we've been, or not research, but a few 1077 00:40:44,600 --> 00:40:46,080 of the things that we've been building at Sabre recently? 1078 00:40:47,820 --> 00:40:48,460 Alright. So, 1079 00:40:49,600 --> 00:40:50,600 well, one of the things 1080 00:40:50,600 --> 00:40:52,440 that we've been doing, of course, is building 1081 00:40:53,140 --> 00:40:54,600 wait, now I need to, the microphone 1082 00:40:54,600 --> 00:40:56,580 holder because I'll be monkeying around on the keyboard 1083 00:40:56,580 --> 00:40:56,980 a lot more. 1084 00:40:59,300 --> 00:40:59,940 Alright, so. 1085 00:41:02,280 --> 00:41:03,900 Can we turn on the light again, please? 1086 00:41:05,480 --> 00:41:05,800 Thanks. 1087 00:41:06,820 --> 00:41:08,600 Alright, so one of the things we've been doing 1088 00:41:08,620 --> 00:41:10,140 well, we've been optimizing 1089 00:41:11,180 --> 00:41:11,620 the 1090 00:41:11,620 --> 00:41:13,760 the diffing engine quite heavily 1091 00:41:14,260 --> 00:41:16,360 and we've rewritten the 1092 00:41:16,360 --> 00:41:18,020 bindiff engine to be very, very fast 1093 00:41:18,520 --> 00:41:20,520 and with very fast I mean we can diff 1094 00:41:20,520 --> 00:41:22,500 a 25,000 1095 00:41:22,500 --> 00:41:24,240 function World of Warcraft image 1096 00:41:24,920 --> 00:41:25,860 against another one 1097 00:41:25,860 --> 00:41:27,760 on this laptop in less than 10 minutes 1098 00:41:28,560 --> 00:41:30,280 which also allows us to do 1099 00:41:31,200 --> 00:41:32,320 basically a very 1100 00:41:32,320 --> 00:41:34,440 large number of diffs, which means we can do, like 1101 00:41:34,440 --> 00:41:36,720 it's not a big deal to do 100,000 diffs a day or so. 1102 00:41:37,600 --> 00:41:38,380 So what we've 1103 00:41:38,620 --> 00:41:40,540 started doing is we've built an infrastructure for automatic 1104 00:41:40,540 --> 00:41:42,620 classification of new malwares into family trees 1105 00:41:43,720 --> 00:41:44,540 I'll show you 1106 00:41:44,540 --> 00:41:46,560 a few of the results. It works basically by 1107 00:41:46,560 --> 00:41:48,540 you sending an executable in and 1108 00:41:48,540 --> 00:41:50,420 that gets unpacked with a statistical 1109 00:41:50,420 --> 00:41:52,560 unpacker and then disassembled 1110 00:41:52,560 --> 00:41:53,760 and compared to everything in the library 1111 00:41:54,320 --> 00:41:56,680 and then we create family diagrams based on 1112 00:41:56,680 --> 00:41:58,660 on similarity mattresses 1113 00:41:58,660 --> 00:42:00,480 using a little bit of bioinformatic stuff 1114 00:42:01,480 --> 00:42:02,280 one second 1115 00:42:18,340 --> 00:42:20,700 so we've classified about a thousand samples here 1116 00:42:20,700 --> 00:42:22,480 and we can see that they 1117 00:42:22,480 --> 00:42:24,520 basically belong to mostly 1118 00:42:24,520 --> 00:42:26,140 one family and then 1119 00:42:26,140 --> 00:42:27,260 a bunch of smaller ones 1120 00:42:27,260 --> 00:42:29,180 so I'll try to zoom in 1121 00:42:32,020 --> 00:42:32,800 well here 1122 00:42:32,800 --> 00:42:34,440 we have the entire 1123 00:42:34,440 --> 00:42:35,160 gobot family 1124 00:42:36,260 --> 00:42:38,420 which are just different variants, they all have a different 1125 00:42:38,620 --> 00:42:40,100 hr1 sum, they have a different md5 sum 1126 00:42:40,100 --> 00:42:42,200 and we have the output of other 1127 00:42:42,660 --> 00:42:44,540 antivirus scanners as what 1128 00:42:44,540 --> 00:42:45,380 they classify what 1129 00:42:49,220 --> 00:42:50,740 I'm looking, there's a few samples 1130 00:42:50,740 --> 00:42:52,480 in here that were not recognized by one or more 1131 00:42:52,480 --> 00:42:54,420 of the av scanners but which are like 99% 1132 00:42:54,420 --> 00:42:56,320 similar to things that we already have in the database 1133 00:42:58,560 --> 00:42:58,960 yes 1134 00:42:59,680 --> 00:43:00,480 it's very amusing 1135 00:43:00,480 --> 00:43:02,380 to see the different naming conventions for things because 1136 00:43:02,380 --> 00:43:04,400 this is all gobot and some of them are called 1137 00:43:05,900 --> 00:43:06,700 exploitmydoom, win32delph 1138 00:43:06,700 --> 00:43:07,100 whatever 1139 00:43:09,440 --> 00:43:09,920 yadayadayada 1140 00:43:09,920 --> 00:43:12,020 where's something that's not, ah here 1141 00:43:12,540 --> 00:43:13,940 this one here for example is 1142 00:43:13,940 --> 00:43:15,940 a mydoom variant that 1143 00:43:16,620 --> 00:43:18,700 trendmicro doesn't recognize and so forth 1144 00:43:18,700 --> 00:43:20,460 there's quite a few of these things 1145 00:43:20,460 --> 00:43:22,160 very amusing, very cute 1146 00:43:23,280 --> 00:43:24,400 works quite well 1147 00:43:24,400 --> 00:43:26,440 it's one of the primary arguments for 1148 00:43:26,440 --> 00:43:27,940 buying a big cluster because when you 1149 00:43:27,940 --> 00:43:30,800 diff n samples against n samples 1150 00:43:30,800 --> 00:43:32,500 well you still have to populate 1151 00:43:32,500 --> 00:43:33,580 the matrix of n square size 1152 00:43:34,440 --> 00:43:36,640 so you probably want to parallelize that 1153 00:43:36,640 --> 00:43:38,220 other stuff we've been doing 1154 00:43:38,620 --> 00:43:39,960 well we've been 1155 00:43:40,400 --> 00:43:41,880 working hard on binnavi 1156 00:43:41,880 --> 00:43:46,480 which is basically a graph visualization 1157 00:43:46,480 --> 00:43:47,180 and 1158 00:43:48,340 --> 00:43:49,540 one second 1159 00:43:50,180 --> 00:43:51,520 too many windows open 1160 00:43:53,060 --> 00:43:54,400 which is a graph visualization 1161 00:43:54,400 --> 00:43:54,960 framework 1162 00:43:56,580 --> 00:43:57,960 it'll take a minute to load 1163 00:44:02,740 --> 00:44:04,260 close a few windows in the meantime 1164 00:44:06,440 --> 00:44:08,520 it's an older version 1165 00:44:08,620 --> 00:44:09,820 that is doing a lot of xml parsing 1166 00:44:09,820 --> 00:44:10,880 which we've since dropped 1167 00:44:10,880 --> 00:44:12,820 now that we've moved to the database 1168 00:44:12,820 --> 00:44:14,120 we don't have to wait for two minutes 1169 00:44:14,120 --> 00:44:14,940 to open a project anymore 1170 00:44:14,940 --> 00:44:16,080 so apologies for this now 1171 00:44:16,980 --> 00:44:18,400 we'll just have to wait 1172 00:44:21,120 --> 00:44:22,180 any questions in the meantime 1173 00:44:22,180 --> 00:44:23,360 regarding the malware classification 1174 00:44:25,920 --> 00:44:26,600 nope, okay 1175 00:44:28,100 --> 00:44:29,080 come on piece of crap 1176 00:44:30,980 --> 00:44:31,720 ah here we go 1177 00:44:31,720 --> 00:44:34,140 so basically what we have on the left side 1178 00:44:34,140 --> 00:44:35,460 here is a list of all the functions 1179 00:44:35,460 --> 00:44:36,160 in the executable 1180 00:44:38,620 --> 00:44:40,140 and yes we can look at them 1181 00:44:41,340 --> 00:44:42,540 and they're nice and shiny 1182 00:44:43,820 --> 00:44:44,340 and 1183 00:44:45,880 --> 00:44:46,620 we can 1184 00:44:46,620 --> 00:44:48,320 well move things 1185 00:44:48,980 --> 00:44:49,880 add comments 1186 00:44:53,680 --> 00:44:54,820 all sorts of things 1187 00:44:54,820 --> 00:44:56,160 we have mozilla start searching 1188 00:45:03,500 --> 00:45:04,540 we can 1189 00:45:04,540 --> 00:45:06,460 look at sub functions by 1190 00:45:06,460 --> 00:45:07,940 oh well let's take another one 1191 00:45:11,560 --> 00:45:12,300 no worries 1192 00:45:12,300 --> 00:45:13,440 you can disable those animations 1193 00:45:13,440 --> 00:45:15,100 once they get on your nerves 1194 00:45:16,440 --> 00:45:17,120 alright so 1195 00:45:17,120 --> 00:45:18,200 you can open sub functions 1196 00:45:18,200 --> 00:45:19,320 which is not all that interesting 1197 00:45:20,320 --> 00:45:21,780 but what is interesting is 1198 00:45:21,780 --> 00:45:22,860 you can inline sub functions 1199 00:45:22,860 --> 00:45:23,940 into the existing function 1200 00:45:27,580 --> 00:45:28,560 and that's fun 1201 00:45:30,020 --> 00:45:31,260 what you can also do is 1202 00:45:31,260 --> 00:45:32,080 you can 1203 00:45:32,600 --> 00:45:34,100 well this is coupled with a debugger 1204 00:45:34,100 --> 00:45:35,120 I'll quickly start my vmware 1205 00:45:35,120 --> 00:45:35,680 to demonstrate 1206 00:46:00,200 --> 00:46:00,560 alright 1207 00:46:01,580 --> 00:46:02,980 so what we can do here now 1208 00:46:02,980 --> 00:46:04,680 is well let's open 1209 00:46:04,680 --> 00:46:06,640 the call tree of all functions in the executable 1210 00:46:06,640 --> 00:46:08,100 that is going to take another few seconds 1211 00:46:08,620 --> 00:46:09,820 because it's about 8000 functions 1212 00:46:12,780 --> 00:46:13,740 blackberry message router 1213 00:46:13,740 --> 00:46:14,480 very much fun 1214 00:46:16,040 --> 00:46:16,840 alright so 1215 00:46:17,500 --> 00:46:19,780 we can search for for example the receive function 1216 00:46:20,520 --> 00:46:21,680 and this is the receive function 1217 00:46:21,680 --> 00:46:23,800 these are all the functions that directly call receive 1218 00:46:23,800 --> 00:46:25,720 these are all the functions that directly call receive 1219 00:46:25,720 --> 00:46:26,400 two layers upwards 1220 00:46:28,040 --> 00:46:30,220 these are all the functions that call receive 1221 00:46:30,220 --> 00:46:31,240 one layer downwards then 1222 00:46:32,440 --> 00:46:34,040 what we can do also now is 1223 00:46:34,040 --> 00:46:35,900 we can set breakpoints on all functions at once 1224 00:46:35,900 --> 00:46:37,680 so what we do is we just hit record 1225 00:46:39,000 --> 00:46:40,520 and in the background it will start 1226 00:46:40,520 --> 00:46:41,240 talking to the vm 1227 00:46:41,860 --> 00:46:43,780 and set 8000 breakpoints 1228 00:46:50,280 --> 00:46:50,800 alright 1229 00:46:51,820 --> 00:46:53,980 so while it's setting breakpoints 1230 00:46:53,980 --> 00:46:55,720 set all the breakpoints 1231 00:46:55,720 --> 00:46:57,340 we'll now send some data 1232 00:47:01,060 --> 00:47:02,100 and we 1233 00:47:02,520 --> 00:47:03,680 hit stop again 1234 00:47:05,500 --> 00:47:06,680 and what we can do now 1235 00:47:06,680 --> 00:47:08,360 is we can see well 1236 00:47:09,600 --> 00:47:10,320 we can just 1237 00:47:10,320 --> 00:47:12,440 see all the debug events that happened 1238 00:47:12,440 --> 00:47:13,160 and 1239 00:47:14,380 --> 00:47:16,580 get the graph of all the functions 1240 00:47:16,580 --> 00:47:17,460 that were just executed 1241 00:47:19,320 --> 00:47:20,940 we can lay them out hierarchically 1242 00:47:20,940 --> 00:47:21,760 they're not that bad really 1243 00:47:21,760 --> 00:47:23,700 make great wallpapers if you have a plotter 1244 00:47:26,000 --> 00:47:26,400 alright 1245 00:47:27,340 --> 00:47:27,740 so 1246 00:47:28,680 --> 00:47:29,600 these are the functions 1247 00:47:33,060 --> 00:47:34,580 other stuff that we can do is 1248 00:47:34,580 --> 00:47:35,040 um 1249 00:47:36,800 --> 00:47:38,600 let me quickly try to find the relevant 1250 00:47:38,620 --> 00:47:38,840 function 1251 00:47:42,200 --> 00:47:43,180 here it is 1252 00:47:43,180 --> 00:47:44,720 so if we look at this 1253 00:47:44,720 --> 00:47:45,980 function here this is the main 1254 00:47:47,540 --> 00:47:48,420 hello main 1255 00:47:48,420 --> 00:47:49,560 SRP message parser 1256 00:47:51,260 --> 00:47:52,160 yes here we are 1257 00:47:54,100 --> 00:47:54,540 and 1258 00:47:54,540 --> 00:47:56,460 we can now of course just collect the same debug 1259 00:47:56,460 --> 00:47:57,120 events on this graph 1260 00:48:01,480 --> 00:48:02,560 and see the 1261 00:48:02,560 --> 00:48:03,300 path it executed 1262 00:48:04,300 --> 00:48:05,880 right there was a mistake here 1263 00:48:05,880 --> 00:48:07,840 hey demo effect I've been waiting for you 1264 00:48:11,840 --> 00:48:12,280 alright 1265 00:48:12,280 --> 00:48:12,680 alright 1266 00:48:15,300 --> 00:48:16,700 so we can now see the path 1267 00:48:16,700 --> 00:48:18,440 that was just executed through this function 1268 00:48:20,320 --> 00:48:20,760 and 1269 00:48:20,760 --> 00:48:22,440 we can zoom in 1270 00:48:24,680 --> 00:48:26,720 and we can inline a sub function 1271 00:48:31,160 --> 00:48:31,880 one second 1272 00:48:35,060 --> 00:48:36,500 and then we have the whole function 1273 00:48:38,720 --> 00:48:40,140 and we can set the breakpoints again 1274 00:48:40,140 --> 00:48:42,080 and then we can see the trace of the debugger 1275 00:48:42,080 --> 00:48:42,960 through multiple functions 1276 00:48:52,740 --> 00:48:53,100 alright 1277 00:48:53,100 --> 00:48:54,540 so there's a whole bunch of fun stuff 1278 00:48:54,540 --> 00:48:55,160 you can do with this 1279 00:48:55,160 --> 00:48:57,880 it can also calculate your paths through the executable 1280 00:48:57,880 --> 00:48:59,040 where you have like two basic blocks 1281 00:48:59,040 --> 00:49:00,000 and you want to get from A to B 1282 00:49:00,000 --> 00:49:01,640 and so forth and so forth 1283 00:49:01,640 --> 00:49:05,620 now we've been moving this away from operating on XML files 1284 00:49:05,620 --> 00:49:07,460 to operating on the generic Java 1285 00:49:07,460 --> 00:49:09,180 on the generic SQL format 1286 00:49:09,180 --> 00:49:11,660 and for that we've also ported 1287 00:49:11,660 --> 00:49:13,540 a small Python interpreter 1288 00:49:13,540 --> 00:49:15,620 into it I'll quickly give you 1289 00:49:15,620 --> 00:49:17,660 a snap or like a glimpse of the development version 1290 00:49:37,580 --> 00:49:38,760 so we connect to the database 1291 00:49:39,580 --> 00:49:41,700 we have multiple executables in the database 1292 00:49:41,700 --> 00:49:43,040 which is quite advantageous 1293 00:49:43,040 --> 00:49:44,140 if you have a team of reverse engineers 1294 00:49:44,140 --> 00:49:46,000 you can just all work on the same database at once 1295 00:49:46,780 --> 00:49:48,140 and you don't have to hunt 1296 00:49:48,140 --> 00:49:49,300 for your disassemblies anymore 1297 00:49:50,240 --> 00:49:50,640 alright 1298 00:49:51,740 --> 00:49:53,680 and now well this is all something 1299 00:49:53,680 --> 00:49:54,680 that you've seen previously 1300 00:49:54,680 --> 00:49:57,120 in the last variant of it 1301 00:49:57,120 --> 00:49:59,000 the nice part is having the Python interpreter 1302 00:50:02,220 --> 00:50:03,380 so we can do stuff like 1303 00:50:04,740 --> 00:50:05,540 manipulate, disassemble 1304 00:50:05,620 --> 00:50:05,720 disassemblies 1305 00:50:05,720 --> 00:50:07,900 in a very very easy way 1306 00:50:07,900 --> 00:50:10,660 like x equals basic block 1307 00:50:11,620 --> 00:50:12,200 0x402080 1308 00:50:12,200 --> 00:50:13,600 print x 1309 00:50:15,300 --> 00:50:15,700 and 1310 00:50:15,700 --> 00:50:18,140 well we can 1311 00:50:18,140 --> 00:50:21,020 have the thing show us it's operands 1312 00:50:21,020 --> 00:50:23,080 like print x dot 1313 00:50:23,440 --> 00:50:24,940 instructions minus two 1314 00:50:25,380 --> 00:50:26,400 dot operands 1315 00:50:27,440 --> 00:50:29,220 print x dot instructions 1316 00:50:29,220 --> 00:50:31,000 minus two dot operands 1317 00:50:31,500 --> 00:50:32,520 one, yes thanks 1318 00:50:34,020 --> 00:50:35,400 x instructions 1319 00:50:35,620 --> 00:50:36,680 operands minus two 1320 00:50:37,300 --> 00:50:38,140 whatever show 1321 00:50:38,140 --> 00:50:40,880 the operands are actually stored in the database as trees 1322 00:50:40,880 --> 00:50:42,960 which is the most generic way of representing them 1323 00:50:43,440 --> 00:50:45,040 and then you can manipulate them easily 1324 00:50:45,620 --> 00:50:47,020 and you can do fun stuff like 1325 00:50:47,020 --> 00:50:48,020 creating a new graph 1326 00:50:49,660 --> 00:50:51,480 and adding a node to that graph 1327 00:50:51,480 --> 00:50:52,440 which consists of 1328 00:50:54,420 --> 00:50:55,800 the HTML code 1329 00:50:55,800 --> 00:50:57,780 generated from a basic block 1330 00:51:01,180 --> 00:51:02,860 and then you can show the graph 1331 00:51:03,900 --> 00:51:05,600 and continue manipulating it 1332 00:51:05,620 --> 00:51:08,160 adding edges, adding comments, whatever you want 1333 00:51:08,160 --> 00:51:09,900 so there's a whole bunch of fun in this one 1334 00:51:10,480 --> 00:51:11,280 in general 1335 00:51:11,280 --> 00:51:13,200 having a database format that is generic 1336 00:51:13,200 --> 00:51:14,680 is really really really empowering 1337 00:51:14,680 --> 00:51:16,360 and I'm very much looking forward to everybody 1338 00:51:17,200 --> 00:51:18,180 trying to use it 1339 00:51:18,180 --> 00:51:20,260 and yelling at us for all the things that we've done wrongly 1340 00:51:21,700 --> 00:51:23,160 any other questions currently? 1341 00:51:28,440 --> 00:51:28,880 cool 1342 00:51:31,020 --> 00:51:32,500 is the small microphone 1343 00:51:32,500 --> 00:51:32,900 like a 1344 00:51:35,620 --> 00:51:36,020 ok 1345 00:51:36,020 --> 00:51:38,860 I had a question on the first product that you were demonstrating 1346 00:51:38,860 --> 00:51:41,100 where you had all the agobots 1347 00:51:41,620 --> 00:51:42,940 it looked like you had 1348 00:51:43,440 --> 00:51:45,380 parents, grandparents, children and so forth 1349 00:51:45,380 --> 00:51:47,680 how do you determine what are the precedents 1350 00:51:47,680 --> 00:51:49,360 and descendants of a particular version 1351 00:51:49,360 --> 00:51:51,700 you're speaking by passing the microphone 1352 00:51:51,700 --> 00:51:52,400 currently, sorry 1353 00:51:52,400 --> 00:51:55,660 how do you determine the precedents 1354 00:51:55,660 --> 00:51:57,460 you know the parents and the children 1355 00:51:57,460 --> 00:51:58,540 of particular flavors 1356 00:51:58,540 --> 00:52:00,940 we have a basically 1357 00:52:00,940 --> 00:52:02,320 percentual similarity metric 1358 00:52:02,320 --> 00:52:04,480 we do structural comparison 1359 00:52:05,620 --> 00:52:06,180 with the stuff that Bindiff does 1360 00:52:06,180 --> 00:52:09,020 and then we have basically a mapping between the functions 1361 00:52:09,020 --> 00:52:10,040 between the two executables 1362 00:52:10,040 --> 00:52:12,920 and we just measure how many functions in the executables 1363 00:52:12,920 --> 00:52:14,580 we were able to match percentually 1364 00:52:14,580 --> 00:52:15,840 to the total number of functions 1365 00:52:15,840 --> 00:52:18,680 so we have a percentage similarity measure 1366 00:52:18,680 --> 00:52:20,460 and then we use UPGMA 1367 00:52:20,460 --> 00:52:21,380 or whatever it's called 1368 00:52:21,380 --> 00:52:22,660 as clustering algorithm 1369 00:52:22,660 --> 00:52:25,260 to generate these parent-child hierarchies 1370 00:52:25,260 --> 00:52:27,440 it's similar to genetic analysis 1371 00:52:27,440 --> 00:52:29,700 where you measure mutants over time 1372 00:52:29,700 --> 00:52:32,240 yeah it's basically the simplest algorithm 1373 00:52:32,240 --> 00:52:33,900 we could glean from a bioinformatics book 1374 00:52:35,820 --> 00:52:36,500 thank you 1375 00:52:36,500 --> 00:52:38,580 any other questions? 1376 00:52:40,700 --> 00:52:41,560 well then I hope 1377 00:52:41,560 --> 00:52:42,640 this was moderately entertaining 1378 00:52:42,640 --> 00:52:43,840 and have a good DEF CON