1 00:00:00,000 --> 00:00:07,720 So, my name is Sergei Bratus. I work for Dartmouth College, and it's actually a lucky coincidence that I get to speak right after this ARP talk. 2 00:00:08,680 --> 00:00:17,240 Because, if you remember, if you were here for the last talk, it was about a covert channel, or at least the part that I got. 3 00:00:18,000 --> 00:00:26,160 A covert channel in ARP. Well, in my tool that I'm going to demo today, such a covert channel would really, really stick out. 4 00:00:27,320 --> 00:00:33,240 And I hope to explain why, and I hope to give some math to prop it up. 5 00:00:33,680 --> 00:00:44,080 So, this is called Entropy-Based Data Organization for Browsing Logs and Packet Captures, and I got this subtitle. 6 00:00:45,320 --> 00:00:51,900 Every year I learn something new at DEF CON. FTW is what I learned this year, so, for the win. 7 00:00:55,000 --> 00:00:55,500 And, 8 00:00:55,580 --> 00:00:56,140 I'm going to show you a little bit of what I learned this year. 9 00:00:56,160 --> 00:01:03,800 What I'm going to do is discuss the state of actual log browsing that you get with free tools, and then see how we can improve it. 10 00:01:04,140 --> 00:01:05,900 So, what is this all about? 11 00:01:07,120 --> 00:01:11,600 And if you'll excuse me, I'll sit so that I can operate the demo. 12 00:01:15,500 --> 00:01:16,860 So, what is this all about? 13 00:01:19,860 --> 00:01:22,760 What is this all about? 14 00:01:22,760 --> 00:01:33,660 Um, we want to design a better interface for browsing logs and capture cap, uh, cap, what? 15 00:01:38,100 --> 00:01:39,800 Okay, where does my mouse go? 16 00:01:41,260 --> 00:01:47,140 Um, okay. Logs and, um, and, uh, packet captures. 17 00:01:47,680 --> 00:01:52,740 And we want it to be a slightly smarter interface than what you get with, uh, other real words. 18 00:01:52,740 --> 00:01:55,180 Uh, Wireshark, uh, grep, and so on. 19 00:01:55,320 --> 00:02:03,180 In that, I would like to see anomalies, or whatever passes for interesting data, in my data set first. 20 00:02:03,500 --> 00:02:08,440 And then I want to be made aware of correlations and where they break. 21 00:02:09,060 --> 00:02:15,040 So, there are many data fields in a typical log record, and, um, many of them are correlated. 22 00:02:17,740 --> 00:02:19,700 And how am I proposing to do that? 23 00:02:20,020 --> 00:02:22,720 Well, I'm proposing to do that by designing a data set. 24 00:02:22,720 --> 00:02:31,260 By designing the interface around decision trees, which is how people think about classification, really, in their minds. 25 00:02:31,560 --> 00:02:36,880 And about basic statistics for, uh, frequency distribution and correlation. 26 00:02:37,300 --> 00:02:40,160 And for that, I propose entropy and friends. 27 00:02:42,640 --> 00:02:44,440 How did this all start? 28 00:02:44,640 --> 00:02:48,940 Well, my wife, um, ran a Tor node at Dartmouth, thanks to Roger. 29 00:02:49,260 --> 00:02:52,700 And we, she kept getting frantic messages from the system. 30 00:02:52,720 --> 00:02:54,500 She said, man, you know, your machine is compromised. 31 00:02:54,640 --> 00:02:55,580 Shut everything down. 32 00:02:55,780 --> 00:02:56,860 There's IRC traffic. 33 00:02:57,580 --> 00:03:00,180 And, of course, we all know that IRC is evil. 34 00:03:01,780 --> 00:03:09,660 Uh, but that stirred us thinking, okay, uh, IRC has, um, Tor has a really interesting traffic mix. 35 00:03:09,860 --> 00:03:13,860 Non-standard ports, uh, encrypted traffic, all sorts of stuff. 36 00:03:14,000 --> 00:03:22,100 If we wanted to check that nothing but Tor, or most likely Tor, was leaving our machine, or coming in. 37 00:03:22,720 --> 00:03:23,260 How would we do that? 38 00:03:23,540 --> 00:03:25,800 We'd go classify things by session. 39 00:03:26,040 --> 00:03:30,860 Um, you know, cut away, uh, until we're left with everything that's not Tor. 40 00:03:31,320 --> 00:03:33,880 And Avarial isn't really that much help there. 41 00:03:34,100 --> 00:03:37,480 Because those filters can get really, really long. 42 00:03:37,800 --> 00:03:42,200 And I know people write really long, uh, TCP dump filters as well. 43 00:03:42,860 --> 00:03:45,520 So, how many page-long filters can you juggle? 44 00:03:46,240 --> 00:03:48,480 What you want to do is really classification. 45 00:03:48,980 --> 00:03:50,840 You know, sort the data out. 46 00:03:51,040 --> 00:03:51,860 This goes here. 47 00:03:51,860 --> 00:03:52,640 This goes there. 48 00:03:52,740 --> 00:03:53,480 This is no threat. 49 00:03:53,720 --> 00:03:54,500 This is well-known. 50 00:03:54,600 --> 00:03:55,960 Okay, this might be interesting. 51 00:03:56,880 --> 00:04:03,000 So, uh, the tool, I posit, should be based about classification as such. 52 00:04:06,060 --> 00:04:07,500 And here we go. 53 00:04:07,720 --> 00:04:11,120 Uh, before we go to the tool, uh, here's a disclaimer. 54 00:04:11,400 --> 00:04:12,960 These are really simple tricks. 55 00:04:13,400 --> 00:04:16,000 And do not expect a survey of research literature. 56 00:04:16,300 --> 00:04:21,600 I did put up some, uh, research paper references on the last slides. 57 00:04:21,860 --> 00:04:27,640 So, if you're interested to know how this is done in IDSs, IPSs that try to use entropy. 58 00:04:27,800 --> 00:04:32,300 As far as I know, all of these are test systems, uh, research systems. 59 00:04:33,420 --> 00:04:36,960 Uh, I'm not aware of any, uh, production system that uses this. 60 00:04:37,080 --> 00:04:38,400 But these things are promising. 61 00:04:38,600 --> 00:04:40,020 And who knows? 62 00:04:40,120 --> 00:04:44,440 I plan to give you enough math, uh, to at least get the basic intuition about the stuff 63 00:04:44,440 --> 00:04:45,440 and how you get around it. 64 00:04:47,680 --> 00:04:50,380 And here we go to the standard log browsing moves. 65 00:04:50,500 --> 00:04:51,840 And this is kind of like, you know. 66 00:04:51,840 --> 00:04:54,060 This is kind of like the hacker jeopardy, right? 67 00:04:54,160 --> 00:04:55,020 What does this do? 68 00:04:58,700 --> 00:05:02,420 Uh, can you see the logs? 69 00:05:02,620 --> 00:05:05,580 Uh, I can enlarge them, right? 70 00:05:05,980 --> 00:05:10,020 So, you just have to count to 11 to get the 11th token. 71 00:05:10,300 --> 00:05:15,860 Then sort, unique, sort, uh, binumeric. 72 00:05:16,220 --> 00:05:19,940 And you get the, the answer, or rather the question, 73 00:05:19,940 --> 00:05:27,780 is this is the number of successful logins via SSH, uh, by IP address. 74 00:05:28,000 --> 00:05:29,420 Broken down by IP address. 75 00:05:29,660 --> 00:05:34,320 So, uh, we look for this kind of information all the time when we admin our systems. 76 00:05:35,000 --> 00:05:39,800 This is grep, and this is the Unix, uh, pipe length, uh, measuring contest. 77 00:05:42,880 --> 00:05:47,240 Alternatively, if you've parsed your logs, and they're sitting nicely in a database, 78 00:05:48,260 --> 00:05:49,100 like this, 79 00:05:49,940 --> 00:05:52,540 uh, then, uh, you can reach for your where clause, 80 00:05:53,860 --> 00:05:56,520 and select count as count, 81 00:05:57,040 --> 00:05:58,760 IP from log data, 82 00:05:58,820 --> 00:06:00,340 group by IP, 83 00:06:00,660 --> 00:06:05,020 uh, that will, uh, get you the same thing as, uh, awking and unicking, 84 00:06:05,140 --> 00:06:07,740 and order by, uh, count. 85 00:06:07,900 --> 00:06:10,020 And then you've got your little table. 86 00:06:10,860 --> 00:06:15,320 And, uh, you know, as many times as you have to get a, uh, useful statistic, 87 00:06:15,880 --> 00:06:19,360 you have to run a query or write a Unix log pipe. 88 00:06:20,360 --> 00:06:22,540 And, of course, you have to parse syslogs, 89 00:06:22,540 --> 00:06:26,500 and, uh, in order to build the tools that I'm going to talk about, 90 00:06:26,680 --> 00:06:31,020 uh, we built our own, uh, syslog parser and the pattern guesser 91 00:06:31,020 --> 00:06:32,880 that guessed those patterns. 92 00:06:33,000 --> 00:06:35,940 So this is an excerpt of the actual packet language, uh, pattern language, 93 00:06:36,120 --> 00:06:37,840 uh, that, uh, I'm using. 94 00:06:38,080 --> 00:06:40,180 But we can talk about this at another time. 95 00:06:40,300 --> 00:06:43,140 I tried some, I used to work with, uh, natural language processing, 96 00:06:43,300 --> 00:06:44,620 so I tried some of the tricks there, 97 00:06:45,440 --> 00:06:49,920 uh, to, uh, have the, uh, pattern guesser, uh, guessed those. 98 00:06:52,760 --> 00:06:55,180 But, basically, you know, this is what you do. 99 00:06:55,880 --> 00:07:00,200 Filter the data, group the data, count across the groups, 100 00:07:00,400 --> 00:07:02,080 sort, and then repeat. 101 00:07:02,440 --> 00:07:05,180 And this is the great cycle of log processing. 102 00:07:05,420 --> 00:07:08,480 You know, this, uh, snake, it's eating its tail, or a boris, 103 00:07:08,480 --> 00:07:10,420 or, uh, whatever it is called. 104 00:07:11,160 --> 00:07:14,980 Uh, you can do it with pipes, you can do it with, uh, where clauses, 105 00:07:15,260 --> 00:07:17,020 uh, but you can't really escape it. 106 00:07:19,700 --> 00:07:22,420 And this is what I, this is the case that I want to make. 107 00:07:22,780 --> 00:07:27,520 That trees are better than, uh, tables and pipes. 108 00:07:28,600 --> 00:07:30,360 And so here is my log tree. 109 00:07:32,420 --> 00:07:37,880 The, uh, this is the first tool that, um, uh, views, uh, parses log. 110 00:07:40,100 --> 00:07:44,120 So the actual log record is down there. 111 00:07:46,380 --> 00:07:47,000 And, uh, this is the first tool that, uh, views parsed syslog. 112 00:07:47,000 --> 00:07:50,820 And the grouping is, uh, done by a template. 113 00:07:51,300 --> 00:07:53,980 I will later show you how that template is derived. 114 00:07:54,620 --> 00:08:01,220 And you can see that, um, it's split by IP, then by user. 115 00:08:03,940 --> 00:08:07,240 It's a pretty, uh, long list, uh, for that particular node. 116 00:08:07,400 --> 00:08:12,020 It's sorted by, uh, the number of records, 117 00:08:12,380 --> 00:08:15,820 the number of actual, uh, log lines that ended up down there. 118 00:08:17,340 --> 00:08:26,260 So, uh, we see that 2,300 logins out of 6,000 119 00:08:26,780 --> 00:08:30,240 come from this single host, uh, in this data set. 120 00:08:30,380 --> 00:08:34,500 And the rest is, uh, by an order of magnitude, magnitude smaller. 121 00:08:36,100 --> 00:08:38,180 Uh, that's, that's interesting information. 122 00:08:38,560 --> 00:08:46,080 Of course, here, uh, you have, uh, ranges of distinct values. 123 00:08:47,000 --> 00:08:49,580 So you can see how many distinct values for port you have, 124 00:08:49,680 --> 00:08:55,380 how many distinct values for, um, user you have, 126 and so on. 125 00:08:56,020 --> 00:09:00,360 Well, so having one classification is good, 126 00:09:00,560 --> 00:09:04,980 but we might try to take another classification 127 00:09:06,240 --> 00:09:09,400 and see how they relate to each other. 128 00:09:09,980 --> 00:09:13,840 So I'm exporting my data to another window. 129 00:09:17,000 --> 00:09:20,780 And in this window, I will choose to regroup it. 130 00:09:26,580 --> 00:09:28,560 And here it's grouped by the user. 131 00:09:29,880 --> 00:09:37,380 And I would like to see where, uh, records from this user turn up. 132 00:09:38,960 --> 00:09:43,180 And if I scroll down, I should be able to see this. 133 00:09:43,920 --> 00:09:51,540 Seven here, one here, and, uh, so on and so forth. 134 00:09:51,880 --> 00:09:58,940 And what we could then do is, uh, look at other attributes 135 00:09:58,940 --> 00:10:02,320 and see by record type. 136 00:10:05,360 --> 00:10:10,700 And we see that, you know, there are so many, uh, public key logins. 137 00:10:10,700 --> 00:10:17,740 And this user that's generating those 2,000 logins is, uh, a major user. 138 00:10:18,080 --> 00:10:21,360 Actually, this user is almost always using the public key. 139 00:10:22,520 --> 00:10:26,420 Uh, what we also see is that there are some failed passwords 140 00:10:26,420 --> 00:10:28,780 and password logins from this user. 141 00:10:31,620 --> 00:10:34,520 And I'm going by the blue number. 142 00:10:34,760 --> 00:10:38,640 And this is failed password for user, uh, two. 143 00:10:38,640 --> 00:10:44,960 Well, so this is approximately anonymized. 144 00:10:45,840 --> 00:10:49,160 Can you guess what actual user this is? 145 00:10:50,540 --> 00:10:52,200 A four-letter user. 146 00:10:52,840 --> 00:10:53,520 Yes. 147 00:10:53,880 --> 00:10:58,780 So when you find, so it's clear why that user is using a public key. 148 00:10:58,860 --> 00:10:59,820 It's a maintenance script. 149 00:11:00,460 --> 00:11:03,400 And it runs from the administrator's console. 150 00:11:03,860 --> 00:11:08,520 And, in fact, if we split this by, uh, IP, 151 00:11:09,520 --> 00:11:16,760 uh, we see that, uh, most of those logins, uh, come from, uh, one and the same console. 152 00:11:17,000 --> 00:11:24,840 2,300 out of, um, right, uh, 2,900. 153 00:11:25,280 --> 00:11:26,120 This one. 154 00:11:26,380 --> 00:11:28,100 So we know the root's machine. 155 00:11:28,600 --> 00:11:30,100 But this is interesting. 156 00:11:30,200 --> 00:11:37,480 So apparently that admin went around and tried his password, uh, from, um, workstations and failed. 157 00:11:37,600 --> 00:11:38,160 Hmm, hmm. 158 00:11:39,080 --> 00:11:39,700 Anyway. 159 00:11:40,860 --> 00:11:54,060 So, uh, the claim is that trees are better for browsing logs even if they're really, really simple trees. 160 00:11:54,300 --> 00:12:04,480 And to back up this claim, I would say that humans always use, uh, trees when they think about classifications. 161 00:12:04,640 --> 00:12:08,320 So here is your protocol hierarchies dumped out of Wireshark. 162 00:12:08,320 --> 00:12:11,320 And here is the visualization of that graph. 163 00:12:11,740 --> 00:12:14,640 And you see that, uh, every time you look over statistics. 164 00:12:15,780 --> 00:12:19,100 And firewall decision trees is what people deal with all the time. 165 00:12:19,700 --> 00:12:23,040 You know, a record comes in and you apply a test. 166 00:12:23,920 --> 00:12:25,140 Is it from the DMZ? 167 00:12:25,380 --> 00:12:26,360 Uh, yes, no. 168 00:12:26,700 --> 00:12:28,200 Is it from the trusted network? 169 00:12:28,420 --> 00:12:28,820 Yes, no. 170 00:12:28,880 --> 00:12:29,520 Is it from others? 171 00:12:29,640 --> 00:12:30,040 Yes, no. 172 00:12:30,240 --> 00:12:36,760 Then you sort it by protocol and accept or deny or drop, uh, and so on and so forth. 173 00:12:36,760 --> 00:12:41,500 Uh, IP tables are living proof that this is what people do. 174 00:12:43,260 --> 00:12:48,560 So, uh, in the demo you just saw, this is your simple syslog. 175 00:12:49,740 --> 00:12:51,240 Groups are nodes. 176 00:12:51,700 --> 00:12:59,420 These are the same groups that you will do with unique and sort or select group by. 177 00:13:02,760 --> 00:13:06,740 Uh, I have another demo which is, uh, the, uh... 178 00:13:06,740 --> 00:13:09,640 Wireshark extra panel that does this. 179 00:13:09,800 --> 00:13:11,800 But that one actually does a lot more. 180 00:13:11,940 --> 00:13:14,680 It tries to get the optimal tree and we'll get to that. 181 00:13:16,580 --> 00:13:21,340 Uh, and they are sorted by, uh, the number of records that end up there. 182 00:13:21,460 --> 00:13:23,540 The records themselves become leaves. 183 00:13:24,660 --> 00:13:26,820 And, uh, this is what's going on. 184 00:13:27,860 --> 00:13:34,760 When you want to run a query, say, pick out a particular IP, you're going down a branch. 185 00:13:36,740 --> 00:13:44,120 Uh, when you further refine that by, say, a user, you're going further down the branch, uh, in the subtree. 186 00:13:44,260 --> 00:13:55,240 And so you, if you remember this table from the previous example, this is what one branch looks like. 187 00:13:56,840 --> 00:14:06,660 I claim that it's so much better to have all the pipes in hand, uh, at the same time. 188 00:14:07,740 --> 00:14:13,920 And all the queries in hand at the same time because these queries are now branches. 189 00:14:14,860 --> 00:14:23,240 And any time when you actually open up a, uh, tree and select a node, this is actually a branch. 190 00:14:24,460 --> 00:14:25,720 This is actually a query. 191 00:14:25,980 --> 00:14:27,220 And you can write it out. 192 00:14:28,320 --> 00:14:32,880 And you can preserve, uh, and log all of your process of log browsing. 193 00:14:34,000 --> 00:14:36,360 Queries pick out a leaf or a node or a tree. 194 00:14:36,940 --> 00:14:41,120 And you keep them in your mind and on your screen at the same time. 195 00:14:41,640 --> 00:14:44,300 And this really, like, looks like a coin sorter. 196 00:14:45,920 --> 00:14:47,680 You know, a record comes in. 197 00:14:48,180 --> 00:14:49,700 Uh, you have a template. 198 00:14:49,920 --> 00:14:54,720 The template says, okay, first we'll, uh, sort everything by destination port. 199 00:14:55,180 --> 00:14:56,300 There you go, record. 200 00:14:58,320 --> 00:15:05,180 And then it gets into another coin sorter, which gets instantiated, uh, for it. 201 00:15:05,280 --> 00:15:06,720 And that's port A. 202 00:15:06,740 --> 00:15:09,080 Okay, now we're going to sort by source IP. 203 00:15:09,880 --> 00:15:12,280 And here you are, source IP. 204 00:15:12,780 --> 00:15:14,240 And here's another record. 205 00:15:14,420 --> 00:15:16,440 It travels down this path. 206 00:15:16,600 --> 00:15:18,140 These coin sorters are already there. 207 00:15:18,300 --> 00:15:21,620 So they happily direct it into a different branch. 208 00:15:22,240 --> 00:15:29,660 Uh, when another record comes along, a new sorter may be created just for it. 209 00:15:29,700 --> 00:15:30,580 That's a new group. 210 00:15:31,180 --> 00:15:34,100 That's a new intermediary node of the tree. 211 00:15:34,620 --> 00:15:35,780 And so it goes. 212 00:15:37,840 --> 00:15:43,900 And the good part is that you can save this template and apply it again and again. 213 00:15:44,100 --> 00:15:49,920 If you think you found the right way to classify your nodes, that's how it does it. 214 00:15:51,260 --> 00:16:01,280 You can, uh, save, send it to somebody else, uh, if they have my tool, uh, which is free, uh, and, uh, needs debugging. 215 00:16:02,600 --> 00:16:06,720 Uh, they apply the, um, uh, the template. 216 00:16:06,720 --> 00:16:12,920 And they have the benefit of your, uh, decision tree for classifying your log. 217 00:16:13,940 --> 00:16:17,780 And the question here is which tree to choose. 218 00:16:18,400 --> 00:16:28,140 Should you choose to split first by user or by IP, then by user? 219 00:16:29,100 --> 00:16:32,200 This is all about choosing the best grouping. 220 00:16:33,100 --> 00:16:36,080 And the grouping should be such that the interesting stuff, 221 00:16:36,080 --> 00:16:37,420 jumps out at you. 222 00:16:38,600 --> 00:16:41,720 And this is what the rest of the talk is about. 223 00:16:42,120 --> 00:16:47,820 Simple heuristics, uh, for choosing the best, uh, grouping, the best classification. 224 00:16:49,100 --> 00:16:59,160 And so, uh, before we do this, why don't I, uh, try to actually demonstrate how it works. 225 00:17:04,460 --> 00:17:18,240 So, this is ethereal, except when you open a capture file, it asks you, 226 00:17:18,360 --> 00:17:26,140 well, which sort of feature, which, uh, set of features would you like me to investigate, uh, 227 00:17:27,240 --> 00:17:29,140 to participate in the capture? 228 00:17:29,140 --> 00:17:30,220 And, uh, the construction of the best template. 229 00:17:30,900 --> 00:17:34,720 And here you say, okay, uh, this is a wireless capture. 230 00:17:34,960 --> 00:17:39,560 So, give me 8211, uh, and, uh, IP. 231 00:17:40,900 --> 00:17:41,820 It's clear enough. 232 00:17:42,040 --> 00:17:45,180 Let's look at the, um, levels two and three. 233 00:17:48,780 --> 00:17:51,100 And, uh, it does its magic. 234 00:17:52,580 --> 00:17:57,660 And gives you this tree representation of your data set. 235 00:17:57,660 --> 00:18:12,460 And its point is to make this the most conspicuous tree in which, um, anomalies would jump out. 236 00:18:12,680 --> 00:18:15,220 And here, you've got just two branches. 237 00:18:16,500 --> 00:18:19,060 The reserved, the by IP flags. 238 00:18:19,200 --> 00:18:20,200 Can you actually see this? 239 00:18:21,580 --> 00:18:22,220 Excellent. 240 00:18:22,520 --> 00:18:26,820 Uh, I was thinking that I'd have to use magnification, KMAG. 241 00:18:26,820 --> 00:18:28,100 But it messes up my screen. 242 00:18:29,460 --> 00:18:31,820 So, IP flags reserved bit. 243 00:18:32,380 --> 00:18:34,220 Right, there are no evil bits here. 244 00:18:34,720 --> 00:18:36,760 Right, remember the evil bit RFC. 245 00:18:37,860 --> 00:18:41,280 But, in one of those, it's not even there. 246 00:18:41,400 --> 00:18:42,260 How is that? 247 00:18:43,240 --> 00:18:45,380 And so we get to see this packet. 248 00:18:46,420 --> 00:18:48,000 Source, destination, something. 249 00:18:48,500 --> 00:18:50,360 Let's see what that packet looks like. 250 00:18:50,460 --> 00:18:51,680 Let's find it in packet list. 251 00:18:53,600 --> 00:18:55,240 And, oh yeah, for sure. 252 00:18:55,300 --> 00:18:55,820 Sure enough. 253 00:18:55,820 --> 00:18:57,520 It's a bogus IP header. 254 00:18:57,780 --> 00:18:58,680 Length zero. 255 00:18:58,880 --> 00:18:59,660 This is not IP. 256 00:18:59,840 --> 00:19:00,320 What is it? 257 00:19:01,800 --> 00:19:02,340 Right. 258 00:19:02,580 --> 00:19:04,220 It looks like it's IP. 259 00:19:04,480 --> 00:19:06,320 Uh, the snap header says so. 260 00:19:07,780 --> 00:19:08,320 Right. 261 00:19:08,540 --> 00:19:10,960 But, uh, it starts. 262 00:19:16,080 --> 00:19:17,540 With version zero. 263 00:19:18,800 --> 00:19:21,280 So, we found an anomalous packet. 264 00:19:22,740 --> 00:19:24,220 And we can delete it. 265 00:19:24,360 --> 00:19:25,800 Um, which I am not going to do. 266 00:19:25,820 --> 00:19:26,880 And, uh, proceed. 267 00:19:27,900 --> 00:19:30,340 Or we can look into the other group. 268 00:19:31,340 --> 00:19:34,880 And look at, uh, oh, what do we have here? 269 00:19:35,060 --> 00:19:36,200 We have some IP fragmentation. 270 00:19:36,620 --> 00:19:39,880 There are three IP fragments in this set. 271 00:19:40,040 --> 00:19:43,460 And the rest is, uh, good clean stuff. 272 00:19:43,780 --> 00:19:46,440 And so, we go in deeper and deeper. 273 00:19:47,820 --> 00:19:49,900 Uh, if we're tired of this. 274 00:19:50,040 --> 00:19:51,440 Here, there are more fragments. 275 00:19:51,640 --> 00:19:55,080 Of course, everything that's associated with fragmentation will jump out at us. 276 00:19:55,080 --> 00:19:58,620 And these packets are really anomalous for this capture. 277 00:19:58,740 --> 00:20:01,100 Because the rest of the data is not like that. 278 00:20:03,500 --> 00:20:10,680 Uh, what we can do is we can check the ranges of other features that occur here. 279 00:20:14,020 --> 00:20:17,340 And see that, sort them by the number of unique values. 280 00:20:17,600 --> 00:20:20,460 We see we have 3,000 IP IDs. 281 00:20:21,240 --> 00:20:22,880 Uh, 2,900. 282 00:20:24,420 --> 00:20:26,260 WLAN, uh, sequence numbers. 283 00:20:26,780 --> 00:20:29,700 So, apparently there is some retransmission going on. 284 00:20:29,880 --> 00:20:31,120 As we will see. 285 00:20:31,400 --> 00:20:33,000 Uh, so many links. 286 00:20:34,300 --> 00:20:36,900 And, uh, so many TTLs. 287 00:20:38,040 --> 00:20:39,880 21 distinct TTLs. 288 00:20:40,080 --> 00:20:41,220 Well, what are they? 289 00:20:42,520 --> 00:20:45,100 Let's, uh, reshape the tree and look. 290 00:20:46,700 --> 00:20:51,060 And so, the largest number of packets in this capture. 291 00:20:51,060 --> 00:20:53,920 Uh, almost a half. 292 00:20:54,200 --> 00:20:59,800 2,300 out of 5,000 has TTL 255. 293 00:21:00,300 --> 00:21:01,780 Well, that's something to know. 294 00:21:01,960 --> 00:21:03,460 What protocol is that? 295 00:21:03,680 --> 00:21:05,280 Well, let's look at the protocols. 296 00:21:05,700 --> 00:21:07,580 We have only 5 protocols. 297 00:21:08,520 --> 00:21:12,000 And we can see, uh, what these things are. 298 00:21:14,500 --> 00:21:16,320 Uh, 11 hex. 299 00:21:16,760 --> 00:21:18,000 That's, uh, 17. 300 00:21:19,180 --> 00:21:20,340 That's, uh... 301 00:21:21,060 --> 00:21:21,520 UDP. 302 00:21:23,420 --> 00:21:23,940 6. 303 00:21:24,680 --> 00:21:25,740 Uh, TCP. 304 00:21:26,660 --> 00:21:27,180 Understandable. 305 00:21:30,200 --> 00:21:31,940 Actually, 67 hex. 306 00:21:32,100 --> 00:21:32,580 What is that? 307 00:21:33,300 --> 00:21:34,340 59 hex. 308 00:21:34,980 --> 00:21:37,440 And one packet has protocol undefined. 309 00:21:37,460 --> 00:21:40,460 But we know that's the, uh, malformed packet that we've seen before. 310 00:21:40,720 --> 00:21:44,140 So, we could see where these guys all go. 311 00:21:44,600 --> 00:21:45,760 I will mark them. 312 00:21:46,200 --> 00:21:48,600 And they will jump out at us in the tree. 313 00:21:49,340 --> 00:21:50,320 And, uh... 314 00:21:50,320 --> 00:21:52,800 Uh, this 67 with the TTL 1. 315 00:21:53,620 --> 00:21:54,980 Well, what is that guy? 316 00:21:55,880 --> 00:21:57,680 Let's find it in the packet list. 317 00:21:58,040 --> 00:21:59,280 Oh, it's a PIM packet. 318 00:22:00,720 --> 00:22:02,080 And what are those guys? 319 00:22:06,940 --> 00:22:08,740 Uh, those guys... 320 00:22:08,740 --> 00:22:09,980 There are five of them. 321 00:22:10,500 --> 00:22:11,720 And here they are. 322 00:22:12,360 --> 00:22:13,800 And let's find them again. 323 00:22:14,300 --> 00:22:15,800 And this is OSPF. 324 00:22:17,140 --> 00:22:18,100 Which, uh... 325 00:22:18,100 --> 00:22:19,340 I'm sure many of you... 326 00:22:19,340 --> 00:22:20,340 Could have told me... 327 00:22:20,340 --> 00:22:21,980 Uh, just by looking at the hex. 328 00:22:23,100 --> 00:22:23,620 Maybe. 329 00:22:24,520 --> 00:22:25,880 Is there, uh... 330 00:22:25,880 --> 00:22:27,880 A drinking game tonight? 331 00:22:28,220 --> 00:22:29,520 Or was it yesterday? 332 00:22:30,880 --> 00:22:31,640 Too bad. 333 00:22:33,880 --> 00:22:34,920 Uh, anyway... 334 00:22:35,940 --> 00:22:36,460 So... 335 00:22:38,260 --> 00:22:40,660 Uh, I would like to direct your attention... 336 00:22:40,660 --> 00:22:42,340 Again, to the fact... 337 00:22:42,340 --> 00:22:45,400 That you can ask the algorithm... 338 00:22:45,400 --> 00:22:47,700 To reshape this tree for you at any level. 339 00:22:47,700 --> 00:22:52,220 And so, if we decide to look at these 53 packets... 340 00:22:52,220 --> 00:22:54,440 With TTL of 1... 341 00:22:55,300 --> 00:22:58,220 Uh, we can apply the algorithm under this node. 342 00:22:59,640 --> 00:23:00,820 And, uh... 343 00:23:00,820 --> 00:23:02,820 I'm not going to modify the protocol... 344 00:23:02,820 --> 00:23:03,820 Uh, the feature choice. 345 00:23:05,780 --> 00:23:08,600 And we see how these packets distribute. 346 00:23:08,880 --> 00:23:11,820 And the feature chosen now was... 347 00:23:11,820 --> 00:23:13,680 Uh, WLAN... 348 00:23:14,720 --> 00:23:15,360 Um... 349 00:23:16,120 --> 00:23:16,760 FC... 350 00:23:16,760 --> 00:23:18,380 The, uh... 351 00:23:18,380 --> 00:23:20,480 Control code from the beginning of the packet. 352 00:23:20,820 --> 00:23:21,460 Right? 353 00:23:21,660 --> 00:23:22,700 Uh, and, uh... 354 00:23:22,700 --> 00:23:24,780 These things distribute into, uh... 355 00:23:24,780 --> 00:23:25,900 Frames, uh... 356 00:23:25,900 --> 00:23:27,680 Destined for the distribution system. 357 00:23:27,880 --> 00:23:30,320 And not a distance for the distribution system. 358 00:23:30,800 --> 00:23:32,140 What is that thing? 359 00:23:32,480 --> 00:23:34,320 That thing is, uh... 360 00:23:34,320 --> 00:23:34,860 This, uh... 361 00:23:34,860 --> 00:23:36,020 SSDP, uh... 362 00:23:36,320 --> 00:23:36,700 Packet. 363 00:23:38,040 --> 00:23:41,340 And so, we go from one, uh... 364 00:23:41,340 --> 00:23:42,320 Subtree to another. 365 00:23:42,560 --> 00:23:43,840 And we look for anomalies. 366 00:23:44,320 --> 00:23:46,520 And there are two more, uh... 367 00:23:46,760 --> 00:23:47,260 Examples to show. 368 00:23:47,880 --> 00:23:49,600 Uh, which, uh... 369 00:23:49,600 --> 00:23:50,920 Uh, we... 370 00:23:50,920 --> 00:23:53,100 I hope we'll get to, um... 371 00:23:53,560 --> 00:23:54,640 Uh, as we proceed. 372 00:23:56,360 --> 00:23:56,960 Uh... 373 00:23:57,620 --> 00:23:59,300 It's very useful... 374 00:23:59,300 --> 00:24:01,380 To be able to summarize... 375 00:24:02,540 --> 00:24:04,360 The distribution of unique values. 376 00:24:04,900 --> 00:24:06,360 So, uh... 377 00:24:06,360 --> 00:24:09,660 Say, you know that there are 319 unique, uh... 378 00:24:09,660 --> 00:24:10,380 Source, uh... 379 00:24:10,380 --> 00:24:10,860 Packets. 380 00:24:10,940 --> 00:24:13,500 And you get this information from the statistics... 381 00:24:13,500 --> 00:24:14,200 Uh... 382 00:24:14,660 --> 00:24:16,120 Summary in Wireshark. 383 00:24:16,760 --> 00:24:19,040 But here, it's correlated with this, uh... 384 00:24:19,040 --> 00:24:20,540 Template view of the tree. 385 00:24:24,260 --> 00:24:24,820 So... 386 00:24:24,820 --> 00:24:25,860 Now... 387 00:24:26,620 --> 00:24:28,120 How does this heuristic work? 388 00:24:28,340 --> 00:24:29,400 And what is the magic? 389 00:24:29,620 --> 00:24:31,500 How does it pick the right tree? 390 00:24:31,560 --> 00:24:32,320 Uh, how do... 391 00:24:32,320 --> 00:24:33,020 Or the wrong tree. 392 00:24:33,160 --> 00:24:34,180 As it happens. 393 00:24:35,260 --> 00:24:35,820 Um... 394 00:24:35,820 --> 00:24:36,660 Um... 395 00:24:36,660 --> 00:24:39,700 We want to define the browsing problem. 396 00:24:40,040 --> 00:24:40,600 Mathematically. 397 00:24:40,900 --> 00:24:41,740 I'm a mathematician. 398 00:24:42,120 --> 00:24:43,860 A former mathematician, if you like. 399 00:24:45,180 --> 00:24:46,600 I do, uh... 400 00:24:46,600 --> 00:24:48,380 Low-level kernel and, uh... 401 00:24:48,380 --> 00:24:50,260 Networking research these days. 402 00:24:50,800 --> 00:24:51,420 But... 403 00:24:52,340 --> 00:24:53,320 You know... 404 00:24:53,320 --> 00:24:55,600 It's nice to be able to define the problem... 405 00:24:55,600 --> 00:24:56,300 Mathematically. 406 00:24:56,520 --> 00:24:58,940 It's good to find a proper statistic for it. 407 00:24:59,260 --> 00:25:01,140 And we look at this picture... 408 00:25:01,140 --> 00:25:01,640 Right? 409 00:25:01,740 --> 00:25:02,880 And what do we see? 410 00:25:03,060 --> 00:25:05,660 We see this little scroll bar thingy... 411 00:25:05,660 --> 00:25:06,820 That's just... 412 00:25:06,820 --> 00:25:07,360 Uh... 413 00:25:07,360 --> 00:25:09,740 Not showing us the rest... 414 00:25:09,740 --> 00:25:10,840 Of the data. 415 00:25:11,000 --> 00:25:13,060 We have no idea what's down there. 416 00:25:13,580 --> 00:25:14,200 Uh... 417 00:25:14,200 --> 00:25:16,280 And the lines that you're interested in... 418 00:25:16,600 --> 00:25:16,900 Are... 419 00:25:16,900 --> 00:25:19,220 Maybe twenty pages away... 420 00:25:19,220 --> 00:25:19,840 Uh... 421 00:25:19,840 --> 00:25:21,860 Each surrounded by a page of chaff... 422 00:25:21,860 --> 00:25:24,240 In a twisty little maze of messages... 423 00:25:24,240 --> 00:25:25,320 Passages... 424 00:25:25,320 --> 00:25:27,060 Whoever played, uh... 425 00:25:27,600 --> 00:25:28,680 Adventure here... 426 00:25:30,060 --> 00:25:30,660 All... 427 00:25:30,660 --> 00:25:31,340 All the same... 428 00:25:31,340 --> 00:25:32,580 Or not exactly the same... 429 00:25:32,580 --> 00:25:32,920 Right? 430 00:25:33,340 --> 00:25:34,800 So this is the face of the enemy. 431 00:25:35,640 --> 00:25:38,300 You're uncertain about what you've got in this. 432 00:25:38,460 --> 00:25:38,940 And... 433 00:25:38,940 --> 00:25:40,980 You can use summarization tools... 434 00:25:40,980 --> 00:25:43,320 But you would like them to be integrated with your interface. 435 00:25:43,720 --> 00:25:45,240 You don't want to write... 436 00:25:45,240 --> 00:25:46,060 So many... 437 00:25:46,060 --> 00:25:46,660 Uh... 438 00:25:46,660 --> 00:25:47,220 Pipes... 439 00:25:47,220 --> 00:25:47,860 And queries. 440 00:25:49,340 --> 00:25:50,640 And of course you can sort. 441 00:25:51,420 --> 00:25:51,900 Sorting... 442 00:25:51,900 --> 00:25:52,500 Clicking... 443 00:25:52,500 --> 00:25:52,740 Uh... 444 00:25:52,740 --> 00:25:53,480 On the tab... 445 00:25:53,480 --> 00:25:53,880 Uh... 446 00:25:53,880 --> 00:25:54,880 Sorts the values... 447 00:25:54,880 --> 00:25:56,240 And you can see the max and the min... 448 00:25:56,240 --> 00:25:56,800 Uh... 449 00:25:56,800 --> 00:25:57,460 According to... 450 00:25:57,460 --> 00:25:58,600 Alphabetic order. 451 00:25:59,540 --> 00:26:00,020 And... 452 00:26:00,020 --> 00:26:02,700 You can drill down with filters to an interesting group. 453 00:26:02,880 --> 00:26:03,580 And again... 454 00:26:03,580 --> 00:26:04,420 Each filter... 455 00:26:04,420 --> 00:26:06,580 Takes you down one branch... 456 00:26:06,580 --> 00:26:08,980 Of the classification tree that you keep in your mind. 457 00:26:09,140 --> 00:26:10,160 So why not on screen? 458 00:26:10,600 --> 00:26:12,480 And all the while there is this key problem. 459 00:26:12,620 --> 00:26:13,200 Where to start? 460 00:26:13,780 --> 00:26:15,220 Which column or protocol... 461 00:26:15,220 --> 00:26:15,620 To pick? 462 00:26:16,020 --> 00:26:16,460 With... 463 00:26:16,460 --> 00:26:16,700 Uh... 464 00:26:16,700 --> 00:26:17,620 Wireshark you can... 465 00:26:17,620 --> 00:26:17,880 Uh... 466 00:26:17,880 --> 00:26:19,740 Get as many columns up here as you like. 467 00:26:19,860 --> 00:26:20,800 But where to start looking? 468 00:26:21,820 --> 00:26:23,680 And how to group those things? 469 00:26:23,880 --> 00:26:25,040 Should you group them by IP? 470 00:26:25,180 --> 00:26:26,140 Should you group them by source? 471 00:26:26,280 --> 00:26:28,240 Should you group them by an obscure protocol feature? 472 00:26:28,900 --> 00:26:31,160 We'd like to automate guessing one and two. 473 00:26:31,220 --> 00:26:31,540 And it's... 474 00:26:31,540 --> 00:26:32,360 Really guessing. 475 00:26:32,840 --> 00:26:34,820 It's a mere heuristics... 476 00:26:34,820 --> 00:26:35,420 But... 477 00:26:35,420 --> 00:26:36,360 You know... 478 00:26:36,360 --> 00:26:37,440 It's better than nothing. 479 00:26:37,560 --> 00:26:37,980 And it... 480 00:26:38,640 --> 00:26:39,080 Works... 481 00:26:39,080 --> 00:26:39,660 Uh... 482 00:26:39,660 --> 00:26:40,440 In many cases. 483 00:26:41,320 --> 00:26:41,760 So... 484 00:26:41,760 --> 00:26:43,360 What we want to do then... 485 00:26:44,000 --> 00:26:44,660 Is to... 486 00:26:45,220 --> 00:26:45,640 Automate uncertainty. 487 00:26:46,360 --> 00:26:48,660 And the trivial observation here is... 488 00:26:48,660 --> 00:26:51,200 Most lines in a large log will not be examined directly. 489 00:26:51,460 --> 00:26:51,680 Ever. 490 00:26:52,340 --> 00:26:56,500 And one needs to convince oneself that he's seen everything interesting. 491 00:26:57,000 --> 00:26:59,920 And you'd like to jump right to the interesting stuff. 492 00:27:00,320 --> 00:27:02,060 And this is what your log looks like. 493 00:27:02,520 --> 00:27:03,880 There is redundancy. 494 00:27:03,880 --> 00:27:04,480 There is repetition. 495 00:27:06,080 --> 00:27:07,040 And somewhere... 496 00:27:07,520 --> 00:27:10,460 There is something that's not like the rest of the stuff. 497 00:27:11,300 --> 00:27:13,540 And most of the time you want to see it. 498 00:27:13,540 --> 00:27:17,480 And so we must deal with uncertainty versus redundancy. 499 00:27:17,480 --> 00:27:18,940 We want to compress data. 500 00:27:19,800 --> 00:27:23,040 And there is actually a statistic that deals with that. 501 00:27:23,140 --> 00:27:24,320 That statistic is entropy. 502 00:27:27,080 --> 00:27:27,760 Uh... 503 00:27:28,540 --> 00:27:28,920 Entropy... 504 00:27:29,540 --> 00:27:30,240 Is... 505 00:27:30,240 --> 00:27:31,320 Speaking informally. 506 00:27:31,420 --> 00:27:34,980 The number of bits to encode a data item... 507 00:27:35,220 --> 00:27:37,060 Under optimal encoding... 508 00:27:37,060 --> 00:27:41,260 In a really, really large batch of data like that. 509 00:27:41,340 --> 00:27:43,260 Distributed statistically like that. 510 00:27:43,540 --> 00:27:47,580 So, here is a stream of A's, B's, A's, B's, C's, and D's... 511 00:27:47,580 --> 00:27:50,220 In which A's, B's, C's, and D's... 512 00:27:52,440 --> 00:27:53,680 Appear equi-probably. 513 00:27:53,880 --> 00:27:55,700 So there is an equal chance... 514 00:27:56,220 --> 00:27:56,940 This is the probability. 515 00:27:57,240 --> 00:27:57,880 This is the chance. 516 00:27:57,900 --> 00:28:00,820 This is the relative amount of A's, B's, and C's... 517 00:28:00,820 --> 00:28:02,120 That you'll see in the stream. 518 00:28:02,320 --> 00:28:04,240 And since they are all equi-probable... 519 00:28:04,240 --> 00:28:06,460 You have to encode each one of them... 520 00:28:07,300 --> 00:28:09,360 And it's two bits per symbol... 521 00:28:09,360 --> 00:28:12,760 Of four possibilities... 522 00:28:13,540 --> 00:28:13,940 Two bits. 523 00:28:16,140 --> 00:28:18,940 A number from one to four can be encoded. 524 00:28:18,940 --> 00:28:20,900 You need two bits to encode that. 525 00:28:21,360 --> 00:28:21,880 But... 526 00:28:21,880 --> 00:28:24,360 If the distribution is non-uniform... 527 00:28:24,360 --> 00:28:26,860 A's are a lot more frequent... 528 00:28:26,860 --> 00:28:29,540 Then, you can modify your encoding... 529 00:28:29,540 --> 00:28:32,800 To take advantage of those long runs of A. 530 00:28:33,840 --> 00:28:35,060 And you say, oh... 531 00:28:35,060 --> 00:28:36,540 At this point... 532 00:28:37,340 --> 00:28:39,140 There are so many A's following. 533 00:28:39,440 --> 00:28:41,560 And you have a really short code for that. 534 00:28:41,560 --> 00:28:46,380 And your basic zip compressor will do it for you. 535 00:28:46,500 --> 00:28:49,260 It will pick that sort of special encoding... 536 00:28:49,260 --> 00:28:51,880 To take advantage of the long runs of the data. 537 00:28:52,540 --> 00:28:54,380 English is like that. 538 00:28:55,140 --> 00:28:56,440 English is redundant. 539 00:28:57,300 --> 00:29:01,300 Depending on how you define the entropy of a natural language... 540 00:29:02,260 --> 00:29:06,400 You get 0.6 to 1.6 bits per character. 541 00:29:09,580 --> 00:29:10,200 And... 542 00:29:10,200 --> 00:29:12,760 The really interesting thing is... 543 00:29:12,760 --> 00:29:15,860 How you define the entropy of the natural language. 544 00:29:16,100 --> 00:29:18,280 In this sequence here... 545 00:29:19,560 --> 00:29:21,480 The assumption was that... 546 00:29:21,480 --> 00:29:23,200 They are thrown out... 547 00:29:23,200 --> 00:29:25,040 According to the distribution... 548 00:29:25,040 --> 00:29:25,700 But randomly. 549 00:29:25,800 --> 00:29:27,000 Not looking at the previous one. 550 00:29:27,220 --> 00:29:28,120 In English... 551 00:29:28,120 --> 00:29:29,320 When you said a word... 552 00:29:29,320 --> 00:29:31,160 You have to continue... 553 00:29:31,160 --> 00:29:33,460 In a restricted number of ways. 554 00:29:33,900 --> 00:29:36,080 Otherwise, you're speaking gibberish. 555 00:29:37,680 --> 00:29:39,440 The same applies to letters. 556 00:29:40,200 --> 00:29:40,520 So... 557 00:29:40,520 --> 00:29:42,260 These are different models of English. 558 00:29:42,440 --> 00:29:47,420 If we just observe the distribution of characters... 559 00:29:47,970 --> 00:29:49,120 That's the English we get. 560 00:29:50,200 --> 00:29:53,000 Each letter is chosen independently of the previous one. 561 00:29:53,060 --> 00:29:54,140 But as often... 562 00:29:54,140 --> 00:29:57,400 As it occurs in the natural language. 563 00:29:57,640 --> 00:29:58,540 This is bigrams. 564 00:29:58,620 --> 00:29:59,700 We look at the previous letter. 565 00:30:00,080 --> 00:30:00,700 Okro... 566 00:30:00,700 --> 00:30:01,340 Li... 567 00:30:01,340 --> 00:30:01,700 Er... 568 00:30:01,700 --> 00:30:02,340 Mmm... 569 00:30:03,200 --> 00:30:04,020 Doesn't work. 570 00:30:06,020 --> 00:30:06,640 Here... 571 00:30:07,010 --> 00:30:07,320 Yeah... 572 00:30:08,060 --> 00:30:08,680 Um... 573 00:30:08,680 --> 00:30:09,200 Um... 574 00:30:09,200 --> 00:30:13,020 My Klingon vocabulary is just about 10 words. 575 00:30:13,500 --> 00:30:14,260 Uh... 576 00:30:14,260 --> 00:30:15,060 Nukneh... 577 00:30:16,000 --> 00:30:16,760 Uh... 578 00:30:16,760 --> 00:30:16,900 Um... 579 00:30:17,680 --> 00:30:18,200 Uh... 580 00:30:18,200 --> 00:30:18,920 Kapla... 581 00:30:20,380 --> 00:30:21,860 I can probably... 582 00:30:21,860 --> 00:30:22,300 Oh... 583 00:30:22,300 --> 00:30:22,860 Tahpah... 584 00:30:22,860 --> 00:30:23,480 Tahbeh... 585 00:30:23,480 --> 00:30:24,760 To be or not to be. 586 00:30:25,640 --> 00:30:28,620 That's just about all of it. 587 00:30:29,360 --> 00:30:31,940 I wrote the Klingon parser once... 588 00:30:31,940 --> 00:30:36,440 To help me read the translation of Hamlet in the... 589 00:30:36,440 --> 00:30:37,720 From the original Klingon. 590 00:30:38,940 --> 00:30:40,360 There is such a thing. 591 00:30:40,440 --> 00:30:41,000 And it exists. 592 00:30:41,180 --> 00:30:42,220 And if you look at it... 593 00:30:42,220 --> 00:30:43,480 Then you see that the... 594 00:30:43,480 --> 00:30:43,920 Uh... 595 00:30:44,580 --> 00:30:47,000 Earthlings have really spoiled it. 596 00:30:47,100 --> 00:30:49,140 It's all about honor and revenge. 597 00:30:49,420 --> 00:30:52,420 And all of those noble Klingon things. 598 00:30:52,700 --> 00:30:55,920 And everything else is just this extra garbage thrown in. 599 00:30:57,220 --> 00:30:57,780 Uh... 600 00:30:58,780 --> 00:30:59,340 Trigrams. 601 00:31:00,900 --> 00:31:01,460 Uh... 602 00:31:01,460 --> 00:31:05,380 Here you see some words that start to resemble English words. 603 00:31:06,480 --> 00:31:08,260 And so you can go further. 604 00:31:08,680 --> 00:31:08,780 And... 605 00:31:08,780 --> 00:31:09,140 Uh... 606 00:31:09,140 --> 00:31:09,660 Uh... 607 00:31:09,660 --> 00:31:10,080 Look at this. 608 00:31:10,380 --> 00:31:10,820 Words... 609 00:31:10,820 --> 00:31:11,680 Unigrams. 610 00:31:11,900 --> 00:31:14,800 So these are words taken out of the bag randomly. 611 00:31:15,620 --> 00:31:16,060 Uh... 612 00:31:16,060 --> 00:31:18,580 These are words taken out of the bag looking at the previous word. 613 00:31:19,400 --> 00:31:21,200 And these are words looking at... 614 00:31:21,200 --> 00:31:24,160 Taken from the bag looking at the two previous words. 615 00:31:24,440 --> 00:31:25,680 And this is actually readable. 616 00:31:25,860 --> 00:31:29,940 The best film on television tonight is There Is No One Here Who Had a Little Bit of Fluff. 617 00:31:31,060 --> 00:31:31,500 Uh... 618 00:31:31,500 --> 00:31:33,140 This is almost grammatical. 619 00:31:33,800 --> 00:31:34,240 Anyway. 620 00:31:34,560 --> 00:31:35,000 So... 621 00:31:35,000 --> 00:31:35,800 Shannon's experiment. 622 00:31:36,480 --> 00:31:36,920 Which... 623 00:31:36,920 --> 00:31:37,180 Uh... 624 00:31:37,180 --> 00:31:37,740 Gave us... 625 00:31:37,740 --> 00:31:38,100 Uh... 626 00:31:38,100 --> 00:31:39,460 1.6 bits... 627 00:31:39,460 --> 00:31:40,100 Uh... 628 00:31:40,100 --> 00:31:40,520 Uh... 629 00:31:40,520 --> 00:31:41,100 Figure. 630 00:31:41,340 --> 00:31:48,140 Is based on how likely humans are to be wrong when predicting the next letter or word 631 00:31:48,140 --> 00:31:48,920 in the text. 632 00:31:49,080 --> 00:31:52,120 So you uncover it letter by letter. 633 00:31:52,260 --> 00:31:56,960 And you see how many times the guess is incorrect. 634 00:31:58,140 --> 00:32:04,800 So entropy measures uncertainty given some previous knowledge. 635 00:32:05,100 --> 00:32:06,900 Given some previous knowledge. 636 00:32:06,900 --> 00:32:07,120 Given some previous research. 637 00:32:07,120 --> 00:32:07,820 And you find that this data is the model of the data. 638 00:32:07,920 --> 00:32:10,640 It may be your mental model of English. 639 00:32:10,780 --> 00:32:13,020 It may be your mental model of your log. 640 00:32:13,400 --> 00:32:15,540 Which is a lot more interesting for our purposes. 641 00:32:18,560 --> 00:32:21,920 And people have already been doing that sort of thing. 642 00:32:22,100 --> 00:32:22,400 Right? 643 00:32:22,460 --> 00:32:26,100 In every log browsing tutorial, in every, uh... 644 00:32:26,100 --> 00:32:29,360 Incident response tutorial, you look at something like... 645 00:32:29,360 --> 00:32:33,320 Look at the most frequent and the least frequent values in the column or list. 646 00:32:33,540 --> 00:32:34,100 Now. 647 00:32:34,180 --> 00:32:35,560 What good is this advice? 648 00:32:36,320 --> 00:32:36,880 In every... 649 00:32:36,880 --> 00:32:39,780 if all those values are equiprobable. 650 00:32:41,600 --> 00:32:45,420 What good is this advice when there are thousands of those values? 651 00:32:45,760 --> 00:32:49,180 Maybe the thing is hiding somewhere in the middle. 652 00:32:49,420 --> 00:32:54,860 So it would be nice to begin with easier-to-understand columns or features, 653 00:32:56,160 --> 00:32:57,980 ones with a simpler distribution. 654 00:32:58,520 --> 00:33:01,920 And this is my suggestion that as implemented in that tool, 655 00:33:01,980 --> 00:33:03,140 you've seen that heuristic work, 656 00:33:03,140 --> 00:33:09,000 start with a data summary based on the columns with the simplest frequency value charts. 657 00:33:09,750 --> 00:33:13,760 These are also called histograms, frequency histograms. 658 00:33:13,760 --> 00:33:15,180 I will show how one is derived. 659 00:33:16,170 --> 00:33:23,800 This means you start with a picture with more simplicity, less uncertainty, smaller entropy. 660 00:33:24,780 --> 00:33:29,300 So you shine your little flashlight on your data 661 00:33:29,300 --> 00:33:32,600 where you're more likely to get, 662 00:33:34,940 --> 00:33:37,840 where you're more likely to recognize an anomaly. 663 00:33:37,960 --> 00:33:44,100 It's really like looking under the street lamps for lost keys, right? 664 00:33:44,220 --> 00:33:47,140 If you just start browsing in the dark, 665 00:33:47,300 --> 00:33:49,820 you're not really likely to find anything. 666 00:33:50,060 --> 00:33:53,820 You may find someone, but probably not your keys. 667 00:33:55,760 --> 00:33:56,360 Entropy. 668 00:33:59,020 --> 00:34:02,020 A simple summary of a column is a range. 669 00:34:03,140 --> 00:34:03,900 Minimum to maximum. 670 00:34:04,580 --> 00:34:06,780 So this tells us, and we can get this by sorting. 671 00:34:07,980 --> 00:34:11,580 Destination IP starts here, ends there. 672 00:34:12,440 --> 00:34:14,980 Destination port, so on and so forth. 673 00:34:16,400 --> 00:34:20,460 This is a frequency histogram that generalizes the range. 674 00:34:20,840 --> 00:34:27,240 So we're taking all the unique values, distinct values in the column, 675 00:34:27,420 --> 00:34:31,480 count how many times they occur, right? 676 00:34:31,620 --> 00:34:32,880 There are little columns here. 677 00:34:35,540 --> 00:34:39,420 The count would be on the y-axis. 678 00:34:39,500 --> 00:34:41,940 This is the label of the port 445. 679 00:34:42,140 --> 00:34:43,520 This is port 80, port 21. 680 00:34:44,000 --> 00:34:48,200 This is a port scan, a real port scan from my network. 681 00:34:50,640 --> 00:34:53,200 Clearly everyone is looking for port 445, 682 00:34:54,340 --> 00:35:00,180 followed by port 80 and FTP and so on and so forth. 683 00:35:01,440 --> 00:35:02,400 And so, 684 00:35:03,140 --> 00:35:05,600 we can build a little histogram for each one of those. 685 00:35:05,740 --> 00:35:09,720 And I ask you, which one of these histograms is easiest to understand? 686 00:35:15,780 --> 00:35:16,220 Right? 687 00:35:18,720 --> 00:35:21,820 Well, I'm not going to wait for an answer from the audience. 688 00:35:24,860 --> 00:35:29,720 Now, when we take the counts, add them all up, get the total counts of the packets, 689 00:35:30,800 --> 00:35:32,540 then we can compute probabilities. 690 00:35:33,140 --> 00:35:39,220 A probability is really the fraction of the count of things that ended up in one bin. 691 00:35:39,320 --> 00:35:42,200 Here, the bin for 445 is pretty large. 692 00:35:43,280 --> 00:35:46,520 The next one is lower and so on. 693 00:35:49,040 --> 00:35:56,240 And having computed the set of probabilities, this is how we define entropy. 694 00:35:56,960 --> 00:36:01,980 We take the log base 2 of inverse probability. 695 00:36:03,300 --> 00:36:08,040 And average them over all the probabilities that we have. 696 00:36:09,820 --> 00:36:17,620 Log 2 is the reason why entropy defined that way is related to the number of bits. 697 00:36:18,160 --> 00:36:18,720 Right? 698 00:36:18,800 --> 00:36:22,380 How many bits do you need to record a number from 1 to n? 699 00:36:22,480 --> 00:36:23,780 Well, log 2n. 700 00:36:25,180 --> 00:36:32,000 And it turns out that if you have a perfect encoding of a really large batch of data, 701 00:36:32,000 --> 00:36:40,580 you can do better than this for your average encoding length per symbol. 702 00:36:41,740 --> 00:36:46,380 This is a theorem introduced by Shannon in 1948. 703 00:36:46,440 --> 00:36:52,900 This revolutionized the entire data transmission business and science. 704 00:36:53,640 --> 00:36:54,820 And why logarithms? 705 00:36:54,900 --> 00:37:01,660 The least number of bits is needed to encode numbers between 1 and n is log 2n. 706 00:37:03,080 --> 00:37:06,440 Now, why is this a measure of your uncertainty? 707 00:37:08,560 --> 00:37:14,420 Because in order to communicate your choice once you've made it, you need to use some bits. 708 00:37:18,440 --> 00:37:24,980 And if you count it as the number of bits to communicate the missing information, that's entropy. 709 00:37:26,340 --> 00:37:31,640 So here is a little bit of math that explains this. 710 00:37:31,660 --> 00:37:32,900 It explains just how it works. 711 00:37:33,280 --> 00:37:41,360 If you choose out of four characters, out of four possibilities, out of four values with equal probability, 712 00:37:41,720 --> 00:37:48,120 then it's a quarter, quarter, quarter, quarter chance to draw each one of them. 713 00:37:48,400 --> 00:37:51,320 Four possibilities give you two bits. 714 00:37:53,240 --> 00:37:58,000 Now, if you draw the first thing with higher probability, 715 00:37:58,300 --> 00:38:00,220 or you need to transmit it more often, 716 00:38:00,220 --> 00:38:01,620 as per your data, 717 00:38:01,740 --> 00:38:03,640 or it occurs more often in your log, 718 00:38:05,660 --> 00:38:09,080 see here it occurs half as often as the rest of them together, 719 00:38:10,600 --> 00:38:13,580 then you are certain, reasonably certain, 720 00:38:13,800 --> 00:38:20,560 that you're going to get the first one, the first character, a, half the time. 721 00:38:22,120 --> 00:38:26,240 So you can decrease your uncertainty. 722 00:38:26,320 --> 00:38:30,140 You can decrease the amount of information that you need to transmit. 723 00:38:30,220 --> 00:38:32,700 The sequences of that a. 724 00:38:35,960 --> 00:38:37,400 Let's bias this a little more. 725 00:38:37,580 --> 00:38:39,360 In 80% you draw a. 726 00:38:40,060 --> 00:38:46,360 Your uncertainty is measured by one bit and a little bit more. 727 00:38:47,800 --> 00:38:51,080 Because what is your uncertainty about what you're going to draw? 728 00:38:51,240 --> 00:38:55,500 You're going to draw this almost often, almost always, right? 729 00:38:56,480 --> 00:38:59,120 And finally, if all you get is a, 730 00:38:59,120 --> 00:39:01,600 then your uncertainty is zero. 731 00:39:01,920 --> 00:39:03,660 a is what you're going to get. 732 00:39:04,680 --> 00:39:05,500 Thank you. 733 00:39:07,080 --> 00:39:09,540 For only one value, there is no entropy. 734 00:39:10,840 --> 00:39:15,420 And so, if I superimpose the entropy measurement over a histogram, 735 00:39:16,860 --> 00:39:21,820 that measurement is going to serve as the measure of simplicity of this histogram. 736 00:39:22,640 --> 00:39:26,020 And, you know, for this one, 737 00:39:26,020 --> 00:39:29,420 it's one bit and a bit. 738 00:39:30,640 --> 00:39:32,660 And here it's five bits. 739 00:39:32,780 --> 00:39:35,260 And here it's, well, almost six bits. 740 00:39:35,320 --> 00:39:36,940 Here it's six bits and a bit. 741 00:39:37,180 --> 00:39:39,320 And so this is clearly the simplest histogram. 742 00:39:39,740 --> 00:39:45,160 So you are more likely to understand the splitting by this feature. 743 00:39:45,520 --> 00:39:48,060 And of course, you know, if you're looking at source ports, 744 00:39:49,100 --> 00:39:52,160 it's obvious how you're going to do that. 745 00:39:52,900 --> 00:39:54,760 It's obvious that you're going to get, 746 00:39:56,020 --> 00:40:00,120 you know, your targets picked by a source port. 747 00:40:02,670 --> 00:40:06,860 So let's look at this in another tool. 748 00:40:18,780 --> 00:40:20,260 All right. 749 00:40:23,280 --> 00:40:24,880 Can you see the screen? 750 00:40:27,520 --> 00:40:29,740 Can you see the letters? 751 00:40:30,880 --> 00:40:31,700 Very good. 752 00:40:32,060 --> 00:40:35,000 Now, these are port scan alerts. 753 00:40:36,340 --> 00:40:39,280 And I press the magic key. 754 00:40:39,540 --> 00:40:41,180 I rework the template. 755 00:40:41,600 --> 00:40:44,800 And it says, okay, destination port is the best you can do. 756 00:40:46,200 --> 00:40:51,180 Let's import some more data in here. 757 00:40:51,340 --> 00:40:52,940 Let's say your next log. 758 00:40:57,840 --> 00:40:59,420 From the next day. 759 00:41:02,940 --> 00:41:04,720 And it's a larger batch. 760 00:41:05,280 --> 00:41:07,440 This batch was 1,500. 761 00:41:07,580 --> 00:41:09,280 Let's import this one. 762 00:41:15,760 --> 00:41:18,540 And so you end up with 18,000. 763 00:41:20,260 --> 00:41:20,900 Right. 764 00:41:21,760 --> 00:41:25,040 And you can see what sort of ranges are there. 765 00:41:27,180 --> 00:41:31,720 You know, 37 destination ports now. 766 00:41:31,880 --> 00:41:33,640 96 destination IPs. 767 00:41:33,860 --> 00:41:35,460 I reapply the magic. 768 00:41:35,860 --> 00:41:39,340 Now, the statistical composition of my set has changed. 769 00:41:39,440 --> 00:41:40,600 I just added more stuff. 770 00:41:48,000 --> 00:41:52,540 Actually, I just added the wrong batch. 771 00:41:53,480 --> 00:41:54,400 I'm sorry. 772 00:41:54,400 --> 00:41:56,120 Oh, no, no, no, no, no, no. 773 00:41:56,220 --> 00:41:57,480 I added the right batch. 774 00:41:59,240 --> 00:42:02,560 Let me rerun this. 775 00:42:11,380 --> 00:42:12,980 This is an earlier version. 776 00:42:13,140 --> 00:42:15,480 And I get confused with the command line. 777 00:42:24,760 --> 00:42:25,440 Right. 778 00:42:25,560 --> 00:42:28,960 So this is the loaded template that I used from the previous time. 779 00:42:31,300 --> 00:42:32,840 I now rebuild it. 780 00:42:41,940 --> 00:42:46,000 And what I see is that the statistical properties did change. 781 00:42:46,720 --> 00:42:54,380 Now, the simplest histogram that I have is a split by the template. 782 00:42:54,380 --> 00:42:54,920 This is the type of the scan. 783 00:42:58,360 --> 00:43:00,520 Most of them are SYN scans. 784 00:43:01,180 --> 00:43:05,380 But seven of those alerts are SYNFIN scans. 785 00:43:07,900 --> 00:43:11,200 So this can serve as a measure of novelty. 786 00:43:13,120 --> 00:43:21,060 And this is actually how the tool would pick up the ARP covert channel from the previous talk. 787 00:43:21,680 --> 00:43:28,820 There is only so much statistical bias in normal ARP. 788 00:43:29,000 --> 00:43:32,520 You don't get to see much variation in those fields. 789 00:43:32,940 --> 00:43:37,600 Once you start transmitting information, you increase variation quite a lot. 790 00:43:38,200 --> 00:43:45,440 And actually, if I manage to get a packet capture from the previous speaker, I may be able to demonstrate it during the Q&A. 791 00:43:48,800 --> 00:43:49,100 Five? 792 00:43:50,360 --> 00:43:51,060 Okay. 793 00:43:53,320 --> 00:43:55,720 So we went through this. 794 00:43:55,900 --> 00:44:01,940 And measuring co-dependence, correlation, is really interesting. 795 00:44:02,180 --> 00:44:04,120 So you look for correlations. 796 00:44:04,120 --> 00:44:10,900 And you want to know if a pair of fields is strongly correlated and where this correlation breaks. 797 00:44:12,080 --> 00:44:16,880 So you would try and rank pairs of values before looking. 798 00:44:17,080 --> 00:44:17,340 Okay. 799 00:44:18,280 --> 00:44:22,440 And, you know, this might be significant. 800 00:44:23,340 --> 00:44:27,660 There is a standard classical example of a source IP from user logins. 801 00:44:27,800 --> 00:44:30,240 Almost everyone comes in from a couple of machines. 802 00:44:30,360 --> 00:44:32,500 One user comes in from all over the place. 803 00:44:32,580 --> 00:44:32,940 Problem? 804 00:44:33,420 --> 00:44:35,000 We've actually seen that scenario. 805 00:44:35,220 --> 00:44:37,380 That user was root. 806 00:44:39,640 --> 00:44:44,360 On a small network, a source IP would be correlated with a TTL. 807 00:44:45,620 --> 00:44:46,500 That's fine. 808 00:44:46,640 --> 00:44:46,920 Right? 809 00:44:47,340 --> 00:44:49,780 The paths are really simple. 810 00:44:49,980 --> 00:44:53,320 Why would the source vary the TTL? 811 00:44:53,460 --> 00:44:58,560 What if a host sends packets with all sorts of TTLs, breaking the correlation? 812 00:44:59,320 --> 00:45:01,420 A user just discovered traceroute. 813 00:45:01,720 --> 00:45:04,600 Or maybe that machine never ran traceroute before. 814 00:45:04,740 --> 00:45:06,560 Maybe it was a printer or an appliance. 815 00:45:07,160 --> 00:45:12,880 If you never observed that traffic from it before, you know, this might be significant. 816 00:45:13,380 --> 00:45:14,440 In fact, 817 00:45:17,840 --> 00:45:36,720 I just spent some time last month cross-building libpcap and arpsk and dsniff and a bunch of other neat tools for this platform, 818 00:45:37,820 --> 00:45:44,380 which turned out to be a wonderful box for doing ARP integration. 819 00:45:44,420 --> 00:45:50,860 We have pretty good build holding. 820 00:45:52,580 --> 00:45:54,280 Yeah, this also... 821 00:45:54,280 --> 00:45:54,640 I'm going to do a little bit more of that in the next three months, 822 00:45:54,640 --> 00:45:58,760 a new Keyboard interface. 823 00:46:03,340 --> 00:46:04,120 That's the new Keyboard, 824 00:46:05,440 --> 00:46:05,980 so it's very interesting to see the progress. 825 00:46:06,200 --> 00:46:06,420 and that's the first thing we're going to do with this😘. 826 00:46:07,560 --> 00:46:07,760 Thank you too, Bob. 827 00:46:07,760 --> 00:46:07,780 The next question, 828 00:46:07,800 --> 00:46:12,760 and I'm going to close out the session. 829 00:46:15,360 --> 00:46:23,040 Okay, so my other example of where correlation may be interesting is from a mod, a multi-user 830 00:46:23,040 --> 00:46:23,660 text adventure. 831 00:46:23,860 --> 00:46:28,640 It's like World of Warcraft in ASCII text, only better player versus player interaction. 832 00:46:29,120 --> 00:46:34,280 And you can talk to my wife because she runs that mod and I'm not an expert. 833 00:46:34,420 --> 00:46:37,960 But having this tool, I helped her fight cheaters. 834 00:46:37,960 --> 00:46:46,060 And so here you see a syslog record format for parsing that syslog. 835 00:46:46,160 --> 00:46:48,320 User gets object in room, room. 836 00:46:48,800 --> 00:46:55,160 And we immediately found out by looking at the correlations in that tree that two rooms 837 00:46:55,160 --> 00:46:57,520 had by far the largest number of objects picked up. 838 00:46:57,760 --> 00:47:04,800 And that's just like gold transfers in World of Warcraft, I get to find out from Greg Hoglund's 839 00:47:04,800 --> 00:47:04,920 talk. 840 00:47:05,020 --> 00:47:06,840 This is always recorded in that particular mod. 841 00:47:09,640 --> 00:47:12,480 Major source of money was a camp of robbers. 842 00:47:12,920 --> 00:47:16,540 Everyone would go in, kill them, get out with the loot. 843 00:47:16,720 --> 00:47:18,860 That was how the economy of that game was run. 844 00:47:19,720 --> 00:47:22,180 Or cheating, right? 845 00:47:22,500 --> 00:47:26,840 Player A kills B over and over and over and over again in the same room. 846 00:47:26,920 --> 00:47:27,220 Why? 847 00:47:27,360 --> 00:47:28,800 Why is he coming that way? 848 00:47:30,580 --> 00:47:35,420 Well, turns out that's how we experience and war points can be gained. 849 00:47:35,940 --> 00:47:36,820 And that, of course, is a very important part of the game. 850 00:47:36,820 --> 00:47:41,380 Of course, it's a noncommercial game, so gold transfer is not a problem. 851 00:47:43,940 --> 00:47:50,340 But these are the things that jump out if you use entropy for correlation of things. 852 00:47:50,580 --> 00:47:59,700 And for the pair of features, instead of single diagrams, you use a three-dimensional 853 00:47:59,700 --> 00:48:00,160 diagram. 854 00:48:00,520 --> 00:48:04,960 These are combinations of, in this case, source IP, destination IP. 855 00:48:05,080 --> 00:48:06,680 The height of... 856 00:48:06,680 --> 00:48:13,040 The histogram is the count, the number of hits. 857 00:48:13,660 --> 00:48:16,840 And I am out right now. 858 00:48:18,060 --> 00:48:20,320 I'm going to skip the math here. 859 00:48:21,180 --> 00:48:21,700 And... 860 00:48:21,700 --> 00:48:23,780 Yes, yes, yes, yes, yes. 861 00:48:23,900 --> 00:48:25,700 I'm so totally going to skip the math. 862 00:48:25,920 --> 00:48:34,520 And I'm going to put up the last slide, not the one that's okay, which is... 863 00:48:34,520 --> 00:48:35,480 Entropy is good. 864 00:48:35,480 --> 00:48:37,720 It's part of a complete analysis kit. 865 00:48:37,880 --> 00:48:40,680 And I would like to thank you for listening. 866 00:48:42,200 --> 00:48:43,360 You for listening. 867 00:48:43,560 --> 00:48:48,980 DEF CON for having me and letting me go two minutes over time. 868 00:48:49,160 --> 00:48:52,220 And everyone who helped me code these tools. 869 00:48:52,400 --> 00:48:54,460 And everyone who helped me with the data. 870 00:48:54,920 --> 00:48:58,740 And you can get those things from our SVN repository. 871 00:48:59,320 --> 00:49:00,700 And please do contribute. 872 00:49:01,220 --> 00:49:01,840 Thank you. 873 00:49:02,740 --> 00:49:03,040 Thank you. 874 00:49:03,300 --> 00:49:04,400 Thank you.