1 00:00:16,200 --> 00:00:24,000 Hello. Can you all hear me okay? All right. So this talk is going to be about information 2 00:00:24,000 --> 00:00:32,600 hiding and binaries. My name is Rakan. Some people choose to remember me as Rakan. It's 3 00:00:32,600 --> 00:00:36,760 going to be a pretty exciting talk. Lots of cool things I've been working on, on steganography. 4 00:00:40,440 --> 00:00:44,240 Basically, there's a big thing I want to warn you all about. There's a big difference between 5 00:00:44,240 --> 00:00:50,380 steganography and stenography. So many people come up to me and go, hey, you know this stenography 6 00:00:50,380 --> 00:00:53,660 thing you're working on? It's really cool. Can you tell me all about it? Well, just for 7 00:00:53,660 --> 00:01:03,880 illustration, that's stenography. All right. So we're just going to talk about information 8 00:01:03,880 --> 00:01:10,360 hiding in general to begin with. And then little by little, I'll delve into theoretical 9 00:01:11,060 --> 00:01:15,620 details and then the practical implementation of things and what can all of this be used 10 00:01:15,620 --> 00:01:23,400 for. There are five general types of information hiding. A lot of you know steganography. 11 00:01:23,660 --> 00:01:28,740 And I've seen it before. And there are lots of applications that do that. But steganography 12 00:01:28,740 --> 00:01:33,040 is just one of them. There's covert channels communications, anonymous communications. 13 00:01:33,520 --> 00:01:42,380 And a big one is copyright marking, which is mostly seen as watermarking. Now, all of 14 00:01:42,380 --> 00:01:50,100 these five different classifications of information hiding are really, we're only really looking 15 00:01:50,100 --> 00:01:53,480 at three different criterias. One of them is data rates. 16 00:01:53,660 --> 00:01:58,300 The other one is stealth. And the third one is resilience to attacks. And these five 17 00:01:58,300 --> 00:02:03,780 different kinds of information hiding have differing requirements for each one of those. 18 00:02:04,100 --> 00:02:10,400 Steganography is when you're trying to hide a message, but you don't necessarily care 19 00:02:10,400 --> 00:02:15,340 about the data rates. But what you do care about is the fact that it's stealthy, that 20 00:02:15,340 --> 00:02:22,300 nobody can know, a third-party eavesdropper cannot know that you're, that there's any 21 00:02:22,300 --> 00:02:23,640 communication going on at all. And that's one of the things that we're trying to do. 22 00:02:24,640 --> 00:02:28,780 But at the same time, it doesn't necessarily have to be resilient. If it is, great. Otherwise, 23 00:02:28,960 --> 00:02:35,160 it's not a big deal. Covert channels, it's kind of a breed apart where you're basically 24 00:02:35,160 --> 00:02:41,240 using channels that were not designed nor intended to provide any information at all, 25 00:02:41,320 --> 00:02:50,300 such as maybe the timing of TCP packets or TCP IP sequence numbers or what error message 26 00:02:50,300 --> 00:02:52,380 is displayed and things like that. 27 00:02:54,000 --> 00:03:00,420 Anonymity is when you're trying to hide, not necessarily the message itself, but the 28 00:03:00,420 --> 00:03:05,600 endpoints of the communication. So I could literally post something on a Usenet group 29 00:03:05,600 --> 00:03:11,400 for everybody to see. But if nobody knows that I posted it and who the destination 30 00:03:11,400 --> 00:03:16,200 is, then that's also a form of information hiding. 31 00:03:16,540 --> 00:03:21,020 Now, copyright marking, that's a big one. I'm going to be spending a lot of time talking 32 00:03:21,020 --> 00:03:23,420 about watermarks and how they're defeated. 33 00:03:23,660 --> 00:03:29,500 Just because most of the information hiding research is done for watermarking purposes, 34 00:03:30,980 --> 00:03:36,840 you have robust marks and fragile marks. The only difference is that it's a different 35 00:03:36,840 --> 00:03:42,940 application. Robust marks are meant to be as resilient as possible to attacks, whereas 36 00:03:42,940 --> 00:03:48,260 fragile marks, as soon as you touch the medium whatsoever, the mark, the hidden information 37 00:03:48,260 --> 00:03:53,640 in it breaks. So this is useful in the case where you're, say, in a court and you have 38 00:03:53,660 --> 00:04:00,100 a digital image and you're trying to use that as an evidence for something. If there 39 00:04:00,100 --> 00:04:05,780 is a fragile mark hidden in it, then if there's any alteration whatsoever in the image, the 40 00:04:05,780 --> 00:04:10,940 mark would have been broken, so you can prove that this image has not been tampered with. 41 00:04:12,080 --> 00:04:16,560 Now robust mark, you all know watermarking, where you try to hide something so that later 42 00:04:16,560 --> 00:04:23,400 on somebody can say, this medium belongs to me because, look at the watermark that's hidden 43 00:04:23,400 --> 00:04:23,640 in it, and it's not tampered with. It's in there. And you can set up the objects, and you can talk to them, and say, this is what they like. And you can prove that there's a particular mark hidden in this image 44 00:04:23,660 --> 00:04:30,620 it. Fingerprinting is similar, but it's, instead of embedding something like copyright 45 00:04:30,620 --> 00:04:37,560 recording industry, you'd embed copyright Joe Schmo, sorry, this file was sent to Joe 46 00:04:37,560 --> 00:04:44,100 Schmo and when I send it to Joe Schmo, if I ever find it on Kazaa or Napster or whatever, 47 00:04:44,100 --> 00:04:50,800 then I would know, okay, Joe Schmo leaked this file and good luck to Joe Schmo. 48 00:04:54,160 --> 00:05:00,740 So historically, basically, there's been three general ways of doing information hiding. 49 00:05:01,040 --> 00:05:10,420 Security service security is a big one. Mainly, way back in Caesar's days, they used to use 50 00:05:10,420 --> 00:05:14,080 these kinds of techniques where, because nobody would know how you would engage the 51 00:05:14,080 --> 00:05:21,940 code information, then nobody but the recipient would find out what your message was, but 52 00:05:21,940 --> 00:05:29,200 it's also used nowadays in the sense that sometimes it's almost impossible to have a 53 00:05:29,200 --> 00:05:35,120 hundred, it's impossible to have a hundred percent foolproof system where nobody can 54 00:05:35,580 --> 00:05:43,960 detect or break your system and get your message out. So today, instead, what people 55 00:05:43,960 --> 00:05:44,060 do is they use... 56 00:05:44,080 --> 00:05:49,720 do is that they try to make the system as difficult as possible to break, even though 57 00:05:49,720 --> 00:05:55,220 they know that eventually it will be broken. And they use obscurity techniques. So they'll 58 00:05:55,220 --> 00:06:03,500 just try to make, like, a reverse engineer's life very difficult. And an example is if 59 00:06:03,500 --> 00:06:08,900 you release a video game and you don't want people to reverse engineer the serial number 60 00:06:08,900 --> 00:06:15,480 generation method, you just make it so difficult to do that it will take a reverse engineer 61 00:06:16,060 --> 00:06:21,220 six months to break. And within six months, you know, you would have sold all the copies 62 00:06:21,220 --> 00:06:27,260 of the game that you would normally have sold anyway. So it wouldn't matter anymore if the 63 00:06:27,260 --> 00:06:29,560 code was broken six months later. 64 00:06:31,440 --> 00:06:36,900 Camouflage is another class of techniques where you're hiding in plain sight, but you 65 00:06:37,540 --> 00:06:38,840 do things to fool the human. 66 00:06:38,840 --> 00:06:46,860 human perceptual system, so you would either put very, very tiny dots in places where the 67 00:06:46,860 --> 00:06:53,000 human eye wouldn't see it, or little holes right next to a character, and because the 68 00:06:53,000 --> 00:06:56,340 character is black and the paper is white, your eye doesn't see it, or you could even 69 00:06:56,340 --> 00:06:58,680 use invisible ink and stuff like that. 70 00:07:00,060 --> 00:07:07,680 Another thing is you could have the data hidden in a very particular location of the medium, 71 00:07:07,680 --> 00:07:12,600 and you would hope that your attacker wouldn't know where to look to find that data. 72 00:07:15,280 --> 00:07:20,180 This is easy to break, though, because all an attacker needs to do is modify your medium 73 00:07:20,180 --> 00:07:27,920 as much as possible while keeping the original meaning of the medium, and they could destroy 74 00:07:27,920 --> 00:07:28,600 your data that way. 75 00:07:28,720 --> 00:07:32,600 So what people have been doing more recently is spread the hidden information all over 76 00:07:32,600 --> 00:07:33,040 the medium. 77 00:07:33,380 --> 00:07:35,800 And what that means is that they would... 78 00:07:35,800 --> 00:07:37,340 One way is to... 79 00:07:37,340 --> 00:07:44,340 One way is to have the message repeated several places all over your medium, and if one place 80 00:07:44,340 --> 00:07:48,040 is broken, then it's okay because you have several other copies and you can reconstruct 81 00:07:48,040 --> 00:07:49,000 the original that way. 82 00:07:50,820 --> 00:07:56,260 Now I touched upon this before, these three general criteria that are used to evaluate 83 00:07:56,260 --> 00:08:01,600 any information-hiding system, data rate, how much data you can store, stealth, how 84 00:08:02,340 --> 00:08:07,200 obvious is it that you've hidden anything, and resilience, where he tries to modify your 85 00:08:08,660 --> 00:08:14,500 medium and extract, and basically break the message that you have in it, how easy is 86 00:08:14,500 --> 00:08:15,560 it for him to do so. 87 00:08:16,000 --> 00:08:17,600 There are three classes of attacks. 88 00:08:18,160 --> 00:08:24,360 One of them is subtractive, which means that you take a medium, which I represent here 89 00:08:24,360 --> 00:08:30,600 as that rectangle, and I use W as watermark because usually a lot of these attacks are 90 00:08:30,600 --> 00:08:31,540 against watermarks. 91 00:08:32,020 --> 00:08:37,140 And basically the idea is to try to take the W... 92 00:08:37,140 --> 00:08:38,560 W out of the rectangle. 93 00:08:38,980 --> 00:08:45,280 So we'll have our friend here, Joe Hacker, who comes along with his friendly chainsaw, 94 00:08:45,460 --> 00:08:51,860 attacks our medium, and extracts the watermark out. 95 00:08:52,200 --> 00:08:57,360 Now in general, this is a pretty hard attack to do because it would mean that your information-hiding 96 00:08:57,360 --> 00:09:05,760 system is so broken that the attacker could know exactly where the watermark is located 97 00:09:05,760 --> 00:09:07,120 and exactly what... 98 00:09:07,120 --> 00:09:12,060 What to do to take it out without destroying the medium in such a way that it's not useful 99 00:09:12,060 --> 00:09:12,400 anymore. 100 00:09:12,900 --> 00:09:20,760 So if you have a huge copyright movie industry smack in the middle of the screen when you're 101 00:09:20,760 --> 00:09:26,980 watching a movie, an attacker could crop that whole section of the screen out and he 102 00:09:26,980 --> 00:09:31,980 would have effectively gotten rid of the watermark. 103 00:09:32,160 --> 00:09:35,620 But the problem is that the resulting medium is just useless now. 104 00:09:35,620 --> 00:09:37,640 And so it's not a successful attack. 105 00:09:38,940 --> 00:09:42,640 A distortive attack is another form of... 106 00:09:42,640 --> 00:09:48,100 Is another kind of attack where the attacker doesn't necessarily know where in the medium 107 00:09:48,920 --> 00:09:54,000 the watermark has resided, but he'll do a lot of different things that basically messes 108 00:09:54,000 --> 00:09:58,740 around with the medium just enough so that it's still useful when he's done messing 109 00:09:58,740 --> 00:09:59,360 around with it. 110 00:09:59,520 --> 00:10:04,940 But the watermark is modified in such a way that it's not recognizable anymore. 111 00:10:05,620 --> 00:10:08,220 By whoever put the watermark in. 112 00:10:10,320 --> 00:10:12,360 So an example is... 113 00:10:12,360 --> 00:10:18,500 Well, illustrations, guy jumps up and down on the thing and then you get a W prime, which 114 00:10:18,500 --> 00:10:19,940 is our new watermark. 115 00:10:21,180 --> 00:10:27,140 An example would be if you have a JPEG with a watermark in it and you scaled it a little 116 00:10:27,140 --> 00:10:34,540 bit, sheared it a little bit, maybe twist some points in the image just enough so that 117 00:10:34,540 --> 00:10:35,600 the human eye can see it. 118 00:10:35,600 --> 00:10:41,040 You may not notice the difference between the original JPEG and the new one, but a machine 119 00:10:41,040 --> 00:10:49,000 looking for a set sequence of colors or however they implemented their system wouldn't recognize 120 00:10:49,000 --> 00:10:49,500 it anymore. 121 00:10:50,880 --> 00:10:55,420 Now an additive attack is where you don't do any of these things. 122 00:10:55,560 --> 00:11:02,780 Instead, you try to make as if you are putting your own watermark into the medium. 123 00:11:03,060 --> 00:11:05,540 And the end result is that you have a medium which... 124 00:11:05,540 --> 00:11:06,380 There are two watermarks in it. 125 00:11:06,560 --> 00:11:10,460 If you're lucky, you can actually override the first watermark. 126 00:11:10,700 --> 00:11:15,080 If not, then you have these two watermarks that are side by side. 127 00:11:15,380 --> 00:11:22,020 And if you end up in court, you can be like, hey, how can you prove that my watermark 128 00:11:22,020 --> 00:11:24,900 wasn't there before yours and this medium actually belongs to me? 129 00:11:28,140 --> 00:11:34,840 So information hiding has been done in so many different mediums, sound, image, all 130 00:11:34,840 --> 00:11:35,300 of this. 131 00:11:37,320 --> 00:11:45,680 Text, you've probably seen a lot of text steganography, there's this spam, I think it's called spam 132 00:11:45,680 --> 00:11:46,020 mimic. 133 00:11:46,580 --> 00:11:47,980 Some of you have probably heard of it. 134 00:11:48,220 --> 00:11:54,020 You enter your message and it generates a spam, like Nigerian 419. 135 00:11:54,480 --> 00:11:57,340 And in it, there's your message hidden. 136 00:11:57,560 --> 00:12:01,120 And if somebody just uses the same technique, they can retrieve it. 137 00:12:01,200 --> 00:12:03,840 But to everybody else, this just looks like a 419 scam. 138 00:12:04,340 --> 00:12:04,820 Okay. 139 00:12:06,880 --> 00:12:09,680 Now, this was information hiding in general. 140 00:12:09,900 --> 00:12:17,120 And now I will talk more about binary information hiding and why is it different and what makes 141 00:12:17,120 --> 00:12:18,360 it an interesting problem to solve. 142 00:12:19,060 --> 00:12:23,160 So it's a low redundancy medium. 143 00:12:23,280 --> 00:12:28,420 What that means is that there's very few different ways to express the same message. 144 00:12:28,780 --> 00:12:34,640 Now, I haven't spoken about redundancy yet, but the idea is that in order to hide any 145 00:12:34,640 --> 00:12:41,000 information in the medium without it being detected, you have to have the resulting medium 146 00:12:41,000 --> 00:12:47,420 look very similar to the original, so that a human cannot look at it and say, hey, what's 147 00:12:47,420 --> 00:12:48,660 wrong with this new medium? 148 00:12:48,740 --> 00:12:49,680 Why does it look so bizarre? 149 00:12:50,980 --> 00:12:55,720 And the way you do that is that if there are several different ways to express the same 150 00:12:55,720 --> 00:13:02,200 thing, at least to the human perception, then you can fool people. 151 00:13:02,380 --> 00:13:04,520 So if your medium... 152 00:13:04,520 --> 00:13:08,360 If your medium is redundant, then you can hide information in it. 153 00:13:08,520 --> 00:13:10,880 An example is the English language. 154 00:13:11,280 --> 00:13:16,360 There are so many different ways to say the same thing that if you choose to say things 155 00:13:16,360 --> 00:13:19,600 one way rather than the other, you could be encoding information. 156 00:13:21,320 --> 00:13:24,500 Any of you know the Monty Python dead parrot sketch? 157 00:13:26,820 --> 00:13:27,260 Yeah. 158 00:13:27,500 --> 00:13:32,020 Anyways, the guy walks into the pet store, he's like, hey, my parrot's dead, and they 159 00:13:32,020 --> 00:13:33,040 start talking about it. 160 00:13:33,100 --> 00:13:34,360 And they get into this big argument. 161 00:13:34,360 --> 00:13:40,020 And the guy goes, really fed up, trying to explain to the salesman that the parrot really 162 00:13:40,020 --> 00:13:40,520 is dead. 163 00:13:40,660 --> 00:13:43,680 And he says the parrot is dead in about, I don't know, 15 different ways. 164 00:13:44,560 --> 00:13:45,660 This parrot is dead. 165 00:13:45,760 --> 00:13:46,580 This parrot is no more. 166 00:13:46,720 --> 00:13:47,720 This parrot has ceased to be. 167 00:13:49,240 --> 00:13:54,080 This parrot has run off its mortal coil and joined the choir invisible, and my favorite, 168 00:13:54,160 --> 00:13:55,580 this is an ex-parrot. 169 00:13:58,100 --> 00:14:04,020 So basically, if you chose one of these dead parrots... 170 00:14:04,800 --> 00:14:08,740 If you chose one of these dead parrots to convey your message, this parrot is dead, you 171 00:14:08,740 --> 00:14:13,300 could convene ahead of time that, okay, if I say the parrot is dead, what I mean is meet 172 00:14:13,300 --> 00:14:14,840 me at noon over there. 173 00:14:14,940 --> 00:14:18,400 If I say this parrot is no more, meet me at 1 over there, and so on. 174 00:14:18,540 --> 00:14:19,920 So that's what I mean by redundancy. 175 00:14:20,020 --> 00:14:23,520 The more redundancy you have in your medium, the more different ways you can express your 176 00:14:23,520 --> 00:14:27,080 message, and the more, the easier it is for you to hide information to it. 177 00:14:27,300 --> 00:14:34,000 Now, binaries have notoriously low redundancy in them because they were designed for me. 178 00:14:34,000 --> 00:14:39,840 From the onset, to be efficient, your instruction set in your CPU instruction set has to be 179 00:14:39,840 --> 00:14:46,540 as small as possible so that your CPU is as not complicated as possible, and it costs 180 00:14:46,540 --> 00:14:48,220 money and time and all of that. 181 00:14:48,660 --> 00:14:53,620 So how do you do it when you have a medium that's specifically been designed to be non-redundant 182 00:14:53,620 --> 00:14:54,040 as possible? 183 00:14:55,240 --> 00:15:02,060 I'll go over this, and there are two classes of techniques you can use to hide information 184 00:15:02,060 --> 00:15:02,620 in binaries. 185 00:15:02,620 --> 00:15:05,740 One of them is called static mark, the other dynamic, I'll go over them right now. 186 00:15:06,440 --> 00:15:16,100 Static data mark is when basically you have pieces of data in your code that you can use 187 00:15:16,100 --> 00:15:25,620 to later identify your mark, meaning you have an array with data such as copyright, I don't 188 00:15:25,620 --> 00:15:29,760 know, recording industry, and so on, and then later on you run strings on your binary 189 00:15:29,760 --> 00:15:31,400 and you find that. 190 00:15:31,580 --> 00:15:32,580 That string. 191 00:15:32,580 --> 00:15:33,900 You're like, aha, you see? 192 00:15:34,680 --> 00:15:36,600 My data mark was hidden in it. 193 00:15:38,260 --> 00:15:39,500 There are many ways to do it. 194 00:15:39,560 --> 00:15:40,660 One way is like this. 195 00:15:41,320 --> 00:15:47,420 Another way is you can actually have codes that have, I don't know, anyway, a bunch 196 00:15:47,420 --> 00:15:47,860 of different ways. 197 00:15:47,940 --> 00:15:49,140 You don't have to use strings either. 198 00:15:49,300 --> 00:15:53,660 You can use anything you want, but the idea, meaning that it's a piece of data that's 199 00:15:53,660 --> 00:15:58,600 just sitting there in your binary waiting to be found in a very specific location. 200 00:16:00,360 --> 00:16:01,880 A code mark is similar. 201 00:16:01,880 --> 00:16:11,560 It's similar, except that you're not playing with data anymore, but code, so instead what 202 00:16:11,560 --> 00:16:19,020 you'd have is you'd have pieces of code ordered in a certain way in your executable. 203 00:16:20,240 --> 00:16:24,200 The original would be the thing on the left, and then you just change it a little bit, 204 00:16:24,340 --> 00:16:28,440 and then if you see the thing on the right anywhere, then you know, okay, this really 205 00:16:28,440 --> 00:16:29,600 is my piece of code. 206 00:16:29,600 --> 00:16:37,000 This is another more sophisticated example of static code marks, which is you have a 207 00:16:37,000 --> 00:16:40,560 bunch of go-to statements that do nothing but go to themselves. 208 00:16:41,560 --> 00:16:48,980 Depending on the ordering, does A go to B or C or D, and does B go to whichever one, 209 00:16:49,160 --> 00:16:54,620 you can have a pretty long list of go-to statements that uniquely identify your code. 210 00:16:54,820 --> 00:16:55,880 It has to be my code. 211 00:16:56,200 --> 00:16:59,580 Nowhere else in the world would I have such a sequence of code. 212 00:16:59,600 --> 00:17:05,740 Go-to statements, as it says, easy to break and easy to implement. 213 00:17:06,800 --> 00:17:09,060 The thing is, it's static. 214 00:17:09,220 --> 00:17:11,580 It's just sitting there waiting to be found. 215 00:17:11,740 --> 00:17:15,040 So if it's sitting there waiting to be found, then all it takes for an attacker is to know 216 00:17:15,040 --> 00:17:17,120 where it is and then mess with it. 217 00:17:18,540 --> 00:17:26,860 So this used to be used a long time ago and everything, but now it's not valid anymore. 218 00:17:27,120 --> 00:17:29,580 Instead, what's more difficult is... 219 00:17:29,600 --> 00:17:30,680 It's what we call dynamic marks. 220 00:17:31,260 --> 00:17:32,640 So a program is running. 221 00:17:33,040 --> 00:17:34,340 You give it a set of inputs. 222 00:17:34,580 --> 00:17:36,100 So you could be clicking on it. 223 00:17:36,200 --> 00:17:40,760 You could be typing something and say if it's a browser, you can type something and it's 224 00:17:40,760 --> 00:17:42,580 in the URL or whatever. 225 00:17:44,080 --> 00:17:51,700 And depending how your program reacts to this input, at some point you can stop it and then 226 00:17:51,700 --> 00:17:56,320 that's the state in which it's in would be the mark itself. 227 00:17:57,200 --> 00:17:58,480 I'll give you examples. 228 00:17:58,480 --> 00:18:02,740 Right now, data structure, mark, execution, Easter eggs. 229 00:18:02,840 --> 00:18:03,680 You all know Easter eggs. 230 00:18:03,940 --> 00:18:07,080 You type about Mozilla and you get this stuff. 231 00:18:07,620 --> 00:18:14,340 So the idea being that if you write a program that looks for this input about Mozilla and 232 00:18:14,340 --> 00:18:20,320 then displays this text when you do type that input, then you know... 233 00:18:20,320 --> 00:18:25,340 And say you're looking at some other web browser somewhere else like five years down the line 234 00:18:25,340 --> 00:18:28,120 and you type about Mozilla and you get the exact same thing. 235 00:18:28,480 --> 00:18:30,300 Like, wait, this is a little bit suspicious. 236 00:18:30,800 --> 00:18:32,400 Why is it reacting the same way? 237 00:18:32,880 --> 00:18:38,760 This is the Easter egg information hiding, yeah. 238 00:18:40,060 --> 00:18:45,340 Dynamic data structure, same general idea where you take a bunch of input except that 239 00:18:45,340 --> 00:18:48,800 you do a whole bunch of operations on that input. 240 00:18:49,080 --> 00:18:55,460 And those operations can be part of your normal execution flow. 241 00:18:55,640 --> 00:18:57,600 So if you're looking at... 242 00:18:58,480 --> 00:19:01,080 At a web browser, it could be... 243 00:19:01,080 --> 00:19:06,640 One input could be the URL and then you XOR it with some random variable in memory. 244 00:19:06,860 --> 00:19:08,420 Like here you have four variables. 245 00:19:08,920 --> 00:19:11,420 You just do some computations with it. 246 00:19:11,600 --> 00:19:16,660 You intermingle it with a lot of other normal code and just keep going on that way until 247 00:19:16,660 --> 00:19:18,640 your last piece of input has been fed in. 248 00:19:19,000 --> 00:19:24,880 And at that point, some of those variables will have a certain content in them. 249 00:19:24,960 --> 00:19:27,660 And if that content is what you expect it to... 250 00:19:27,660 --> 00:19:33,540 So here, the ASCII, the great Mahir, then you know that, okay, this is my program and 251 00:19:33,540 --> 00:19:34,680 this is my watermark. 252 00:19:37,580 --> 00:19:45,200 This is another form of dynamic watermarking where it's a data structure. 253 00:19:45,880 --> 00:19:50,880 This data structure is a linked list and you basically have two pointers in them. 254 00:19:50,960 --> 00:19:55,120 One pointer that points to one of the other elements in the list and the second pointer 255 00:19:55,120 --> 00:19:57,460 just simply points to the next element. 256 00:19:57,520 --> 00:19:57,640 Okay. 257 00:19:57,660 --> 00:19:58,420 In the list. 258 00:19:58,580 --> 00:20:07,840 And depending on how you order your pointers, you can encode certain data. 259 00:20:08,140 --> 00:20:12,740 So in this case, we have four, sorry, we have five linked list elements. 260 00:20:12,880 --> 00:20:17,180 And with that, I mean, it's just a formula that you use. 261 00:20:18,520 --> 00:20:23,380 The first element all the way on the left is five to the power of four just because 262 00:20:23,380 --> 00:20:27,440 there are five elements and then four for the zero-based counting. 263 00:20:27,440 --> 00:20:34,580 And then the first pointer on the left, if it pointed to null, then it would be zero times 264 00:20:34,580 --> 00:20:35,300 five to the four. 265 00:20:35,380 --> 00:20:38,380 If it points to itself, then it's one times five to the four. 266 00:20:38,420 --> 00:20:41,380 If it points to the next item, then it's two times five to the four and so on. 267 00:20:42,600 --> 00:20:44,620 And you can encode a number that way. 268 00:20:45,060 --> 00:20:51,780 Now the advantage of doing this is that if you choose two large prime numbers, P and 269 00:20:51,780 --> 00:20:55,900 Q, multiply them together, you get this other huge number. 270 00:20:55,900 --> 00:21:03,900 Now, if you encode this huge number, N, into your data structure, later on, if you're 271 00:21:03,900 --> 00:21:09,160 trying to prove that indeed this is your code, what you can do is say, look, I've extracted 272 00:21:09,160 --> 00:21:15,880 N from this data structure and I know how to factor N. Now, factorizing a lot too, 273 00:21:17,340 --> 00:21:20,980 the product of two large prime numbers is extremely difficult. 274 00:21:21,820 --> 00:21:25,840 So if you can do that, it proves that, yes, you were the original. 275 00:21:25,900 --> 00:21:27,900 You were the originator of the code. 276 00:21:28,860 --> 00:21:32,820 So in this case, seven times 191 equals 1337. 277 00:21:35,960 --> 00:21:43,580 Now, dynamic execution trace is you get a set of inputs and you just look at the way 278 00:21:43,580 --> 00:21:44,740 your program executes. 279 00:21:44,840 --> 00:21:52,120 You don't necessarily look at what data gets produced or any output or anything. 280 00:21:52,320 --> 00:21:55,320 Instead what you look at is, for example, the addresses. 281 00:21:55,900 --> 00:21:58,140 Instead the program goes through while it's executing. 282 00:21:58,500 --> 00:22:01,900 Or maybe even this falls in the sequence of thereof. 283 00:22:02,660 --> 00:22:05,260 You can use that to uniquely identify your program. 284 00:22:05,840 --> 00:22:08,000 Now, there are a whole bunch of attacks on all of these things. 285 00:22:08,180 --> 00:22:09,540 They're just more difficult to implement. 286 00:22:10,000 --> 00:22:14,940 One of them is what we call semantics for preserving transformation, which just means 287 00:22:14,940 --> 00:22:19,080 that you have a piece of code on the left, which is just assigning three variables, 288 00:22:20,100 --> 00:22:24,660 and you change it to something that's functionally equivalent. 289 00:22:24,660 --> 00:22:24,740 So, for example, I can actually put in a two-dimensional expression, which is equivalent, 290 00:22:24,940 --> 00:22:26,800 but it's just unrecognizable. 291 00:22:29,640 --> 00:22:33,640 If you were to try to recognize the code on the right automatically, you'd be like, 292 00:22:33,740 --> 00:22:36,780 no, it doesn't look anything like the first piece of code, but in fact, functionally, 293 00:22:36,780 --> 00:22:37,520 it's the same thing. 294 00:22:41,400 --> 00:22:45,360 To the linked list that I told you about before, you can add a whole bunch of different pointers, 295 00:22:45,460 --> 00:22:48,120 confusing the recognizing program. 296 00:22:49,920 --> 00:22:52,280 Just in general, add levels of indirection. 297 00:22:53,920 --> 00:22:54,640 All right. 298 00:22:54,640 --> 00:22:56,000 it's supposed to work in a certain way, 299 00:22:56,180 --> 00:22:58,420 you know, maybe add more function calls, 300 00:22:58,520 --> 00:22:59,460 more system calls, 301 00:22:59,540 --> 00:23:01,840 just change just the general way it works 302 00:23:01,840 --> 00:23:04,680 while keeping the functional equivalency. 303 00:23:07,680 --> 00:23:09,280 Now, this is all great and everything, 304 00:23:09,460 --> 00:23:10,500 but the problem is that 305 00:23:11,560 --> 00:23:13,260 I just said things like, 306 00:23:13,380 --> 00:23:14,620 yeah, so you add a pointer here, 307 00:23:14,780 --> 00:23:16,360 or you add function calls, 308 00:23:16,540 --> 00:23:17,860 and you do stuff like that. 309 00:23:18,040 --> 00:23:18,760 But the thing is that, 310 00:23:18,800 --> 00:23:19,600 how do you do that 311 00:23:19,600 --> 00:23:22,000 if you do not have access to the source code? 312 00:23:22,000 --> 00:23:24,340 And this is the main difference 313 00:23:24,340 --> 00:23:26,800 between bytecode 314 00:23:26,800 --> 00:23:29,500 and things like assembly code, 315 00:23:29,940 --> 00:23:35,440 where bytecode can be disassembled one-to-one, 316 00:23:35,540 --> 00:23:38,180 meaning you can pretty much get 317 00:23:38,180 --> 00:23:40,680 the original, quote-unquote, source code 318 00:23:40,680 --> 00:23:43,880 when you disassemble Java bytecode, 319 00:23:44,080 --> 00:23:46,680 but you cannot do that with assembly code. 320 00:23:46,880 --> 00:23:47,780 And the reason is 321 00:23:49,840 --> 00:23:51,760 there is no difference 322 00:23:51,760 --> 00:23:53,560 between data and code, 323 00:23:53,740 --> 00:23:55,080 so you could never know 324 00:23:55,080 --> 00:23:56,560 if something was a number 325 00:23:56,560 --> 00:23:58,440 or if something was an instruction 326 00:23:58,440 --> 00:24:01,780 that you're supposed to execute. 327 00:24:02,260 --> 00:24:04,120 So there are disassemblers, of course, 328 00:24:04,160 --> 00:24:06,080 but they're not perfect. 329 00:24:06,240 --> 00:24:09,280 You can simply not disassemble something 330 00:24:09,280 --> 00:24:11,660 and then reassemble it 331 00:24:11,660 --> 00:24:12,620 and expect it to work. 332 00:24:13,180 --> 00:24:14,580 No way, it won't work. 333 00:24:14,720 --> 00:24:16,000 Disassembly is never perfect. 334 00:24:16,640 --> 00:24:19,520 In fact, perfect disassembly 335 00:24:19,520 --> 00:24:21,560 is what we call an intractable problem, 336 00:24:21,760 --> 00:24:23,780 meaning it's just impossible. 337 00:24:26,100 --> 00:24:27,560 So as a result, 338 00:24:27,640 --> 00:24:29,800 we cannot use the advanced techniques 339 00:24:29,800 --> 00:24:32,060 that I talked about 340 00:24:32,060 --> 00:24:34,840 for attacking dynamic watermarks. 341 00:24:35,040 --> 00:24:38,080 And it's really difficult 342 00:24:38,080 --> 00:24:41,380 to even have dynamic watermarks in code 343 00:24:41,380 --> 00:24:42,520 to begin with, 344 00:24:42,580 --> 00:24:45,100 because unless you have the original source code, 345 00:24:45,480 --> 00:24:46,640 there's nothing you can do. 346 00:24:47,020 --> 00:24:49,840 You cannot just add that graph, 347 00:24:49,940 --> 00:24:51,300 that linked list I told you about, 348 00:24:51,760 --> 00:24:54,060 you can't just add it in the middle of the code 349 00:24:54,060 --> 00:24:56,340 and get it to cooperate nicely 350 00:24:56,340 --> 00:24:57,940 with everything else that's around it. 351 00:24:58,820 --> 00:24:59,800 So as a result, 352 00:24:59,840 --> 00:25:00,880 very little work has been done. 353 00:25:03,020 --> 00:25:04,460 Most of the work that's been done 354 00:25:04,460 --> 00:25:05,420 has been on source code 355 00:25:05,420 --> 00:25:06,560 and not machine code. 356 00:25:09,280 --> 00:25:12,620 So what's something that hides information, 357 00:25:14,160 --> 00:25:15,260 information in a loose sense, 358 00:25:16,840 --> 00:25:17,720 into binaries? 359 00:25:18,040 --> 00:25:18,480 Viruses. 360 00:25:19,220 --> 00:25:20,340 Viruses come in 361 00:25:20,340 --> 00:25:21,660 and they hide their own code, 362 00:25:21,760 --> 00:25:23,700 and they try to make it very difficult 363 00:25:23,700 --> 00:25:25,080 for an antivirus to detect. 364 00:25:25,520 --> 00:25:27,800 So this is something interesting to look into 365 00:25:27,800 --> 00:25:30,560 if we want to hide information into it. 366 00:25:30,660 --> 00:25:32,880 So the way it usually works, 367 00:25:33,360 --> 00:25:34,360 you have your program, 368 00:25:34,820 --> 00:25:35,940 there's an entry point, 369 00:25:36,100 --> 00:25:37,160 which is where the program starts, 370 00:25:38,680 --> 00:25:40,520 and the program just runs from there. 371 00:25:41,300 --> 00:25:42,400 What a virus would do 372 00:25:42,400 --> 00:25:43,680 is it puts a payload 373 00:25:43,680 --> 00:25:45,280 at the end of the program 374 00:25:45,280 --> 00:25:47,520 and then hijacks the entry point. 375 00:25:49,560 --> 00:25:51,620 And when it's done executing its own code, 376 00:25:51,760 --> 00:25:54,200 it goes back to the original entry point 377 00:25:54,200 --> 00:25:55,480 and just keeps on executing there 378 00:25:55,480 --> 00:25:56,580 as if nothing had happened. 379 00:25:57,920 --> 00:26:01,360 This is the basic first virus, whatever. 380 00:26:02,840 --> 00:26:04,600 Now that's very easy to detect 381 00:26:04,600 --> 00:26:06,600 because what antiviruses do 382 00:26:06,600 --> 00:26:08,520 is they just look for this kind of behavior 383 00:26:08,520 --> 00:26:11,560 and detect it. 384 00:26:12,320 --> 00:26:12,840 So instead, 385 00:26:13,100 --> 00:26:14,220 oh, sorry, 386 00:26:14,380 --> 00:26:17,400 the payload basically would be fixed originally. 387 00:26:18,280 --> 00:26:20,400 So what an antivirus would do 388 00:26:20,400 --> 00:26:21,740 is just basically go through the payload, 389 00:26:21,740 --> 00:26:23,440 grab for that code sequence, 390 00:26:23,780 --> 00:26:24,560 and it would know, 391 00:26:24,640 --> 00:26:26,180 okay, if I find this piece of code, 392 00:26:26,440 --> 00:26:28,160 then it's obviously a virus, 393 00:26:28,240 --> 00:26:29,740 and flag it, and that's it. 394 00:26:30,020 --> 00:26:31,380 So what people started doing 395 00:26:31,380 --> 00:26:32,820 was use encryption, 396 00:26:33,100 --> 00:26:34,360 where they would have this, 397 00:26:35,040 --> 00:26:37,940 a few statements that would decrypt 398 00:26:37,940 --> 00:26:40,680 the code that they would actually then run. 399 00:26:41,200 --> 00:26:45,180 Now, and every time a virus infects a new host, 400 00:26:45,400 --> 00:26:47,000 they would change the key 401 00:26:47,000 --> 00:26:49,620 that would be used to encrypt and decrypt. 402 00:26:49,700 --> 00:26:51,160 So you would have every single, 403 00:26:51,160 --> 00:26:53,940 at every single new host, 404 00:26:54,100 --> 00:26:55,620 you'd have a different code block 405 00:26:55,620 --> 00:26:58,080 at the end of your program. 406 00:26:59,280 --> 00:27:00,940 So the virus body would be changing. 407 00:27:01,160 --> 00:27:05,080 But this fixed routine would remain the same. 408 00:27:05,280 --> 00:27:06,400 You know, it needs to decrypt. 409 00:27:06,480 --> 00:27:08,060 So what antivirus people started doing 410 00:27:08,060 --> 00:27:11,860 was simply triggering on that decryption routine. 411 00:27:12,100 --> 00:27:14,560 If they ever see that decryption routine in your code, 412 00:27:14,660 --> 00:27:16,280 then they're like, okay, there's a virus in there. 413 00:27:16,840 --> 00:27:18,740 So what people started doing was, 414 00:27:20,140 --> 00:27:21,140 we call it polymorphism, 415 00:27:21,160 --> 00:27:21,640 or polymorphic virus, 416 00:27:22,280 --> 00:27:26,740 which is simply you keep that idea 417 00:27:26,740 --> 00:27:28,580 of encrypting your virus body, 418 00:27:29,260 --> 00:27:32,300 but change the way, 419 00:27:32,440 --> 00:27:38,640 change the decoding of your decryption routine. 420 00:27:40,280 --> 00:27:43,020 And yeah, so there are different ways 421 00:27:43,020 --> 00:27:44,380 you can write the same piece of code. 422 00:27:44,540 --> 00:27:45,980 So every time you infect a new host, 423 00:27:46,100 --> 00:27:49,120 you just write a new version of your decryption routine. 424 00:27:49,400 --> 00:27:51,140 Now that made antivirus, 425 00:27:51,160 --> 00:27:53,920 antivirus makers' lives a little difficult 426 00:27:53,920 --> 00:27:54,720 for a little while. 427 00:27:54,940 --> 00:27:57,440 But then they realized that all they needed to do 428 00:27:57,980 --> 00:28:02,300 was to wait for the virus to decrypt its code. 429 00:28:02,620 --> 00:28:05,120 And because at some point it has to decrypt it 430 00:28:05,120 --> 00:28:05,920 and then run it. 431 00:28:06,060 --> 00:28:07,680 So if ever it finds, 432 00:28:08,560 --> 00:28:11,580 the antivirus finds this decrypted code in memory, 433 00:28:11,760 --> 00:28:14,300 then they flag the virus. 434 00:28:14,580 --> 00:28:16,680 So that's what's been happening. 435 00:28:17,560 --> 00:28:19,700 Now, as a response to that, 436 00:28:19,800 --> 00:28:20,880 what people have been doing is called 437 00:28:20,880 --> 00:28:23,320 metamorphic viruses. 438 00:28:23,880 --> 00:28:24,900 And in this case, 439 00:28:24,980 --> 00:28:27,040 there simply is no decryptor. 440 00:28:28,860 --> 00:28:31,420 Some people use encryption with it, 441 00:28:31,480 --> 00:28:34,040 but the basic idea is 442 00:28:34,040 --> 00:28:35,680 it doesn't necessarily even have to have one. 443 00:28:35,920 --> 00:28:36,860 And instead, 444 00:28:37,480 --> 00:28:40,680 it simply uses different ways of writing codes. 445 00:28:41,640 --> 00:28:45,140 And every time it spreads itself to new hosts, 446 00:28:45,380 --> 00:28:48,060 it will just rewrite its own code in a different way. 447 00:28:48,240 --> 00:28:50,700 And so when it's loaded in memory, 448 00:28:50,880 --> 00:28:52,320 it looks different every single time, 449 00:28:52,360 --> 00:28:53,700 even though it's the same code. 450 00:28:53,860 --> 00:28:55,660 That's much more difficult to detect. 451 00:28:57,480 --> 00:29:00,520 So a trick that metamorphic viruses use, 452 00:29:00,740 --> 00:29:02,060 I'm going to talk about metamorphic viruses 453 00:29:02,060 --> 00:29:06,220 because it's on the basis of that information hiding 454 00:29:06,220 --> 00:29:08,220 that I've chosen to implement information hiding. 455 00:29:10,120 --> 00:29:13,220 Register swapping is simply... 456 00:29:15,120 --> 00:29:17,220 How many of you know a little bit about assembly? 457 00:29:18,840 --> 00:29:19,720 Okay, all right. 458 00:29:19,800 --> 00:29:20,540 I thought, all right. 459 00:29:20,880 --> 00:29:21,420 Good. 460 00:29:21,560 --> 00:29:22,800 So basically, 461 00:29:22,960 --> 00:29:26,240 you have assembly statements 462 00:29:26,240 --> 00:29:28,360 and you use different registers. 463 00:29:28,620 --> 00:29:31,760 But there's no rhyme or reason necessarily 464 00:29:31,760 --> 00:29:35,620 as to which registers you use in your code. 465 00:29:35,960 --> 00:29:39,440 You could use EAX or EBX or ECX, 466 00:29:39,540 --> 00:29:40,100 anything you want, 467 00:29:40,160 --> 00:29:42,100 as long as you're not clobbering any registers 468 00:29:42,100 --> 00:29:43,320 that you've used previously, 469 00:29:44,440 --> 00:29:45,320 you're good to go. 470 00:29:45,500 --> 00:29:47,780 So in this code example, 471 00:29:47,960 --> 00:29:48,700 on the left, 472 00:29:48,940 --> 00:29:50,720 you'd be using ESI, 473 00:29:50,880 --> 00:29:53,400 EAX, and ECX, and EBX. 474 00:29:54,150 --> 00:29:54,440 No? 475 00:29:54,640 --> 00:29:55,220 Yeah. 476 00:29:55,380 --> 00:29:56,440 And basically, 477 00:29:56,580 --> 00:29:58,760 you would just swap the registers around. 478 00:29:58,940 --> 00:30:02,460 And the result is that your resulting code 479 00:30:03,120 --> 00:30:04,760 still behaves the same way. 480 00:30:04,840 --> 00:30:07,960 You're still doing the same thing, 481 00:30:08,140 --> 00:30:11,520 except that it looks different now. 482 00:30:11,700 --> 00:30:13,140 The portions in red, 483 00:30:13,830 --> 00:30:15,920 basically almost half of the code looks different. 484 00:30:16,080 --> 00:30:20,180 So if an antivirus were to simply grep for... 485 00:30:20,880 --> 00:30:21,800 for a code sequence, 486 00:30:22,100 --> 00:30:23,020 it would never find this, 487 00:30:23,060 --> 00:30:24,980 even though this is functionally equivalent. 488 00:30:26,400 --> 00:30:28,020 Now, there are very, very many tricks. 489 00:30:28,140 --> 00:30:29,300 That was just a simple one. 490 00:30:29,920 --> 00:30:31,760 Instruction substitution means that 491 00:30:31,760 --> 00:30:33,660 you take several instructions that have this... 492 00:30:33,660 --> 00:30:35,200 the same meaning, 493 00:30:35,340 --> 00:30:36,320 and you swap them. 494 00:30:36,600 --> 00:30:38,020 And depending which one you use, 495 00:30:38,120 --> 00:30:38,880 it just looks different, 496 00:30:38,960 --> 00:30:39,920 but it acts the same way. 497 00:30:40,540 --> 00:30:43,000 You can have data that's... 498 00:30:44,140 --> 00:30:45,700 that you use in your code, 499 00:30:45,800 --> 00:30:47,680 but then it's not really doing anything. 500 00:30:47,980 --> 00:30:50,800 So instead, what you do is you just change it, 501 00:30:50,800 --> 00:30:52,440 you change the data to a different value, 502 00:30:53,280 --> 00:30:55,280 and your code looks different because 503 00:30:55,280 --> 00:30:57,140 it just has different data in it now, 504 00:30:57,260 --> 00:30:58,460 but you're not actually using it, 505 00:30:58,520 --> 00:31:01,200 or if you are, you compensate for the change elsewhere, 506 00:31:01,540 --> 00:31:02,120 things like that. 507 00:31:03,160 --> 00:31:05,420 You can add nops in the middle of your code, 508 00:31:05,560 --> 00:31:07,680 garbage, random things that do nothing, 509 00:31:08,360 --> 00:31:09,280 and so on. 510 00:31:09,400 --> 00:31:12,040 Basically, you're just trying to change your code as much as... 511 00:31:12,040 --> 00:31:15,380 changing the looks of your code as much as possible, 512 00:31:15,540 --> 00:31:20,260 but, in fact, the functionality remains the same. 513 00:31:20,400 --> 00:31:20,780 But, in fact, the functionality remains the same. 514 00:31:20,800 --> 00:31:22,280 So, Hydren 515 00:31:23,040 --> 00:31:23,600 uses 516 00:31:24,360 --> 00:31:26,360 instruction substitution that I'll detail now 517 00:31:26,360 --> 00:31:28,380 to encode data, 518 00:31:28,560 --> 00:31:28,980 and 519 00:31:30,320 --> 00:31:31,880 I'll go for a demo. 520 00:31:32,040 --> 00:31:33,040 Hopefully it'll work. 521 00:31:39,440 --> 00:31:40,000 Alright. 522 00:31:40,820 --> 00:31:41,380 So... 523 00:31:42,160 --> 00:31:42,880 Hang on. 524 00:31:48,500 --> 00:31:50,720 Alright, so, the way Hydren works 525 00:31:50,800 --> 00:31:52,740 is that, basically, you just... 526 00:31:53,660 --> 00:31:54,620 you supply 527 00:31:54,620 --> 00:31:56,620 it a binary, so I can 528 00:31:56,620 --> 00:31:58,900 do, like, bin ls, 529 00:31:58,920 --> 00:32:00,700 and then you supply 530 00:32:00,700 --> 00:32:01,860 it a message file. 531 00:32:02,600 --> 00:32:03,080 Message. 532 00:32:05,700 --> 00:32:06,680 And then you just 533 00:32:06,680 --> 00:32:08,580 give it an output file, so it could be 534 00:32:08,580 --> 00:32:09,480 ls.stegged. 535 00:32:12,200 --> 00:32:12,680 Password? 536 00:32:12,760 --> 00:32:13,060 Foo. 537 00:32:15,280 --> 00:32:16,460 Alright, so embedded, 538 00:32:16,800 --> 00:32:17,500 you know, it 539 00:32:19,160 --> 00:32:20,360 embedded 192 bytes 540 00:32:21,320 --> 00:32:22,840 it could have embedded up to 541 00:32:23,340 --> 00:32:23,740 362. 542 00:32:24,960 --> 00:32:25,960 Now, let's just 543 00:32:27,280 --> 00:32:28,700 execute ls.stegged. 544 00:32:32,920 --> 00:32:33,800 Looks the same. 545 00:32:35,700 --> 00:32:36,240 You know, 546 00:32:36,360 --> 00:32:37,240 you can do whatever you want. 547 00:32:38,840 --> 00:32:40,140 For all practical purposes, 548 00:32:40,400 --> 00:32:41,760 it's still ls. 549 00:32:42,580 --> 00:32:42,980 Now, 550 00:32:45,920 --> 00:32:46,680 let me see 551 00:32:46,680 --> 00:32:48,560 what message I hid in there. 552 00:32:48,680 --> 00:32:49,860 So I do hide and decode. 553 00:32:50,800 --> 00:32:51,840 ls.stegged. 554 00:32:54,360 --> 00:32:54,920 Password? 555 00:32:55,000 --> 00:32:55,520 Foo. 556 00:32:56,900 --> 00:32:57,460 Bang. 557 00:32:59,420 --> 00:32:59,980 Now... 558 00:33:05,820 --> 00:33:06,740 Xavier is 559 00:33:06,740 --> 00:33:07,900 my handle, by the way. 560 00:33:09,280 --> 00:33:10,740 You can see the original 561 00:33:10,740 --> 00:33:12,760 bin ls and ls.stegged 562 00:33:12,760 --> 00:33:14,200 exactly the same size. 563 00:33:14,440 --> 00:33:16,680 But the new one now just has some extra 564 00:33:16,680 --> 00:33:17,440 information in it. 565 00:33:18,520 --> 00:33:19,080 Alright. 566 00:33:20,800 --> 00:33:21,260 Let's try that demo. 567 00:33:23,040 --> 00:33:23,920 . 568 00:33:27,800 --> 00:33:28,680 . 569 00:33:32,960 --> 00:33:33,840 . 570 00:33:33,840 --> 00:33:34,140 . 571 00:33:34,140 --> 00:33:34,340 . 572 00:33:34,340 --> 00:33:34,560 . 573 00:33:34,560 --> 00:33:35,400 . 574 00:33:35,400 --> 00:33:36,240 . 575 00:33:37,640 --> 00:33:38,520 . 576 00:33:38,520 --> 00:33:38,700 . 577 00:33:41,880 --> 00:33:42,440 . 578 00:33:43,960 --> 00:33:44,520 . 579 00:33:44,520 --> 00:33:44,700 . 580 00:33:44,700 --> 00:33:44,740 . 581 00:33:46,580 --> 00:33:47,140 . 582 00:33:47,140 --> 00:33:47,420 . 583 00:33:48,020 --> 00:33:48,580 . 584 00:33:48,580 --> 00:33:48,720 . 585 00:33:48,720 --> 00:33:48,740 . 586 00:33:48,740 --> 00:33:48,760 . 587 00:33:51,400 --> 00:33:51,960 . 588 00:33:51,960 --> 00:33:51,980 . 589 00:33:56,460 --> 00:33:57,020 . 590 00:33:57,020 --> 00:33:57,320 . 591 00:34:02,020 --> 00:34:02,620 . 592 00:34:02,620 --> 00:34:03,140 . 593 00:34:06,980 --> 00:34:07,280 . 594 00:34:07,580 --> 00:34:07,620 . 595 00:34:07,620 --> 00:34:07,660 . 596 00:34:07,660 --> 00:34:07,680 . 597 00:34:07,680 --> 00:34:07,820 . 598 00:34:08,940 --> 00:34:09,540 . 599 00:34:09,540 --> 00:34:09,720 . 600 00:34:13,760 --> 00:34:14,340 . 601 00:34:16,460 --> 00:34:17,040 . 602 00:34:17,040 --> 00:34:18,060 . 603 00:34:18,060 --> 00:34:18,160 . 604 00:34:18,160 --> 00:34:18,440 . 605 00:34:18,440 --> 00:34:18,880 . 606 00:34:18,880 --> 00:34:19,180 . 607 00:34:19,180 --> 00:34:19,220 . 608 00:34:19,220 --> 00:34:19,280 . 609 00:34:19,280 --> 00:34:19,300 . 610 00:34:19,300 --> 00:34:20,320 . 611 00:34:20,320 --> 00:34:20,360 . 612 00:34:24,900 --> 00:34:25,400 . 613 00:34:32,420 --> 00:34:32,920 . 614 00:34:32,920 --> 00:34:32,940 . 615 00:34:32,940 --> 00:34:33,340 . 616 00:34:33,340 --> 00:34:33,380 . 617 00:34:33,380 --> 00:34:33,400 . 618 00:34:34,140 --> 00:34:34,640 . 619 00:34:34,640 --> 00:34:34,740 . 620 00:34:34,740 --> 00:34:35,540 . 621 00:34:35,540 --> 00:34:35,560 . 622 00:34:49,080 --> 00:34:49,580 . 623 00:34:50,320 --> 00:34:50,640 . 624 00:34:52,700 --> 00:34:53,260 . 625 00:34:57,260 --> 00:34:57,820 . 626 00:34:57,820 --> 00:34:57,920 . 627 00:34:57,920 --> 00:34:58,200 . 628 00:34:58,200 --> 00:34:58,480 . 629 00:34:58,480 --> 00:34:58,520 . 630 00:35:02,020 --> 00:35:02,580 . 631 00:35:02,580 --> 00:35:02,660 . 632 00:35:02,660 --> 00:35:02,680 . 633 00:35:02,680 --> 00:35:09,480 simply compares two registers. If you're only looking at the same register, if you test 634 00:35:09,480 --> 00:35:18,080 EAX with itself, which is often done to test for if it's zero or not, you can equally do, 635 00:35:18,740 --> 00:35:22,160 you can OR it with itself, and there are two different ways of doing OR. I'll explain this 636 00:35:22,160 --> 00:35:25,860 a little bit later. Or you can AND it with itself. There are also two different ways 637 00:35:25,860 --> 00:35:31,840 to AND it, but just to keep it simple, I've kept this to four. With four instructions, 638 00:35:31,840 --> 00:35:37,520 you can embed, with four instructions, you can embed two bits of data. In this case, 639 00:35:37,560 --> 00:35:40,940 I've chosen test is zero, OR is zero one, and so on. 640 00:35:42,900 --> 00:35:49,880 Anyways, this is just an example. I have a listing on the left, and the data I want to 641 00:35:49,880 --> 00:35:58,040 encode is zero, one, zero, zero. I hit an add. I want to embed a zero. I already have an add, 642 00:35:58,120 --> 00:36:01,820 which is zero, so I just leave it as is. Or, same thing, I can embed two bits and I 643 00:36:01,820 --> 00:36:06,200 just flip it around and so on. It's pretty simple. There are a bunch of stuff that I do 644 00:36:06,200 --> 00:36:11,340 in HIDEN to make it a bit more secure, because the idea is that you would want to have your 645 00:36:12,420 --> 00:36:17,200 information... I mean, it's steganography. We're doing information hiding, but I would 646 00:36:17,200 --> 00:36:20,880 ideally like to do steganography, which means that it has to be stealthy. 647 00:36:21,160 --> 00:36:27,700 Now, I don't want somebody to simply look at the text, at the resulting binary, and 648 00:36:27,700 --> 00:36:30,260 be like, oh, this looks really suspicious, and what's going on. 649 00:36:30,860 --> 00:36:31,580 ASCII text... 650 00:36:31,580 --> 00:36:38,520 If you embed straight ASCII text, it's very suspicious, because every most significant 651 00:36:38,520 --> 00:36:45,380 bit in ASCII is zero or one. I forgot which one. What would happen is that you would end 652 00:36:45,380 --> 00:36:52,200 up having this repeating sequence. Every eight bits, you have one, one, one. That just looks 653 00:36:52,200 --> 00:37:00,480 really weird. Instead, what we do is we encrypt it, encrypt everything. The resulting... The 654 00:37:00,480 --> 00:37:04,620 stuff that you embed is actually... Looks like garbage. 655 00:37:05,820 --> 00:37:11,300 Now, there's another thing I do to prevent people from seeing what's going on, is what 656 00:37:11,300 --> 00:37:17,040 I call random walk. Now, if you simply went through the listing, as I said before, and 657 00:37:17,040 --> 00:37:22,800 embedded sequentially, you know, at every other instruction that you saw, and your 658 00:37:22,800 --> 00:37:30,280 message doesn't fill the whole size of the binary, then you'd end up with a whole clump 659 00:37:30,480 --> 00:37:37,740 of data at the top of the binary, and nothing afterwards. So that would look suspicious 660 00:37:37,740 --> 00:37:41,040 from the point of view of an attacker. So instead, you have a random walk, which is 661 00:37:41,500 --> 00:37:48,720 you seed a random number generator with, say, your password, and then you just call the 662 00:37:48,720 --> 00:37:52,800 random number generator every time, and it just gives you back a number, another number. 663 00:37:52,980 --> 00:37:58,700 And you use that number to jump around the binary and embed your stuff. So this is the 664 00:37:58,700 --> 00:38:00,100 binary with all the, like... 665 00:38:00,480 --> 00:38:11,200 Code locations. Now, the blue blobs are where you can actually embed things. So you pick 666 00:38:11,200 --> 00:38:15,420 one, and then you just jump a random number, and then just keep jumping a random number, 667 00:38:15,480 --> 00:38:24,560 and just keep going until you fill everything up. When the person... When somebody receives 668 00:38:24,560 --> 00:38:29,040 your message, what they would do is they would feed the same input to the random number generator, 669 00:38:29,260 --> 00:38:30,460 which is the password. 670 00:38:30,480 --> 00:38:35,500 And by doing that, they could retrieve the same exact sequence of random numbers that 671 00:38:35,500 --> 00:38:37,240 have been output for you. 672 00:38:37,880 --> 00:38:44,100 Now, sometimes some of the instructions that I use are not equivalent in edge cases. 673 00:38:44,520 --> 00:38:48,600 So addition and subtraction, you'd assume, are the same, you know, most of the time. 674 00:38:48,680 --> 00:38:56,340 But sometimes they're not. An example is if you add negative one to, say, EAX, the result 675 00:38:56,340 --> 00:38:58,120 is negative one. 676 00:38:58,200 --> 00:38:58,840 But the... 677 00:38:59,820 --> 00:39:00,340 The... 678 00:39:00,480 --> 00:39:06,480 The flags are set, the overflow flag is zero, and the carry flag is zero. But if you do... 679 00:39:06,480 --> 00:39:11,260 If you subtract one instead to EAX, then your carry flag is set differently. 680 00:39:12,300 --> 00:39:18,160 So what I do is I scan ahead. Like, if I see an addition or a subtraction, and I want 681 00:39:18,160 --> 00:39:22,840 to change it, I scan ahead to see what other instructions there are in front of it. 682 00:39:22,900 --> 00:39:28,820 And if one of the instructions ahead of it is an instruction that changes the carry flag 683 00:39:28,820 --> 00:39:30,220 anyway, it clobbers it. 684 00:39:30,220 --> 00:39:37,980 And in between the addition and that clobbering instruction, there are no instructions that 685 00:39:37,980 --> 00:39:40,920 check for this carry flag. Then we're good, we can use... 686 00:39:40,920 --> 00:39:42,900 We can do whatever we want with a carry flag, it never gets checked. 687 00:39:44,480 --> 00:39:47,940 Other instructions have similar behaviors and, you know... 688 00:39:50,720 --> 00:39:52,860 Yeah, what do we do if we have seven instructions? 689 00:39:53,340 --> 00:39:58,960 I showed you the example where we have two instructions, four instructions, but if we 690 00:39:58,960 --> 00:40:00,200 have eight instructions, we can embed them in the other instructions. 691 00:40:00,200 --> 00:40:04,960 three bits of information. But if we have only seven, what are we going to do? We could 692 00:40:04,960 --> 00:40:11,880 just waste three of them and then only use four of them for embedding. But that would 693 00:40:11,880 --> 00:40:16,680 be a waste. So instead what I do is I use one of the instructions as a wild card, Joker. 694 00:40:18,500 --> 00:40:25,300 And if there is no instruction that can be embedded with it, sorry, I try to embed, say, 695 00:40:25,300 --> 00:40:31,060 with seven instructions, I try to embed three bits as much as I can. But if I cannot, then 696 00:40:31,060 --> 00:40:35,900 I use one of the instructions as a Joker value, meaning this instruction encodes no data, 697 00:40:36,020 --> 00:40:42,980 skip, move forward. The result of that, we can embed log two of n minus one bits of information 698 00:40:42,980 --> 00:40:49,420 for when n is not a power of two. So the example with seven instructions is that you can embed 699 00:40:49,420 --> 00:40:53,780 log two of six bits of information, which is 2.58 bits. 700 00:40:55,300 --> 00:41:00,760 Whereas normally, we would only have done with two bits. So it's an improvement. 701 00:41:02,500 --> 00:41:08,260 Now, instructions are not created equal, meaning that it is possible to detect addition and subtraction 702 00:41:08,260 --> 00:41:14,280 in all these instruction substitutions that I do, simply because the compilers produce code 703 00:41:14,280 --> 00:41:19,380 in a certain way, and at the end of the day, you can see that difference when you're using 704 00:41:19,380 --> 00:41:24,440 hidden. An example is negative subtractions. Compilers rarely do. 705 00:41:25,620 --> 00:41:30,420 Sub EAX negative five. For some reason, they just never do that. Instead, they would do 706 00:41:30,420 --> 00:41:38,820 add EAX five. And what hidden does is that it creates very many of those negative subtractions. 707 00:41:38,980 --> 00:41:43,420 So if you were to just look for an inordinate number of negative subtractions, you would know, 708 00:41:43,560 --> 00:41:51,820 all right, something is very weird in this code. It's also low bandwidth, meaning outguess, 709 00:41:51,820 --> 00:41:55,280 which embeds into JPEGs, and that's one bit of information for everything. 710 00:41:55,300 --> 00:41:58,100 17 bits of image, whereas hidden.