Đăng ký Đăng nhập
Trang chủ Hacking gmail computer...

Tài liệu Hacking gmail computer

.PDF
40
335
93

Mô tả:

Hacking Gmail ™ Ben Hammersley Hacking Gmail ™ Hacking Gmail ™ Ben Hammersley Hacking Gmail™ Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2006 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN-13: 978-0-7645-9611-7 ISBN-10: 0-7645-9611-X Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 1B/RU/RS/QV/IN No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at http://www.wiley.com/go/permissions. Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Website is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Website may provide or recommendations it may make. Further, readers should be aware that Internet Websites listed in this work may have changed or disappeared between when this work was written and when it is read. For general information on our other products and services or to obtain technical support, please contact our Customer Care Department within the U.S. at (800) 762-2974, outside the U.S. at (317) 572-3993 or fax (317) 572-4002. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Library of Congress Cataloging-in-Publication Data Hammersley, Ben. Hacking Gmail / Ben Hammersley. p. cm. Includes index. ISBN-13: 978-0-7645-9611-7 (paper/website) ISBN-10: 0-7645-9611-X (paper/website) 1. Gmail (Electronic resource) 2. Electronic mail systems. 3. Internet programming. I. Title. TK5105.74.G55H36 2006 004.692—dc22 2005029719 Trademarks: Wiley and the Wiley logo are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. ExtremeTech and the ExtremeTech logo are trademarks of Ziff Davis Publishing Holdings, Inc. Used under license. All rights reserved. Gmail is a trademark of Google, Inc. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. Meanwhile, back in Florence, Anna, Lucy, Mischa, and Pico ignored the swearing and kept me fed. Love, as ever, to them. About the Author Armed only with a PowerBook and some fine pipe tobacco, Ben Hammersley is a journalist, writer, explorer, and an errant developer and explainer of semantic web technology. He’s also liable to spread his dirty, dirty words over at The Guardian. As an Englishman of the clichéd sort, Ben’s angle brackets always balance, and his tweed is always pressed. He’s not worn trousers for six months now. Ask him about it sometime. Credits Executive Editor Chris Webb Project Coordinator Michael Kruzil Development Editor Brian Herrmann Graphics and Production Specialists Carrie A. Foster Lynsey Osborn Melanee Prendergast Technical Editor Justin Blanton Production Editor Kenyon Brown Quality Control Technicians Leeann Harney, Jessica Kramer, Charles Spencer, Brian H. Walls Copy Editor Nancy Rapoport Proofreading and Indexing TECHBOOKS Production Services Editorial Manager Mary Beth Wakefield Cover Design Anthony Bunyan Production Manager Tim Tate Vice President and Executive Group Publisher Richard Swadley Vice President and Executive Publisher Joseph B. Wikert Contents at a Glance Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix Part I: Starting to Use Gmail . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Chapter 1: Desktop Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Chapter 2: Integrating Your Existing Mail. . . . . . . . . . . . . . . . . . . . . . . . . . 11 Chapter 3: Gmail Power Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Part II: Getting Inside Gmail . . . . . . . . . . . . . . . . . . . . . . . . . 27 Chapter 4: Skinning Gmail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Chapter 5: How Gmail Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Chapter 6: Gmail and Greasemonkey . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 Chapter 7: Gmail Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 Chapter 8: Checking for Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 Chapter 9: Reading Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 Chapter 10: Sending Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 Part III: Conquering Gmail . . . . . . . . . . . . . . . . . . . . . . . . . 167 Chapter 11: Dealing with Labels . . . . . . . . . . . . . . . . . . . . . Chapter 12: Addressing Addresses . . . . . . . . . . . . . . . . . . . . Chapter 13: Building an API from the HTML-Only Version of Gmail. Chapter 14: Exporting Your Mail. . . . . . . . . . . . . . . . . . . . . Chapter 15: Using Gmail to . . . . . . . . . . . . . . . . . . . . . . . . Chapter 16: Using GmailFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 177 183 197 203 213 Appendix: Long Code Listings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 Contents Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix Part I: Starting to Use Gmail 1 Chapter 1: Desktop Integration . . . . . . . . . . . . . . . . . . . . . . . . 3 New Mail Notification . . . . Windows . . . . . . . . Mac OS X . . . . . . . Linux, etc. . . . . . . . Redirecting mailto: . . . . . . Windows . . . . . . . . Multiplatform/Mozilla . OS X . . . . . . . . . . GmailerXP . . . . . . . And Now . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3 5 5 6 7 7 8 8 9 Chapter 2: Integrating Your Existing Mail . . . . . . . . . . . . . . . . . . 11 Importing Your Mail into Gmail . . . Gmail Loader . . . . . . . . . . Setting Up Pop Access Inside Gmail . Setting Up Pop Within an Application IMAP for Gmail. . . . . . . . . . . . And Now . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 11 12 13 14 14 Chapter 3: Gmail Power Tips. . . . . . . . . . . . . . . . . . . . . . . . . 15 Keyboard Shortcuts . . . . . . . . Plus Addressing and Filtering . . . Other Addressing Tips . . . Quickly Mark a Group of E-Mails Send Executables as Attachments . Advanced Searching . . . . . . . . And Now . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 20 21 23 23 24 26 xii Contents Part II: Getting Inside Gmail 27 Chapter 4: Skinning Gmail . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Deconstructing Gmail . . . . . . . The Top Section . . . . . . The Navigation Menu . . . The Activity Area . . . . . . The Bottom Section . . . . Applying a New Style . . . . . . . Creating Gmail Lite . . . . . . . . Walking Through the Style Sheet . Removing Google’s Advertising . . And Now . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 33 35 38 42 44 44 45 51 51 Chapter 5: How Gmail Works . . . . . . . . . . . . . . . . . . . . . . . . 53 What the Devil Is Going On? . . . . . . . . . . . . . . . Preloading the Interface. . . . . . . . . . . . . . . Introducing XMLHttpRequest . . . . . . . . . . . . . . Using XMLHttpRequest Yourself . . . . . . . . . Finding XMLHttpRequest within the Gmail code Sniffing the Network Traffic. . . . . . . . . . . . . . . . Firing Up Tcpflow . . . . . . . . . . . . . . . . . Prodding Gmail to Hear It Squeak . . . . . . . . . . . . Preparing to Watch the Gmail Boot Sequence . . . Cleaning Up the Log . . . . . . . . . . . . . . . . Stepping Through the Gmail Boot Sequence . . . . . . . Logging In . . . . . . . . . . . . . . . . . . . . . The First Cookie . . . . . . . . . . . . . . . . . . Loading the Inbox . . . . . . . . . . . . . . . . . Reading an Individual Mail . . . . . . . . . . . . . And Now . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 54 55 55 61 62 62 67 67 68 68 69 71 74 81 89 Chapter 6: Gmail and Greasemonkey . . . . . . . . . . . . . . . . . . . . 91 What Is Greasemonkey?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 The Userscripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 Displaying Bloglines Within Gmail . . . . . . . . . . . . . . . . . . . . . . 92 How It Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 Add a Delete Button. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 GmailSecure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 MailtoComposeInGmail . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 Other Userscripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 Mark Read Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 Multiple Signatures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 Hide Invites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 Random Signatures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 And Now . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 Contents Chapter 7: Gmail Libraries . . . . . . . . . . . . . . . . . . . . . . . . . 117 PHP — Gmailer . . . . . . . . . . . . . . . . . . Getting and Installing the Library. . . . . . How to Use It . . . . . . . . . . . . . . . . Perl — Mail::Webmail::Gmail . . . . . . . . . . . Getting and Installing the Library. . . . . . Using the Library . . . . . . . . . . . . . . Python — Libgmail . . . . . . . . . . . . . . . . Getting and Installing the Library. . . . . . How to Use It . . . . . . . . . . . . . . . . Reading the First Message in the Inbox . . . Setting Yourselves Up for the Remaining Chapters And Now . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 118 119 127 127 128 131 131 132 134 135 136 Chapter 8: Checking for Mail . . . . . . . . . . . . . . . . . . . . . . . . 137 The Basics in Perl . . . . . . . . . . . . . . . . . . The Basics in PHP . . . . . . . . . . . . . . . . . . The Basics in Python . . . . . . . . . . . . . . . . . Building on the Basics . . . . . . . . . . . . . . . . New Mail Count in RSS . . . . . . . . . . . New Mail Count to AOL Instant Messenger . And Now . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 139 140 142 142 144 149 Chapter 9: Reading Mail . . . . . . . . . . . . . . . . . . . . . . . . . . 151 Reading Mail with Perl. . . . . . . . . . . . . . . . . . . The Basics . . . . . . . . . . . . . . . . . . . . . . Accessing All the Data of a Message . . . . . . . . Listing the Mail and Displaying a Chosen Message Dealing with Attachments. . . . . . . . . . . . . . Making an RSS Feed of Your Inbox . . . . . . . . . And Now . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 151 152 153 155 155 159 Chapter 10: Sending Mail. . . . . . . . . . . . . . . . . . . . . . . . . . 161 Sending Mail with Gmail SMTP . . . . . . . . . . . . . . . . . . . . . . . . . . 161 Sending Mail with Perl . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 And Now . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 Part III: Conquering Gmail 167 Chapter 11: Dealing with Labels . . . . . . . . . . . . . . . . . . . . . . 169 Listing the Existing Labels . Setting New Labels. . . . . Creating a New Label Removing Labels . . . . . . And Now . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 173 175 175 176 xiii xiv Contents Chapter 12: Addressing Addresses . . . . . . . . . . . . . . . . . . . . . 177 The Contacts List . . . . . . . . Importing Contacts. . . . . . . . Showing Your Current Contacts . Exporting Contacts. . . . . . . . And Now . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 178 180 181 182 Chapter 13: Building an API from the HTML-Only Version of Gmail . . . 183 A First Look at the HTML Version . Introducing Basic Scraping . . . . . . HTML::TokeParser . . . . . . Parsing the Inbox . . . . . . . Retrieving the Individual Page. Dealing with Threads . . . . . Dealing with Other Folders . . And Now . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 186 186 188 192 195 195 196 Chapter 14: Exporting Your Mail . . . . . . . . . . . . . . . . . . . . . . 197 Exporting as a Massive Text File . Converting to Mbox . . . . . . . Appending to IMAP . . . . . . . And Now . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 199 200 201 Chapter 15: Using Gmail to . . . . . . . . . . . . . . . . . . . . . . . . . 203 Using Gmail as a To-Do List . . . . . . . . . . Using Filters . . . . . . . . . . . . . . . . Using gmtodo . . . . . . . . . . . . . . . Using Gmail to Find Information in RSS Feeds. Using Gmail to Find Torrent Files . . . . Using Gmail as a Notepad . . . . . . . . . . . . Using Gmail as a Spam Filter . . . . . . . . . . An Even Simpler Way of Doing It . . . . Using Gmail as Storage for a Photo Gallery . . . And Now . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 203 205 205 206 207 209 210 210 211 Chapter 16: Using GmailFS . . . . . . . . . . . . . . . . . . . . . . . . . 213 The Underlying Idea . . . . . . . . . . . . . . . . . Installing GmailFS . . . . . . . . . . . . . . . . . . The Correct Python . . . . . . . . . . . . . . Installing FUSE . . . . . . . . . . . . . . . . Installing Libgmail. . . . . . . . . . . . . . . Installing GmailFS . . . . . . . . . . . . . . Using GmailFS . . . . . . . . . . . . . . . . . . . . Mounting GmailFS from the Command Line Mounting GmailFS from fstab . . . . . . . . Passing Commands to the File System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 213 213 215 215 215 216 216 217 217 Contents How GmailFS Works . . . . . . . . . . . What Makes Up a File? . . . . . . . Representing All of This in E-Mail . The Actual Data in Action . . . . . And Now . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 218 220 220 221 Appendix: Long Code Listings . . . . . . . . . . . . . . . . . . . . . . . 223 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 xv Acknowledgments Books of this nature are tremendously difficult to write. Without support from Google (we didn’t ask, admittedly) and with Gmail being in perpetual Beta throughout the writing process, we often found ourselves with chapters being made obsolete overnight. Deadlines passed, were rescheduled, passed again. Editors wept salt tears. Publishers, that sainted breed, were patient and handsome and generally lovely. Chris Webb and Brian Herrmann, both of the Wiley clan, stood by the project so faithfully that their names will be forever legend. Men of the Far North will sing songs to their honor. Justin Blanton, the technical editor, managed to combine a Law Degree with the task: there’s not enough beer in the world to pay him back. Thanks to all of them, and everyone else at Wiley.
- Xem thêm -

Tài liệu liên quan