1 00:00:00,000 --> 00:00:06,080 All right, might look soft. Hi everybody, I'm Scott Wolchuk, and this talk is Crawling BitTorrent DHTs for Fun and Profit. 2 00:00:06,080 --> 00:00:08,740 And I'm pretty sure I didn't post my password on the slides. 3 00:00:09,220 --> 00:00:11,840 All right, so I'll start with the bad news. 4 00:00:12,040 --> 00:00:14,760 So BitTorrent sites have this tendency to get sued, right? 5 00:00:14,900 --> 00:00:19,820 Like earlier, or last year, we had the PiratePay4 lose a court case, that they're still appealing. 6 00:00:20,040 --> 00:00:23,720 We had Mininova get forced to take all the copyrighted files off of their website. 7 00:00:24,500 --> 00:00:28,960 Going back a couple years, we had Oink get shut down, one of the biggest private BitTorrent sites. 8 00:00:28,960 --> 00:00:33,360 Going back even further, we had Supernova get shut down in 2004. 9 00:00:33,740 --> 00:00:37,980 And then coming back to the present, we also had Isohunts having some legal trouble in the U.S. 10 00:00:38,400 --> 00:00:39,700 So, not great news. 11 00:00:41,220 --> 00:00:47,040 Another piece of bad news that's been publicized recently is the possibility of large-scale BitTorrent surveillance. 12 00:00:47,540 --> 00:00:54,060 So there was this paper in Leet earlier this year called Spying the World from Your Laptop by some folks from France. 13 00:00:54,380 --> 00:00:58,380 And in this paper, they talked about how by crawling the PiratePay, Mininova, 14 00:00:58,480 --> 00:00:58,940 and a couple of other sites, they could get a lot of money. 15 00:00:58,960 --> 00:01:04,860 And a couple of the other major trackers, you can track literally like tens of millions of BitTorrent users using just one machine. 16 00:01:05,160 --> 00:01:09,780 So we knew BitTorrent wasn't anonymous, but it's kind of striking that you can do all the spying from one machine, 17 00:01:09,980 --> 00:01:13,400 as long as you crawl all the centralized BitTorrent search sites and so on. 18 00:01:15,160 --> 00:01:21,980 So in response to this, especially their legal trouble, in a blog post called World's Most Resilient Tracking, 19 00:01:22,620 --> 00:01:28,440 the PiratePay post said that they were switching to, or at least promoting, DHT-based BitTorrent tracking. 20 00:01:28,540 --> 00:01:28,800 And they said, 21 00:01:28,960 --> 00:01:29,960 So we know that there are a couple of the benefits of this, 22 00:01:30,060 --> 00:01:32,700 where that there's no central tracker that can be down, 23 00:01:32,920 --> 00:01:34,980 and you don't have to rely on a single surfer. 24 00:01:35,040 --> 00:01:37,940 And if you want to check it out, it's blog post number 175 on their site. 25 00:01:39,540 --> 00:01:44,680 But there's a problem with their switch to DHT tracking, at least from their perspective, I think. 26 00:01:44,780 --> 00:01:48,740 And it's that the DHT, just like all the centralized torrent sites, can be crawled. 27 00:01:48,780 --> 00:01:49,720 We can download the whole thing. 28 00:01:50,100 --> 00:01:54,020 And the fact that the DHT is crawlable means that pirates have both, 29 00:01:54,500 --> 00:01:57,320 it's got both good news and bad news for pirates. 30 00:01:57,940 --> 00:01:58,940 So the bad news is that, 31 00:01:58,940 --> 00:02:02,420 the bad news for all the pirates in the crowd is that the content owners can still track you through the DHT, 32 00:02:02,520 --> 00:02:04,740 and it's even harder to stop them, 33 00:02:04,800 --> 00:02:09,060 because you don't have a centralized point where you can do things like IP blocking, rate limiting, and so on. 34 00:02:10,300 --> 00:02:15,800 The good news for pirates is that even if all the content industries got their shit really together legally, 35 00:02:16,060 --> 00:02:18,520 and they managed to sue all the torrent sites into oblivion, 36 00:02:18,700 --> 00:02:20,660 overnight, you wake up, there's no backups. 37 00:02:21,020 --> 00:02:22,760 As long as you found out about it quick enough, 38 00:02:22,940 --> 00:02:26,220 you could have a pretty big torrent site back up within a couple of hours. 39 00:02:27,180 --> 00:02:28,760 And so these two, 40 00:02:29,160 --> 00:02:34,340 facts are going to have some consequences for attacks on BitTorrent that I'm going to revisit toward the end of the talk. 41 00:02:35,500 --> 00:02:37,020 All right, so that's the basic idea. 42 00:02:37,280 --> 00:02:39,880 Now I'm going to move forward and look at the details for the rest of the talk. 43 00:02:40,140 --> 00:02:43,260 All right, so first in background, I know a lot of people aren't familiar with this, 44 00:02:43,340 --> 00:02:45,460 so what the heck is a BitTorrent DHT? 45 00:02:46,600 --> 00:02:49,220 So think back to the last time you downloaded a torrent. 46 00:02:49,280 --> 00:02:51,220 You probably went to a website that looked something like this, 47 00:02:51,300 --> 00:02:53,580 the Pirate Bay, maybe one of the other BitTorrent search engines. 48 00:02:54,000 --> 00:02:55,940 You typed in whatever you were looking for, 49 00:02:56,100 --> 00:02:58,920 and you ended up at a page that looks like, 50 00:02:58,940 --> 00:03:02,420 you cleverly avoided the really huge download button, 51 00:03:02,580 --> 00:03:05,120 which in my opinion is like the world's most misleading ad. 52 00:03:05,400 --> 00:03:06,940 It's just an ad, it doesn't download your torrent. 53 00:03:07,040 --> 00:03:11,020 And you click the download this torrent link right under the huge download button. 54 00:03:11,420 --> 00:03:13,340 And your BitTorrent client fired up, 55 00:03:14,000 --> 00:03:17,520 and it connected to some people around the world and downloaded your files. 56 00:03:17,800 --> 00:03:20,160 And so the question I'm going to talk about is, 57 00:03:20,340 --> 00:03:22,660 how does your BitTorrent client find those peers? 58 00:03:24,180 --> 00:03:26,020 So the old school way of doing this, 59 00:03:26,040 --> 00:03:28,500 from the original BitTorrent design, is to use a BitTorrent tracker. 60 00:03:28,940 --> 00:03:31,820 And the trackers are a bunch of servers that are listed in the .torrent file. 61 00:03:32,160 --> 00:03:34,000 Let's say that's your laptop in the lower left there, 62 00:03:34,120 --> 00:03:35,500 1, 2, 3, 4, 68, 81. 63 00:03:36,140 --> 00:03:39,380 Your laptop sends an announce request to the tracker 64 00:03:39,380 --> 00:03:40,920 for the info hash of the torrent, 65 00:03:40,980 --> 00:03:44,260 which I've represented as hex 1, 2, 3, 4, a, b, etc. 66 00:03:44,720 --> 00:03:46,160 And for purposes of this talk, 67 00:03:46,280 --> 00:03:48,560 the info hash is just this magic random looking string 68 00:03:48,560 --> 00:03:50,280 that uniquely identifies the torrent. 69 00:03:50,760 --> 00:03:54,900 Tracker says, okay, I know that 1, 2, 3, 4, 68, 81 is downloading this torrent. 70 00:03:55,460 --> 00:03:56,600 Great, it makes a note of that, 71 00:03:56,660 --> 00:03:58,820 and it sends you back a list of other peers that all, 72 00:03:58,940 --> 00:04:00,640 also announced themselves, is downloading this torrent. 73 00:04:01,180 --> 00:04:03,260 So, and then your BitTorrent client takes that list, 74 00:04:03,380 --> 00:04:05,160 connects to them, does the BitTorrent magic, 75 00:04:05,280 --> 00:04:06,040 and you get your files. 76 00:04:07,600 --> 00:04:10,540 But there's a problem with the centralized method of tracking, 77 00:04:10,700 --> 00:04:12,240 and it's that trackers tend to go down. 78 00:04:12,360 --> 00:04:14,740 And by go down, I mean mostly that they tend to get sued, right? 79 00:04:14,860 --> 00:04:16,060 One of the, if I remember correctly, 80 00:04:16,240 --> 00:04:17,720 one of the Pirate Bay's big legal problems 81 00:04:17,720 --> 00:04:19,740 was that they were running a tracker, hence the blog post. 82 00:04:20,160 --> 00:04:21,080 So what you really want, 83 00:04:21,240 --> 00:04:23,680 and this is like a canonical distributed systems failure 84 00:04:23,680 --> 00:04:24,980 where you have one server that goes down 85 00:04:24,980 --> 00:04:26,120 and your system stops working. 86 00:04:26,560 --> 00:04:28,500 So what you really want is something more reliable, 87 00:04:28,940 --> 00:04:30,760 and what the BitTorrent developers have been pushing forward 88 00:04:30,760 --> 00:04:31,820 for the past couple of years 89 00:04:31,820 --> 00:04:34,660 is tracking with distributed hash tables, 90 00:04:34,900 --> 00:04:37,460 which I'll abbreviate for the rest of the talk as DHTs. 91 00:04:38,680 --> 00:04:39,960 So what is a DHT? 92 00:04:40,620 --> 00:04:43,880 Well, so there's actually years of academic research on this 93 00:04:43,880 --> 00:04:45,180 that I'm going to condense into about two minutes. 94 00:04:45,400 --> 00:04:47,800 In short, it's a peer-to-peer network, hence the distributed, 95 00:04:48,000 --> 00:04:50,480 that stores key value pairs, hence the hash table. 96 00:04:50,640 --> 00:04:53,620 So it's the big hash table in the sky or in the cloud, 97 00:04:53,720 --> 00:04:56,680 if you want to use the recent term. 98 00:04:57,000 --> 00:04:57,960 All right, so how does this work? 99 00:04:58,080 --> 00:04:58,600 You have your laptop. 100 00:04:58,600 --> 00:05:00,500 You have your laptop again, 1, 2, 3, 4, 68, 81. 101 00:05:01,140 --> 00:05:03,300 You can store a value under a key. 102 00:05:03,440 --> 00:05:05,820 For example, you might store 1 under the key O-N-E, 103 00:05:06,380 --> 00:05:08,280 and you can look up a value by key. 104 00:05:08,400 --> 00:05:10,400 So you might do a get for the key T-W-O, 105 00:05:10,600 --> 00:05:13,140 and if all is right with the world, you get the value too. 106 00:05:13,580 --> 00:05:15,680 All right, so it's just a big distributed system 107 00:05:15,680 --> 00:05:18,920 that wants a hash table like a dict or a hash in Perl or Python 108 00:05:19,380 --> 00:05:21,140 or your other favorite programming language. 109 00:05:22,660 --> 00:05:24,740 We need a bit more detail for this talk. 110 00:05:24,920 --> 00:05:27,120 So it turns out, so this is a peer-to-peer network, 111 00:05:27,320 --> 00:05:28,580 so we have to have some way, 112 00:05:28,600 --> 00:05:30,620 figuring out which peers are going to store the data. 113 00:05:30,920 --> 00:05:33,540 So the way it works is that both peers and items of data 114 00:05:33,540 --> 00:05:37,180 get 160-bit, 20-byte IDs. 115 00:05:37,820 --> 00:05:39,400 For purposes of this talk, again, 116 00:05:39,460 --> 00:05:41,480 the peer ID is picked magically at random, 117 00:05:41,540 --> 00:05:43,260 and it's just guaranteed to be probably unique. 118 00:05:43,580 --> 00:05:48,020 The data ID is picked by taking the SHA-1 hash of the key. 119 00:05:48,600 --> 00:05:50,940 So SHA-1 gets you a random-ish number 120 00:05:50,940 --> 00:05:53,440 that is probably unique for this key. 121 00:05:53,840 --> 00:05:57,340 And then what you do is you have the peers store data 122 00:05:57,340 --> 00:05:58,580 that has a close hash. 123 00:05:59,900 --> 00:06:03,980 So if I'm peer 10, I might store data items 11, 12, and 9, 124 00:06:04,120 --> 00:06:05,480 but probably not data item 200. 125 00:06:08,200 --> 00:06:09,580 So how do you do DH tracking? 126 00:06:09,760 --> 00:06:12,900 Well, you throw away the tracker, 127 00:06:13,040 --> 00:06:14,800 and you replace it with this big distributed system. 128 00:06:15,100 --> 00:06:17,180 So again, you have your laptop trying to get peers. 129 00:06:17,580 --> 00:06:20,620 First thing you do is look up the info hash of the torrent 130 00:06:20,620 --> 00:06:21,580 as a key in the table. 131 00:06:21,700 --> 00:06:24,800 Remember, this is what you sent to the tracker before 132 00:06:24,800 --> 00:06:25,920 to tell it which torrent you wanted. 133 00:06:26,280 --> 00:06:28,160 And what comes back as the value 134 00:06:28,160 --> 00:06:30,500 in the DHT is a list of the peers 135 00:06:30,500 --> 00:06:31,920 that are also downloading the torrent. 136 00:06:32,100 --> 00:06:33,700 And then to make sure you show up 137 00:06:33,700 --> 00:06:34,960 when somebody else does this, 138 00:06:35,160 --> 00:06:37,400 you do a store for your IP address import 139 00:06:37,400 --> 00:06:39,760 under that same key, the info hash of the torrent. 140 00:06:40,680 --> 00:06:42,140 All right, so we do the same thing 141 00:06:42,140 --> 00:06:43,040 that we did with the tracker, 142 00:06:43,180 --> 00:06:45,460 but we've replaced the vulnerable single machine 143 00:06:45,460 --> 00:06:46,940 with this distributed system 144 00:06:46,940 --> 00:06:48,140 that's much harder to take down. 145 00:06:48,540 --> 00:06:50,440 And by the way, the DHT is formed 146 00:06:50,440 --> 00:06:53,320 by all the BitTorrent clients that have DHT support. 147 00:06:53,500 --> 00:06:55,260 So your BitTorrent client just joins this network 148 00:06:55,260 --> 00:06:55,940 when you start it up. 149 00:06:57,600 --> 00:06:58,040 Okay. 150 00:06:58,160 --> 00:06:59,160 So we've got DHT tracking. 151 00:06:59,340 --> 00:07:00,900 The other piece of the puzzle 152 00:07:00,900 --> 00:07:02,720 that the Pirate Bay added in that blog post 153 00:07:02,720 --> 00:07:03,920 is magnet links. 154 00:07:04,900 --> 00:07:07,040 And so the magnet link looks like this 155 00:07:07,040 --> 00:07:08,220 up at the top of the slide there. 156 00:07:08,800 --> 00:07:10,100 It starts with magnet colon. 157 00:07:10,280 --> 00:07:12,060 And the important part of the magnet link 158 00:07:12,060 --> 00:07:13,440 is what I have in bold there. 159 00:07:13,540 --> 00:07:14,200 It's an info hash. 160 00:07:14,400 --> 00:07:15,620 Remember, this is the identifier 161 00:07:15,620 --> 00:07:17,640 that you were sending the tracker into the DHT. 162 00:07:18,140 --> 00:07:20,160 So when your BitTorrent client sees one of these, 163 00:07:20,260 --> 00:07:21,700 it can go directly to the DHT 164 00:07:21,700 --> 00:07:23,480 and get a list of peers right away, 165 00:07:23,580 --> 00:07:24,480 no.torrent required. 166 00:07:25,620 --> 00:07:27,100 It's not entirely clear to me 167 00:07:27,100 --> 00:07:28,020 why they started using this. 168 00:07:28,160 --> 00:07:30,600 It's smaller than using a .torrent file, 169 00:07:30,860 --> 00:07:32,580 but I think that they thought 170 00:07:32,580 --> 00:07:33,660 it improved their legal position. 171 00:07:34,080 --> 00:07:35,640 It's not clear to me that it does, 172 00:07:35,700 --> 00:07:36,540 but I'm not a lawyer, 173 00:07:36,660 --> 00:07:37,260 so what do I know? 174 00:07:39,620 --> 00:07:40,020 Okay. 175 00:07:40,060 --> 00:07:41,780 So we have DHT tracking and magnet links. 176 00:07:41,860 --> 00:07:43,540 Now, the talk's called crawling DHTs. 177 00:07:43,560 --> 00:07:45,380 So how would you build a DHT crawler? 178 00:07:45,940 --> 00:07:47,400 What we did was 179 00:07:47,400 --> 00:07:50,580 we dug through the Views BitTorrent client. 180 00:07:50,800 --> 00:07:52,140 It's also called Azureus. 181 00:07:52,200 --> 00:07:53,620 You might be more familiar with that name. 182 00:07:53,880 --> 00:07:57,200 And we looked through all their DHT implementation stuff 183 00:07:57,200 --> 00:08:00,400 and we re-implemented the protocol in C for efficiency. 184 00:08:00,680 --> 00:08:03,100 So it was kind of a huge piece of Java code. 185 00:08:03,220 --> 00:08:04,200 We wanted something a bit faster, 186 00:08:04,320 --> 00:08:05,140 so we had to redo it in C. 187 00:08:06,240 --> 00:08:08,300 Once we had this efficient DHT client, 188 00:08:08,500 --> 00:08:11,300 we used it to perform what's called a Sybil attack on the DHT. 189 00:08:11,500 --> 00:08:15,560 So a Sybil attack is this generic attack on distributed systems. 190 00:08:15,620 --> 00:08:19,140 It's named after a character from a novel or a play or something 191 00:08:19,580 --> 00:08:20,780 with multiple personalities. 192 00:08:21,240 --> 00:08:22,800 And what you do is you give your machine 193 00:08:22,800 --> 00:08:25,420 multiple personalities in your distributed system. 194 00:08:26,320 --> 00:08:26,720 So, 195 00:08:27,420 --> 00:08:29,780 for example, you simulate thousands of clients 196 00:08:29,780 --> 00:08:30,880 in whatever system at once. 197 00:08:30,960 --> 00:08:33,720 So, for example, we put thousands of DHT clients 198 00:08:33,720 --> 00:08:35,180 on this netbook here, let's say. 199 00:08:35,720 --> 00:08:36,720 Once we've done that, 200 00:08:36,780 --> 00:08:41,600 we've got thousands of pretty much randomly spaced IDs in the DHT. 201 00:08:41,800 --> 00:08:43,600 And so when someone stores something, 202 00:08:43,920 --> 00:08:47,060 it's going to be likely that the value is going to land 203 00:08:47,060 --> 00:08:48,620 on one of our simulated clients, 204 00:08:48,920 --> 00:08:51,680 which means it's likely to land on the single physical machine. 205 00:08:53,020 --> 00:08:54,780 So, when we're doing the Sybil attack, 206 00:08:55,040 --> 00:08:57,060 we can just sit and wait for values to come in. 207 00:08:57,200 --> 00:08:59,000 And so we use a couple of other tricks, 208 00:08:59,080 --> 00:09:00,840 which are talked about in that paper reference 209 00:09:00,840 --> 00:09:01,680 at the bottom of the slide. 210 00:09:02,100 --> 00:09:04,100 But the result is that you can cheaply capture 211 00:09:04,100 --> 00:09:05,860 almost all of the views DHT. 212 00:09:06,240 --> 00:09:08,980 And again, if you want to read up more about this, 213 00:09:09,060 --> 00:09:09,800 the paper's called 214 00:09:09,800 --> 00:09:11,860 Defeating Vanish with Low-Cost Sybil Attacks 215 00:09:11,860 --> 00:09:12,980 Against Large DHTs. 216 00:09:13,400 --> 00:09:15,140 And there's a link to it in the links 217 00:09:15,140 --> 00:09:16,580 at the end of the slides. 218 00:09:18,220 --> 00:09:18,740 All right. 219 00:09:19,240 --> 00:09:20,900 The one other thing I have to tell you 220 00:09:20,900 --> 00:09:22,820 is that there's actually two BitTorrent DHTs, 221 00:09:22,840 --> 00:09:24,360 as if this wasn't complicated enough. 222 00:09:24,840 --> 00:09:27,180 There's the mainline DHT and the views DHT. 223 00:09:27,200 --> 00:09:29,900 So the views DHT is just for the views client, 224 00:09:30,100 --> 00:09:32,160 and the mainline DHT is for everybody else. 225 00:09:32,240 --> 00:09:35,420 It turns out the views client is a lot nicer, 226 00:09:35,840 --> 00:09:37,080 but it's also complicated, 227 00:09:37,300 --> 00:09:39,580 and so lots of people just haven't bothered 228 00:09:39,580 --> 00:09:41,400 to do separate implementations of it yet. 229 00:09:41,820 --> 00:09:44,500 So in this talk, I've only implemented this stuff on views 230 00:09:44,500 --> 00:09:48,040 because that was what we had code lying around for already. 231 00:09:48,300 --> 00:09:50,740 But you could extend all of this to mainline, too. 232 00:09:52,380 --> 00:09:54,800 Okay, so we've got a DHT crawler. 233 00:09:54,840 --> 00:09:55,660 What can we do with it? 234 00:09:55,800 --> 00:09:56,760 Well, the first thing we can do 235 00:09:56,760 --> 00:09:58,320 is build a BitTorrent search engine. 236 00:09:59,500 --> 00:10:00,340 So what do we want to do? 237 00:10:00,420 --> 00:10:02,500 We're going to build a BitTorrent search engine from scratch. 238 00:10:02,780 --> 00:10:05,260 So unlike that Leet paper I mentioned earlier in the talk, 239 00:10:05,420 --> 00:10:07,780 we're not going to look at any of the existing torrent sites, 240 00:10:07,960 --> 00:10:09,600 and we're not going to look at any existing trackers. 241 00:10:10,040 --> 00:10:11,820 Instead, what we're going to be able to do 242 00:10:11,820 --> 00:10:12,680 is recover fast, 243 00:10:13,060 --> 00:10:15,940 even if all of the existing torrent sites and search engines 244 00:10:15,940 --> 00:10:17,980 were sued into oblivion overnight and no backups. 245 00:10:18,740 --> 00:10:20,280 So this gives us a way to recover 246 00:10:20,280 --> 00:10:21,900 even if everybody gets sued. 247 00:10:22,280 --> 00:10:24,020 And then what's our site going to look like? 248 00:10:24,140 --> 00:10:25,420 Well, we're going to provide keyword search 249 00:10:25,420 --> 00:10:26,640 just like every other BitTorrent, 250 00:10:26,760 --> 00:10:27,680 I'm sure it's a search site, 251 00:10:27,800 --> 00:10:29,400 and you're going to get a magnet link to your torrent. 252 00:10:31,880 --> 00:10:33,320 So how do you design a search engine? 253 00:10:33,500 --> 00:10:35,580 Well, it's crawl index search is the general design. 254 00:10:35,760 --> 00:10:36,760 So think about Google, right? 255 00:10:36,820 --> 00:10:38,240 They've got their crawler, Googlebot, 256 00:10:38,340 --> 00:10:39,840 that goes out and downloads webpages. 257 00:10:40,500 --> 00:10:43,320 They do their indexing with some massive MapReduce job 258 00:10:43,320 --> 00:10:44,260 or something else. 259 00:10:44,320 --> 00:10:44,720 Who knows? 260 00:10:44,860 --> 00:10:45,780 They won't really tell anybody. 261 00:10:46,140 --> 00:10:48,400 And then the search part is whatever the back end is 262 00:10:48,400 --> 00:10:49,460 for the Google.com webpage. 263 00:10:49,660 --> 00:10:50,660 It handles your source query. 264 00:10:51,200 --> 00:10:52,560 The other cool thing about Google 265 00:10:52,560 --> 00:10:54,900 is that they had a really nice ranking metric 266 00:10:54,900 --> 00:10:55,940 in terms of page rank, 267 00:10:56,040 --> 00:10:56,720 which let you measure, 268 00:10:56,720 --> 00:10:58,380 measure the goodness or popularity of a page 269 00:10:58,380 --> 00:10:59,340 based on incoming links. 270 00:11:00,160 --> 00:11:01,800 So how does our search engine work? 271 00:11:02,180 --> 00:11:03,280 Well, again, for the crawler, 272 00:11:03,320 --> 00:11:05,300 we just use the DHT crawler that I just talked about. 273 00:11:05,640 --> 00:11:07,680 The indexing step is just a Python script 274 00:11:07,680 --> 00:11:10,100 that imports the result, the DHT, into Postgres. 275 00:11:10,640 --> 00:11:13,540 And the search is Postgres' keyword search. 276 00:11:14,140 --> 00:11:16,380 For ranking, we actually have it a lot easier than Google 277 00:11:16,380 --> 00:11:17,800 because we're getting those lists of peers 278 00:11:17,800 --> 00:11:20,700 that normal clients would have gotten from the DHT. 279 00:11:21,040 --> 00:11:22,980 So if you want to know how popular your torrent is, 280 00:11:23,060 --> 00:11:24,480 you just count the size of that peer list, 281 00:11:24,600 --> 00:11:26,000 and that's how many people are downloading it, 282 00:11:26,080 --> 00:11:26,620 which is probably, 283 00:11:26,720 --> 00:11:28,540 a pretty good guess at how popular it is. 284 00:11:30,700 --> 00:11:31,740 But there's a problem. 285 00:11:31,920 --> 00:11:33,660 So if you build a DHT crawler for the, 286 00:11:33,660 --> 00:11:34,460 if you go read that paper, 287 00:11:34,560 --> 00:11:36,320 you build a crawler for the views DHT, 288 00:11:36,460 --> 00:11:37,220 you're going to, 289 00:11:37,220 --> 00:11:38,860 and you actually download the whole thing, 290 00:11:38,980 --> 00:11:40,920 you're going to find out that what you got 291 00:11:40,920 --> 00:11:44,280 are pairs of the SHA-1 hash of the info hash of torrents, 292 00:11:44,280 --> 00:11:44,980 and a list of peers. 293 00:11:45,600 --> 00:11:46,380 The problem is, 294 00:11:46,440 --> 00:11:47,980 you can't build a torrent site out of that 295 00:11:47,980 --> 00:11:49,660 because you need to give people the info hash, 296 00:11:49,900 --> 00:11:51,180 and the whole point of SHA-1 297 00:11:51,180 --> 00:11:52,280 is that it's supposed to be one way. 298 00:11:52,340 --> 00:11:53,020 It's hard to reverse. 299 00:11:53,160 --> 00:11:55,600 So you can't calculate the info hash of the torrent 300 00:11:55,600 --> 00:11:56,340 from what you get there. 301 00:11:56,900 --> 00:11:58,180 So the way we worked around this 302 00:11:58,180 --> 00:12:00,600 is we found this other record type in the views DHT 303 00:12:00,600 --> 00:12:01,680 called a torrent description. 304 00:12:02,460 --> 00:12:04,820 The views client actually stores these in the DHT 305 00:12:04,820 --> 00:12:06,880 to support its own prototype search feature 306 00:12:06,880 --> 00:12:07,440 that's not, 307 00:12:07,480 --> 00:12:08,180 as far as I know, 308 00:12:08,260 --> 00:12:09,620 it's not exposed in the interface yet. 309 00:12:10,400 --> 00:12:12,140 And the torrent description looks like that, 310 00:12:12,160 --> 00:12:13,460 that last point on the page. 311 00:12:13,600 --> 00:12:14,300 This is B encoding, 312 00:12:14,540 --> 00:12:16,660 if any of you are familiar with the details of BitTorrent. 313 00:12:17,080 --> 00:12:18,620 Again, the important parts are in bold. 314 00:12:18,760 --> 00:12:19,940 So there's the title of the torrent, 315 00:12:19,980 --> 00:12:21,040 which is fast and furious here, 316 00:12:21,400 --> 00:12:23,100 and then there is the info hash, 317 00:12:23,280 --> 00:12:24,640 which is that big hex string in bold. 318 00:12:25,260 --> 00:12:26,700 So if we take this torrent, 319 00:12:26,720 --> 00:12:29,320 we can connect the title and the info hash 320 00:12:29,320 --> 00:12:30,220 to the list of peers 321 00:12:30,220 --> 00:12:33,000 just by calculating the SHA-1 of the info hash ourselves 322 00:12:33,000 --> 00:12:34,940 and matching it up with our database using a join. 323 00:12:35,940 --> 00:12:38,000 All right, so that's how we get over this SHA-1 problem, 324 00:12:38,180 --> 00:12:39,600 and that's what lets us build the search engine. 325 00:12:40,860 --> 00:12:42,500 The indexing is just a Python script 326 00:12:42,500 --> 00:12:43,620 that does a pass over the logs 327 00:12:43,620 --> 00:12:45,500 and does a bunch of insert statements into Postgres. 328 00:12:45,600 --> 00:12:46,600 Nothing too exciting there. 329 00:12:47,260 --> 00:12:49,560 The search, likewise, is just a big SQL query, 330 00:12:49,720 --> 00:12:51,840 and you can build the website in PHP or Django 331 00:12:51,840 --> 00:12:54,020 or whatever web framework you like. 332 00:12:54,760 --> 00:12:56,100 All right, so you put this all together, 333 00:12:56,220 --> 00:12:56,700 and you can build a web framework. 334 00:12:57,300 --> 00:12:59,420 And you can build what I'll show you in a second 335 00:12:59,420 --> 00:13:00,820 as a big search engine pretty fast. 336 00:13:02,520 --> 00:13:03,760 Now, the other side, 337 00:13:03,940 --> 00:13:05,980 I guess the dark side or the light side of this, 338 00:13:06,040 --> 00:13:07,300 depending on which side you're on, 339 00:13:07,440 --> 00:13:09,140 is that you can also spy on BitTorrent users 340 00:13:09,140 --> 00:13:10,800 if you want to do things like sudo, right? 341 00:13:10,900 --> 00:13:11,960 So how does this work? 342 00:13:13,360 --> 00:13:16,020 Well, you do the same crawl that you did for search. 343 00:13:16,180 --> 00:13:17,560 You just repeat it over time. 344 00:13:17,720 --> 00:13:18,980 So you run your crawler many times 345 00:13:18,980 --> 00:13:20,960 over several weeks, days, years, whatever. 346 00:13:21,200 --> 00:13:22,560 And you run the same importer, 347 00:13:22,660 --> 00:13:24,020 and you get two database tables. 348 00:13:24,180 --> 00:13:25,140 You get the peer lists 349 00:13:25,540 --> 00:13:26,320 that you would have gotten 350 00:13:26,320 --> 00:13:26,920 from the DHT, 351 00:13:26,980 --> 00:13:27,840 and then you get a table 352 00:13:27,840 --> 00:13:28,620 full of torrent descriptions. 353 00:13:29,340 --> 00:13:30,540 So if you want to take an IP 354 00:13:30,540 --> 00:13:32,980 and see what files they downloaded 355 00:13:32,980 --> 00:13:34,620 so that you can tell the right people to sue them 356 00:13:34,620 --> 00:13:36,980 or take files and map it to IPs, 357 00:13:37,100 --> 00:13:39,000 you just do a join on these two tables, 358 00:13:39,060 --> 00:13:41,100 which is a really basic database operation 359 00:13:41,100 --> 00:13:42,220 where you take two tables 360 00:13:42,220 --> 00:13:43,320 and see where they're the same. 361 00:13:43,780 --> 00:13:44,800 And again, you just do it 362 00:13:44,800 --> 00:13:46,160 by taking the SHA1 of the info hash 363 00:13:46,160 --> 00:13:48,380 and matching it up with keys you got from the DHT. 364 00:13:48,660 --> 00:13:50,480 And that gives you content to IP mapping. 365 00:13:52,760 --> 00:13:54,120 So the rest of the talk, 366 00:13:54,280 --> 00:13:55,640 so how well does this work? 367 00:13:56,700 --> 00:13:58,720 So what we did was we ran our crawler 368 00:13:58,720 --> 00:13:59,740 for two weeks and two days. 369 00:13:59,840 --> 00:14:00,960 We did three crawls per day, 370 00:14:01,060 --> 00:14:01,820 one every eight hours. 371 00:14:02,440 --> 00:14:06,280 And we set the crawl to simulate 8,000 nodes in the DHT 372 00:14:06,280 --> 00:14:07,780 for a period of two hours. 373 00:14:08,280 --> 00:14:10,240 Our model for how well the crawler works 374 00:14:10,240 --> 00:14:11,640 predicts that this should show you 375 00:14:11,640 --> 00:14:13,920 about 20% of the contents of the DHT. 376 00:14:13,980 --> 00:14:14,820 So this isn't a full crawl, 377 00:14:14,980 --> 00:14:16,140 but as you'll see in a second, 378 00:14:16,160 --> 00:14:16,940 we can do it really fast. 379 00:14:18,440 --> 00:14:20,100 So how big a search engine do you get? 380 00:14:20,300 --> 00:14:22,140 Well, our average crawl created a search engine 381 00:14:22,140 --> 00:14:23,920 that would have had about a million torrents in it. 382 00:14:24,260 --> 00:14:26,200 For comparison, this is a pretty good fraction, 383 00:14:26,220 --> 00:14:26,300 but it's not a whole lot. 384 00:14:26,300 --> 00:14:27,540 This is a fraction of what the Pirate Bay has. 385 00:14:27,640 --> 00:14:29,620 They've indexed about 2.8 million torrents 386 00:14:29,620 --> 00:14:30,320 last time I checked. 387 00:14:30,820 --> 00:14:32,200 So it's not a complete replacement. 388 00:14:32,340 --> 00:14:33,940 People aren't gonna build torrent sites like this 389 00:14:33,940 --> 00:14:34,680 if they don't have to. 390 00:14:35,660 --> 00:14:36,200 Excuse me. 391 00:14:37,300 --> 00:14:39,060 But it's a pretty good fraction, 392 00:14:39,320 --> 00:14:42,360 and it turns out we find that the most popular torrents 393 00:14:42,360 --> 00:14:44,220 are a lot more popular than the rest. 394 00:14:44,400 --> 00:14:46,020 So torrents don't have a long tail distribution. 395 00:14:46,540 --> 00:14:49,120 So as long as we get most of the most popular torrents, 396 00:14:49,120 --> 00:14:49,980 we're actually doing really good. 397 00:14:51,440 --> 00:14:52,560 How long does it take? 398 00:14:52,800 --> 00:14:54,880 The crawler runs for about an hour and 20 minutes, 399 00:14:55,020 --> 00:14:55,400 80 minutes. 400 00:14:55,400 --> 00:14:57,100 And you have to wait about 20 minutes 401 00:14:57,100 --> 00:14:58,680 for all the import into the database 402 00:14:58,680 --> 00:14:59,780 and the indexing to happen. 403 00:14:59,900 --> 00:15:01,220 So it's a total of 100 minutes, 404 00:15:01,400 --> 00:15:02,560 which is less than two hours. 405 00:15:02,680 --> 00:15:05,280 So you can build your search engine pretty damn fast. 406 00:15:05,800 --> 00:15:07,960 You can go even faster if you've got more bandwidth. 407 00:15:08,120 --> 00:15:09,100 So if you want to pay Amazon 408 00:15:09,100 --> 00:15:12,100 to throw in your crawler on EC2, great. 409 00:15:12,620 --> 00:15:14,400 And if you want to wait longer, 410 00:15:14,560 --> 00:15:15,780 you can build a bigger search engine. 411 00:15:18,120 --> 00:15:19,580 Now how well does monitoring work? 412 00:15:19,820 --> 00:15:21,580 Over that 16-day period, 413 00:15:21,720 --> 00:15:23,780 we tracked eight million IP addresses 414 00:15:25,400 --> 00:15:27,060 downloading one and a half million torrents. 415 00:15:27,060 --> 00:15:29,840 So pretty sizable number, especially for just two weeks. 416 00:15:30,740 --> 00:15:32,340 Now to give you kind of a flavor 417 00:15:32,340 --> 00:15:35,340 of the kind of spy we're able to do, 418 00:15:35,920 --> 00:15:37,940 first we looked up the top seven torrents. 419 00:15:37,940 --> 00:15:39,380 Yeah, there's been a ton of studies that did this, 420 00:15:39,440 --> 00:15:41,220 but this one is like direct from the DHT. 421 00:15:41,940 --> 00:15:44,480 Unlike that other study, there was some accusation 422 00:15:44,480 --> 00:15:46,140 that their top torrents were fake. 423 00:15:46,260 --> 00:15:49,740 I attempted to verify and most of these were not fake. 424 00:15:49,920 --> 00:15:51,160 So if you look at this list, 425 00:15:51,300 --> 00:15:53,020 what you notice is that they're all popular 426 00:15:53,020 --> 00:15:54,500 recent TV and movies. 427 00:15:55,400 --> 00:15:57,620 They're probably not legit, right? 428 00:15:57,680 --> 00:15:59,480 It doesn't, it seems unlikely 429 00:16:00,200 --> 00:16:02,140 that these are legally distributed. 430 00:16:02,300 --> 00:16:04,100 It looks like somebody's probably infringing copyright 431 00:16:04,100 --> 00:16:06,340 at least in the US by distributing this. 432 00:16:06,520 --> 00:16:09,140 And by the way, that's the second to last episode of Lost, 433 00:16:09,280 --> 00:16:10,060 not the last one. 434 00:16:10,140 --> 00:16:12,060 Unfortunately, we had to stop like right before 435 00:16:12,060 --> 00:16:13,640 the last episode of Lost came out, 436 00:16:13,700 --> 00:16:15,700 which would have been really cool, but that's life. 437 00:16:16,560 --> 00:16:20,260 All right, so it looks like the top torrents are all pirated, 438 00:16:20,320 --> 00:16:23,060 but what about, well, maybe the rest of it's just Linux ISOs. 439 00:16:23,100 --> 00:16:25,180 So we dug through the list. 440 00:16:25,400 --> 00:16:27,360 I looked at the file names and the titles 441 00:16:27,360 --> 00:16:28,900 for the top thousand torrents, 442 00:16:28,900 --> 00:16:31,180 and there was nothing in there that was obviously legit, 443 00:16:31,380 --> 00:16:33,320 except for one torrent. 444 00:16:33,420 --> 00:16:35,620 There was one legit thing in the top thousand, 445 00:16:35,700 --> 00:16:37,760 and it was a subscription to a search for porn. 446 00:16:39,140 --> 00:16:41,100 So as far as we can tell, 447 00:16:41,280 --> 00:16:44,640 it doesn't look like y'all are mostly downloading Linux ISOs 448 00:16:44,640 --> 00:16:46,160 on this particular DHT. 449 00:16:46,900 --> 00:16:48,460 So you're gonna have to do another study 450 00:16:48,460 --> 00:16:50,280 if you want something that makes it look like it's legit. 451 00:16:50,380 --> 00:16:52,040 Sorry, I couldn't really conclude that. 452 00:16:52,940 --> 00:16:55,300 The other thing we can do is track the popularity 453 00:16:55,300 --> 00:16:56,200 of stuff over time. 454 00:16:56,420 --> 00:16:58,100 So this is the penultimate episode of Lost. 455 00:16:58,300 --> 00:17:00,840 It aired on Tuesday, May 18th. 456 00:17:00,920 --> 00:17:03,100 It becomes available on BitTorrent in the crawl 457 00:17:03,100 --> 00:17:04,540 immediately after it airs. 458 00:17:04,560 --> 00:17:05,120 You guys are fast. 459 00:17:06,680 --> 00:17:09,660 But it's not very popular until Friday rolls around. 460 00:17:09,960 --> 00:17:11,800 And so you can make two arguments with this. 461 00:17:12,020 --> 00:17:13,580 You could try to say that, 462 00:17:13,620 --> 00:17:15,280 whoa, people are just using BitTorrent 463 00:17:15,280 --> 00:17:16,840 to time shift their viewing of Lost 464 00:17:16,840 --> 00:17:18,100 because they missed it on Tuesday. 465 00:17:18,660 --> 00:17:20,160 The other argument you can make, 466 00:17:20,220 --> 00:17:21,720 which is probably equally valid, 467 00:17:21,720 --> 00:17:23,200 so this doesn't really say either way, 468 00:17:23,380 --> 00:17:24,680 is that pirates are lazy 469 00:17:24,680 --> 00:17:26,600 and they don't have time to torrent stuff until Friday. 470 00:17:27,040 --> 00:17:28,860 Right, so this could go either way. 471 00:17:30,320 --> 00:17:32,660 Looks like I've got a little bit of, no. 472 00:17:33,400 --> 00:17:35,480 All right, so that gives you kind of a flavor 473 00:17:35,480 --> 00:17:36,440 of the monitoring we can do. 474 00:17:36,520 --> 00:17:38,060 If I've got time, I'll show you a couple more charts. 475 00:17:38,320 --> 00:17:40,220 But let me start wrapping it up. 476 00:17:40,540 --> 00:17:42,340 All right, so with this DHT crawler, 477 00:17:42,340 --> 00:17:44,180 if you crawl to use DHT, you can do two things. 478 00:17:44,300 --> 00:17:46,520 You can create big BitTorrent search engines fast, 479 00:17:47,080 --> 00:17:49,620 and you can spy on eight million people in two weeks. 480 00:17:50,380 --> 00:17:51,440 Now, what I'm gonna start, 481 00:17:51,440 --> 00:17:53,200 one thing we conclude from that 482 00:17:53,200 --> 00:17:55,600 is that there's not really a whole lot of point 483 00:17:55,600 --> 00:17:57,780 in all these lawsuits against torrent sites, right? 484 00:17:57,940 --> 00:18:00,480 There's not really cut off the head and the body will die. 485 00:18:00,640 --> 00:18:02,740 It's more like even if you cut off all the heads, 486 00:18:02,860 --> 00:18:04,180 we'll just grow new ones in two hours. 487 00:18:04,420 --> 00:18:05,300 So what's really the point? 488 00:18:06,260 --> 00:18:09,080 The flip side of this is that even moving to the DHT 489 00:18:09,080 --> 00:18:10,740 is not gonna magically turn BitTorrent 490 00:18:10,740 --> 00:18:12,160 into some anonymous protocol, right? 491 00:18:12,320 --> 00:18:14,480 Even if there is only DHT tracking, 492 00:18:14,640 --> 00:18:15,920 it's not gonna help people hide 493 00:18:15,920 --> 00:18:18,040 because we can spy on people using just the DHT. 494 00:18:19,020 --> 00:18:21,060 So what we expect to see in the future 495 00:18:21,440 --> 00:18:24,400 is DHT poisoning, so attacks that make it harder 496 00:18:24,400 --> 00:18:25,860 to use the DHT-defined peers 497 00:18:25,860 --> 00:18:27,560 and harder to do this kind of search engine building. 498 00:18:28,300 --> 00:18:30,260 And if you wanna continue stopping, 499 00:18:31,360 --> 00:18:33,700 if you wanna continue trying to stop BitTorrent 500 00:18:34,220 --> 00:18:36,700 by suing people, the only people really left to sue 501 00:18:36,700 --> 00:18:38,840 are the users and the releasers, 502 00:18:38,880 --> 00:18:40,920 which I imagine is a big portion of the audience. 503 00:18:41,200 --> 00:18:42,360 So look out for lawsuits. 504 00:18:45,440 --> 00:18:46,700 So here's a couple links. 505 00:18:46,800 --> 00:18:49,540 The top one there is just the basic views page about the DHT. 506 00:18:49,680 --> 00:18:51,120 The second one there is really important. 507 00:18:51,440 --> 00:18:53,200 It's on the slides, on the CD. 508 00:18:53,540 --> 00:18:55,680 It's gonna have updated slides. 509 00:18:56,000 --> 00:18:57,880 It's got a link to the paper that goes with this talk, 510 00:18:58,000 --> 00:18:58,940 which has more pretty charts, 511 00:18:59,300 --> 00:19:01,140 and it's got a client for the views DHT. 512 00:19:02,280 --> 00:19:04,120 And then those are the two papers I referenced. 513 00:19:04,260 --> 00:19:06,240 The top one there is spying the world from your laptop. 514 00:19:06,520 --> 00:19:08,720 Bottom one is our paper, 515 00:19:08,820 --> 00:19:11,060 which talks about how to build a views DHT crawler. 516 00:19:11,400 --> 00:19:12,520 I think I got one minute, 517 00:19:12,600 --> 00:19:13,780 so I'll show you one more pretty chart. 518 00:19:14,000 --> 00:19:16,260 This is torrent popularity on a log log scale. 519 00:19:16,980 --> 00:19:18,300 So the scale is not linear. 520 00:19:18,500 --> 00:19:20,480 The little inset there has a linear scale. 521 00:19:20,480 --> 00:19:22,340 And just the cool thing about this 522 00:19:22,340 --> 00:19:24,600 is that the most popular torrents are really popular, 523 00:19:24,780 --> 00:19:26,980 but popularity falls off super fast. 524 00:19:27,180 --> 00:19:28,480 So if you catch like the top, 525 00:19:28,640 --> 00:19:30,840 I think it was 17% of torrents, 526 00:19:31,300 --> 00:19:34,100 you've got almost all of what's interesting. 527 00:19:34,400 --> 00:19:35,900 All right, man, I think I'm out of time, 528 00:19:35,940 --> 00:19:37,760 so I will take questions in the Q&A room. 529 00:19:38,040 --> 00:19:38,560 Thank you.