1 00:00:00,500 --> 00:00:09,080 So today's agenda, we're going to review some basic screen scraper theory, not too much, but a little bit. 2 00:00:10,060 --> 00:00:15,760 We're going to define what I constitute as being a difficult case, difficult site to screen scrape. 3 00:00:17,220 --> 00:00:20,860 I'm going to demo some screen scraper tricks. 4 00:00:23,040 --> 00:00:29,020 And when you look at what I'm doing, you're going to say, man, that's really, how do you manage something like that? 5 00:00:29,020 --> 00:00:34,000 Well, I'm actually going to show you some ideas for some large-scale deployment of this technique. 6 00:00:35,640 --> 00:00:42,640 And we're going to wrap things up with a heartwarming moment with captchas and puppies. 7 00:00:45,360 --> 00:00:51,140 Okay, so what I'm going to show you is some rather unusual ways to do screen scraping, but I think pretty effective. 8 00:00:51,900 --> 00:00:56,700 You're not going to walk out of here with a set of scripts you can use, 9 00:00:56,800 --> 00:00:58,840 but I'm hoping that you walk out of here with some ideas. 10 00:00:59,020 --> 00:01:04,920 What I want to do is I want to expose you to some stuff here and kind of get you thinking along some new lines, hopefully. 11 00:01:08,120 --> 00:01:16,100 So I'm going to talk about a couple tools, and I had some criteria for selecting what I was going to talk about today. 12 00:01:16,560 --> 00:01:17,900 They had to meet three criteria. 13 00:01:18,080 --> 00:01:22,560 Number one, had to be completely customizable, completely hackable. 14 00:01:23,800 --> 00:01:25,440 Should be free or open source. 15 00:01:26,760 --> 00:01:28,860 And number three, should be platform independent. 16 00:01:29,020 --> 00:01:37,920 Generally, what I do is I develop in Windows, and then I deploy either in Windows or with Ubuntu or FreeBSD. 17 00:01:39,100 --> 00:01:40,280 A little bit about me. 18 00:01:40,400 --> 00:01:42,240 I am Minneapolis-based. 19 00:01:42,440 --> 00:01:45,080 I've been writing bots for about 15 years. 20 00:01:45,400 --> 00:01:46,880 There's a picture of my city. 21 00:01:48,140 --> 00:01:50,820 Soon to be Las Vegas-bound, hopefully. 22 00:01:50,940 --> 00:01:51,980 I'll be living here in a couple months. 23 00:01:53,340 --> 00:01:58,280 Most of my clients are outside of the U.S., either European or Asian. 24 00:01:59,820 --> 00:02:02,360 I'm wearing my DC-612 shirt. 25 00:02:02,660 --> 00:02:04,120 Anybody here from DC-612? 26 00:02:07,140 --> 00:02:10,640 I'm a big supporter of local DEF CON groups. 27 00:02:12,620 --> 00:02:13,380 Seek them out. 28 00:02:13,500 --> 00:02:14,660 They're all over the place. 29 00:02:15,020 --> 00:02:19,720 And if you don't have one in your area, there's nothing keeping you from creating one. 30 00:02:24,000 --> 00:02:28,360 Real quick, back in DEF CON 5 was my first DEF CON. 31 00:02:28,500 --> 00:02:29,000 I was in the U.S. and I was in the U.S. and I was in the U.S. and I was in the U.S. and I was in the U.S. and I was in the U.S. and I was in the U.S. and I was in the U.S. and I was in the U.S. and I was in the U.S. and I was in the U.S. 32 00:02:29,020 --> 00:02:30,580 I recovered. 33 00:02:30,880 --> 00:02:33,620 I covered it for Computer World magazine. 34 00:02:33,940 --> 00:02:36,980 I think I've only missed three DEF CONs since DEF CON 5. 35 00:02:37,480 --> 00:02:40,540 DEF CON 10, I did an introduction to writing spiders and agents. 36 00:02:41,020 --> 00:02:43,880 DEF CON 11, I did one on online corporate intelligence. 37 00:02:44,340 --> 00:02:46,960 Two years ago, I did one on executable images. 38 00:02:47,560 --> 00:02:54,480 And not only do I keep getting e-mail about that one, I actually get phone calls yet regarding that particular talk. 39 00:02:55,760 --> 00:02:57,560 And today we're going to talk about... 40 00:02:58,540 --> 00:03:01,600 Screen scrapers and scraping difficult websites. 41 00:03:03,440 --> 00:03:07,220 Two years ago, I had a book came out, and this is my connection with No Starch. 42 00:03:08,760 --> 00:03:14,060 It's available in English, Italian, supposedly a Russian copy is coming out. 43 00:03:14,100 --> 00:03:14,720 I haven't seen it yet. 44 00:03:15,040 --> 00:03:17,480 The Chinese version just came out a couple months ago. 45 00:03:19,200 --> 00:03:23,960 So, I talk about a lot of kind of traditional techniques and strategies in my book. 46 00:03:24,160 --> 00:03:25,960 None of that is obsolete. 47 00:03:26,500 --> 00:03:27,540 Basically, the things that I do... 48 00:03:27,540 --> 00:03:33,020 The things that I'm showing you today are things you supplement those concepts and tools with. 49 00:03:34,620 --> 00:03:35,140 Okay. 50 00:03:35,480 --> 00:03:37,020 Why are screen scrapers important? 51 00:03:37,980 --> 00:03:40,320 It always amazes me. 52 00:03:40,420 --> 00:03:46,780 We've got, with the Internet, we've got the largest collection of information and services ever compiled. 53 00:03:47,080 --> 00:03:48,940 And they're all digitized. 54 00:03:49,140 --> 00:03:51,340 You can access them through a common format. 55 00:03:51,620 --> 00:03:57,280 And it just amazes me that everybody uses the exact same tool, the browser. 56 00:03:57,540 --> 00:03:58,660 To access it, right? 57 00:03:59,920 --> 00:04:00,860 Think about it. 58 00:04:00,960 --> 00:04:02,220 I mean, it doesn't make any sense. 59 00:04:02,520 --> 00:04:08,460 It's like every problem's a nail and the solution's always a hammer, right? 60 00:04:10,700 --> 00:04:15,280 Browsers, in order to do what they're doing and to do the wide variety of things that they do, 61 00:04:15,340 --> 00:04:19,720 they have to be very general purpose, and they make an awful lot of compromises. 62 00:04:20,620 --> 00:04:22,400 First off, they're very manual tools. 63 00:04:22,600 --> 00:04:25,280 And if you have people involved, you're going to get error. 64 00:04:25,860 --> 00:04:27,180 And it's time consuming. 65 00:04:27,180 --> 00:04:32,000 Which means it's also expensive to use browsers in a corporate setting. 66 00:04:33,360 --> 00:04:37,020 A browser can't make any decisions for you, like a web bot can. 67 00:04:38,340 --> 00:04:39,600 Browsers are not proactive. 68 00:04:39,900 --> 00:04:44,860 A browser is never going to go off and tell you when something happened online as it's happening. 69 00:04:45,800 --> 00:04:54,720 And what I tell people is that you will never, ever be able to excel by using the same tools that everybody else is using. 70 00:04:54,980 --> 00:04:56,640 So if you're doing something online, 71 00:04:56,640 --> 00:04:59,120 and the internet is important, 72 00:04:59,440 --> 00:05:03,020 and you use the exact same tools that your competitors are using, 73 00:05:03,260 --> 00:05:06,020 you'll never get a competitive advantage doing that. 74 00:05:06,180 --> 00:05:07,120 You're just going to... 75 00:05:07,820 --> 00:05:10,340 If you're lucky, you'll do as well as your competition. 76 00:05:11,920 --> 00:05:15,140 Okay, quick review of traditional screen scraping. 77 00:05:16,480 --> 00:05:19,060 By that I mean downloading web pages, 78 00:05:19,800 --> 00:05:20,660 managing cookies, 79 00:05:22,180 --> 00:05:23,460 handling encryption, 80 00:05:25,260 --> 00:05:26,540 server redirection, 81 00:05:27,420 --> 00:05:28,660 hiding your identity, 82 00:05:28,880 --> 00:05:32,020 looking stealthy, using proxies, random timing, 83 00:05:32,260 --> 00:05:33,680 trying to look like a person, 84 00:05:35,320 --> 00:05:36,560 emulating form submission, 85 00:05:36,780 --> 00:05:37,960 that's also a very important thing, 86 00:05:39,320 --> 00:05:41,320 and parsing information from the web, 87 00:05:42,160 --> 00:05:45,480 and then taking action on those things that you find. 88 00:05:47,440 --> 00:05:49,360 Now all those things are... 89 00:05:49,360 --> 00:05:50,500 There's a... 90 00:05:50,500 --> 00:05:56,220 When my book came out, I also open sourced a set of libraries for writing spiders and bots and that kind of stuff. 91 00:05:56,640 --> 00:05:59,140 And if you paid to get in, 92 00:05:59,180 --> 00:06:01,840 and if you have a CD, 93 00:06:03,720 --> 00:06:05,640 there's the URL where you can get those libraries. 94 00:06:07,820 --> 00:06:09,940 Okay, what constitutes a difficult case? 95 00:06:10,740 --> 00:06:14,000 I've noticed that within probably like the last two years, 96 00:06:14,100 --> 00:06:16,920 either by design or by accident, 97 00:06:17,560 --> 00:06:21,440 a lot of web pages are becoming much, much harder to scrape. 98 00:06:21,660 --> 00:06:23,240 And we'll look at some of those reasons. 99 00:06:24,000 --> 00:06:24,520 Um... 100 00:06:25,700 --> 00:06:26,620 If you ever get in a situation where you have to scrape, 101 00:06:26,620 --> 00:06:28,060 or go to a travel website, 102 00:06:28,920 --> 00:06:30,620 and you'll make your query, 103 00:06:30,640 --> 00:06:32,180 like you're looking for seats or something, 104 00:06:32,880 --> 00:06:34,720 and then you get one of these little pages, 105 00:06:34,840 --> 00:06:36,220 kind of like that, uh... 106 00:06:36,740 --> 00:06:38,040 little northwest thing there, 107 00:06:38,120 --> 00:06:39,580 where it's like, you know, waiting, 108 00:06:39,740 --> 00:06:41,300 processing your search. 109 00:06:42,000 --> 00:06:43,500 Basically what it's doing is, 110 00:06:43,640 --> 00:06:46,420 if you made a query, 111 00:06:46,560 --> 00:06:48,880 that takes a long time for it to fetch the stuff from the database, 112 00:06:49,300 --> 00:06:51,080 they basically give you something to look at, 113 00:06:51,240 --> 00:06:53,240 and the page just keeps refreshing 114 00:06:53,720 --> 00:06:54,880 until your data's ready, 115 00:06:55,000 --> 00:06:55,860 and then it presents your data. 116 00:06:56,620 --> 00:06:58,260 Um, this isn't really a difficult case. 117 00:06:58,360 --> 00:06:59,580 This is more of an annoyance. 118 00:06:59,900 --> 00:07:01,480 And there are ways of handling that. 119 00:07:01,580 --> 00:07:03,380 But it's still, it's an annoyance, for sure. 120 00:07:05,660 --> 00:07:08,840 Um, JavaScript can also be an annoyance. 121 00:07:09,280 --> 00:07:12,960 Uh, especially when JavaScript is used to 122 00:07:12,960 --> 00:07:16,920 to automatically modify forms after you hit the submit button. 123 00:07:17,460 --> 00:07:19,080 That happens very frequently. 124 00:07:20,140 --> 00:07:24,660 Um, and again, there's a URL with a form analyzer 125 00:07:24,660 --> 00:07:26,540 that's kind of handy for using on this kind of stuff. 126 00:07:26,620 --> 00:07:28,740 And basically what you do is you just, 127 00:07:28,840 --> 00:07:30,460 if there's a form that you want to analyze, 128 00:07:32,200 --> 00:07:35,120 you download that page, save it as, you know, 129 00:07:35,120 --> 00:07:36,080 to your local file, 130 00:07:36,600 --> 00:07:39,560 change the action to that URL, 131 00:07:39,720 --> 00:07:41,200 and you fill out the form, 132 00:07:41,400 --> 00:07:43,180 assuming that you also have all the JavaScript 133 00:07:43,180 --> 00:07:44,060 and everything you need, 134 00:07:44,200 --> 00:07:46,400 it'll just redirect you to this web page 135 00:07:46,400 --> 00:07:48,100 and it does this analysis of the form, 136 00:07:48,260 --> 00:07:50,580 and it's pretty handy when you're trying to analyze forms. 137 00:07:53,140 --> 00:07:54,360 The thing that's become 138 00:07:55,180 --> 00:07:56,560 really prevalent is, 139 00:07:56,620 --> 00:07:57,500 is AJAX. 140 00:07:58,260 --> 00:07:59,120 And, um, 141 00:08:00,000 --> 00:08:02,580 AJAX isn't just being used for little things anymore. 142 00:08:02,900 --> 00:08:04,380 Uh, it used to be used 143 00:08:04,380 --> 00:08:05,720 for things like, um, 144 00:08:05,960 --> 00:08:08,040 you know, changing a record in a database 145 00:08:08,040 --> 00:08:08,980 or something like that. 146 00:08:09,420 --> 00:08:12,400 AJAX is now being used a lot for 147 00:08:13,520 --> 00:08:14,520 flowing content 148 00:08:14,520 --> 00:08:15,140 on pages. 149 00:08:15,560 --> 00:08:18,460 Um, which is kind of bad web design 150 00:08:18,460 --> 00:08:20,740 because it basically defeats 151 00:08:20,740 --> 00:08:21,660 your back button, 152 00:08:21,800 --> 00:08:23,620 which is something you never really want to do. 153 00:08:24,000 --> 00:08:26,220 But like if you go to Expedia, 154 00:08:26,620 --> 00:08:27,360 or Twitter, 155 00:08:27,540 --> 00:08:29,580 or a lot of modern web pages, 156 00:08:29,800 --> 00:08:31,580 and if you go to the second page 157 00:08:31,580 --> 00:08:32,940 of search results 158 00:08:32,940 --> 00:08:35,740 and do a show source, 159 00:08:36,140 --> 00:08:38,740 it won't show anything that's on the second page 160 00:08:38,740 --> 00:08:40,460 because that stuff is all dynamically flowing. 161 00:08:40,960 --> 00:08:42,260 So that is a problem. 162 00:08:42,420 --> 00:08:43,860 That's a very difficult problem 163 00:08:44,500 --> 00:08:45,920 when you're using traditional 164 00:08:47,220 --> 00:08:48,500 techniques like curl 165 00:08:48,500 --> 00:08:49,900 to download web pages. 166 00:08:51,520 --> 00:08:52,840 Flash is a problem 167 00:08:52,840 --> 00:08:54,660 primarily when it's used 168 00:08:54,660 --> 00:08:55,260 in navigation. 169 00:08:56,800 --> 00:08:58,480 Um, there are techniques 170 00:08:58,480 --> 00:09:00,680 for extracting text from Flash. 171 00:09:00,880 --> 00:09:02,100 So that's not such a big deal. 172 00:09:02,400 --> 00:09:04,340 But when it's used as navigation 173 00:09:04,340 --> 00:09:05,960 that is a difficult thing. 174 00:09:06,180 --> 00:09:07,980 Same thing with dynamic HTML. 175 00:09:08,540 --> 00:09:10,360 Um, the other thing that's really 176 00:09:10,360 --> 00:09:11,980 gotten bad is some just 177 00:09:12,620 --> 00:09:14,000 bizarre cookie behavior. 178 00:09:14,660 --> 00:09:16,100 Um, you'll have 179 00:09:16,840 --> 00:09:18,720 and again, I'm assuming 180 00:09:18,720 --> 00:09:20,160 that the only reason for doing this 181 00:09:20,160 --> 00:09:22,000 is to keep people from scraping the pages 182 00:09:22,620 --> 00:09:24,660 is you will find, I've seen things 183 00:09:24,660 --> 00:09:26,320 like where there is 184 00:09:27,480 --> 00:09:28,440 JavaScript that 185 00:09:28,440 --> 00:09:30,680 assembles itself after it flows 186 00:09:30,680 --> 00:09:31,800 and then writes 187 00:09:32,460 --> 00:09:33,800 cookies in certain sequences. 188 00:09:34,240 --> 00:09:36,240 Um, I've seen a lot of 189 00:09:36,240 --> 00:09:38,180 images that are writing cookies. 190 00:09:38,600 --> 00:09:40,180 Um, so maybe they saw my talk 191 00:09:40,180 --> 00:09:41,320 two years ago, I don't know. 192 00:09:41,940 --> 00:09:43,880 Um, but just really strange 193 00:09:43,880 --> 00:09:46,560 cookie behavior. And I've tried sitting there with 194 00:09:46,560 --> 00:09:48,760 um, you know, analyzing 195 00:09:48,760 --> 00:09:50,420 network traffic and stuff and trying to 196 00:09:50,420 --> 00:09:52,500 recreate the stuff and it's really, really 197 00:09:52,500 --> 00:09:53,380 difficult to do. 198 00:09:55,140 --> 00:09:56,540 Uh, this is one of my favorite 199 00:09:56,620 --> 00:09:58,600 ones. Um, I've seen this from 200 00:09:58,600 --> 00:10:00,060 time to time where 201 00:10:00,460 --> 00:10:02,520 instead of having a name for a form 202 00:10:02,520 --> 00:10:04,140 element, you'll get like a 203 00:10:04,140 --> 00:10:06,240 you know, a 200 character hash 204 00:10:06,240 --> 00:10:08,020 that seems random. 205 00:10:08,840 --> 00:10:10,420 So it makes it very difficult 206 00:10:10,420 --> 00:10:12,460 to look for, like if you want to emulate 207 00:10:12,460 --> 00:10:13,900 a form looking for the 208 00:10:13,900 --> 00:10:15,580 uh, um 209 00:10:16,200 --> 00:10:18,320 you know, the form name. Yeah? 210 00:10:23,120 --> 00:10:23,820 It's a what? 211 00:10:27,620 --> 00:10:28,060 Okay. 212 00:10:32,920 --> 00:10:33,360 Okay. 213 00:10:36,240 --> 00:10:38,220 And, and you really don't have to. 214 00:10:38,340 --> 00:10:39,920 So, so 215 00:10:39,920 --> 00:10:41,920 the comment was that was made to 216 00:10:42,940 --> 00:10:44,140 preventage or um 217 00:10:44,140 --> 00:10:46,460 to prevent cross-site scripting 218 00:10:46,460 --> 00:10:47,080 kind of techniques. 219 00:10:48,260 --> 00:10:49,560 Okay. Um, 220 00:10:50,140 --> 00:10:52,500 for me it's just a pain. It makes it hard 221 00:10:52,500 --> 00:10:53,900 to write scrapers. 222 00:10:55,080 --> 00:10:56,460 But I'm going to show you how to defeat 223 00:10:56,620 --> 00:10:58,280 that. The problem is, is that 224 00:10:58,280 --> 00:11:00,260 with all of the browser's limitations 225 00:11:00,260 --> 00:11:01,580 to a large extent, 226 00:11:02,160 --> 00:11:04,560 we're still kind of tied to the browser. Because the browser 227 00:11:04,560 --> 00:11:06,720 does handle all this stuff automatically. 228 00:11:07,460 --> 00:11:07,880 Um, 229 00:11:09,180 --> 00:11:10,400 sometimes you can fool 230 00:11:10,400 --> 00:11:12,500 a server into giving you simpler content. 231 00:11:13,600 --> 00:11:14,440 For example, 232 00:11:14,520 --> 00:11:15,660 you can, you can um 233 00:11:16,480 --> 00:11:18,660 spoof your bot and tell it it's an iPhone 234 00:11:18,660 --> 00:11:20,520 or something. So you'll get 235 00:11:20,520 --> 00:11:22,660 possibly simpler content or some kind of 236 00:11:22,660 --> 00:11:24,220 mobile device. Um, 237 00:11:24,400 --> 00:11:26,520 but the real, what I found 238 00:11:26,620 --> 00:11:28,480 is that it became very important to find a way 239 00:11:28,480 --> 00:11:30,640 to A, emulate a browser 240 00:11:30,640 --> 00:11:32,280 and maintain 241 00:11:32,280 --> 00:11:34,640 full capability to do 242 00:11:34,640 --> 00:11:35,820 anything I wanted to do 243 00:11:36,420 --> 00:11:37,680 while I'm emulating a browser. 244 00:11:38,420 --> 00:11:39,640 So here's what I came up with. 245 00:11:40,140 --> 00:11:42,560 Um, I started using iMacro. How many people 246 00:11:42,560 --> 00:11:44,040 here use iMacros? Can I just see a 247 00:11:44,480 --> 00:11:46,320 show of hands? Okay, good, good, good. 248 00:11:46,680 --> 00:11:48,220 Um, iMacros 249 00:11:48,220 --> 00:11:49,580 is a browser plug-in. 250 00:11:50,060 --> 00:11:51,640 Uh, it's readily available. 251 00:11:51,920 --> 00:11:54,440 It meets all my criteria as far as being 252 00:11:54,440 --> 00:11:56,360 you know, free platform 253 00:11:56,620 --> 00:11:57,980 or independent. It solves 254 00:11:57,980 --> 00:12:00,500 every single difficult case that I've mentioned. 255 00:12:00,920 --> 00:12:02,860 Uh, when I discovered iMacros 256 00:12:03,520 --> 00:12:04,520 and some of these 257 00:12:04,520 --> 00:12:06,000 techniques, I swear it was like 258 00:12:06,000 --> 00:12:08,500 the gods handing me fire. It was like 259 00:12:08,500 --> 00:12:10,460 oh, thank you Jesus, this is 260 00:12:10,460 --> 00:12:12,340 wonderful. Um, because 261 00:12:12,340 --> 00:12:14,300 it, it is a incredibly great 262 00:12:14,300 --> 00:12:16,460 tool and you can 263 00:12:16,460 --> 00:12:18,520 hack it very 264 00:12:18,520 --> 00:12:20,460 successfully to do things 265 00:12:20,460 --> 00:12:22,400 well beyond what 266 00:12:22,400 --> 00:12:24,100 iMacros was ever designed to do. 267 00:12:24,360 --> 00:12:26,600 And we'll be demoing some of that stuff here today. 268 00:12:26,620 --> 00:12:27,260 Um, 269 00:12:28,800 --> 00:12:30,580 so iMacro solves all the difficult 270 00:12:30,580 --> 00:12:32,540 cases because it uses an 271 00:12:32,540 --> 00:12:34,120 actual browser. Okay, that's important. 272 00:12:34,740 --> 00:12:36,700 Um, and I'm gonna show you a few additional 273 00:12:36,700 --> 00:12:38,460 hacks now that 274 00:12:38,460 --> 00:12:40,520 uh, turn it into a serious screen scraping 275 00:12:40,520 --> 00:12:40,860 tool. 276 00:12:42,620 --> 00:12:43,740 Um, so anyway, 277 00:12:44,340 --> 00:12:45,820 like I said, it's, it's um, 278 00:12:46,880 --> 00:12:48,400 it's just an add-on for Firefox. 279 00:12:48,980 --> 00:12:50,460 It's also available for Internet 280 00:12:50,460 --> 00:12:52,500 Explorer. Uh, you just do a quick 281 00:12:52,500 --> 00:12:54,540 search on it, download it. It's a real quick 282 00:12:54,540 --> 00:12:56,600 and easy install. Uh, once it's 283 00:12:56,620 --> 00:12:58,640 installed, uh, you click 284 00:12:58,640 --> 00:12:59,800 the little iMacros 285 00:13:01,140 --> 00:13:01,900 thing up there, 286 00:13:02,020 --> 00:13:04,300 and that will bring up this side panel 287 00:13:04,300 --> 00:13:06,580 where you can do things like recording. So if you 288 00:13:06,580 --> 00:13:07,760 just hit the record button 289 00:13:08,340 --> 00:13:10,620 and enter a URL, for example 290 00:13:10,620 --> 00:13:12,500 fill in a form. This is not 291 00:13:12,500 --> 00:13:14,560 my real address, by the way. Um, 292 00:13:14,980 --> 00:13:16,580 hit the form, press save, 293 00:13:16,740 --> 00:13:18,160 and then stop the macro. 294 00:13:19,540 --> 00:13:20,480 And then you can replay 295 00:13:20,480 --> 00:13:22,360 it. You can, you can go in, you can pick 296 00:13:22,360 --> 00:13:24,480 the, uh, current macro, hit 297 00:13:24,480 --> 00:13:26,600 play, and uh, I'm gonna do it 298 00:13:26,620 --> 00:13:28,060 a quick demo here to show you how this works. 299 00:13:38,740 --> 00:13:40,620 So after, I'm gonna, I'm gonna explain a little 300 00:13:40,620 --> 00:13:42,280 bit what I'm doing here. Um, 301 00:13:42,480 --> 00:13:44,500 after doing a lot of talks, I, 302 00:13:44,620 --> 00:13:46,640 I know that it's 303 00:13:46,640 --> 00:13:48,500 best to keep your demos as simple 304 00:13:48,500 --> 00:13:50,460 as possible. So basically 305 00:13:50,460 --> 00:13:52,080 what I have here is I've got a 306 00:13:53,200 --> 00:13:54,560 copy of Apache running 307 00:13:54,560 --> 00:13:56,540 on my laptop. So this is, I'm not making any 308 00:13:56,620 --> 00:13:58,720 network connections outside of this machine. 309 00:13:58,820 --> 00:14:00,260 In fact, I'm not even on a network right now. 310 00:14:01,580 --> 00:14:02,660 So, here's what I do. 311 00:14:02,920 --> 00:14:04,700 I've got my URL here. I'm already 312 00:14:04,700 --> 00:14:05,760 at the page I wanna go to. 313 00:14:07,240 --> 00:14:08,600 So here's the, uh, little, 314 00:14:08,760 --> 00:14:10,400 here's, here's the iMacro's, um, 315 00:14:10,560 --> 00:14:12,180 icon. So you can 316 00:14:12,700 --> 00:14:13,980 turn the panel on and off. 317 00:14:15,800 --> 00:14:16,560 So I'm just gonna 318 00:14:16,560 --> 00:14:18,560 come in here, and I'm gonna click record. 319 00:14:19,280 --> 00:14:20,720 And I'm gonna hit the record button. 320 00:14:21,180 --> 00:14:22,740 And I'm gonna start filling stuff out. 321 00:14:23,100 --> 00:14:23,840 Where's my mouse? 322 00:14:24,960 --> 00:14:25,520 There we go. 323 00:14:28,000 --> 00:14:28,400 ... 324 00:14:28,400 --> 00:14:28,500 ... 325 00:14:38,800 --> 00:14:39,200 ... 326 00:14:42,800 --> 00:14:43,200 ... 327 00:14:43,200 --> 00:14:43,220 ... 328 00:14:44,800 --> 00:14:45,200 ... 329 00:14:45,200 --> 00:14:45,380 ... 330 00:14:45,380 --> 00:14:46,060 Okay, so I have 331 00:14:46,440 --> 00:14:48,400 filled in the form. I'm gonna hit 332 00:14:48,400 --> 00:14:50,440 save. You notice stuff happening in 333 00:14:50,440 --> 00:14:51,620 the, uh, left column? 334 00:14:52,240 --> 00:14:53,920 Okay, so I've got a result now. 335 00:14:54,120 --> 00:14:56,000 And I've got a whole bunch of stuff over here. 336 00:14:56,620 --> 00:14:58,760 This is the actual macro code over here. 337 00:14:59,400 --> 00:15:00,560 So if I hit stop, 338 00:15:00,800 --> 00:15:02,720 um, I can choose to save 339 00:15:02,720 --> 00:15:04,000 this macro if I want to. 340 00:15:04,380 --> 00:15:05,800 Or I can just come in here, 341 00:15:06,440 --> 00:15:07,860 and I can hit the, uh, the current 342 00:15:08,980 --> 00:15:10,660 macro. And I can come over here 343 00:15:10,660 --> 00:15:11,380 and say play. 344 00:15:12,960 --> 00:15:13,820 And it should 345 00:15:14,820 --> 00:15:16,020 redo what I just did. 346 00:15:20,240 --> 00:15:22,160 So it loaded the page. I've, I've got 347 00:15:22,740 --> 00:15:24,440 excessively long delays here, just 348 00:15:24,440 --> 00:15:25,440 for dramatic effect. 349 00:15:26,700 --> 00:15:28,600 This is gonna actually happen much quicker 350 00:15:28,600 --> 00:15:28,980 than this. 351 00:15:30,220 --> 00:15:30,600 ... 352 00:15:30,600 --> 00:15:31,200 ... 353 00:15:34,820 --> 00:15:36,240 Oh! What happened? 354 00:15:37,180 --> 00:15:37,200 ... 355 00:15:37,940 --> 00:15:39,880 I have absolutely no idea how that happened. 356 00:15:40,840 --> 00:15:42,460 Good thing I've got a canned version. 357 00:15:46,740 --> 00:15:47,300 ... 358 00:15:47,300 --> 00:15:47,420 ... 359 00:15:48,140 --> 00:15:48,700 ... 360 00:15:48,700 --> 00:15:49,120 ... 361 00:15:49,120 --> 00:15:51,160 ... ... 362 00:15:53,940 --> 00:15:54,420 ... 363 00:15:56,520 --> 00:15:58,720 I'll do the canned version while I'm talking here. 364 00:15:59,140 --> 00:16:00,840 Um, so this is, 365 00:16:00,860 --> 00:16:02,600 this in itself is very useful. 366 00:16:02,840 --> 00:16:05,060 Um, basically it's, it's 367 00:16:05,060 --> 00:16:06,860 almost like having active 368 00:16:06,860 --> 00:16:08,920 bookmarking. So not only can you 369 00:16:08,920 --> 00:16:10,520 bookmark a page, but you can actually 370 00:16:11,060 --> 00:16:12,500 go through a series of links. 371 00:16:13,020 --> 00:16:15,080 So, for example, if you have 372 00:16:15,080 --> 00:16:17,220 a page on, I don't know, 373 00:16:17,320 --> 00:16:18,900 some newspaper that you like. 374 00:16:19,120 --> 00:16:21,040 You could set this thing up to go ahead 375 00:16:21,040 --> 00:16:23,080 and, and click through whatever links it needs to 376 00:16:23,080 --> 00:16:24,400 click through to get to your page. 377 00:16:24,760 --> 00:16:27,140 And you could save a copy of it to read later. 378 00:16:27,380 --> 00:16:29,000 And you could run it on a cron. 379 00:16:29,040 --> 00:16:30,280 I mean, you could do all kinds of stuff like that. 380 00:16:30,700 --> 00:16:32,780 This, this in itself is, is 381 00:16:32,780 --> 00:16:35,080 somewhat limited, but, but it opens up a whole 382 00:16:35,080 --> 00:16:36,380 opportunity, um, 383 00:16:36,820 --> 00:16:37,900 whole set of opportunities. 384 00:16:38,840 --> 00:16:39,200 ... 385 00:16:39,740 --> 00:16:40,100 ... 386 00:16:41,040 --> 00:16:45,100 Okay, so let's 387 00:16:45,100 --> 00:16:46,380 look a little bit at what's going on here. 388 00:16:46,580 --> 00:16:48,860 Um, the real interesting part is 389 00:16:49,120 --> 00:16:49,920 line five, 390 00:16:51,360 --> 00:16:52,860 where it's basically saying, 391 00:16:53,060 --> 00:16:54,940 okay, go to this form, and 392 00:16:54,940 --> 00:16:56,760 here's the name of the element, 393 00:16:56,960 --> 00:16:58,780 and I want you to put this content in there. 394 00:16:59,080 --> 00:17:01,060 And it does the same thing on line six, seven, 395 00:17:01,100 --> 00:17:03,160 eight, and nine. And then on line ten, 396 00:17:03,340 --> 00:17:04,940 it essentially hits 397 00:17:04,940 --> 00:17:06,960 the save button. And, 398 00:17:07,080 --> 00:17:09,080 uh, that's what the macro looks like. It's, it's very, 399 00:17:09,180 --> 00:17:10,360 uh, very simple stuff. 400 00:17:12,220 --> 00:17:13,020 Um, where 401 00:17:13,020 --> 00:17:14,760 you don't have tags, 402 00:17:15,080 --> 00:17:16,960 for example, like that, that, uh, 403 00:17:17,040 --> 00:17:19,080 big long, um, I think it was 404 00:17:19,120 --> 00:17:20,980 the last one I showed you, the, the difficulties, 405 00:17:21,680 --> 00:17:23,140 where you've got the, the form 406 00:17:23,140 --> 00:17:24,940 name with the big hash, uh, 407 00:17:25,060 --> 00:17:26,560 you can hit x, y coordinates 408 00:17:26,560 --> 00:17:28,920 to find those. And what I've 409 00:17:28,920 --> 00:17:31,220 done is, if you have varying lengths of content, 410 00:17:31,760 --> 00:17:32,820 you basically do 411 00:17:32,820 --> 00:17:35,080 kind of like the way you would do a, uh, 412 00:17:35,100 --> 00:17:36,880 a sled, if you're doing a 413 00:17:36,880 --> 00:17:39,080 buffer overflow error. Instead of having a bunch 414 00:17:39,080 --> 00:17:41,000 of no-ops, you start clicking lower 415 00:17:41,000 --> 00:17:43,060 than where the button's gonna be, and you just keep clicking 416 00:17:43,060 --> 00:17:44,900 up with the width of the button 417 00:17:44,900 --> 00:17:47,060 until you hit it. It, it sounds stupid, 418 00:17:47,120 --> 00:17:48,120 but it works really well. 419 00:17:50,320 --> 00:17:51,240 Okay, so here's, 420 00:17:51,240 --> 00:17:53,020 here's the way I like to do these. I, I 421 00:17:53,020 --> 00:17:54,840 don't run macros the 422 00:17:54,840 --> 00:17:57,020 way I just showed you. What I do is I 423 00:17:57,020 --> 00:17:59,160 create a template file, and I'll show 424 00:17:59,160 --> 00:18:01,000 you a little bit more what I mean by that. 425 00:18:01,420 --> 00:18:03,060 Um, and then I run a PHP 426 00:18:03,060 --> 00:18:04,800 program that converts 427 00:18:04,800 --> 00:18:06,800 that template into the actual macro, 428 00:18:07,260 --> 00:18:08,660 and then I run the macro. 429 00:18:09,660 --> 00:18:10,980 So this is what my template 430 00:18:10,980 --> 00:18:12,760 file looks like. And here, 431 00:18:12,840 --> 00:18:14,880 basically all I've done is I've 432 00:18:14,880 --> 00:18:17,140 replaced all of the content 433 00:18:17,860 --> 00:18:18,560 with a 434 00:18:19,120 --> 00:18:20,940 variable. And I like to do something 435 00:18:20,940 --> 00:18:22,780 that makes the variable stand out, so 436 00:18:22,780 --> 00:18:25,060 it's basically, um, you know, 437 00:18:25,100 --> 00:18:26,960 pound underscore the name of the variable 438 00:18:26,960 --> 00:18:29,020 underscore pound. And it makes it 439 00:18:29,020 --> 00:18:30,760 very easy to do the next step, 440 00:18:31,300 --> 00:18:32,740 where basically I just do some 441 00:18:32,740 --> 00:18:34,960 substitution. So what I'll do then 442 00:18:34,960 --> 00:18:37,080 is I'll have my, uh, PHP program 443 00:18:37,080 --> 00:18:38,820 running, and I get some 444 00:18:38,820 --> 00:18:40,980 data from someplace, and we'll talk about where 445 00:18:40,980 --> 00:18:41,980 data comes from later. 446 00:18:42,880 --> 00:18:45,020 And I will pull in the, 447 00:18:45,040 --> 00:18:47,040 uh, template file, which I 448 00:18:47,040 --> 00:18:48,600 call, uh, protofile. 449 00:18:49,120 --> 00:18:50,860 And then I just do a whole bunch of string 450 00:18:50,860 --> 00:18:52,820 substitutions. So I substitute 451 00:18:53,380 --> 00:18:55,080 those variables that I put into 452 00:18:55,080 --> 00:18:56,340 the template with actual data, 453 00:18:56,840 --> 00:18:58,860 and then I write out the, uh, 454 00:18:59,000 --> 00:19:01,100 the macro. So this is a 455 00:19:01,100 --> 00:19:03,060 very typical way of the way I, I 456 00:19:03,060 --> 00:19:03,560 do things. 457 00:19:05,260 --> 00:19:07,020 Now, you can use this technique 458 00:19:07,020 --> 00:19:09,140 to do substitutions 459 00:19:09,140 --> 00:19:10,680 of field variables, 460 00:19:11,940 --> 00:19:13,040 URLs, you can 461 00:19:13,040 --> 00:19:14,980 change delay times, you can change 462 00:19:14,980 --> 00:19:17,060 destination files, um, 463 00:19:17,140 --> 00:19:19,100 basically anything you can do with a program, you can 464 00:19:19,120 --> 00:19:21,180 you can change. So it's actually very powerful. 465 00:19:22,260 --> 00:19:22,700 Uh, 466 00:19:22,860 --> 00:19:24,420 plus, you can also create loops, 467 00:19:25,000 --> 00:19:27,100 uh, you can change data sources, you can 468 00:19:27,100 --> 00:19:28,880 send status, status messages 469 00:19:29,360 --> 00:19:31,040 to a central server. There's all kinds 470 00:19:31,040 --> 00:19:31,720 of stuff you can do. 471 00:19:33,640 --> 00:19:34,920 Um, and then I launch 472 00:19:34,920 --> 00:19:36,740 the program from PHP, 473 00:19:37,480 --> 00:19:38,460 and, um, 474 00:19:39,720 --> 00:19:40,800 again, I don't know. 475 00:19:41,000 --> 00:19:42,820 Well, I guess you can see it. Um, 476 00:19:42,980 --> 00:19:45,020 basically, it's, you pull 477 00:19:45,020 --> 00:19:47,000 up Firefox, and you 478 00:19:47,000 --> 00:19:48,560 point to a, uh, particular 479 00:19:49,120 --> 00:19:50,980 uh, URL that 480 00:19:50,980 --> 00:19:51,660 runs your macro. 481 00:19:53,160 --> 00:19:54,940 Now, generally when I do this, 482 00:19:55,080 --> 00:19:57,060 I, I launch these usually from a 483 00:19:57,060 --> 00:19:58,960 cron file, or some kind of a scheduled 484 00:19:58,960 --> 00:20:01,160 task, and I've always 485 00:20:01,160 --> 00:20:03,120 had better luck doing this if I either 486 00:20:03,120 --> 00:20:04,300 do it from a bash program 487 00:20:04,960 --> 00:20:07,060 that calls the PHP, or 488 00:20:07,060 --> 00:20:09,120 in the case of Windows, if I have a batch file 489 00:20:09,120 --> 00:20:11,000 where that calls the PHP 490 00:20:11,000 --> 00:20:13,100 program. The other thing that's important 491 00:20:13,100 --> 00:20:15,060 to remember is that if you're doing this on 492 00:20:15,060 --> 00:20:16,560 a flavor of Unix, 493 00:20:16,760 --> 00:20:19,020 you want to make sure that you designate 494 00:20:19,120 --> 00:20:21,100 a display for this thing to, to show 495 00:20:21,100 --> 00:20:22,360 on, or else it's not gonna work. 496 00:20:22,720 --> 00:20:24,860 And you're gonna have a very long afternoon 497 00:20:24,860 --> 00:20:26,980 trying to figure out why your stuff isn't running. 498 00:20:29,360 --> 00:20:31,360 Okay, couple hints for using iMacros. 499 00:20:31,960 --> 00:20:32,760 I always 500 00:20:32,760 --> 00:20:34,240 dedicate a browser, 501 00:20:34,880 --> 00:20:36,820 uh, for using iMacros on a particular 502 00:20:36,820 --> 00:20:39,000 machine. Um, and 503 00:20:39,000 --> 00:20:41,120 the reason for this is that if you're doing this correctly, 504 00:20:41,640 --> 00:20:43,020 one of the first things you do 505 00:20:43,020 --> 00:20:45,200 every time you have a session is, 506 00:20:45,200 --> 00:20:46,720 uh, you clear out all your cookies. 507 00:20:47,340 --> 00:20:48,900 And that just kind of makes it difficult 508 00:20:49,120 --> 00:20:50,960 for normal browsing if you do that. 509 00:20:52,080 --> 00:20:52,100 Um, 510 00:20:53,220 --> 00:20:55,120 if you're gonna do this seriously, 511 00:20:55,380 --> 00:20:56,820 I, I recommend buying the commercial 512 00:20:56,820 --> 00:20:58,900 version of iMacros. 513 00:20:59,000 --> 00:21:00,380 They actually have their own browser. 514 00:21:00,920 --> 00:21:02,980 Um, for no other reason than it 515 00:21:02,980 --> 00:21:04,300 gives you better version control. 516 00:21:04,640 --> 00:21:06,880 So you don't have iMacros 517 00:21:06,880 --> 00:21:08,980 keeping telling you that you've got an update, or Firefox 518 00:21:08,980 --> 00:21:11,020 telling you you have an update. You know, 519 00:21:11,040 --> 00:21:13,080 it's nice to test things before they go into production, 520 00:21:13,260 --> 00:21:14,960 and that just kind of makes it a little more difficult. 521 00:21:15,500 --> 00:21:16,960 Um, the other thing is, 522 00:21:17,100 --> 00:21:19,040 um, iMacros is available 523 00:21:19,120 --> 00:21:20,160 for Internet Explorer. 524 00:21:20,580 --> 00:21:23,040 I don't use that because I found it to be 525 00:21:23,040 --> 00:21:23,660 a little flaky. 526 00:21:25,100 --> 00:21:26,980 The other thing is that if you're gonna be 527 00:21:26,980 --> 00:21:28,820 doing this, and if you're gonna be launching, uh, 528 00:21:28,960 --> 00:21:30,320 a macro from a 529 00:21:31,080 --> 00:21:32,960 cron, it would be to make sure that 530 00:21:32,960 --> 00:21:34,680 you've got the iMacros activated 531 00:21:34,680 --> 00:21:36,560 in Firefox before it comes up. 532 00:21:36,660 --> 00:21:38,960 Or else your macro's not gonna run, and again, 533 00:21:39,120 --> 00:21:40,480 you're gonna have a very long afternoon. 534 00:21:43,360 --> 00:21:44,240 Okay, um, 535 00:21:44,400 --> 00:21:47,020 a couple of things I like to do in iMacros 536 00:21:47,020 --> 00:21:49,060 headers. As I said, a very long 537 00:21:49,120 --> 00:21:50,980 timeout. If you set a timeout for 538 00:21:50,980 --> 00:21:53,100 240, that's, uh, what, 539 00:21:53,140 --> 00:21:55,160 240 seconds. What is that? That's like 540 00:21:55,160 --> 00:21:56,900 four minutes. Um, 541 00:21:57,660 --> 00:21:59,040 especially if you're going through Tor 542 00:21:59,040 --> 00:22:00,920 or something where you've got a really slow network 543 00:22:00,920 --> 00:22:02,200 connection, um, 544 00:22:03,180 --> 00:22:04,920 time is usually not of the essence, 545 00:22:05,020 --> 00:22:06,020 so I just let the things run. 546 00:22:07,200 --> 00:22:09,100 Um, I generally tell it to ignore 547 00:22:09,100 --> 00:22:11,040 all errors. I clear 548 00:22:11,040 --> 00:22:12,760 all the cookies. Um, 549 00:22:12,900 --> 00:22:15,140 I close all my tabs, and I'll be showing 550 00:22:15,140 --> 00:22:17,200 you the importance of this in just a bit. 551 00:22:18,220 --> 00:22:19,100 Um, you have to 552 00:22:19,120 --> 00:22:21,020 have the option of turning images on and off, 553 00:22:21,180 --> 00:22:23,140 and if you can get away with not having 554 00:22:23,140 --> 00:22:25,300 images displayed, it's probably to your advantage 555 00:22:25,300 --> 00:22:26,620 to have images turned off. 556 00:22:27,260 --> 00:22:29,060 Um, and again, this is one of those things 557 00:22:29,060 --> 00:22:31,080 you can do in the string substitution that I showed 558 00:22:31,080 --> 00:22:32,240 you when you're writing your macro. 559 00:22:33,260 --> 00:22:35,100 And again, if you, especially if you're going through 560 00:22:35,100 --> 00:22:36,840 Tor or some kind of a 561 00:22:37,300 --> 00:22:38,940 anomalizer, it's nice to turn off your images 562 00:22:38,940 --> 00:22:39,320 sometimes. 563 00:22:40,940 --> 00:22:43,040 The other thing that I do is, is this little 564 00:22:43,040 --> 00:22:44,820 thing. If you're extracting data, 565 00:22:46,120 --> 00:22:47,200 um, iMacros has a way 566 00:22:47,200 --> 00:22:49,100 of extracting data, and you can put it in 567 00:22:49,120 --> 00:22:51,120 to spreadsheets and stuff. If you don't 568 00:22:51,120 --> 00:22:52,940 put this little line in here, you're gonna get these 569 00:22:52,940 --> 00:22:55,120 annoying little pop-ups that come up every time 570 00:22:55,120 --> 00:22:56,980 it's extracting data. And 571 00:22:56,980 --> 00:22:58,800 if you have an automated system, that just 572 00:22:58,800 --> 00:23:01,120 doesn't work, so I always throw this line in there as well. 573 00:23:03,260 --> 00:23:05,240 Um, the commands for iMacro 574 00:23:05,680 --> 00:23:06,720 are, are really 575 00:23:06,720 --> 00:23:09,040 simple, and there's a nice, uh, 576 00:23:09,120 --> 00:23:10,220 command reference online, 577 00:23:10,720 --> 00:23:13,220 as well as user forms and all that kind of cool stuff. 578 00:23:15,140 --> 00:23:16,940 Okay, so let's look a little bit at where 579 00:23:16,940 --> 00:23:18,320 this data might come from. 580 00:23:19,120 --> 00:23:20,800 This is, um, kind of a, a typical 581 00:23:20,800 --> 00:23:23,040 configuration for me. Well, I have, uh, 582 00:23:23,060 --> 00:23:25,100 my targets, off to the left there. 583 00:23:25,760 --> 00:23:26,920 And then I have the machine 584 00:23:26,920 --> 00:23:29,040 that's running iMacros. I refer to that as 585 00:23:29,040 --> 00:23:31,040 my harvester. And then I'll have 586 00:23:31,040 --> 00:23:32,740 some kind of a central server, which is 587 00:23:32,740 --> 00:23:35,100 usually just a website that I've 588 00:23:35,100 --> 00:23:37,040 kind of customized for doing this kind of stuff. 589 00:23:37,820 --> 00:23:39,020 So, my harvester 590 00:23:39,020 --> 00:23:40,900 will go out and periodically poll 591 00:23:41,280 --> 00:23:43,080 the central server to ask if it 592 00:23:43,080 --> 00:23:45,040 has anything for it to do. And if 593 00:23:45,040 --> 00:23:47,120 it does, it'll tell it what to do. 594 00:23:47,200 --> 00:23:48,660 So that'll include which websites, 595 00:23:49,120 --> 00:23:50,360 to use as targets, 596 00:23:50,580 --> 00:23:52,400 and what data to apply to them. 597 00:23:53,100 --> 00:23:54,860 And then my harvester will go out 598 00:23:54,860 --> 00:23:56,460 and it'll download the page, 599 00:23:56,660 --> 00:23:58,800 and it'll save screens, 600 00:23:58,980 --> 00:24:01,040 it'll parse results, and then 601 00:24:01,040 --> 00:24:02,920 it'll send data back up to the centralized 602 00:24:02,920 --> 00:24:05,080 server. That, that's very typical 603 00:24:05,080 --> 00:24:06,260 in the way I do this kind of stuff. 604 00:24:07,340 --> 00:24:09,080 So, in large-scale 605 00:24:09,080 --> 00:24:10,920 deployment, you can have 606 00:24:10,920 --> 00:24:13,000 lots and lots and lots 607 00:24:13,000 --> 00:24:14,460 of harvesters, okay? 608 00:24:14,980 --> 00:24:16,980 And all of these 609 00:24:16,980 --> 00:24:19,080 harvesters are running asynchronously 610 00:24:19,120 --> 00:24:21,020 and they periodically poll 611 00:24:21,020 --> 00:24:23,080 the central server, asking for 612 00:24:23,080 --> 00:24:25,100 things to do. They go off and they 613 00:24:25,100 --> 00:24:27,060 hit the targets, download the pages, parse stuff 614 00:24:27,060 --> 00:24:29,000 off, and send the data back to the 615 00:24:29,000 --> 00:24:30,980 central server. Now, you can 616 00:24:30,980 --> 00:24:33,040 manage a whole bunch of 617 00:24:34,080 --> 00:24:35,100 harvesters this way. 618 00:24:35,580 --> 00:24:37,120 The central server can even 619 00:24:37,120 --> 00:24:38,740 do things like software updates 620 00:24:38,740 --> 00:24:40,340 for the harvesters. 621 00:24:40,940 --> 00:24:42,960 Basically what this is is a botnet, right? 622 00:24:43,280 --> 00:24:44,800 That's essentially what it is. 623 00:24:45,260 --> 00:24:45,780 And 624 00:24:46,900 --> 00:24:48,680 this configuration is really 625 00:24:49,120 --> 00:24:50,340 changed my 626 00:24:51,100 --> 00:24:53,020 thinking in terms of how to 627 00:24:53,020 --> 00:24:55,160 how to host 628 00:24:55,160 --> 00:24:57,020 a, or how, yeah, I guess 629 00:24:57,020 --> 00:24:59,060 how to host what the 630 00:24:59,060 --> 00:25:01,380 serving requirements are for screen scrapers. 631 00:25:02,160 --> 00:25:03,060 Because you really 632 00:25:03,060 --> 00:25:05,000 don't need a data center anymore for this. 633 00:25:05,200 --> 00:25:07,040 Because the central server can be 634 00:25:07,040 --> 00:25:09,020 some cheap $10 a month website 635 00:25:09,020 --> 00:25:10,840 that you're using, and 636 00:25:10,840 --> 00:25:12,320 all the harvesters can be 637 00:25:12,900 --> 00:25:14,540 you know, $50 638 00:25:14,960 --> 00:25:16,980 10-year-old PCs that you 639 00:25:16,980 --> 00:25:19,060 bought on Craigslist. And if you 640 00:25:19,120 --> 00:25:20,860 do this well, and if they're on separate power 641 00:25:20,860 --> 00:25:23,020 networks and using separate connections to 642 00:25:23,020 --> 00:25:25,100 the internet, and, I mean, they can be 643 00:25:25,100 --> 00:25:27,040 in separate countries, so you've got all kinds of 644 00:25:27,040 --> 00:25:28,200 redundancy built in. 645 00:25:29,100 --> 00:25:30,860 None of the stuff that you're looking at 646 00:25:30,860 --> 00:25:32,940 generally is anything 647 00:25:32,940 --> 00:25:34,800 that isn't already available 648 00:25:34,800 --> 00:25:36,900 online, so you don't have security problems. 649 00:25:37,780 --> 00:25:38,980 No data is stored 650 00:25:38,980 --> 00:25:40,980 locally, so you don't have any backup issues. 651 00:25:41,480 --> 00:25:41,880 So 652 00:25:43,080 --> 00:25:44,900 hosting becomes really simple. In fact, 653 00:25:45,020 --> 00:25:47,040 one of the things I've been tempted to do is 654 00:25:47,040 --> 00:25:47,680 they make these little 655 00:25:49,120 --> 00:25:50,960 Linux boxes that look like wall warts. 656 00:25:51,020 --> 00:25:52,960 They just plug into the wall, and they've got 657 00:25:52,960 --> 00:25:54,940 built-in Wi-Fi. I thought about 658 00:25:54,940 --> 00:25:57,000 just taking those and going to some places where they have public 659 00:25:57,000 --> 00:25:58,420 Wi-Fi, like, you know, libraries. 660 00:25:59,040 --> 00:26:00,940 And you just put a little sticker on there that 661 00:26:00,940 --> 00:26:02,720 says, you know, security 662 00:26:02,720 --> 00:26:04,960 please do not remove, you know, 663 00:26:04,980 --> 00:26:06,060 and just plug it in, and 664 00:26:06,980 --> 00:26:08,100 you've got another harvester. 665 00:26:10,460 --> 00:26:10,860 It 666 00:26:10,860 --> 00:26:11,500 could happen. 667 00:26:13,680 --> 00:26:14,840 Okay, I'm going to show you 668 00:26:14,840 --> 00:26:16,960 some hacks now to iMacros that make it 669 00:26:16,960 --> 00:26:18,980 really effective. The first 670 00:26:19,120 --> 00:26:20,320 thing that I showed you is just a really 671 00:26:20,320 --> 00:26:22,780 straightforward iMacros kind of thing. 672 00:26:26,040 --> 00:26:27,000 But we need to take it 673 00:26:27,000 --> 00:26:28,720 beyond that, which means we need to add a little more 674 00:26:28,720 --> 00:26:31,140 programming power to it. Now, iMacros 675 00:26:31,140 --> 00:26:32,520 does have a 676 00:26:32,960 --> 00:26:35,100 kind of a JavaScript-like programming 677 00:26:35,100 --> 00:26:36,060 language, but 678 00:26:36,960 --> 00:26:39,040 I don't want to learn anything new. I'm just going to go 679 00:26:39,040 --> 00:26:40,620 on, use tools that I've got, 680 00:26:41,220 --> 00:26:41,580 and 681 00:26:42,860 --> 00:26:45,040 do something where I have complete total control. 682 00:26:45,220 --> 00:26:47,060 And I'm not a big fan of JavaScript to begin 683 00:26:47,060 --> 00:26:47,580 with, so. 684 00:26:49,120 --> 00:26:50,580 iMacros has some limited 685 00:26:51,060 --> 00:26:52,580 parsing and data extraction capability, 686 00:26:53,280 --> 00:26:53,880 but 687 00:26:55,080 --> 00:26:56,940 I haven't found any 688 00:26:56,940 --> 00:26:58,880 like, pre-packaged 689 00:26:58,880 --> 00:27:00,860 screen scrapers that do as good a job 690 00:27:00,860 --> 00:27:02,560 as a parsing script. 691 00:27:03,020 --> 00:27:05,120 Because your scripts can be written to be 692 00:27:05,120 --> 00:27:06,880 fault-tolerant and a lot 693 00:27:06,880 --> 00:27:08,980 smarter, and can actually make parsing decisions 694 00:27:08,980 --> 00:27:11,020 as opposed to looking for 695 00:27:11,020 --> 00:27:12,980 things either at static places or with static 696 00:27:12,980 --> 00:27:13,360 names. 697 00:27:14,820 --> 00:27:15,420 Um 698 00:27:17,960 --> 00:27:18,560 So, 699 00:27:19,120 --> 00:27:21,100 without what I'm going to show you right here, 700 00:27:21,900 --> 00:27:23,100 iMacros leaves you with 701 00:27:23,100 --> 00:27:24,920 a lot of the limitations that browsers 702 00:27:24,920 --> 00:27:26,280 have inherently. So, 703 00:27:27,480 --> 00:27:29,000 what would happen, here's my 704 00:27:29,000 --> 00:27:31,060 hack. Suppose you could 705 00:27:31,060 --> 00:27:33,000 execute iMacros in one 706 00:27:33,000 --> 00:27:33,620 browser tab, 707 00:27:35,280 --> 00:27:36,940 and then open another browser 708 00:27:36,940 --> 00:27:38,920 tab, and analyze 709 00:27:39,620 --> 00:27:40,960 the screen that you 710 00:27:40,960 --> 00:27:42,200 downloaded in the first tab. 711 00:27:42,840 --> 00:27:44,800 That you could write, you could parse the data, 712 00:27:45,020 --> 00:27:46,940 you could read and write stuff to a 713 00:27:46,940 --> 00:27:49,100 database, you could pass data back to iMacros, 714 00:27:49,120 --> 00:27:49,240 um, 715 00:27:50,800 --> 00:27:52,660 you could go open other webpages, 716 00:27:52,940 --> 00:27:54,500 you could aggregate information, 717 00:27:55,000 --> 00:27:57,100 you could do basically anything you want to do. 718 00:27:57,340 --> 00:27:59,040 That's what we're going to do here. 719 00:27:59,440 --> 00:28:00,680 So, what we're going to do here, 720 00:28:00,840 --> 00:28:01,780 I got another demo, 721 00:28:02,980 --> 00:28:04,900 what we're going to do is when we get to this point 722 00:28:04,900 --> 00:28:06,840 in the first demo, we're going to tack on 723 00:28:06,840 --> 00:28:08,880 some extra code that creates a 724 00:28:08,880 --> 00:28:09,900 second browser tab, 725 00:28:10,760 --> 00:28:12,600 it launches a local PHP 726 00:28:12,950 --> 00:28:14,840 program that's running locally on this machine 727 00:28:14,840 --> 00:28:15,220 in Apache, 728 00:28:16,380 --> 00:28:18,760 we're going to parse the webpage that we saved 729 00:28:19,120 --> 00:28:20,180 in the first tab, 730 00:28:21,000 --> 00:28:22,860 we're going to return the access code 731 00:28:22,860 --> 00:28:24,720 back to the first tab, 732 00:28:25,240 --> 00:28:26,980 and then we're going to complete our form 733 00:28:26,980 --> 00:28:28,460 submission. So you can see at the end here, 734 00:28:29,280 --> 00:28:31,040 um, there was this big access 735 00:28:31,040 --> 00:28:32,840 code that it gave us that we needed to 736 00:28:32,840 --> 00:28:34,980 plug into this other form field to complete 737 00:28:34,980 --> 00:28:36,600 the, uh, the ordeal. 738 00:28:36,780 --> 00:28:38,640 Which looks a lot like a CAPTCHA, right? 739 00:28:38,740 --> 00:28:40,320 This is kind of like a simplified 740 00:28:41,000 --> 00:28:42,040 CAPTCHA kind of application. 741 00:28:44,000 --> 00:28:45,080 Alright, so let's go to 742 00:28:45,080 --> 00:28:45,680 demo two here. 743 00:28:49,560 --> 00:28:50,000 ... 744 00:28:50,700 --> 00:28:51,140 ... 745 00:28:55,140 --> 00:28:55,580 ... 746 00:28:57,480 --> 00:28:57,920 ... 747 00:28:57,920 --> 00:28:58,660 Okay, so it starts 748 00:28:58,660 --> 00:28:59,600 like the first one. 749 00:29:00,480 --> 00:29:00,920 ... 750 00:29:02,480 --> 00:29:03,920 And it fills out the form. 751 00:29:04,860 --> 00:29:05,300 ... 752 00:29:07,060 --> 00:29:08,480 Again with dramatic 753 00:29:08,480 --> 00:29:09,100 delays. 754 00:29:10,240 --> 00:29:10,680 ... 755 00:29:12,600 --> 00:29:14,920 Okay, so it did that. Now what it's going to do 756 00:29:14,920 --> 00:29:16,780 is it's going to save a copy of this 757 00:29:16,780 --> 00:29:18,960 screen. It opens a second 758 00:29:19,120 --> 00:29:20,660 tab. It goes to that tab. 759 00:29:21,300 --> 00:29:22,860 It goes to a local program 760 00:29:22,860 --> 00:29:24,280 now that's parsing the data. 761 00:29:25,640 --> 00:29:27,120 It actually doesn't take this long 762 00:29:27,120 --> 00:29:28,840 to parse, but it's giving me some time to speak. 763 00:29:29,120 --> 00:29:30,640 Then it goes back to the first tab. 764 00:29:31,540 --> 00:29:33,000 And it pulls in the data 765 00:29:33,000 --> 00:29:33,300 source. 766 00:29:34,780 --> 00:29:36,860 And it's going to throw that number 767 00:29:36,860 --> 00:29:38,840 in that field. Hit save. 768 00:29:39,300 --> 00:29:39,740 ... 769 00:29:40,460 --> 00:29:40,900 ... 770 00:29:42,460 --> 00:29:43,780 Again, dramatic pause. 771 00:29:44,960 --> 00:29:47,120 And, uh, it takes us to our final screen. 772 00:29:47,340 --> 00:29:48,660 Okay, so you saw what happened there, right? 773 00:29:49,120 --> 00:29:51,160 The first tab grabbed a bunch of information. 774 00:29:51,600 --> 00:29:53,000 And even though that was a really 775 00:29:53,000 --> 00:29:55,100 simple screen, that could have been 776 00:29:55,100 --> 00:29:57,160 entirely Ajax created. 777 00:29:57,700 --> 00:29:57,800 Okay? 778 00:29:58,980 --> 00:30:01,040 It saves that screen, opens a 779 00:30:01,040 --> 00:30:03,000 second tab. Second tab runs 780 00:30:03,000 --> 00:30:04,980 some custom code that acts on the 781 00:30:04,980 --> 00:30:06,980 saved data, returns that data 782 00:30:06,980 --> 00:30:09,100 back to the first tab, and it completes 783 00:30:09,100 --> 00:30:09,580 the process. 784 00:30:11,240 --> 00:30:13,060 I'll often have three or four tabs 785 00:30:13,060 --> 00:30:15,120 going when I'm doing this kind of thing. 786 00:30:15,200 --> 00:30:16,920 And it's really, really 787 00:30:16,920 --> 00:30:17,300 powerful. 788 00:30:19,120 --> 00:30:20,960 Let's take a little bit, let's look a little bit 789 00:30:20,960 --> 00:30:22,320 at what's really going on here. 790 00:30:25,260 --> 00:30:27,080 Okay, so basically I tacked 791 00:30:27,080 --> 00:30:28,920 just a few more lines of code onto the old 792 00:30:28,920 --> 00:30:31,020 macro. The first one is 793 00:30:31,020 --> 00:30:32,160 I'm saving the screen 794 00:30:33,580 --> 00:30:34,880 using a iMacro 795 00:30:34,880 --> 00:30:35,620 save as command. 796 00:30:36,940 --> 00:30:38,580 Then I go ahead and I open up 797 00:30:38,580 --> 00:30:41,020 a second tab. I move over to 798 00:30:41,020 --> 00:30:43,040 that tab. And then I go 799 00:30:43,040 --> 00:30:44,860 to a URL. You can use 800 00:30:44,860 --> 00:30:46,540 any URL including local 801 00:30:46,920 --> 00:30:48,880 URLs. So I go to a local 802 00:30:49,120 --> 00:30:51,180 program that reads 803 00:30:51,180 --> 00:30:52,080 the parsed results. 804 00:30:53,300 --> 00:30:54,420 And whoops. 805 00:30:54,980 --> 00:30:57,080 And basically that program will 806 00:30:57,080 --> 00:30:58,040 read the results, 807 00:30:58,660 --> 00:31:00,960 send it back in a format that 808 00:31:00,960 --> 00:31:03,040 iMacros can read. Then I come 809 00:31:03,040 --> 00:31:04,900 back. I open up tab one again. 810 00:31:05,260 --> 00:31:06,920 I open up what they call a 811 00:31:06,920 --> 00:31:09,080 data source, which is basically just 812 00:31:09,080 --> 00:31:11,000 a standard comma separated 813 00:31:11,000 --> 00:31:13,120 value file. It reads that in. 814 00:31:13,840 --> 00:31:14,900 I'm telling it 815 00:31:14,900 --> 00:31:17,040 that I've only got one column of 816 00:31:17,040 --> 00:31:18,640 data. And 817 00:31:19,120 --> 00:31:20,700 I'm showing where the loop is going to exist 818 00:31:20,700 --> 00:31:22,800 here. And I just have one piece of data 819 00:31:22,800 --> 00:31:24,660 so there's really just one iteration 820 00:31:24,660 --> 00:31:27,160 in the loop. The content 821 00:31:27,160 --> 00:31:28,440 has been replaced with the 822 00:31:28,440 --> 00:31:30,120 value that's in column one. 823 00:31:30,920 --> 00:31:32,980 And then I submit the form 824 00:31:32,980 --> 00:31:34,900 and I'm done. So that's all 825 00:31:34,900 --> 00:31:36,800 there is to this. It's really, really 826 00:31:36,800 --> 00:31:38,900 simple to really expand 827 00:31:38,900 --> 00:31:40,380 the capability of iMacros. 828 00:31:41,440 --> 00:31:42,140 And again, 829 00:31:42,300 --> 00:31:44,800 you can throw any kind of page 830 00:31:44,800 --> 00:31:47,040 at it with any kind of 831 00:31:47,040 --> 00:31:48,760 JavaScript or Flash or whatever. 832 00:31:49,300 --> 00:31:50,520 And you can handle it. 833 00:31:50,600 --> 00:31:52,000 It's a thing of beauty. 834 00:31:54,660 --> 00:31:56,840 Using additional tabs to run local programs 835 00:31:56,840 --> 00:31:58,920 facilitates advanced features that are 836 00:31:58,920 --> 00:32:00,860 not possible with iMacros configurations. 837 00:32:01,660 --> 00:32:03,240 For example, you can interrupt 838 00:32:03,240 --> 00:32:05,020 a macro to do other 839 00:32:05,020 --> 00:32:06,700 things like parse data 840 00:32:06,700 --> 00:32:08,720 from the pages that were downloaded. 841 00:32:09,060 --> 00:32:10,400 You can act on the results. 842 00:32:10,840 --> 00:32:13,140 You can interface with local peripherals. 843 00:32:13,280 --> 00:32:15,000 In other words, if you want to send a fax 844 00:32:15,000 --> 00:32:16,920 in the middle of an iMacros 845 00:32:16,920 --> 00:32:19,100 session, you can do that. You can 846 00:32:19,120 --> 00:32:20,840 change your proxy settings if you want. 847 00:32:21,760 --> 00:32:22,800 You can aggregate 848 00:32:22,800 --> 00:32:24,600 data from multiple web sources 849 00:32:24,900 --> 00:32:25,760 or websites. 850 00:32:26,860 --> 00:32:28,620 You can also aggregate services. 851 00:32:29,760 --> 00:32:31,000 For example, maybe 852 00:32:31,000 --> 00:32:32,260 you go off and you 853 00:32:32,260 --> 00:32:34,100 I don't know, you 854 00:32:35,720 --> 00:32:37,040 for example, maybe 855 00:32:37,040 --> 00:32:37,980 you're looking at 856 00:32:41,520 --> 00:32:42,960 I'm making this up on the spot. 857 00:32:43,800 --> 00:32:45,100 Supposing you have a little 858 00:32:45,100 --> 00:32:46,800 business where you buy and sell books. 859 00:32:47,220 --> 00:32:49,040 So you find something you think might 860 00:32:49,120 --> 00:32:50,760 be a good buy on eBay. 861 00:32:51,040 --> 00:32:52,980 You got a bot out there looking at books on eBay. 862 00:32:53,580 --> 00:32:55,120 And your web bot 863 00:32:55,120 --> 00:32:57,260 has to make a decision as to whether or not to buy it. 864 00:32:57,540 --> 00:32:58,980 So maybe it goes off onto 865 00:32:58,980 --> 00:33:01,040 Amazon and it looks at what the sales 866 00:33:01,040 --> 00:33:03,000 ranking is. And if it's a good 867 00:33:03,000 --> 00:33:04,400 sales ranking and a low price, 868 00:33:04,940 --> 00:33:06,940 maybe you got a little formula you run and 869 00:33:06,940 --> 00:33:08,680 decide whether or not you want to buy the book. 870 00:33:09,040 --> 00:33:10,700 You know, that's the kind of thing you can do 871 00:33:10,700 --> 00:33:12,080 with this kind of power. 872 00:33:13,720 --> 00:33:15,080 You can also upload data 873 00:33:15,080 --> 00:33:16,620 to essential servers in 874 00:33:17,100 --> 00:33:18,460 Macro, which is very powerful. 875 00:33:19,120 --> 00:33:20,920 Basically anything you can do with a computer 876 00:33:20,920 --> 00:33:23,340 program, you can now do with iMacros. 877 00:33:24,640 --> 00:33:26,720 Okay, I promised you a heartwarming moment. 878 00:33:27,540 --> 00:33:28,460 So here it comes. 879 00:33:31,140 --> 00:33:33,200 Since we're talking about CAPTCHAs, 880 00:33:34,000 --> 00:33:35,040 Carnegie Mellon 881 00:33:35,040 --> 00:33:37,080 is the group, 882 00:33:37,200 --> 00:33:38,940 the university that came up with the whole 883 00:33:38,940 --> 00:33:40,980 CAPTCHA idea. And maybe 884 00:33:40,980 --> 00:33:42,280 you've seen this reCAPTCHA. 885 00:33:42,660 --> 00:33:45,100 They're being used everywhere now. They're used on Twitter. 886 00:33:45,260 --> 00:33:46,760 They're used on Craigslist. 887 00:33:47,980 --> 00:33:48,780 They're used 888 00:33:49,120 --> 00:33:50,140 all over the place. 889 00:33:51,000 --> 00:33:52,960 Carnegie Mellon figured out that 890 00:33:53,640 --> 00:33:54,780 as a population, 891 00:33:54,920 --> 00:33:56,380 we do a quarter billion 892 00:33:57,420 --> 00:33:58,380 CAPTCHAs every day. 893 00:33:59,240 --> 00:34:01,040 So what they did is they came up with this 894 00:34:01,040 --> 00:34:02,440 free service for people. 895 00:34:02,740 --> 00:34:04,740 And it's a decent 896 00:34:04,740 --> 00:34:06,240 CAPTCHA service. It really is. 897 00:34:06,980 --> 00:34:08,820 And right now they're getting 30 898 00:34:08,820 --> 00:34:10,600 million uses a day 899 00:34:11,120 --> 00:34:12,360 from their reCAPTCHA service. 900 00:34:13,220 --> 00:34:14,780 The cool thing about this 901 00:34:14,780 --> 00:34:16,960 is that the words that 902 00:34:16,960 --> 00:34:18,620 they're using that you 903 00:34:19,120 --> 00:34:19,740 don't need to type in 904 00:34:19,740 --> 00:34:23,040 are actually scanned from old documents. 905 00:34:23,720 --> 00:34:25,080 Right now they're doing 906 00:34:25,080 --> 00:34:27,020 old copies of the New York Times. 907 00:34:27,560 --> 00:34:28,160 And 908 00:34:28,160 --> 00:34:30,020 what actually happens here is 909 00:34:30,020 --> 00:34:32,180 as people complete the CAPTCHAs, 910 00:34:32,180 --> 00:34:34,000 they're actually digitizing 911 00:34:34,000 --> 00:34:36,600 these old documents for later use. 912 00:34:36,840 --> 00:34:38,800 Which is kind of a clever thing to do. 913 00:34:39,180 --> 00:34:40,880 So right now when you do your 914 00:34:40,880 --> 00:34:42,620 CAPTCHA on Twitter, you're actually 915 00:34:43,780 --> 00:34:45,000 digitizing old copies 916 00:34:45,000 --> 00:34:46,420 of the New York Times is what you're doing. 917 00:34:48,020 --> 00:34:49,020 So it's 918 00:34:49,120 --> 00:34:50,360 a pretty clever idea really. 919 00:34:50,460 --> 00:34:51,160 It really is. 920 00:34:53,460 --> 00:34:54,740 They have an algorithm 921 00:34:54,740 --> 00:34:57,040 that they use. And they look to see 922 00:34:57,040 --> 00:34:57,880 how many times 923 00:34:58,920 --> 00:35:00,060 basically they vote. 924 00:35:00,380 --> 00:35:02,140 And I don't know how many votes are required 925 00:35:02,140 --> 00:35:03,660 to get a legitimate word. 926 00:35:04,140 --> 00:35:05,760 But in this case if 927 00:35:05,760 --> 00:35:08,940 fisherman comes up 90% of the time 928 00:35:08,940 --> 00:35:10,660 for the first word, it's probably 929 00:35:10,660 --> 00:35:11,100 fisherman. 930 00:35:12,500 --> 00:35:14,620 I've heard of hacks where people will 931 00:35:14,620 --> 00:35:16,660 you get a big group of people together 932 00:35:16,660 --> 00:35:18,840 and they all type in the same word until it 933 00:35:19,120 --> 00:35:20,120 finally starts to accept it. 934 00:35:20,740 --> 00:35:22,060 I don't know if that's true or not. 935 00:35:22,160 --> 00:35:23,760 But I've heard rumors that that works. 936 00:35:23,980 --> 00:35:26,360 So that's how I guess that they're doing it. 937 00:35:26,520 --> 00:35:27,920 I don't know for a fact. 938 00:35:28,020 --> 00:35:28,880 But that's my guess. 939 00:35:30,500 --> 00:35:32,560 And they're getting really great success. 940 00:35:32,860 --> 00:35:34,840 So the original documents, 941 00:35:35,020 --> 00:35:36,200 especially with these really old ones, 942 00:35:36,380 --> 00:35:38,500 they're printed out with lead type 943 00:35:38,500 --> 00:35:39,100 and what not. 944 00:35:39,520 --> 00:35:41,420 And the type isn't really great. 945 00:35:41,740 --> 00:35:43,440 And when they do an OCR translation, 946 00:35:44,860 --> 00:35:46,600 there are a lot of errors as you can see 947 00:35:46,600 --> 00:35:47,320 in the second example. 948 00:35:49,120 --> 00:35:50,680 The transcriptions look really clean. 949 00:35:52,360 --> 00:35:55,000 So in addition to this, 950 00:35:55,000 --> 00:35:56,620 the other thing that's happening right now 951 00:35:56,620 --> 00:35:58,800 is there are services 952 00:35:58,800 --> 00:36:00,440 that will solve CAPTCHAs for you. 953 00:36:00,780 --> 00:36:02,820 In fact they write actual 954 00:36:02,820 --> 00:36:04,180 APIs that you can use. 955 00:36:05,200 --> 00:36:06,220 Which is pretty cool. 956 00:36:06,780 --> 00:36:08,960 And unlike the optical 957 00:36:08,960 --> 00:36:10,880 character reader solutions that you may 958 00:36:10,880 --> 00:36:12,840 or may not have seen at DEF CON over the last 959 00:36:12,840 --> 00:36:14,840 couple years, these are actually solved 960 00:36:14,840 --> 00:36:15,820 by real people. 961 00:36:17,000 --> 00:36:18,880 And the way it works 962 00:36:19,120 --> 00:36:21,260 is, not that I would know how this works, 963 00:36:21,440 --> 00:36:23,040 but the way I think this works, 964 00:36:23,240 --> 00:36:23,880 is 965 00:36:24,460 --> 00:36:26,160 you take your image 966 00:36:26,160 --> 00:36:28,500 and you send it off to these people 967 00:36:28,500 --> 00:36:31,000 and most of them 968 00:36:31,000 --> 00:36:32,000 are based in either 969 00:36:32,940 --> 00:36:34,720 India, Bangladesh, Pakistan, 970 00:36:34,960 --> 00:36:36,540 Vietnam, and 971 00:36:37,100 --> 00:36:39,080 three individual people are sitting 972 00:36:39,080 --> 00:36:40,800 either in an office or in their home 973 00:36:40,800 --> 00:36:42,740 with a computer set up to do this 974 00:36:42,740 --> 00:36:45,160 and they'll see the image and they'll type in 975 00:36:45,160 --> 00:36:45,880 what they think it is. 976 00:36:46,300 --> 00:36:48,240 You get three results back 977 00:36:49,120 --> 00:36:50,700 and what you do then is you write some software 978 00:36:50,700 --> 00:36:52,560 that basically votes, if two match 979 00:36:53,090 --> 00:36:54,760 you can pretty much assume that that's what the 980 00:36:54,760 --> 00:36:56,380 real answer is and 981 00:36:59,100 --> 00:37:00,940 the accuracy is actually quite high. 982 00:37:01,340 --> 00:37:02,620 It's a good deal. 983 00:37:02,920 --> 00:37:04,900 And it costs about a half a cent 984 00:37:04,900 --> 00:37:06,120 to get a CAPTCHA solved. 985 00:37:06,580 --> 00:37:08,260 So it's a good thing. 986 00:37:08,460 --> 00:37:09,200 It's a good thing. 987 00:37:11,300 --> 00:37:12,900 If you want to find out who's doing this 988 00:37:12,900 --> 00:37:15,060 I would just suggest doing a real quick Google search 989 00:37:15,060 --> 00:37:17,120 and you'll come up with a number of 990 00:37:17,120 --> 00:37:19,100 organizations that do CAPTCHAs all the time. 991 00:37:19,800 --> 00:37:21,260 So here's how it works. 992 00:37:21,380 --> 00:37:23,320 The CAPTCHA is displayed on a web page 993 00:37:23,900 --> 00:37:24,460 and 994 00:37:25,000 --> 00:37:27,160 you take the image, the CAPTCHA 995 00:37:27,160 --> 00:37:29,340 image and you set it up 996 00:37:29,340 --> 00:37:31,020 in their API and you send it off to the 997 00:37:31,020 --> 00:37:32,960 service and it's solved 998 00:37:32,960 --> 00:37:35,160 not by a human but by several human 999 00:37:35,160 --> 00:37:37,220 beings and they send you 1000 00:37:37,220 --> 00:37:38,340 the text back 1001 00:37:39,280 --> 00:37:39,840 and 1002 00:37:40,520 --> 00:37:42,660 you enter that into the CAPTCHA box 1003 00:37:42,660 --> 00:37:44,620 and the CAPTCHA is solved. 1004 00:37:45,440 --> 00:37:47,200 Along with some unintentional 1005 00:37:47,200 --> 00:37:47,540 consequences. 1006 00:37:49,120 --> 00:37:50,820 Basically it's a feel-good win-win situation 1007 00:37:50,820 --> 00:37:52,360 for everybody because 1008 00:37:52,900 --> 00:37:55,360 you end up with spammers paying to digitize 1009 00:37:55,360 --> 00:37:57,120 old documents and promote 1010 00:37:57,120 --> 00:37:58,040 literacy worldwide 1011 00:37:58,840 --> 00:37:59,440 and 1012 00:38:00,460 --> 00:38:01,720 it's true, it's true. 1013 00:38:02,120 --> 00:38:05,240 And people in developing nations have jobs 1014 00:38:05,240 --> 00:38:07,040 and my understanding is that 1015 00:38:07,780 --> 00:38:09,280 this kind of work 1016 00:38:09,280 --> 00:38:11,140 puts a lot of college 1017 00:38:11,140 --> 00:38:13,040 kids through school in places 1018 00:38:13,040 --> 00:38:14,400 like Pakistan and Vietnam. 1019 00:38:16,100 --> 00:38:17,100 It's hard to get 1020 00:38:17,100 --> 00:38:18,080 numbers as to 1021 00:38:19,480 --> 00:38:21,220 how many people are doing this 1022 00:38:21,220 --> 00:38:22,760 but the number that I heard is that 1023 00:38:22,760 --> 00:38:24,680 it's a $20 million a year business 1024 00:38:25,220 --> 00:38:26,820 CAPTCHA solving at 1025 00:38:26,820 --> 00:38:28,160 like a half a cent a piece. 1026 00:38:30,200 --> 00:38:30,880 But do 1027 00:38:30,880 --> 00:38:32,220 responsible things with this. 1028 00:38:33,340 --> 00:38:34,920 I don't want to get spam email 1029 00:38:34,920 --> 00:38:35,560 from all you guys. 1030 00:38:38,020 --> 00:38:38,900 So in conclusion 1031 00:38:39,360 --> 00:38:40,840 we reviewed a little bit of 1032 00:38:40,840 --> 00:38:42,780 traditional screen scraper theory 1033 00:38:43,340 --> 00:38:44,220 we described 1034 00:38:44,740 --> 00:38:47,040 why it's becoming more difficult to write scrapers 1035 00:38:47,840 --> 00:38:49,020 and we saw that I 1036 00:38:49,120 --> 00:38:50,880 macros can solve really all 1037 00:38:50,880 --> 00:38:52,840 the difficult cases if you can do these 1038 00:38:52,840 --> 00:38:54,780 second and third tab hacks 1039 00:38:54,780 --> 00:38:55,980 on iMacros. 1040 00:38:56,360 --> 00:38:58,900 It gives you absolute browser emulation 1041 00:38:58,900 --> 00:39:01,020 capability. It gives you complete 1042 00:39:01,020 --> 00:39:03,020 control by writing these little scripts 1043 00:39:03,020 --> 00:39:05,340 that execute in other tabs 1044 00:39:05,340 --> 00:39:06,600 locally on your 1045 00:39:07,120 --> 00:39:07,840 harvester machine 1046 00:39:07,840 --> 00:39:11,080 and we also looked at 1047 00:39:11,080 --> 00:39:12,880 managing some large scale deployments 1048 00:39:12,880 --> 00:39:14,360 of this kind of stuff. So 1049 00:39:14,360 --> 00:39:15,600 I guess I'm done. 1050 00:39:16,220 --> 00:39:17,080 We have 1051 00:39:22,780 --> 00:39:25,020 I think we have a little time for questions 1052 00:39:25,020 --> 00:39:27,340 and whatever doesn't get asked 1053 00:39:27,980 --> 00:39:29,100 here I'm going to 1054 00:39:29,100 --> 00:39:30,240 go back to the vendor area 1055 00:39:30,920 --> 00:39:32,620 where I'll be hanging out at the NoStarch booth. 1056 00:39:40,980 --> 00:39:43,140 The question was how fast do you get 1057 00:39:43,140 --> 00:39:44,920 a reply from these CAPTCHA solvers? 1058 00:39:45,620 --> 00:39:47,020 My experience is that 1059 00:39:47,020 --> 00:39:49,100 it takes between 45 seconds and a minute. 1060 00:39:50,260 --> 00:39:50,800 Typically. 1061 00:39:52,320 --> 00:39:53,340 And you think about 1062 00:39:53,340 --> 00:39:55,080 what's going on, there's an awful 1063 00:39:55,080 --> 00:39:57,180 lot of stuff happening during that 45 seconds. 1064 00:39:57,540 --> 00:39:58,840 So that's really not 1065 00:39:58,840 --> 00:39:59,440 bad time. 1066 00:40:01,740 --> 00:40:03,120 And most of the bots 1067 00:40:03,120 --> 00:40:05,080 I run, it doesn't really 1068 00:40:05,080 --> 00:40:06,540 matter how long it takes for them to run. 1069 00:40:06,860 --> 00:40:08,700 Not these particular bots. 1070 00:40:09,500 --> 00:40:10,280 Other ones 1071 00:40:11,050 --> 00:40:11,860 are different. Yes? 1072 00:40:12,420 --> 00:40:14,740 One of the difficult situations I run into 1073 00:40:14,740 --> 00:40:16,780 is websites not 1074 00:40:16,780 --> 00:40:18,840 fully displayed and 1075 00:40:19,120 --> 00:40:20,760 things being bugged in iMac 1076 00:40:20,760 --> 00:40:22,800 rather than it never continues 1077 00:40:22,800 --> 00:40:23,780 with its 1078 00:40:24,960 --> 00:40:26,460 script. Have you run into that? 1079 00:40:26,720 --> 00:40:27,900 Yeah, the question was 1080 00:40:29,300 --> 00:40:30,840 websites that don't finish 1081 00:40:30,840 --> 00:40:32,560 loading, essentially, right? 1082 00:40:33,400 --> 00:40:34,580 I have seen that. 1083 00:40:34,720 --> 00:40:36,820 And the way I've gotten around it is 1084 00:40:36,820 --> 00:40:37,760 to turn off images. 1085 00:40:38,920 --> 00:40:39,940 Because what you're pro- 1086 00:40:39,940 --> 00:40:42,720 Yeah, sometimes you've got flash 1087 00:40:42,720 --> 00:40:44,400 that just kind of never stops loading. 1088 00:40:44,760 --> 00:40:46,920 If you turn off images, flash goes away. 1089 00:40:47,840 --> 00:40:49,040 A lot of times you end up 1090 00:40:49,120 --> 00:40:50,800 waiting for banner ads from slow 1091 00:40:50,800 --> 00:40:53,020 ad servers, too. That's what really kills me. 1092 00:40:53,640 --> 00:40:55,040 So yeah, if you can 1093 00:40:55,040 --> 00:40:56,720 get away with turning off images, 1094 00:40:57,020 --> 00:40:58,900 turn off images, and that 1095 00:40:58,900 --> 00:40:59,920 problem should go away. 1096 00:41:01,420 --> 00:41:02,500 Really, really. 1097 00:41:05,440 --> 00:41:05,960 Yes? 1098 00:41:13,040 --> 00:41:15,000 The question is, have I done any 1099 00:41:15,000 --> 00:41:16,240 multi-threading with this? 1100 00:41:17,400 --> 00:41:17,920 No. 1101 00:41:19,960 --> 00:41:20,560 No. 1102 00:41:20,740 --> 00:41:22,640 And I can't think of too many times 1103 00:41:22,640 --> 00:41:23,840 when I'd really have... 1104 00:41:23,840 --> 00:41:26,540 The way I do multi-threading is 1105 00:41:26,540 --> 00:41:27,980 I would do things... 1106 00:41:27,980 --> 00:41:29,340 I've done some strange things. 1107 00:41:29,640 --> 00:41:31,820 Generally, I do it by either adding more 1108 00:41:31,820 --> 00:41:33,580 hardware, or 1109 00:41:34,380 --> 00:41:36,420 I've had bots running in 1110 00:41:37,060 --> 00:41:38,580 frames within 1111 00:41:38,580 --> 00:41:39,660 web pages. 1112 00:41:41,060 --> 00:41:42,700 That's another way to do multi-threading. 1113 00:41:42,820 --> 00:41:44,300 You just basically create a whole new instance. 1114 00:41:44,940 --> 00:41:46,220 But most things 1115 00:41:47,200 --> 00:41:48,620 online are very 1116 00:41:49,120 --> 00:41:49,200 procedural. 1117 00:41:50,000 --> 00:41:52,340 And that's one of the reasons why I don't use 1118 00:41:52,340 --> 00:41:53,900 OOP when I program, because 1119 00:41:54,890 --> 00:41:56,660 the web is very procedural. 1120 00:41:58,300 --> 00:42:00,720 And I'm an old-school Java programmer 1121 00:42:00,720 --> 00:42:02,840 converted to a procedural 1122 00:42:02,840 --> 00:42:04,600 PHP programmer. Yes? 1123 00:42:14,440 --> 00:42:15,880 The question is, 1124 00:42:15,900 --> 00:42:18,300 the question is, can you 1125 00:42:19,180 --> 00:42:20,540 install iMacros through a 1126 00:42:21,540 --> 00:42:22,320 ActiveX control? 1127 00:42:22,460 --> 00:42:23,100 I'm sure you can. 1128 00:42:24,520 --> 00:42:26,000 I mean, I'm sure you can. 1129 00:42:26,120 --> 00:42:28,900 And you know, this does run on Internet Explorer, too. 1130 00:42:29,000 --> 00:42:30,940 So, yeah, I'm sure that's possible. 1131 00:42:32,660 --> 00:42:33,280 Anybody else? 1132 00:42:35,100 --> 00:42:36,220 Great. You've been great. 1133 00:42:36,640 --> 00:42:38,580 And I'll catch you in the vendors area. 1134 00:42:38,760 --> 00:42:39,440 Thank you very much.