1 00:00:00,000 --> 00:00:03,200 I'm Nick Harbour. I'm an incident responder and consultant with Mandiant. 2 00:00:03,740 --> 00:00:06,760 My primary analysis. I also do a lot of research and development. 3 00:00:08,600 --> 00:00:12,000 So, let's get cracking. Oh, there's also supposed to be questions and answers 4 00:00:12,000 --> 00:00:15,100 or something. They want me to keep me hostage in there for two hours. 5 00:00:15,720 --> 00:00:20,100 I'm going to have to bail on that. As you can imagine, that doesn't sound too entertaining. I did compete in the Race to Zero 6 00:00:20,100 --> 00:00:23,340 competition, so I'd kind of like to get over there and see if I won or not. 7 00:00:25,000 --> 00:00:27,620 So, I apologize for not having an extended 8 00:00:27,620 --> 00:00:28,740 two-hour QA session. 9 00:00:31,240 --> 00:00:35,500 So, here's what we're going to talk about a little bit today. We're going to start out, I'm going to go over some basics on Packers 10 00:00:35,500 --> 00:00:39,620 and exactly what the current state of the field is today. And a little bit 11 00:00:39,620 --> 00:00:43,380 of theory behind them. And then I'm going to talk about my tool that I'm releasing called 12 00:00:43,380 --> 00:00:47,540 PE Scrambler and how it's different from what's out there today. And I'm going to 13 00:00:47,540 --> 00:00:51,520 rant a little bit about the challenges and headaches I faced when 14 00:00:51,520 --> 00:00:55,700 writing the tool. It was kind of a pain. And I'm going to discuss 15 00:00:56,240 --> 00:00:57,600 piecewise some of the techniques that I'm going to talk about today. 16 00:00:57,620 --> 00:01:01,200 And go into the theory on exactly how they work, why they work, 17 00:01:01,320 --> 00:01:04,960 what the flaws might be in modern disassembly techniques and things like that. 18 00:01:05,420 --> 00:01:09,460 The future avenues of development, such as the polymorphic code replacement. 19 00:01:10,020 --> 00:01:13,600 And then I have a tool for the good guys at the end, which is 20 00:01:13,600 --> 00:01:17,520 a malware detection tool that uses a disassembler to detect 21 00:01:17,520 --> 00:01:21,420 packed binaries in malware. So, releasing two tools today. 22 00:01:21,520 --> 00:01:23,880 This is a talk that's going to encompass both of them. 23 00:01:24,780 --> 00:01:27,640 Alright. So let's talk a little bit about packers and where 24 00:01:27,640 --> 00:01:31,640 they're going today. A packer, if you don't know what it is, it's a tool to compress 25 00:01:31,640 --> 00:01:34,880 or encrypt a binary so that it still has its original functionality. 26 00:01:35,380 --> 00:01:39,800 There's two sides of the coin on how they want to be used. Compression or protection. 27 00:01:41,160 --> 00:01:43,520 And they're kind of, there's usually a trade off between the two. 28 00:01:44,260 --> 00:01:47,140 So I plotted on a graph like this. So you have packers that 29 00:01:47,140 --> 00:01:51,660 are really good at compression that don't particularly care too much about being hard to reverse engineer 30 00:01:51,660 --> 00:01:52,940 or thwarting the reverse engineer. 31 00:01:53,140 --> 00:01:54,820 Then on the other end of the scale you have packers, 32 00:01:54,860 --> 00:01:56,840 which actually might make the binary larger, 33 00:01:57,040 --> 00:01:58,900 but are very difficult to reverse engineer. 34 00:01:59,200 --> 00:02:02,600 So my PE Scrambler tool, it's certainly going to be 35 00:02:02,600 --> 00:02:04,600 on the armoring end, not on the compression end. 36 00:02:04,680 --> 00:02:07,220 It's going to make binaries probably almost twice as big. 37 00:02:10,240 --> 00:02:12,180 A little bit about the traditional packer design, 38 00:02:12,360 --> 00:02:14,860 which is going to encompass most of the easy, common packers 39 00:02:14,860 --> 00:02:16,120 that are on the compression end of things. 40 00:02:16,920 --> 00:02:18,540 As a reverse engineer and malware analyst, 41 00:02:18,680 --> 00:02:21,040 I don't usually lose sleep about those kind of packers. 42 00:02:21,040 --> 00:02:25,280 They're easy to defeat, and the reason they're easy to defeat 43 00:02:25,280 --> 00:02:26,900 is they all work on the same basic model. 44 00:02:28,060 --> 00:02:31,160 The packer program compresses or encrypts the original binary 45 00:02:31,160 --> 00:02:32,560 in its complete intact state. 46 00:02:32,740 --> 00:02:35,020 It appends a small unpacker stub program, 47 00:02:35,280 --> 00:02:37,340 and then when the executable runs, 48 00:02:37,460 --> 00:02:40,040 that unpacker stub launches, unencrypts or uncompresses 49 00:02:40,740 --> 00:02:42,600 the original binary in its complete state, 50 00:02:42,780 --> 00:02:44,100 and then just jumps into it. 51 00:02:45,240 --> 00:02:46,820 So if you catch it with its pants down, 52 00:02:46,900 --> 00:02:48,780 you have the original binary pretty much intact. 53 00:02:49,140 --> 00:02:50,940 So here's how the process works. 54 00:02:51,040 --> 00:02:53,360 When the actual packer compresses the original binary, 55 00:02:53,520 --> 00:02:55,580 we have an original binary here, 56 00:02:55,620 --> 00:02:56,960 which has three sections in it, 57 00:02:57,060 --> 00:02:58,980 .text, .data, and then a resources section. 58 00:02:59,380 --> 00:03:00,740 I'm just picking on UPX. 59 00:03:00,800 --> 00:03:02,860 It's a pretty good basic model of a packer. 60 00:03:03,280 --> 00:03:05,580 All that stuff in the .text and the .data, 61 00:03:05,660 --> 00:03:07,080 which is executable instructions 62 00:03:07,080 --> 00:03:09,880 and any type of data needed by the program, 63 00:03:10,040 --> 00:03:12,060 is all compressed and put into one of these sections 64 00:03:12,060 --> 00:03:14,240 in the pack binary, usually the UPX1 section, 65 00:03:14,440 --> 00:03:17,820 and that's also where you get the stub program 66 00:03:17,820 --> 00:03:19,000 put right in that same thing. 67 00:03:19,140 --> 00:03:20,820 And there's a UPX0 section, 68 00:03:21,040 --> 00:03:22,320 which is just kind of an empty placeholder, 69 00:03:22,500 --> 00:03:23,860 and we'll see how that loads. 70 00:03:24,020 --> 00:03:25,680 Whenever you launch the packed binary, 71 00:03:26,300 --> 00:03:28,560 it looks quite a bit different in memory than it did on disk. 72 00:03:28,840 --> 00:03:30,600 You have that UPX0 section, 73 00:03:30,700 --> 00:03:32,960 which was empty in the actual file, 74 00:03:33,120 --> 00:03:34,760 that becomes much larger in memory 75 00:03:34,760 --> 00:03:37,060 and actually becomes pretty much the size 76 00:03:37,060 --> 00:03:38,020 of all the original data. 77 00:03:38,400 --> 00:03:41,760 So the entry point in the packed binary launches. 78 00:03:42,000 --> 00:03:44,820 The stub program unpacks the original code 79 00:03:44,820 --> 00:03:47,060 out of its section and populates it 80 00:03:47,060 --> 00:03:48,280 into the UPX0 section, 81 00:03:48,480 --> 00:03:50,160 and then it just jumps right into it. 82 00:03:51,140 --> 00:03:53,160 And most traditional packers 83 00:03:53,160 --> 00:03:54,480 are kind of just theme and variations 84 00:03:54,480 --> 00:03:55,580 on this very basic model. 85 00:03:55,800 --> 00:03:57,420 You have a packed payload. 86 00:03:57,740 --> 00:04:00,140 You have kind of a landing zone where you want to put it. 87 00:04:00,460 --> 00:04:01,600 The unpacker stub, 88 00:04:02,060 --> 00:04:03,920 through any type of gyration and mechanism, 89 00:04:04,520 --> 00:04:06,340 unpacks it in its complete original state. 90 00:04:06,560 --> 00:04:08,420 So the binary has to get back to a point 91 00:04:09,280 --> 00:04:11,380 where it was originally compiled to run from. 92 00:04:11,440 --> 00:04:12,480 There's not a whole lot of moving 93 00:04:12,880 --> 00:04:14,420 that you can do on where that thing is. 94 00:04:15,760 --> 00:04:17,180 So like I said, they're easy to defeat. 95 00:04:17,320 --> 00:04:18,860 There's many ways you can use 96 00:04:18,860 --> 00:04:20,200 to detect these basic packers. 97 00:04:21,040 --> 00:04:23,080 We can detect when code is being overwritten. 98 00:04:23,200 --> 00:04:25,360 We can detect when that section jump occurs, 99 00:04:25,520 --> 00:04:27,680 like when the unpacker stub jumps into something 100 00:04:27,680 --> 00:04:29,420 that didn't used to be code. 101 00:04:30,560 --> 00:04:32,340 And the main problem is that 102 00:04:32,340 --> 00:04:36,360 it uncompresses the original binary into memory. 103 00:04:36,540 --> 00:04:38,320 So if you catch it while it's running, 104 00:04:38,500 --> 00:04:41,420 you have it, and you can easily reverse engineer it. 105 00:04:41,460 --> 00:04:42,820 Nothing's been changed with that binary. 106 00:04:43,560 --> 00:04:44,940 So stepping it up a notch, 107 00:04:45,220 --> 00:04:46,880 some more sophisticated packers 108 00:04:46,880 --> 00:04:49,520 do some things mainly with actually modifying 109 00:04:49,520 --> 00:04:50,500 that original binary. 110 00:04:51,040 --> 00:04:52,960 So at no point do you actually have 111 00:04:52,960 --> 00:04:54,780 a complete original intact binary 112 00:04:54,780 --> 00:04:56,620 that you can easily reverse engineer in IDA Pro. 113 00:04:58,100 --> 00:05:00,580 So ThaMida and VMprotect are pretty good examples. 114 00:05:00,740 --> 00:05:02,760 They actually translate the instructions 115 00:05:02,760 --> 00:05:04,420 in the original binary into, like, 116 00:05:04,480 --> 00:05:06,240 a virtual machine language that executes. 117 00:05:06,980 --> 00:05:09,000 That's particularly tricky, but it also, 118 00:05:09,080 --> 00:05:10,360 as you can imagine, might have some problems 119 00:05:10,360 --> 00:05:11,940 in compatibility and whatnot. 120 00:05:12,260 --> 00:05:13,300 Those are commercial tools, 121 00:05:13,500 --> 00:05:16,000 and they cost quite a bit of money to run. 122 00:05:17,740 --> 00:05:19,760 And it's always kind of used at your own risk. 123 00:05:19,760 --> 00:05:21,280 Not that my tool isn't, 124 00:05:21,400 --> 00:05:23,620 but I work on a slightly different model. 125 00:05:25,880 --> 00:05:27,700 So how my little packer works 126 00:05:28,760 --> 00:05:31,720 is I manipulate the x86 instructions 127 00:05:31,720 --> 00:05:33,840 for the purpose of anti-reverse engineering. 128 00:05:34,340 --> 00:05:35,860 So I have a disassembler, 129 00:05:35,900 --> 00:05:37,480 so I basically disassemble the whole binary, 130 00:05:37,680 --> 00:05:39,360 and based on all that analysis, 131 00:05:39,780 --> 00:05:41,540 I can move around chunks of code, 132 00:05:41,640 --> 00:05:43,000 I can wrap chunks of code, 133 00:05:43,080 --> 00:05:43,960 I can do all sorts of things. 134 00:05:44,020 --> 00:05:45,760 I can hijack function calls, 135 00:05:46,860 --> 00:05:48,960 wrap chunks of code in anti-reverse engineering, 136 00:05:48,960 --> 00:05:51,700 and later on we'll get into some polymorphic stuff 137 00:05:51,700 --> 00:05:52,220 that I can do. 138 00:05:53,980 --> 00:05:55,820 So some of the challenges and headaches I've had 139 00:05:55,820 --> 00:05:58,520 when writing this is there's no margin of error 140 00:05:58,520 --> 00:05:59,520 for bad disassembly. 141 00:05:59,600 --> 00:06:01,860 So since I'm in the business of finding instructions 142 00:06:01,860 --> 00:06:03,980 and manipulating them and moving them around, 143 00:06:04,220 --> 00:06:05,720 if I do that on something 144 00:06:05,720 --> 00:06:07,440 that wasn't actually instructions to begin with, 145 00:06:08,340 --> 00:06:10,040 potentially serious problems with the binary. 146 00:06:10,140 --> 00:06:10,760 It's not going to work. 147 00:06:10,980 --> 00:06:12,960 So iDub Pro can get away with that 148 00:06:12,960 --> 00:06:14,440 and it's disassembly because, eh, whatever. 149 00:06:14,680 --> 00:06:16,280 It disassembled something that wasn't real. 150 00:06:16,280 --> 00:06:17,920 You know, the user can go in there 151 00:06:17,920 --> 00:06:19,420 and mess with it and it's fine. 152 00:06:19,580 --> 00:06:25,240 But for me, I have a realistic set standard 153 00:06:25,240 --> 00:06:26,940 on what needs to be proper disassembly. 154 00:06:26,980 --> 00:06:29,040 It simply will bomb out my whole program 155 00:06:29,040 --> 00:06:30,260 if it isn't perfect. 156 00:06:30,440 --> 00:06:32,540 So I spent most of this project actually 157 00:06:32,540 --> 00:06:33,860 refining the disassembler, 158 00:06:33,880 --> 00:06:37,240 reducing false positives and getting the code 159 00:06:37,240 --> 00:06:39,560 really to a true disassembly, 160 00:06:39,580 --> 00:06:41,280 which is pretty interesting. 161 00:06:42,080 --> 00:06:42,700 There's a lot into that. 162 00:06:43,380 --> 00:06:44,780 It's pretty amazing that pretty much 163 00:06:44,780 --> 00:06:46,760 almost any arbitrary data structure 164 00:06:46,760 --> 00:06:49,840 can look like Intel assembly if you disassemble it, 165 00:06:49,920 --> 00:06:51,280 even though it completely isn't. 166 00:06:52,360 --> 00:06:54,260 So my disassembler is very pessimistic 167 00:06:54,260 --> 00:06:56,000 and I'm going to use this same disassembler engine 168 00:06:56,000 --> 00:06:57,680 and the other tool I'm going to show you 169 00:06:57,680 --> 00:06:59,420 at the end of the talk, which I can use to find malware. 170 00:07:01,100 --> 00:07:03,160 All right, so let's get into the first little trick I can do. 171 00:07:04,280 --> 00:07:06,240 I just called it function call dispatching. 172 00:07:06,380 --> 00:07:08,420 So basically, with my disassembly, 173 00:07:08,460 --> 00:07:11,220 I'm going to find every function call in the program, 174 00:07:11,360 --> 00:07:12,580 whether it's to an internal function 175 00:07:12,580 --> 00:07:14,760 or to something from the import table 176 00:07:14,780 --> 00:07:16,240 like an external DLL. 177 00:07:16,440 --> 00:07:17,800 I can find each one of those instructions 178 00:07:17,800 --> 00:07:21,780 and actually remap them to a tiny little 65-byte function 179 00:07:21,780 --> 00:07:23,040 that I insert into the binary. 180 00:07:23,360 --> 00:07:25,880 And this function is basically then going to call 181 00:07:25,880 --> 00:07:26,980 whatever it was supposed to call. 182 00:07:27,240 --> 00:07:31,800 So if you look at an original call tree of a function, 183 00:07:32,000 --> 00:07:33,680 so we have function A that calls B and C, 184 00:07:33,860 --> 00:07:35,900 and then each one of those calls functions of its own. 185 00:07:36,320 --> 00:07:39,560 If you dispatch all these and you remap them all 186 00:07:39,560 --> 00:07:40,560 to point to the dispatcher, 187 00:07:40,680 --> 00:07:43,020 the call tree is completely obliterated. 188 00:07:43,020 --> 00:07:45,020 It all looks like everything is just calling one function. 189 00:07:45,540 --> 00:07:46,340 It's pretty sweet. 190 00:07:46,880 --> 00:07:48,500 And once we have the ability to do that, 191 00:07:48,560 --> 00:07:50,500 we can do further avenues of research 192 00:07:50,500 --> 00:07:53,560 and function-level packing and things like that. 193 00:07:55,020 --> 00:07:56,560 So how this thing works, 194 00:07:56,660 --> 00:07:58,000 it works based off the return pointer. 195 00:07:58,280 --> 00:08:00,820 So I'm just going to cover a quick primer on the return pointer 196 00:08:00,820 --> 00:08:02,700 for anybody that's a little bit new to this. 197 00:08:03,200 --> 00:08:05,240 So here's a quick snippet of C code. 198 00:08:05,380 --> 00:08:06,460 It prints out two things. 199 00:08:07,320 --> 00:08:08,380 When this gets compiled, 200 00:08:08,620 --> 00:08:10,560 we get this set of assembly instructions. 201 00:08:11,020 --> 00:08:12,680 Notice those two call instructions. 202 00:08:13,020 --> 00:08:14,660 That's the real important guys that we're looking at here. 203 00:08:14,980 --> 00:08:18,000 So we see offsets being pushed to the printf and whatnot. 204 00:08:19,560 --> 00:08:21,740 So I'm going to step through this and watch how it executes. 205 00:08:23,520 --> 00:08:24,300 First the push. 206 00:08:24,460 --> 00:08:26,360 So you see the string hello world pushed on the stack 207 00:08:26,360 --> 00:08:27,760 or really a pointer to it. 208 00:08:29,820 --> 00:08:31,120 Now when the call instruction executes, 209 00:08:31,740 --> 00:08:32,620 this is the key point here. 210 00:08:32,720 --> 00:08:33,840 The thing that was pushed on the stack 211 00:08:33,840 --> 00:08:34,860 is what's called the return pointer. 212 00:08:34,940 --> 00:08:37,660 So that's going to point back to the next instruction in the list. 213 00:08:39,100 --> 00:08:40,660 So when the printf function is done, 214 00:08:40,700 --> 00:08:42,480 it knows where it needs to get back to in your program. 215 00:08:43,820 --> 00:08:45,440 And we can continue stepping through. 216 00:08:46,280 --> 00:08:48,440 And the same thing happens for every single function call. 217 00:08:48,600 --> 00:08:49,820 And in most binaries, 218 00:08:49,880 --> 00:08:51,720 that return pointer is never going to change. 219 00:08:51,900 --> 00:08:53,540 For every return pointer, 220 00:08:53,700 --> 00:08:55,400 I should know, based on disassembly, 221 00:08:55,420 --> 00:08:57,180 what function was supposed to have been called 222 00:08:57,180 --> 00:08:59,100 by the previous call instruction. 223 00:08:59,880 --> 00:09:00,720 It's pretty basic. 224 00:09:00,940 --> 00:09:02,260 So the function call dispatcher, 225 00:09:02,280 --> 00:09:05,740 all it does is it has a table of return pointers 226 00:09:05,740 --> 00:09:06,880 and then a table of targets. 227 00:09:07,140 --> 00:09:08,740 So whenever it gets called, 228 00:09:08,820 --> 00:09:10,360 it checks the return pointer off the stack 229 00:09:10,360 --> 00:09:11,740 and sees what it's supposed to call. 230 00:09:13,020 --> 00:09:13,680 And then it goes back and jumps to it. 231 00:09:14,100 --> 00:09:14,700 It's beautiful. 232 00:09:18,180 --> 00:09:18,720 All right. 233 00:09:18,800 --> 00:09:20,920 So the next concept here is code chunking. 234 00:09:21,200 --> 00:09:23,900 So this is going to kind of open the avenue 235 00:09:23,900 --> 00:09:25,440 for a lot more advanced areas of research 236 00:09:25,440 --> 00:09:26,920 because the main problem you have 237 00:09:26,920 --> 00:09:28,920 with trying to add anti-reverse engineering code 238 00:09:28,920 --> 00:09:30,900 into a binary is that you don't have the ability 239 00:09:30,900 --> 00:09:33,020 to just wedge in extra bytes into a binary 240 00:09:33,020 --> 00:09:33,960 and then hope that it works. 241 00:09:34,080 --> 00:09:35,320 It simply doesn't work that way. 242 00:09:35,760 --> 00:09:37,180 It's going to fail pretty miserably. 243 00:09:37,340 --> 00:09:38,660 That's what I tried when I was young. 244 00:09:39,480 --> 00:09:41,600 I found it to be a lot more of a problem. 245 00:09:43,020 --> 00:09:44,840 You can know how to intelligently move things around. 246 00:09:45,040 --> 00:09:45,940 So that's exactly what I do. 247 00:09:46,100 --> 00:09:49,080 I find sequences of instructions that I can easily relocate 248 00:09:49,080 --> 00:09:51,420 and I do things like I substitute a jump there 249 00:09:51,420 --> 00:09:52,920 and put the instructions somewhere else 250 00:09:52,920 --> 00:09:54,400 and then I jump back when I'm done. 251 00:09:54,600 --> 00:09:55,640 It seems pretty basic, 252 00:09:55,700 --> 00:09:57,380 but once you have the ability to move things around, 253 00:09:57,580 --> 00:09:59,280 the code becomes more position independent 254 00:09:59,280 --> 00:10:01,780 and I can insert code everywhere I want. 255 00:10:01,880 --> 00:10:04,720 So I can weave in anti-reverse engineering code to that. 256 00:10:04,820 --> 00:10:08,580 I can make it also more difficult to reverse engineer 257 00:10:08,580 --> 00:10:11,080 because that's going to obscure the flow control of the program. 258 00:10:11,280 --> 00:10:11,460 All right. 259 00:10:13,020 --> 00:10:15,480 And one basic thing I just call scrambling. 260 00:10:15,600 --> 00:10:17,240 That's where the term PE scrambler comes from. 261 00:10:17,680 --> 00:10:18,820 So here's four functions 262 00:10:18,820 --> 00:10:21,220 and if I break them up into little relocatable sections, 263 00:10:21,560 --> 00:10:22,680 I just jumble them up. 264 00:10:22,860 --> 00:10:23,700 It's pretty simple. 265 00:10:24,380 --> 00:10:26,640 Now unfortunately, this isn't going to be enough. 266 00:10:26,780 --> 00:10:29,020 If you're looking at it in a static linear disassembler, 267 00:10:29,980 --> 00:10:31,640 this might kind of beat you for a while. 268 00:10:31,760 --> 00:10:32,880 It's like, what's going on? 269 00:10:33,080 --> 00:10:34,920 But IDA Pro with its graph mode 270 00:10:34,920 --> 00:10:37,020 is still going to reconstruct the functions appropriately. 271 00:10:37,280 --> 00:10:39,540 So this isn't quite good enough. 272 00:10:42,060 --> 00:10:42,600 All right. 273 00:10:45,940 --> 00:10:48,640 So I mentioned the relocation technique with a simple jump, 274 00:10:48,820 --> 00:10:50,880 which is the programming equivalent of, like, GoTo 275 00:10:50,880 --> 00:10:53,020 if you guys are old, like, basic programmers. 276 00:10:54,960 --> 00:10:56,600 But there's other advanced things I can do. 277 00:10:56,720 --> 00:10:58,860 I can do things like find instructions 278 00:10:58,860 --> 00:11:01,040 that produce known conditional flags 279 00:11:01,040 --> 00:11:03,160 and I can put in a conditional jump, 280 00:11:03,720 --> 00:11:05,880 which to a human, we know that's basically unconditional. 281 00:11:06,220 --> 00:11:07,100 It's like, you know, 282 00:11:07,120 --> 00:11:09,080 if the moon is made out of cheese, go here. 283 00:11:10,000 --> 00:11:10,920 To a disassembler, 284 00:11:10,940 --> 00:11:12,600 it doesn't know that the moon is not made out of cheese. 285 00:11:13,020 --> 00:11:13,540 But we know. 286 00:11:14,980 --> 00:11:18,320 So let me start with the basic jump relocation, 287 00:11:18,380 --> 00:11:20,900 just in case you didn't quite catch that. 288 00:11:21,220 --> 00:11:24,300 So here we have a set of instructions on the left 289 00:11:24,300 --> 00:11:26,420 and how it's going to get translated by PE Scrambler 290 00:11:26,420 --> 00:11:26,840 on the right 291 00:11:26,840 --> 00:11:28,660 with basic jump relocation. 292 00:11:28,860 --> 00:11:29,880 So we have a call instruction, 293 00:11:30,200 --> 00:11:30,820 and then after that, 294 00:11:30,880 --> 00:11:31,720 I'm going to relocate everything 295 00:11:31,720 --> 00:11:33,020 from the test instruction down. 296 00:11:33,260 --> 00:11:35,380 So basically breaking this off into two sections. 297 00:11:35,880 --> 00:11:36,800 And it's just simple. 298 00:11:36,880 --> 00:11:38,900 I just replace the test instruction with a jump 299 00:11:38,900 --> 00:11:40,220 and everything I moved it, 300 00:11:40,260 --> 00:11:41,560 that it was pointing to, 301 00:11:41,700 --> 00:11:43,320 is moved to somewhere else in the file. 302 00:11:43,600 --> 00:11:45,440 This is basically position independent, 303 00:11:45,680 --> 00:11:46,880 so there's no real problems with this. 304 00:11:47,360 --> 00:11:48,920 But it's also pretty easy to detect. 305 00:11:49,220 --> 00:11:51,140 IDAPRO is going to show you basically what you see on the right 306 00:11:51,640 --> 00:11:53,480 where it's going to show you function chunks 307 00:11:53,480 --> 00:11:54,900 and one just flows right into the other. 308 00:11:55,060 --> 00:11:56,620 No real advantage to doing this 309 00:11:57,040 --> 00:11:58,980 if you're looking in modern IDAPRO. 310 00:12:00,880 --> 00:12:02,400 But IDAPRO isn't very good at these 311 00:12:02,400 --> 00:12:04,580 known conditional stuff like I was talking about. 312 00:12:04,700 --> 00:12:05,940 So the whole idea here is we're going to find 313 00:12:06,380 --> 00:12:08,880 a flag and substitute a conditional jump 314 00:12:08,900 --> 00:12:11,320 I can also later on insert conditionals 315 00:12:11,320 --> 00:12:12,540 which are kind of fake. 316 00:12:13,460 --> 00:12:14,900 So here's a fake conditional jump. 317 00:12:15,120 --> 00:12:16,980 I'm going to target here the XOR instruction. 318 00:12:17,340 --> 00:12:18,800 So XOR, EAX, EAX. 319 00:12:18,960 --> 00:12:20,440 That sets EAX to zero. 320 00:12:20,840 --> 00:12:23,300 Since it's zero, the zero flag is going to be set. 321 00:12:23,660 --> 00:12:24,720 And then I do a jump. 322 00:12:24,980 --> 00:12:27,100 JZ, that means jump if the zero flag is set. 323 00:12:27,600 --> 00:12:28,660 So to us, 324 00:12:28,680 --> 00:12:29,900 we know that the zero flag is set. 325 00:12:30,020 --> 00:12:32,080 I can tell you the zero flag will always be set 326 00:12:32,080 --> 00:12:33,160 at that point in the program. 327 00:12:33,620 --> 00:12:34,800 The disassembler doesn't know. 328 00:12:35,220 --> 00:12:38,320 So it thinks that other stuff can happen. 329 00:12:38,900 --> 00:12:39,600 I have a point right here 330 00:12:39,600 --> 00:12:40,920 where I say fake code right here. 331 00:12:41,220 --> 00:12:42,380 We'll get into that in a second. 332 00:12:42,540 --> 00:12:45,920 But this is a completely unconditional jump in reality. 333 00:12:49,620 --> 00:12:51,460 We can also insert some fake conditionals 334 00:12:51,460 --> 00:12:52,260 like I was mentioning 335 00:12:52,260 --> 00:12:54,480 to kind of trip up the automated analysis process. 336 00:12:55,860 --> 00:12:57,000 Things that the human knows. 337 00:12:57,460 --> 00:12:57,940 So right here. 338 00:12:58,120 --> 00:12:59,480 In most Windows processes, 339 00:13:00,340 --> 00:13:01,660 this is pretty ridiculous, 340 00:13:01,760 --> 00:13:05,720 you'll never see ESP being 80000 or greater. 341 00:13:05,920 --> 00:13:07,060 I mean, that's absolutely insane. 342 00:13:07,400 --> 00:13:08,880 So I could say, 343 00:13:08,900 --> 00:13:10,060 I can insert an instruction right here 344 00:13:10,060 --> 00:13:11,500 that says compare ESP with that 345 00:13:11,500 --> 00:13:13,340 and then jump if less than or equal to. 346 00:13:13,920 --> 00:13:15,640 So that's basically an unconditional jump 347 00:13:15,640 --> 00:13:16,600 in the Windows process. 348 00:13:17,800 --> 00:13:19,440 A disassembler, there's no way a disassembler 349 00:13:19,440 --> 00:13:19,940 is going to know that. 350 00:13:19,980 --> 00:13:21,920 It's not going to keep track of what ESP should be, 351 00:13:22,000 --> 00:13:23,680 what are reasonable values or not. 352 00:13:23,820 --> 00:13:25,260 It simply doesn't have that level of intelligence. 353 00:13:25,640 --> 00:13:26,760 But we as humans do. 354 00:13:27,100 --> 00:13:29,180 Well, some of us do. 355 00:13:30,080 --> 00:13:30,660 Just kidding. 356 00:13:34,500 --> 00:13:35,860 Alright, so the whole point 357 00:13:35,860 --> 00:13:37,300 of doing these fake conditionals 358 00:13:37,300 --> 00:13:37,800 and everything like that 359 00:13:37,800 --> 00:13:39,080 and trying to trip up with fake conditionals 360 00:13:39,080 --> 00:13:41,600 is to produce conflicting sets of disassembly. 361 00:13:41,700 --> 00:13:43,480 This is how you defeat a disassembler. 362 00:13:43,920 --> 00:13:45,840 So most disassemblers, 363 00:13:45,880 --> 00:13:47,240 when they come to a conditional branch, 364 00:13:47,620 --> 00:13:49,040 they trust the false branch first 365 00:13:49,040 --> 00:13:51,100 because they disassemble the false branch first. 366 00:13:51,380 --> 00:13:52,700 Whatever they disassemble first, 367 00:13:52,840 --> 00:13:53,660 they trust the most. 368 00:13:53,940 --> 00:13:55,440 So what we want to do is basically 369 00:13:55,440 --> 00:13:57,860 get the false branch executing wrong code 370 00:13:57,860 --> 00:14:00,200 and have that truth branch executing 371 00:14:00,200 --> 00:14:03,080 from a slightly different offset so that it actually doesn't match up. 372 00:14:06,020 --> 00:14:07,400 Truth branch, it's like, 373 00:14:07,500 --> 00:14:08,700 well, I already have instructions here, 374 00:14:08,820 --> 00:14:10,140 I'm good to go, I'm going to bail. 375 00:14:13,140 --> 00:14:14,140 So here's an example. 376 00:14:14,380 --> 00:14:15,680 We have three instructions, 377 00:14:15,880 --> 00:14:16,940 a push, a move, and an XOR 378 00:14:16,940 --> 00:14:17,920 that take up five bytes. 379 00:14:18,420 --> 00:14:20,200 If you start at the 5-5, 380 00:14:20,320 --> 00:14:22,220 they produce that exact set of instructions. 381 00:14:22,560 --> 00:14:23,700 If for whatever reason, 382 00:14:23,800 --> 00:14:25,660 the disassembler started one byte earlier 383 00:14:25,660 --> 00:14:27,100 and we planted an E8, 384 00:14:27,380 --> 00:14:30,140 then it's going to disassemble a call instruction. 385 00:14:31,100 --> 00:14:32,020 It's pretty basic, 386 00:14:32,120 --> 00:14:34,380 and the disassembler's never going to go back 387 00:14:35,860 --> 00:14:37,060 to overlapping instructions. 388 00:14:37,440 --> 00:14:38,080 They just don't. 389 00:14:44,320 --> 00:14:45,280 So what we do here, 390 00:14:45,400 --> 00:14:47,540 like with these false conditionals that I was mentioning, 391 00:14:47,700 --> 00:14:49,920 we have the truth branch point one byte in, 392 00:14:50,000 --> 00:14:51,540 then we have the false branch point 393 00:14:51,540 --> 00:14:53,040 to one byte before, so 394 00:14:53,900 --> 00:14:55,720 if it's doing that false branch first 395 00:14:55,720 --> 00:14:57,380 like I mentioned, it's going to actually 396 00:14:57,380 --> 00:14:59,920 disassemble the exact wrong instruction. 397 00:15:00,280 --> 00:15:01,960 So the truth branch is going to be hidden, 398 00:15:02,100 --> 00:15:02,460 essentially. 399 00:15:03,600 --> 00:15:05,840 And like I said, since we have the ability to move 400 00:15:05,860 --> 00:15:07,240 around sections of code 401 00:15:07,800 --> 00:15:09,080 and change the size of things, 402 00:15:09,200 --> 00:15:11,560 I have the ability to add these type of little nuggets 403 00:15:11,560 --> 00:15:12,940 in there all throughout the program 404 00:15:12,940 --> 00:15:15,160 because I have free reign to add code as needed. 405 00:15:17,580 --> 00:15:19,680 So now we're going to get into some 406 00:15:19,680 --> 00:15:20,780 impossible disassembly. 407 00:15:20,960 --> 00:15:22,760 This is a common one, it's fairly well known. 408 00:15:22,980 --> 00:15:24,780 We have a jump instruction, which is two bytes. 409 00:15:25,400 --> 00:15:25,800 Oops. 410 00:15:26,700 --> 00:15:28,860 Jump actually jumps from the end of the instruction, 411 00:15:29,040 --> 00:15:30,500 so the argument here is negative one. 412 00:15:30,820 --> 00:15:32,560 So it's actually going to jump into itself, 413 00:15:33,220 --> 00:15:34,320 which seems kind of ridiculous. 414 00:15:35,860 --> 00:15:37,320 It executes perfectly, so it jumps into itself, 415 00:15:37,520 --> 00:15:39,660 and then starting at the second byte of itself, 416 00:15:39,900 --> 00:15:41,480 the instruction it disassembles is 417 00:15:41,480 --> 00:15:44,640 increment EAX, then decrement EAX. 418 00:15:44,760 --> 00:15:45,740 This is kind of like a no-op, 419 00:15:45,880 --> 00:15:48,020 but a no-op that will fool a disassembler. 420 00:15:49,880 --> 00:15:52,020 Alright, moving on, I've come up with a lot of these 421 00:15:52,020 --> 00:15:53,120 over the years. 422 00:15:53,320 --> 00:15:54,640 They're kind of fun, it's like a puzzle. 423 00:15:54,780 --> 00:15:57,540 How do you completely ruin a disassembler for life? 424 00:15:58,340 --> 00:15:59,280 So here's another one. 425 00:16:00,020 --> 00:16:01,900 A move instruction, XOR, 426 00:16:02,020 --> 00:16:03,620 and then a jump, zero to negative seven. 427 00:16:03,840 --> 00:16:05,660 So I'm going to show you the flow of how this actually goes. 428 00:16:05,860 --> 00:16:08,300 So going from the end of the jump of zero instruction, 429 00:16:09,000 --> 00:16:10,400 it actually points back here 430 00:16:10,400 --> 00:16:11,840 to the second instruction. 431 00:16:12,100 --> 00:16:13,480 And if you look at what that actually is, 432 00:16:13,540 --> 00:16:14,520 it's part of that move instruction. 433 00:16:15,180 --> 00:16:18,040 So it's actually the operand to the move instruction. 434 00:16:18,780 --> 00:16:19,700 And what is that? 435 00:16:19,780 --> 00:16:20,700 It's a jump at five. 436 00:16:21,640 --> 00:16:22,640 It jumps to right there. 437 00:16:23,340 --> 00:16:25,780 So notice the jump of zero to negative seven. 438 00:16:25,980 --> 00:16:27,460 I said on a conditional, 439 00:16:27,680 --> 00:16:29,000 it takes the false branch first. 440 00:16:29,200 --> 00:16:31,120 The false branch I planted in E8. 441 00:16:31,400 --> 00:16:33,360 So it's going to disassemble that stuff 442 00:16:33,360 --> 00:16:34,080 as a call instruction. 443 00:16:35,860 --> 00:16:36,620 The false branch is going to produce 444 00:16:36,620 --> 00:16:38,140 a completely different set of disassembly. 445 00:16:38,760 --> 00:16:40,560 You're jumping to embedded instructions 446 00:16:40,560 --> 00:16:42,080 within embedded instructions. 447 00:16:42,300 --> 00:16:43,940 I don't think a disassembler is going to get this. 448 00:16:44,420 --> 00:16:46,060 You guys might have a disassembly that will. 449 00:16:46,200 --> 00:16:46,820 I don't. 450 00:16:50,060 --> 00:16:51,720 Then we can get into polymorphic replacement. 451 00:16:52,420 --> 00:16:54,260 This isn't going to be as advanced 452 00:16:54,260 --> 00:16:55,960 as some of the viruses and whatnot out there, 453 00:16:56,060 --> 00:16:57,480 but even at a basic level, 454 00:16:57,620 --> 00:17:00,160 this can be pretty mean for signature detection. 455 00:17:01,180 --> 00:17:02,180 So what I'm going to do is 456 00:17:02,180 --> 00:17:04,480 seek out small little clusters of instructions 457 00:17:04,480 --> 00:17:05,460 that I can replace 458 00:17:05,860 --> 00:17:06,500 with equivalent instructions, 459 00:17:07,160 --> 00:17:08,220 and just do it. 460 00:17:08,360 --> 00:17:09,580 I didn't have the ability to do this 461 00:17:09,580 --> 00:17:11,620 until we had the ability to break apart the binary, 462 00:17:12,180 --> 00:17:14,160 which allowed us to add more code as needed. 463 00:17:16,180 --> 00:17:18,580 And also these types of polymorphic replacements 464 00:17:18,580 --> 00:17:19,240 can be randomized. 465 00:17:20,140 --> 00:17:22,460 So basically, given an original binary, 466 00:17:22,700 --> 00:17:23,740 every time I run this tool, 467 00:17:24,600 --> 00:17:26,380 I could essentially randomize the binary, 468 00:17:26,580 --> 00:17:27,300 the compiled code, 469 00:17:27,480 --> 00:17:28,480 which is pretty neat. 470 00:17:34,160 --> 00:17:35,160 So here's a few of them. 471 00:17:35,860 --> 00:17:37,600 I have a push instruction, which is really simple. 472 00:17:37,780 --> 00:17:38,900 Push modifies the stack. 473 00:17:39,000 --> 00:17:40,160 It puts a variable on the stack. 474 00:17:40,340 --> 00:17:42,620 I can do that with an equivalent set of subtraction 475 00:17:42,620 --> 00:17:44,520 as well as a move relative to the stack. 476 00:17:44,740 --> 00:17:46,740 So I manually adjust the stack pointer, 477 00:17:46,820 --> 00:17:48,400 and then I manually move data onto it. 478 00:17:48,540 --> 00:17:49,640 It's the same thing as a push. 479 00:17:50,680 --> 00:17:51,520 Same thing with call. 480 00:17:51,900 --> 00:17:53,060 Call is just like a jump, 481 00:17:53,160 --> 00:17:55,000 only it puts that return pointer on the stack. 482 00:17:55,240 --> 00:17:57,260 So I can manually put the return pointer on the stack 483 00:17:57,260 --> 00:17:58,000 and then do a jump. 484 00:17:58,640 --> 00:17:59,280 Fairly simple. 485 00:17:59,860 --> 00:18:00,660 You get the idea. 486 00:18:05,860 --> 00:18:08,080 It's basically inserting useless deadbeat instructions. 487 00:18:08,480 --> 00:18:09,740 So I push something on the stack 488 00:18:09,740 --> 00:18:10,540 and then I remove it. 489 00:18:11,060 --> 00:18:12,540 I subtract from the stack pointer. 490 00:18:12,960 --> 00:18:14,140 It's completely useless code. 491 00:18:15,460 --> 00:18:17,020 But if you had an antivirus or something 492 00:18:17,020 --> 00:18:18,920 that had a signature for a sequence of instructions 493 00:18:18,920 --> 00:18:21,200 and you added code in between it, 494 00:18:21,280 --> 00:18:22,320 the signature's broken. 495 00:18:24,240 --> 00:18:25,920 One thing that most compilers do 496 00:18:25,920 --> 00:18:27,900 is this is what the first thing on the top 497 00:18:27,900 --> 00:18:29,460 is called the function prolog. 498 00:18:30,420 --> 00:18:31,880 It sets up the stack frame, 499 00:18:32,580 --> 00:18:33,400 that kind of thing. 500 00:18:33,580 --> 00:18:35,840 You can do this with one instruction, but most compilers don't. 501 00:18:35,860 --> 00:18:36,620 For efficiency. 502 00:18:37,340 --> 00:18:39,340 So I can actually find the function prologs 503 00:18:39,340 --> 00:18:41,000 and almost every function replace them with like enter. 504 00:18:41,260 --> 00:18:43,040 Or there's any number of ways you can imagine 505 00:18:43,040 --> 00:18:43,980 to set up a stack frame, 506 00:18:44,100 --> 00:18:47,000 which can be easily substituted based on disassembly. 507 00:18:47,740 --> 00:18:48,460 Jump instructions. 508 00:18:49,120 --> 00:18:50,820 All the return instruction is 509 00:18:50,820 --> 00:18:52,720 is it takes the value off the stack and jumps to it. 510 00:18:53,020 --> 00:18:55,480 So I can substitute a jump for a push and a return 511 00:18:55,840 --> 00:18:56,480 pretty easy. 512 00:18:56,980 --> 00:18:58,660 As you can kind of see where I'm going with this, 513 00:18:58,720 --> 00:18:59,640 there's any number of instructions 514 00:18:59,640 --> 00:19:01,560 which have any number of equivalent mappings. 515 00:19:02,220 --> 00:19:03,740 There's a lot that can go on here. 516 00:19:05,860 --> 00:19:07,720 I can actually substitute a logical comparison 517 00:19:07,720 --> 00:19:09,140 with an equivalent one. 518 00:19:10,020 --> 00:19:12,580 Let me show you an example of this tool. 519 00:19:20,600 --> 00:19:24,060 It's only on the screen, 520 00:19:24,200 --> 00:19:25,940 so you have to trust my typing. 521 00:19:26,820 --> 00:19:28,420 In this directory, 522 00:19:28,560 --> 00:19:30,140 I have PEScrambler.exe 523 00:19:30,140 --> 00:19:32,220 and I have Notepad.exe. 524 00:19:34,880 --> 00:19:35,840 PEScrambler.exe 525 00:19:35,860 --> 00:19:37,020 I run it, 526 00:19:37,080 --> 00:19:38,880 get the command line options there. 527 00:19:39,060 --> 00:19:41,900 It just takes a dash i input file, dash o output file. 528 00:19:42,120 --> 00:19:43,180 There's really nothing to it. 529 00:19:44,900 --> 00:19:45,340 So, 530 00:19:46,440 --> 00:19:47,160 let's specify, 531 00:19:47,460 --> 00:19:47,880 oops, 532 00:19:48,900 --> 00:19:50,300 dash i Notepad, 533 00:19:50,880 --> 00:19:53,300 dash o new Notepad. 534 00:19:56,980 --> 00:19:57,620 And it runs 535 00:19:57,620 --> 00:19:58,840 so you see the list of things it does. 536 00:19:59,740 --> 00:20:01,220 Disassembling, generating cross references, 537 00:20:01,460 --> 00:20:02,520 remapping call instructions, 538 00:20:03,700 --> 00:20:04,360 armoring code. 539 00:20:04,600 --> 00:20:05,840 That's all the other things we talked about. 540 00:20:06,320 --> 00:20:07,740 And now that should work. 541 00:20:09,220 --> 00:20:11,020 Oh, let me get a directory listing here. 542 00:20:12,040 --> 00:20:13,060 In the directory listing, 543 00:20:13,180 --> 00:20:14,220 you can actually see that it actually 544 00:20:14,220 --> 00:20:16,740 added about 30k to the binary, 545 00:20:16,860 --> 00:20:17,740 so it's actually much bigger. 546 00:20:23,580 --> 00:20:24,420 Tab over. 547 00:20:27,040 --> 00:20:28,220 It blacked my screen. 548 00:20:30,860 --> 00:20:31,300 Yeah. 549 00:20:33,420 --> 00:20:33,960 Hold on. 550 00:20:42,300 --> 00:20:43,520 My screen is black. 551 00:20:43,640 --> 00:20:44,700 I don't know what's going on. 552 00:20:46,120 --> 00:20:47,700 Anyway, you have to trust me, it did. 553 00:20:56,840 --> 00:20:57,640 Hold on. 554 00:21:01,420 --> 00:21:02,060 There we go. 555 00:21:04,660 --> 00:21:05,360 Bear with me. 556 00:21:06,620 --> 00:21:06,940 Yeah. 557 00:21:07,500 --> 00:21:07,940 All right. 558 00:21:08,360 --> 00:21:09,680 So there is Notepad launching, 559 00:21:10,120 --> 00:21:10,680 right there. 560 00:21:11,220 --> 00:21:13,080 That's the actual new modified Notepad 561 00:21:13,080 --> 00:21:13,720 that we were playing with. 562 00:21:14,600 --> 00:21:16,320 Just to show you that it actually does work and everything. 563 00:21:16,920 --> 00:21:18,200 I don't know what's going on with my laptop. 564 00:21:18,460 --> 00:21:20,480 It's been a pretty solid laptop up until now. 565 00:21:22,440 --> 00:21:24,040 Let's take a look at these in disassembly. 566 00:21:24,120 --> 00:21:26,340 I can show you some of the things 567 00:21:26,340 --> 00:21:26,800 that are going on here. 568 00:21:26,860 --> 00:21:28,100 Here's the original Notepad. 569 00:21:28,100 --> 00:21:30,580 This is before I modified it in IDA. 570 00:21:31,000 --> 00:21:33,140 You can see IDA shows you a nice graph 571 00:21:33,140 --> 00:21:34,700 of all the instructions and all that. 572 00:21:34,900 --> 00:21:36,240 The main thing I want you to look at here 573 00:21:36,240 --> 00:21:36,840 is the actual, 574 00:21:37,060 --> 00:21:38,740 this is basically the map of the binary. 575 00:21:39,020 --> 00:21:39,980 Blue means code. 576 00:21:40,220 --> 00:21:41,020 Gray means data. 577 00:21:41,180 --> 00:21:41,920 That's all you need to know. 578 00:21:43,360 --> 00:21:45,580 Now let's take a look at the PEScrambled binary. 579 00:21:48,200 --> 00:21:49,180 Take a look at the column, 580 00:21:49,280 --> 00:21:51,100 the map up there. 581 00:21:51,680 --> 00:21:53,120 Not quite the same, is it? 582 00:21:54,060 --> 00:21:54,460 Yeah. 583 00:21:55,340 --> 00:21:56,200 Here's what I was talking about 584 00:21:56,200 --> 00:21:57,320 with the function called chunking. 585 00:21:57,560 --> 00:21:59,500 You can see it's actually translated what we had 586 00:21:59,500 --> 00:22:01,480 into just a series of these little jumps and whatnot. 587 00:22:02,860 --> 00:22:04,000 We can still kind of get some 588 00:22:04,620 --> 00:22:05,420 logic here going. 589 00:22:10,060 --> 00:22:11,500 This call instruction right here, 590 00:22:11,580 --> 00:22:13,120 this is the actual function called Dispatcher. 591 00:22:14,100 --> 00:22:15,560 You can read through the logic if you want. 592 00:22:15,640 --> 00:22:16,840 I'm not going to spend much time on it. 593 00:22:25,900 --> 00:22:26,540 Crossreference 2. 594 00:22:26,680 --> 00:22:27,760 We're going to get a nice little map. 595 00:22:29,260 --> 00:22:30,800 This is every function that's calling 596 00:22:30,800 --> 00:22:32,580 our little function called Dispatcher. 597 00:22:32,780 --> 00:22:33,480 And as you zoom in, 598 00:22:33,960 --> 00:22:35,520 you're going to find it's quite flat. 599 00:22:36,000 --> 00:22:38,820 Every single call instruction in the entire binary 600 00:22:38,820 --> 00:22:40,040 is calling the same thing. 601 00:22:40,580 --> 00:22:42,580 Oh, and that's not the whole story. 602 00:22:43,700 --> 00:22:45,020 Let's do the equivalent. 603 00:22:45,260 --> 00:22:46,380 Open subviews. 604 00:22:47,720 --> 00:22:48,160 Trackpad. 605 00:22:50,500 --> 00:22:50,940 Graphs. 606 00:22:53,000 --> 00:22:53,820 Crossreference is from. 607 00:22:54,460 --> 00:22:55,960 Anybody have any ideas on what this is going to do? 608 00:22:57,560 --> 00:22:58,760 If you guessed jack shit, 609 00:22:58,960 --> 00:22:59,740 you got it right. 610 00:23:03,220 --> 00:23:04,920 The reason is IDA doesn't know exactly 611 00:23:04,920 --> 00:23:06,380 how my function called Dispatcher works, 612 00:23:06,460 --> 00:23:07,740 so it doesn't know that this thing 613 00:23:07,740 --> 00:23:10,580 actually calls every other function call 614 00:23:10,580 --> 00:23:11,720 in the whole binary. 615 00:23:12,380 --> 00:23:13,680 You could reverse engineer this, 616 00:23:13,740 --> 00:23:14,720 figure out how it works and all that. 617 00:23:14,860 --> 00:23:15,420 It's pretty simple. 618 00:23:15,500 --> 00:23:16,280 Just a little bit of shell code. 619 00:23:18,820 --> 00:23:20,020 Some other cool bits. 620 00:23:23,580 --> 00:23:24,320 That's pretty much it. 621 00:23:24,460 --> 00:23:26,300 Let me show you what a normal call graph 622 00:23:26,300 --> 00:23:27,400 looks like in a normal program, 623 00:23:27,500 --> 00:23:28,400 in case you haven't seen it. 624 00:23:30,740 --> 00:23:32,540 I'm going to go up here to the top. 625 00:23:33,940 --> 00:23:34,300 Graphs. 626 00:23:36,900 --> 00:23:37,460 Function calls. 627 00:23:37,720 --> 00:23:39,860 Here's a normal call graph of an entire program. 628 00:23:40,040 --> 00:23:42,120 You can see, through reverse engineering, 629 00:23:42,240 --> 00:23:44,340 you can get inferences here. 630 00:23:44,500 --> 00:23:46,560 If I see a function that calls a bunch of registry functions, 631 00:23:46,800 --> 00:23:48,280 maybe that's something that does registry stuff. 632 00:23:48,580 --> 00:23:50,280 If I wax all this stuff with the function call 633 00:23:50,280 --> 00:23:51,880 redirector, it's good to go. 634 00:23:53,940 --> 00:23:54,440 Just a little bit more. 635 00:23:54,460 --> 00:23:56,500 Some ideas there on what's going on. 636 00:23:59,680 --> 00:24:00,520 Moving on. 637 00:24:04,980 --> 00:24:07,360 I don't need to go any further. 638 00:24:07,620 --> 00:24:08,820 I was just going to show you one more tool. 639 00:24:10,180 --> 00:24:10,440 Oh shit. 640 00:24:11,520 --> 00:24:12,600 We're way ahead of time. 641 00:24:15,460 --> 00:24:16,560 One other tool. 642 00:24:17,200 --> 00:24:18,720 Let me get this back to the top. 643 00:24:21,440 --> 00:24:21,860 FindEvil. 644 00:24:23,420 --> 00:24:24,360 I have a tool here. 645 00:24:24,460 --> 00:24:25,100 It's a GUI. 646 00:24:25,680 --> 00:24:27,160 I'm going to try to launch another GUI. 647 00:24:31,800 --> 00:24:33,100 I did it again. 648 00:24:38,300 --> 00:24:39,340 It's completely black. 649 00:24:39,840 --> 00:24:40,440 Damn it. 650 00:24:43,080 --> 00:24:44,240 How FindEvil works. 651 00:24:44,520 --> 00:24:45,720 I'm going to talk about what was in the slides. 652 00:24:45,980 --> 00:24:47,700 How FindEvil actually works is 653 00:24:47,700 --> 00:24:48,740 I disassemble a binary. 654 00:24:50,040 --> 00:24:51,360 Based on disassembly, 655 00:24:51,360 --> 00:24:53,820 I know how many instructions were legitimate. 656 00:24:54,340 --> 00:24:56,440 My disassembler is very pessimistic, 657 00:24:56,500 --> 00:24:57,500 so it doesn't trust anything 658 00:24:57,500 --> 00:24:59,480 that it doesn't absolutely think is code. 659 00:25:00,320 --> 00:25:01,620 If there's any anti-disassembly tricks 660 00:25:01,620 --> 00:25:02,420 like what I've shown you, 661 00:25:03,300 --> 00:25:04,420 it completely fakes it out. 662 00:25:05,120 --> 00:25:07,220 It won't disassemble very much code at all. 663 00:25:11,280 --> 00:25:13,980 What I do here for this defined malware 664 00:25:13,980 --> 00:25:15,640 is I'm going to disassemble every binary 665 00:25:15,640 --> 00:25:16,300 on the system. 666 00:25:16,480 --> 00:25:18,200 You just try to go malware hunting. 667 00:25:18,200 --> 00:25:19,500 Disassemble every binary 668 00:25:19,500 --> 00:25:22,280 and see which ones don't have very many instructions 669 00:25:22,280 --> 00:25:23,440 that I was able to disassemble. 670 00:25:23,660 --> 00:25:24,800 Typically in a large binary, 671 00:25:24,920 --> 00:25:27,180 I should have a whole bunch of instructions 672 00:25:27,180 --> 00:25:28,500 that were able to be disassembled. 673 00:25:28,560 --> 00:25:29,740 Whereas packed binaries, 674 00:25:29,900 --> 00:25:31,520 I'm only going to disassemble maybe a little bit 675 00:25:31,520 --> 00:25:34,800 of the unpacker stub. 676 00:25:44,980 --> 00:25:45,960 There we go. 677 00:25:49,820 --> 00:25:50,800 Okay, here's FindEvil. 678 00:25:51,980 --> 00:25:52,580 No applause. 679 00:25:53,580 --> 00:25:54,200 Oh, shit. 680 00:25:56,920 --> 00:25:58,000 Now I'm up over here, 681 00:25:58,060 --> 00:25:58,920 but you're not up over there. 682 00:26:01,940 --> 00:26:02,540 Coming up. 683 00:26:02,800 --> 00:26:03,300 Coming up. 684 00:26:04,620 --> 00:26:05,120 There we go. 685 00:26:06,320 --> 00:26:06,620 Hooray. 686 00:26:09,940 --> 00:26:11,400 See, I saw that I'm running a little quickly, 687 00:26:11,500 --> 00:26:13,160 so I'm purposely doing this to stall. 688 00:26:14,900 --> 00:26:15,960 Okay, so here's FindEvil. 689 00:26:17,260 --> 00:26:17,940 I would just do 690 00:26:18,840 --> 00:26:19,240 scan. 691 00:26:19,540 --> 00:26:20,960 If you've ever used the other tool I wrote 692 00:26:20,960 --> 00:26:21,700 called RedCurtain, 693 00:26:22,220 --> 00:26:23,900 the interface may seem a little familiar, 694 00:26:24,020 --> 00:26:25,880 but vastly different technologies underneath. 695 00:26:26,340 --> 00:26:27,760 RedCurtain did entropy analysis 696 00:26:27,760 --> 00:26:29,440 on all the binaries to try to find 697 00:26:31,000 --> 00:26:32,800 binaries that had a lot of random data in them, 698 00:26:32,940 --> 00:26:34,640 which means usually compressed data, 699 00:26:35,120 --> 00:26:36,940 which can be used to detect packers. 700 00:26:36,980 --> 00:26:38,020 The problem with RedCurtain, though, 701 00:26:38,080 --> 00:26:40,400 is you got a lot of false negatives on some packers. 702 00:26:40,460 --> 00:26:43,480 If they had really weak compression 703 00:26:43,480 --> 00:26:44,760 or they didn't do compression, 704 00:26:44,900 --> 00:26:46,860 they just XORed, the entropy score 705 00:26:48,200 --> 00:26:48,280 would be low. 706 00:26:48,380 --> 00:26:50,100 So I didn't want something that's going to give me 707 00:26:50,100 --> 00:26:51,360 false negatives on a packer. 708 00:26:51,740 --> 00:26:53,880 And this technique, I've never found a false negative. 709 00:26:55,820 --> 00:26:57,000 So just throwing that out there. 710 00:26:57,380 --> 00:26:58,040 I'm going to... 711 00:26:58,860 --> 00:27:01,780 I'm going to scan just a little demo folder 712 00:27:01,780 --> 00:27:03,040 I have with some malware in it. 713 00:27:03,980 --> 00:27:04,560 FindEvil malware. 714 00:27:06,680 --> 00:27:07,360 It scans. 715 00:27:08,240 --> 00:27:10,140 If you notice, that actually disassembled pretty quick. 716 00:27:10,520 --> 00:27:12,180 If you ever loaded a binary in IDA Pro, 717 00:27:12,440 --> 00:27:13,720 it takes a while to disassemble. 718 00:27:14,640 --> 00:27:15,680 I go much faster. 719 00:27:15,880 --> 00:27:17,300 One of the reasons I go much faster is, 720 00:27:18,200 --> 00:27:19,840 I just capped the disassembly at 10K. 721 00:27:20,200 --> 00:27:21,400 So once I've hit 10K, 722 00:27:21,500 --> 00:27:22,920 I'm assuming I'm probably not packed. 723 00:27:23,800 --> 00:27:24,400 I bail. 724 00:27:25,240 --> 00:27:26,300 So what we see here... 725 00:27:26,300 --> 00:27:27,540 The main column I want you to look at 726 00:27:27,540 --> 00:27:28,900 is code to disassembly ratio, 727 00:27:29,200 --> 00:27:30,700 even though it's kind of fuzzy on that screen. 728 00:27:32,520 --> 00:27:35,100 If it detected there's not enough instructions 729 00:27:35,100 --> 00:27:37,500 for the size of the sections that are marked code, 730 00:27:37,760 --> 00:27:38,720 I'm going to flag that. 731 00:27:38,900 --> 00:27:39,980 If I detected... 732 00:27:40,420 --> 00:27:42,280 If it disassembled 10K or more, 733 00:27:42,380 --> 00:27:44,080 I just mark it as green and you can move on. 734 00:27:44,840 --> 00:27:46,140 So that's the main field. 735 00:27:46,300 --> 00:27:48,120 And I've never seen a truly packed binary 736 00:27:48,120 --> 00:27:51,640 that actually did not score red in that column. 737 00:27:52,640 --> 00:27:53,660 There's also a yellow field, 738 00:27:53,800 --> 00:27:54,600 but it's a little bit more rare. 739 00:27:55,080 --> 00:27:57,400 There's some other columns in here of interest 740 00:27:57,400 --> 00:27:59,380 in case, for whatever reason, 741 00:27:59,400 --> 00:28:00,280 that didn't quite work right. 742 00:28:00,600 --> 00:28:01,320 File to code. 743 00:28:01,480 --> 00:28:03,080 So if I have a really small file, 744 00:28:03,480 --> 00:28:06,480 and then I go through the PE file format 745 00:28:06,480 --> 00:28:07,800 and I see that actually, 746 00:28:07,960 --> 00:28:08,980 when the thing's in memory, 747 00:28:08,980 --> 00:28:11,260 there should be a whole lot more code, 748 00:28:11,480 --> 00:28:12,200 that kind of 749 00:28:13,140 --> 00:28:14,500 keys me off to the fact that maybe 750 00:28:14,500 --> 00:28:16,560 it's actually compressed in the file 751 00:28:16,560 --> 00:28:18,280 and it's going to be uncompressed in memory. 752 00:28:18,520 --> 00:28:19,480 So I flag that. 753 00:28:19,640 --> 00:28:21,740 That's also a pretty dang good indicator. 754 00:28:23,060 --> 00:28:24,880 I've never seen a false positive on that one either. 755 00:28:25,400 --> 00:28:26,340 Some of the other columns, 756 00:28:27,120 --> 00:28:28,320 you can take your pick. 757 00:28:29,240 --> 00:28:30,680 But this is a good way, 758 00:28:30,800 --> 00:28:32,460 if you have a hard drive or whatever, 759 00:28:32,660 --> 00:28:34,220 you can just run this tool against it 760 00:28:34,220 --> 00:28:36,140 and if there is a packed binary on there, 761 00:28:36,200 --> 00:28:36,960 it will be red. 762 00:28:38,980 --> 00:28:40,620 So this only has the problem of 763 00:28:40,620 --> 00:28:42,040 a few false positives maybe, 764 00:28:42,160 --> 00:28:43,800 but no false negatives that I know of. 765 00:28:45,140 --> 00:28:46,720 And both of these are available 766 00:28:46,720 --> 00:28:49,220 on the website. 767 00:28:49,380 --> 00:28:51,420 Let me skip to the end. 768 00:29:06,520 --> 00:29:07,000 So, 769 00:29:08,980 --> 00:29:10,280 source code is not currently available. 770 00:29:12,640 --> 00:29:13,080 Yeah. 771 00:29:14,380 --> 00:29:16,160 Truth be told, my company might 772 00:29:16,780 --> 00:29:18,840 take action on me 773 00:29:18,840 --> 00:29:20,360 for even releasing the binary. 774 00:29:20,520 --> 00:29:22,240 They seriously did not like it. 775 00:29:22,900 --> 00:29:24,800 But I did develop this 776 00:29:24,800 --> 00:29:25,880 completely on my own time. 777 00:29:26,120 --> 00:29:28,000 No company affiliation officially. 778 00:29:28,580 --> 00:29:29,740 Slides don't say my company. 779 00:29:30,580 --> 00:29:31,520 We'll see what happens. 780 00:29:31,680 --> 00:29:32,660 I like to put stuff out there. 781 00:29:33,020 --> 00:29:34,600 You might see code, you might not. 782 00:29:34,840 --> 00:29:35,760 Don't hold your breath. 783 00:29:39,320 --> 00:29:40,600 That is not an M. 784 00:29:40,660 --> 00:29:41,260 That is an RN. 785 00:29:41,440 --> 00:29:44,580 So it's all up there. 786 00:29:44,800 --> 00:29:46,420 And thanks a lot. 787 00:29:46,580 --> 00:29:47,320 Does anybody have any questions? 788 00:29:48,560 --> 00:29:49,640 Are you in the blue? 789 00:29:53,800 --> 00:29:58,800 It's just the Shannon entropy curve. 790 00:29:58,920 --> 00:30:00,320 So we go through the binary, 791 00:30:00,360 --> 00:30:02,180 find every section that's marked as code 792 00:30:02,180 --> 00:30:04,760 in the image count code characteristic 793 00:30:04,760 --> 00:30:06,440 and then do entropy on those. 794 00:30:08,040 --> 00:30:08,760 Next down here. 795 00:30:08,980 --> 00:30:09,940 Have you considered doing 796 00:30:09,940 --> 00:30:11,440 multiple dispatchers 797 00:30:11,440 --> 00:30:12,960 or maybe test any dispatchers 798 00:30:12,960 --> 00:30:15,220 or maybe having some logic 799 00:30:15,220 --> 00:30:16,920 that could map into the call graph 800 00:30:16,920 --> 00:30:18,480 of some other program? 801 00:30:19,040 --> 00:30:20,620 Yeah, interesting you mention that. 802 00:30:21,080 --> 00:30:23,640 Well, I haven't looked into multiple dispatchers 803 00:30:23,640 --> 00:30:25,800 because the one seems to do enough job. 804 00:30:25,980 --> 00:30:27,840 But with the function called dispatching, 805 00:30:28,000 --> 00:30:29,500 I'm looking into actually 806 00:30:29,500 --> 00:30:31,440 that's where I'm going to intercept things, 807 00:30:31,660 --> 00:30:34,260 maybe be able to change the functionality 808 00:30:34,260 --> 00:30:36,080 of any function that I want to remap 809 00:30:36,800 --> 00:30:38,480 or just wrap it around 810 00:30:38,980 --> 00:30:39,860 into anti-reverse engineering code, 811 00:30:40,060 --> 00:30:40,900 things like that. 812 00:30:41,020 --> 00:30:42,140 There's a lot of options you can do. 813 00:30:47,420 --> 00:30:48,200 Rescramble it twice? 814 00:30:49,900 --> 00:30:52,000 Not really because my disassembler 815 00:30:52,000 --> 00:30:52,900 is very pessimistic, 816 00:30:52,980 --> 00:30:54,680 so if there's any anti-reverse engineering tricks, 817 00:30:54,800 --> 00:30:55,660 it just shits the bed. 818 00:30:57,200 --> 00:30:58,440 I mean, it fails. 819 00:30:58,840 --> 00:31:01,840 So whenever I try to go to rescramble it, 820 00:31:01,920 --> 00:31:03,960 it's going to get like three bytes in 821 00:31:03,960 --> 00:31:05,860 and be like, dude, seriously. 822 00:31:13,940 --> 00:31:15,980 Yeah, so good point. 823 00:31:16,220 --> 00:31:17,820 The next tool I want to write is just, 824 00:31:17,900 --> 00:31:18,980 I don't know what it's going to be called, 825 00:31:19,080 --> 00:31:20,220 but based on my disassembly, 826 00:31:20,240 --> 00:31:21,660 I can find the most interesting strings 827 00:31:21,660 --> 00:31:22,800 and based on that, 828 00:31:22,840 --> 00:31:23,540 I'm going to look into ways 829 00:31:23,540 --> 00:31:26,460 to dynamically pack and unpack strings 830 00:31:26,460 --> 00:31:27,720 as needed based on, 831 00:31:27,800 --> 00:31:29,200 so weave that code right in 832 00:31:29,200 --> 00:31:30,940 instead of unpacking all the strings up front. 833 00:31:31,160 --> 00:31:32,940 It can be done with disassembly, 834 00:31:32,940 --> 00:31:33,200 I believe. 835 00:31:34,700 --> 00:31:35,960 So I think you've been in the back 836 00:31:35,960 --> 00:31:36,860 and had your hand up for a while. 837 00:31:40,900 --> 00:31:41,380 . 838 00:31:49,220 --> 00:31:50,800 I would like to say no comment, 839 00:31:50,900 --> 00:31:51,800 but yeah, 840 00:31:51,920 --> 00:31:54,300 I did want to do STAG with this 841 00:31:54,300 --> 00:31:55,960 and it can be done 842 00:31:55,960 --> 00:31:57,200 and it may be being done 843 00:31:57,200 --> 00:31:58,240 and maybe not. 844 00:32:00,660 --> 00:32:02,060 No official comment. 845 00:32:02,380 --> 00:32:03,480 Mandiant is not responsible 846 00:32:03,480 --> 00:32:04,740 for things said on the stage. 847 00:32:05,900 --> 00:32:06,660 Down here in front. 848 00:32:09,840 --> 00:32:10,240 . 849 00:32:10,240 --> 00:32:12,520 Oh, well, you saw Notepad running, right? 850 00:32:13,300 --> 00:32:14,580 I actually surprisingly, 851 00:32:14,700 --> 00:32:16,640 I thought with the function call dispatcher 852 00:32:16,640 --> 00:32:17,480 where I'm intercepting everything 853 00:32:17,480 --> 00:32:20,480 and adding tons of instructions 854 00:32:20,480 --> 00:32:21,540 and tons of loops and whatnot 855 00:32:21,540 --> 00:32:22,600 to every single function call, 856 00:32:22,680 --> 00:32:23,840 I thought it would be a lot slower. 857 00:32:24,480 --> 00:32:25,180 Surprisingly not. 858 00:32:25,980 --> 00:32:26,380 . 859 00:32:30,200 --> 00:32:30,740 . 860 00:32:30,740 --> 00:32:31,160 . 861 00:32:35,940 --> 00:32:36,480 . 862 00:32:36,480 --> 00:32:37,500 . 863 00:32:38,280 --> 00:32:38,820 . 864 00:32:38,820 --> 00:32:38,880 . 865 00:32:38,880 --> 00:32:38,920 . 866 00:32:38,920 --> 00:32:39,040 . 867 00:32:39,040 --> 00:32:39,060 . 868 00:32:39,060 --> 00:32:39,080 . 869 00:32:40,220 --> 00:32:41,320 . 870 00:32:44,620 --> 00:32:45,170 . 871 00:32:45,720 --> 00:32:45,980 . 872 00:32:45,980 --> 00:32:46,040 . 873 00:32:46,040 --> 00:32:46,880 . 874 00:32:46,880 --> 00:32:47,020 . 875 00:32:47,020 --> 00:32:48,020 . 876 00:32:48,020 --> 00:32:48,080 . 877 00:32:48,080 --> 00:32:48,120 . 878 00:32:48,120 --> 00:32:48,140 . 879 00:32:48,140 --> 00:32:49,980 . 880 00:32:49,980 --> 00:32:51,500 . 881 00:32:51,500 --> 00:32:52,180 . 882 00:32:57,780 --> 00:32:58,540 . 883 00:32:58,540 --> 00:32:58,580 . 884 00:32:58,580 --> 00:32:58,700 . 885 00:32:58,700 --> 00:32:59,140 . 886 00:32:59,140 --> 00:32:59,460 . 887 00:32:59,460 --> 00:32:59,900 . 888 00:32:59,900 --> 00:33:00,340 . 889 00:33:00,340 --> 00:33:00,840 . 890 00:33:00,840 --> 00:33:00,920 . 891 00:33:00,920 --> 00:33:00,940 . 892 00:33:00,940 --> 00:33:00,980 . 893 00:33:21,500 --> 00:33:21,580 . 894 00:33:25,260 --> 00:33:25,700 . 895 00:33:25,700 --> 00:33:25,960 . 896 00:33:32,900 --> 00:33:33,340 . 897 00:33:33,340 --> 00:33:33,480 . 898 00:33:33,480 --> 00:33:33,660 . 899 00:33:33,660 --> 00:33:34,000 . 900 00:33:34,000 --> 00:33:34,040 . 901 00:33:34,040 --> 00:33:34,060 . 902 00:33:48,020 --> 00:33:48,460 . 903 00:33:55,060 --> 00:33:55,700 . 904 00:33:55,700 --> 00:33:56,360 . 905 00:33:59,440 --> 00:33:59,760 . 906 00:34:00,840 --> 00:34:01,480 . 907 00:34:03,000 --> 00:34:03,640 . 908 00:34:03,640 --> 00:34:03,800 . 909 00:34:03,800 --> 00:34:03,860 . 910 00:34:03,860 --> 00:34:04,180 . 911 00:34:04,180 --> 00:34:04,200 . 912 00:34:04,200 --> 00:34:04,320 . 913 00:34:13,880 --> 00:34:14,520 . 914 00:34:14,520 --> 00:34:14,560 . 915 00:34:14,560 --> 00:34:14,700 . 916 00:34:22,440 --> 00:34:23,220 . 917 00:34:25,860 --> 00:34:26,640 . 918 00:34:26,640 --> 00:34:27,500 . 919 00:34:28,100 --> 00:34:28,460 . 920 00:34:28,460 --> 00:34:28,500 . 921 00:34:28,500 --> 00:34:28,860 . 922 00:34:28,860 --> 00:34:29,220 . 923 00:34:29,220 --> 00:34:29,280 . 924 00:34:32,380 --> 00:34:33,160 . 925 00:34:33,160 --> 00:34:33,280 . 926 00:34:33,280 --> 00:34:33,300 . 927 00:34:33,300 --> 00:34:33,720 . 928 00:34:33,720 --> 00:34:34,680 . 929 00:34:34,680 --> 00:34:35,220 . 930 00:34:51,540 --> 00:34:51,820 . 931 00:35:01,540 --> 00:35:01,820 . 932 00:35:02,340 --> 00:35:02,620 . 933 00:35:02,620 --> 00:35:02,680 . 934 00:35:02,680 --> 00:35:02,820 . 935 00:35:02,820 --> 00:35:02,900 . 936 00:35:02,900 --> 00:35:03,320 . 937 00:35:03,320 --> 00:35:03,380 . 938 00:35:03,380 --> 00:35:03,400 . 939 00:35:03,400 --> 00:35:03,420 . 940 00:35:03,420 --> 00:35:03,680 . 941 00:35:07,260 --> 00:35:07,540 . 942 00:35:07,540 --> 00:35:07,560 . 943 00:35:07,560 --> 00:35:08,440 . 944 00:35:11,300 --> 00:35:12,000 . 945 00:35:12,000 --> 00:35:12,500 . 946 00:35:12,500 --> 00:35:12,640 . 947 00:35:12,640 --> 00:35:13,260 . 948 00:35:13,260 --> 00:35:14,940 . 949 00:35:14,940 --> 00:35:14,960 . 950 00:35:19,320 --> 00:35:20,720 . 951 00:35:43,100 --> 00:35:47,420 I haven't tried it on a wide variety, and I don't have any good tools for instrumenting 952 00:35:47,420 --> 00:35:54,880 that kind of stuff, but for malware purposes, that's mainly not that anybody writes malware. 953 00:35:57,000 --> 00:36:02,560 I would really be sparing if performance is that much of an issue with you, I might look 954 00:36:02,560 --> 00:36:07,780 for things that anti-reverse engineering technologies that you can integrate in your 955 00:36:07,780 --> 00:36:11,200 source code so you can turn it on and off as needed and put it in sporadically. 956 00:36:11,340 --> 00:36:14,400 The whole advantage of this tool is that you don't need source code, you can just run it 957 00:36:14,400 --> 00:36:19,080 against a compiled binary so people who are less, who don't have the source code can use 958 00:36:19,080 --> 00:36:22,500 it and it does things in a way that the source code stuff won't. 959 00:36:22,700 --> 00:36:26,620 If performance is that big of an issue and your timings come out to be shot after you 960 00:36:26,620 --> 00:36:29,820 run it, I don't think there's any way I'm going to get around that, it's a fundamental 961 00:36:29,820 --> 00:36:30,360 issue. 962 00:36:31,020 --> 00:36:31,420 Thank you. 963 00:36:32,220 --> 00:36:32,540 Thank you. 964 00:36:32,560 --> 00:36:33,340 Any other questions? 965 00:36:47,900 --> 00:37:02,040 Well, it's interesting. 966 00:37:02,040 --> 00:37:06,460 You mentioned dead code because it's going to be tough to determine it to be dead code. 967 00:37:06,580 --> 00:37:10,520 Dead code would be, at least typically my thought, is functions that don't get called, 968 00:37:10,640 --> 00:37:12,520 things that are left out, looked over. 969 00:37:12,900 --> 00:37:20,160 The instructions that I insert are not dead, they're executed frequently, so I mean, you 970 00:37:20,160 --> 00:37:23,480 could do some runtime optimization and say, well, these instructions aren't needed. 971 00:37:23,680 --> 00:37:26,800 That would be an incredibly sophisticated tool, though, so that's actually probably 972 00:37:26,800 --> 00:37:29,840 a lot harder than anything I've developed and anything I'm going to develop. 973 00:37:30,120 --> 00:37:30,220 So... 974 00:37:39,740 --> 00:37:43,340 Well, it's not really based on variables, like the conditional jump trick and whatnot, 975 00:37:43,540 --> 00:37:44,640 that's just a flag register. 976 00:37:46,760 --> 00:37:50,340 Theoretically, I mean, something that you come out to predict it, but I can probably 977 00:37:50,340 --> 00:37:55,400 write the anti-reverse engineering stuff quicker than people can write the code to actually 978 00:37:55,400 --> 00:37:56,640 detect what I'm doing. 979 00:37:56,920 --> 00:37:59,040 It's a losing game for detection. 980 00:37:59,040 --> 00:38:00,600 Because this stuff is easy. 981 00:38:00,740 --> 00:38:03,640 Like, getting the code to mix stuff up and all that was tough. 982 00:38:03,920 --> 00:38:06,720 The actual technique to defeat disassemblers was easy. 983 00:38:06,860 --> 00:38:07,720 There's nothing to it. 984 00:38:08,780 --> 00:38:09,660 Any other questions? 985 00:38:12,620 --> 00:38:13,620 All right, well, thanks. 986 00:38:14,360 --> 00:38:14,760 Hopefully... 987 00:38:14,760 --> 00:38:15,380 Thanks. 988 00:38:15,940 --> 00:38:16,340 Thank you. 989 00:38:16,860 --> 00:38:17,220 Thank you. 990 00:38:17,220 --> 00:38:17,440 Thank you.