1 00:00:00,000 --> 00:00:04,720 All right, everyone. Thanks for coming to this talk. This talk is titled Smashing the Stack with Hydra. 2 00:00:05,060 --> 00:00:08,180 We're from Columbia University's Intrusion Detection Systems Lab. 3 00:00:09,000 --> 00:00:11,280 My name is Yingbo Song. I'm the middle author. 4 00:00:11,900 --> 00:00:16,620 This is Prathap, and our advisor, Sal Stoffel, is sitting down here in the middle row. 5 00:00:17,320 --> 00:00:21,960 So before I begin, even though I'm giving this talk, Prathap here did a lot of the work for this, 6 00:00:22,140 --> 00:00:25,960 so keep your scorn or praise upon him at the end. 7 00:00:26,300 --> 00:00:29,580 All right. So an overview of our project. 8 00:00:29,580 --> 00:00:32,740 So Hydra is a new polymorphic shellcode engine for x86 platforms. 9 00:00:33,560 --> 00:00:39,320 We designed this to bypass signature, statistical, and emulator-based IDS systems, basically. 10 00:00:39,960 --> 00:00:43,400 It does this by integrating several obfuscation techniques into one engine, 11 00:00:43,520 --> 00:00:48,220 such as self-cyphering, statistical memory, forking shellcode, and much more. 12 00:00:48,460 --> 00:00:50,400 And I'll talk about these in today's talk. 13 00:00:51,080 --> 00:00:53,340 So basics that Smashing the Stack. 14 00:00:53,480 --> 00:00:56,620 This is from LF1's seminal paper in FRAC. 15 00:00:57,060 --> 00:00:58,400 This is the stack frame. 16 00:00:58,400 --> 00:01:05,060 When you call a function, you have the EIP, which is the address of the function that called. 17 00:01:05,400 --> 00:01:07,180 This function is what we return to. 18 00:01:07,360 --> 00:01:08,780 It sets up the local variables. 19 00:01:09,120 --> 00:01:15,260 If you don't have bound checking, you can send a simple exploit with a no-op sled, payload, return zone. 20 00:01:15,620 --> 00:01:19,560 The return zone overrides the EIP, and when the function calls return, 21 00:01:19,860 --> 00:01:22,840 it jumps into a no-op sled and passes into the payload. 22 00:01:23,120 --> 00:01:28,240 And you basically lose the execution context of your program to whatever. 23 00:01:28,400 --> 00:01:34,400 So just keep in mind what the three default zones look like for a regular shellcode. 24 00:01:34,600 --> 00:01:36,260 No-op sled, payload, return zone. 25 00:01:36,640 --> 00:01:40,480 And Hydra basically obfuscates all of these sections and adds more. 26 00:01:41,500 --> 00:01:42,900 Okay, so polymorphic shellcode. 27 00:01:42,960 --> 00:01:44,240 Why do we need polymorphic shellcode? 28 00:01:44,560 --> 00:01:47,880 Well, it's because IDS signatures for shellcode is easy to write. 29 00:01:48,060 --> 00:01:52,020 For example, you can detect a string of hex 90s, and that's your basic no-op sled. 30 00:01:52,480 --> 00:01:55,720 You can look for a bin SH, and that's an indication you're trying to open a shell. 31 00:01:56,440 --> 00:01:58,380 So many polymorphic engines use... 32 00:01:58,400 --> 00:02:00,780 an encoder to cipher the payload with a random key. 33 00:02:01,180 --> 00:02:04,160 But that doesn't work if your decoder is always the same. 34 00:02:04,620 --> 00:02:06,820 And IDS can just try and detect the decoder. 35 00:02:06,920 --> 00:02:08,660 So the decoder has to be polymorphic. 36 00:02:08,660 --> 00:02:09,620 It has to change every time. 37 00:02:10,420 --> 00:02:13,600 There's also statistical IDS systems out there that look at byte distributions, 38 00:02:14,540 --> 00:02:15,540 multigram byte distributions. 39 00:02:16,080 --> 00:02:21,020 There are also new IDS systems being introduced now based on emulation, dynamic emulation. 40 00:02:21,320 --> 00:02:24,680 There's an actual sensor on the network in line with your traffic trying 41 00:02:24,680 --> 00:02:27,340 to execute all the bytes that come across the network. 42 00:02:27,340 --> 00:02:32,320 And people have actually gotten this to work on 100 megabit line rates, which is very impressive. 43 00:02:32,660 --> 00:02:36,600 There's also dynamic disassembly-based IDS, which looks... 44 00:02:36,600 --> 00:02:42,040 which dynamically disassembles all network traffic and tries to look for large basic blocks. 45 00:02:42,220 --> 00:02:48,320 So normal code, normal data should not have large basic blocks when you disassemble them. 46 00:02:48,480 --> 00:02:53,160 And if you find large chunks of executable code, large chunks of instructions, 47 00:02:53,480 --> 00:02:56,320 it could be an indication of an exploit coming through. 48 00:02:57,340 --> 00:02:59,140 So here's a listing of Hydra's features. 49 00:02:59,740 --> 00:03:03,260 We have a knob instruction generator, recursive knob sleds. 50 00:03:03,940 --> 00:03:08,840 Everything is randomized, including register selection and clearing, randomized multilayer ciphering. 51 00:03:09,080 --> 00:03:13,200 We do junk code data insertion, multi-part type decoders. 52 00:03:13,260 --> 00:03:14,040 I'll explain what that means. 53 00:03:14,140 --> 00:03:19,040 It's basically we take the decoder, break it up into pieces, and insert it into the payload itself. 54 00:03:20,060 --> 00:03:21,760 Multigram statistical mimicry. 55 00:03:21,820 --> 00:03:25,580 This is machine learning techniques to make your shell code look like normal traffic. 56 00:03:26,260 --> 00:03:27,320 Randomized return zone. 57 00:03:28,120 --> 00:03:29,260 I'll explain what that is. 58 00:03:29,320 --> 00:03:33,020 It's basically jumping into different parts of the knob sled, forking shell code. 59 00:03:33,220 --> 00:03:38,280 So there's some recent work now on how do you safely execute an exploit. 60 00:03:38,600 --> 00:03:41,840 When you exploit a process, that process typically hangs. 61 00:03:41,920 --> 00:03:42,400 It crashes. 62 00:03:42,780 --> 00:03:47,200 Your code may run, but it might also throw off an IDS alert. 63 00:03:47,480 --> 00:03:52,400 So this is how to safely execute your shell code and have the vulnerable process continue executing. 64 00:03:53,980 --> 00:03:57,200 We also do something called time-lock ciphering for anti-emulators. 65 00:03:57,200 --> 00:03:57,300 This is a way to do that. 66 00:03:57,300 --> 00:03:58,560 It's a way to do anti-emulator and anti-disassembly techniques. 67 00:03:58,880 --> 00:03:59,860 I'll talk about that. 68 00:04:00,400 --> 00:04:01,380 Alpha-numeric encoding. 69 00:04:02,140 --> 00:04:06,660 The shell code can be pushed down to a printable characters range. 70 00:04:07,860 --> 00:04:08,440 All right. 71 00:04:08,460 --> 00:04:10,020 So knob sled obfuscation. 72 00:04:10,220 --> 00:04:11,860 No-ops don't have to be hex-90. 73 00:04:12,380 --> 00:04:16,920 If you look at the KLED engine, for example, they use the ASCII characters A to Z. 74 00:04:17,220 --> 00:04:20,060 Any of those characters are actually valid no-ops. 75 00:04:21,360 --> 00:04:24,920 You can't use them in line as no-ops because they touch the stack and so on. 76 00:04:24,960 --> 00:04:27,000 But you can create a group of these. 77 00:04:27,040 --> 00:04:27,180 You can use them in line as no-ops because they touch the stack and so on. 78 00:04:27,180 --> 00:04:31,720 You can just put them in front of the payload and execute that, and your payload will still 79 00:04:31,720 --> 00:04:32,120 be fine. 80 00:04:32,800 --> 00:04:37,840 Hydro contains a no-op generator that basically goes out and builds a library of all possible 81 00:04:37,840 --> 00:04:40,860 no-op instructions of multiple byte sizes. 82 00:04:41,240 --> 00:04:43,260 We do this by setting up code to test. 83 00:04:44,300 --> 00:04:48,580 We write code to set up stack and register canary variables. 84 00:04:48,840 --> 00:04:51,580 Then we build a sled using a potential no-op instruction. 85 00:04:52,100 --> 00:04:56,480 Then we write validation code at the end to check those canary variables. 86 00:04:57,180 --> 00:04:59,220 Then we execute that payload, basically. 87 00:04:59,720 --> 00:05:04,840 At the end, if that no-op sled worked and all the canary variables are fine at the end, 88 00:05:04,960 --> 00:05:07,200 then that instruction can be used as a no-op sled. 89 00:05:07,880 --> 00:05:14,380 We use this to find approximately two million no-op instructions that can be used. 90 00:05:14,580 --> 00:05:16,700 You're not limited to just hex-90. 91 00:05:18,040 --> 00:05:20,680 There's also multi-character no-ops. 92 00:05:21,560 --> 00:05:26,900 For example, if you read the original FRAC article by the KLED team, there's something 93 00:05:26,900 --> 00:05:27,160 called no-ops. 94 00:05:27,160 --> 00:05:28,540 It's called a recursive no-op sled. 95 00:05:28,960 --> 00:05:32,660 What you do is you find all one-byte no-op instructions by brute force. 96 00:05:32,860 --> 00:05:34,840 There's only 256 possible choices. 97 00:05:35,180 --> 00:05:39,300 Then you find two-byte no-ops where the second byte is the first no-op. 98 00:05:39,620 --> 00:05:42,480 It doesn't matter if you jump into the first byte or the second byte. 99 00:05:42,560 --> 00:05:43,200 They're both no-ops. 100 00:05:44,220 --> 00:05:47,000 Larger no-op instructions recursively contain smaller no-ops. 101 00:05:47,560 --> 00:05:50,340 This is why it's called a recursive no-op sled. 102 00:05:52,580 --> 00:05:56,600 Hydro distinguishes between two types of no-op instructions, basic no-op equivalents, which 103 00:05:56,600 --> 00:05:57,140 is what you put in your no-op sled. 104 00:05:57,140 --> 00:06:00,480 You put it in front of the payload, and it basically just catches the execution jump 105 00:06:00,480 --> 00:06:03,020 and delivers the execution into the payload safely. 106 00:06:03,420 --> 00:06:07,260 The second type of no-ops are what we call state-safe no-ops. 107 00:06:07,440 --> 00:06:09,820 State-safe no-ops can be inserted between instructions. 108 00:06:10,320 --> 00:06:14,440 These are the no-ops that do not leave the stack in an unsafe state. 109 00:06:14,680 --> 00:06:17,140 They don't randomly modify memory. 110 00:06:18,100 --> 00:06:22,680 Special conditions are put into place when we search for those. 111 00:06:23,040 --> 00:06:27,120 We found about two million total no-op equivalent instructions, the ones you can use to build 112 00:06:27,120 --> 00:06:30,540 a traditional no-op sled, and about 30,000 state-safe no-ops. 113 00:06:30,840 --> 00:06:35,280 You can see the large amount of variation you can generate in a polymorphic engine. 114 00:06:35,700 --> 00:06:37,300 You're not just limited to just hex 90. 115 00:06:39,300 --> 00:06:40,460 Register clearing operations. 116 00:06:40,900 --> 00:06:43,280 We have many different ways of selecting and clearing registers. 117 00:06:43,760 --> 00:06:48,160 Most of these methods involved generating random keys, moving the keys around, and then 118 00:06:50,160 --> 00:06:54,320 move registers, subtract, register, and so on, as long as it clears a register at the 119 00:06:54,320 --> 00:06:54,520 end. 120 00:06:54,700 --> 00:06:57,100 It does a lot of various things before that. 121 00:06:57,680 --> 00:07:02,860 Hydra provides a large library of such instructions, and a platform to easily add more. 122 00:07:04,740 --> 00:07:09,420 For some operations, the random key is generated to further obfuscate the payload. 123 00:07:10,500 --> 00:07:12,000 Multi-partite decoding. 124 00:07:12,880 --> 00:07:15,260 Hydra generates non-contiguous decoders. 125 00:07:15,560 --> 00:07:20,600 In a traditional polymorphic engine, you have your no-op sled, you have your decoder, your 126 00:07:20,600 --> 00:07:26,220 payload, and no-op sled will catch the execution jump, pass that into the decoder. 127 00:07:26,280 --> 00:07:27,100 The decoder will pass that into the decoder. 128 00:07:27,120 --> 00:07:31,460 The decoder will dynamically reverse whatever encoding method you use to obfuscate the payload. 129 00:07:32,380 --> 00:07:37,740 But typically decoders are contiguous, they're just one block of code, and those can be detected 130 00:07:37,740 --> 00:07:42,180 by IDS sensors if you try hard enough, signatures or statistical methods. 131 00:07:42,700 --> 00:07:46,780 So in Hydra, what we did was break up the decoder instructions and then scatter those 132 00:07:46,780 --> 00:07:47,900 into the payload itself. 133 00:07:48,480 --> 00:07:52,180 The instructions jump between each other while decoding the payload. 134 00:07:52,440 --> 00:07:56,340 So you cannot easily write a signature for such a decoder. 135 00:07:57,040 --> 00:08:03,160 Currently, only bi-part decoding is implemented, where we have half of the decoder instructions 136 00:08:03,160 --> 00:08:06,580 up front and half in the back, and we have the payload in between. 137 00:08:06,920 --> 00:08:10,140 And these two decoder portions will just jump between each other. 138 00:08:11,440 --> 00:08:17,820 But we plan to add more true multi-partite decoding in the future. 139 00:08:20,540 --> 00:08:22,440 So multi-layer ciphering. 140 00:08:22,540 --> 00:08:27,100 Multi-layer ciphering is pretty much standard these days for shellcode obfuscation. 141 00:08:27,860 --> 00:08:35,480 We've used CLED, Metasploit, even back to the ADM mutate days, people will just XOR the 142 00:08:35,480 --> 00:08:37,460 payload with randomly chosen keys. 143 00:08:37,960 --> 00:08:45,680 Even back in the mid-90s, people were using 32-bit keys to do encryption on their shellcode 144 00:08:45,680 --> 00:08:50,960 payloads, and that works very well against most AV IDS sensors. 145 00:08:51,500 --> 00:08:54,480 So multi-layer ciphering is basically the newer way of doing it. 146 00:08:54,600 --> 00:08:56,120 You don't just use XOR. 147 00:08:56,220 --> 00:08:56,620 There are a lot. 148 00:08:57,120 --> 00:08:59,840 You can use any type of instruction, as long as they're reversible. 149 00:09:00,160 --> 00:09:02,740 For example, rotate right, rotate left. 150 00:09:03,380 --> 00:09:05,480 You have XOR, add, subtract. 151 00:09:06,020 --> 00:09:10,740 There are many different types of instructions you can use, as long as the payload is decrypted 152 00:09:10,740 --> 00:09:11,060 properly. 153 00:09:11,300 --> 00:09:16,700 If you add a key to your payload, you have to subtract it at some point before in the 154 00:09:16,700 --> 00:09:17,040 decoder. 155 00:09:17,240 --> 00:09:22,980 So if your encoder uses an add, your decoder has to use a subtract. 156 00:09:23,660 --> 00:09:26,660 And in Hydra, the cipher order is dynamic. 157 00:09:27,120 --> 00:09:28,560 Every time, it's completely random. 158 00:09:28,820 --> 00:09:34,180 You don't get the same cipher operations in each run, and you don't get the same keys 159 00:09:34,180 --> 00:09:34,760 in each run. 160 00:09:35,120 --> 00:09:37,220 And we'll have demos of this at the end. 161 00:09:37,900 --> 00:09:42,960 We use 32-bit keys, and it's generated randomly per invocation. 162 00:09:43,680 --> 00:09:46,920 Hydra uses six rounds of ciphering by default. 163 00:09:48,040 --> 00:09:49,600 I just lost my screen. 164 00:09:49,640 --> 00:09:50,180 Hold on a second. 165 00:09:53,020 --> 00:09:53,460 Okay. 166 00:09:53,540 --> 00:09:53,720 It's back. 167 00:09:53,720 --> 00:09:53,820 It's back. 168 00:09:54,040 --> 00:09:58,780 Six rounds of ciphering is used by default, but the user can specify a number. 169 00:10:00,620 --> 00:10:02,300 Inline junk code insertion. 170 00:10:02,480 --> 00:10:07,600 Hydra automatically spaces out your shellcode payload, basically. 171 00:10:07,820 --> 00:10:09,020 So you give it your shellcode. 172 00:10:09,220 --> 00:10:11,860 It takes that and spreads the instructions apart. 173 00:10:12,020 --> 00:10:14,840 In between the instructions, we can insert junk. 174 00:10:14,980 --> 00:10:17,200 We can insert arbitrary data, basically. 175 00:10:17,880 --> 00:10:22,040 And what we do is we typically insert no op instructions. 176 00:10:22,040 --> 00:10:25,920 You can also insert anti-disassembly code, random junk. 177 00:10:26,220 --> 00:10:35,220 Or you can use this section for statistical memory attacks, which we'll talk about in 178 00:10:35,220 --> 00:10:35,520 a minute. 179 00:10:36,760 --> 00:10:42,460 So statistical IDS sensors are the new way of detecting shellcode. 180 00:10:42,640 --> 00:10:49,200 Basically they learn statistical models for normal content and try to detect exploits. 181 00:10:51,020 --> 00:10:51,940 What happened? 182 00:10:55,100 --> 00:10:57,080 I think I just lost my screen again. 183 00:11:02,580 --> 00:11:03,060 Oh. 184 00:11:06,100 --> 00:11:06,580 Okay. 185 00:11:07,740 --> 00:11:08,460 Statistical memory. 186 00:11:08,660 --> 00:11:13,260 So Hydra actually uses machine learning based techniques to make shellcode look like normal 187 00:11:13,260 --> 00:11:13,660 traffic. 188 00:11:14,600 --> 00:11:20,040 Hydra, all you have to do is provide Hydra with instances of normal traffic that you 189 00:11:20,040 --> 00:11:20,460 want to mimic. 190 00:11:20,460 --> 00:11:25,660 And it will build statistical models for multigram distributions. 191 00:11:26,180 --> 00:11:32,080 So what is the frequency of certain character distributions, certain two-by character distribution, 192 00:11:32,320 --> 00:11:34,400 three-by, up to five, seven, and so on. 193 00:11:35,080 --> 00:11:39,880 And it will take your shellcode, build a model of it, take normal traffic, build a model 194 00:11:39,880 --> 00:11:44,320 of it, and it will tweak your shellcode until the two models look very similar. 195 00:11:44,520 --> 00:11:46,460 And it uses machine learning techniques to do that. 196 00:11:46,940 --> 00:11:48,620 Unfortunately, I don't have time to explain that. 197 00:11:48,780 --> 00:11:50,440 But if you want to learn more about it, you can do that. 198 00:11:50,440 --> 00:11:54,640 And if you want to know the details of that, just find me afterwards, and I'll point you 199 00:11:54,640 --> 00:11:55,120 to some papers. 200 00:11:56,300 --> 00:11:58,980 So we do this using Markov chain Monte Carlo. 201 00:11:59,220 --> 00:12:03,060 It's basically a machine learning technique to sample, build a distribution, sample from 202 00:12:03,060 --> 00:12:03,540 that distribution. 203 00:12:04,060 --> 00:12:10,580 And if you recall, we have the junk code insertion feature. 204 00:12:10,940 --> 00:12:16,380 When we space out the instructions, we take the statistical memory bytes and put it in 205 00:12:16,380 --> 00:12:17,540 those spaced out sections. 206 00:12:19,680 --> 00:12:20,200 Randomize. 207 00:12:20,200 --> 00:12:20,360 Return. 208 00:12:20,360 --> 00:12:20,740 Return zones. 209 00:12:21,080 --> 00:12:26,600 So the randomized return address zone is basically a sequence of repeated target addresses. 210 00:12:26,880 --> 00:12:28,200 They point to the NOP sled. 211 00:12:28,460 --> 00:12:32,220 When you write a simple stack exploit, you're hoping that one of these addresses overrides 212 00:12:32,220 --> 00:12:33,220 the IP on the stack. 213 00:12:33,380 --> 00:12:35,780 When the function returns, it jumps into your NOP sled. 214 00:12:36,360 --> 00:12:41,580 And the basic way to randomize this zone is to just add random offsets to each of the 215 00:12:41,580 --> 00:12:42,720 individual address components. 216 00:12:43,160 --> 00:12:50,180 It breaks signatures by completely randomizing each component of the address zone. 217 00:12:51,680 --> 00:12:59,200 So emulator-based IDS systems are the very new, newly introduced techniques. 218 00:12:59,840 --> 00:13:02,560 They exist mostly in the academic communities. 219 00:13:04,180 --> 00:13:08,560 What you do here is you basically build a stripped down x86 emulator and dynamically 220 00:13:08,560 --> 00:13:14,060 execute all network traffic and look for self-decrypting behavior or large basic blocks. 221 00:13:14,380 --> 00:13:19,680 And to defeat this, we basically use something called syscall-based ciphering. 222 00:13:19,680 --> 00:13:25,480 Where we exploit some type of OS functionality to grab a key, which is used to decode the 223 00:13:25,480 --> 00:13:26,340 main cipher operations. 224 00:13:26,860 --> 00:13:28,760 So Hydro uses the time syscall. 225 00:13:29,080 --> 00:13:35,160 And our shellcode will actually call, make the time syscall, get the return value back, 226 00:13:35,420 --> 00:13:40,000 and use the most significant bits of that result as the key to decode the main cipher 227 00:13:40,000 --> 00:13:40,360 operations. 228 00:13:40,720 --> 00:13:44,540 So if you recall, we have the main cipher operations, like xor. 229 00:13:45,040 --> 00:13:49,480 Those instructions are ciphered based on the key we get from syscall. 230 00:13:49,560 --> 00:13:49,660 Okay. 231 00:13:49,680 --> 00:13:55,020 If the syscall is not handled as most emulators can't, then the shellcode cannot be decoded 232 00:13:55,020 --> 00:13:57,420 properly and it will look like random traffic. 233 00:13:58,580 --> 00:14:04,460 But when it gets to the actual host and the OS can handle the syscall, then the proper 234 00:14:04,460 --> 00:14:07,100 shellcode is properly decoded and it will run. 235 00:14:08,600 --> 00:14:15,060 So this also introduces the concept of a shell life, which is where a user can specify how 236 00:14:15,060 --> 00:14:18,720 good, how long of a window this shellcode can run for. 237 00:14:18,980 --> 00:14:26,100 Because we use the time syscall, we can specify, say, seven most significant bytes and that 238 00:14:26,100 --> 00:14:28,700 gives you five minutes for when this shellcode is good. 239 00:14:28,800 --> 00:14:34,020 After five minutes, the shellcode will not decrypt properly and it can't be disassembled. 240 00:14:34,120 --> 00:14:35,520 Well, it's hard to disassemble it. 241 00:14:36,000 --> 00:14:38,760 So network IDS can emulate all possible syscalls. 242 00:14:38,880 --> 00:14:43,740 That's basically the main idea behind why we did this time cipher idea. 243 00:14:44,100 --> 00:14:45,040 It bypasses the syscall. 244 00:14:45,040 --> 00:14:49,740 It bypasses emulators and it bypasses dynamic disassembly-based methods and it slows down 245 00:14:49,740 --> 00:14:54,960 human reverse engineers because it's very hard to figure out exactly where these little 246 00:14:54,960 --> 00:14:56,100 tiny mechanisms are. 247 00:14:56,240 --> 00:15:00,640 These are very small mechanisms that we put in a few bytes at most. 248 00:15:01,320 --> 00:15:03,460 So forking shellcode. 249 00:15:03,560 --> 00:15:07,580 This is something that just got recent attention at CanSecWest. 250 00:15:07,900 --> 00:15:10,900 Some people from Immunity Inc. presented a talk on this. 251 00:15:11,120 --> 00:15:13,220 We did this at the exact same time. 252 00:15:13,220 --> 00:15:16,060 We didn't know that they were also working on it. 253 00:15:16,180 --> 00:15:17,900 So basically, you have an exploit. 254 00:15:18,060 --> 00:15:19,060 You have a target process. 255 00:15:19,420 --> 00:15:23,720 You exploit that target process by a stack exploit or a stack overflow or something. 256 00:15:24,140 --> 00:15:27,080 And what happens is that the target process will crash. 257 00:15:27,740 --> 00:15:28,220 Thanks. 258 00:15:28,400 --> 00:15:31,600 The target process will crash and that's not a desirable result. 259 00:15:31,980 --> 00:15:38,420 What you want to do is have that process keep going simultaneously, have your exploit execute. 260 00:15:38,940 --> 00:15:43,120 Because if the process crash, if it starts doing weird things, then that might alert 261 00:15:43,120 --> 00:15:45,320 a sysadmin or some sort of AD sensor. 262 00:15:45,620 --> 00:15:50,980 So the solution is that we have mechanisms in Hydra that adds forking features to your 263 00:15:50,980 --> 00:15:56,400 shellcode where once the shellcode executes, it immediately forks. 264 00:15:56,440 --> 00:16:01,260 The child executes the payload and the parent attempts to recover the exploited process. 265 00:16:01,460 --> 00:16:03,060 It tries to repair the stack. 266 00:16:03,140 --> 00:16:08,600 It tries to figure out the right return address so that the parent can actually go back to 267 00:16:08,600 --> 00:16:09,260 normal execution. 268 00:16:09,620 --> 00:16:11,260 And we'll demonstrate all of these at the end. 269 00:16:11,460 --> 00:16:13,100 So this feature is very useful. 270 00:16:13,100 --> 00:16:14,540 It's kind of hard to get right. 271 00:16:14,640 --> 00:16:15,500 Recovery is very hard. 272 00:16:15,600 --> 00:16:19,900 Once you exploit the process, you typically lose EIP. 273 00:16:20,160 --> 00:16:23,940 So you have to kind of do some disassembly on your target to figure out exactly where 274 00:16:23,940 --> 00:16:26,080 the offsets are, the proper offsets are. 275 00:16:26,180 --> 00:16:27,820 You have to understand the target address space. 276 00:16:28,240 --> 00:16:33,540 But if you know how to do that, then Hydra adds all this forking feature in automatically. 277 00:16:36,000 --> 00:16:37,100 So alphanumeric encoding. 278 00:16:38,320 --> 00:16:40,900 Most polymorphic engines these days use alphanumeric encoding. 279 00:16:41,240 --> 00:16:42,840 It basically just drops. 280 00:16:42,840 --> 00:16:46,720 Drops all of your shellcode into printable characters range. 281 00:16:47,080 --> 00:16:49,260 We use the alpha 2 encoder. 282 00:16:49,380 --> 00:16:51,420 Those functionalities incorporate into Hydra. 283 00:16:51,840 --> 00:16:58,140 And we also have the alphanumeric no-op generators. 284 00:16:58,720 --> 00:17:03,240 And the alphanumeric no-ops are incorporated into the alpha 2 encoder as well. 285 00:17:04,000 --> 00:17:08,220 So the main benefit of using Hydra is that it has all of these different features. 286 00:17:08,380 --> 00:17:10,940 They're all modular and they all work together. 287 00:17:10,940 --> 00:17:16,500 So this is, if you see on top, that is the traditional shellcode, no-op sled payload 288 00:17:16,500 --> 00:17:17,040 return zone. 289 00:17:17,340 --> 00:17:23,040 And then you have Hydra shellcode, which is you have this recursive sled, alpha decoder, 290 00:17:23,120 --> 00:17:28,000 time-lock cipher, fork, and you have the payloads and the decoders all scattered around. 291 00:17:28,460 --> 00:17:32,320 So the goal of this is basically make it impossible to recognize that what you're looking 292 00:17:32,320 --> 00:17:33,080 at is shellcode. 293 00:17:33,320 --> 00:17:35,800 It's impossible to use the signatures for this. 294 00:17:35,900 --> 00:17:39,480 It's impossible to use statistical methods for this or emulator methods for this. 295 00:17:39,500 --> 00:17:40,280 Well, maybe not impossible. 296 00:17:40,280 --> 00:17:41,040 But very hard. 297 00:17:41,180 --> 00:17:43,240 That's the goal of this work. 298 00:17:44,440 --> 00:17:46,960 And I'll pass it off to Prathap, who will demo this. 299 00:17:48,140 --> 00:17:48,780 All right. 300 00:17:52,540 --> 00:17:54,520 I'll be showing three quick demos here. 301 00:17:55,560 --> 00:18:00,680 The first one, if you just run Hydra without any command line options, you get a decryption 302 00:18:00,680 --> 00:18:00,940 loop. 303 00:18:01,480 --> 00:18:06,880 That's the multi-level cipher operations that will be used for encoding the shellcode. 304 00:18:07,360 --> 00:18:09,380 And the second one would be... 305 00:18:09,380 --> 00:18:09,640 If I... 306 00:18:10,280 --> 00:18:14,180 This is a small shell script that runs Hydra three times and shows us the alphanumeric 307 00:18:14,180 --> 00:18:18,320 encodings of the shellcode, such as the invocations. 308 00:18:19,660 --> 00:18:24,520 We see that this is one payload. 309 00:18:25,100 --> 00:18:26,520 And this is the second payload. 310 00:18:27,240 --> 00:18:28,880 And this is the third payload. 311 00:18:29,240 --> 00:18:34,120 So we see that the content and the length of all the three strings are different. 312 00:18:34,620 --> 00:18:39,640 And this is because we're using two levels of polymorphic encodings, first at the binary 313 00:18:39,640 --> 00:18:41,900 level and the second one at the alphanumeric level. 314 00:18:43,080 --> 00:18:48,040 And the third demo would be multi-threading test. 315 00:18:49,000 --> 00:18:50,240 So we have three... 316 00:18:50,240 --> 00:18:52,440 This is a small program that we're going to exploit. 317 00:18:52,700 --> 00:18:58,960 We have three functions, main, A, and B. So main calls A and A calls B, and B is a function 318 00:18:58,960 --> 00:18:59,820 that will be exploited. 319 00:19:00,340 --> 00:19:08,180 And the goal of the multi-level, I mean, multi-threaded shellcode is to return back into main, skipping 320 00:19:08,180 --> 00:19:09,620 A from B. So... 321 00:19:09,620 --> 00:19:14,780 That is, from B, you return back into A, and we should be able to see the in-main string. 322 00:19:16,100 --> 00:19:18,680 And this is the vulnerable... 323 00:19:18,680 --> 00:19:20,340 This is where we're exploiting the program. 324 00:19:20,860 --> 00:19:21,800 This is the shellcode. 325 00:19:22,420 --> 00:19:23,880 So I just compiled it already. 326 00:19:31,040 --> 00:19:32,700 So we see a shell here. 327 00:19:33,420 --> 00:19:36,680 As well as we come into B, we skip A, and we come into main. 328 00:19:36,840 --> 00:19:39,300 The reason why we skip A is because the payload... 329 00:19:39,300 --> 00:19:46,740 We would actually overwrite the EIP of A. So we just have to get the second last EIP, 330 00:19:46,920 --> 00:19:48,280 and that's the reason we come into main. 331 00:19:49,200 --> 00:19:55,100 And the third test would be the time lock test. 332 00:19:55,380 --> 00:19:57,560 I just invoke Hydra minus seven. 333 00:19:57,840 --> 00:20:04,140 So minus T tells Hydra that we need a time-locked shellcode, and seven is a precision. 334 00:20:05,020 --> 00:20:07,460 And we get the shellcode here. 335 00:20:08,360 --> 00:20:14,420 So we see that the current time is this, and depending on the precision, the time the shellcode 336 00:20:14,420 --> 00:20:18,880 expires at this particular time, we would actually want a higher precision, I think. 337 00:20:18,980 --> 00:20:19,980 Let me just invoke it again. 338 00:20:26,680 --> 00:20:27,780 This is too small. 339 00:20:27,960 --> 00:20:28,580 Let me get eight. 340 00:20:30,580 --> 00:20:31,040 Yeah. 341 00:20:31,120 --> 00:20:33,140 So the time increases now. 342 00:20:34,620 --> 00:20:35,080 Okay. 343 00:20:35,800 --> 00:20:36,260 Okay. 344 00:20:36,980 --> 00:20:37,440 Okay. 345 00:20:39,220 --> 00:20:39,720 Yeah. 346 00:20:40,880 --> 00:20:44,160 So just copy this. 347 00:20:47,200 --> 00:20:47,980 Oh, sorry. 348 00:20:51,320 --> 00:20:52,340 I don't see, though. 349 00:20:53,780 --> 00:20:54,280 Okay. 350 00:20:54,880 --> 00:20:55,600 It's too long. 351 00:20:57,560 --> 00:20:58,060 Yeah. 352 00:21:00,300 --> 00:21:01,300 All right. 353 00:21:01,360 --> 00:21:04,060 So apparently this last demo was a bit hard to pull off. 354 00:21:04,340 --> 00:21:04,480 Yeah. 355 00:21:04,480 --> 00:21:11,180 The resolution is kind of messing up with the ‑‑ do you have time? 356 00:21:11,280 --> 00:21:11,900 Time test. 357 00:21:12,040 --> 00:21:12,240 Let's see. 358 00:21:12,360 --> 00:21:12,540 This one. 359 00:21:12,740 --> 00:21:12,980 Yeah. 360 00:21:20,740 --> 00:21:21,620 One moment. 361 00:21:22,500 --> 00:21:22,940 Yeah. 362 00:21:23,100 --> 00:21:24,480 The screen just turned off. 363 00:21:25,080 --> 00:21:25,520 Okay. 364 00:21:25,540 --> 00:21:26,060 So ‑‑ 365 00:21:26,060 --> 00:21:26,760 Yeah. 366 00:21:26,760 --> 00:21:32,580 Basically, like, when you put in an argument for the time-lock shellcode, only within 367 00:21:32,580 --> 00:21:34,300 that time frame the shellcode would be executable. 368 00:21:34,340 --> 00:21:34,460 Okay. 369 00:21:34,460 --> 00:21:36,940 And after that, the decoder loop would fail and ‑‑ 370 00:21:37,440 --> 00:21:38,240 All right. 371 00:21:38,440 --> 00:21:38,840 Thanks. 372 00:21:38,980 --> 00:21:39,980 I think we're out of time. 373 00:21:40,140 --> 00:21:40,340 Yeah. 374 00:21:40,680 --> 00:21:43,080 We should get off before they drag us off the stage. 375 00:21:43,300 --> 00:21:43,840 All right. 376 00:21:43,860 --> 00:21:44,200 Thanks. 377 00:21:47,380 --> 00:21:48,440 We'll be around. 378 00:21:48,840 --> 00:21:52,940 If you want more ‑‑ if you have any questions or want to see a demo, just find us. 379 00:21:52,980 --> 00:21:53,900 We'll be walking around.